appending * to glob returns files with '*' !!

Discussion in 'Python' started by John [H2O], Sep 19, 2008.

  1. John [H2O]

    John [H2O] Guest

    John [H2O], Sep 19, 2008
    #1
    1. Advertising

  2. John [H2O]

    Sean DiZazzo Guest

    On Sep 19, 1:37 pm, "John [H2O]" <> wrote:
    > I have a glob.glob search:
    >
    > searchstring = os.path.join('path'+'EN*')


    shouldn't that be os.path.join(path, 'EN*') ?

    > ___
    > This returns some files:
    > EN082333
    > EN092334
    > EN*


    Mine doesn't return that last string.

    >
    > My routine cannot handle the '*' and it should'nt be returned anyway? :-/
    >

    Well, its an easy fix.

    files = glob.glob(searchstring)
    for f in files:
    if not f[-1] =="*":
    print f

    > A bug?


    Post a small *tested* example that recreates the error on your system.

    ~Sean
     
    Sean DiZazzo, Sep 22, 2008
    #2
    1. Advertising

  3. John [H2O]

    alex23 Guest

    On Sep 20, 6:37 am, "John [H2O]" <> wrote:
    > My routine cannot handle the '*' and it should'nt be returned anyway? :-/
    >
    > A bug?


    Not at all. That's the same behaviour you'll get if you do 'ls EN*'.

    In your case, you're asking to match on anything that begins with EN,
    a subset of files that -includes- EN*.

    Why do you consider this behaviour surprising?
     
    alex23, Sep 22, 2008
    #3
    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. Georgy Pruss
    Replies:
    15
    Views:
    758
    Tim Roberts
    Dec 1, 2003
  2. Tim Peters
    Replies:
    1
    Views:
    385
    Duncan Booth
    Dec 1, 2003
  3. Sean Berry

    Question about glob.glob <--newbie

    Sean Berry, May 4, 2004, in forum: Python
    Replies:
    3
    Views:
    360
    David M. Cooke
    May 4, 2004
  4. Elbert Lev

    glob.glob unicode bug or feature

    Elbert Lev, Jul 31, 2004, in forum: Python
    Replies:
    5
    Views:
    421
    Neil Hodgson
    Aug 2, 2004
  5. Hitesh

    glob.glob output

    Hitesh, Mar 12, 2007, in forum: Python
    Replies:
    6
    Views:
    419
    Hitesh
    Mar 13, 2007
Loading...

Share This Page