Regexp problem when parsing a string

Discussion in 'Python' started by Alessandro Marino, Mar 21, 2010.

  1. 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
    Alessandro Marino, Mar 21, 2010
    #1
    1. Advertising

  2. 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
    Steven D'Aprano, Mar 21, 2010
    #2
    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. Ryan Krauss

    string parsing / regexp question

    Ryan Krauss, Nov 28, 2007, in forum: Python
    Replies:
    5
    Views:
    254
    Ryan Krauss
    Nov 28, 2007
  2. Sébastien Maurette
    Replies:
    3
    Views:
    135
    David Vallner
    Oct 2, 2006
  3. Gabra Kadabra
    Replies:
    9
    Views:
    102
    RichardOnRails
    Nov 24, 2007
  4. Mikel Lindsaar
    Replies:
    0
    Views:
    479
    Mikel Lindsaar
    Mar 31, 2008
  5. Joao Silva
    Replies:
    16
    Views:
    354
    7stud --
    Aug 21, 2009
Loading...

Share This Page