[NeXus-code-tickets] [NeXusCode] #324: Name clashes with 'open'
NeXus Data Format Library and Applications
noreply at nexusformat.org
Fri Jan 27 22:16:30 GMT 2012
#324: Name clashes with 'open'
-----------------------------+------------------------
Reporter: Ray Osborn | Owner: Ray Osborn
Type: defect | Status: new
Priority: major | Milestone:
Component: python bindings | Version: 4.3.0-rc1
Keywords: |
-----------------------------+------------------------
There is a function called 'open' in napi.py, which is included in the
'__all__' list. That means that doing 'from nxs import *' prevents use of
the standard Python open function. Of course, wildcard imports are frowned
because of just this issue but, for interactive use of the tree API, they
are highly desirable, and not likely to cause problems. It would be good
if people are not forced to type 'nxs.NXentry' etc. and 'open' and perhaps
'load' in tree.py, are the only problems.
There are a couple of possible solutions. One is to rename 'open' to
'nxopen', or make 'nxopen = open' and add only nxopen to the __all__ list.
The other is to put 'import napi as nx' in the package __init__.py so that
'from nxs import *', will still require calling 'nx.open'. The latter,
however, would require people to type 'nxs.nx.open' if they just did
'import nxs'.
Comments on this are welcome.
--
Ticket URL: <http://trac.nexusformat.org/code/ticket/324>
NeXus Data Format Library and Applications <http://www.nexusformat.org/>
NeXus Data Format Library and Applications
More information about the NeXus-code-tickets
mailing list