473,493 Members | 2,265 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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


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.

Sep 21 '08 #1
4 1476
On Sep 19, 1:37*pm, "John [H2O]" <washa...@gmail.comwrote:
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
Sep 21 '08 #2
On Sep 20, 6:37*am, "John [H2O]" <washa...@gmail.comwrote:
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?
Sep 21 '08 #3
John [H2O] wrote:
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?
No, it means you actually have a file named 'EN*' in the directory.

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
Many would be cowards if they had courage enough.
-- Thomas Fuller
Sep 22 '08 #4

No bug indeed, Erik was correct, in fact I had files with the * in the
name...

Thanks all for your replies!
Erik Max Francis wrote:
>
John [H2O] wrote:
>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?

No, it means you actually have a file named 'EN*' in the directory.

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
Many would be cowards if they had courage enough.
-- Thomas Fuller
--
http://mail.python.org/mailman/listinfo/python-list

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

Sep 23 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
3054
by: Georgy Pruss | last post by:
On Windows XP glob.glob doesn't work properly for files without extensions. E.g. C:\Temp contains 4 files: 2 with extensions, 2 without. C:\Temp>dir /b * aaaaa.aaa bbbbb.bbb ccccc ddddd ...
6
1484
by: Eric | last post by:
Pythonistas, I seem at a loss for a List Comprehension syntax that will do what I want. I have a list of string position spans: >>> breaks the first pair representing: someString
4
3418
by: Python Dunce | last post by:
I've run into an issue with glob and matching filenames with brackets '' in them. The problem comes when I'm using part of such a filename as the path I'm passing to glob. Here's a trimmed down...
1
7501
by: Tony | last post by:
Hello All, I'm having difficulty in using the glob function with stat. Here is a simple piece of code – ----------------------------------------------------------- #! /usr/bin/perl -w use...
8
8437
by: Neil Webster | last post by:
Hi, I was wondering whether anybody could help me out. I have a program, for part of it I am trying to pass a variable to a glob function, this returns an empty list. The strange thing is...
6
3279
by: Hitesh | last post by:
import string import os f = open ("c:\\servername.txt", 'r') linelist = f.read() lineLog = string.split(linelist, '\n') lineLog = lineLog #print lineLog for l in lineLog:
5
1537
by: PythonNewbie | last post by:
Hello, so I needed to write a quick code that lets me merge whole bunch of text files in a given folder into one text file. So, I wrote this up after reading about glob import glob...
8
2354
by: mark.bergman | last post by:
I am porting from Digital Unix to Linux (RHEL 4), and am seeing a difference in the return value of glob(). Given a non-existant directory "/tmp/a", and the following line of code: result =...
5
2389
by: jo3c | last post by:
hi everyone happy new year! im a newbie to python i have a question by using linecache and glob how do i read a specific line from a file in a batch and then insert it into database? because...
0
7119
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5453
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.