tobiah wrote:
[snip]
> class Employee:
>
>       __init__(self, id):
>               self.id = id
>
> e = Employee(32445)
>
> ... later
>
>
> e.firstname = 'foo'
> e.lastname = 'bar'
>
> ... more as the information comes about.

Personally, I think that this is not a good solution. How would the
reader of your code guess what properties your object has? If you don't
like to write too many assignments, you can at least do something like
this:

def __init__(self, id, **kw):
    self.id = id
    for name in ['first_name', 'last_name', 'age', 'salary',
'whatever']:
        self.__dict__[name] = kw.get(name, None)

--
Maxim Sloyko

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to