Re: Explicit variable declaration

2008-04-25 Thread Filip Gruszczyński
> In Python the standard patten for "declaring" variables is just to assign to > them as they are needed. If you want the effect of a declaration as you > would do in C, you can just define the variable and initialize it to 0 or > None. (Or {} for a new dictionary, or [] for a new list.) Yep

Re: Explicit variable declaration

2008-04-24 Thread Jason Stokes
"Filip Gruszczynski" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> If you want to just declare that name exist, but doesn't want to >> declare the type, why don't you just do this: >> >> def somefunc(): >> nonlocal = nonlocal >> local = 0 # or None or [] or an initial

Re: Explicit variable declaration

2008-04-24 Thread Terry Reedy
"Filip Gruszczynski" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] |> If you want to just declare that name exist, but doesn't want to | > declare the type, why don't you just do this: Names do not 'exist' in Python, nor do they have types. They are bound to objects that have t

Re: Explicit variable declaration

2008-04-23 Thread Filip Gruszczyński
> If you want to just declare that name exist, but doesn't want to > declare the type, why don't you just do this: > > def somefunc(): > nonlocal = nonlocal > local = 0 # or None or [] or an initial value > # > return nonlocal * local Err.. I don't quite get. How it may help me?

Re: Explicit variable declaration

2008-04-23 Thread Lie
On Apr 23, 4:52 pm, "Filip Gruszczyński" <[EMAIL PROTECTED]> wrote: > > You mean the type? Not in 2.x, but in 3.x, there are function > > annotations: > > > def a_function(arg1: int, arg2: str) -> None: pass > > Nope, I don't like types ;-) 3.x seems pretty revolutionary, and this > typing can b

Re: Explicit variable declaration

2008-04-23 Thread Filip Gruszczyński
Wow! This is extremely easy and seems to do exactly what I need. Those decorators are pretty powerful then. Thanks for your help, I'll try to use this. > def uses(names): > def decorator(f): > used = set(f.func_code.co_varnames) > declared = set(names.split()) > undecl

Re: Explicit variable declaration

2008-04-23 Thread Duncan Booth
Steve Holden <[EMAIL PROTECTED]> wrote: > Filip Gruszczy"ski wrote: >> Just declaring, that they exist. Saying, that in certain function >> there would appear only specified variables. Like in smalltalk, if I >> remember correctly. >> > Icon has (had?) the same feature: if the "local" statement

Re: Explicit variable declaration

2008-04-23 Thread Steve Holden
Filip Gruszczyński wrote: You mean the type? Not in 2.x, but in 3.x, there are function annotations: def a_function(arg1: int, arg2: str) -> None: pass Nope, I don't like types ;-) 3.x seems pretty revolutionary, and this typing can be appreciated by some people. Declaring what about them

Re: Explicit variable declaration

2008-04-23 Thread Filip Gruszczyński
> You mean the type? Not in 2.x, but in 3.x, there are function > annotations: > > def a_function(arg1: int, arg2: str) -> None: pass Nope, I don't like types ;-) 3.x seems pretty revolutionary, and this typing can be appreciated by some people. > Declaring what about them? If you mean declari

Re: Explicit variable declaration

2008-04-22 Thread Gabriel Genellina
En Tue, 22 Apr 2008 21:39:41 -0300, Filip Gruszczyński <[EMAIL PROTECTED]> escribió: Hello everyone! It is my first message on this list, therefore I would like to say hello to everyone. I am fourth year student of CS on the Univeristy of Warsaw and recently I have become very interested in d

Re: Explicit variable declaration

2008-04-22 Thread Ben Finney
"Filip Gruszczyński" <[EMAIL PROTECTED]> writes: > I have become very interested in dynamically typed languages, > especially Python. Good to know. Welcome to the group. > I would like to ask, whether there is any way of explicitly > declaring variables used in a function? Declaring what about

Re: Explicit variable declaration

2008-04-22 Thread Benjamin
On Apr 22, 7:39 pm, "Filip Gruszczyński" <[EMAIL PROTECTED]> wrote: > Hello everyone! > > It is my first message on this list, therefore I would like to say > hello to everyone. I am fourth year student of CS on the Univeristy of > Warsaw and recently I have become very interested in dynamically ty

Re: Explicit variable declaration

2008-04-22 Thread Dan Bishop
On Apr 22, 7:39 pm, "Filip Gruszczyński" <[EMAIL PROTECTED]> wrote: > Hello everyone! > > It is my first message on this list, therefore I would like to say > hello to everyone. I am fourth year student of CS on the Univeristy of > Warsaw and recently I have become very interested in dynamically ty