Python Virtual Environments
1 min read FROM python:3.7
WORKDIR ['/app']
COPY ['requirements.txt', '/app']
RUN ['pip', 'install', '--no-cache-dir', 'upgrade', '-r', 'requirements.txt']
COPY ['/app', '/app']
CMD ['uvicorn', 'app:app', '--host', '0.0.0.0', '--port', '80'
Python have great features that make it easy to use different programming paradigms. Let's explore some of the best features of Python.
1 min readdef stateful_function():
cache = {}
def wrapper_function(*args, **kwargs):
key = str(args) + st(kwargs)
if key not in cache:
cache[key] = func(*args, **kwargs)
return cache[key]
return wrapper_function
@stateful_function
def fibonacci(n):
if n < 2:
return n
return fibonacci(n-1) + fibonacci(n-2)
Terminal Basics for Linux and Mac OS
1 min read mkdir dir_name
cd dir_name
touch file_name
echo 'foo' > file_name
ls
cat file_name
rm file_name
Python is a great language for beginners and experts alike. Let's explore the basics of Python. From modules, packages, scope, and more. Let's dive in!
1 min readdef outer():
x = 'local'
def inner():
nonlocal x
x = 'nonlocal'
inner()
if __name__ == '__main__':
outer()