Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6616559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:35:51+00:00 2026-05-25T20:35:51+00:00

so i have a os.walk code search = self.search.get_text() top = ‘/home/bludiescript/tv-shows’ for dirpath,

  • 0

so i have a os.walk code

search = self.search.get_text()
top = '/home/bludiescript/tv-shows'
for dirpath, dirnames, filenames in os.walk(top):
  for filename in filenames:
    if fnmatch.fnmatch(filename, search)
      print os.path.join([dirpath, filename])

on python docs it shows you can match any seq of chars with [seq] pattern but no matter how i try to implement that it give so kind of error or no results at all.

so what would be the correct implementation to match the seq of cars in search so it will print out the file or files that match

implementations i tried

if fnmatch.fnmatch(filename, [search]) error i got was typeerror unhasable type : 'list'
if fnmatch.fnmatch[filename, search] error i got was typeerror fnmatch function is not subscriptable
if fnmatch.fnmatch([filename, search]) error typeerror fnmatch takes two arguments  1 given
if fnmatch.fnmatch([filename], search) error typeerror expected string or buffer
if fnmatch.fnmatch([search], filename) error typeerror expected string or buffer 
if fnmatch.fnmatch(filename, search, [seq]) error nameerror global name seq not defined

if fnmatch.fnmatch(filename, '[search]')

no errors but did not produce any results

search values

hello, mkv, merry 1, 2, 3, 4, 5, 6, 7, etc…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:35:51+00:00Added an answer on May 25, 2026 at 8:35 pm

    fnmatch implements the Unix shell wildcard syntax. So whatever you can type in an ls command (for example) will work:

    >>> fnmatch.fnmatch("qxx", "[a-z]xx")
    True
    >>> fnmatch.fnmatch("abc", "a??")
    True
    >>> fnmatch.fnmatch("abcdef", "a*f")
    True
    >>> fnmatch.fnmatch("abcdef", "a*[f-k]")
    True
    

    Keep in mind, fnmatch is purely a string matching operation. If you find it more convenient to use a different pattern style, for example, regexes, then simply use regex operations to match your filenames.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a piece of code which I'm using to search for the executables
Have you guys had any experiences (positive or negative) by placing your source code/solution
Have a n-tire web application and search often times out after 30 secs. How
I am trying to do a code walk through a badly written bash script.
I have some code that relied on methods not being inlined : internal class
I have a some code that gets passed a class derived from a certain
Why have the calling thread walk into the async method until the inner 'await'?
Task: Cut or erase a file after first walk-through. i have an install file
i have this code : class random_walk: #ns: number of steps1d #np: number of
I have the following code: class random_walk: #ns: number of steps #np: number of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.