Skip to main content

Access intrinsic operators through a lookup dict

Project description

Access intrinsic operators through a lookup dict

More information: https://docs.python.org/3/library/operator.html

from operatorlookup import doops

print('-------------------------')

print(doops("==", 10, 20))

print(doops("+", 10, 20))

print(doops("-", 10, 20))

print('-------------------------')

defli = list(range(10))

print(defli)

_ = [(doops("=", defli, x, x * 10)) for x in range(10)]

print(defli)

print('-------------------------')

defli = list(range(10))

print(defli)

_ = [(doops("del", defli, 0)) for x in range(10) if x > 5]

print(defli)

print('-------------------------')

defli = {}

print(defli)

_ = [(doops("=", defli, x,x*100)) for x in range(10) if x > 5]

print(defli)

print('-------------------------')

getitemsresult = [(doops("[]", defli, x)) for x in range(10) if x > 5]

print(getitemsresult)





False

30

-10

-------------------------

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

[0, 10, 20, 30, 40, 50, 60, 70, 80, 90]

-------------------------

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

[4, 5, 6, 7, 8, 9]

-------------------------

{}

{6: 600, 7: 700, 8: 800, 9: 900}

-------------------------

[600, 700, 800, 900]



# All operations:

from operatorlookup import opdict

print(opdict)

{'+': <function _operator.add(a, b, /)>,

 'concat': <function _operator.concat(a, b, /)>,

 'in': <function _operator.contains(a, b, /)>,

 '/': <function _operator.truediv(a, b, /)>,

 '//': <function _operator.floordiv(a, b, /)>,

 '&': <function _operator.and_(a, b, /)>,

 '^': <function _operator.xor(a, b, /)>,

 '~': <function _operator.invert(a, /)>,

 '|': <function _operator.or_(a, b, /)>,

 '**': <function _operator.pow(a, b, /)>,

 'is': <function _operator.is_(a, b, /)>,

 'is not': <function _operator.is_not(a, b, /)>,

 '=': <function _operator.setitem(a, b, c, /)>,

 'del': <function _operator.delitem(a, b, /)>,

 '[]': <function _operator.getitem(a, b, /)>,

 '<<': <function _operator.lshift(a, b, /)>,

 '%': <function _operator.mod(a, b, /)>,

 '*': <function _operator.mul(a, b, /)>,

 '@': <function _operator.matmul(a, b, /)>,

 'neg': <function _operator.neg(a, /)>,

 'not': <function _operator.not_(a, /)>,

 'pos': <function _operator.pos(a, /)>,

 '>>': <function _operator.rshift(a, b, /)>,

 '-': <function _operator.sub(a, b, /)>,

 'truth': <function _operator.truth(a, /)>,

 '<': <function _operator.lt(a, b, /)>,

 '<=': <function _operator.le(a, b, /)>,

 '==': <function _operator.eq(a, b, /)>,

 '!=': <function _operator.ne(a, b, /)>,

 '>=': <function _operator.ge(a, b, /)>,

 '>': <function _operator.gt(a, b, /)>,

 '+=': <function _operator.iadd(a, b, /)>,

 '&=': <function _operator.iand(a, b, /)>,

 'iconcat': <function _operator.iconcat(a, b, /)>,

 '//=': <function _operator.ifloordiv(a, b, /)>,

 '<<=': <function _operator.ilshift(a, b, /)>,

 '%=': <function _operator.imod(a, b, /)>,

 '*=': <function _operator.imul(a, b, /)>,

 '@=': <function _operator.imatmul(a, b, /)>,

 '|=': <function _operator.ior(a, b, /)>,

 '**=': <function _operator.ipow(a, b, /)>,

 '>>=': <function _operator.irshift(a, b, /)>,

 '-=': <function _operator.isub(a, b, /)>,

 '/=': <function _operator.itruediv(a, b, /)>,

 '^=': <function _operator.ixor(a, b, /)>}

Project details


Release history Release notifications | RSS feed

This version

0.10

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

operatorlookup-0.10.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

operatorlookup-0.10-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file operatorlookup-0.10.tar.gz.

File metadata

  • Download URL: operatorlookup-0.10.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for operatorlookup-0.10.tar.gz
Algorithm Hash digest
SHA256 1f895aa37353f6c8edcf1bd0590f94fc62cb2cd9170235849fc5b5ecbbba1031
MD5 071b4c2c89dcfefe24dd3374648d70de
BLAKE2b-256 3a59671e7dff9ef1d0817a1f5c9ef49bf15bddaa25361b48fdd946e4a39f023a

See more details on using hashes here.

File details

Details for the file operatorlookup-0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for operatorlookup-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 00eacd8e8d3e7d14dbb1b196764a6ed55b20e04e769ffec7c80309012fa52e6a
MD5 da706a078f569aa213df4b8e09dbb935
BLAKE2b-256 c8304fe95174ee0e76c6613978cde9d8b67669a6ebe1176cc18054f7c84f8e1b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page