setting variables in outer functions
Tommy Nordgren
tommy.nordgren at comhem.se
Mon Oct 29 17:18:20 EDT 2007
More information about the Python-list mailing list
Mon Oct 29 17:18:20 EDT 2007
- Previous message (by thread): python logging config file doesn't allow filters?
- Next message (by thread): setting variables in outer functions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 29 okt 2007, at 21.59, brad wrote: > Tommy Nordgren wrote: >> Given the following: >> def outer(arg) >> avar = '' >> def inner1(arg2) >> # How can I set 'avar' here ? > > Try this... works for me... maybe not for you? > > def outer(avar=False): > print avar > if avar == True: > return > > def inner(avar=True): > print avar > return avar > > outer(inner()) > > outer() > -- > http://mail.python.org/mailman/listinfo/python-list This is not a general solution to this problem. What works, though, (I just thought of it) is to do the following: def outer(arg): adict = {} def inner1(arg): adict['avar'] = 'something' #now the value set by inner1 is available to other nested functions ------ What is a woman that you forsake her, and the hearth fire and the home acre, to go with the old grey Widow Maker. --Kipling, harp song of the Dane women Tommy Nordgren tommy.nordgren at comhem.se
- Previous message (by thread): python logging config file doesn't allow filters?
- Next message (by thread): setting variables in outer functions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list