On Fri, 23 Nov 2012 09:52:25 +0100, Peter Otten wrote:
> Steven D'Aprano wrote:
>> http://code.activestate.com/recipes/577030/
>
> Am I reading that right that you don't invoke method() as
> MyClass.method()?
No. I give an example and explicitly state:
You can use this class without instan
Steven D'Aprano wrote:
> On Thu, 22 Nov 2012 16:51:27 +0100, Peter Otten wrote:
>
>> Marc Aymerich wrote:
>>
>>> Hi,
>>>
>>> I want to create a method within a class that is able to accept either
>>> a class or an instance.
> [...]
>> Why would you overload a method that way?
>
>
> The use-ca
On Thu, 22 Nov 2012 16:51:27 +0100, Peter Otten wrote:
> Marc Aymerich wrote:
>
>> Hi,
>>
>> I want to create a method within a class that is able to accept either
>> a class or an instance.
[...]
> Why would you overload a method that way?
The use-case I have is that I have a number of classe
On Thursday, November 22, 2012 5:26:59 PM UTC+1, Dave Angel wrote:
> On 11/22/2012 11:12 AM, Thomas Bach wrote:
>
> > On Thu, Nov 22, 2012 at 10:52:56AM -0500, Dave Angel wrote:
>
> >> On 11/22/2012 10:14 AM, Marc Aymerich wrote:
>
> >>> I want to create a method within a class that is able to a
On Thursday, November 22, 2012 4:51:30 PM UTC+1, Peter Otten wrote:
> Marc Aymerich wrote:
>
>
>
> > Hi,
>
> >
>
> > I want to create a method within a class that is able to accept either a
>
> > class or an instance.
>
> >
>
> > class MyClass(object):
>
> > @magic_decorator
>
> >
On 11/22/2012 11:12 AM, Thomas Bach wrote:
> On Thu, Nov 22, 2012 at 10:52:56AM -0500, Dave Angel wrote:
>> On 11/22/2012 10:14 AM, Marc Aymerich wrote:
>>> I want to create a method within a class that is able to accept either a
>>> class or an instance.
>>>
>> I haven't tried it, but how about i
On Thu, Nov 22, 2012 at 10:52:56AM -0500, Dave Angel wrote:
> On 11/22/2012 10:14 AM, Marc Aymerich wrote:
> > I want to create a method within a class that is able to accept either a
> > class or an instance.
> >
>
> I haven't tried it, but how about if you do a @classmethod decorator,
> and the
On 11/22/2012 10:14 AM, Marc Aymerich wrote:
> Hi,
>
> I want to create a method within a class that is able to accept either a
> class or an instance.
>
> class MyClass(object):
> @magic_decorator
> def method(param):
> # param can be MyClass (cls) or an instance of MyClass (self)
Marc Aymerich wrote:
> Hi,
>
> I want to create a method within a class that is able to accept either a
> class or an instance.
>
> class MyClass(object):
> @magic_decorator
> def method(param):
> # param can be MyClass (cls) or an instance of MyClass (self)
>
> so I can do some
Hi,
I want to create a method within a class that is able to accept either a class
or an instance.
class MyClass(object):
@magic_decorator
def method(param):
# param can be MyClass (cls) or an instance of MyClass (self)
so I can do something like:
instance = MyClass()
MyClass.
10 matches
Mail list logo