Path PEP: What should Path(None) do?

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Mon Jul 25 12:06:02 EDT 2005


Peter Hansen wrote:
> 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(None)
> path(u'None')
>  >>> path(object())
> path(u'<object object at 0x00AAB438>')
>  >>> path(3.14159)
> path(u'3.14159')
> 
> 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.

Settled.

Reinhold



More information about the Python-list mailing list