intro-to-python
intro-to-python copied to clipboard
An Introduction to Programming in Python
Notes for using `Flask-SQLAlchemy` package for database with `Flask-Migrate` package for migrations. Flask-SQLAlchemy: + https://github.com/pallets/flask-sqlalchemy/ + https://flask-sqlalchemy.palletsprojects.com/en/2.x/ + https://flask-sqlalchemy.palletsprojects.com/en/2.x/api/#models + https://docs.sqlalchemy.org/en/13/core/type_basics.html + https://docs.sqlalchemy.org/en/13/orm/join_conditions.html?highlight=foreign%20key Flask-Migrate: + https://flask-migrate.readthedocs.io/en/latest/ + https://github.com/miguelgrinberg/Flask-Migrate ```sh pipenv...
Here is an example of passing some python data to the page, and accessing it via JavaScript, for example to make a dataviz. Uses the plotly JavaScript library. Route: ```py...
Add instructions to the web app exercise, for students looking for further exploration. Snippets below: Requirements.txt file (uses [Authlib package](https://docs.authlib.org/en/stable/)): ```py # ... # web app oauth login with google:...
Add to notes about Env Vars the following [excerpt](https://sendgrid.com/docs/ui/account-and-settings/api-keys/ ) from Twilio SendGrid: > ## Storing an API key in an environment variable > > Twilio SendGrid recommends storing your...
Add notes on time vs space complexity. References: + https://stackabuse.com/big-o-notation-and-algorithm-analysis-with-python-examples/ + https://docs.codeclimate.com/docs/cognitive-complexity + https://docs.codeclimate.com/docs/maintainability
Add "notes/python/packages/memory_profiler.md": + https://pypi.org/project/memory-profiler/ + https://github.com/pythonprofilers/memory_profiler#decorator ```py from memory_profiler import profile @profile def my_func(): a = [1] * (10 ** 6) b = [2] * (2 * 10 ** 7)...
References: + https://www.python.org/dev/peps/pep-0318/ + https://docs.python.org/3/library/functools.html#functools.wraps ```py from functools import wraps def my_decorator(f): @wraps(f) def wrapper(*args, **kwds): print('Calling decorated function') return f(*args, **kwds) return wrapper @my_decorator def example(): """Docstring""" print('Called example...
https://github.com/huggingface/transformers https://huggingface.co/transformers/main_classes/pipelines.html?highlight=pipeline#transformers.pipeline ```sh pip install transformers ``` ```py from transformers import pipeline classifier = pipeline('sentiment-analysis') classifier ``` ````py results = classifier('We are very happy to introduce pipeline to the transformers...
```py # https://stackoverflow.com/questions/51046454/how-can-we-use-selenium-webdriver-in-colab-research-google-com !pip install selenium !apt-get update # to update ubuntu to correctly run apt install !apt install chromium-chromedriver !cp /usr/lib/chromium-browser/chromedriver /usr/bin import sys sys.path.insert(0,'/usr/lib/chromium-browser/chromedriver') ``` ```py # https://github.com/prof-rossetti/intro-to-python/blob/main/notes/python/packages/selenium.md...
Add this to the notes about functions: > "for example, this function is expected to take two int arguments and is also expected to have an int return value:" ```py...