This repository holds the code for the Real Python When Do You Use an Ellipsis in Python? tutorial.
To run the examples in this repository, you need to have the dependencies installed. You should first create a virtual environment:
$ python -m venv venv
$ source venv/bin/activateThen, navigate into the subfolder and install the requirements with pip:
(venv) $ python -m pip install -r requirements.txtThe requirements are separated for each example, so you can decide which you want to install into your virtual environment.
Enter the flask_stub_example/ folder. You can then run the Flask server in debug mode with this command:
(venv) $ flask --app app --debug runYou can visit http://127.0.0.1:5000/ in your browser to see the "Hello, world!" message. Because count_visitor() defined in app.py is a stub function using ..., nothing happens. This serves as an example that shows how you can avoid counting visitors during development.
If you run the app without --debug, then custom_stats.count_visitor() will execute each time you reload the main page. The example function prints a message to your console. This serves as a stand-in for how your app would count visitors when run in production.
Enter the type_hints_examples/ folder and run the files with mypy:
(venv) $ mypy tuple_example.py
(venv) $ mypy callable_example.pyEnter the numpy_example/ folder and run this command:
(venv) $ python numpy_no_ellipsis_example.py- Philipp Acsany, E-mail: philipp@realpython.com
Distributed under the MIT license. See LICENSE for more information.