Tricks and tips from learning resources
Dan Bader has emails and courses on Python: VIDEO What Python Projects Should I Build to Get a Job? Aug 23, 2017
- tensorflow (for machine learning)
- crawling (spider based projects)
- database handling (firebase, Mysql etc.)
- Object-oriented programming with classes and their methods
- Cloud Python
docopt at https://github.com/docopt/docopt and described at http://docopt.org/ creates custom CLI commands by parsing a command help text into cli code that implements it.
Dan Bader recommends the use of the
http://click.pocoo.org/6/why/ click custom package (from Armin Ronacher) instead of the argparse package that comes with Python 3.2+ (and the optparse package that comes with Python 2).
Click provides decorators such as the “@click.command()” below:
\# cli.py import click @click.command() def main(): print("I'm a beautiful CLI ✨") if __name__ == "__main__": main()
squares = [x * x for x in range(10)]
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
Abhishake Gupta’s pyTest https://github.com/letspython3x/code_examples
Pros create a test .py file to go with each py file.
There are several libraries to support testing.
Described at Python Tutorial: Unit Testing Your Code with the unittest Module Aug 16, 2017 by Corey Schafer
- after pip3 install pytest
import file_ab_session as fas def test_add_function_given_two_arguments(): RESULT = fas.add(2,3) EXPECTED_RESULT = 5 assert RESULT == EXPECTED_RESULT
Applicable to both:
Name all test classes with a name beginning with “test”.
Tests are not run from top to bottom, so each test needs to be stand-alone.
To do stuff before the tests:
@classmethod def setupClass(cls) print('in setupClass') @classmethod def tearDownClass(cls) print('in tearDownClass')
Python in the Cloud
- Intro to Boto3
- https://linuxacademy.com/howtoguides/posts/show/topic/14209-automating-aws-with-python-and-boto3 has a whole video course
- Python, Boto3, and AWS S3: Demystified by Ralu Bolovan
- https://github.com/Azure/azure-sdk-for-python/pulls has a large set of libraries so you can install each individually. To install them all:
pip install azure