Why is the shutil module called shutil?

C

Chris Rebert

The topic says it all:
Why is shutil named shutil? What does it stand for? This is just a
mild curiosity of mine.

"sh" is short for "shell", in line with Unix convention, where the
default shell is located at /bin/sh.
http://en.wikipedia.org/wiki/Shell_(computing)
http://en.wikipedia.org/wiki/Unix_shell

"util" is short for "utilities".

shutil is a utility module used to accomplish tasks which one often
does when in the shell, such as copying, moving, or removing directory
trees. But shutil (to my knowledge) is not implemented using shell
commands or by running external programs, so it thus avoids a whole
host of shell-related issues.

It's not the best name, but what with backwards compatibility and all,
it's unlikely to change any time soon.

Cheers,
Chris
 
D

Dennis Lee Bieber

The topic says it all:
Why is shutil named shutil? What does it stand for? This is just a
mild curiosity of mine.
The shutil module for reference: http://docs.python.org/library/shutil.html#module-shutil

SHell UTILities -- ie; Python internal methods for doing things that
the typical UNIX/LINUX shell commands would do. Gives somewhat more
control than doing os.system("shellcommand"), and doesn't require
starting/stopping a shell process for each command.
 
F

Fletcher Johnson

"sh" is short for "shell", in line with Unix convention, where the
default shell is located at /bin/sh.http://en.wikipedia.org/wiki/Shell_(computing)http://en.wikipedia.org/wiki/Unix_shell

"util" is short for "utilities".

shutil is a utility module used to accomplish tasks which one often
does when in the shell, such as copying, moving, or removing directory
trees. But shutil (to my knowledge) is not implemented using shell
commands or by running external programs, so it thus avoids a whole
host of shell-related issues.

It's not the best name, but what with backwards compatibility and all,
it's unlikely to change any time soon.

Cheers,
Chris
--http://rebertia.com

I had a hunch it might have been that.
 
M

Matt Joiner

Please continue

Because even after 20 freaking years of evolution Python "heads of
state" (or states of head) cannot be bi-partisan enough to agree on a
freaking File and/or path object; remind you of any "body" we know?
 
R

rantingrick

Please continue

Well specifically we should have a look over the Ruby API's of "File",
"Dir", and "IO". I don't believe we should copy them verbatim --as the
Ruby API is not Pythonic-- however, it may be a good starting point
for something that has been decades overdue within this community.

There was the rejected Path object from PEP 355:
http://www.python.org/dev/peps/pep-0355/

But it seems the "Anointed One" tossed the idea due to it's
"versatility" and it being a subclass of string... is he joking? o_O

First of all, what the hell is wrong with versatility Mr Van Rossum?
Where else would you put these methods? True it may be a large
collection, however, can YOU offer any suggestions as to where else we
would put them or are YOU just going to latch on to your prejudices of
path objects like your irrational fears of functional programming? Do
you remember the map and lambda fiasco?

We need you to get on board and push something through. When you hide
your head in the sand and imagine everything is "peachy cream" you
expose your backside for a swift kicking.

[References:]

Ruby File Object:
http://www.ruby-doc.org/core/classes/File.html

Ruby Dir Object:
http://ruby-doc.org/core/classes/Dir.html

Ruby IO Object:
http://www.ruby-doc.org/core/classes/IO.html
 
D

Devin Jeanpierre

Well specifically we should have a look over the Ruby API's of "File",
"Dir", and "IO". I don't believe we should copy them verbatim --as the
Ruby API is not Pythonic-- however, it may be a good starting point
for something that has been decades overdue within this community.

Perhaps you would be interested in one of the recent threads on Python-Ideas.

http://mail.python.org/pipermail/python-ideas/2011-September/011559.html

Also please stop being abrasive and personally attacking other members
of the Python community.

Devin

Please continue

Well specifically we should have a look over the Ruby API's of "File",
"Dir", and "IO". I don't believe we should copy them verbatim --as the
Ruby API is not Pythonic-- however, it may be a good starting point
for something that has been decades overdue within this community.

