[NCLUG] Looking at programming languages...

Walker, Philip M (Optical Storage) phil.walker at hp.com
Thu Jan 17 10:35:26 MST 2008


Python is good stuff, but one limitation prevents me from becoming enthusiastic:

 the indentation relies on the assumption that tabs (if present) are unambiguously equivalent to 8 spaces.

Of course, that assumption is not valid unless your editor is configured that way (mine isn't), and as a result, I always have to convert tabs to 8 actual spaces before I can see how the code will actually appear to the compiler.

My editor (vim) is configured by default for tabs == 4 spaces, and out of respect for other developers that have to read my code, I always output files with no tabs, but many (most?) Python developers distribute files with mixed tabs and spaces.

Phil

-----Original Message-----
From: Sean Reifschneider [mailto:jafo at tummy.com]
Sent: Wednesday, January 16, 2008 8:34 PM
To: Northern Colorado Linux Users Group
Subject: Re: [NCLUG] Looking at programming languages...

On Wed, Jan 16, 2008 at 05:00:39PM -0700, Michael Milligan wrote:
> My biggest problem with Python was the rigid indent style forced upon
> me,

I anticipated having a problem with the indentation, but when I started writing Python I found that I didn't have to adjust my indentation style at all what I was using in C.  What I did find was that it was impossible to make mistakes like I'd made in the past:

   if (condition)
      if (othercondition) code();
   #oops, need an else here so during maintenance I add:
   else someothercode();

In C the else goes with the othercondition else.  In Python, it looks at the indentation and does what I had intended.  Of course, you can compensate for this by always adding braces in languages that use them.
That's the habit I've been using since I got bitten by the above back in the <gasp> '80s.

So, if your biggest problem with Python is the enforced indentation, then
either:

   You're blessed to have so few problems.

or:

   You really need to obtain the habit of a good indentation style.

Sean
--
 "If you're really us, what UDP port do you use?"  "TFTP, dudes!"
                 -- Scott Kleihege, 2005 Sean Reifschneider, Member of Technical Staff <jafo at tummy.com> tummy.com, ltd. - Linux Consulting since 1995: Ask me about High Availability





More information about the NCLUG mailing list