Newbie Question: Giving names to Elements of List/Tuple/Dict
Duncan Booth
duncan at rcp.co.uk
Fri Nov 29 10:53:45 EST 2002
More information about the Python-list mailing list
Fri Nov 29 10:53:45 EST 2002
- Previous message (by thread): Newbie Question: Giving names to Elements of List/Tuple/Dict
- Next message (by thread): Newbie Question: Giving names to Elements of List/Tuple/Dict
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Oren Tirosh <oren-py-l at hishome.net> wrote in news:mailman.1038579643.30978.python-list at python.org: >> My question now is, how can I assign names to the elements? Or is there >> a better way of doing this? > > Many Python programmers use an empty class for this: > Or a nearly empty class if you want to be lazier when creating the objects: >>> class Struct: def __init__(self, **args): vars(self).update(args) >>> s = Struct(name="Duncan", email="me at somewhere") >>> s.name 'Duncan' >>> s.email 'me at somewhere' >>>
- Previous message (by thread): Newbie Question: Giving names to Elements of List/Tuple/Dict
- Next message (by thread): Newbie Question: Giving names to Elements of List/Tuple/Dict
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list