Need help with Python scoping rules

kj no.email at please.post
Thu Aug 27 08:21:38 EDT 2009


In <02a6427a$0$15633$c3e8da3 at news.astraweb.com> Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:

>On Thu, 27 Aug 2009 09:09:21 +0200, Hendrik van Rooyen wrote:

>> On Wednesday 26 August 2009 17:45:54 kj wrote:
>>> In <02a54597$0$20629$c3e8da3 at news.astraweb.com> Steven D'Aprano
>> <steve at REMOVE-THIS-cybersource.com.au> writes:
>> 
>>> >Why are you defining a method without a self parameter?
>>>
>>> Because, as I've explained elsewhere, it is not a method: it's a
>>> "helper" function, meant to be called only once, within the class
>>> statement itself.
>> 
>> If the sole purpose of the function is to be used to define what will
>> become a constant, why do you not just calculate the constant on your
>> calculator, or at the interactive prompt, and assign it to the
>> attribute, and be done with it?
>> 
>> Why waste run time recalculating every time the programme is called?

>What you are calculating might actually be quite complicated to enter as 
>a literal.

Thank you!

kynn



More information about the Python-list mailing list