What's the perfect (OS independent) way of storing filepaths ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cousin Stanley

    #16
    Re: What's the perfect (OS independent) way of storing filepaths ?

    [2] And they are right to do so. Programs that dump config files and
    directories, hidden or not, in the top level of the user's home directory
    are incredibly rude. It may have been a Unix standard for as long as
    there has been a Unix, but it's still the programming equivalent of
    coming into somebody's house and throwing your tools all over their
    living room floor.
    Personally, I feel the same way about dumping files
    into the python site-package directory ....

    For example, I've never understood why kde and qt packages
    don't use a sub-dir to house their xxxx.so libs ....

    Moving the xxxx.egg-info files into sub-dirs or their own tree
    would also clean up the site-packages dir ....


    --
    Stanley C. Kitching
    Human Being
    Phoenix, Arizona

    Comment

    • Stef Mientki

      #17
      Re: What's the perfect (OS independent) way of storing filepaths?

      Bruno Desthuilliers wrote:
      Eric Wertman a écrit :
      >>>I (again) wonder what's the perfect way to store, OS-independent,
      >>>filepaths ?
      >>
      >I'm in agreement that perfect probably isn't applicable. If I were
      >doing this myself, I might store the information in a tuple:
      >>
      >base = 'some root structure ('/' or 'C')
      >
      make it "C:\"
      wouldn't " C:/" be more universal and therefor better ?
      >
      >path = ['some','set','o f','path','name s']
      >filename = 'somefile.ext'
      >>
      >pathdata = (root,path,file name)
      >>
      >and write a couple of simple functions to reconstruct them based on
      >the os.
      >
      like, err, os.path.join ?
      Yes (because these functions don't function correctly with i.e pdb,
      which might be due to bugs in pdb).
      cheers,
      Stef

      Comment

      • Steven D'Aprano

        #18
        Re: What's the perfect (OS independent) way of storing filepaths ?

        On Mon, 20 Oct 2008 23:56:22 +0200, Stef Mientki wrote:
        Bruno Desthuilliers wrote:
        >Eric Wertman a écrit :
        >>>>I (again) wonder what's the perfect way to store, OS-independent,
        >>>>filepaths ?
        >>>
        >>I'm in agreement that perfect probably isn't applicable. If I were
        >>doing this myself, I might store the information in a tuple:
        >>>
        >>base = 'some root structure ('/' or 'C')
        >>
        >make it "C:\"
        wouldn't " C:/" be more universal and therefor better ?

        Do you really think there are Linux or Mac systems with a C: drive?

        This whole question is based on the ludicrous assumption that general
        file system paths can be platform-independent. That's a bit like trying
        to write code that is programming language-independent.


        --
        Steven

        Comment

        • Eric Wertman

          #19
          Re: What's the perfect (OS independent) way of storing filepaths ?

          Do you really think there are Linux or Mac systems with a C: drive?
          >
          This whole question is based on the ludicrous assumption that general
          file system paths can be platform-independent. That's a bit like trying
          to write code that is programming language-independent.

          That's sort of where I was going originally... just pick a way to
          store the path elements and write some simple functions (yes, many of
          them will just be os.path calls) to reconstruct them based on the
          actual needs of the application. If your root element is in
          ascii.letters then it's most likely windows machine, so adding a ':'
          and using os.path.join would be appropriate in the function.

          Comment

          • Lawrence D'Oliveiro

            #20
            Re: What's the perfect (OS independent) way of storing filepaths ?

            In message <mailman.2661.1 224419704.3487. python-list@python.org >, Stef
            Mientki wrote:
            I (again) wonder what's the perfect way to store, OS-independent,
            filepaths ?
            URLs beginning file://.

            Comment

            • Lawrence D'Oliveiro

              #21
              Re: What's the perfect (OS independent) way of storing filepaths ?

              In message <gdhs50$fj3$1@r umours.uwaterlo o.ca>, Ross Ridge wrote:
              However, the normal place to store settings on Windows is in the registry.
              Which becomes a single point of failure for the whole system.

              Comment

              • Lawrence D'Oliveiro

                #22
                Re: What's the perfect (OS independent) way of storing filepaths ?

                In message <010d03fd$0$206 60$c3e8da3@news .astraweb.com>, Steven D'Aprano
                wrote:
                Do you really think there are Linux or Mac systems with a C: drive?
                And what about files on Dimdows systems kept on a drive other than C?
                This whole question is based on the ludicrous assumption that general
                file system paths can be platform-independent.
                There is supposed to be a POSIX-compliant layer somewhere underneath all the
                Dimdows crud. You could write to that.

                Comment

                • Lawrence D'Oliveiro

                  #23
                  Re: What's the perfect (OS independent) way of storing filepaths ?

                  In message <010c838b$0$206 70$c3e8da3@news .astraweb.com>, Steven D'Aprano
                  wrote:
                  And 75% [1] of average Windows users will either delete the file, move it
                  to a more convenient[2] location, or edit the file name to remove the dot.
                  Doesn't seem very likely to me. Experienced Dimdows users would well know
                  that stuffing around with files they don't understand is liable to break
                  some application or another, so they shouldn't do it.
                  [2] And they are right to do so. Programs that dump config files and
                  directories, hidden or not, in the top level of the user's home directory
                  are incredibly rude. It may have been a Unix standard for as long as
                  there has been a Unix, but it's still the programming equivalent of
                  coming into somebody's house and throwing your tools all over their
                  living room floor.
                  Hmm, actually you have a point there. There's also the security issue, in
                  that other users can tell what apps you've been using based on the dotfiles
                  present in your home directory.

                  Comment

                  • Roel Schroeven

                    #24
                    Re: What's the perfect (OS independent) way of storing filepaths?

                    Steven D'Aprano schreef:
                    On Mon, 20 Oct 2008 10:20:06 +0000, Duncan Booth wrote:
                    >
                    >Steven D'Aprano <steve@REMOVE-THIS-cybersource.com .auwrote:
                    >>
                    >>On Sun, 19 Oct 2008 15:40:32 +0000, Duncan Booth wrote:
                    >>>
                    >>>Steven D'Aprano <steve@REMOVE-THIS-cybersource.com .auwrote:
                    >>>>
                    >>>>In Linux, config files should go into:
                    >>>>>
                    >>>>~/.<appname>/ or /etc/<appname>/
                    >>>>>
                    >>>>In Windows (which versions?) then should go into the Documents And
                    >>>>Settings folder, where ever that is.
                    >>>>>
                    >>>>There's no single string which can represent both of these
                    >>>>conventions !
                    >>>The first of those should do nicely for both Linux and Windows:
                    >>>>
                    >>>>>>os.path.n ormpath(os.path .expanduser('~/.appname'))
                    >>>'C:\\Documen ts and Settings\\Dunca n\\.appname'
                    >>>
                    >>Except Windows users will be wondering why they have a directory
                    >>starting with '.' in their home directory. Dot to make files hidden is
                    >>not AFAIK supported by Windows.
                    >>>
                    >The leading dot doesn't make the files hidden on Windows, but there's no
                    >reason why you can't create files/folders with a leading dot and many
                    >programs do just that. On the machine I'm on right now, 'dir .*' shows
                    >me:
                    [snip]
                    >
                    And 75% [1] of average Windows users will either delete the file, move it
                    to a more convenient[2] location, or edit the file name to remove the dot.
                    I don't think so: the average Windows user will never even see the files
                    in that directory; they only see the files in the 'Desktop' and 'My
                    Documents' folders.

                    --
                    The saddest aspect of life right now is that science gathers knowledge
                    faster than society gathers wisdom.
                    -- Isaac Asimov

                    Roel Schroeven

                    Comment

                    • Laszlo Nagy

                      #25
                      Re: What's the perfect (OS independent) way of storing filepaths?

                      >However, the normal place to store settings on Windows is in the registry.
                      >>
                      >
                      Which becomes a single point of failure for the whole system.
                      >
                      LOL :-)

                      BTW famous big popular programs like firefox and thunderbird will store
                      their configuration data under "Documents and Settings\Applic ation
                      data". I believe this is the standard place to store application
                      configuration data. And inside that directory, you should be able to use
                      whatever file name you want, beginning with a dot or not.

                      Users who like to go inside "Documents and Settings\Applic ation data"
                      and delete things without knowing what they do deserve to have a
                      malfunctioning system for sure.

                      BTW it would be nice to have a standard 'Application data" like
                      directory under UNIX. It is true that all kinds of programs will create
                      ..app files in your home dir which is not very polite.

                      Laszlo

                      Comment

                      • Steven D'Aprano

                        #26
                        Re: What's the perfect (OS independent) way of storing filepaths ?

                        On Tue, 21 Oct 2008 11:32:14 +0200, Laszlo Nagy wrote:
                        Users who like to go inside "Documents and Settings\Applic ation data"
                        and delete things without knowing what they do deserve to have a
                        malfunctioning system for sure.
                        The worst consequence from deleting a settings file should be to revert
                        to factory defaults (which, admittedly, may mean the software can't do
                        anything useful until you configure it). It should NEVER be malfunction
                        or data loss.

                        Of course, that's in principle. In practice, most software is
                        insufficiently defensive to work that way. In the Real World, deleting
                        settings files can have any consequence from nothing at all to serious
                        meltdown.

                        But as a matter of principle, users should be able to delete settings
                        files and lose nothing more than, well, settings. That's why it's a
                        SETTINGS file, not a DATA file. Settings should be information that can
                        be easily regenerated if lost. Anything that can't easily be regenerated,
                        like address books and bookmarks, are documents, not settings. Any
                        program which hides such documents in a hidden settings directory where
                        users can't easily make backup copies is a badly behaved program.

                        BTW it would be nice to have a standard 'Application data" like
                        directory under UNIX. It is true that all kinds of programs will create
                        .app files in your home dir which is not very polite.
                        Agreed, except I hope that when it eventually happens, the name won't
                        have a space in it, and it especially won't include the word "My" (as in
                        "My Settings", "My Preferences", or "My Application Data").


                        --
                        Steven

                        Comment

                        • Ross Ridge

                          #27
                          Re: What's the perfect (OS independent) way of storing filepaths ?

                          Ross Ridge wrote:
                          However, the normal place to store settings on Windows is in the registry.
                          Lawrence D'Oliveiro <ldo@geek-central.gen.new _zealandwrote:
                          Which becomes a single point of failure for the whole system.
                          As opposed to the file system being the single point failure?

                          Ross Ridge

                          --
                          l/ // Ross Ridge -- The Great HTMU
                          [oo][oo] rridge@csclub.u waterloo.ca
                          -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/
                          db //

                          Comment

                          • Grant Edwards

                            #28
                            Re: What's the perfect (OS independent) way of storing filepaths ?

                            On 2008-10-21, Laszlo Nagy <gandalf@shopze us.comwrote:
                            >
                            >>However, the normal place to store settings on Windows is in the registry.
                            >>>
                            >>
                            >Which becomes a single point of failure for the whole system.
                            >>
                            LOL :-)
                            >
                            BTW famous big popular programs like firefox and thunderbird
                            will store their configuration data under "Documents and
                            Settings\Applic ation data". I believe this is the standard
                            place to store application configuration data. And inside that
                            directory, you should be able to use whatever file name you
                            want, beginning with a dot or not.
                            >
                            Users who like to go inside "Documents and
                            Settings\Applic ation data" and delete things without knowing
                            what they do deserve to have a malfunctioning system for sure.
                            >
                            BTW it would be nice to have a standard 'Application data"
                            like directory under UNIX.
                            The standard is to create either a .appname file or .appname
                            directory in the user's home directory.
                            It is true that all kinds of programs will create .app files
                            in your home dir which is not very polite.
                            It _is_ polite. Polite means following the established rules
                            and doing what's expected of you. That's exactly what is
                            expected of applications under Unix.

                            --
                            Grant Edwards grante Yow! I wonder if I ought
                            at to tell them about my
                            visi.com PREVIOUS LIFE as a COMPLETE
                            STRANGER?

                            Comment

                            • Lawrence D'Oliveiro

                              #29
                              Re: What's the perfect (OS independent) way of storing filepaths ?

                              In message <gdkh1o$9f5$1@r umours.uwaterlo o.ca>, Ross Ridge wrote:
                              Lawrence D'Oliveiro <ldo@geek-central.gen.new _zealandwrote:
                              >
                              >Ross Ridge wrote:
                              >
                              >>However, the normal place to store settings on Windows is in the
                              >>registry.
                              >
                              >Which becomes a single point of failure for the whole system.
                              >
                              As opposed to the file system being the single point failure?
                              The file system is involved regardless. But leaving out an additional layer
                              of failure on top of it does make things more robust, yes. The file system
                              already has provisions for simultaneous access by multiple processes,
                              journalling, integrity checking etc; implementing a "registry" on top of
                              this means reinventing a whole separate API and architecture that has to
                              provide this sort of thing, or leave it out and suffer the well-known
                              consequences.

                              Plus the fact that the Windows Registry is actually a munging together of
                              things that are kept in quite separate places in Unix/Linux: system config
                              files versus shared read-only data versus writable data versus user prefs
                              etc. Putting all these things together just makes it more likely that
                              somebody will clobber something it didn't mean to.

                              Comment

                              • Ross Ridge

                                #30
                                Re: What's the perfect (OS independent) way of storing filepaths ?

                                Ross Ridge wrote:
                                As opposed to the file system being the single point failure?
                                Lawrence D'Oliveiro <ldo@geek-central.gen.new _zealandwrote:
                                >The file system is involved regardless. But leaving out an additional
                                >layer of failure on top of it does make things more robust, yes.
                                No, that doesn't follow. Having TCP as layer on top of IP doesn't make
                                the Internet less robust even though it's additional point of failure.
                                For the matter, settings files also have an additional layer of failure
                                in the code that intreprets and updates the setting files.
                                >The file system already has provisions for simultaneous access by multiple
                                >processes, journalling, integrity checking etc; implementing a "registry"
                                >on top of this means reinventing a whole separate API and architecture
                                >that has to provide this sort of thing, or leave it out and suffer the
                                >well-known consequences.
                                If settings files benefit from those provisions of the filesystem then
                                so does the registry. If the registry needs additional provisions so
                                do settings files for the same reasons.
                                >Plus the fact that the Windows Registry is actually a munging together of
                                >things that are kept in quite separate places in Unix/Linux: system config
                                >files versus shared read-only data versus writable data versus user prefs
                                >etc. Putting all these things together just makes it more likely that
                                >somebody will clobber something it didn't mean to.
                                Nope. Microsoft implemented the registry because users were clobbering
                                things they weren't ment to, and it succeded in making it a less likely
                                occurence.

                                Ross Ridge

                                --
                                l/ // Ross Ridge -- The Great HTMU
                                [oo][oo] rridge@csclub.u waterloo.ca
                                -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/
                                db //

                                Comment

                                Working...