Python evangelists unite!

Peter Milliken peter.milliken at gtech.com
Mon Dec 3 23:39:49 EST 2001


Sorry Jim, you are one up on me here, I have never had to face this
situation. Thanks for the tip. Could you provide a real example of where you
might want this? (if it isn't too long to give! :-)). You have made me
curious.



<James_Althoff at i2.com> wrote in message
news:mailman.1007079579.26398.python-list at python.org...
>
> Peter Milliken wrote:
> >There is no real justification that works for these "features" of
python -
>
> OTOH, there *are* plenty of good *reasons* for them.
>
> Consider "adding attributes to instances".  Languages that don't support
> this feature directly require some kind of a workaround since this is
> something that one simply needs to do from time to time.  A typical
> workaround is to define, as part of a class's definition, a catch-all
> property whose value is a hashtable.  Clients add "instance-specific"
> attributes to a given instance "on the fly" by adding name-value pairs to
> the instance's hashtable.  Java/Swing's JComponent (with its
> putClientProperty and getClientProperty methods) is a good example of this
> type of workaround.
>
> Jim
>
>
>





More information about the Python-list mailing list