But then you have to tell everyone who uses your code to do this for their system. You can either extend PYTHONPATH systemwide by appending the full path to libs to it, whereas several paths are separated using a colon. A better solution would be to have a single file to extend the PYTHONPATH. Every file that imports M圜lass has to be changed, which is tedious and error-prone. In each of these files, you have to add the first two lines. Imagine you got several Python files that want to access M圜lass. However, this solution not only looks terrible, but it also has a lousy code design. append ( "./libs" ) from my_package.classes import M圜lass if _name_ = "_main_" : a = M圜lass ( "a" ) print ( a )
0 Comments
Leave a Reply. |