There was the rejected Path object from PEP 355:
   http://www.python.org/dev/peps/pep-0355/

But it seems the "Anointed One" tossed the idea due to it's
"versatility" and it being a subclass of string... is he joking? o_O

First of all, what the hell is wrong with versatility Mr Van Rossum?
Where else would you put these methods? True it may be a large
collection, however, can YOU offer any suggestions as to where else we
would put them or are YOU just going to latch on to your prejudices of
path objects like your irrational fears of functional programming? Do
you remember the map and lambda fiasco?

We need you to get on board and push something through. When you hide
your head in the sand and imagine everything is "peachy cream" you
expose your backside for a swift kicking.

[References:]

Ruby File Object:
    http://www.ruby-doc.org/core/classes/File.html

Ruby Dir Object:
   http://ruby-doc.org/core/classes/Dir.html

Ruby IO Object:
   http://www.ruby-doc.org/core/classes/IO.html
 
R

rantingrick

Here is a *very* rough outline of my ideas. There are probably a few
mistakes in there. I've decided on three main main objects. A File
object, a Path object, and a Dir object.


## START ENLIGHTENMENT ##

class Path:
def __init__(self, path):
#
# Properties about the path:
drive => str
directory => str
filename => str
extension => str
uncshare[1]=> ???
#
# Mutations.
def coerce(self) => File or Dir
def normalize(self): => ip or Path? #normcase/normpath
def expand_user(self): => ip or Path?
def expand_vars(self): => ip or Path?
def absolute(self) => ip or Path? #realpath/abspath
def strip(self) => ip => remove one extension.
def chmod(self, mode) => None
def chown(self, uid, gid) => None [1]
def rename(self, newname) => None
def access(self, mode): => None #access
def chroot(self) => None
#
# Introspection.
def is_valid(self): # exists
def is_absolute(self): #isabs
def is_directory(self): #isdir
def is_file(self): #isfile
def is_link(self): #islnk
def is_mount(self): #ismount
def is_identical(self, other): #issamefile
def time_accessed(self): #atime
def time_modified(self): #mtime
def time_changed(self): #ctime
## def utime(self, times) => None
#
# Inspection.
def info_stat(self): #stat
def info_lstat(self): #lstat
def info_statvfs(self): #statvfs
#
# Extraction.
def basename(self): => str
#Do we need basename when properties exist?
def partition(self) => (drive, path, filename, extension)
#Do we need partition when properties exist?
def splitunc(self): ???
def splitall(self): ???
def relpathto(self, dest): => ???
def pathconf(self, name): #pathconfig
#
# Modifying operations on links
def link(self, newpath): ...
def symlink(self, newlink): ...
def readlink(self): ...
def readlinkabs(self): ...

class File:
def new(path)
(...All existing file methods here...)
#
# Mutate, Clone, Destroy.
def rename(self, newname) => ip or File?
def delete(self, overwrites=3) => None
def copy(self, dst) => File
def unlink(self) => None #
#
# Attribute mutation.
def update(self) => None #touch
def copy_mode(src) => None #copymode
def copy_stat(src) => None #copystat
def update_mode(dst) => None
def update_stat(dst) => None
#
# Other
def bytes(self): => int => 1292894
def size(self, fmtstr="{0:0.2f}") => str => "1.23 MB"
def backup(self) => filename.bak{count}


class Dir:
def new(path)
def open(path)
#
# Mutate, Clone, Destroy.
def delete(self, onerror=None): => None
def copy(self, dst, symlinks=True): => Dir
#
# Introspection.
def get_paths(self, pattern=None): [Path, Path, ...]
def get_dirs(self, pattern=None): => [Dir, Dir, ...]
def get_files(self, pattern=None): => [File, File, ...]
#
def walk_paths(self, pattern=None): itereach->PathObj
def walk_dirs(self, pattern=None): itereach->DirObj
def walk_files(self, pattern=None): itereach->FileObj
#
def match(self, pattern) => bool
def glob(self, pattern): => [Path, Path, ...]

