Re: @classmethod question

2008-04-30 Thread Bruno Desthuilliers
Scott SA a écrit : On 4/24/08, Bruno Desthuilliers ([EMAIL PROTECTED]) wrote: It is a series of convenience methods, in this case I'm interacting with a database via an ORM (object-relational model). out of curiosity : which one ? I'm rapidly becoming a "django junkie"^TM (snip) Then if

Re: @classmethod question

2008-04-29 Thread Ivan Illarionov
On Tue, 29 Apr 2008 14:30:08 -0600, Scott SA wrote: > With that said, your reply is amazingly helpful in my quest to > understand python, Django, etc. Django is the ORM I referred to, so the > material you have written helps explain a few things. This was my intention. Django ORM uses Pyhton clas

Re: @classmethod question

2008-04-29 Thread Scott SA
On 4/23/08, Ivan Illarionov ([EMAIL PROTECTED]) wrote: >On 24 ???, 07:27, Scott SA <[EMAIL PROTECTED]> wrote: >> I'm using the @classemethod decorator for some convenience methods and for > >It would make sense to separate instance-level and class-level >behaviour with additional 'objects' namesp

Re: @classmethod question

2008-04-29 Thread Scott SA
On 4/24/08, Bruno Desthuilliers ([EMAIL PROTECTED]) wrote: >> It is a series of convenience methods, in this case I'm interacting >> with a database via an ORM (object-relational model). > >out of curiosity : which one ? I'm rapidly becoming a "django junkie"^TM >> I want the ability >> to call

Re: @classmethod question

2008-04-24 Thread M.-A. Lemburg
On 2008-04-24 05:27, Scott SA wrote: Hi, I'm using the @classemethod decorator for some convenience methods and for some reason, either mental block or otherwise, can't seem to figure out how to elegantly detect if the call is from an instance or not. Here's the problem: Within the class defi

Re: @classmethod question

2008-04-24 Thread Arnaud Delobelle
Scott SA <[EMAIL PROTECTED]> writes: A side note > class RecipieClass: Recipe is a more widespread spelling, I believe. Moreover it is the convention in python that only class names are capitalized, so you don't need to append a 'Class'. class Recipe: ... clafoutis = Recipe(

Re: @classmethod question

2008-04-24 Thread Bruno Desthuilliers
Scott SA a écrit : Hi, I'm using the @classemethod decorator for some convenience methods and for some reason, either mental block or otherwise, can't seem to figure out how to elegantly detect if the call is from an instance or not. Well, the point is that a classmethod *always* receive the cla

Re: @classmethod question

2008-04-23 Thread Gabriel Genellina
En Thu, 24 Apr 2008 00:27:13 -0300, Scott SA <[EMAIL PROTECTED]> escribió: I'm using the @classemethod decorator for some convenience methods and for some reason, either mental block or otherwise, can't seem to figure out how to elegantly detect if the call is from an instance or not. Here'

Re: @classmethod question

2008-04-23 Thread Ivan Illarionov
On 24 апр, 07:27, Scott SA <[EMAIL PROTECTED]> wrote: > Hi, > > I'm using the @classemethod decorator for some convenience methods and for > some reason, either mental block or otherwise, can't seem to figure out how > to elegantly detect if the call is from an instance or not. > > Here's the pro

@classmethod question

2008-04-23 Thread Scott SA
Hi, I'm using the @classemethod decorator for some convenience methods and for some reason, either mental block or otherwise, can't seem to figure out how to elegantly detect if the call is from an instance or not. Here's the problem: Within the class definition, 'isinstance' has nothing to co

Re: instance + classmethod question

2005-12-12 Thread Mike Meyer
Laszlo Zsolt Nagy <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >>Laszlo Zsolt Nagy <[EMAIL PROTECTED]> writes: >>>Is it possible to tell, which instance was used to call the >>>classmethod that is currently running? >>Ok, I read through what got to my nntp server, and I'm still >>completely conf

Re: instance + classmethod question

2005-12-12 Thread Laszlo Zsolt Nagy
Mike Meyer wrote: >Laszlo Zsolt Nagy <[EMAIL PROTECTED]> writes: > > >>Is it possible to tell, which instance was used to call the >>classmethod that is currently running? >> >> > >Ok, I read through what got to my nntp server, and I'm still >completely confused. > >A class method isn't nece

Re: instance + classmethod question

2005-12-11 Thread Mike Meyer
Laszlo Zsolt Nagy <[EMAIL PROTECTED]> writes: > Is it possible to tell, which instance was used to call the > classmethod that is currently running? Ok, I read through what got to my nntp server, and I'm still completely confused. A class method isn't necessarilry called by an instance. That's wh

Re: instance + classmethod question

2005-12-11 Thread Steven Bethard
Laszlo Zsolt Nagy wrote: > In my methods, most code is about string manipulation and calling other > classmethods. > There are only a few places where I can use an instance, but it is not > required. > I would like to reuse as most code as possible, so I do not want to > create two different > m

Re: instance + classmethod question

2005-12-11 Thread Laszlo Zsolt Nagy
Hello Steven, I already implemented this using the form @classmethod def methodname(cls,other_params,self=None) but your example code looks so neat! This is exactly what I needed. :-) In my methods, most code is about string manipulation and calling other classmethods. There are only a few

Re: instance + classmethod question

2005-12-11 Thread Steven Bethard
Laszlo Zsolt Nagy wrote: > > Hello, > > Is it possible to tell, which instance was used to call the classmethod > that is currently running? > [snip] > > processor = SQLProcessors.StdOutProcessor() # Print to stdout > PostgreSQLConnection.process_create_tables(processor,dbdef) # This > soul

instance + classmethod question

2005-12-11 Thread Laszlo Zsolt Nagy
Hello, Is it possible to tell, which instance was used to call the classmethod that is currently running? Background: I have a class called DatabaseConnection and it has a classmethod called process_create_tables. This method should create some database tables defined by a database definiti