On Thu, Mar 09, 2017 at 09:04:05PM +0100, Jasper Spaans wrote:
> > 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?
> > """
> 
> Probeer het eens met functie3(functie2) -- dus zonder aanhalingstekens.
> Of als je per se iets met een string wil doen, functie3(locals()["functie2"]).

Ja, met `locals()["functienaam"]` als parameter kan ik wat het plan is.
Dank je wel.


#!/usr/bin/env python

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):
        """ te gebruiken als "help tekst printer." """
        print functienaam.__doc__
        return

if __name__ == "__main__":
        functie3(locals()['functie2'])
        # toepassing
        user_input = 'functie2'
        functie3(locals()[user_input])

de_gewenste_output = """
functie die doc string van andere functie print
functie die doc string van andere functie print
"""

# l l


Groeten
Geert Stappers
-- 
Leven en laten leven
_______________________________________________
Python-nl mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-nl

Antwoord per e-mail aan