#######################################
# Not sure what to do with these yet.
#######################################
def startfile(self)
# startfile should part of os anyway.

## END ENLIGHTENMENT ##
 
R

rantingrick

Oh the creative juices are flowing now!!!



class Path:
def __init__(self, path):
def __coerce__(self) => File or Dir
#
# Properties about the path:
drive => str
directory => str
filename => str
extension => str
## uncshare[1]=> ???
#
# Mutations.
def expand_user(self): => ip or Path?
def expand_vars(self): => ip or Path?
def to_normpath(self): => ip #normcase/normpath
def to_abspath(self) => ip #realpath/abspath
def set_access(self, mode) => None
def set_owner(self, uid, gid) => None
def set_root(self, path) => None
#
# Introspection.
def is_accessable(self, mode) => bool #access
def is_valid(self) => bool # exists
def is_absolute(self) => bool #isabs
def is_directory(self) => bool #isdir
def is_file(self) => bool #isfile
def is_link(self) => bool #islnk
def is_mount(self) => bool #ismount
def is_same(self, path_Dir_or_File) => bool #issamefile
#
# Inspection, Extraction
def get_abspath(self)=> Path
def get_normpath(self) => Path
## def get_atime(self) => str #atime
## def get_mtime(self) => str #mtime
## def get_ctime(self) => str #ctime
def get_stat(self) => stat #stat,lstat
## def get_statvfs(self) => stat #statvfs
## # do we really need this antiquity?

############################################################
# Question #
############################################################
# Should all the stat stuff like get_mtime, get_ctime, #
# get_atime, etc... be accessed only under get_stat? I #
# believe so! #
############################################################

def get_drive(self): => str
def get_directory(self): => str
def get_filename(self): => str (empty if is_dir)
def get_extension(self): => str (empty if is_dir)
#
def split(self) => (drive, path, filename, extension)
## def splitunc(self): ???
## def splitall(self): ???
## def relpathto(self, dest): => ???
## def pathconf(self, name): #pathconfig
#
# Modifying operations on links
def link_new(self, newpath, symbolic=False): ...
def link_read(self): ...
def link_readabs(self): ...


class File:
def new(path)
(...All existing file methods here...)
#
# Mutate, Clone, Destroy.
def rename(self, newname) => ip or File?
def delete(self, overwrites=3) => None
def copy(self, dst) => File
def unlink(self) => None #
#
# Attribute mutation.
def update(self) => None #touch
def copy_mode(src) => None #copymode
def copy_stat(src) => None #copystat
def update_mode(dst) => None
def update_stat(dst) => None
#
# Other
def get_bytes(self): => int => 1292894
def get_size(self, fmtstr="{0:0.2f}") => str => "1.23 MB"
def backup(self) => filename.bak{count}


class Dir:
def new(path)
def open(path)
#
# Mutate, Clone, Destroy.
def delete(self, onerror=None): => None
def copy(self, dst, symlinks=True): => Dir
#
# Introspection.
def get_paths(self, pattern=None): [Path, Path, ...]
def get_dirs(self, pattern=None): => [Dir, Dir, ...]
def get_files(self, pattern=None): => [File, File, ...]
def walk_paths(self, pattern=None): itereach->PathObj
def walk_dirs(self, pattern=None): itereach->DirObj
def walk_files(self, pattern=None): itereach->FileObj

############################################################
# Question #
############################################################
# Do we really need "get_*" AND "walk_*"? I believe we #
# should choose one set of three #
############################################################

def match(self, pattern) => bool
# Do we need match when re would suffice?
def glob(self, pattern): => [Path, Path, ...]

############################################################
# Excommunicated Methods.
############################################################
def startfile(self)
# startfile should part of os anyway.
 
A

alex23

Oh the creative juices are flowing now!!!

It's a pity they won't flow into a PyPI project to aggregate interest
in such replacement objects.

But please, spam us some more with your code stubs. It's a nice change
from invective.
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top