Differences between revisions 13 and 14
Revision 13 as of 2015-06-11 21:50:22
Size: 4708
Editor: ErikJohnson
Comment:
Revision 14 as of 2015-06-11 21:59:26
Size: 5126
Editor: ErikJohnson
Comment: More ranting about whitespace.
Deletions are marked like this. Additions are marked like this.
Line 43: Line 43:
mixed up and causing my program ot not run correctly. I have since come to see Python's significant mixed up and causing my program to not run correctly. I have since come to see Python's significant
Line 45: Line 45:
looks just like it executes! '''They've been defined to be the same thing!''' Code reads just like it
looks, because you can't be lazy and not indent your code properly - its required to achieve the
correct behavior. IMHO: it is '''''not a design flaw''''': it was a wise design decision.
looks just like it executes! '''They've been defined to be the same thing!''' Code reads just like
it is actually structured. This was a conscious decision to try to address one of C's problems.
You can't be lazy and not indent your code properly. You get the structure right to get the program
to run right and resolve the readability problem at the same time - not put it off as a nicety to
be skipped over. ''This is an aid to readability and *understandability*!''
IMO: It definitely '''''is NOT a design flaw!''''' On the contrary, it was a wise decision that
ultimately saves typing and makes code more readable, letting you focus on the important parts
rather than a page full of curly braces.

Erik Johnson

I am a member of the Albuquerque Python Meetup: http://wiki.python.org/AbqPython/ http://www.meetup.com/AbqPython/

My email: Spam is largely out of control on the internet. Sometimes I check email at HedgesFan at G mail dot com. If you want my regular email address that is checked almost daily, ask me for it.

Python Ramblings

I am currently doing a course on Coursera titled An introduction to Interactive Programming In Python. (The link is to the actual instance of the class I am in - you may need to go in through the Coursera front page and search class listings to get to the next offering of the class.)

I don't really expect to learn a lot about the Python language itself, but some neat things are starting to happen with programming languages in general. In this case, they are using a wholly in-browser environment to run Python. It's not quite the same Python, but almost (one shortcoming I noticed is iteritems() on dict is missing.) This is based on http://www.skulpt.org/

Programming Contest Sites

Vim stuff

Significant whitespace (i.e., indentation) is one of the biggest complaints I hear about Python. I have to admit I was not a big of it at first, and had some issues with spaces and tabs getting mixed up and causing my program to not run correctly. I have since come to see Python's significant white space as one of its best features. Python executes just like it looks, and looks just like it executes! They've been defined to be the same thing! Code reads just like it is actually structured. This was a conscious decision to try to address one of C's problems. You can't be lazy and not indent your code properly. You get the structure right to get the program to run right and resolve the readability problem at the same time - not put it off as a nicety to be skipped over. This is an aid to readability and *understandability*! IMO: It definitely is NOT a design flaw! On the contrary, it was a wise decision that ultimately saves typing and makes code more readable, letting you focus on the important parts rather than a page full of curly braces.

I did have a colleague come to me once (I guess as some sort of perceived representative for Python) and bitterly complain: "I remember now why I don't like Python! When you store your source code in PDF format, all the indentation gets stripped! That's such a pain in the -bleep-! No other modern languages have this problem - they all use curly braces to make blocks explicit!" Yes, well... some people will "get" this design decision, others may not. I just laughed and told him, "I've used Python for over 10 years, and have yet to see this problem. It's not a convincing argument that something is wrong with Python. Python wasn't designed for that (nor did it ever advertise that you could)."

It is a fairly compelling argument not to store your Python source in PDF format, though. (If you want to display Python source in HTML, wrap it in a <pre> tag. I'm no PDF expert, but I would be surprised if there isn't some similar feature to get text to come out without the whitespace stripped in PDF.) If you've lost all your source formatting, that's a problem even if it may still compile.

Anyway, don't do that.

Using this .vimrc (or _vimrc on Windows), I've hardly thought about this indentation issue for over a decade:

set tabstop:4
set shiftwidth:4
set et
set autoindent
set wrap
set textwidth=72
syn on

Some other vim tricks/settings I don't want to lose track of:


CategoryHomepage

ErikJohnson (last edited 2018-05-24 19:40:20 by ErikJohnson)

Unable to edit the page? See the FrontPage for instructions.