Path PEP: What should Path(None) do?
peter at engcorp.com
Mon Jul 25 11:32:09 EDT 2005
Michael Hoffman wrote:
> Currently it returns Path('None'). This means I have to do a check on
> input before pathifying it to make sure it is not None.
> Perhaps it should throw ValueError?
Without checking, I suspect it is merely doing str(x) or unicode(x) on
whatever is passed to it:
path(u'<object object at 0x00AAB438>')
Therefore I think the question should be broadened beyond just None.
Should Path(x) simply call str(x) on the object or should it raise
ValueError or TypeError or something if it's not a basestring?
Given that pretty much *everything* in Python can have str() called on
it, I think we should ask for a modicum of type-safety here and reject
non-strings as input.
More information about the Python-list