Suggestions for good programming practices?

Aahz aahz at pythoncraft.com
Tue Jun 25 12:31:08 EDT 2002


In article <3D18868A.4050002 at mxm.dk>, Max M  <maxm at mxm.dk> wrote:
>
>You can also make it even more general:
>
>class MyData:
>
>     def __init__(self, **args):
>         self.__dict__.update(args)
>
>d = MyData(firstName='Max M', lastName='Rasmussen')

My preference is for

class MyData:
    pass

d = MyData()
d.firstName = None
d.lastName = 'Aahz'

At the very least, I think you ought to rewrite your example as

d = MyData(
    firstName = 'Max M',
    lastName = 'Rasmussen
    )
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Project Vote Smart: http://www.vote-smart.org/



More information about the Python-list mailing list