Re: getattr() on nested functions?

2008-08-21 Thread castironpi
On Aug 21, 10:14 am, Bruno Desthuilliers wrote: > Gabriel Rossetti a écrit : > > > > > Bruno Desthuilliers wrote: > >> Gabriel Rossetti a écrit : > >>> Terry Reedy wrote: > >> (snip) > Unlike the class approach, this requires recreating the constant > functions and dict with each call to

Re: getattr() on nested functions?

2008-08-21 Thread Bruno Desthuilliers
Gabriel Rossetti a écrit : Bruno Desthuilliers wrote: Gabriel Rossetti a écrit : Terry Reedy wrote: (snip) Unlike the class approach, this requires recreating the constant functions and dict with each call to _test. Quick to write but a bit 'dirty', in my opinion. Another standard idiom is

Re: getattr() on nested functions?

2008-08-21 Thread Gabriel Rossetti
Bruno Desthuilliers wrote: Gabriel Rossetti a écrit : Terry Reedy wrote: (snip) Unlike the class approach, this requires recreating the constant functions and dict with each call to _test. Quick to write but a bit 'dirty', in my opinion. Another standard idiom is to set up the constants ou

Re: getattr() on nested functions?

2008-08-21 Thread Bruno Desthuilliers
Gabriel Rossetti a écrit : Terry Reedy wrote: (snip) Unlike the class approach, this requires recreating the constant functions and dict with each call to _test. Quick to write but a bit 'dirty', in my opinion. Another standard idiom is to set up the constants outside the function: def re

Re: getattr() on nested functions?

2008-08-21 Thread Gabriel Rossetti
Terry Reedy wrote: Gabriel Rossetti wrote: Bruno Desthuilliers wrote: Gabriel Rossetti a écrit : I thought that since functions are objects, that I could obtain it's nested functions. Well, there's probably a very hackish way, but it's not worth the pain. What Bruno meant here, I belie

Re: getattr() on nested functions?

2008-08-20 Thread Terry Reedy
Gabriel Rossetti wrote: Bruno Desthuilliers wrote: Gabriel Rossetti a écrit : I thought that since functions are objects, that I could obtain it's nested functions. Well, there's probably a very hackish way, but it's not worth the pain. What Bruno meant here, I believe, is that there i

Re: getattr() on nested functions?

2008-08-20 Thread Gabriel Rossetti
Bruno Desthuilliers wrote: Gabriel Rossetti a écrit : Hello, I can't get getattr() to return nested functions, Of course. Nested functions are not attributes of their container function. Ok I tried this : >>> def toto(): ... def titi(): ... pass ... f = getattr(toto

Re: getattr() on nested functions?

2008-08-20 Thread Gabriel Rossetti
Gabriel Genellina wrote: En Wed, 20 Aug 2008 05:34:38 -0300, Gabriel Rossetti <[EMAIL PROTECTED]> escribi�: I can't get getattr() to return nested functions, I tried this : >>> def toto(): ... def titi(): ... pass ... f = getattr(toto, "titi") ... print str(f) ... >>

Re: getattr() on nested functions?

2008-08-20 Thread Bruno Desthuilliers
Gabriel Rossetti a écrit : Hello, I can't get getattr() to return nested functions, Of course. Nested functions are not attributes of their container function. I tried this : >>> def toto(): ... def titi(): ... pass ... f = getattr(toto, "titi") ... print str(f) ...

Re: getattr() on nested functions?

2008-08-20 Thread Gabriel Genellina
En Wed, 20 Aug 2008 05:34:38 -0300, Gabriel Rossetti <[EMAIL PROTECTED]> escribi�: I can't get getattr() to return nested functions, I tried this : >>> def toto(): ... def titi(): ... pass ... f = getattr(toto, "titi") ... print str(f) ... >>> toto() Traceback (most

Re: getattr() on nested functions?

2008-08-20 Thread Hrvoje Niksic
Gabriel Rossetti <[EMAIL PROTECTED]> writes: > I can't get getattr() to return nested functions, I tried this : > def toto(): > ... def titi(): > ... pass > ... f = getattr(toto, "titi") > ... print str(f) > ... toto() > Traceback (most recent call last): > File

getattr() on nested functions?

2008-08-20 Thread Gabriel Rossetti
Hello, I can't get getattr() to return nested functions, I tried this : >>> def toto(): ... def titi(): ... pass ... f = getattr(toto, "titi") ... print str(f) ... >>> toto() Traceback (most recent call last): File "", line 1, in File "", line 4, in toto AttributeError