Re: how to tell a method is classmethod or static method or instance method

2012-02-15 Thread Nathan Rice
> And I'll take this opportunity to plug my dualmethod descriptor: > > http://code.activestate.com/recipes/577030-dualmethod-descriptor/ I use an analogous pattern in SQL Alchemy all the time (it's called hybridmethod/hybridproperty there). +1 to dualmethod, that pattern is great when you want a

Re: how to tell a method is classmethod or static method or instance method

2012-02-14 Thread Zheng Li
thank you. I know the second way works. but in my case, i need "method1" to be a class method, because I use it to create an object. I have a lot of classes that have "__init__" with 2 arguments -- self, and user id. usually, "SomeClass(user_id)" is used to create an object of "SomeClass", bu

Re: how to tell a method is classmethod or static method or instance method

2012-02-14 Thread Cameron Simpson
On 14Feb2012 13:13, Zheng Li wrote: | > On 13Feb2012 15:59, Zheng Li wrote: | > | how to tell a method is class method or static method or instance method? | > | > Maybe a better question is: | > under what circumstances do you need to figure this out? | | I can get "method1" of class "Test" b

Re: how to tell a method is classmethod or static method or instance method

2012-02-13 Thread Zheng Li
I can get "method1" of class "Test" by a = getattr(Test, "method1") and I also want know how to invoke it a() or a(Test()) BTW: I don't see what the problem is if I ask a question just because I am curious about it. On 2012/02/13, at 16:23, Cameron Simpson wrote: > On 13Feb2012 15

Re: how to tell a method is classmethod or static method or instance method

2012-02-13 Thread 88888 Dihedral
在 2012年2月13日星期一UTC+8下午4时03分24秒,Steven D'Aprano写道: > On Mon, 13 Feb 2012 15:59:27 +0900, Zheng Li wrote: > > > how to tell a method is class method or static method or instance > > method? > > That's a good question, with a subtle answer that depends on exactly what > you mean by the question. If

Re: how to tell a method is classmethod or static method or instance method

2012-02-13 Thread Steven D'Aprano
On Mon, 13 Feb 2012 15:59:27 +0900, Zheng Li wrote: > how to tell a method is class method or static method or instance > method? That's a good question, with a subtle answer that depends on exactly what you mean by the question. If you mean the object you get back from ordinary attribute acces

Re: how to tell a method is classmethod or static method or instance method

2012-02-12 Thread Cameron Simpson
On 13Feb2012 15:59, Zheng Li wrote: | how to tell a method is class method or static method or instance method? Maybe a better question is: under what circumstances do you need to figure this out? I'm actually quite serious here. Please outline what circumstances cause you to want to ask and

how to tell a method is classmethod or static method or instance method

2012-02-12 Thread Zheng Li
how to tell a method is class method or static method or instance method? -- http://mail.python.org/mailman/listinfo/python-list