Unknown2008-11-19 06:08:20
I like intendation (sp?) because it shows me quickly and easily which code block goes where, or belongs to which if for example.
But with brackets I often end up forgetting to close some. Or I put an if in at some point then the intendation of the closing brackets is all wrong and I -again- have no bloody idea of what goes where and when the interpreter then claims a bracket is missing somewhere it gets very tedious. Intendation is usually easier and faster to fix, and I at least (generally) immediately see where it is missing too.
To each their own I suppose. I'm just tired of having to chase closing brackets a la zmud / cmud.
But with brackets I often end up forgetting to close some. Or I put an if in at some point then the intendation of the closing brackets is all wrong and I -again- have no bloody idea of what goes where and when the interpreter then claims a bracket is missing somewhere it gets very tedious. Intendation is usually easier and faster to fix, and I at least (generally) immediately see where it is missing too.
To each their own I suppose. I'm just tired of having to chase closing brackets a la zmud / cmud.
Unknown2008-11-19 11:52:41
In-den-ta-tion. 
It helps to have an editor that matches brackets for you. I always code by creating the pair of brackets and then filling in the code between, so I don't forget to close anything. Besides, you can still indent your code to make it look pretty...

It helps to have an editor that matches brackets for you. I always code by creating the pair of brackets and then filling in the code between, so I don't forget to close anything. Besides, you can still indent your code to make it look pretty...
Unknown2008-11-19 14:14:52
QUOTE(Zarquan @ Nov 19 2008, 12:52 PM) 583971
In-den-ta-tion. 
It helps to have an editor that matches brackets for you. I always code by creating the pair of brackets and then filling in the code between, so I don't forget to close anything. Besides, you can still indent your code to make it look pretty...

It helps to have an editor that matches brackets for you. I always code by creating the pair of brackets and then filling in the code between, so I don't forget to close anything. Besides, you can still indent your code to make it look pretty...
I used to do that. Then would change things later in the code. And then again.. and again... Eventually it would just look messed up and I'd be annoyed at the 20+ lines I'd have just to close brackets OR the 1 line with 10001 closing brackets (Yeah I know my coding sucks. I try to split it up, but in some cases it's not worth it or would make it even worse in the long run.)
Summary: Brackets are a creation of Kethuru. At least in my very own personal hell corner.
Daganev2008-11-19 16:10:00
ahh, its the coding in brackets you don't like, not the reading of it... gotcha!
Yes, coding with brackets can be a real pain if you don'th ave a good code editor that does all that autoformating for you.
Yes, coding with brackets can be a real pain if you don'th ave a good code editor that does all that autoformating for you.
Trakis2008-11-19 17:22:38
For anyone else interested, I found this helpful:
http://simonwillison.net/2004/May/7/switch/
Originally, as I understand it, the reason for using a switch statement was to optimize code. By reading the comments, in Python, it doesn't seem like much speed is lost by using if/elif, so I'm going with something that looks like this:
if value == 'a': result = x * 5
elif value == 'b': result = x + 7
elif value == 'c': result = x - 2
Probably not the most elegant solution, but it works, so, I'm okay with it.
http://simonwillison.net/2004/May/7/switch/
Originally, as I understand it, the reason for using a switch statement was to optimize code. By reading the comments, in Python, it doesn't seem like much speed is lost by using if/elif, so I'm going with something that looks like this:
if value == 'a': result = x * 5
elif value == 'b': result = x + 7
elif value == 'c': result = x - 2
Probably not the most elegant solution, but it works, so, I'm okay with it.
Daganev2008-11-19 18:48:54
Switch statements also make the code easier to read (sometimes), but apparnently Python doesn't even have switch statements, so that lambda thing looks great.
Unknown2008-11-19 20:14:57
I'm starting to wonder in what context you're using the word "lambda" here.. 
(Uh.. yes I know what lambda functions are. I also know what an if/elif is.)

(Uh.. yes I know what lambda functions are. I also know what an if/elif is.)