Is there anyway to catch the following type of bug in Python code:
message = 'This is a message'
# some code
# some more code
if some_obscure_condition:
nessage = 'Some obscure condition occured.'
# yet more code
# still more code
print message
In the above example, message should be set to '
Would it be considered good form to begin every method or function with
a bunch of asserts checking to see if the parameters are of the correct
type (in addition to seeing if they meet other kinds of precondition
constraints)? Like:
def foo(a, b, c, d):
assert type(a) == str
ass
Which is better: using an if/else construct to simulate a C switch or
use a dictionary? Example:
def foo():
if c == 1:
doCase1()
elif c == 2:
doCase2()
elif c == 3:
doCase3()
elif c == 4:
doCase4()
elif c == 5:
doCase5()
else:
raise "shouldn't
Ahh .. yes of course, you are right. I mis-typed. I like how you
defined the dictionary all in one statement, though. I didn't think
of doing it that way.
-- Arcadio
On Jun 19, 4:11 pm, heltena <[EMAIL PROTECTED]> wrote:
> asincero ha escrit:
>
>
>
> >
I have a class called Users that provides a higher level of
abstraction to an underlying "users" table in a pgsql database. It
has methods like "addUser()" and "deleteUser()" which, obviously, wrap
the corresponding SQL statements. My question is would it better to
let any exceptions thrown by th