PyWart: os.path needs immediate attention!

Michael Poeltl michael.poeltl at univie.ac.at
Sat Jul 30 02:30:47 CEST 2011


join 'Python-Dev'-mailinglist and tell them!                                    
from now on I will just ignore threads you initiated

does trolling really make that much fun?
* rantingrick <rantingrick at gmail.com> [2011-07-29 19:25]:
> 
> --------------------------------------------------
>  Overview of Problems:
> --------------------------------------------------
> 
>  * Too many methods exported.
>  * Poor choice of method names.
>  * Non public classes/methods exported!
>  * Duplicated functionality.
> 
> --------------------------------------------------
>  Proposed new functionality:
> --------------------------------------------------
> 
>  * New path module will ONLY support one path sep! There is NO reason
> to support more than one. When we support more than one path sep we
> help to propagate multiplicity.We should only support the slash and
> NOT the backslash across ALL OS's since the slash is more widely
> accepted. If an OS does not have the capability to support only the
> slash then that OS is not worthy of a Python builtin module. The users
> of such OS will be responsible for managing their OWN os_legacy.path
> module. We are moving forward. Those who wish to wallow in the past
> will be left behind.
> 
>  * Introduce a new method named "partition" which (along with string
> splitting methods) will replace the six methods "basename", "dirname",
> "split", "splitdrive", "splitunc", "splittext". The method will return
> a tuple of the path split into four parts: (drive, path, filename,
> extension). This is the ONLY splitting method this module needs. All
> other splits can use string methods.
> 
> --------------------------------------------------
>  Expose of the Warts of current module:
> --------------------------------------------------
> 
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~
>  1. Too many methods
> ~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Follows is a list of what to keep and what to cull:
> 
>  + abspath
>  + altsep
>  - basename --> path.partition[-2]
>  + commonprefix
>  + curdir
>  + defpath
>  + devnull
>  - dirname --> os.path.join(drive,path)
>  + exists
>  + expanduser
>  + expandvars
>  + extsep
>  - genericpath --> should be private!
>  + getatime
>  + getctime
>  + getmtime
>  + getsize
>  + isabs
>  + isdir
>  + isfile
>  + islink
>  + ismount
>  + join
>  - lexists --> duplicate!
>  - normcase --> path = path.lower()
>  - normpath --> should not need this!
>  - os --> should be private!
>  + pardir
>  + pathsep
>  + realpath
>  + relpath
>  + sep
>  - split --> path.rsplit('/', 1)
>  - splitdrive --> path.split(':', 1)
>  - splitext --> path.rsplit('.')
>  - splitunc --> Unix specific!
>  - stat --> should be private!
>  + supports_unicode_filenames --> windows specific!
>  - sys --> should be private!
>  + walk
>  - warnings --> should be private!
> 
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~
>  2. Poor Name Choices:
> ~~~~~~~~~~~~~~~~~~~~~~~~~
> 
>  * basename --> should be: filename
>  * split --> split what?
>  * splitext --> Wow, informative!
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~
>  3. Non Public Names Exposed!
> ~~~~~~~~~~~~~~~~~~~~~~~~~
> 
>  * genericpath
>  * os
>  * stat
>  * sys
>  * warnings
> 
> 
> Note: i did not check the Unix version of os.path for this.
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~
>  4. Duplicated functionality.
> ~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> >>> os.path.lexists.__doc__
> 'Test whether a path exists.  Returns False for broken symbolic links'
> >>> os.path.exists.__doc__
> 'Test whether a path exists.  Returns False for broken symbolic links'
> 
> Should have been one method:
> >>> os.path.exists(path, ignoreSymLnks=False)
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 

-- 
Michael Poeltl
Computational Materials Physics      voice: +43-1-4277-51409
Univ. Wien, Sensengasse 8/12         fax:   +43-1-4277-9514 (or 9513) 
A-1090 Wien, AUSTRIA   cmp.mpi.univie.ac.at 



More information about the Python-list mailing list