Why is the shutil module called shutil?

Discussion in 'Python' started by Fletcher Johnson, Sep 24, 2011.

  1. Fletcher Johnson, Sep 24, 2011
    #1
    1. Advertising

  2. Fletcher Johnson

    Chris Rebert Guest

    On Fri, Sep 23, 2011 at 8:36 PM, Fletcher Johnson <> wrote:
    > 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
    --
    http://rebertia.com
     
    Chris Rebert, Sep 24, 2011
    #2
    1. Advertising

  3. On Fri, 23 Sep 2011 20:36:05 -0700 (PDT), Fletcher Johnson
    <> declaimed the following in
    gmane.comp.python.general:

    > 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.


    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Sep 24, 2011
    #3
  4. On Sep 23, 11:58 pm, Chris Rebert <> wrote:
    > On Fri, Sep 23, 2011 at 8:36 PM, Fletcher Johnson <>wrote:
    > > 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
    > --http://rebertia.com


    I had a hunch it might have been that.
     
    Fletcher Johnson, Sep 24, 2011
    #4
  5. Fletcher Johnson

    rantingrick Guest

    On Sep 23, 10:36 pm, Fletcher Johnson <> wrote:
    > 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


    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?
     
    rantingrick, Sep 24, 2011
    #5
  6. Fletcher Johnson

    Terry Reedy Guest

    On 9/23/2011 11:36 PM, Fletcher Johnson wrote:
    > 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


    I think it would be nice if the doc explained. Feel free to open a doc
    issue to add '(sh-ell util-ities)' or something after "The shutil " and
    add me, terry.reedy, as nosy.

    --
    Terry Jan Reedy
     
    Terry Reedy, Sep 25, 2011
    #6
  7. Fletcher Johnson

    Matt Joiner Guest

    Please continue

    On Sun, Sep 25, 2011 at 8:36 AM, rantingrick <> wrote:
    > On Sep 23, 10:36 pm, Fletcher Johnson <> wrote:
    >> 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

    >
    > 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?
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >
     
    Matt Joiner, Sep 25, 2011
    #7
  8. Fletcher Johnson

    rantingrick Guest

    On Sep 24, 11:56 pm, Matt Joiner <> wrote:
    > 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
     
    rantingrick, Sep 25, 2011
    #8
  9. > 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

    On Sun, Sep 25, 2011 at 4:30 PM, rantingrick <> wrote:
    > On Sep 24, 11:56 pm, Matt Joiner <> wrote:
    >> 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
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >
     
    Devin Jeanpierre, Sep 25, 2011
    #9
  10. Fletcher Johnson

    rantingrick Guest

    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 ##
     
    rantingrick, Sep 25, 2011
    #10
  11. Fletcher Johnson

    rantingrick Guest

    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.
     
    rantingrick, Sep 26, 2011
    #11
  12. Fletcher Johnson

    alex23 Guest

    On Sep 26, 9:50 am, rantingrick <> wrote:
    > 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.
     
    alex23, Sep 26, 2011
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Apricot
    Replies:
    4
    Views:
    559
    velthuijsen
    Apr 16, 2004
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    974
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,213
    Smokey Grindel
    Dec 2, 2006
  4. S_K
    Replies:
    6
    Views:
    1,250
    Robert Dunlop
    Nov 8, 2007
  5. klia
    Replies:
    0
    Views:
    326
Loading...

Share This Page