Nested function scope problem
Antoon Pardon
apardon at forel.vub.ac.be
Fri Jul 28 14:36:53 EDT 2006
On 2006-07-28, Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:
> Hmmm, I've not followed the PEPs -- has any thought been given to
> unifying class/instance and dictionary notation so that
>
> a['b']
> and
> a.b
If that is what you want, you could use the following class:
class Unified(object):
def __init__(__, **kwargs):
for key,value in kwargs.items():
setattr(__, key, value)
def __getitem__(self, key):
return getattr(self, key)
def __setitem__(self, key, value):
setattr(self, key, value)
More information about the Python-list
mailing list