Re: [Python-Dev] Making staticmethod objects callable?

2006-03-16 Thread Nicolas Fleury
Guido van Rossum wrote: There's no need to change Python so that people coming from other languages won't make silly mistakes, is there? Is that really a mistake... Yes, it's a mistake since staticmethod is a descriptor, but isn't it in a sense an implementation detail, particularly for a

Re: [Python-Dev] Making staticmethod objects callable?

2006-03-15 Thread Nicolas Fleury
Armin Rigo wrote: Hi Nicolas, On Thu, Mar 02, 2006 at 01:55:03AM -0500, Nicolas Fleury wrote: (...) A use case is not hard to imagine, especially a private static method called only to build a class attribute. Uh. I do this all the time, and the answer is simply: don't make that a

Re: [Python-Dev] Making staticmethod objects callable?

2006-03-15 Thread Guido van Rossum
On 3/15/06, Nicolas Fleury [EMAIL PROTECTED] wrote: I think we all agree on this list that there's no point using a staticmethod for that use case. My suggestion was for some comp.lang.python people, a lot coming from other languages. Their reflex would be much more to define a staticmethod.

Re: [Python-Dev] Making staticmethod objects callable?

2006-03-12 Thread Armin Rigo
Hi Nicolas, On Thu, Mar 02, 2006 at 01:55:03AM -0500, Nicolas Fleury wrote: (...) A use case is not hard to imagine, especially a private static method called only to build a class attribute. Uh. I do this all the time, and the answer is simply: don't make that a staticmethod.

Re: [Python-Dev] Making staticmethod objects callable?

2006-03-12 Thread Thomas Wouters
On 3/12/06, Armin Rigo [EMAIL PROTECTED] wrote: Staticmethods are for the rare case where you needdynamic class-based dispatch but don't have an instance around.Actually, I would argue that's what classmethods are for, not staticmethods. You may not envision a desire for having the class in the

[Python-Dev] Making staticmethod objects callable?

2006-03-01 Thread Nicolas Fleury
Hi, I've posted this question on comp.lang.python, but nobody seems to conclude it is a bad idea, so I post it here. http://groups.google.com/group/comp.lang.python/browse_frm/thread/6082dae1deef9161/88bb8a26750dd8c6?lnk=raothl=en#88bb8a26750dd8c6 Basically, should staticmethods be made

Re: [Python-Dev] Making staticmethod objects callable?

2006-03-01 Thread Steven Bethard
On 3/1/06, Nicolas Fleury [EMAIL PROTECTED] wrote: Basically, should staticmethods be made callable so that the following would not raise an exception: class A: @staticmethod def foo(): pass bar = foo() There's workarounds, but it's really just about usability.

Re: [Python-Dev] Making staticmethod objects callable?

2006-03-01 Thread Nicolas Fleury
Steven Bethard wrote: My only (mild) concern is that if staticmethod is going to get a __call__, I think classmethod should probably get one too. Inside a class this doesn't make much sense: I agree, make sense or not, if @staticmethod def foo() and a simple def foo(self) can all be called

Re: [Python-Dev] Making staticmethod objects callable?

2006-03-01 Thread Guido van Rossum
On 3/1/06, Nicolas Fleury [EMAIL PROTECTED] wrote: The problem is that even after explaining descriptors (which IMHO can be a more advanced feature for newbies), you still need a workaround and you might end up with (or call __get__): class A: def foo(): pass bar = foo() foo

Re: [Python-Dev] Making staticmethod objects callable?

2006-03-01 Thread Nicolas Fleury
Guido van Rossum wrote: In which context did you find a need for defining a static method and calling it inside the class definition? I'm guessing that what you're playing dubious scoping games. I'm not. I almost never use staticmethod actually. I find them not very pythonic, in my humble