08-16-2010, 07:54 PM
(This post was last modified: 08-16-2010, 07:55 PM by Daniel Faraday.)
1) Finishing off with an elif should work if you wanted to set a value.
Else is used because it encompasses everything that you didn't want to clarify.
So let's say you only checked.
100 < x < 150 (Greater than 100 less than 150)
and
180 < x < 250 (Greater than 180 less than 250)
Then you finished off with an else it would include less than 100 , less than 180 greater than 150, and also greater than 250.
So an else would be better in that situation.
2) You could if it's a smaller app, but once you get into coding large projects it would seem tacky.
3) Because when you use an else you can't set what needs to be true.
Else statements are used when you want something to happen for what you didn't make a statement for.
4) Because that's used to set the path. There isn't a need to set something that is already set.
I haven't gotten far into Python, but I think that would only be needed if you're path was set for Python 2.6 and then, for example, you wanted to use Python 3.1 for that one app.
Also some distros use scripts that are dependent on a certain version of Python so you have to use that line to set the path for the version of Python you wish to use.
Else is used because it encompasses everything that you didn't want to clarify.
So let's say you only checked.
100 < x < 150 (Greater than 100 less than 150)
and
180 < x < 250 (Greater than 180 less than 250)
Then you finished off with an else it would include less than 100 , less than 180 greater than 150, and also greater than 250.
So an else would be better in that situation.
2) You could if it's a smaller app, but once you get into coding large projects it would seem tacky.
3) Because when you use an else you can't set what needs to be true.
Else statements are used when you want something to happen for what you didn't make a statement for.
4) Because that's used to set the path. There isn't a need to set something that is already set.
I haven't gotten far into Python, but I think that would only be needed if you're path was set for Python 2.6 and then, for example, you wanted to use Python 3.1 for that one app.
Also some distros use scripts that are dependent on a certain version of Python so you have to use that line to set the path for the version of Python you wish to use.