Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > appending * to glob returns files with '*' !!

Reply
Thread Tools

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

 
 
John [H2O]
Guest
Posts: n/a
 
      09-19-2008

I have a glob.glob search:

searchstring = os.path.join('path'+'EN*')
files = glob.glob(searchstring)
for f in files:
print f


___
This returns some files:
EN082333
EN092334
EN*

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

A bug?



--
View this message in context: http://www.nabble.com/appending-*-to...p19579121.html
Sent from the Python - python-list mailing list archive at Nabble.com.

 
Reply With Quote
 
 
 
 
Sean DiZazzo
Guest
Posts: n/a
 
      09-21-2008
On Sep 19, 1:37*pm, "John [H2O]" <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
alex23
Guest
Posts: n/a
 
      09-21-2008
On Sep 20, 6:37*am, "John [H2O]" <(E-Mail Removed)> 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?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
glob.glob output Hitesh Python 6 03-13-2007 03:45 PM
glob.glob unicode bug or feature Elbert Lev Python 5 08-02-2004 12:09 AM
Question about glob.glob <--newbie Sean Berry Python 3 05-04-2004 05:34 PM
RE: Bug in glob.glob for files w/o extentions in Windows Tim Peters Python 1 12-01-2003 09:22 AM
Bug in glob.glob for files w/o extentions in Windows Georgy Pruss Python 15 12-01-2003 04:04 AM



Advertisments