catching all exceptions

2005-08-13 Thread a_geek
Hello,

I'd like to catch all exeptions and be able to inspect them.

The simple case: I know which exceptions I'll get:

# standard textbook example:
try:
something()
except ThisException, e:
print "some error occurred: ", str(e)


The not-so-simple case: Handling all other exceptions:

# nice-to-have:
try:
something()
except *, e:
print "some error occurred: ", type(e), str(e)


Well, actually the second statement doesn't even compile... any ideas
why I shouldn't be able to catch "anonymous" exceptions like this, or
whether and how I can (and only overlooked it)?


TIA!


Kind Regards,
Toni
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: catching all exceptions [SOLVED]

2005-08-13 Thread a_geek
Hello,

Tomasz Lisowski wrote:
>> Well, actually the second statement doesn't even compile... any ideas
>> why I shouldn't be able to catch "anonymous" exceptions like this, or
>> whether and how I can (and only overlooked it)?

[ one of three suggestions: ]

> Try this:

Ok, so the answer simply was that I didn't see "it", although the
solution is in the manual.

Thank you!


Kind Regards,
Toni
-- 
http://mail.python.org/mailman/listinfo/python-list


problem with "time"

2005-03-08 Thread a_geek
Hello,

I'm writing a small program that needs to check Unix timestamps for
falling into an interval (typical usage: ./program 2005-03, you get
the idea). Now, I create two time stamps from the user's input to
create the interval's borders using mktime(). Trying to check the sanity
of my program, I also converted the values back to tuples using
localtime(). Unfortunately, I get back one of them with the DST flag
set, and the other with the DST flag unset.

I have _no_ idea on how localtime() could reasonably synthesize
different values for that flag for _any_ time value converted in about
the same millisecond. What gives?

Thank you!
-- 
http://mail.python.org/mailman/listinfo/python-list