473,786 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

indentation

every time I switch editor all the script indentation get mixed up,
and python start giving me indentation weird errors.
indentation also hard to follow because it invisible unlike brackets
{ }

is there any solution to this problems?

thank you!
Oct 19 '08
28 1514
On Mon, 20 Oct 2008 14:25:17 -0400, Terry Reedy wrote:
If I type *hypothetical* code for a post, *I* have to
type all the spaces, and I often use 2 per indent level. If I type in
IDLE, *it* adds the spaces (4 per indent) automatically.
But of course you would never post code without testing it first, right?
That would an Abomination Unto Nuggan.

*wink*
--
Steven
Oct 20 '08 #21
On Mon, 2008-10-20 at 13:29 +0000, Steven D'Aprano wrote:
On Mon, 20 Oct 2008 11:01:19 +0200, Bruno Desthuilliers wrote:
Steven D'Aprano a écrit :
On Sun, 19 Oct 2008 19:03:29 +0200, Bruno Desthuilliers wrote:

Steven D'Aprano a écrit :

(snip)

You can use tabs, or spaces. If you use spaces, you can choose 4
spaces, or 8, or any number,
By all means, make it 4 spaces - that's the standard.

It's *a* standard. I believe it is the standard for the Python standard
library, but there are other standards.
I can't remember having seen any other "standard" so far.


How about PEP 8? It's not even hidden deep in the bowels of the PEP --
it's almost at the top.
http://www.python.org/dev/peps/pep-0008/

"For really old code that you don't want to mess up, you can continue to
use 8-space tabs."
Fair, but limited to old code, so doesn't apply to instructions for new
code.
>
Then there's string.expandta bs():

expandtabs(...)
S.expandtabs([tabsize]) -string

Return a copy of S where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.
The default for a tab does not imply anything about how python code
should be indented.
>
Here's Jamie Zawinski:
http://www.jwz.org/doc/tabs-vs-spaces.html

"On defaultly-configured Unix systems, and on ancient dumb terminals and
teletypes, the tradition has been for the TAB character to mean ``move to
the right until the current column is a multiple of 8.'' (As it happens,
this is how Netscape interprets TAB inside <PREas well.) This is also
the default in the two most popular Unix editors, Emacs and vi."
Again, refers to the interpretation of a tab, rather than indentation
conventions.
>
This page is a little old (2002), but it states that the standards for
OpenBSD and Linux (presumably the kernels) are 8 space indents:

http://xarg.net/writing/tabs
Not python. I think when Bruno says it's *the* standard, we can assume
he means "for python."
Here's a style guide that recommends 2, 3 or 4 space indents:

http://www.cs.bris.ac.uk/Teaching/Re...MS12100/style/
Again, it's for java and C, not python.
>
And of course, whenever there's a difference of opinion, we can turn to
the ultimate source of all knowledge: Googlefight! *wink*

http://www.googlefight.com/index.php...GB&word1=tab+8
+spaces&word2=t ab+4+spaces
Nearly 50 million hits for "tab 8 spaces" versus a piddly 762 thousand
hits for "tab 4 spaces".

And I still don't care how many spaces are in a tab. ;D

Cheers,
Cliff

Oct 20 '08 #22
Terry Reedy <tj*****@udel.e duwrote:
>Yes there is. If I type *hypothetical* code for a post, *I* have to
type all the spaces, and I often use 2 per indent level. If I type in
IDLE, *it* adds the spaces (4 per indent) automatically.
Hmm... I have doubt then how much it really can be *the* standard if
it's only being followed it when it's convenient.

Ross Ridge

--
l/ // Ross Ridge -- The Great HTMU
[oo][oo] rr****@csclub.u waterloo.ca
-()-/()/ http://www.csclub.uwaterloo.ca/~rridge/
db //
Oct 21 '08 #23
In message
<a8************ *************** *******@v15g200 0hsa.googlegrou ps.com>,
Gandalf wrote:
every time I switch editor all the script indentation get mixed up ...
Mixed up in what way? Are you configuring your editors to do automatic
space/tab conversion in inconsistent ways?
Oct 21 '08 #24
In message <01************ **********@news .astraweb.com>, Steven D'Aprano
wrote:
Here's Jamie Zawinski:
http://www.jwz.org/doc/tabs-vs-spaces.html

"On defaultly-configured Unix systems, and on ancient dumb terminals and
teletypes, the tradition has been for the TAB character to mean ``move to
the right until the current column is a multiple of 8.''
Actually, I think that should be "multiple of 8 plus 1". If you're in column
1, pressing tab will move the equivalent of 8 spaces, which takes you
column 9, not 8.
Oct 21 '08 #25
Steven D'Aprano wrote:
On Mon, 20 Oct 2008 14:25:17 -0400, Terry Reedy wrote:
>If I type *hypothetical* code for a post, *I* have to
type all the spaces, and I often use 2 per indent level. If I type in
IDLE, *it* adds the spaces (4 per indent) automatically.

But of course you would never post code without testing it first, right?
That would an Abomination Unto Nuggan.

