Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Best place for a function?

Reply
Thread Tools

Re: Best place for a function?

 
 
Inyeol Lee
Guest
Posts: n/a
 
      03-09-2007
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
 
Reply With Quote
 
 
 
 
Bruno Desthuilliers
Guest
Posts: n/a
 
      03-11-2007
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 ?
 
Reply With Quote
 
 
 
 
Inyeol Lee
Guest
Posts: n/a
 
      03-13-2007
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Best Place Of Training for MCSE Dave Marden Microsoft Certification 1 04-10-2006 03:49 PM
Best place to jack off on the internet Consultant MCSD 0 08-31-2004 06:52 AM
Re: Best place for exchanging $ to Euro? mrtravelkay Cisco 0 04-23-2004 11:50 PM
Where is best place for best price buying Mobo & CPU combo? Arawak Computer Support 6 02-05-2004 04:46 PM
Best place to hold dataset between postbacks? Gandalf ASP .Net 1 07-17-2003 11:28 PM



Advertisments