معرفی شرکت ها


PythonicSwitch-1.0.3


Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر

توضیحات

A pythonic way to implement switch-case
ویژگی مقدار
سیستم عامل OS Independent
نام فایل PythonicSwitch-1.0.3
نام PythonicSwitch
نسخه کتابخانه 1.0.3
نگهدارنده []
ایمیل نگهدارنده []
نویسنده DrSparky-2007
ایمیل نویسنده adityaiyer2007@gmail.com
آدرس صفحه اصلی https://github.com/DrSparky-2007/PythonicSwitchCase
آدرس اینترنتی https://pypi.org/project/PythonicSwitch/
مجوز -
# Pythonic Switch Case ### A pythonic way to implement switch-case ##### What is "Switch-case"? A switch case is a way to control the flow of a program depending on the value of a variable. Example in java: ```java switch (day) { case 1: System.out.print("Monday"); break; case 2: System.out.print("Tuesday"); break; case 3: System.out.print("Wednesday") break; default: System.out.print("Other days"); break; } ``` A switch case is faster than an If-else since it maps the code to certain values. This means that instead of comparing 3 times you just have to get some code from a map (dictionary). Now python doesn't support switch cases, so here is how I made one! ##### How to use Being a pythoneer, I have used a class to implement the switch case ```python # First import the class (Yes, it is just one class) from pySwitch import Switch # Now you can make a switch object # Pass in the value sw = Switch(day) # You can add cases easily sw.case(1, print, "Monday") sw.case(2, print, "Tuesday") sw.case(3, print, "Wednesday") # And you can add a default sw.default(print, "Other days") ``` Now for the smart people out there, you can use lambda functions to put args and kwargs together. ```py sw.case(1, lambda: print("Monday")) ``` And you can put multiline code snippets by defining them and deleting them after When you want to delete the switch, call the kill function first and then you can safely delete the object


نحوه نصب


نصب پکیج whl PythonicSwitch-1.0.3:

    pip install PythonicSwitch-1.0.3.whl


نصب پکیج tar.gz PythonicSwitch-1.0.3:

    pip install PythonicSwitch-1.0.3.tar.gz