Xuancong Wang schrieb am 19.04.2016 um 11:13: > Python supports meta-programming, in which a variable with name > specified in a string can be created at run-time. One built-in library > which make use of this is argparse. > > For example: > > parser.add_argument('-N', '--max_threads', help='maximum number of > concurrent decoding threads', type=int, default=16) > > in this case, the variable max_threads is created from the string > argument.
Actually, no. What argparse returns on parsing is an object with dynamically created attributes. It doesn't magically inject any global variables into your module namespace. Or were you trying to compile argparse itself? Then I don't see a reason either why that shouldn't work. > And then Cython will generate an incorrect C program with > the following error: > > smt.py:78:88: undeclared name not builtin: headtail > smt.c:1:2: error: #error Do not use this file, it is the result of a > failed Cython compilation. > > In comparison, I found that nuitka can convert this kind of Python > programs sucessfully. I hope Cython can be improved. Thanks! Cython makes this an error because in almost all cases, with very few exceptions, it is an actual bug in your program. For me personally, this already helped me find several bugs in the past, both in my code as well as other people's code, including at least one in Python's standard library. If you think you know better, you can disable the check by setting Cython.Compiler.Options.error_on_unknown_names = False Stefan _______________________________________________ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel