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

  • Home
  • SEARCH
  • 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 723879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:09:31+00:00 2026-05-14T06:09:31+00:00

/Users/smcho/Desktop/bracket/[10,20] directory has abc.txt, but when I run this Python code import glob import

  • 0

/Users/smcho/Desktop/bracket/[10,20] directory has “abc.txt”, but when I run this Python code

import glob
import os.path

path1 = "/Users/smcho/Desktop/bracket/\[10,20\]"
pathName = os.path.join(path1, "*.txt")
print glob.glob(pathName)

It returns an empty list.

  • Can’t Python’s glob handle the bracket letters or others?
  • Is there any way to solve this problem?
  • 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-14T06:09:32+00:00Added an answer on May 14, 2026 at 6:09 am

    The brackets in glob are used for character classes (e.g. [a-z] will match lowercase letters). You can put each bracket in a character class to force them being matched:

    path1 = "/Users/smcho/Desktop/bracket/[[]10,20[]]"
    

    [[] is a character class containing only the character [, and []] is a character class containing only the character ] (the closing bracket can be placed in a character class by putting it in the first position).

    Additionally, since brackets aren’t escaped in string literals, your code will look for a backslash as well as a bracket.

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

Sidebar

Related Questions

CLASSPATH has the /Users/smcho/Desktop/clojure as one of its path, and this directory has the
I have the following code to run python and get the result in scratch
/Users/madhukar/Desktop/wishstix/Classes/wishstixAppDelegate.h:11:0 /Users/madhukar/Desktop/wishstix/Classes/wishstixAppDelegate.h:11:32: error: FBConnect/FBSession.h: No such file or directory /Users/madhukar/Desktop/wishstix/wishstix_Prefix.pch:13:0 In file included from
My users will import through cut and paste a large string that will contain
As explained in here , putting (setq default-directory ~/Desktop/mag ) in .emacs is supposed
My users are having an intermittent error when using a Windows Forms application built
My users use the site pretty equally 24/7. Is there a meme for build
Our users have created MS-Excel spreadsheets which over time have evolved into fairly complex
My users are presented a basically a stripped down version of a spreadsheet. There
I want to allow users to upload avatar-type images in a variety of formats

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.