Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64032 > unrolled thread
| Started by | Rita <rmorgan466@gmail.com> |
|---|---|
| First post | 2014-01-15 20:09 -0500 |
| Last post | 2014-01-15 20:09 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
data validation when creating an object Rita <rmorgan466@gmail.com> - 2014-01-15 20:09 -0500
| From | Rita <rmorgan466@gmail.com> |
|---|---|
| Date | 2014-01-15 20:09 -0500 |
| Subject | data validation when creating an object |
| Message-ID | <mailman.5554.1389834588.18130.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
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 call the object like this
x=Foo()
x.validateData()
Is this the preferred way? Is there a way I can run validateData()
automatically, maybe put it in __init__? Or are there other techniques
people use for this sort of thing?
--
--- Get your facts first, then you can distort them as you please.--
Back to top | Article view | comp.lang.python
csiph-web