Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64036 > unrolled thread

Re: data validation when creating an object

Started byMark Lawrence <breamoreboy@yahoo.co.uk>
First post2014-01-16 01:26 +0000
Last post2014-01-16 01:26 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: data validation when creating an object Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-16 01:26 +0000

#64036 — Re: data validation when creating an object

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2014-01-16 01:26 +0000
SubjectRe: data validation when creating an object
Message-ID<mailman.5558.1389835628.18130.python-list@python.org>
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 Python I don't ever recall seeing 
this, could we have a reference please.

>
> 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.--
>
>


-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web