Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: Best place for a function? (http://www.velocityreviews.com/forums/t482984-re-best-place-for-a-function.html)

Inyeol Lee 03-09-2007 07:27 PM

Re: Best place for a function?
 
On Wed, Mar 07, 2007 at 05:27:04PM -0500, Sergio Correia wrote:
> I'm writing a class, where one of the methods is kinda complex. The
> method uses a function which I know for certain will not be used
> anywhere else. This function does not require anything from self, only
> the args passed by the method.
>
> Where should I put the function?


Use staticmethod. It's a normal function with class namespace.

--Inyeol

Bruno Desthuilliers 03-11-2007 05:36 PM

Re: Best place for a function?
 
Inyeol Lee a écrit :
> On Wed, Mar 07, 2007 at 05:27:04PM -0500, Sergio Correia wrote:
>
>>I'm writing a class, where one of the methods is kinda complex. The
>>method uses a function which I know for certain will not be used
>>anywhere else. This function does not require anything from self, only
>>the args passed by the method.
>>
>>Where should I put the function?

>
>
> Use staticmethod. It's a normal function with class namespace.


What do you think the OP will gain from making a simple helper function
a staticmethod ? Apart from extra lookup time ?

Inyeol Lee 03-13-2007 03:43 PM

Re: Best place for a function?
 
On Sun, Mar 11, 2007 at 06:36:02PM +0100, Bruno Desthuilliers wrote:
> Inyeol Lee a écrit :
> > On Wed, Mar 07, 2007 at 05:27:04PM -0500, Sergio Correia wrote:
> >
> >>I'm writing a class, where one of the methods is kinda complex. The
> >>method uses a function which I know for certain will not be used
> >>anywhere else. This function does not require anything from self, only
> >>the args passed by the method.
> >>
> >>Where should I put the function?

> >
> >
> > Use staticmethod. It's a normal function with class namespace.

>
> What do you think the OP will gain from making a simple helper function
> a staticmethod ? Apart from extra lookup time ?


Namespace.
Plz check this old thread. It explains some usage of staticmethod.
http://mail.python.org/pipermail/pyt...ry/190258.html

--Inyeol


All times are GMT. The time now is 12:36 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.