Turning a signature-changing decorator into a signature-preserving one

2009-02-13 Thread Gustavo Narea
Hello, everybody. I have this signature-changing decorator which I want to turn into a signature-preserving one. Here's my try , but I get this error: http://paste

Re: Turning a signature-changing decorator into a signature-preserving one

2009-02-14 Thread Gustavo Narea
On Feb 14, 6:38 am, Michele Simionato wrote: > On Feb 14, 12:56 am, Gustavo Narea wrote: > > > > > Hello, everybody. > > > I have this signature-changing decorator > > <http://paste.chrisarndt.de/paste/15aac02a90094a41a13a1b9b85a14dd6> > > which I >

Re: Turning a signature-changing decorator into a signature-preserving one

2009-02-16 Thread Gustavo Narea
On Feb 14, 3:27 pm, Michele Simionato wrote: > I lack the context to see how this could be fixed in your case, but > this a not a show stopper, you can just keep the original decorator > and forget about making itsignature preserving. I'm sorry for the possibly dumb question, but how can I do tha

Re: Turning a signature-changing decorator into a signature-preserving one

2009-02-16 Thread Gustavo Narea
On Feb 16, 3:56 pm, Michele Simionato wrote: > On Feb 16, 3:50 pm, Gustavo Narea wrote: > > > On Feb 14, 3:27 pm, Michele Simionato > > wrote: > > > > I lack the context to see how this could be fixed in your case, but > > > this a not a show stopper, y

Re: Turning a signature-changing decorator into a signature-preserving one

2009-02-16 Thread Gustavo Narea
On Feb 16, 4:18 pm, Michele Simionato wrote: > Yes, I am saying don't mess with the internal mechanism of Pylons and > leave it as > it was. Or was it broken from the beginning? The only reason I see for > you > to touch those things is if you are a Pylons core developer. It was broken from the b

Re: Turning a signature-changing decorator into a signature-preserving one

2009-02-16 Thread Gustavo Narea
On Feb 16, 4:40 pm, Michele Simionato wrote: > > It was broken from the beginning on Pylons. > > > I'm a TurboGears 2 core developer, and TurboGears is powered by Pylons > > as of version 2. The decorator has always worked in TurboGears because > > of the way TG finds the action arguments, but now

Re: Turning a signature-changing decorator into a signature-preserving one

2009-02-16 Thread Gustavo Narea
On Feb 16, 4:59 pm, Gustavo Narea wrote: > On Feb 16, 4:40 pm, Michele Simionato > wrote: > > > > > > It was broken from the beginning on Pylons. > > > > I'm a TurboGears 2 core developer, and TurboGears is powered by Pylons > > > as of versio

Re: Turning a signature-changing decorator into a signature-preserving one

2009-02-16 Thread Gustavo Narea
On Feb 16, 5:18 pm, Michele Simionato wrote: > On Feb 16, 4:59 pm, Gustavo Narea wrote: > > > > > I've not seen anything special in Pylons or TurboGears 2 decorators, > > except that they are all functions that use the decorator package -- > > while my decora

Best way to evaluate boolean expressions from strings?

2009-04-27 Thread Gustavo Narea
Hello, everybody. I need to evaluate boolean expressions like "foo == 1" or "foo ==1 and (bar > 2 or bar == 0)" which are defined as strings (in a database or a plain text file, for example). How would you achieve this? These expressions will contain placeholders for Python objects (like "foo" an

Re: Best way to evaluate boolean expressions from strings?

2009-04-28 Thread Gustavo Narea
Thank you very much, Gabriela and Peter! I'm going for Pyparsing. :) -- Gustavo. -- http://mail.python.org/mailman/listinfo/python-list

Grandchildren of TestCase don't work

2008-08-19 Thread Gustavo Narea
;     testMethod = getattr(self, self._testMethodName) > AttributeError: 'TestDatabaseGrandChildTesting' object has no > attribute '_testMethodName' Isn't it possible to use grand-grandchildren of unittest.TestCase? Please use this file to reproduce it: http://paste.

Performance of list vs. set equality operations

2010-04-06 Thread Gustavo Narea
Hello! Could you please confirm whether my understanding of equality operations in sets and lists is correct? This is how I think things work, partially based on experimentation and the online documentation for Python: When you compare two lists, *every* element of one of the lists is compared ag

Re: Performance of list vs. set equality operations

2010-04-06 Thread Gustavo Narea
On Apr 6, 7:28 pm, Chris Colbert wrote: > the proof is in the pudding: > > In [1]: a = range(1) > > In [2]: s = set(a) > > In [3]: s2 = set(a) > > In [5]: b = range(1) > > In [6]: a == b > Out[6]: True > > In [7]: s == s2 > Out[7]: True > > In [8]: %timeit a == b > 1000 loops, best of 3: 2

Rich comparison methods don't work in sets?

2009-06-19 Thread Gustavo Narea
Hello, everyone. I've noticed that if I have a class with so-called "rich comparison" methods (__eq__, __ne__, etc.), when its instances are included in a set, set.__contains__/__eq__ won't call the .__eq__ method of the elements and thus the code below: """ obj1 = RichComparisonClass() obj2 = Ric

Re: Rich comparison methods don't work in sets?

2009-06-20 Thread Gustavo Narea
Hello again, everybody. Thank you very much for your responses. You guessed right, I didn't use the __hash__ method (and I forgot to mention that, sorry). And unfortunately, I think I can't make them hashable, because the objects are compared based on their attributes, which are in turn other kin

Re: Rich comparison methods don't work in sets?

2009-06-21 Thread Gustavo Narea
Hi, everyone. OK, I got it now! The value of the hash is not decisive, as __eq__ will still be called when the hashes match. It's like a filter, for performance reasons. It's really nice, I just tried it and it worked. Thank you very, very much!! Cheers, - Gustavo. -- http://mail.python.or