Skip to content

Using dunder methods to making work in REPL easier. #543

@BjornFJohansson

Description

@BjornFJohansson

Every dunder method in Python, summarized in the table below.
We use "+" / add() in Dseq to signify double stranded ligation when two phosphodiester bonds are formed. Other dunder methods could be overridden for other kinds of manipulation.

for instance "~obj" / invert could for example return the reverse complement of the sequence.

Operator Dunder method Reverse In-place
+ __add__() __radd__() __iadd__()
- __sub__ __rsub__ __isub__
* __mul__ __rmul__ __imul__
/ __truediv__ __rtruediv__ __itruediv__
// __floordiv__ __rfloordiv__ __ifloordiv__
% __mod__ __rmod__ __imod__
divmod(a, b) __divmod__ __rdivmod__
** __pow__ __rpow__ __ipow__
+a __pos__(self)
-a __neg__(self)
abs(a) __abs__(self)
round(a) __round__(self, n)
@ __matmul__ __rmatmul__ __imatmul__
& __and__ __rand__ __iand__
` ` __or__ __ror__
^ __xor__ __rxor__ __ixor__
<< __lshift__ __rlshift__ __ilshift__
>> __rshift__ __rrshift__ __irshift__
~a __invert__(self)

Metadata

Metadata

Assignees

No one assigned

    Labels

    ideaNew idea

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions