First time here? Check out the FAQ!

Ask Your Question
0

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

asked 2 years ago

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 2 years ago

Emmanuel Charpentier gravatar image

updated 2 years ago

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.

Preview: (hide)
link

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: 2 years ago

Seen: 135 times

Last updated: Sep 04 '22