With or Using
Roman Suzi
rnd at onego.ru
Tue May 1 02:50:50 EDT 2001
On Tue, 1 May 2001, Greg Ewing wrote:
><tim at worthy.demon.co.uk> wrote:
>> Rather than typing jim each time,
>> jim.born=1960
>> jim.haircolour='Brown'
>> jim.eyecolour='Green'
>
>def with(subject, **args):
> for attr, value in args.items():
> setattr(subject, attr, value)
Or, if subject allow it:
def with(subject, **args):
subject.__dict__(args) # or special method could be used
>
>jim = person()
>with(jim,
> born = 1960,
> haircolour = 'Brown',
> eyecolour = 'Green')
>
>
Sincerely yours, Roman Suzi
--
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Tuesday, May 01, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "Caterpillar: Scratching post." _/
More information about the Python-list
mailing list