| | |
multi line if statement
![]() |
•
•
Join Date: May 2008
Posts: 8
Reputation:
Solved Threads: 0
This may be a stupid question but..
I am trying to do something like this....
and i get an invalid syntax error. so how do you do that properly? google wasn't much help.
I am trying to do something like this....
Python Syntax (Toggle Plain Text)
if not something and not somethineElse and not someOtherThing and not thisThing: print "asdf"
and i get an invalid syntax error. so how do you do that properly? google wasn't much help.
Relax, it's not a stupid question. Here's the proper syntax:
You can use \ anywhere you need to continue a statement on the next line.
python Syntax (Toggle Plain Text)
if not something \ not somethineElse and \ not someOtherThing and \ not thisThing: print "asdf"
You can use \ anywhere you need to continue a statement on the next line.
Last edited by scru; Feb 6th, 2009 at 9:59 pm.
For that you could also go:
python Syntax (Toggle Plain Text)
notList = ["list vars here"] if False not in [not var for var in notList]: #do stuff
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Check out my Site | and join us on IRC | Python Specific IRC
you can also do like this:
python Syntax (Toggle Plain Text)
a=0 b=0 c=0 d=0 if not(a==0 and b==0 and c==0 and d==0): print "go home" else: print "come here"
![]() |
Similar Threads
- Improving this program (Python)
- read multi line txt.file and display in textbox (Visual Basic 4 / 5 / 6)
- Macro for dynamically allocate multidimensional arrays (C)
- SQL Data into Textbox or Listbox (C#)
- help deleting object from multi-dimesional array (C++)
- Project Bank System (C)
- Merge Two Files (C++)
- using foreach with multi-dimensional arrays (PHP)
- My own read function (C)
Other Threads in the Python Forum
- Previous Thread: qt desinger (QlistViewitem) and python
- Next Thread: Python modules ..
| Thread Tools | Search this Thread |
abrupt accessdenied anti apache application approximation argv array beginner book builtin calculator change converter countpasswordentry curved dan08 dictionaries dictionary dynamic edit enter examples file float format function gui homework import inches input java keyboard lapse launcher library line lines linux list lists loop microphone mouse movingimageswithpygame mysqlquery newb number numbers numeric output parameters parsing path phonebook plugin port prime programming progressbar projects py2exe pygame pyopengl python random recursion redirect remote reverse scrolledtext session simple software sprite statictext string strings syntax table terminal text textarea threading time tlapse trick tricks tuple tutorial twoup ubuntu unicode unit urllib urllib2 variable wordgame wxpython






