With or Using
Konrad Hinsen
hinsen at cnrs-orleans.fr
Tue Apr 17 04:32:01 EDT 2001
Tim Howarth <tim at worthy.demon.co.uk> writes:
> Have a "with" or "using" block,
>
> with jim:
> born=1960
> haircolour='Brown'
> eyecolour='Green'
How about this syntax:
set_attributes(jim,
born = 1960,
haircolour = 'Brown',
eyecolour = 'Green')
All it takes is a short function definition:
def set_attributes(object, **arguments):
for name, value in arguments.items():
setattr(object, name, value)
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24
Rue Charles Sadron | Fax: +33-2.38.63.15.17
45071 Orleans Cedex 2 | Deutsch/Esperanto/English/
France | Nederlands/Francais
-------------------------------------------------------------------------------
More information about the Python-list
mailing list