[pythonvis] Re: Indentation of code

  • From: "Jeffrey Thompson" <jthomp@xxxxxxxxxxx>
  • To: <pythonvis@xxxxxxxxxxxxx>
  • Date: Thu, 08 May 2014 16:03:59 -0400

Charles Sharon, and other listeners,

 

                No, the indentations are necessary for the program to run 
correctly.

The indentation is instead of braces.

 

                If you check out Edsharp’s documentation and look for the word 
“brace” or “{“ you will (eventually) get to a section which allows programmers 
to use braces the way they are used in most other languages.

As I recall, there is a utility to convert from braces to indented lines.

I have not tried it.

What you have to realize is that to either run your code you have to use the 
utility to make indents for the Python interpreter.

And if you are working collabrativly, where different programmers are not using 
braces as other languages do,

then you will be obliged to run the utility on whatever piece of code you have 
written or modified.

The same goes for every piece of code that you input from the shared folders.

I started to run into this problem when I was doing code development in Python 
where

I was using Tabs for indenting and everyone else was using spaces (which 
conforms to Python coding style standards). 

everybody using spaces to indent (3-4 spaces for each level).

My boss was "scared silly" with this solution to the conversion problem,

because I was transforming code,

and if it didn't work it could really mess things up for whatever code was 
being transformed.

 

What you might do instead is to use "# {" instead of "{".

You cannot do it at the beginning of a line, or the line is commented out.

But could do it on a separate line or at the end of a line.Even so, you would 
probably have the single line comment-brace indented to the same level as the 
previous line

and the correxponding right brace would have to be outdented once

from the previous line.

 

Edsharp has the ability to match corresponding braces may discover that it's a 
problem in Python.

I'm not sure it's smart enough to skip any braces in quotes or comments.So it 
might not work too well for what I have suggested above.

Look, I hear ya, and I've been there.

I've wasted a good chunk of time when I rarely get the indents wrong and have 
to figure out where the problem is.

So lack of braces may seem to create problems.

But after awhile you get used to it.

and stop making as many mistakesI'd say this problem became rare after about 4 
weeks of python usage.

 

One additional problem is that braces and brackets are both used in real code, 
just not to define a block of code.

 

One trick that could save you a lot of time:

After you select a block of text,

if you press "tab" or "shift-tabb" you will put or remove a tab at the 
beginning of each line in the block of text.

This is not so useful when writing code,

but it can be of great value in importing a section of code from another 
program where the indentation may be different from what you need.

and after testing, run a utility to change the leading tabs to the appropriate 
number of spaces that your group is using to do an indent.

You will find more detail in Edsharp documentation.

 

                Jet (Jeffrey Thompson)

From: pythonvis-bounce@xxxxxxxxxxxxx [mailto:pythonvis-bounce@xxxxxxxxxxxxx] On 
Behalf Of Charles Rivard

Sent: Thursday, May 08, 2014 1:05 PM

To: pythonvis@xxxxxxxxxxxxx

Subject: [pythonvis] Re: Indentation of code

 

Are there different levels on indentation?  If so, wouldn't the program run 
differently when different lengths of indentation is used?  Or are you speaking 
only of representation for reading purposes rather than for actual code 
writing?  Thanks.

 

---

Be positive!  When it comes to being defeated, if you think you're finished, 
you! really! are! finished!

----- Original Message ----- 

From: Richard Dinger <mailto:rrdinger@xxxxxxxxxx> 

To: pythonvis@xxxxxxxxxxxxx <mailto:pythonvis@xxxxxxxxxxxxx> 

Sent: Wednesday, May 07, 2014 9:41 PM

Subject: [pythonvis] Indentation of code

 

A close relative to Sharon’s code format issue is how many spaces to use in 
code examples.  This may be controversial.

Although four spaces is the most common indentation, I suggest two spaces per 
indentation level will work better especially for email.  Two and four spaces 
are both common standards, but four spaces eats too much page territory.

Richard

 

 

From: pythonvis-bounce@xxxxxxxxxxxxx [mailto:pythonvis-bounce@xxxxxxxxxxxxx] On 
Behalf Of Sharon Hooley
Sent: Thursday, May 08, 2014 2:51 PM
To: pythonvis@xxxxxxxxxxxxx
Subject: [pythonvis] Re: Indentation of code

 

Maybe you could type, indent 2, indent 4, ectcetera, then type the colon before 
skipping the line?

 


Sent from my iPhone


On May 7, 2014, at 8:41 PM, Richard Dinger <rrdinger@xxxxxxxxxx> wrote:

A close relative to Sharon’s code format issue is how many spaces to use in 
code examples.  This may be controversial.

 

Although four spaces is the most common indentation, I suggest two spaces per 
indentation level will work better especially for email.  Two and four spaces 
are both common standards, but four spaces eats too much page territory.

 

Richard

Other related posts: