Aahz wrote:
In article mailman.2244.1261418090.2873.python-l...@python.org,
Jean-Michel Pichavant jeanmic...@sequans.com wrote:
class A:
def __init__(self, foo = None, bar = None):
if len(foo) 5:
raise ValueError('foo cannot exceed 5 characters')
Bad Idea
In article mailman.2244.1261418090.2873.python-l...@python.org,
Jean-Michel Pichavant jeanmic...@sequans.com wrote:
class A:
def __init__(self, foo = None, bar = None):
if len(foo) 5:
raise ValueError('foo cannot exceed 5 characters')
Bad Idea -- what happens when
In article mailman.2271.1261450134.2873.python-l...@python.org,
Steve Holden st...@holdenweb.com wrote:
SNIP
What's the exact reason for requiring that a creator argument be of a
specific type? So operations on the instances don't go wrong? Well, why
not just admit that we don't have control
On Mon, Jan 4, 2010 at 10:17 AM, Albert van der Horst
alb...@spenarnc.xs4all.nl wrote:
snip
This triggers a question: I can see the traceback, but it
would be much more valuable, if I could see the arguments
passed to the functions. Is there a tool?
print(locals()) #this actually gives the
Steve Holden st...@holdenweb.com wrote:
What's the exact reason for requiring that a creator argument be of a
specific type? So operations on the instances don't go wrong? Well, why
not just admit that we don't have control over everything, and just *let
things go wrong* when the wrong type is
En Mon, 04 Jan 2010 15:17:04 -0300, Albert van der Horst
alb...@spenarnc.xs4all.nl escribió:
This triggers a question: I can see the traceback, but it
would be much more valuable, if I could see the arguments
passed to the functions. Is there a tool?
Yes, the cgitb module [1]. Despite its
In article mailman.423.1262627230.28905.python-l...@python.org,
Chris Rebert c...@rebertia.com wrote:
On Mon, Jan 4, 2010 at 10:17 AM, Albert van der Horst
alb...@spenarnc.xs4all.nl wrote:
snip
This triggers a question: I can see the traceback, but it
would be much more valuable, if I could see
Denis Doria a écrit :
Hi;
I'm checking the best way to validate attributes inside a class. Of
course I can use property to check it, but I really want to do it
inside the __init__:
If you use a property, you'll have the validation in the initializer AND
everywhere else too. If you care about
Steve Holden a écrit :
(snip)
What's the exact reason for requiring that a creator argument be of a
specific type? So operations on the instances don't go wrong? Well, why
not just admit that we don't have control over everything, and just *let
things go wrong* when the wrong type is passed?
Bruno Desthuilliers wrote:
Steve Holden a écrit :
(snip)
What's the exact reason for requiring that a creator argument be of a
specific type? So operations on the instances don't go wrong? Well, why
not just admit that we don't have control over everything, and just *let
things go wrong*
On 12/22/2009 8:52 PM, Bruno Desthuilliers wrote:
Steve Holden a écrit :
(snip)
What's the exact reason for requiring that a creator argument be of a
specific type? So operations on the instances don't go wrong? Well, why
not just admit that we don't have control over everything, and just *let
Hi;
I'm checking the best way to validate attributes inside a class. Of
course I can use property to check it, but I really want to do it
inside the __init__:
class A:
def __init__(self, foo, bar):
self.foo = foo #check if foo is correct
self.bar = bar
All examples that I
On Mon, Dec 21, 2009 at 9:41 AM, Denis Doria denisdo...@gmail.com wrote:
All examples that I saw with property didn't show a way to do it in
the __init__. Just to clarify, I don't want to check if the parameter
is an int, or something like that, I want to know if the parameter do
not use more
Denis Doria wrote:
Hi;
I'm checking the best way to validate attributes inside a class. Of
course I can use property to check it, but I really want to do it
inside the __init__:
class A:
def __init__(self, foo, bar):
self.foo = foo #check if foo is correct
self.bar = bar
* Denis Doria:
I thought in something like:
class A:
def __init__(self, foo = None, bar = None):
set_foo(foo)
self._bar = bar
def set_foo(self, foo):
if len(foo) 5:
raise something
_foo = foo
foo = property(setter = set_foo)
But looks
Denis Doria wrote:
Hi;
I'm checking the best way to validate attributes inside a class. Of
course I can use property to check it, but I really want to do it
inside the __init__:
class A:
def __init__(self, foo, bar):
self.foo = foo #check if foo is correct
self.bar
On Mon, 21 Dec 2009 09:41:22 -0800, Denis Doria wrote:
Hi;
I'm checking the best way to validate attributes inside a class.
There is no best way, since it depends on personal taste.
Of
course I can use property to check it, but I really want to do it inside
the __init__:
If you really
On 12/22/2009 4:41 AM, Denis Doria wrote:
Hi;
I'm checking the best way to validate attributes inside a class. Of
course I can use property to check it, but I really want to do it
inside the __init__:
class A:
def __init__(self, foo, bar):
self.foo = foo #check if foo is correct
On Mon, 21 Dec 2009 21:49:11 +, r0g wrote:
I use assertions myself e.g.
foo = 123456
assert len(foo) = 5
Traceback (most recent call last):
File stdin, line 1, in module
AssertionError
Dunno if this would be considered good or bad programming practice by
those more experienced
Steven D'Aprano wrote:
On Mon, 21 Dec 2009 21:49:11 +, r0g wrote:
I use assertions myself e.g.
foo = 123456
assert len(foo) = 5
Traceback (most recent call last):
File stdin, line 1, in module
AssertionError
Dunno if this would be considered good or bad programming practice by
r0g wrote:
Steven D'Aprano wrote:
On Mon, 21 Dec 2009 21:49:11 +, r0g wrote:
I use assertions myself e.g.
foo = 123456
assert len(foo) = 5
Traceback (most recent call last):
File stdin, line 1, in module
AssertionError
Dunno if this would be considered good or bad programming
On Tue, 22 Dec 2009 00:18:21 +, r0g wrote:
Yikes, glad to be set me straight on that one! Thanks :) It's a pity
though, I really like the way it reads. Is there anything similar with
ISN'T disabled when optimizations are turned on?
Yes: an explicit test-and-raise.
if not condition:
22 matches
Mail list logo