473,786 Members | 2,578 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 1515
Ross Ridge a écrit :
Bruno Desthuilliers <br************ ********@websit eburo.invalidwr ote:
>I can't remember having seen any other "standard" so far.

I've seen various indentation styles used in examples on this newsgroup.
I meant: in a real-life project.

Oct 20 '08 #11
Bruno Desthuilliers <br************ ********@websit eburo.invalidwr ote:
I can't remember having seen any other "standard" so far.
Ross Ridge a écrit :
I've seen various indentation styles used in examples on this newsgroup.
Bruno Desthuilliers <br************ ********@websit eburo.invalidwr ote:
>I meant: in a real-life project.
So? There's no reason to assume the styles people use on this newsgroup
don't reflect those they use in "real-life" projects.

Ross Ridge

--
l/ // Ross Ridge -- The Great HTMU
[oo][oo] rr****@csclub.u waterloo.ca
-()-/()/ http://www.csclub.uwaterloo.ca/~rridge/
db //
Oct 20 '08 #12
Bruno Desthuilliers <br************ ********@websit eburo.invalidwr ote:
Ross Ridge a écrit :
>Bruno Desthuilliers <br************ ********@websit eburo.invalidwr ote:
>>I can't remember having seen any other "standard" so far.

I've seen various indentation styles used in examples on this newsgroup.

I meant: in a real-life project.

When I asked a similar question back in 2006, Sybren Stuvel offered:
Duncan Booth enlightened us with:
Can you point at any significant body of publically visible Python
code which uses tabs exclusively ?

Everything Python at http://www.stuvel.eu/software
Peter Decker came up with:
Dabo. http://dabodev.com
Those were the only two suggestions given for Python projects with tabs as
a coding style. I don't know if the first of these has more than 1
developer, the second lists 7 people as contributors.

So it looks like real-life projects do exist, just not very many or very
large.
Oct 20 '08 #13
On 20 Okt, 14:24, Duncan Booth <duncan.bo...@i nvalid.invalidw rote:
>
Those were the only two suggestions given for Python projects with tabs as
a coding style. I don't know if the first of these has more than 1
developer, the second lists 7 people as contributors.

So it looks like real-life projects do exist, just not very many or very
large.
I think Webware uses (or used) tabs exclusively, and that was more
than a seven person project once upon a time.

Paul
Oct 20 '08 #14
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."
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.
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."
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

Here's a style guide that recommends 2, 3 or 4 space indents:

http://www.cs.bris.ac.uk/Teaching/Re...MS12100/style/
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".

--
Steven
Oct 20 '08 #15
Ross Ridge a écrit :
Bruno Desthuilliers <br************ ********@websit eburo.invalidwr ote:
>I can't remember having seen any other "standard" so far.
Ross Ridge a écrit :
>I've seen various indentation styles used in examples on this newsgroup.

Bruno Desthuilliers <br************ ********@websit eburo.invalidwr ote:
>I meant: in a real-life project.

So? There's no reason to assume the styles people use on this newsgroup
don't reflect those they use in "real-life" projects.
Yes there are. I can give you two:
1/ code editor are usually configured to insert X spaces when hitting
'tab' - which is not necessarily the case for newsreaders. Guess what
happens when someone writes a code snippet directly in his newsreader ?

2/ I sometimes use 2-spaces when posting here to avoid linewraps

!-)
Oct 20 '08 #16
Duncan Booth a écrit :
Bruno Desthuilliers <br************ ********@websit eburo.invalidwr ote:
>Ross Ridge a écrit :
>>Bruno Desthuilliers <br************ ********@websit eburo.invalidwr ote:
I can't remember having seen any other "standard" so far.
I've seen various indentation styles used in examples on this newsgroup.
I meant: in a real-life project.

(snip two examples)

So it looks like real-life projects do exist,
Possibly. I just said that *I* didn't remember having seen such a thing.

Oct 20 '08 #17
On Sun, 19 Oct 2008 07:16:44 -0700, Gandalf wrote:
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!
When in Rome, do like the Romans do.
When coding python in general, use four spaces as described in style
guideline (PEP8)
However, when the code you're editing doesn't follow the guideline,
follow the code's guideline.

If the code doesn't have a guideline (e.g. the code liberally mix up tabs
and spaces), make one and enforce it.

Oct 20 '08 #18
I can't remember having seen any other "standard" so far.

there is this meme flowing around:

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.
I Allways thought that was some of the interpretations of the ZEN of
Python, so, who can enlighten me of the origin?

Harald
Oct 20 '08 #19
Ross Ridge wrote:
Bruno Desthuilliers <br************ ********@websit eburo.invalidwr ote:
>I can't remember having seen any other "standard" so far.
Ross Ridge a écrit :
>I've seen various indentation styles used in examples on this newsgroup.

Bruno Desthuilliers <br************ ********@websit eburo.invalidwr ote:
>I meant: in a real-life project.

So? There's no reason to assume the styles people use on this newsgroup
don't reflect those they use in "real-life" projects.
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.

Oct 20 '08 #20

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
7095
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
1983
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
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
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
10110
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
9961
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
8989
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 project—planning, coding, testing, and deployment—without 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
7512
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
6745
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();...
1
4066
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.