2013/11/1 Ryan Gonzalez <[email protected]> > I am writing a tool in RPython that needs to access environment variables. > Now, all has been going well, but I noticed something interesting. The > RPython translator sees os.environ as constant. But, will it still be > constant on other platforms? > > What I'm saying is, are the environment variables permanently embedded > into the application? i.e., if I run it on another PC, the values will be > the same? Or is there an RLib equivalent? Because I really don't feel like > writing a C wrapper... >
RPython magic... In RPython, os.environ is not a dictionary, but a clever wrapper around getenv() and putenv(). See the implementation in ll_os_environ.py: https://bitbucket.org/pypy/pypy/src/default/rpython/rtyper/module/ll_os_environ.py - as an object, os.environ is equivalent to None: nothing is embedded in the application. - only some methods are implemented, and redirect to some implementation that use the C primitives. Yes, I also found this "Controller" crazy the first time I saw it. But very clever and powerful. -- Amaury Forgeot d'Arc
_______________________________________________ pypy-dev mailing list [email protected] https://mail.python.org/mailman/listinfo/pypy-dev
