Re: Python Newbie

2013-02-24 Thread J.R.

On 21/02/2013 19:40, piterrr.dolin...@gmail.com wrote:




I am nervous about using variables "out of the blue", without having
to declare them. For example, when I write "i = 0" it is perfectly OK
to Python without 'i' being declared earlier. How do I know that I
haven't used this variable earlier and I am unintentionally
overwriting the value? I find I constantly have to use the search
facility in the editor, which is not fun.

You see, Javascript, for one, behaves the same way as Python (no
variable declaration) but JS has curly braces and you know the
variable you have just used is limited in scope to the code within
the { }. With Python, you have to search the whole file.



No, JavaScript - or better, ECMAScript -, does have variable 
declaration. If you don't declare a variable with the "var" statement it 
will become an unintentional global variable which is a very bad thing.


If the variable statement occurs inside a Function Declaration, the 
variables are defined with function-local scope in that function. 
Otherwise, they are defined with global scope (that is, they
are created as members of the global object. Variables are created when 
the execution scope is entered. A Block { } does not define a new 
execution scope.


PS.: JavaScript is a trademark, and the actual language name is 
specified as ECMAScript.


See <http://ecma-international.org/ecma-262/5.1/>

--
Joao Rodrigues (J.R.)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Newbie

2013-02-24 Thread J.R.

On 24/02/2013 23:03, Roy Smith wrote:

In article ,
  "J.R."  wrote:


PS.: JavaScript is a trademark, and the actual language name is
specified as ECMAScript.


The decision whether to call it JavaScript or ECMAScript really comes
down to, "Do you want to be correct, or do you want people to know what
you're talking about?"



I was giving the reason why I used the language standardized name 
(ECMAScript) in the previous paragraph that you snipped. However it is 
perfectly okay using the term "JavaScript" when referring to an 
ECMAScript implementation. The same happens when you ask for a Band-Aid, 
not a bandage; or ask for Kleenex, not tissue, or when you “Google” for 
a word instead of searching for it.


--
Joao Rodrigues (J.R.)
--
http://mail.python.org/mailman/listinfo/python-list