Ralf W. Grosse-Kunstleve wrote: > >>> import std_vector > __main__:1: DeprecationWarning: assignment shadows builtin > >>> dir(std_vector) > ['__doc__', '__file__', '__name__', 'array_cast', 'boost_array_sum', > 'cos', 'double', 'float', 'in_place_multiply', 'int', 'long', 'size_t'] > > std_vector is a Boost.Python extension module I suspect the warning is shown due to the way Boost builds the namespace of the extension module. Shadowing of builtin names is checked by the setattr method of the module type. Boost is probably using module_setattr to populate the global dictionary. There's nothing wrong with doing that except that it triggers a spurious warning. > Does the DeprecationWarning mean that I cannot provide this intuitive > interface anymore? That was not the intention. Having module globals that shadow builtins is okay. The warning is supposed to be triggered if the scope of a name is changed from builtin to global at runtime. Eg: import string string.str = 'ha ha' That's a strange thing to do and I suspect there is little code out there that does it. Unfortunately the code that tries to detect it is imperfect. > It seems to me that the names of builtin types are essentially made > equivalent to reserved keywords. No, see above. Neil
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4