Path inherits from basestring again

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Sat Jul 30 08:44:44 EDT 2005


NickC wrote:
> [Re: how to get at the base class]
> 
> Do you really want to have a "only works for Path" way to get at the
> base class, rather than using the canonical Path.__bases__[0]?
> 
> How about a new property in the os.path module instead? Something like
> os.path.path_type.
> 
> Then os.path.path_type is unicode if and only if
> os.path.supports_unicode_filenames is True. Otherwise,
> os.path.path_type is str.
> 
> Then converting a Path to str or unicode is possible using:
> 
> as_str_or_unicode = os.path.path_type(some_path)
> 
> The other thing is that you can simply make Path inherit from
> os.path.path_type.

That's what I suggested with Path.Base. It has the advantage that you don't have
to import os.path to get at it (Path is meant so that you can avoid os.path).

Reinhold



More information about the Python-list mailing list