On 9 November 2013 13:08, John von Horn <j....@btinternet.com> wrote: > I'm Mr. Noobie here, I've just started easing into Python (2.7.4) and am > enjoying working along to some youtube tutorials. I've done a little > programming in the past. > > I've just got a few thoughts I'd like to share and ask about: > > * Why not allow floater=float(int1/int2) - rather than floater=float > (int1)/float(int2)? > > Give me a float (or an error message) from evaluating everything in the > brackets. Don't make me explicitly convert everything myself (unless I > want to)
In Python 2, `int1/int2` does integer division. So `float(that_result)` gives a truncated float. `int1/float(int2)` obviously avoids this by dividing by a float. If `float(int1/int2)` were to return the same value, `float` could not be a normal function, and would have to be magic. Magic is bad. Fortunately, Python 3 does the sane thing and just does floating-point division by default. Great, eh? > * No sign of a select .. case statement > > Another useful tool in the programmer's toolbox > > Select DayofWeek > > case "mon" > > ... > > end select `select` is quite an odd statement, in that in most cases it's just a weaker variant of `if`. By the time you're at the point where a `select` is actually more readable you're also at the point where a different control flow is probably a better idea. Things like dictionaries or a variables pointing to functions are really useful and can be encapsulated in a class quite well. This is a bit more advanced but largely more rigorous. But most of the time the idea is just that an `if` is more explicit, and it's not like a `case` statement can be optimised as it can in lower-level languages with simpler datatypes. > * Call me pedantic by why do we need a trailing comma for a list of one > item? Keep it intuitive and allow lstShopping=[] or ["Bread"] or > ["Bread", "Milk","Hot Chocolate"] I don't like ["Bread",]. It bugs me. You don't. You might be confused because you need to write `("hello",)`, but that's because the *comma* makes a *tuple*, not the brackets. Imagine if `2 * (1/2)` gave you `(0.5, 0.5)`! > Is everyone happy with the way things are? Could anyone recommend a good, > high level language for CGI work? Not sure if I'm going to be happy with > Perl (ahhh, get him, he's mentioned Perl and is a heretic!) or Python. I > would very much value any constructive criticism or insights. I don't know squat about CGI, but I think Python can grow on anyone open to the idea of programming at a high level. Not "high level" as in "expert" but as in "using higher-level constructs", if you get the meaning. Python implements these quite well. Your first two complaints are not new, though. -- https://mail.python.org/mailman/listinfo/python-list