[Python-Dev] API for the new sysconfig module
Raymond Hettinger
raymond.hettinger at gmail.com
Fri Dec 10 21:27:26 CET 2010
On Dec 10, 2010, at 6:20 AM, Éric Araujo wrote:
> Final note: with 3.2 being in beta, I don’t know how much can be changed
> now.
Part of the purpose of a beta, and in our case, two betas is to give
people a chance to exercise new APIs and fix them before they
become set in stone two months later.
IMO, sysconfig did not warrant a whole module. The pile of
awkward accessor functions is harder to learn / remember
than the simple data structure shown in the last email.
Rather than using two levels of dictionary, it's also possible
to use a named tuple if you think that is more clean looking:
>>> c = sys.sysconfig()
>>> c.config_vars.get('SO)
'.pyd'
>>> c.platform
'win32'
>>> c.paths.get('stdlib')
'C:\\Python32\\Lib'
>>> # the named tuple fields:
>>> c.fields
['config_vars', 'platform', 'version', 'scheme_names', 'paths']
This would be a straight-forward API that uses existing, well-known
tools (attribute access and dict.get) instead of an unnecessary
nest of ad-hoc accessor functions living in a new module.
Tastes may vary on writing getter functions for every category
of interest but we did not need a whole new module for this.
The referenced email didn't indicate much if any thought about
the API design, so I think should get that thought now.
If those functions were already public in distutils, it is trivial
to write an adapter for them there.
Raymond
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20101210/350bf6c0/attachment.html>
More information about the Python-Dev
mailing list