Thanks everyone for the replies.
On Thu, Jan 16, 2014 at 1:36 AM, Cameron Simpson c...@zip.com.au wrote:
On 16Jan2014 15:53, Ben Finney ben+pyt...@benfinney.id.au wrote:
Roy Smith r...@panix.com writes:
Ben Finney ben+pyt...@benfinney.id.au wrote:
Who says it's frowned on to do
On Thursday, January 16, 2014 10:46:10 AM UTC-5, Robert Kern wrote:
I prefer to keep my __init__() methods as dumb as possible to retain the
flexibility to construct my objects in different ways. Sure, it's convenient
to,
say, pass a filename and have the __init__() open() it for me. But
I suspect when best to validate inputs depends on when they
come in, and what the cost is of having objects with invalid
state. If the input is something that is passed along when
the object is instantiated, you kind of have to validate in
__init__ or __new__, right?
Let's create a stupid
On 2014-01-16 16:18, Roy Smith wrote:
On Thursday, January 16, 2014 10:46:10 AM UTC-5, Robert Kern wrote:
I prefer to keep my __init__() methods as dumb as possible to retain the
flexibility to construct my objects in different ways. Sure, it's convenient to,
say, pass a filename and have the
On 2014-01-16 04:05, Roy Smith wrote:
Rita rmorgan...@gmail.com writes:
I know its frowned upon to do work in the __init__() method and only
declarations should be there.
In article mailman..1389834993.18130.python-l...@python.org,
Ben Finney ben+pyt...@benfinney.id.au wrote:
Who
I would like to do some data validation when its going to a class.
class Foo(object):
def __init__(self):
pass
I know its frowned upon to do work in the __init__() method and only
declarations should be there.
So, should i create a function called validateData(self) inside foo?
I would
Rita rmorgan...@gmail.com writes:
I would like to do some data validation when its going to a class.
class Foo(object):
def __init__(self):
pass
I know its frowned upon to do work in the __init__() method and only
declarations should be there.
Who says it's frowned on to do work in
On 15Jan2014 20:09, Rita rmorgan...@gmail.com wrote:
I would like to do some data validation when its going to a class.
class Foo(object):
def __init__(self):
pass
I know its frowned upon to do work in the __init__() method and only
declarations should be there.
This rule of thumb
On 16/01/2014 01:09, Rita wrote:
I would like to do some data validation when its going to a class.
class Foo(object):
def __init__(self):
pass
I know its frowned upon to do work in the __init__() method and only
declarations should be there.
In the 10+ years that I've been using
On Thu, Jan 16, 2014 at 12:25 PM, Cameron Simpson c...@zip.com.au wrote:
However, I would also have obvious validity checks in __init__
itself on the supplied values. Eg:
def __init__(self, size, lifetime):
if size 1:
raise ValueError(size must be = 1, received: %r % (size,))
Unfortunately, I couldn't find the reference but I know I read it
somewhere. Even with a selective search I wasn't able to find it. I think I
read it in context of module/class test case writing.
I will keep your responses in mind therefore I will put logic in __init__
for data validation.
On 1/15/2014 8:09 PM, Rita wrote:
I know its frowned upon to do work in the __init__() method and only
declarations should be there.
Dear Python beginners:
Don't believe the Python rules people write unless it is by one of the
core developers or one of the other experts posting here. Even
Rita rmorgan...@gmail.com writes:
I know its frowned upon to do work in the __init__() method and only
declarations should be there.
In article mailman..1389834993.18130.python-l...@python.org,
Ben Finney ben+pyt...@benfinney.id.au wrote:
Who says it's frowned on to do work in the
Roy Smith r...@panix.com writes:
Ben Finney ben+pyt...@benfinney.id.au wrote:
Who says it's frowned on to do work in the initialiser? Where are they
saying it? That seems over-broad, I'd like to read the context of that
advice.
There are some people who advocate that C++ constructors
In article mailman.5567.1389848051.18130.python-l...@python.org,
Ben Finney ben+pyt...@benfinney.id.au wrote:
Roy Smith r...@panix.com writes:
But, Python is not C++. I suspect the people who argue for __init__()
not doing much are extrapolating a C++ pattern to other languages
without
On 16Jan2014 12:46, Chris Angelico ros...@gmail.com wrote:
On Thu, Jan 16, 2014 at 12:25 PM, Cameron Simpson c...@zip.com.au wrote:
However, I would also have obvious validity checks in __init__
itself on the supplied values. Eg:
def __init__(self, size, lifetime):
if size 1:
On 16Jan2014 15:53, Ben Finney ben+pyt...@benfinney.id.au wrote:
Roy Smith r...@panix.com writes:
Ben Finney ben+pyt...@benfinney.id.au wrote:
Who says it's frowned on to do work in the initialiser? Where are they
saying it? That seems over-broad, I'd like to read the context of that
17 matches
Mail list logo