Stories to learn Python stuff. Inspired by the great work made by NodeSchool.
“The only way to learn a new programming language is by writing programs in it.”
Pyschool could always use more stories, whether as specific python features, existing libraries, programming concepts, or even programming concepts not specific to Python itself like event handling, threading and such. New stories are always welcome :)
Ready to write your story? Here's how to set up a story hipyschool for local development. All stories derive from the base Story library.
- Fork/clone/copy the hipyschool or the py101 repo on Github. Those a good examples of simple stories to begin with.
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you could set up your copy for local development:
$ mkvirtualenv my_python_story $ cd my_python_story/ $ python setup.py develop
- Create a module for your Story. For example
mystory/__init__.py
. Define thename
,title
andadventures
variables. You will have to use thegettext()
function fromstory.translation
to receive translations. More on that below. - Create one or more Adventures. A story is a collection of one or more adventures
- Create a module for your adventure for example
mystory/myfirstadventure
- Create the
`README.rst
file describing your adventure in the previous folder - (Optional) Make an Spanish translation. You must name it
README.es.rst
- In the
__init__.py
file define a class calledAdventure
, that derives from BaseAdventure.
- Create a module for your adventure for example
Since the
gettext()
function relies on PyBabel, so you will have to initialize the translation by running:$ make msg-init $ make msg-extract
You should see several files for each language in
mystory/locale/
corresponding for the usages of thegettext()
function. If the command fail, try again.(Optional) Modify and add translations in the locale files and then run:
$ make msg
It is recommended to create some unit tests for checking your solutions, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 my_python_story tests $ python setup.py test or py.test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin
- Publish your package in pip, so it is available publicly
- Let us know or submit a pull request to the Pyschool GitHub website to update our website to include your story.
PySchool is Copyright (c) 2015-2017 sophilabs, inc.
PySchool is maintained and funded by sophilabs, inc. The names and logos for sophilabs are trademarks of sophilabs, inc.