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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:26:40+00:00 2026-05-27T10:26:40+00:00

I’ve a part of my python program which is generated, the generated codes contains

  • 0

I’ve a part of my python program which is generated, the generated codes contains a lot of nested if / else, my problem is that a lot can be too much and I got this Error when running my code:

IndentationError: too many levels of indentation

I’ve read that this was some limitation defined on the low level of the python interpreter, does anybody know how I can find a workaround for it? Some interpreter parameters would be fine, the only solution proposal I’ve found suggests to recompile Python in order to set a different value for the MAXINDENT constant, which is not exactly what I’m dreaming of.

EDIT : The code is a big bunch of nested if...else , it’s dirty but it was the quickest I found to port a complex decision tree to Python. I know how dirty it is; I did not write it myself — I did not even plan to edit it (I would rather touch the generator).

I know I can modelize this decision tree in other fashions. What I would like is a way simpler than that, like tweaking the interpretor if possible.

EDIT 2 : Now I’ve done some refactoring, and my tree is stored as a dictionary: The loading of the file gives a new error :

s_push: parser stack overflow
MemoryError

Here again I found a resource suggesting some tweaks of the interpreter’s headers.


  • 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-27T10:26:41+00:00Added an answer on May 27, 2026 at 10:26 am

    You can have deeply nested structures that are generated dynamically e.g., ~100 nested-levels list leads to s_push: parser stack overflow as a string literal but it works if you create it dynamically from json-text, example:

    import ast
    import json
    
    N = 100
    s = "["*N + "123" +"]"*N
    
    L1 = json.loads(s)
    def flatten(L):
        for el in L:
            try:
                for item in flatten(el):
                    yield item
            except TypeError:
                yield el
    assert next(flatten(L1)) == 123
    print("json ok")
    
    L2 = ast.literal_eval(s) # raises MemoryError
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into

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.