2. Some Basics
q Your project is not special
n What you are trying to accomplish might be special
n How you accomplish it probably isn’t
q You are not special
n You may be super smart
n And a brilliant coder
n There are a lot of brilliant coders that are very smart
3. Some Basics
q Use the tools available to you
n Lean on the software already available
n Spend time understanding how others have solved your
very unique problems
q Building a simple Web App?
n Use Flask
q Building a more complex Web Apps?
n Use Django
q What to have fun with ASCII Art
n Use the Art package
4. Third Party Packages
q For years developers have been solving very
specific problems through software
q Python’s embrace in the open source community
means there are a lot of problems already solved
q With some caveats:
n Using third party code means you are relying on others
n Packages can go stale, not being updated and falling
behind
n Third party packages can make keeping your own code
current more difficult
5. Third Party Packages
q Best Practices
n Use popular packages
n Consider development activity when evaluating which
packages to use
n This becomes more important depending on how
important the package is to you accomplishing the
features you are building
n Be sure to understand which versions of the packages
you are using and stay consistent across teams
6. Virtual Environments
q Versions of Python
n Different versions of Python have different features and
behaviors
n Python 2 vs Python 3 have very significant differences
q Versions of Third Party packages
n Just like Python, different versions of packages can also
have significant differences
7. Virtual Environments
q Consistency within teams and collaborators
n Make sure everyone is developing the software using
the same version of Python
n Make sure all the third party tools you are using are also
consistent within teams
q Flexibility between projects
n Project One, with Team A, is using Python 3.7 and
Psychopg 3.14
n Project Two, with Team B, is using Python 3.9 and
Psychopg 3.3
27. Virtual Environments
Ok… Python is 3.9
What are all the packages
you are using on this
project? I see a bunch of
imports in the code and
I’ve already installed 50
packages, but I think I’m
missing a few
36. Virtual Environments
q Python’s virtual environments
q Created on a per project basis
q python –m venv {directory name}
n Creates a directory in your project
n Copies the current version of system python
n When you install packages, they are installed into this
virtual environment
n Added in latest versions of Python
n Also a stand alone more feature rich package you can
install via PIP
37. Virtual Environments
q Activate Environment
n source {directory}/bin/activate
n Begins using environments Python and installed
packages
n Any new PIP installations will be installed into the virtual
environment
n Windows:
q {directory}/Scripts/activate.bat
q Deactivate Environment
n deactivate
38. Package Installer for Python (PIP)
q Install a package
n python –m pip install {package}
n Dependencies
q All the packages the package you are installing uses
q PIP will install them as well
q List all installed packages (and version)
n python –m pip list
q Remove a package
n python –m pip uninstall {package}
39. Requirements
q Take a snap shot of all your packages
n python –m pip freeze > requirements.txt
q Install all packages from snapshot
n python –m pip install –r requirements.txt