Leon wrote:
So I need to go back to the module including "parent" class
to define the objects that I maybe use in future as None,
You can assign them to a placeholder, with a method that always exists
but does nothing.
class NullObject(object):
def method(self, *args, **kw):
pas
On May 5, 3:25 am, Marco Mariani wrote:
> Leon wrote:
> > One way, define the object before it is used,
> > like this:
> > object = None
>
> This is a good practice anyway. Conditional existance of objects is
> quite evil. Resorting to if defined('foo') is double-plus-ugly.
This was why I asked
Leon wrote:
One way, define the object before it is used,
like this:
object = None
This is a good practice anyway. Conditional existance of objects is
quite evil. Resorting to if defined('foo') is double-plus-ugly.
The other way, using try ... catch
try:
object.method()
catch NameEr
One way, define the object before it is used,
like this:
object = None
.
.
if object is not None:
object.method()
The other way, using try ... catch
try:
object.method()
catch NameError:
pass
for big programs, which is better, or any other way?
Miles
--
http://mail.pyth