Function attributes again

Fernando Rodríguez spamers at must.die
Wed May 30 12:15:06 EDT 2001


On Wed, 30 May 2001 17:08:23 +0200, "Alex Martelli" <aleaxit at yahoo.com> wrote:

>"Fernando Rodríguez" <spamers at must.die> wrote in message
>news:h71ahtoc3gn0eft2se5obpoh5kpndqqbua at 4ax.com...
>> Hi!
>>
>> How can I check (from within a function) if it has attributes?  I
>> tried if __dict__ == None in the definition, but it doesn't work:
>>
>> def f(a, b):
>> z = 0
>> if __dict__ == None:
>> __dict__['c'] = 4
>
>You have to check for f.__dict__ instead:
Thanks! :-)





'Fernando



More information about the Python-list mailing list