Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pythonic: code name conflicting with built-in

I'm currently creating a code named "SET". The code's name is an acronym, which has been defined for many (non programming) reasons, and therefore cannot be changed.

Problem: The easiest, and I believe the less painful way for the end-user to use my code would be naming the package "set". But of course this is a problem since this conflicts with the built-in set function.

Question: What are the possible solutions? Some may be (there is probably more):

  1. change the package name (eg. setb).

    import setb
    

    I would really really prefer not to, because then it will be different from the real name

  2. make the package's name upper-case (SET)

    import SET
    

    It would be a straight forward solution, but I'm wondering: is this a pythonic proper naming for a package? Also, I find this a bit painful since all modules defined in the code will have something like "import SET.x.y..." (ie. upper-case, written a lot of times). But this is not a really big deal if this is a pythonic way.

  3. keep the name "set"

    import set
    

    Well this is obviously not fine. But it would be a problem only if the user is using "import set", would not it be? This should not happen in "normal usage conditions", since the code will provides some scripts to use it, rather use it as a standard python module. But we never know, and it could be imported as it, and there may be even some problems I'm not seeing (with the built-in set).

I'm considering the solution 2., but I'm really not sure. Maybe this is not proper, or maybe you guys have a better solution.

PS: I've found some similar topics on the web and on stackoverflow, but it usually deals with names inside a script or module inside a package. The problem here is really related to the code's name (which is meaningful only written this way), and therefore related to the proper naming of the package's name.


EDIT

Selected solution: I've choosen to use "SET" as the package name. Although many good suggestions have been proposed here: pyset, semt, setool... or the more explicit "starexoplanettool" (expliciting the acronym). Thanks to you all.

EDIT #2

I like the "funny" solution of having a package named S, and a subpackage, E... to get finally:

    import S.E.T

Thanks Don Question.

like image 371
mhavel Avatar asked Dec 10 '22 02:12

mhavel


1 Answers

Why not spell out the meaning behind the acronym, and if the user is desperate for a shorter name, they can do import someetymologyterm as SET or whatever they prefer. Python gives them the choice, so it's not the end of the world either way.

like image 135
Gareth Latty Avatar answered Dec 25 '22 21:12

Gareth Latty