Re: Can't get items out of a set?

2008-03-08 Thread Cruxic
On Mar 8, 7:32 am, Alan Isaac <[EMAIL PROTECTED]> wrote: > Cruxic wrote: > > people = set( [Person(1, 'Joe'), Person(2, 'Sue')] ) > > ... > > p = people.get_equivalent(2) #method doesn't exist as far as I know > > print p.name #prints S

Re: Can't get items out of a set?

2008-03-08 Thread Cruxic
On Mar 7, 11:20 am, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > [Cruxic] > > > Is it possible to get an object out of a set() given another object > > that has the same hash code and equality (__hash__() and __eq__() > > return the same)? > > Yes, but it r

Can't get items out of a set?

2008-03-07 Thread Cruxic
quivalent(2) #method doesn't exist as far as I know print p.name #prints Sue I'm not sure if the above code compiles but I hope you get the idea. Is it possible? Much Thanks. - Cruxic -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible to tack on random stuff to objects?

2008-02-12 Thread Cruxic
That does the trick. Thanks, Bruno. On Feb 12, 1:23 am, Bruno Desthuilliers wrote: > Cruxic a écrit : > > > Is it possible to tack on arbitrary attributes to a python object? > > Depends on the object's class. In the common case it's possible but > there are

Possible to tack on random stuff to objects?

2008-02-11 Thread Cruxic
Is it possible to tack on arbitrary attributes to a python object? For example: s = 'nice 2 meet you' s.isFriendly = True In the above example Python complains on the second line with: AttributeError: 'str' object has no attribute 'isFriendly' Is there another way? -- http://mail.python.org/ma