*wink*
I have learned at least three times to either test or specify
*untested*, except when testing is impossible, as when discussing
unimplemented syntax or answering questions based on unposted input. I
have learned much from posting *tested* code snippets.

Oct 21 '08 #26
GHUM a crit :
(snip)

Thus spake the Lord: Thou shalt indent with four spaces. No more, no
less.
Four shall be the number of spaces thou shalt indent, and the number
of thy
indenting shall be four. Eight shalt thou not indent, nor either
indent thou
two, excepting that thou then proceed to four. Tabs are right out.
+4 qotw !-)

Oct 21 '08 #27
On Tue, 21 Oct 2008 17:41:08 +1300, Lawrence D'Oliveiro wrote:
In message <01************ **********@news .astraweb.com>, Steven D'Aprano
wrote:
>Here's Jamie Zawinski:
http://www.jwz.org/doc/tabs-vs-spaces.html

"On defaultly-configured Unix systems, and on ancient dumb terminals
and teletypes, the tradition has been for the TAB character to mean
``move to the right until the current column is a multiple of 8.''

Actually, I think that should be "multiple of 8 plus 1". If you're in
column 1, pressing tab will move the equivalent of 8 spaces, which takes
you column 9, not 8.
Ever noticed that computer freaks often start counting at 0? ;-)

Ciao,
Marc 'BlackJack' Rintsch
Oct 21 '08 #28
2008/10/21 Marc 'BlackJack' Rintsch <bj****@gmx.net >:
Ever noticed that computer freaks often start counting at 0? ;-)
We grow to be like our pets....

--
Tim Rowe
Oct 21 '08 #29

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1255
by: Magnus Lie Hetland | last post by:
Not many members on the Atox mailing list yet, so I'll venture a request here... In Atox 0.2, I've added support for indentation tokens (somewhat like the Python indentation scheme, but a bit more relaxed). If anyone finds that sort of thing interesting, please have a look and give me your opinion -- does it seem like a useful way of dealing with this sort of thing? (It seems that lookahead is more sorely needed with indentation, to
147
7788
by: Sateesh | last post by:
Hi, I am a beginner in Python, and am wondering what is it about the indentation in Python, without which python scripts do not work properly. Why can't the indentation not so strict so as to give better freedom to the user? Is there any plausible reason behind this? Cheers! Sateesh
177
7092
by: C# Learner | last post by:
Why is C syntax so uneasy on the eye? In its day, was it _really_ designed by snobby programmers to scare away potential "n00bs"? If so, and after 50+ years of programming research, why are programming languages still being designed with C's syntax? These questions drive me insane. Every waking minute...
7
5878
by: diffuser78 | last post by:
I am a newbie to Python. I am mainly using Eric as the IDE for coding. Also, using VIM and gedit sometimes. I had this wierd problem of indentation. My code was 100% right but it wont run because indentation was not right. I checked time and again but still no success. I rewrote the code over again in VI and it ran. Can you please explain whats the trick behind the correct indentation. Thanks
9
3181
by: John Salerno | last post by:
How do you make a single string span multiple lines, but also allow yourself to indent the second (third, etc.) lines so that it lines up where you want it, without causing the newlines and tabs or spaces to be added to the string as well? Example (pretend this is all on one line): self.DTD = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"\n"http://www.w3.org/TR/html4/strict.dtd">\n\n'
135
7527
by: Xah Lee | last post by:
Tabs versus Spaces in Source Code Xah Lee, 2006-05-13 In coding a computer program, there's often the choices of tabs or spaces for code indentation. There is a large amount of confusion about which is better. It has become what's known as “religious war” — a heated fight over trivia. In this essay, i like to explain what is the situation behind it, and which is proper.
4
1804
by: bearophileHUGS | last post by:
This is the best praise of semantic indentation I have read so far, by Chris Okasaki: http://okasaki.blogspot.com/2008/02/in-praise-of-mandatory-indentation-for.html A quotation: I have appreciated that article, and I have personally seen how fast students learn Python basics compared to other languages, but I think that it's way more than just indentation that makes the Python language so quick to learn .
43
1982
by: Bill Cunningham | last post by:
I have had several complaints by some people who wish to help me and I wish to get the problem straight. I wrote this small utility myself and added some indentation and I wonder if it is acceptable. It does make source easier to read. #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { if (argc!=3) {
1
1686
by: Eric S. Johansson | last post by:
in trying to make programming in Python more accessible to disabled programmers (specifically mobility impaired speech recognition users), and hitting a bit of a wall. The wall (for today) is indentation. I need a method of getting the "right indentation" without having to speak a bunch of unnecessary commands. For example, depth specified by the previous line. But, frequently you need to go to a more arbitrary indentation for example...
19
2106
by: Eric S. Johansson | last post by:
Almar Klein wrote: there's nothing like self interest to drive one's initiative. :-) 14 years with speech recognition and counting. I'm so looking to my 15th anniversary of being injured next year.... another initiative is exporting the speech recognition environment to the Linux context. In a nutshell, he dictated to application on Windows, it tunnels over the network to a Linux machine, and will allow you to cut and paste to and...
0
10360
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10108
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9960
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7510
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.