Ask Your Question
0

How to name new libraries/modules properly with conflictions with 3rd party code

asked 2022-09-03 06:16:04 +0200

Pickle gravatar image

Hello,

I am currently working on some code for SageMath that I want to name in the src as "control". However, the third party code I am integrating it with is also called "control" from the PyPI repository.

https://pypi.org/project/control/

https://github.com/python-control/pyt...

Can I maintain the name "control" in the SageMath code while using the external "control" code? Or with these names conflict? Do I need to change mine to something else in a first-come-first-serve fashion?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-09-03 09:38:51 +0200

Emmanuel Charpentier gravatar image

updated 2022-09-04 10:00:53 +0200

you may import controlunder a name convenient for you. Example :

sage: import sympy as sy

now you can use "sy" to access its components :

sage: z=sy.symbols("z")

And the resulting importation works as expected :

sage: z
z
sage: z._sage_()
z

Note that the name sympy is still used to name its objects !

sage: type(z)
<class 'sympy.core.symbol.Symbol'>

And the name sympy is still unknown from your namespace :

sage: sympy.Lambda
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Input In [23], in <cell line: 1>()
----> 1 sympy.Lambda

NameError: name 'sympy' is not defined

Details are in the reference.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2022-09-03 06:16:04 +0200

Seen: 92 times

Last updated: Sep 04 '22