Null pattern

G

George Sakkis

I'd like to extend the Null pattern from
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/68205 to
handle special methods (e.g. Null[3], del Null['key'], Null+1) but
it's not always clear how to do it while keeping the behavior
consistent and intuitive.

For example, consider the container methods __len__, __iter__ and
__contains__. The obvious choice for a null container is an empty one.
When taking __getitem__ into account though, the behaviour looks
inconsistent:
0

Another group of methods is rich comparisons: Should Null > x be
allowed and if so, what it should return ?

Then again, perhaps Null is an inherently domain-specific notion and
there are no general answers to such questions, in which case it
doesn't make sense trying to define an all-purpose Null object.

George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,269
Latest member
vinaykumar_nevatia23

Latest Threads

Top