I found following solution to the problem.
Instead of assigning id directly to __hash__ it has to be wrapped with an
instancemethod object. It is somehow strange that this doesn't happen
automatically and it is also strange that instancemethod isn't exposed in
the type module. However it can easi
Fredrik Lundh wrote:
>
> >>> id
>
> >>> lambda x: id(x)
> at 0x00C07C30>
>
> any special reason why you're not using Python to write Python programs,
> btw?
>
>
I am aware that id is a built in function why shouldn't i use it?
Replaceing lambda with id was intended as an performance hack
castironpi wrote:
>
> The answer is fairly technical. For member functions to be bound to
> instances, they are required to have a __get__ method (which takes
> instance and owner as parameters). 'id' does not.
>
> (Why does 'id' not have a __get__ method?)
>
> By contrast,
>
set.add
>
Hello!
Executing following little program gives me an TypeError.
What makes me wonder is that foo does get an argument passed while bar
doesn't. Can anyone explain why??
Thanks
Ruediger
class foo(list):
__hash__ = lambda x: id(x)
class bar(list):
__hash__ = id
_s_ = set(
Paul Hankin wrote:
> This is better written using takewhile...
> itertools.takewhile(lambda x: x != value, iterable)
>
> But if you really need to reinvent the wheel, perhaps this is simpler?
>
> def test(iterable, value, op=operator.ne):
> for x in iterable:
> if not op(x, value):
urikaluzhny wrote:
> It seems that I rather frequently need a list or iterator of the form
> [x for x in <> while <>]
> And there is no one like this.
> May be there is another short way to write it (not as a loop). Is
> there?
> Thanks
I usually have the same problem and i came up with an soluti
[EMAIL PROTECTED] wrote:
> Hi Rüdiger,
>
> Thanks for your message. I liked your approach and I've been trying
> something along exactly these sorts of lines, but I have a few
> problems and queries.
>
> The first problem is that the id of the frame object can be re-used,
> so for example this
[EMAIL PROTECTED] wrote:
> Hi all,
>
> I'm part of a small team writing a Python package for a scientific
> computing project. The idea is to make it easy to use for relatively
> inexperienced programmers. As part of that aim, we're using what we're
> calling 'magic functions', and I'm a little b
maybe following recipe from activestate may be usefull.
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496960
http://sebulba.wikispaces.com/recipe+thread2
--
http://mail.python.org/mailman/listinfo/python-list