On Nov 17, 1:24 pm, Ethan Furman wrote:
> If you do need to sometimes call it from a method then still leave off
> the '@staticmethod', and give 'self' a default of 'None':
>
> def _get_next_id(self=None):
> [blah, blah, blah]
> return id
>
> user_id = IntField(required=Tru
On Thu, Nov 17, 2011 at 10:13 PM, Dotan Cohen wrote:
> I'm at work far from Idle.
Taken out of context, I'm sure your boss is pleased. :)
ChrisA
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Nov 17, 2011 at 09:37, Ian Kelly wrote:
> On Wed, Nov 16, 2011 at 11:44 PM, Dotan Cohen wrote:
>> Try this (untested):
>>
>> class C:
>> @staticmethod
>> def foo():
>> pass
>>
>> print "inside", C.foo, callable(C.foo)
>
> If you had tested this, you would have found that you g
Am 17.11.2011 03:30 schrieb Roy Smith:
When I run this (python 2.6.1):
class C:
@staticmethod
def foo():
pass
print "inside", foo, callable(foo)
print "outside", C.foo, callable(C.foo)
I get:
inside False
outside True
Right. The reason is that on an attribute acce
On Wed, Nov 16, 2011 at 11:44 PM, Dotan Cohen wrote:
> Try this (untested):
>
> class C:
> @staticmethod
> def foo():
> pass
>
> print "inside", C.foo, callable(C.foo)
If you had tested this, you would have found that you get a NameError,
since C is not yet bound inside the class bloc
On Thu, Nov 17, 2011 at 04:30, Roy Smith wrote:
> When I run this (python 2.6.1):
>
> class C:
> @staticmethod
> def foo():
> pass
>
> print "inside", foo, callable(foo)
>
> print "outside", C.foo, callable(C.foo)
>
> I get:
>
> inside False
> outside True
>
> I don't understand.
> However, the fix is not as simple as merely making staticmethod objects
> callable. This was discussed at the 2011 language summit:
>
> http://www.boredomandlaziness.org/2011/03/python-language-summit-rough-notes.html
>
> See also this thread:
>
> http://mail.python.org/pipermail/python-dev/2011-
In article <4ec490ec$0$30003$c3e8da3$54964...@news.astraweb.com>,
Steven D'Aprano wrote:
> This has come up before.
>
> http://bytes.com/topic/python/answers/34396-static-method-object-not-callable
>
> http://bytes.com/topic/python/answers/462734-make-staticmethod-objects-callabl
> e
>
>
> H
On Wed, 16 Nov 2011 21:30:57 -0500, Roy Smith wrote:
> When I run this (python 2.6.1):
>
> class C:
> @staticmethod
> def foo():
> pass
> print "inside", foo, callable(foo)
>
> print "outside", C.foo, callable(C.foo)
>
> I get:
>
> inside False
> outside True
>
> I don'
Roy Smith wrote:
class User(Document):
@staticmethod
def _get_next_id():
[blah, blah, blah]
return id
user_id = IntField(required=True, default=_get_next_id)
If you don't call '_get_next_id()' from any class methods (in other
words, if you don't need to ever say 'se
In article
,
alex23 wrote:
> What you're effectively trying to do is use a class before it has been
> constructed to help construct itself.
>
> Just define it as a helper function before the class declaration.
Yes, this is the workaround I ended up with.
--
http://mail.python.org/mailman/lis
On Nov 17, 12:30 pm, Roy Smith wrote:
> class C:
> @staticmethod
> def foo():
> pass
>
> print "inside", foo, callable(foo)
>
> print "outside", C.foo, callable(C.foo)
>
> I don't understand. Why is foo not callable inside of the class
> definition?
Consider this:
>>
12 matches
Mail list logo