Thanks to all for quick relies.

Chris, you are (almost) spot on with the if blocks indentation. This is what I 
do, and it has served me well for 15 years.

code
code

   if (some condition)
   {
      code
      code
   }

code
code

This is what I call code clarity. With Python, I am having to do this

code
code

##############################

if (some condition):
  code
  code

##############################

code
code

It does the job, but is not ideal.

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.

Thanks to Chris, Ian and Dave for explaining the () issue around if and for 
statement. I don't agree with this, but I understand your points. The reason 
why I like parentheses is because they help with code clarity. I am obsessed 
with this. :-) After all, there is a reason why so many languages have required 
them for several decades.


What about Python's ambiguity?
For example, in C you would write

if (myVar != 0)
  do something

in Python, this is legal

if (not myVar):
  do something

What does this mean? Is it a test for myVar being equal to zero or a test for 
null, or else?

I want to learn a new language but Python's quirks are a bit of a shock to me 
at this point. I have been Pythoning only for about a week.

In the mean time, thanks to most of you for encouraging me to give Python a 
chance. I will do my best to like it, w/o prejudice.

Peter
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to