On 11 July 2013 20:50, Mark McLoughlin mar...@redhat.com wrote:
That answer does begin with this, though:
I almost always use hasattr: it's the correct choice for most cases.
I have to disagree here, hasattr is basically a timebomb. Three-param
getattr, or safe_hasattr are *much* better
On 07/11/2013 05:20 AM, Mark McLoughlin wrote:
On Wed, 2013-07-10 at 19:49 -0400, Monty Taylor wrote:
I'd like top-post and hijack this thread for another exception related
thing:
a) Anyone writing code such as:
try:
blah()
except SomeException:
raise
On 07/11/2013 05:43 AM, Thomas Hervé wrote:
On Thu, Jul 11, 2013 at 1:49 AM, Monty Taylor mord...@inaugust.com
mailto:mord...@inaugust.com wrote:
I'd like top-post and hijack this thread for another exception related
thing:
a) Anyone writing code such as:
try:
On 07/11/2013 05:43 AM, Thomas Hervé wrote:
On Thu, Jul 11, 2013 at 1:49 AM, Monty Taylor mord...@inaugust.com
mailto:mord...@inaugust.com wrote:
I'd like top-post and hijack this thread for another exception related
thing:
a) Anyone writing code such as:
try:
On 07/11/2013 06:22 AM, Sean Dague wrote:
On 07/11/2013 05:43 AM, Thomas Hervé wrote:
On Thu, Jul 11, 2013 at 1:49 AM, Monty Taylor mord...@inaugust.com
mailto:mord...@inaugust.com wrote:
I'd like top-post and hijack this thread for another exception
related
thing:
a)
On Fri, Jul 12, 2013 at 5:33 PM, Monty Taylor mord...@inaugust.com wrote:
On 07/11/2013 05:43 AM, Thomas Hervé wrote:
On Thu, Jul 11, 2013 at 1:49 AM, Monty Taylor mord...@inaugust.com
mailto:mord...@inaugust.com wrote:
I'd like top-post and hijack this thread for another
On Fri, Jul 12, 2013 at 10:09 AM, Monty Taylor mord...@inaugust.com wrote:
On 07/11/2013 05:20 AM, Mark McLoughlin wrote:
On Wed, 2013-07-10 at 19:49 -0400, Monty Taylor wrote:
I'd like top-post and hijack this thread for another exception related
thing:
a) Anyone writing code such
Hi folks
Monty
Thank you for your adding good topic for this.
I agree, hiding true cause by exception get hard to debug
For, example, Sqlalchemy gives me this error for general sql errors..
exceptions must be old-style classes or derived from BaseException, not str
(It should be hidden from
Somewhat offtopic, but others might find it interesting. On another project
I used a different technique for exceptions, where the original exception
is enhanced with new fields as it propagates up the stack to where it's
handled. In this way all the information needed to handle the exception is
I'm curious if folks know about this?
import sys
def foo():
raise Exception('Foo Exception')
def bar():
try:
foo()
except Exception:
exc_info = sys.exc_info()
raise Exception('Bar Exception'), None, exc_info[2]
bar()
Traceback (most recent call last):
On Wed, 2013-07-10 at 21:14 +0200, Thomas Hervé wrote:
On Wed, Jul 10, 2013 at 8:32 PM, Mark McLoughlin mar...@redhat.com
wrote:
On Wed, 2013-07-10 at 11:01 -0700, Nachi Ueno wrote:
Personally, I prefer not to use exception for such cases.
The key
On Wed, 2013-07-10 at 19:49 -0400, Monty Taylor wrote:
I'd like top-post and hijack this thread for another exception related
thing:
a) Anyone writing code such as:
try:
blah()
except SomeException:
raise SomeOtherExceptionLeavingOutStackContextFromSomeException
should be mocked
On Thu, Jul 11, 2013 at 5:20 AM, Mark McLoughlin mar...@redhat.com wrote:
But I think what you're saying is missing is the stack trace from the
underlying exception.
As I understood it, Python doesn't have a way of chaining exceptions
like this but e.g. Java does. A little bit more poking
HI folks
I would like to ask the review criteria in the community.
Should we use exception for non-exceptional cases when we can use
parameter checking?
Example1: Default value for array index
try:
value = list[5]
except IndexError:
value = 'default_value'
This can be also written
On Wed, Jul 10, 2013 at 1:01 PM, Nachi Ueno na...@ntti3.com wrote:
HI folks
I would like to ask the review criteria in the community.
Should we use exception for non-exceptional cases when we can use
parameter checking?
Example1: Default value for array index
try:
value = list[5]
On Wed, 2013-07-10 at 11:01 -0700, Nachi Ueno wrote:
HI folks
I would like to ask the review criteria in the community.
Should we use exception for non-exceptional cases when we can use
parameter checking?
Example1: Default value for array index
try:
value = list[5]
except
Hi Mark
Thank you for your answering
I don't think this statement contradicts the intent of EAFP.
I got it :)
Personally, I prefer not to use exception for such cases.
My instinct is the same, but EAFP does seem to be the python way. There
are times I can tolerate the EAFP approach but,
On Wed, Jul 10, 2013 at 8:32 PM, Mark McLoughlin mar...@redhat.com wrote:
On Wed, 2013-07-10 at 11:01 -0700, Nachi Ueno wrote:
Personally, I prefer not to use exception for such cases.
The key here is personally. I don't think we have to agree on all style
issues.
My instinct is the
Hi Thomas
Thank you for your reply.
The key here is personally. I don't think we have to agree on all style
issues.
personally is why I'm asking it for communities.
IMO, we should agree on the style issue as much as we can. (Eg pep8, flake8)
for more consistant review.
However, I also agree
On 07/10/2013 02:01 PM, Nachi Ueno wrote:
HI folks
I would like to ask the review criteria in the community.
Should we use exception for non-exceptional cases when we can use
parameter checking?
Example1: Default value for array index
try:
value = list[5]
except IndexError:
value
On Wed, Jul 10, 2013 at 3:57 PM, David Ripton drip...@redhat.com wrote:
On 07/10/2013 02:01 PM, Nachi Ueno wrote:
HI folks
I would like to ask the review criteria in the community.
Should we use exception for non-exceptional cases when we can use
parameter checking?
Example1: Default
On Wed, Jul 10, 2013 at 3:30 PM, Doug Hellmann
doug.hellm...@dreamhost.comwrote:
On Wed, Jul 10, 2013 at 3:57 PM, David Ripton drip...@redhat.com wrote:
On 07/10/2013 02:01 PM, Nachi Ueno wrote:
HI folks
I would like to ask the review criteria in the community.
Should we use exception
22 matches
Mail list logo