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 7995681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:29:36+00:00 2026-06-04T14:29:36+00:00

So I have a yaml file that I’m using as a config file. I’m

  • 0

So I have a yaml file that I’m using as a config file. I’m trying to do some string matching with regular expressions, but I’m having trouble interpreting the regex from yaml into python. The regex in question looks like this:

regex:
    - [A-Za-z0-9]

And when I try to use the re.match function, I get this error:

Traceback (most recent call last):
  File "./dirpylint.py", line 132, in <module>
    sys.exit(main())
  File "./dirpylint.py", line 32, in main
    LevelScan(level)
  File "./dirpylint.py", line 50, in LevelScan
    regex_match(level)
  File "./dirpylint.py", line 65, in regex_match
    if re.match(expression, item) == None:
  File "/usr/lib/python2.7/re.py", line 137, in match
    return _compile(pattern, flags).match(string)
  File "/usr/lib/python2.7/re.py", line 229, in _compile
    p = _cache.get(cachekey)
TypeError: unhashable type: 'list'

I understand that it’s interpreting the regex as a list, but how would I use the regex defined in the yaml file to search for a string?

  • 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-06-04T14:29:39+00:00Added an answer on June 4, 2026 at 2:29 pm

    The problem is the YAML, not the Python.
    If you want to store a string value containing literal square brackets in a YAML file, you have to quote it:

    regex:
      - '[A-Za-z0-9]'
    

    The use of ‘single quotes’ means the YAML will not interpret any backslash escape sequences in the regex. e.g. \b

    Also, note that in this YAML the value of regex is a list containing one string, not a simple string.

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

Sidebar

Related Questions

Okay, I have the following YAML file that was generated by using yaml_db for
I have some configuration values in a YAML file that needs loaded when my
Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
I'm trying to use a yaml config file as a very simple flat file
I am trying to load data from a YAML file where some fields contain
I have a YAML file of groups that I would like to get into
I have an initializer that loads configuration settings from a yaml file. I need
I'm building a script that utilizes a config file (YAML) to read in all
I have a yaml file which contains some times: hours: - 00:00:00 - 00:30:00
I have a yaml file that looks like this: # The following key opens

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.