How can I write readable Python code when there are no curly brackets and semicolons? [closed]
I love the semicolons and curly brackets from C and PHP.
Now I am starting to program with Python and when the code gets bigger it seems to me very messy without them (the curly brackets and semicolons).
The orientation in PHP or C is much efficient and faster, at least for me.
On the other hand I like many features of Python.
However, I think that maintaining the code will be very hard after some time.
How do you write readable code when there are no semicolons and braces?
Is there any plugin for Eclipse or Netbeans which will emulate semicolons and curly brackets.
ADDITIONAL QUESTION: Is there a version of Python with semicolons and curly-braces?
SOLVED !!!
I have found something which looks like an improved version of Python http://writeonly.wordpress.com/2010/04/01/whython-python-for-people-who-hate-whitespace/
I will give it a try.
>>> from __future__ import braces
File "<stdin>", line 1
SyntaxError: not a chance
there is semicolon:
a=3; b=4
I don't see how braces make the code any more readable.
One thing that makes code less readable is cluttering up your code by saying things twice.
Indentation to clarify block structures is good practice in most languages (notable exception - the language that shall not be named, first syllable "brain").
Given that the indentation is there to describe the block structure anyway, why repeat yourself by adding braces?
C++ is my main language, and I'm not going to call this duplication evil, but it's a happy thing to get rid of this small annoyance and minor clutter (and get slightly more readable code) when I use Python.
It's also nice that Python makes a particular extreme evil impossible - cases where the braces are inconsistent with the indentation, so that the indentation is misleading.
BTW - a lot of the old prejudice about significant whitespace is due to languages like Fortran - which have an entirely different (and evil) approach to significant whitespace. A lot of old-timers have a kneejerk response because of that - and a lot of youngsters have a kneejerk response because it's not what Java (or whatever) does, of course.
Haskell also has a similar style of significant whitespace to Pythons. In Haskell, the braces are still valid - you can use braces to keep a block on one line, or you can use indentation only, or you can use both. It's not just Python and its imitators that make indentation syntactically significant.
精彩评论