mailRe: builtins


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Edward d'Auvergne on February 20, 2007 - 15:09:
Hi Gary,

wellcome back, I hope the search for jobs and fame was fruitful

I'll definitely be around in the future. I'm not in a position to confirm anything though.


I have been trying to get the current unit tests to work from the
command line e.g. ' ./unit_test_runner.py maths_fns/test_chi2.py'.
However, most of them fail beacuase the global variable Debug is not
defined. Chris tells me that this is because debug has been added to the
python __builtins__  namespace. This  points to a couple of questions

1. why are we playing with __builtins__?

A number of relax features are placed into __builtin__, most significantly the RelaxError and RelaxWarning systems. These mimic and simply extend the normal python error and warning exception systems. I did notice that this will be an important issue for stand alone operation of individual unit tests - the calls to RelaxErrors will necessarily cause exceptions. As for a solution I don't know the best way of handling the __builtin__ objects and flags.


2. how do we get round this

I'm not sure.


as an aside __builtins__ is  'an implementation detail'
http://docs.python.org/lib/module-builtin.html and its use will prevent
relax from working on iron python, jython and pypy. So is this use of
__builtins__ something we need to reconsider...

Apart from __builtin__, how else would we have the equivalent of a 'global' variable (accessible to all parts of the program)? Are there alternative solutions to using __builtin__ or are there alternative solutions for getting the __builtin__ relax objects into the unit tests? I don't see the addition of objects to __builtin__ as a big implementation issue as __builtin__ exists in all python implementations (http://www.jython.org/docs/api/org/python/core/__builtin__.html and Google picks up the rest of the scattered docs). Wouldn't global variables have the same issue, being absent, with the stand alone unit tests? Could an alternative be the creation of a new module which sets up all the relax __builtin__ objects by importing 'error.py' and setting dummy values of 'Debug' to zero?

Cheers,

Edward



Related Messages


Powered by MHonArc, Updated Tue Feb 20 16:40:27 2007