[Tutor] help with a class

John washakie at gmail.com
Thu Aug 25 10:30:56 CEST 2011


Thanks for the feedback. I wasn't aware about the assert usage not
being intended for production code.

On Wed, Aug 24, 2011 at 11:37 PM, Alan Gauld <alan.gauld at btinternet.com> wrote:
> On 24/08/11 21:03, Prasad, Ramit wrote:
>>
>> I was under the impression that asserts are more for testing
>
>> than for production code
>
> That's true.
>
>> def overide_options(self, options, run_id=None):
>>
>>         if not isinstance(options, dict):
>>                 raise TypeError("override options requires a dict")
>
> This is good if you want to keep the check in for production.
> But using an assert here while testing then removing it from production
> would be a valid use too. The typecheck is not required for the function to
> work if you are confident of the data being passed in. assert checks the
> data while you are gaining that confidence.
>
> So either approach is valid.
> It all depends on how variable your input data is going to be.
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Configuration
``````````````````````````
Plone 2.5.3-final,
CMF-1.6.4,
Zope (Zope 2.9.7-final, python 2.4.4, linux2),
Python 2.6
PIL 1.1.6
Mailman 2.1.9
Postfix 2.4.5
Procmail v3.22 2001/09/10
Basemap: 1.0
Matplotlib: 1.0.0


More information about the Tutor mailing list