I need a small help!
Well, just now I wanted to add a new function to my python library - py-everything! But I am not sure in which module I should put it? First I thought, ok, it should go into maths. But then I thought it is not really a mathematical operation, you are checking if a number is even or not? I Will, be happy if you helped!
The function takes in a number and returns True if it is even, False otherwise.
Top comments (8)
__init__
shouldn't usually contain implementations, so I'd put it inmaths
.Then, if you want
mylib.maths.is_number
to be available asmylib.is_number
, you'd put this in__init__.py
...That will allow you to import it from your library like this:
Yes, but it is a very common function so, I would want so that it can be imported easily.
Ergo, the preceding suggestion. You still don't want to put implementation in
__init__.py
if you can at all help it.Hmm, I also don't want to, but I want the function to be accessible much easier, you see?
That's why I suggested what I did. By following the technique I outlined, you can access the function from just
mylib
instead ofmylib.maths
. Read my initial comment again carefully.Yep, your 1st comment explains it... I will try that, it looks good to me. But again, I have to see what others, comment, right?
Look like a mathematical concept to me... :)
basic-mathematics.com/even-and-odd...
hmmm....