Skip to content

Instantly share code, notes, and snippets.

# exceptions.py
class UserException(Exception):
...
class UserNotFoundError(UserException):
def __init__(self):
self.status_code = 404
self.detail = "User Not Found"
@ikobi12
ikobi12 / decorator_factory.py
Last active December 8, 2023 09:37
[Python] Python #python #ipython
def decorator_factory(argument):
def decorator(function):
def wrapper(*args, **kwargs):
something_with_argument(argument)
result = function(*args, **kwargs)
return result
return wrapper
return decorator
Write another program that prompts for a list of numbers
as above and at the end prints out both the maximum and minimum of
the numbers instead of the average.
largest = None
smallest = None
count = 0
total = 0
while True:
try:

Python 内置的 List vs Numpy

Test on MacBook Air (11-inch, Early 2015) 1.6 GHz Intel Core i5

List: List Time used: 7.607762999999999

import time
start = time.clock()
a = range(10000000)	
b = range(10000000)
@wojteklu
wojteklu / clean_code.md
Last active April 15, 2024 20:31
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules