shelve file name extention

Discussion in 'Python' started by Monu, Sep 8, 2008.

  1. Monu

    Monu Guest

    Hi All,
    When I am using shelve on my local machine it generates the db file as
    given filename. But in another machine it's generating <filename>.dat
    and .dir.
    can anyone tell me how can I force sheve module to write the db in
    <filename>.dir and <filename>.dat, instead of <filename>? Do I have to
    install a specific version of the python?

    Thanks...
    Monu
    Monu, Sep 8, 2008
    #1
    1. Advertising

  2. Monu

    Guest

    Monu> When I am using shelve on my local machine it generates the db
    Monu> file as given filename. But in another machine it's generating
    Monu> <filename>.dat and .dir. can anyone tell me how can I force sheve
    Monu> module to write the db in <filename>.dir and <filename>.dat,
    Monu> instead of <filename>? Do I have to install a specific version of
    Monu> the python?

    Shelve is just a thin layer on top of a concrete db file module. Sounds
    like on your two machines there are different underlying db file modules
    available. You're pretty much at the mercy of those modules as to file
    naming. All you are giving it when opening a shelve file is the prefix.

    Skip
    , Sep 8, 2008
    #2
    1. Advertising

  3. Monu

    Monu Guest

    On Sep 8, 1:47 pm, wrote:
    >     Monu> When I am using shelve on my local machine it generates the db
    >     Monu> file as given filename. But in another machine it's generating
    >     Monu> <filename>.dat and .dir.  can anyone tell me how can I force sheve
    >     Monu> module to write the db in <filename>.dir and <filename>.dat,
    >     Monu> instead of <filename>? Do I have to install a specific version of
    >     Monu> the python?
    >
    > Shelve is just a thin layer on top of a concrete db file module.  Sounds
    > like on your two machines there are different underlying db file modules
    > available.  You're pretty much at the mercy of those modules as to file
    > naming.  All you are giving it when opening a shelve file is the prefix..
    >
    > Skip


    Thanks Skip.
    So Can't I choose which module to use. Is there any preferance on
    which shelve chooses these modules?
    Monu, Sep 11, 2008
    #3
  4. Monu

    Monu Guest

    On Sep 8, 1:47 pm, wrote:
    >     Monu> When I am using shelve on my local machine it generates the db
    >     Monu> file as given filename. But in another machine it's generating
    >     Monu> <filename>.dat and .dir.  can anyone tell me how can I force sheve
    >     Monu> module to write the db in <filename>.dir and <filename>.dat,
    >     Monu> instead of <filename>? Do I have to install a specific version of
    >     Monu> the python?
    >
    > Shelve is just a thin layer on top of a concrete db file module.  Sounds
    > like on your two machines there are different underlying db file modules
    > available.  You're pretty much at the mercy of those modules as to file
    > naming.  All you are giving it when opening a shelve file is the prefix..
    >
    > Skip


    Thanks Skip.
    So Can't I choose which module to use. Is there any preferance on
    which shelve chooses these modules?
    Monu, Sep 11, 2008
    #4
  5. Monu wrote:

    > So Can't I choose which module to use. Is there any preferance on
    > which shelve chooses these modules?


    it uses the anydbm module to look for available DBM-style drivers, which
    looks for modules in the following order: dbhash, gdbm, dbm, dumbdbm.

    if you know which one you want, you can open the database file yourself,
    and pass it to the Shelf constructor:

    import shelve
    import somedbm

    db = shelve.Shelf(somedbm.open(file, flag))

    </F>
    Fredrik Lundh, Sep 11, 2008
    #5
    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. Carl Ogawa

    How do I make .cgi extention work?

    Carl Ogawa, Dec 27, 2003, in forum: Perl
    Replies:
    1
    Views:
    988
  2. Howard

    change file extention

    Howard, Jan 5, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    2,021
    Teemu Keiski
    Jan 5, 2006
  3. shilpa
    Replies:
    3
    Views:
    8,817
    shilpa
    Jun 30, 2005
  4. Jesper Olsen

    C++ extention

    Jesper Olsen, Nov 18, 2003, in forum: Python
    Replies:
    2
    Views:
    441
    Jesper Olsen
    Nov 18, 2003
  5. Ron

    Get file extention from path

    Ron, Jul 21, 2003, in forum: Perl Misc
    Replies:
    5
    Views:
    123
Loading...

Share This Page