Skip to content

Name clashes with 'open' #7

@eugenwintersberger

Description

@eugenwintersberger

Original reporter: rayosborn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions