Hoi Geert,

Het moet zijn:

*functie3(functie2)*  # dus niet als string meegeven maar de functie zelf

of:

*functie3('functie2')*  # zoals je hebt

en dan:

*def functie3(functienaam):*
*    print(eval(functienaam).__doc__)*  # dit werkt altijd, maar eval is
mooi in je code

of:

*def functie3(functienaam):*
*    print(globals()[functienaam].__doc__)*  # dit werkt niet bij built-in
functies

Succes!

Groet,
Douwe.

w: www.karibu-online.nl
m: 06 5060 4033

2017-03-09 19:26 GMT+01:00 Geert Stappers <stapp...@stappers.nl>:

> #!/usr/bin/env python
>
> # Hoi,
>
> # lees a.u.b. verder ...
>
> def functie1():
>         """functie die zijn eigen doc string print"""
>         print functie1.__doc__
>         return
>
> def functie2():
>         """functie die doc string van andere functie print"""
>         print functie1.__doc__
>         return
>
> def functie3(functienaam):
>         """Wat ik zou willen"""
>         print functienaam.__doc__
>         return
>
> def functie4(functienaam):
>         """Mijn poging om voorbij 'str(object) -> string' te komen"""
>         print repr(functienaam.__doc__)
>         return
>
> if __name__ == "__main__":
>         functie1()
>         functie2()
>         functie3('functie2')
>         #functie4('functie2')
> output = """
> functie die zijn eigen doc string print
> functie die zijn eigen doc string print
> str(object) -> string
>
> Return a nice string representation of the object.
> If the argument is a string, the return value is the same object.
> """
>
> vraag = """
> Wat te doen om voorbij '''str(object) -> string
>
> Return a nice string representation of the object.
> If the argument is a string, the return value is the same object.
> ''' te komen?
> """
>
> # l l
>
>
> Groeten
> Geert Stappers
> --
> Leven en laten leven
> _______________________________________________
> Python-nl mailing list
> Python-nl@python.org
> https://mail.python.org/mailman/listinfo/python-nl
>
_______________________________________________
Python-nl mailing list
Python-nl@python.org
https://mail.python.org/mailman/listinfo/python-nl

Antwoord per e-mail aan