Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
pyCustomEnum
#python 3.6.9 #pyCustomEnum #this code is created by Rezaul Hoque on January 12,2022;contact: jewelmrh@yahoo.com,Dhaka, Bangladesh #note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; from enum import Enum from functools import total_ordering @total_ordering class FoodOrder(Enum): Ordered = 1 Completed = 2 Refunded = 3 def __str__(self): return f'({self.value}){self.name.lower()}:' def __eq__(self, other): if isinstance(other, int): return self.value == other if isinstance(other, FoodOrder): return self is other return False def __lt__(self, other): if isinstance(other, int): return self.value < other if isinstance(other, FoodOrder): return self.value < other.value return False def __bool__(self): if self is self.Ordered: return True return False for member in FoodOrder: print(member, bool(member)) status = int(input("Please enter status of your order:\n")) if status < FoodOrder.Completed: print("The order has not yet delivered.Please wait.") if status == FoodOrder.Completed: print("The order is delivered.") if status == FoodOrder.Refunded: print("Order is cancelled. Money is refunded.Thank you.")
run
|
edit
|
history
|
help
0
python decorator with parameter example
shivareddy correct
Lab_III_3_24_11_2020
числа близнецы
check the browser existence one by one
Stk String replace
on_off
Python3 - product lists
Guessing game
Celcius to Fahrenheit