Skip to main content

No project description provided

Project description

I have noticed that switch/case statements are coming to Python, so I thought it would be amusing to release the 101002938662893028482039th "Missing switch/case package" to this platform.

import switchem

MONKEY = 1
ELEPHANT = 2
GIRAFFE = 3
HORSE = 4
SQUIRREL = 5

for case in switchem(3):
    if case(MONKEY):
        print("It is a monkey")
        break
    
    if case(ELEPHANT, GIRAFFE, HORSE):
        print("It is not a monkey or a squirrel")
    
    if case(SQUIRREL):
        print("It is not a monkey for sure")

This has the fall-through behaviour (fall-through will activate as soon as the correct value is checked). It is written in for-loop notation to allow for the use of the break keyword. This means that using the iter function on these objects will only yield one object.

Project details


Download files

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

Source Distribution

switchem-0.1.0.tar.gz (1.8 kB view details)

Uploaded Source

File details

Details for the file switchem-0.1.0.tar.gz.

File metadata

  • Download URL: switchem-0.1.0.tar.gz
  • Upload date:
  • Size: 1.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.4

File hashes

Hashes for switchem-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a29d2384be1b033db99fdc055bbec488a09d39d63fef8792f4822fbb815961eb
MD5 25a59f96fc604f96a4fcd88e111f0828
BLAKE2b-256 5f0a2f842e0b5f02e8fd5864592cdd68976c5e6a41ed1f343114d46f1578bee5

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