Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Regexp problem when parsing a string

Reply
Thread Tools

Regexp problem when parsing a string

 
 
Alessandro Marino
Guest
Posts: n/a
 
      03-21-2010
I'm a beginner and I was trying to write a program to parse recursively all
file names in a directory specified as parameter. The problem is that I get
a "None" printed to stdout when a file is positively matched. While when the
file name doesn't match the regexp the output seems ok.

C:\>c:\python.exe g:\a.py sample
====> foo - bar.txt , first part is: foo
None
skipping: foo.txt

Instead I expect an output like this one:

C:\>c:\python.exe g:\a.py sample
====> foo - bar.txt , first part is: foo
None
skipping: foo.txt

Could anyone help me to figure out why "None" appears in the putput?

Thanks and regards,
Ale

 
Reply With Quote
 
 
 
 
Steven D'Aprano
Guest
Posts: n/a
 
      03-21-2010
On Sun, 21 Mar 2010 19:12:18 +0100, Alessandro Marino wrote:

> Could anyone help me to figure out why "None" appears in the putput?


I get:

"Attachment not shown: MIME type application/octet-stream; filename a.py"

Posting attachments to Usenet is tricky. Many newsgroups filter out
anything they think isn't text, or even any attachment at all. Some news
clients do the same thing.

If you have too much code to include directly in your post, then you
should put it up on a website somewhere and just include the link.

Without looking at your code, I'd guess that using regular expressions is
the wrong approach. Perhaps you should look at the glob module, and
possibly os.walk.



--
Steven
 
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
[regexp] How to convert string "/regexp/i" to /regexp/i - ? Joao Silva Ruby 16 08-21-2009 05:52 PM
Ruby 1.9 - ArgumentError: incompatible encoding regexp match(US-ASCII regexp with ISO-2022-JP string) Mikel Lindsaar Ruby 0 03-31-2008 10:27 AM
string parsing / regexp question Ryan Krauss Python 5 11-28-2007 11:18 PM
New at regexp and Ruby need help on parsing a string. Gabra Kadabra Ruby 9 11-24-2007 09:29 PM
replace a string delimited by 2 other string, regexp problem Sébastien Maurette Ruby 3 10-02-2006 09:40 PM



Advertisments