#๐ Im trying to make this code into a module so i can import it later.
45 messages ยท Page 1 of 1 (latest)
@drifting orchid
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
it's already a module! all you have to do is just from Vector2 import Vector2
oh ok that sounds good
thanks ๐
also, why the pyi file?
your Vector2.py already includes type hints, no need to write a type stubs file
wait whats that
whats the builtins.pyi file for?
oh well
when i click on a magic method that i dind't put it takes me to that script
btw about magic methods, is it okay?
oh, its because they're written in C, so pycharm just takes you to the python stub file
what would be wrong with them?
i dont know, that why i ask you
alr i guess its fine ๐
which magic method in specific are you talking about?
idk
the only im unsure about tho
floordiv
when i simply use the __floor__ method it crashed
that just overrides the // operator
oh ok
don't quote me on this, but i don't think __floor__ is a magic method that exists
do you want it to floor when math.floor is called on it?
not really..
thank you tho
nevermind, __floor__ is a magic method that exists
it only gets called when you call math.floor on it though
alr im gonna add it
btw
what is the other=float argument in __floordiv__
im bad at math
!d object.floordiv
object.__floordiv__(self, other)``````py
object.__mod__(self, other)``````py
object.__divmod__(self, other)```
These methods are called to implement the binary arithmetic operations (`+`, `-`, `*`, `@`, `/`, `//`, `%`, [`divmod()`](https://docs.python.org/3/library/functions.html#divmod), [`pow()`](https://docs.python.org/3/library/functions.html#pow), `**`, `<<`, `>>`, `&`, `^`, `|`). For instance, to evaluate the expression `x + y`, where *x* is an instance of a class that has an [`__add__()`](https://docs.python.org/3/reference/datamodel.html#object.__add__) method, `type(x).__add__(x, y)` is called. The [`__divmod__()`](https://docs.python.org/3/reference/datamodel.html#object.__divmod__) method should be the equivalent to using [`__floordiv__()`](https://docs.python.org/3/reference/datamodel.html#object.__floordiv__) and [`__mod__()`](https://docs.python.org/3/reference/datamodel.html#object.__mod__); it should not be related to [`__truediv__()`](https://docs.python.org/3/reference/datamodel.html#object.__truediv__). Note that [`__pow__()`](https://docs.python.org/3/reference/datamodel.html#object.__pow__) should be defined to accept an optional third argument if the ternary version of the built-in [`pow()`](https://docs.python.org/3/library/functions.html#pow) function is to be supported.
If one of those methods does not support the operation with the supplied arguments, it should return [`NotImplemented`](https://docs.python.org/3/library/constants.html#NotImplemented).
read that
k!
!close
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.