| | |
Python Indentation
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
Concerning Python Indentation Syntax:
I have researched this and read some reasoning behind indentation-level enforcement. My question is: does this exist simply to ensure consistency when dealing with nested statements, a precaution against sloppy composition of code?
I am not complaining about this, and actually I somewhat like this, but it seems to always crop up while compiling, improper indentations throughout my code say, for example, if I add a snippet of code such as a RNG just to test it out; I must then stop and format everything beneath the inserted code in order to get a valid run. This is not much different than stopping to fix C++ errors before a valid compile except for those errors never really relate to indentation.
As I said, I do not dislike this feature, this rule of Python, as I pretty much like everything about Python. I just wish to understand (from someone well acquainted with this language) why the enforcement of indentation was decided upon by the designer of Python as a necessary "evil"
:cheesy: . Just curious.
Regards,
sharky_machine
I have researched this and read some reasoning behind indentation-level enforcement. My question is: does this exist simply to ensure consistency when dealing with nested statements, a precaution against sloppy composition of code?
I am not complaining about this, and actually I somewhat like this, but it seems to always crop up while compiling, improper indentations throughout my code say, for example, if I add a snippet of code such as a RNG just to test it out; I must then stop and format everything beneath the inserted code in order to get a valid run. This is not much different than stopping to fix C++ errors before a valid compile except for those errors never really relate to indentation.
As I said, I do not dislike this feature, this rule of Python, as I pretty much like everything about Python. I just wish to understand (from someone well acquainted with this language) why the enforcement of indentation was decided upon by the designer of Python as a necessary "evil"
:cheesy: . Just curious.Regards,
sharky_machine
Avoiding the endless begin/end or curly braces, and also the end of line semicolons makes code simpler to read and understand. When you use an editor made for Python, indentations become easy to follow. You absolutley have to avoid mixing spaces with tabs in your indents. That's the main reason you have problems with other folks code! I religiously use spaces (4) only, since tab settings vary so much.
drink her pretty
Thank-you Ene Uran .
I need to stick to a set amount of spaces (indentation); I think four (4) spaces seems like a good amount.
regards,
sharky_machine
I need to stick to a set amount of spaces (indentation); I think four (4) spaces seems like a good amount.
regards,
sharky_machine
Thus spoke 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 the devil's apples!"
May 'the Google' be with you!
•
•
Join Date: Jul 2006
Posts: 608
Reputation:
Solved Threads: 150
So the real man's computing challenge would appear to be the
Obsucated Python Contest :mrgreen:
Write a program to play chess in as unclear a way possible.
Jeff
(with apologies to the real thing)
Obsucated Python Contest :mrgreen:
Write a program to play chess in as unclear a way possible.
Jeff
(with apologies to the real thing)
![]() |
Similar Threads
- Starting Python (Python)
- Why should i learn Python? (Python)
- what is python (Python)
Other Threads in the Python Forum
- Previous Thread: Python GUI build: Logic Complications and Mistakes
- Next Thread: Very basic de/encrypt program
| Thread Tools | Search this Thread |
advanced aliased bash beginner bits calling casino changecolor class clear command convert corners count csv cturtle cursor def definedlines dictionary digital dynamic dynamically events examples external file float format frange function google gui hints homework i/o iframe import info input java line linux list lists loop matching mouse multiple number numbers obexftp output parsing path port prime programming projects py py2exe pygame pygtk python random rational raw_input recursion return scrolledtext signal singleton skinning stderr string strings subprocess table tails terminal text thread threading time tkinter tlapse tuple tutorial ubuntu unicode urllib urllib2 valueerror variable voip web-scrape whileloop windows word wxpython






