eryksun
>
> Oh my. I don't think using the numbers spelled out makes it any
> better. I couldn't keep dict_thirty_four vs dict_sixty_five straight
> in my head to save my life.
It was just for fun. But by coincidence I was trolling the web and
some guy wanted to know if Python could change a numb
On Sun, Jun 23, 2013 at 10:38 PM, Jim Mooney wrote:
> What about class variables instead of globals?, I put this in the my
> lazy typer module, maker.py, which works fine to persist the numbers
> between function calls so I can increment them:
>
> class count:
> dict = list = set = tuple = 0
>
On 22 June 2013 19:24, Steven D'Aprano wrote:
> * If you assign to a name (e.g. "spam = 42") anywhere inside the body of a
> function, then that name is treated as a local variable, which is a fast
> lookup.
>
> * Otherwise, it is treated as unknown scope, and Python will search nesting
> functio
On 23/06/13 05:59, Albert-Jan Roskam wrote:
I was playing around with this a bit and arrived at the following surprising (for me at
least) result. I thought the global/local/nonlocal keywords could be used to get values
from another scope. Though this could also happen implicitly, e.g. if only
On Sat, Jun 22, 2013 at 3:59 PM, Albert-Jan Roskam wrote:
>
> I was playing around with this a bit and arrived at the following
> surprising (for me at least) result. I thought the global/local/nonlocal
> keywords could be used to get values from another scope. Though this
> could also happen impl
> One catch with Python nested scopes is that binding a name defaults to
> the local scope. You can get around this by using a mutable container,
> just as was done with globals before the "global" keyword was added in
> version 0.9.4 (1991). The better solution is a new keyword, but adding
>
On Sat, Jun 22, 2013 at 7:10 AM, Steven D'Aprano wrote:
> The function attribute "__closure__" is set to None for regular functions.
> For closures, it is set to a bunch of stuff needed for the inner function to
> work correctly. (No user serviceable parts inside.) Basically, the inner
> function
On 22/06/13 17:04, Peter Otten wrote:
This technique of nesting a function inside another function ("closure")
To be pedantic, not all nested functions are closures. Here's one which is not:
def outer(arg):
def inner(x):
return x + 1
assert inner.__closure__ is None
return
Jim Mooney wrote:
> dictnumfarkadoodle = listnumfarkadoodle = setnumfarkadoodle = 0
> # Since these are global I'm using words not likely to be duplicated
> until I figure a different way and
> # replace 'farkadoodle' with '' ;')
Name clashes are generally not a problem if
(1) you keep module s