Maximum number of arguments in Python
See original GitHub issueHey! Quoting your documentation,
When I say it supports everything I really mean everything:
I hate to be that guy, but I’m using your library (which is really amazing, by the way) and I actually encountered this issue in a poorly designed JS file. Reproduction:
test_str = "arr = new Array({})".format(','.join([str(x) for x in range(257)]))
import js2py
ctx = js2py.EvalJs()
ctx.execute(test_str)
💥
Traceback (most recent call last):
File "/home/liam/.virtualenvs/scraper/lib/python3.5/site-packages/js2py/evaljs.py", line 171, in execute
compiled = cache[hashkey]
KeyError: b'bT(\xc0iho\x10\xc1q\xe6\x8c\xd1 \xe8U'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/liam/.virtualenvs/scraper/lib/python3.5/site-packages/js2py/evaljs.py", line 174, in execute
compiled = cache[hashkey] = compile(code, '<EvalJS snippet>', 'exec')
File "<EvalJS snippet>", line 3
SyntaxError: more than 255 arguments
I guess not much you can do, right? Maybe document it?
Issue Analytics
- State:
- Created 7 years ago
- Comments:19 (13 by maintainers)
Top Results From Across the Web
What is a maximum number of arguments in a Python function?
In Python 3.7 and newer, there is no limit. This is the result of work done in issue #27213 and issue #12844; #27213...
Read more >4 Examples to Learn Python Max function - jQuery-AZ
The max() function is used to return the maximum value for two or more arguments passed to it. If an iterable like a...
Read more >Python - Advanced Parameter Handling For Functions
Python lets us define a function that handles an unknown and unlimited number of argument values. Examples of built-in functions with a unlimited...
Read more >Are there guidelines on how many parameters a function ...
The ideal number of arguments for a function is zero (niladic). Next comes one (monadic), followed closely by two (dyadic). Three arguments (triadic)...
Read more >Python max() - Programiz
The max() function returns the largest item in an iterable. It can also be used to find the largest item between two or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There is no point solving this specific issue, there are much more edge cases which are almost impossible to solve with the current approach - eg recursion limit of python. I will solve all the problems by implementing a proper interpreter.
Hey @PiotrDabkowski looks like this thread got pretty off-topic. My use case is actually for Arrays only. I think that one AST transformation here would suffice. Specifically, if you could change:
Array(
...
)
➡️[
...
]
that would solve my real-life problem 😄 I’m not a JS guru like yourself, but I believe array literals and the
Array
constructor are exactly equivalent. I’ve done this in the interim for the project I’m working on but I used a horrible regex hack that I’m pretty ashamed of.For the actual code that I was testing to crash this, it was at: http://www.startimes.com/f.aspx?t=36588040 (check out
var topics = Array(...
). The code is so poorly architected that this simple web scraping project I’m working on turned into what felt like cryptanalysis 😉