Re:Try Python, Ruby, Lua, Scheme, QBasic, Forth ...
by marekmroz on Friday September 30, 2011 @09:15AM
(#3056821)
In python you can use tabs or spaces (however many) as long as it is consistent. Don't mix tabs and spaces. 4 spaces recommended.
Style Guide: http://www.python.org/dev/peps/pep-0008/ Indentation Myths: http://www.secnetix.de/olli/Python/block_indentation.hawk
Re:Try Python, Ruby, Lua, Scheme, QBasic, Forth ...
by veyron on Friday September 30, 2011 @10:46AM
(#3057192)
It's not really discussed in the PEP but in fact python treats the tab at the same indentation level as 8 spaces. You can mix tabs and 8 spaces without impunity
Check http://ideone.com/VIwf4 for an example. Basically, it shows that python treats 8 spaces at the same indent level as a tab
Re:Try Python, Ruby, Lua, Scheme, QBasic, Forth ...
by max99x on Friday September 30, 2011 @10:53AM
(#3057221)
I think ideone and/or your editor converts tabs to 8 spaces. Trying a tab indent followed by an 8-space one raises an error in native IPython for me. In any case, we're using normal CPython compiled to JavaScript, so it's unlikely to change finer points of the behaviour like this.
One comment: in python, technically tabs are equivalent to 8 spaces, but in your REPL it is equivalent to 4 spaces. Is that a modification to the version of python you are using, or did you make a decision to match 4 spaces (BTW: I really like this, but it breaks some older code)