merge master
@@ -10,3 +10,5 @@ docs/_build
|
||||
|
||||
# Ignore files generated during build
|
||||
build/
|
||||
|
||||
venv/
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
sudo: false
|
||||
language: python
|
||||
python:
|
||||
- "3.6"
|
||||
install: pip install sphinx
|
||||
script:
|
||||
- make doctest
|
||||
- make html
|
||||
script:
|
||||
- make doctest
|
||||
- make html
|
||||
|
||||
@@ -4,7 +4,7 @@ How to contribute
|
||||
This guide is under heavy development. If you would like to contribute, please
|
||||
see:
|
||||
|
||||
http://docs.python-guide.org/en/latest/notes/contribute/
|
||||
https://docs.python-guide.org/notes/contribute/
|
||||
|
||||
How to test your changes
|
||||
------------------------
|
||||
@@ -15,15 +15,15 @@ The html version of this guide is built with [sphinx](http://www.sphinx-doc.org/
|
||||
pip install --user sphinx
|
||||
```
|
||||
|
||||
Then navigate to the directory of the makefile and ```make build``` or ```make html```. Sphinx will then generate the html in a folder called _build/html
|
||||
Then navigate to the directory of the Makefile and ```make build``` or ```make html```. Sphinx will then generate the HTML in a folder called `_build/html/`
|
||||
|
||||
After navigating to this folder, you can then use python's built in webserver to view your changes locally:
|
||||
After navigating to this folder, you can then use Python's built in webserver to view your changes locally:
|
||||
|
||||
``` bash
|
||||
python3 -m http.server
|
||||
```
|
||||
|
||||
By default, http.server listens on every ip address bound on your host on port 8000. To bind to a specific one, say, localhost on port 8005:
|
||||
By default, `http.server` listens on every IP address bound on your host on port 8000. To bind to a specific one, say, localhost on port 8005:
|
||||
|
||||
``` bash
|
||||
python3 -m http.server 8005 --bind 127.0.0.1
|
||||
@@ -34,4 +34,4 @@ Style Guide
|
||||
|
||||
For all contributions, please follow the `Guide Style Guide`:
|
||||
|
||||
http://docs.python-guide.org/en/latest/notes/styleguide/
|
||||
https://docs.python-guide.org/notes/styleguide/
|
||||
|
||||
@@ -33,4 +33,4 @@ Topics include:
|
||||
|
||||
If you aren't fond of reading reStructuredText, there is an
|
||||
almost up-to-date `HTML version at docs.python-guide.org
|
||||
<http://docs.python-guide.org>`_.
|
||||
<https://docs.python-guide.org>`_.
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
404 — Not Found
|
||||
===============
|
||||
|
||||
**Sorry, but we couldn't find the page you requested.**
|
||||
|
||||
It looks like this was the result of either:
|
||||
|
||||
- a mistyped address
|
||||
- an out-of-date link
|
||||
|
||||
`Click here to go back to the homepage. <https://docs.python-guide.org/>`_
|
||||
|
||||
Or, try `searching <https://docs.python-guide.org/search/>`_.
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<script>
|
||||
ga('send', {
|
||||
hitType: 'event',
|
||||
eventCategory: 'error',
|
||||
eventAction: '404',
|
||||
eventLabel: document.referrer,
|
||||
nonInteraction: true
|
||||
});
|
||||
</script>
|
||||
@@ -59,6 +59,12 @@ dirhtml:
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
||||
|
||||
netlify: dirhtml
|
||||
@cp $(BUILDDIR)/dirhtml/404/index.html $(BUILDDIR)/dirhtml/404.html
|
||||
@sed -i -e 's/src="..\//src="\//g' $(BUILDDIR)/dirhtml/404.html
|
||||
@sed -i -e 's/href="..\//href="\//g' $(BUILDDIR)/dirhtml/404.html
|
||||
@cp _extra/* $(BUILDDIR)/dirhtml/
|
||||
|
||||
singlehtml:
|
||||
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
||||
@echo
|
||||
@@ -175,3 +181,6 @@ pseudoxml:
|
||||
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
|
||||
@echo
|
||||
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
|
||||
|
||||
serve:
|
||||
cd $(BUILDDIR)/dirhtml && python3 -m http.server 8005
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# Redirect rules
|
||||
# Docs: https://www.netlify.com/docs/redirects/
|
||||
|
||||
# Redirect http to https (avoid one extra hop with an explicit rule for /en/latest/)
|
||||
http://docs.python-guide.org/en/latest/* https://docs.python-guide.org/:splat 301!
|
||||
http://docs.python-guide.org/* https://docs.python-guide.org/:splat 301!
|
||||
|
||||
# Redirect RTD prefix to /
|
||||
/en/latest/* /:splat 301!
|
||||
|
||||
# Redirect domain aliases to primary domain
|
||||
http://python-guide.org/* http://docs.python-guide.org/:splat 301!
|
||||
https://python-guide.org/* https://docs.python-guide.org/:splat 301!
|
||||
|
||||
# Redirect Netlify version to primary domain
|
||||
https://python-guide.netlify.com/* https://docs.python-guide.org/:splat 301!
|
||||
|
||||
/guide-book https://www.amazon.com/Hitchhikers-Guide-Python-Practices-Development/dp/1491933178/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=bookforkind-20&linkId=804806ebdacaf3b56567347f3afbdbca 302
|
||||
@@ -0,0 +1,105 @@
|
||||
google.com, pub-2802445174821308, RESELLER, f08c47fec0942fa0
|
||||
|
||||
|
||||
appnexus.com, 8692, DIRECT, f5ab79cb980f11d1
|
||||
|
||||
|
||||
districtm.io, 100835, DIRECT
|
||||
appnexus.com, 1908, RESELLER, f5ab79cb980f11d1
|
||||
google.com, pub-9685734445476814, RESELLER, f08c47fec0942fa0
|
||||
|
||||
|
||||
appnexus.com, 1613, reseller
|
||||
appnexus.com, 3326, reseller
|
||||
google.com, pub-1409765517756851, reseller
|
||||
google.com, pub-4075894099602271, reseller
|
||||
freewheel.tv, 146081, reseller
|
||||
rubiconproject.com, 8861, reseller, 0bfd66d529a55807
|
||||
|
||||
|
||||
aol.com, 11119, DIRECT
|
||||
adtech.com, 11341, DIRECT
|
||||
coxmt.com, 2000067907202, RESELLER
|
||||
Openx.com, 537143344, RESELLER
|
||||
indexexchange.com, 175407, RESELLER
|
||||
|
||||
|
||||
sonobi.com, 337f0e70cc, DIRECT
|
||||
rhythmone.com, 1059622079, RESELLER
|
||||
contextweb.com, 560606, RESELLER
|
||||
|
||||
|
||||
sovrn.com, 217352, DIRECT, fafdf38b16bf6b2b
|
||||
lijit.com, 217352, DIRECT, fafdf38b16bf6b2b
|
||||
openx.com, 537120960, RESELLER
|
||||
openx.com, 83499, RESELLER
|
||||
openx.com, 538959099, RESELLER
|
||||
pubmatic.com, 137711, RESELLER
|
||||
pubmatic.com, 156212, RESELLER
|
||||
pubmatic.com, 62483, RESELLER
|
||||
contextweb.com, 558511, RESELLER
|
||||
gumgum.com, 11645, RESELLER, ffdef49475d318a9
|
||||
|
||||
|
||||
openx.com, 539824308, RESELLER, 6a698e2ec38604c6
|
||||
|
||||
|
||||
rubiconproject.com, 17822, DIRECT, 0bfd66d529a55807
|
||||
|
||||
|
||||
gumgum.com, 13174, DIRECT, ffdef49475d318a9
|
||||
33across.com, 0013300001r0t9mAAA, RESELLER
|
||||
adtech.com, 9904, RESELLER
|
||||
Advertising.com, 16736, RESELLER
|
||||
aolcloud.net, 9904, RESELLER
|
||||
appnexus.com, 1001, RESELLER, f5ab79cb980f11d1
|
||||
appnexus.com, 1942, RESELLER, f5ab79cb980f11d1
|
||||
appnexus.com, 2758, RESELLER, f5ab79cb980f11d1
|
||||
appnexus.com, 3135, RESELLER, f5ab79cb980f11d1
|
||||
appnexus.com, 7597, RESELLER, f5ab79cb980f11d1
|
||||
bidtellect.com, 1407, RESELLER, 1c34aa2d85d45e93
|
||||
contextweb.com, 558355, RESELLER
|
||||
criteo.com, 109412, DIRECT, 9fac4a4a87c2a44f
|
||||
google.com, pub-3848273848634341, RESELLER, f08c47fec0942fa0
|
||||
google.com, pub-9557089510405422, RESELLER, f08c47fec0942fa0
|
||||
indexexchange.com, 177754, RESELLER, 50b1c356f2c5c8fc
|
||||
lkqd.com, 470, RESELLER, 59c49fa9598a0117
|
||||
lkqd.net, 470, RESELLER, 59c49fa9598a0117
|
||||
openx.com, 537120563, RESELLER, 6a698e2ec38604c6
|
||||
openx.com, 537149485, RESELLER, 6a698e2ec38604c6
|
||||
openx.com, 540003333, RESELLER, 6a698e2ec38604c6
|
||||
outbrain.com, 01a755b08c8c22b15d46a8b753ab6955d4, RESELLER
|
||||
outbrain.com, 01a755b08c8c22b15d46a8b753ab6955d4, DIRECT
|
||||
pubmatic.com, 50758, RESELLER, 5d62403b186f2ace
|
||||
revcontent.com, 76611, RESELLER
|
||||
rhythmone.com, 78519861, RESELLER
|
||||
smaato.com, 1100033117, RESELLER
|
||||
spotx.tv, 147949, RESELLER, 7842df1d2fe2db34
|
||||
spotxchange.com, 147949, RESELLER, 7842df1d2fe2db34
|
||||
springserve.com, 686, DIRECT, a24eb641fc82e93d
|
||||
|
||||
|
||||
indexexchange.com, 187196, DIRECT
|
||||
|
||||
rhythmone.com, 1059622079, RESELLER, a670c89d4a324e47
|
||||
contextweb.com, 560606, RESELLER, 89ff185a4c4e857
|
||||
ccoxmt.com, 2000067997702, RESELLER
|
||||
adtech.com, 11119, RESELLER
|
||||
33across.com, 0013300001r0t9mAAA, RESELLER
|
||||
adtech.com, 9904, RESELLER
|
||||
Advertising.com, 16736, RESELLER
|
||||
aolcloud.net, 9904, RESELLER
|
||||
appnexus.com, 7597, RESELLER, f5ab79cb980f11d1
|
||||
bidtellect.com, 1407, RESELLER, 1c34aa2d85d45e93
|
||||
contextweb.com, 558355, RESELLER
|
||||
criteo.com, 109412, DIRECT, 9fac4a4a87c2a44f
|
||||
indexexchange.com, 177754, RESELLER, 50b1c356f2c5c8fc
|
||||
lkqd.com, 470, RESELLER, 59c49fa9598a0117
|
||||
lkqd.net, 470, RESELLER, 59c49fa9598a0117
|
||||
outbrain.com, 01a755b08c8c22b15d46a8b753ab6955d4, RESELLER
|
||||
outbrain.com, 01a755b08c8c22b15d46a8b753ab6955d4, DIRECT
|
||||
revcontent.com, 76611, RESELLER
|
||||
smaato.com, 1100033117, RESELLER
|
||||
spotx.tv, 147949, RESELLER, 7842df1d2fe2db34
|
||||
spotxchange.com, 147949, RESELLER, 7842df1d2fe2db34
|
||||
springserve.com, 686, DIRECT, a24eb641fc82e93d
|
||||
@@ -0,0 +1,2 @@
|
||||
User-agent: *
|
||||
Disallow:
|
||||
|
Before Width: | Height: | Size: 83 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 156 KiB |
|
After Width: | Height: | Size: 177 KiB |
|
After Width: | Height: | Size: 121 KiB |
|
After Width: | Height: | Size: 81 KiB |
|
After Width: | Height: | Size: 117 KiB |
|
After Width: | Height: | Size: 119 KiB |
|
After Width: | Height: | Size: 178 KiB |
|
After Width: | Height: | Size: 106 KiB |
|
After Width: | Height: | Size: 107 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 72 KiB |
|
After Width: | Height: | Size: 201 KiB |
|
After Width: | Height: | Size: 82 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 116 KiB |
|
After Width: | Height: | Size: 124 KiB |
|
After Width: | Height: | Size: 100 KiB |
|
After Width: | Height: | Size: 82 KiB |
|
After Width: | Height: | Size: 102 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 117 KiB |
|
After Width: | Height: | Size: 91 KiB |
|
After Width: | Height: | Size: 192 KiB |
|
After Width: | Height: | Size: 136 KiB |
|
After Width: | Height: | Size: 84 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 74 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 81 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 127 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 94 KiB |
|
After Width: | Height: | Size: 57 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 127 KiB |
|
After Width: | Height: | Size: 167 KiB |
|
After Width: | Height: | Size: 75 KiB |
@@ -1,47 +1 @@
|
||||
<!-- Alabaster (krTheme++) Hacks -->
|
||||
<aside id="python27">
|
||||
<a href="https://www.kennethreitz.org/requests3"><strong>Requests 3.0</strong> development is underway, and your financial help is appreciated!</a>
|
||||
</aside>
|
||||
|
||||
<!-- Python 2 Death Clock™ -->
|
||||
<style type="text/css">
|
||||
body { margin-top: 4em; }
|
||||
#python27 {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0; right: 0;
|
||||
height: auto;
|
||||
text-align: center;
|
||||
color: white;
|
||||
background-color: black;
|
||||
font-size: larger;
|
||||
line-height: 3;
|
||||
}
|
||||
#python27 a {
|
||||
color: white;
|
||||
}
|
||||
|
||||
</style>
|
||||
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
|
||||
<script>
|
||||
var death = new Date('2020-04-12');
|
||||
|
||||
var diff = moment.duration(death - moment());
|
||||
|
||||
document.querySelector('#python27 time').innerText = (diff.years() * 12) + diff.months();
|
||||
</script>
|
||||
-->
|
||||
<script type="text/javascript">
|
||||
var _gauges = _gauges || [];
|
||||
(function() {
|
||||
var t = document.createElement('script');
|
||||
t.type = 'text/javascript';
|
||||
t.async = true;
|
||||
t.id = 'gauges-tracker';
|
||||
t.setAttribute('data-site-id', '56ca79a64b2ffa7a470027ea');
|
||||
t.setAttribute('data-track-path', 'https://track.gaug.es/track.gif');
|
||||
t.src = 'https://d36ee2fcip1434.cloudfront.net/track.js';
|
||||
var s = document.getElementsByTagName('script')[0];
|
||||
s.parentNode.insertBefore(t, s);
|
||||
})();
|
||||
</script>
|
||||
@@ -0,0 +1,113 @@
|
||||
{% extends "!layout.html" %}
|
||||
|
||||
{%- block extrahead %}
|
||||
{# No super() because we want to avoid loading an empty custom.css file #}
|
||||
|
||||
{# <meta name="viewport" content="width=device-width, initial-scale=0.75, maximum-scale=0.75" /> #}
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style>
|
||||
div.body {
|
||||
min-width: initial;
|
||||
max-width: initial;
|
||||
}
|
||||
</style>
|
||||
|
||||
{% if pagename == 'index' %}
|
||||
<link rel="canonical" href="https://docs.python-guide.org/"/>
|
||||
<meta property="og:url" content="https://docs.python-guide.org/">
|
||||
{% elif pagename == '404' %}
|
||||
{# No canonical on our 404 template. #}
|
||||
{% else %}
|
||||
<link rel="canonical" href="https://docs.python-guide.org/{{ pagename }}/"/>
|
||||
<meta property="og:url" content="https://docs.python-guide.org/{{ pagename }}">
|
||||
{% endif %}
|
||||
|
||||
<link rel="icon" type="image/png" href="https://media.readthedocs.org/images/favicon.png">
|
||||
|
||||
<meta name="google-site-verification" content="013PxE2_8KX9jdUSC5gr8QsfdxTXr1mFgmD9zplp5II" />
|
||||
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta property="twitter:image" content="https://docs.python-guide.org/_static/social-card.jpg">
|
||||
<meta property="og:image" content="https://docs.python-guide.org/_static/social-card.jpg">
|
||||
<meta property="og:title" content="{{ title }}{{ titlesuffix }}">
|
||||
<meta property="og:type" content="article">
|
||||
{%- if metatags is defined %}
|
||||
{# FIXME: For some reason the `meta` dict is always empty. Extract the desc from the `metatags` text. #}
|
||||
<meta property="og:description" content="{{ metatags[15:-24] }}">
|
||||
{%- endif %}
|
||||
|
||||
<script>window.rp_prop_id = '29182759436';</script>
|
||||
<script src="https://srv.realpython.net/tag.js" async></script>
|
||||
|
||||
<script src="https://d31vxm9ubutrmw.cloudfront.net/static/js/2169.js"></script>
|
||||
|
||||
{# Alabaster theme native GA integration is outdated (ga.js). #}
|
||||
{# Insert our own GA snippet instead. #}
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-37242602-11', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{# From: https://github.com/bitprophet/alabaster/blob/5f249677242be96601e034edb3697b7482a6abcf/alabaster/layout.html #}
|
||||
{# Nav should appear before content, not after #}
|
||||
{%- block content %}
|
||||
{%- if theme_fixed_sidebar|lower == 'true' %}
|
||||
<div class="document">
|
||||
{{ sidebar() }}
|
||||
{%- block document %}
|
||||
<div class="documentwrapper">
|
||||
{%- if render_sidebar %}
|
||||
<div class="bodywrapper">
|
||||
{%- endif %}
|
||||
|
||||
{%- block relbar_top %}
|
||||
{%- if theme_show_relbar_top|tobool %}
|
||||
<div class="related top">
|
||||
|
||||
{{- rellink_markup () }}
|
||||
</div>
|
||||
{%- endif %}
|
||||
{% endblock %}
|
||||
|
||||
<div class="body" role="main">
|
||||
<div style="display:block;position:relative; margin-bottom: 1em;">
|
||||
<div style="display:block;width:100%;padding-top:12.5%;"></div>
|
||||
<div class="rpad" data-unit="8x1" style="position:absolute;left:0;top:0;right:0;bottom:0;overflow:hidden;"></div>
|
||||
</div>
|
||||
{% block body %} {% endblock %}
|
||||
</div>
|
||||
|
||||
{%- block relbar_bottom %}
|
||||
{%- if theme_show_relbar_bottom|tobool %}
|
||||
<div class="related bottom">
|
||||
|
||||
{{- rellink_markup () }}
|
||||
</div>
|
||||
{%- endif %}
|
||||
{% endblock %}
|
||||
|
||||
{%- if render_sidebar %}
|
||||
</div>
|
||||
{%- endif %}
|
||||
</div>
|
||||
{%- endblock %}
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
{%- else %}
|
||||
{{ super() }}
|
||||
{%- endif %}
|
||||
{%- endblock %}
|
||||
|
||||
{%- block footer %}
|
||||
<div class="footer">
|
||||
<div style="text-align: center;" id="waldo-tag-2171"></div>
|
||||
{% if show_copyright %}<p>©{{ copyright }}</p>{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -4,72 +4,69 @@
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p style="margin-left:auto; margin-right: auto;"><iframe src="https://ghbtns.com/github-btn.html?user=realpython&repo=python-guide&type=watch&count=true&size=large" allowtransparency="true" frameborder="0" scrolling="0" width="200px" height="35px"></iframe></p>
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />
|
||||
<style>
|
||||
.algolia-autocomplete{
|
||||
width: 100%;
|
||||
height: 1.5em
|
||||
}
|
||||
.algolia-autocomplete a{
|
||||
border-bottom: none !important;
|
||||
}
|
||||
#doc_search{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
<input id="doc_search" placeholder="Search the Guide" autofocus/>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
|
||||
<script type="text/javascript"> docsearch({
|
||||
apiKey: '512b0d6c0c8578bed7662f5279c2249c',
|
||||
indexName: 'python-guide',
|
||||
inputSelector: "#doc_search",
|
||||
debug: false // Set debug to true if you want to inspect the dropdown
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<p>
|
||||
This opinionated guide exists to provide both novice and expert Python developers a best practice handbook to the installation, configuration, and usage of Python on a daily basis.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<h3>Stay Informed</h3>
|
||||
<p>Receive updates on new releases and upcoming projects.</p>
|
||||
|
||||
<p><iframe src="http://ghbtns.com/github-btn.html?user=kennethreitz&type=follow&count=false"
|
||||
allowtransparency="true" frameborder="0" scrolling="0" width="200" height="20"></iframe></p>
|
||||
|
||||
<p><a href="https://twitter.com/kennethreitz" class="twitter-follow-button" data-show-count="false">Follow @kennethreitz</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script></p>
|
||||
|
||||
<p><a href="http://tinyletter.com/kennethreitz">Join Mailing List</a>.</p>
|
||||
<p><a href="https://saythanks.io/to/kennethreitz">Say Thanks!</a></p>
|
||||
|
||||
<a href="http://www.dataquest.io/?utm_source=hitchhikersguide&utm_medium=ad">
|
||||
<img src="{{ pathto('_static/ad.png', 1) }}" alt="">
|
||||
</a>
|
||||
|
||||
<hr>
|
||||
<div style="display:block;position:relative;margin: 1em 0 1em 0;">
|
||||
<div style="display:block;width:100%;padding-top:100%;"></div>
|
||||
<div class="rpad" data-unit="1x1" style="position:absolute;left:0;top:0;right:0;bottom:0;overflow:hidden;"></div>
|
||||
</div>
|
||||
|
||||
<h3>O'Reilly Book</h3>
|
||||
|
||||
<p>This guide is now available in tangible book form!</p>
|
||||
|
||||
<a href="https://www.amazon.com/Hitchhikers-Guide-Python-Practices-Development/dp/1491933178/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=bookforkind-20&linkId=804806ebdacaf3b56567347f3afbdbca" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1491933178&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=bookforkind-20" ></a><img src="//ir-na.amazon-adsystem.com/e/ir?t=bookforkind-20&l=li2&o=1&a=1491933178" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
|
||||
<p><a href="/guide-book" target="_blank"><img style="max-width: 100%; text-align: center;" src="/_static/guide-book-cover.jpg" alt="Python Guide Book Cover"></a></p>
|
||||
|
||||
<p>All proceeds are being directly donated to the <a href="https://djangogirls.org">DjangoGirls</a> organization.</p>
|
||||
|
||||
<h3>Other Projects</h3>
|
||||
|
||||
<p>More <a href="http://kennethreitz.org/">Kenneth Reitz</a> projects:</p>
|
||||
<ul>
|
||||
<li><a href="http://howtopython.org/">howtopython.org</a></li>
|
||||
<li><a href="http://wsl-guide.org/">wsl-guide.org</a></li>
|
||||
<li><a href="http://pipenv.org/">pipenv</a></li>
|
||||
<li><a href="http://pep8.org/">pep8.org</a></li>
|
||||
<li><a href="http://python-requests.org">Requests: HTTP for Humans</a></li>
|
||||
<li><a href="https://github.com/kennethreitz/maya">Maya: Datetimes for Humans</a></li>
|
||||
<li><a href="https://github.com/kennethreitz/records">Records: SQL for Humans</a></li>
|
||||
<li><a href="http://www.git-legit.org">Legit: Git for Humans</a></li>
|
||||
<li><a href="http://docs.python-tablib.org/en/latest/">Tablib: Tabular Datasets</a></li>
|
||||
</ul>
|
||||
|
||||
<h3>Contributors</h3>
|
||||
<p>
|
||||
This guide is the result of the collaboration of
|
||||
<a href="https://github.com/kennethreitz/python-guide/graphs/contributors">hundreds of people</a>
|
||||
around the world, and your contributions
|
||||
<a href="http://docs.python-guide.org/en/latest/notes/contribute/">are welcome</a>!
|
||||
<a href="https://docs.python-guide.org/notes/contribute/">are welcome</a>!
|
||||
</p>
|
||||
|
||||
|
||||
<h3>Useful Links</h3>
|
||||
<ul>
|
||||
<li><a href="http://python-guide.org/">The Guide Website</a></li>
|
||||
<li><a href="http://github.com/kennethreitz/python-guide">The Guide @ GitHub</a></li>
|
||||
<li><a href="http://github.com/kennethreitz/python-guide/issues">Issue Tracker</a></li>
|
||||
<li><a href="https://docs.python-guide.org/">The Guide Website</a></li>
|
||||
<li><a href="http://github.com/realpython/python-guide">The Guide @ GitHub</a></li>
|
||||
<li><a href="http://github.com/realpython/python-guide/issues">Issue Tracker</a></li>
|
||||
<li><a href="https://media.readthedocs.org/pdf/python-guide/latest/python-guide.pdf">The Guide as a PDF</a></li>
|
||||
</ul>
|
||||
|
||||
<h3>Translations</h3>
|
||||
<ul>
|
||||
<li><a href="http://docs.python-guide.org/en/latest/">English</a></li>
|
||||
<li><a href="https://docs.python-guide.org/">English</a></li>
|
||||
<li><a href="https://python-guide-fr.readthedocs.io/fr/latest/">French</a></li>
|
||||
<li><a href="https://pythonguidecn.readthedocs.io/zh/latest/">Chinese</a></li>
|
||||
<li><a href="http://python-guideja.readthedocs.io/ja/latest/">Japanese</a></li>
|
||||
|
||||
@@ -4,55 +4,28 @@
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p style="margin-left:auto; margin-right: auto;"><iframe src="https://ghbtns.com/github-btn.html?user=realpython&repo=python-guide&type=watch&count=true&size=large" allowtransparency="true" frameborder="0" scrolling="0" width="200px" height="35px"></iframe></p>
|
||||
|
||||
<p>
|
||||
This opinionated guide exists to provide both novice and expert Python developers a best practice handbook to the installation, configuration, and usage of Python on a daily basis.
|
||||
</p>
|
||||
|
||||
|
||||
<h3>Get Updates</h3>
|
||||
<p>Receive updates on new releases and upcoming projects.</p>
|
||||
|
||||
<p><iframe src="http://ghbtns.com/github-btn.html?user=kennethreitz&type=follow&count=false"
|
||||
allowtransparency="true" frameborder="0" scrolling="0" width="200" height="20"></iframe></p>
|
||||
|
||||
<p><a href="https://twitter.com/kennethreitz" class="twitter-follow-button" data-show-count="false">Follow @kennethreitz</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script></p>
|
||||
<p><a href="https://saythanks.io/to/kennethreitz">Say Thanks!</a></p>
|
||||
<p><a href="http://tinyletter.com/kennethreitz">Join Mailing List</a>.</p>
|
||||
|
||||
<a href="http://www.dataquest.io/?utm_source=hitchhikersguide&utm_medium=ad">
|
||||
<img src="{{ pathto('_static/ad.png', 1) }}" alt="">
|
||||
</a>
|
||||
|
||||
<hr>
|
||||
<div style="display:block;position:relative;margin: 1em 0 1em 0;">
|
||||
<div style="display:block;width:100%;padding-top:100%;"></div>
|
||||
<div class="rpad" data-unit="1x1" style="position:absolute;left:0;top:0;right:0;bottom:0;overflow:hidden;"></div>
|
||||
</div>
|
||||
|
||||
<h3>O'Reilly Book</h3>
|
||||
|
||||
<p>This guide is now available in tangible book form!</p>
|
||||
|
||||
<a href="https://www.amazon.com/Hitchhikers-Guide-Python-Practices-Development/dp/1491933178/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=bookforkind-20&linkId=804806ebdacaf3b56567347f3afbdbca" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1491933178&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=bookforkind-20" ></a><img src="//ir-na.amazon-adsystem.com/e/ir?t=bookforkind-20&l=li2&o=1&a=1491933178" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
|
||||
<p><a href="/guide-book" target="_blank"><img style="max-width: 100%; text-align: center;" src="/_static/guide-book-cover.jpg" alt="Python Guide Book Cover"></a></p>
|
||||
|
||||
<p>All proceeds are being directly donated to the <a href="https://djangogirls.org">DjangoGirls</a> organization.</p>
|
||||
|
||||
|
||||
|
||||
<h3>Other Projects</h3>
|
||||
|
||||
<p>More <a href="http://kennethreitz.org/">Kenneth Reitz</a> projects:</p>
|
||||
<ul>
|
||||
<li><a href="http://howtopython.org/">howtopython.org</a></li>
|
||||
<li><a href="http://wsl-guide.org/">wsl-guide.org</a></li>
|
||||
<li><a href="http://pipenv.org/">pipenv</a></li>
|
||||
<li><a href="http://pep8.org/">pep8.org</a></li>
|
||||
<li><a href="http://python-requests.org">Requests: HTTP for Humans</a></li>
|
||||
<li><a href="https://github.com/kennethreitz/maya">Maya: Datetimes for Humans</a></li>
|
||||
<li><a href="https://github.com/kennethreitz/records">Records: SQL for Humans</a></li>
|
||||
<li><a href="http://www.git-legit.org">Legit: Git for Humans</a></li>
|
||||
<li><a href="http://docs.python-tablib.org/en/latest/">Tablib: Tabular Datasets</a></li>
|
||||
</ul>
|
||||
|
||||
<h3>Translations</h3>
|
||||
<ul>
|
||||
<li><a href="http://docs.python-guide.org/en/latest/">English</a></li>
|
||||
<li><a href="https://docs.python-guide.org/">English</a></li>
|
||||
<li><a href="https://python-guide-fr.readthedocs.io/fr/latest/">French</a></li>
|
||||
<li><a href="https://pythonguidecn.readthedocs.io/zh/latest/">Chinese</a></li>
|
||||
<li><a href="http://python-guideja.readthedocs.io/ja/latest/">Japanese</a></li>
|
||||
|
||||
@@ -46,7 +46,7 @@ master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'pythonguide'
|
||||
copyright = u'2016. A <a href="http://kennethreitz.com/pages/open-projects.html">Kenneth Reitz</a> Project. <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/">CC BY-NC-SA 3.0</a>'
|
||||
copyright = u'2011–2018 <a href="http://kennethreitz.com/pages/open-projects.html">Kenneth Reitz</a> & <a href="https://realpython.com">Real Python</a>. <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/">CC BY-NC-SA 3.0</a>'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
@@ -106,11 +106,11 @@ html_theme = 'alabaster'
|
||||
# documentation.
|
||||
html_theme_options = {
|
||||
'show_powered_by': False,
|
||||
'github_user': 'kennethreitz',
|
||||
'github_user': 'realpython',
|
||||
'github_repo': 'python-guide',
|
||||
'github_banner': True,
|
||||
'show_related': False,
|
||||
'note_bg': '#FFF59C'
|
||||
'note_bg': '#FFF59C',
|
||||
}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
@@ -241,7 +241,7 @@ man_pages = [
|
||||
epub_title = u'pythonguide'
|
||||
epub_author = u'Kenneth Reitz'
|
||||
epub_publisher = u'Kenneth Reitz'
|
||||
epub_copyright = u'2016, Kenneth Reitz'
|
||||
epub_copyright = u'2011–2018, Kenneth Reitz & Real Python'
|
||||
|
||||
# The language of the text. It defaults to the language option
|
||||
# or en if the language is not set.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Your Development Environment
|
||||
============================
|
||||
|
||||
.. image:: https://farm3.staticflickr.com/2930/33175624924_7febc46cc4_k_d.jpg
|
||||
.. image:: /_static/photos/33175624924_7febc46cc4_k_d.jpg
|
||||
|
||||
|
||||
Text Editors
|
||||
@@ -164,8 +164,8 @@ MIT licensed.
|
||||
Enthought Canopy
|
||||
----------------
|
||||
`Enthought Canopy <https://www.enthought.com/products/canopy/>`_ is a Python
|
||||
IDE which is focused towards Scientists and Engineers as it provides pre
|
||||
installed libraries for data analysis.
|
||||
IDE which is focused towards Scientists and Engineers as it provides pre
|
||||
installed libraries for data analysis.
|
||||
|
||||
Eclipse
|
||||
-------
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Further Configuration of Pip and Virtualenv
|
||||
===========================================
|
||||
|
||||
.. image:: https://farm4.staticflickr.com/3934/34018732105_f0e6758859_k_d.jpg
|
||||
.. image:: /_static/photos/34018732105_f0e6758859_k_d.jpg
|
||||
|
||||
Requiring an active virtual environment for ``pip``
|
||||
---------------------------------------------------
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
Pipenv & Virtual Environments
|
||||
=============================
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4290/35294660055_42c02b2316_k_d.jpg
|
||||
.. image:: /_static/photos/35294660055_42c02b2316_k_d.jpg
|
||||
|
||||
This tutorial walks you through installing and using Python packages.
|
||||
This tutorial walks you through installing and using Python packages.
|
||||
|
||||
It will show you how to install and use the necessary tools and make strong
|
||||
recommendations on best practices. Keep in mind that Python is used for a great
|
||||
@@ -34,7 +34,7 @@ install the latest 3.x version from `python.org`_ or refer to the
|
||||
`Installing Python`_ section of this guide.
|
||||
|
||||
.. Note:: If you're newcomer and you get an error like this:
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
>>> python
|
||||
@@ -47,7 +47,7 @@ install the latest 3.x version from `python.org`_ or refer to the
|
||||
`getting started tutorial`_ for an introduction to using your operating
|
||||
system's shell and interacting with Python.
|
||||
|
||||
Additionally, you'll need to make sure you have :ref:`pip` available. You can
|
||||
Additionally, you'll need to make sure you have `pip`_ available. You can
|
||||
check this by running:
|
||||
|
||||
.. code-block:: bash
|
||||
@@ -60,22 +60,23 @@ using your OS package manager, you may have to `install pip <https://pip.pypa.io
|
||||
|
||||
.. _getting started tutorial: https://opentechschool.github.io/python-beginners/en/getting_started.html#what-is-python-exactly
|
||||
.. _python.org: https://python.org
|
||||
.. _pip: https://pypi.org/project/pip/
|
||||
.. _Homebrew: https://brew.sh
|
||||
.. _Installing Python: http://docs.python-guide.org/en/latest/starting/installation/
|
||||
.. _Installing Python: https://docs.python-guide.org/starting/installation/
|
||||
|
||||
|
||||
Installing Pipenv
|
||||
-----------------
|
||||
|
||||
:ref:`Pipenv` is a dependency manager for Python projects. If you're familiar
|
||||
`Pipenv`_ is a dependency manager for Python projects. If you're familiar
|
||||
with Node.js' `npm`_ or Ruby's `bundler`_, it is similar in spirit to those
|
||||
tools. While :ref:`pip` can install Python packages, Pipenv is recommended as
|
||||
tools. While `pip`_ can install Python packages, Pipenv is recommended as
|
||||
it's a higher-level tool that simplifies dependency management for common use
|
||||
cases.
|
||||
|
||||
Use ``pip`` to install Pipenv:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: console
|
||||
|
||||
$ pip install --user pipenv
|
||||
|
||||
@@ -100,6 +101,7 @@ Use ``pip`` to install Pipenv:
|
||||
user ``PATH`` permanently in the `Control Panel`_. You may need to log
|
||||
out for the ``PATH`` changes to take effect.
|
||||
|
||||
.. _Pipenv: https://docs.pipenv.org/
|
||||
.. _npm: https://www.npmjs.com/
|
||||
.. _bundler: http://bundler.io/
|
||||
.. _user base: https://docs.python.org/3/library/site.html#site.USER_BASE
|
||||
@@ -120,11 +122,13 @@ tutorial) and run:
|
||||
$ pipenv install requests
|
||||
|
||||
Pipenv will install the excellent `Requests`_ library and create a ``Pipfile``
|
||||
for you in your project's directory. The :ref:`Pipfile` is used to track which
|
||||
for you in your project's directory. The `Pipfile`_ is used to track which
|
||||
dependencies your project needs in case you need to re-install them, such as
|
||||
when you share your project with others. You should get output similar to this
|
||||
(although the exact paths shown will vary):
|
||||
|
||||
.. _Pipfile: https://github.com/pypa/pipfile
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
Creating a Pipfile for this project...
|
||||
@@ -207,7 +211,7 @@ Install virtualenv via pip:
|
||||
.. code-block:: console
|
||||
|
||||
$ pip install virtualenv
|
||||
|
||||
|
||||
Test your installation
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
@@ -3,13 +3,16 @@
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
.. meta::
|
||||
:description: An opinionated guide to the Python programming language and a best practice handbook to the installation, configuration, and usage of Python on a daily basis.
|
||||
|
||||
The Hitchhiker's Guide to Python!
|
||||
=================================
|
||||
|
||||
Greetings, Earthling! Welcome to The Hitchhiker's Guide to Python.
|
||||
|
||||
**This is a living, breathing guide.** If you'd like to contribute,
|
||||
`fork us on GitHub <https://github.com/kennethreitz/python-guide>`_!
|
||||
`fork us on GitHub <https://github.com/realpython/python-guide>`_!
|
||||
|
||||
This handcrafted guide exists to provide both novice and expert Python
|
||||
developers a best practice handbook to the installation, configuration, and
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
The Community
|
||||
=============
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4225/34689432801_78d97ecec9_k_d.jpg
|
||||
.. image:: /_static/photos/34689432801_78d97ecec9_k_d.jpg
|
||||
|
||||
BDFL
|
||||
----
|
||||
@@ -71,7 +71,7 @@ Here's an overview of the PEP acceptance workflow:
|
||||
|
||||
|
||||
Python Conferences
|
||||
--------------------------
|
||||
------------------
|
||||
|
||||
The major events for the Python community are developer conferences. The two
|
||||
most notable conferences are PyCon, which is held in the US, and its European
|
||||
@@ -81,8 +81,17 @@ A comprehensive list of conferences is maintained at `pycon.org <http://www.pyco
|
||||
|
||||
|
||||
Python User Groups
|
||||
--------------------------
|
||||
------------------
|
||||
|
||||
User Groups are where a bunch of Python developers meet to present or talk
|
||||
about Python topics of interest. A list of local user groups is maintained at
|
||||
the `Python Software Foundation Wiki <http://wiki.python.org/moin/LocalUserGroups>`_.
|
||||
|
||||
|
||||
Online Communities
|
||||
------------------
|
||||
|
||||
`PythonistaCafe <https://www.pythonistacafe.com>`_ is an invite-only, online community
|
||||
of Python and software development enthusiasts helping each other succeed and grow.
|
||||
Think of it as a club of mutual improvement for Pythonistas where a broad range of
|
||||
programming questions, career advice, and other topics are discussed every day.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Documentation
|
||||
=============
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4178/33928823133_2f3d32cf32_k_d.jpg
|
||||
.. image:: /_static/photos/33928823133_2f3d32cf32_k_d.jpg
|
||||
|
||||
Official Documentation
|
||||
----------------------
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Introduction
|
||||
============
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4180/34725946825_0f85497e60_k_d.jpg
|
||||
.. image:: /_static/photos/34725946825_0f85497e60_k_d.jpg
|
||||
|
||||
From the `official Python website <http://python.org/about/>`_:
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Learning Python
|
||||
===============
|
||||
|
||||
.. image:: https://farm3.staticflickr.com/2840/32800783863_11a00db52c_k_d.jpg
|
||||
.. image:: /_static/photos/32800783863_11a00db52c_k_d.jpg
|
||||
|
||||
Beginner
|
||||
--------
|
||||
@@ -15,8 +15,22 @@ quick-start guide to the language.
|
||||
|
||||
`The Python Tutorial <http://docs.python.org/tutorial/index.html>`_
|
||||
|
||||
Real Python
|
||||
~~~~~~~~~~~
|
||||
|
||||
Real Python is a repository of free and in-depth Python tutorials created by a diverse team of professional Python developers. At Real Python you can learn all things Python from the ground up. Everything from the absolute basics of Python, to web development and web scraping, to data visualization, and beyond.
|
||||
|
||||
`Real Python <https://realpython.com/>`_
|
||||
|
||||
Python Basics
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
pythonbasics.org is an introductiory tutorial for beginners. The tutorial includes exercises. It covers the basics and there are also in-depth lessons like object oriented programming and regular expressions.
|
||||
|
||||
`Python basics <https://pythonbasics.org/>`_
|
||||
|
||||
Python for Beginners
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
thepythonguru.com is a tutorial focuses on beginner programmers. It covers many python concepts
|
||||
in depth. It also teaches you some advance constructs of python like lambda expression, regular expression.
|
||||
@@ -25,14 +39,6 @@ At last it finishes off with tutorial "How to access MySQL db using python"
|
||||
|
||||
`Python for beginners <http://thepythonguru.com/>`_
|
||||
|
||||
Learn Python for Data Science Interactively
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
If you prefer an online interactive environment to learn Python for Data Science, `this free python tutorial by DataCamp <https://www.datacamp.com/courses/intro-to-python-for-data-science?tap_a=5644-dce66f&tap_s=116411-750171>`_ is a great way to get started. If you're already somewhat advanced and interested in machine learning, check out this `course on Supervised Learning with scikit-learn <https://www.datacamp.com/courses/supervised-learning-with-scikit-learn?tap_a=5644-dce66f&tap_s=116411-750171>`_, by one the core developers of scikit-learn.
|
||||
|
||||
|
||||
`Python for data science <http://datacamp.com/?tap_a=5644-dce66f&tap_s=116411-750171>`_
|
||||
|
||||
Learn Python Interactive Tutorial
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -44,12 +50,10 @@ without having to install Python locally.
|
||||
|
||||
`Learn Python <http://www.learnpython.org/>`_
|
||||
|
||||
|
||||
If you want a more traditional book, *Python For You and Me* is an excellent
|
||||
resource for learning all aspects of the language.
|
||||
|
||||
`Python for You and Me <https://pymbook.readthedocs.io/>`_
|
||||
`Learn Python Interactively with DataCamp! <https://www.datacamp.com/>`_
|
||||
|
||||
Learn Python Step by Step
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -116,7 +120,7 @@ Dive Into Python 3 is a good book for those ready to jump in to Python 3. It's
|
||||
a good read if you are moving from Python 2 to 3 or if you already have some
|
||||
experience programming in another language.
|
||||
|
||||
`Dive Into Python 3 <http://www.diveintopython3.net/>`_
|
||||
`Dive Into Python 3 <http://diveintopython3.problemsolving.io/>`_
|
||||
|
||||
|
||||
Think Python: How to Think Like a Computer Scientist
|
||||
@@ -191,6 +195,15 @@ making the process of learning Python fun and engaging.
|
||||
Intermediate
|
||||
------------
|
||||
|
||||
Python Tricks: The Book
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Discover Python's best practices with simple examples and start writing even more beautiful + Pythonic code. "Python Tricks: The Book" shows you exactly how.
|
||||
|
||||
You’ll master intermediate and advanced-level features in Python with practical examples and a clear narrative:
|
||||
|
||||
`Python Tricks: The Book <https://realpython.com/products/python-tricks-book/>`_
|
||||
|
||||
Effective Python
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -243,7 +256,7 @@ and can make classes and objects behave in different and magical ways.
|
||||
|
||||
.. note:: The Rafekettler.com is currently down, you can go to their Github version directly. Here you can find a PDF version:
|
||||
`A Guide to Python's Magic Methods (repo on GitHub) <https://github.com/RafeKettler/magicmethods/blob/master/magicmethods.pdf>`_
|
||||
|
||||
|
||||
|
||||
|
||||
For Engineers and Scientists
|
||||
@@ -266,7 +279,7 @@ puts the emphasis on numerical methods and how to implement them in Python.
|
||||
|
||||
`Numerical Methods in Engineering with Python <http://www.cambridge.org/us/academic/subjects/engineering/engineering-mathematics-and-programming/numerical-methods-engineering-python-2nd-edition>`_
|
||||
|
||||
Miscellaneous topics
|
||||
Miscellaneous Topics
|
||||
--------------------
|
||||
|
||||
Problem Solving with Algorithms and Data Structures
|
||||
@@ -315,6 +328,14 @@ web app from scratch.
|
||||
`Fullstack Python <https://www.fullstackpython.com>`_
|
||||
|
||||
|
||||
PythonistaCafe
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
PythonistaCafe is an invite-only, online community of Python and software development enthusiasts helping each other succeed and grow. Think of it as a club of mutual improvement for Pythonistas where a broad range of programming questions, career advice, and other topics are discussed every day.
|
||||
|
||||
`PythonistaCafe <https://www.pythonistacafe.com>`_
|
||||
|
||||
|
||||
References
|
||||
----------
|
||||
|
||||
|
||||
@@ -1,7 +1,22 @@
|
||||
News
|
||||
====
|
||||
|
||||
.. image:: https://farm4.staticflickr.com/3804/33573767786_eececc5d27_k_d.jpg
|
||||
.. image:: /_static/photos/33573767786_eececc5d27_k_d.jpg
|
||||
|
||||
PyCoder’s Weekly
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
PyCoder’s Weekly is a free weekly Python newsletter for Python developers
|
||||
by Python developers (Projects, Articles, News, and Jobs).
|
||||
|
||||
`PyCoder’s Weekly <https://pycoders.com/>`_
|
||||
|
||||
Real Python
|
||||
~~~~~~~~~~~
|
||||
|
||||
At Real Python you can learn all things Python from the ground up, with weekly free and in-depth tutorials. Everything from the absolute basics of Python, to web development and web scraping, to data visualization, and beyond.
|
||||
|
||||
`Real Python <https://realpython.com/>`_
|
||||
|
||||
Planet Python
|
||||
~~~~~~~~~~~~~
|
||||
@@ -32,14 +47,6 @@ A short-form Python podcast covering recent developer headlines.
|
||||
|
||||
`Python Bytes <https://pythonbytes.fm>`_
|
||||
|
||||
Pycoder's Weekly
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Pycoder's Weekly is a free weekly Python newsletter for Python developers
|
||||
by Python developers (Projects, Articles, News, and Jobs).
|
||||
|
||||
`Pycoder's Weekly <http://www.pycoders.com/>`_
|
||||
|
||||
Python Weekly
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Contribute
|
||||
~~~~~~~~~~
|
||||
|
||||
.. image:: https://farm3.staticflickr.com/2858/33573769116_49c1ef51e7_k_d.jpg
|
||||
.. image:: /_static/photos/33573769116_49c1ef51e7_k_d.jpg
|
||||
|
||||
Python-guide is under active development, and contributors are welcome.
|
||||
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
License
|
||||
=======
|
||||
|
||||
.. image:: https://farm4.staticflickr.com/3762/32800805573_568d6b72fd_k_d.jpg
|
||||
.. image:: /_static/photos/32800805573_568d6b72fd_k_d.jpg
|
||||
|
||||
The Guide is licensed under the `Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported license <https://creativecommons.org/licenses/by-nc-sa/3.0/>`_.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
The Guide Style Guide
|
||||
=====================
|
||||
|
||||
.. image:: https://farm4.staticflickr.com/3684/33573755856_7f43d43adf_k_d.jpg
|
||||
.. image:: /_static/photos/33573755856_7f43d43adf_k_d.jpg
|
||||
|
||||
As with all documentation, having a consistent format helps make the
|
||||
document more understandable. In order to make The Guide easier to digest,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Systems Administration
|
||||
======================
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4179/34435690580_3afec7d4cd_k_d.jpg
|
||||
.. image:: /_static/photos/34435690580_3afec7d4cd_k_d.jpg
|
||||
|
||||
Fabric
|
||||
------
|
||||
@@ -234,37 +234,37 @@ The Ansible playbook will ping all of the servers in the :file:`hosts.yml` file.
|
||||
You can also select groups of servers using Ansible. For more information
|
||||
about Ansible, read the `Ansible Docs <http://docs.ansible.com/>`_.
|
||||
|
||||
`An Ansible tutorial <https://serversforhackers.com/an-ansible-tutorial/>`_ is also a
|
||||
`An Ansible tutorial <https://serversforhackers.com/an-ansible-tutorial/>`_ is also a
|
||||
great and detailed introduction to getting started with Ansible.
|
||||
|
||||
|
||||
Chef
|
||||
----
|
||||
`Chef <https://www.chef.io/chef/>`_ is a systems and cloud infrastructure automation
|
||||
framework that makes it easy to deploy servers and applications to any physical,
|
||||
virtual, or cloud location. In case this is your choice for configuration management,
|
||||
you will primarily use Ruby to write your infrastructure code.
|
||||
`Chef <https://www.chef.io/chef/>`_ is a systems and cloud infrastructure automation
|
||||
framework that makes it easy to deploy servers and applications to any physical,
|
||||
virtual, or cloud location. In case this is your choice for configuration management,
|
||||
you will primarily use Ruby to write your infrastructure code.
|
||||
|
||||
Chef clients run on every server that is part of your infrastructure and these regularly
|
||||
check with your Chef server to ensure your system is always aligned and represents the
|
||||
desired state. Since each individual server has its own distinct Chef client, each server
|
||||
Chef clients run on every server that is part of your infrastructure and these regularly
|
||||
check with your Chef server to ensure your system is always aligned and represents the
|
||||
desired state. Since each individual server has its own distinct Chef client, each server
|
||||
configures itself and this distributed approach makes Chef a scalable automation platform.
|
||||
|
||||
Chef works by using custom recipes (configuration elements), implemented in cookbooks. Cookbooks, which are basically
|
||||
packages for infrastructure choices, are usually stored in your Chef server.
|
||||
Read the `Digital Ocean tutorial series
|
||||
<https://www.digitalocean.com/community/tutorials/how-to-install-a-chef-server-workstation-and-client-on-ubuntu-vps-instances>`_
|
||||
Chef works by using custom recipes (configuration elements), implemented in cookbooks. Cookbooks, which are basically
|
||||
packages for infrastructure choices, are usually stored in your Chef server.
|
||||
Read the `Digital Ocean tutorial series
|
||||
<https://www.digitalocean.com/community/tutorials/how-to-install-a-chef-server-workstation-and-client-on-ubuntu-vps-instances>`_
|
||||
on chef to learn how to create a simple Chef Server.
|
||||
|
||||
To create a simple cookbook the `knife <https://docs.chef.io/knife.html>`_ command is used:
|
||||
|
||||
.. code-block:: console
|
||||
.. code-block:: console
|
||||
|
||||
knife cookbook create cookbook_name
|
||||
|
||||
`Getting started with Chef <http://gettingstartedwithchef.com/first-steps-with-chef.html>`_
|
||||
is a good starting point for Chef Beginners and many community maintained cookbooks that can
|
||||
serve as a good reference or tweaked to serve your infrastructure configuration needs can be
|
||||
`Getting started with Chef <http://gettingstartedwithchef.com/first-steps-with-chef.html>`_
|
||||
is a good starting point for Chef Beginners and many community maintained cookbooks that can
|
||||
serve as a good reference or tweaked to serve your infrastructure configuration needs can be
|
||||
found on the `Chef Supermarket <https://supermarket.chef.io/cookbooks>`_.
|
||||
|
||||
- `Chef Documentation <https://docs.chef.io/>`_
|
||||
@@ -304,7 +304,7 @@ your Puppet modules.
|
||||
.. code-block:: console
|
||||
|
||||
$ facter operatingsystem
|
||||
Ubuntu
|
||||
Ubuntu
|
||||
|
||||
Writing Modules in Puppet is pretty straight forward. Puppet Manifests together
|
||||
form Puppet Modules. Puppet manifest end with an extension of ``.pp``.
|
||||
@@ -374,7 +374,7 @@ Buildout
|
||||
--------
|
||||
|
||||
`Buildout <http://www.buildout.org>`_ is an open source software build tool.
|
||||
Buildout is created using the Python programming language. It implements a
|
||||
Buildout is created using the Python programming language. It implements a
|
||||
principle of separation of configuration from the scripts that do the setting up.
|
||||
Buildout is primarily used to download and set up dependencies in Python eggs
|
||||
format of the software being developed or deployed. Recipes for build tasks in any
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Continuous Integration
|
||||
======================
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4173/33907150594_9abba7ad0a_k_d.jpg
|
||||
.. image:: /_static/photos/33907150594_9abba7ad0a_k_d.jpg
|
||||
|
||||
.. note::
|
||||
For advice on writing your tests, see :doc:`/writing/tests`.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Command-line Applications
|
||||
=========================
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4272/34435690330_11930b5987_k_d.jpg
|
||||
.. image:: /_static/photos/34435690330_11930b5987_k_d.jpg
|
||||
|
||||
Command-line applications, also referred to as
|
||||
`Console Applications <http://en.wikipedia.org/wiki/Console_application>`_,
|
||||
@@ -68,9 +68,20 @@ sub-command to do the work.
|
||||
Cement
|
||||
------
|
||||
|
||||
`Cement <http://builtoncement.com/>`_ is an advanced CLI Application Framework.
|
||||
`Cement <http://builtoncement.com/>`_ is an advanced CLI Application Framework.
|
||||
Its goal is to introduce a standard, and feature-full platform
|
||||
for both simple and complex command line applications as well
|
||||
as support rapid development needs without sacrificing quality.
|
||||
Cement is flexible, and it's use cases span from the simplicity of a micro-framework
|
||||
to the complexity of a meg-framework.
|
||||
as support rapid development needs without sacrificing quality.
|
||||
Cement is flexible, and it's use cases span from the simplicity of a micro-framework
|
||||
to the complexity of a meg-framework.
|
||||
|
||||
Python Fire
|
||||
-----------
|
||||
|
||||
`Python Fire <https://github.com/google/python-fire/>`_ is a library for
|
||||
automatically generating command line interfaces from absolutely any Python
|
||||
object. It can help debug Python code more easily from the command line,
|
||||
create CLI interfaces to existing code, allow you to interactively explore
|
||||
code in a REPL, and simplify transitioning between Python and Bash (or any
|
||||
other shell).
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Interfacing with C/C++ Libraries
|
||||
================================
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4173/34725951345_c8f5959a2e_k_d.jpg
|
||||
.. image:: /_static/photos/34725951345_c8f5959a2e_k_d.jpg
|
||||
|
||||
C Foreign Function Interface
|
||||
----------------------------
|
||||
@@ -105,20 +105,20 @@ Example: Overloading __repr__
|
||||
:linenos:
|
||||
|
||||
%include "string.i"
|
||||
|
||||
|
||||
%module myclass
|
||||
%{
|
||||
#include <string>
|
||||
#include "MyClass.h"
|
||||
%}
|
||||
|
||||
|
||||
%extend MyClass {
|
||||
std::string __repr__()
|
||||
{
|
||||
return $self->getName();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%include "MyClass.h"
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Network Applications
|
||||
====================
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4251/34364815780_bea6614025_k_d.jpg
|
||||
.. image:: /_static/photos/34364815780_bea6614025_k_d.jpg
|
||||
|
||||
HTTP
|
||||
::::
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
Cryptography
|
||||
============
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4220/33907152824_bf91078cc1_k_d.jpg
|
||||
.. image:: /_static/photos/33907152824_bf91078cc1_k_d.jpg
|
||||
|
||||
Cryptography
|
||||
------------
|
||||
|
||||
`Cryptography <https://cryptography.io/en/latest/>`_ is an actively developed
|
||||
library that provides cryptographic recipes and primitives. It supports
|
||||
library that provides cryptographic recipes and primitives. It supports
|
||||
Python 2.6-2.7, Python 3.3+ and PyPy.
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ Example
|
||||
.. code-block:: python3
|
||||
|
||||
import gpg
|
||||
|
||||
|
||||
# Encryption to public key specified in rkey.
|
||||
a_key = input("Enter the fingerprint or key ID to encrypt to: ")
|
||||
filename = input("Enter the filename to encrypt: ")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Databases
|
||||
=========
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4225/33907152464_a99fdcc8de_k_d.jpg
|
||||
.. image:: /_static/photos/33907152464_a99fdcc8de_k_d.jpg
|
||||
|
||||
DB-API
|
||||
------
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
GUI Applications
|
||||
================
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4250/33907143624_cd621b535c_k_d.jpg
|
||||
.. image:: /_static/photos/33907143624_cd621b535c_k_d.jpg
|
||||
|
||||
|
||||
Alphabetical list of GUI Applications.
|
||||
@@ -59,7 +59,9 @@ PySide
|
||||
------
|
||||
PySide is a Python binding of the cross-platform GUI toolkit Qt.
|
||||
|
||||
pip install pyside
|
||||
.. code-block:: console
|
||||
|
||||
$ pip install pyside
|
||||
|
||||
https://wiki.qt.io/Category:LanguageBindings::PySide::Downloads
|
||||
|
||||
@@ -88,6 +90,16 @@ Qt
|
||||
is widely used for developing software with a GUI but can also be used for
|
||||
non-GUI applications.
|
||||
|
||||
PySimpleGUI
|
||||
------
|
||||
`PySimpleGUI <https://pysimplegui.readthedocs.io/>`_ is a wrapper for the Tkinter. The amount of code required to implement custom GUIs is much shorter using PySimpleGUI than if the same GUI were written directly using tkinter. Having Tkinter as a base results in the ability to run on a larger number of platforms than other GUI frameworks.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ pip install pysimplegui
|
||||
|
||||
PySimpleGUI is contained in a single PySimpleGUI.py file. Should pip installation be impossible, pasting the PySimpleGUI.py file into a project's folder is all that's required to import and begin using.
|
||||
|
||||
Toga
|
||||
----
|
||||
`Toga <https://toga.readthedocs.io/en/latest/>`_ is a Python native, OS
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Image Manipulation
|
||||
==================
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4157/34575689432_3de8e9a348_k_d.jpg
|
||||
.. image:: /_static/photos/34575689432_3de8e9a348_k_d.jpg
|
||||
|
||||
Most image processing and manipulation techniques can be carried out
|
||||
effectively using two libraries: Python Imaging Library (PIL) and OpenSource
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
JSON
|
||||
====
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4174/33928819683_97b5c6a184_k_d.jpg
|
||||
.. image:: /_static/photos/33928819683_97b5c6a184_k_d.jpg
|
||||
|
||||
The `json <https://docs.python.org/2/library/json.html>`_ library can parse
|
||||
JSON from strings or files. The library parses JSON into a Python dictionary
|
||||
@@ -60,7 +60,7 @@ You can start using simplejson when the json library is not available by
|
||||
importing simplejson under a different name:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
||||
import simplejson as json
|
||||
|
||||
After importing simplejson as json, the above examples will all work as if you
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
Machine Learning
|
||||
================
|
||||
|
||||
.. image:: https://farm4.staticflickr.com/3954/34018729885_002ced9b54_k_d.jpg
|
||||
.. image:: /_static/photos/34018729885_002ced9b54_k_d.jpg
|
||||
|
||||
Python has a vast number of libraries for data analysis, statistics and Machine Learning itself, making it a language of choice for many data scientists.
|
||||
Python has a vast number of libraries for data analysis, statistics and Machine Learning itself, making it a language of choice for many data scientists.
|
||||
|
||||
Some widely used packages for Machine Learning and other Data Science applications are enlisted below.
|
||||
|
||||
@@ -45,7 +45,7 @@ Installation
|
||||
Through PyPI:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
||||
pip install -U scikit-learn
|
||||
|
||||
Through conda:
|
||||
@@ -61,28 +61,28 @@ Example
|
||||
|
||||
For this example, we train a simple classifier on the `Iris dataset <http://en.wikipedia.org/wiki/Iris_flower_data_set>`_, which comes bundled in with scikit-learn.
|
||||
|
||||
The dataset takes four features of flowers: sepal length, sepal width, petal length and petal width, and classifies them into three flower species (labels): setosa, versicolor or virginica. The labels have been represented as numbers in the dataset: 0 (setosa), 1 (versicolor) and 2 (virginica).
|
||||
The dataset takes four features of flowers: sepal length, sepal width, petal length and petal width, and classifies them into three flower species (labels): setosa, versicolor or virginica. The labels have been represented as numbers in the dataset: 0 (setosa), 1 (versicolor) and 2 (virginica).
|
||||
|
||||
We shuffle the Iris dataset, and divide it into separate training and testing sets: keeping the last 10 data points for testing and rest for training. We then train the classifier on the training set, and predict on the testing set.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from sklearn.datasets import load_iris
|
||||
from sklearn.datasets import load_iris
|
||||
from sklearn import tree
|
||||
from sklearn.metrics import accuracy_score
|
||||
import numpy as np
|
||||
|
||||
#loading the iris dataset
|
||||
iris = load_iris()
|
||||
iris = load_iris()
|
||||
|
||||
x = iris.data #array of the data
|
||||
y = iris.target #array of labels (i.e answers) of each data entry
|
||||
|
||||
#getting label names i.e the three flower species
|
||||
y_names = iris.target_names
|
||||
y_names = iris.target_names
|
||||
|
||||
#taking random indices to split the dataset into train and test
|
||||
test_ids = np.random.permutation(len(x))
|
||||
test_ids = np.random.permutation(len(x))
|
||||
|
||||
#splitting data and labels into train and test
|
||||
#keeping last 10 entries for testing, rest for training
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Networking
|
||||
==========
|
||||
|
||||
.. image:: https://farm3.staticflickr.com/2892/34151833832_6bdfd930af_k_d.jpg
|
||||
.. image:: /_static/photos/34151833832_6bdfd930af_k_d.jpg
|
||||
|
||||
Twisted
|
||||
-------
|
||||
@@ -35,4 +35,4 @@ gevent
|
||||
|
||||
`gevent <http://www.gevent.org/>`_ is a coroutine-based Python networking
|
||||
library that uses greenlets to provide a high-level synchronous API on top of
|
||||
the libev event loop.
|
||||
the libev event loop.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Scientific Applications
|
||||
=======================
|
||||
|
||||
.. image:: https://farm3.staticflickr.com/2890/33925223870_97e44f5629_k_d.jpg
|
||||
.. image:: /_static/photos/33925223870_97e44f5629_k_d.jpg
|
||||
|
||||
Context
|
||||
:::::::
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
HTML Scraping
|
||||
=============
|
||||
|
||||
.. image:: https://farm3.staticflickr.com/2900/34268661876_442428e122_k_d.jpg
|
||||
.. image:: /_static/photos/34268661876_442428e122_k_d.jpg
|
||||
|
||||
Web Scraping
|
||||
------------
|
||||
@@ -105,5 +105,3 @@ using Python or we can save it to a file and share it with the world.
|
||||
Some more cool ideas to think about are modifying this script to iterate
|
||||
through the rest of the pages of this example dataset, or rewriting this
|
||||
application to use threads for improved speed.
|
||||
|
||||
If you want to learn how to import data using python - this `DataCamp course on Importing Data <https://www.datacamp.com/courses/importing-data-in-r-part-1?tap_a=5644-dce66f&tap_s=116411-750171>`_ is a great place to start.
|
||||
|
||||
@@ -2,41 +2,41 @@
|
||||
Data Serialization
|
||||
==================
|
||||
|
||||
.. image:: https://farm3.staticflickr.com/2927/33467946364_3e59bd376a_k_d.jpg
|
||||
.. image:: /_static/photos/33467946364_3e59bd376a_k_d.jpg
|
||||
|
||||
What is data serialization?
|
||||
---------------------------
|
||||
|
||||
Data serialization is the concept of converting structured data into a format
|
||||
that allows it to be shared or stored in such a way that its original
|
||||
structure to be recovered. In some cases, the secondary intention of data
|
||||
serialization is to minimize the size of the serialized data which then
|
||||
Data serialization is the concept of converting structured data into a format
|
||||
that allows it to be shared or stored in such a way that its original
|
||||
structure to be recovered. In some cases, the secondary intention of data
|
||||
serialization is to minimize the size of the serialized data which then
|
||||
minimizes disk space or bandwidth requirements.
|
||||
|
||||
Pickle
|
||||
------
|
||||
|
||||
The native data serialization module for Python is called `Pickle
|
||||
<https://docs.python.org/2/library/pickle.html>`_.
|
||||
The native data serialization module for Python is called `Pickle
|
||||
<https://docs.python.org/2/library/pickle.html>`_.
|
||||
|
||||
Here's an example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
||||
import pickle
|
||||
|
||||
|
||||
#Here's an example dict
|
||||
grades = { 'Alice': 89, 'Bob': 72, 'Charles': 87 }
|
||||
|
||||
|
||||
#Use dumps to convert the object to a serialized string
|
||||
serial_grades = pickle.dumps( grades )
|
||||
|
||||
#Use loads to de-serialize an object
|
||||
|
||||
#Use loads to de-serialize an object
|
||||
received_grades = pickle.loads( serial_grades )
|
||||
|
||||
Protobuf
|
||||
--------
|
||||
|
||||
If you're looking for a serialization module that has support in multiple
|
||||
languages, Google's `Protobuf
|
||||
<https://developers.google.com/protocol-buffers>`_ library is an option.
|
||||
If you're looking for a serialization module that has support in multiple
|
||||
languages, Google's `Protobuf
|
||||
<https://developers.google.com/protocol-buffers>`_ library is an option.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Speed
|
||||
=====
|
||||
|
||||
.. image:: https://farm3.staticflickr.com/2826/33175625804_e225b90f3e_k_d.jpg
|
||||
.. image:: /_static/photos/33175625804_e225b90f3e_k_d.jpg
|
||||
|
||||
CPython, the most commonly used implementation of Python, is slow for CPU bound
|
||||
tasks. `PyPy`_ is fast.
|
||||
@@ -234,14 +234,14 @@ Concurrent.futures
|
||||
The `concurrent.futures`_ module is a module in the standard library that
|
||||
provides a "high-level interface for asynchronously executing callables". It
|
||||
abstracts away a lot of the more complicated details about using multiple
|
||||
threads or processes for concurrency, and allows the user to focus on
|
||||
threads or processes for concurrency, and allows the user to focus on
|
||||
accomplishing the task at hand.
|
||||
|
||||
The `concurrent.futures`_ module exposes two main classes, the
|
||||
`ThreadPoolExecutor` and the `ProcessPoolExecutor`. The ThreadPoolExecutor
|
||||
will create a pool of worker threads that a user can submit jobs to. These jobs
|
||||
will then be executed in another thread when the next worker thread becomes
|
||||
available.
|
||||
available.
|
||||
|
||||
The ProcessPoolExecutor works in the same way, except instead of using multiple
|
||||
threads for its workers, it will use multiple processes. This makes it possible
|
||||
@@ -275,7 +275,7 @@ everything in parallel. :
|
||||
# Do something with the result
|
||||
print(page.text)
|
||||
|
||||
For even more control, the `submit(func, *args, **kwargs)` method will schedule
|
||||
For even more control, the `submit(func, *args, **kwargs)` method will schedule
|
||||
a callable to be executed ( as `func(*args, **kwargs)`) and returns a `Future`_
|
||||
object that represents the execution of the callable.
|
||||
|
||||
@@ -389,9 +389,9 @@ still alive (because the join call timed out):
|
||||
Because multiple threads have access to the same section of memory, sometimes
|
||||
there might be situations where two or more threads are trying to write to the
|
||||
same resource at the same time or where the output is dependent on the sequence
|
||||
or timing of certain events. This is called a `data race`_ or race condition.
|
||||
or timing of certain events. This is called a `data race`_ or race condition.
|
||||
When this happens, the output will be garbled or you may encounter problems
|
||||
which are difficult to debug. A good example is this `stackoverflow post`_.
|
||||
which are difficult to debug. A good example is this `stackoverflow post`_.
|
||||
|
||||
The way this can be avoided is by using a `Lock`_ that each thread needs to
|
||||
acquire before writing to a shared resource. Locks can be acquired and released
|
||||
@@ -412,7 +412,7 @@ through either the contextmanager protocol (`with` statement), or by using
|
||||
|
||||
def monitor_website(some_website):
|
||||
"""
|
||||
Monitor a website and then if there are any changes,
|
||||
Monitor a website and then if there are any changes,
|
||||
log them to disk.
|
||||
"""
|
||||
while True:
|
||||
@@ -429,7 +429,7 @@ Here, we have a bunch of threads checking for changes on a list of sites and
|
||||
whenever there are any changes, they attempt to write those changes to a file
|
||||
by calling `log(changes)`. When `log()` is called, it will wait to acquire
|
||||
the lock with `with file_lock:`. This ensures that at any one time, only one
|
||||
thread is writing to the file.
|
||||
thread is writing to the file.
|
||||
|
||||
Spawning Processes
|
||||
------------------
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Web Applications & Frameworks
|
||||
=============================
|
||||
|
||||
.. image:: https://farm3.staticflickr.com/2891/34309496175_b82d104282_k_d.jpg
|
||||
.. image:: /_static/photos/34309496175_b82d104282_k_d.jpg
|
||||
|
||||
As a powerful scripting language adapted to both fast prototyping
|
||||
and bigger projects, Python is widely used in web application
|
||||
@@ -51,7 +51,7 @@ Development Web Server
|
||||
Django
|
||||
------
|
||||
|
||||
`Django <http://www.djangoproject.com>`_ is a "batteries included" web
|
||||
`Django <https://www.djangoproject.com>`_ is a "batteries included" web
|
||||
application framework, and is an excellent choice for creating content-oriented
|
||||
websites. By providing many utilities and patterns out of the box, Django aims
|
||||
to make it possible to build complex, database-backed web applications quickly,
|
||||
@@ -91,6 +91,19 @@ suit your needs. Or, you can easily use any library you want yourself!
|
||||
Flask is default choice for any Python web application that isn't a good
|
||||
fit for Django.
|
||||
|
||||
Falcon
|
||||
------
|
||||
|
||||
`Falcon <https://falconframework.org/>`_ is a good choice when your goal is
|
||||
to build RESTful API microservices that are fast and scalable.
|
||||
|
||||
It is a reliable, high-performance Python web framework for building large-scale
|
||||
app backends and microservices. Falcon encourages the REST architectural style of
|
||||
mapping URIs to resources, trying to do as little as possible while remaining highly effective.
|
||||
|
||||
Falcon highlights four main focuses: speed, reliability, flexibility and debuggability.
|
||||
It implements HTTP through "responders" such as ``on_get()``, ``on_put()``, etc.
|
||||
These responders receive intuitive request and response objects.
|
||||
|
||||
Tornado
|
||||
--------
|
||||
@@ -107,12 +120,26 @@ Pyramid
|
||||
|
||||
`Pyramid <https://trypyramid.com/>`_ is a very flexible framework with a heavy
|
||||
focus on modularity. It comes with a small number of libraries ("batteries")
|
||||
built-in, and encourages users to extend its base functionality.
|
||||
built-in, and encourages users to extend its base functionality. A set of
|
||||
provided cookiecutter templates helps making new project decisions for users.
|
||||
It poweres one of the most important parts of python infrastucture
|
||||
`PyPI <https://pypi.org/>`_.
|
||||
|
||||
Pyramid does not have a large user base, unlike Django and Flask. It's a
|
||||
capable framework, but not a very popular choice for new Python web
|
||||
applications today.
|
||||
|
||||
Masonite
|
||||
--------
|
||||
|
||||
`Masonite <https://docs.masoniteproject.com>`_ is a modern and developer centric, "batteries included", web framework.
|
||||
|
||||
The Masonite framework follows the MVC (Model-View-Controller) architecture pattern and is heavily inspired by frameworks such as Rails and Laravel, so if you are coming to Python from a Ruby or PHP background then you will feel right at home!
|
||||
|
||||
Masonite comes with a lot of functionality out of the box including a powerful IOC container with auto resolving dependency injection, craft command line tools and the Orator active record style ORM.
|
||||
|
||||
Masonite is perfect for beginners or experienced developers alike and works hard to be fast and easy from install through to deployment. Try it once and you’ll fall in love.
|
||||
|
||||
Web Servers
|
||||
:::::::::::
|
||||
|
||||
@@ -142,7 +169,7 @@ servers and provide top performance [3]_.
|
||||
Gunicorn
|
||||
--------
|
||||
|
||||
`Gunicorn <http://gunicorn.org/>`_ (Green Unicorn) is a pure-python WSGI
|
||||
`Gunicorn <https://gunicorn.org/>`_ (Green Unicorn) is a pure-python WSGI
|
||||
server used to serve Python applications. Unlike other Python web servers,
|
||||
it has a thoughtful user-interface, and is extremely easy to use and
|
||||
configure.
|
||||
@@ -210,14 +237,14 @@ details.
|
||||
Heroku
|
||||
------
|
||||
|
||||
`Heroku <http://www.heroku.com/python>`_ offers first-class support for
|
||||
`Heroku <https://www.heroku.com/python>`_ offers first-class support for
|
||||
Python 2.7–3.5 applications.
|
||||
|
||||
Heroku supports all types of Python web applications, servers, and frameworks.
|
||||
Applications can be developed on Heroku for free. Once your application is
|
||||
ready for production, you can upgrade to a Hobby or Professional application.
|
||||
|
||||
Heroku maintains `detailed articles <https://devcenter.heroku.com/categories/python>`_
|
||||
Heroku maintains `detailed articles <https://devcenter.heroku.com/categories/python-support>`_
|
||||
on using Python with Heroku, as well as `step-by-step instructions
|
||||
<https://devcenter.heroku.com/articles/getting-started-with-python>`_ on
|
||||
how to set up your first application.
|
||||
@@ -227,7 +254,7 @@ Heroku is the recommended PaaS for deploying Python web applications today.
|
||||
Eldarion
|
||||
--------
|
||||
|
||||
`Eldarion <http://eldarion.cloud/>`_ (formely known as Gondor) is a PaaS powered
|
||||
`Eldarion <https://eldarion.cloud/>`_ (formely known as Gondor) is a PaaS powered
|
||||
by Kubernetes, CoreOS, and Docker. They support any WSGI application and have a
|
||||
guide on deploying `Django projects <https://eldarion-gondor.github.io/docs/how-to/setup-deploy-first-django-project/>`_.
|
||||
|
||||
@@ -390,12 +417,12 @@ Chameleon
|
||||
---------
|
||||
|
||||
`Chameleon <https://chameleon.readthedocs.io/>`_ Page Templates are an HTML/XML template
|
||||
engine implementation of the `Template Attribute Language (TAL) <http://en.wikipedia.org/wiki/Template_Attribute_Language>`_,
|
||||
engine implementation of the `Template Attribute Language (TAL) <https://en.wikipedia.org/wiki/Template_Attribute_Language>`_,
|
||||
`TAL Expression Syntax (TALES) <https://chameleon.readthedocs.io/en/latest/reference.html#expressions-tales>`_,
|
||||
and `Macro Expansion TAL (Metal) <https://chameleon.readthedocs.io/en/latest/reference.html#macros-metal>`_ syntaxes.
|
||||
|
||||
Chameleon is available for Python 2.5 and up (including 3.x and pypy), and
|
||||
is commonly used by the `Pyramid Framework <http://trypyramid.com>`_.
|
||||
is commonly used by the `Pyramid Framework <https://trypyramid.com/>`_.
|
||||
|
||||
Page Templates add within your document structure special element attributes
|
||||
and text markup. Using a set of simple language constructs, you control the
|
||||
@@ -492,5 +519,5 @@ Mako is well respected within the Python web community.
|
||||
.. rubric:: References
|
||||
|
||||
.. [1] `The mod_python project is now officially dead <http://blog.dscpl.com.au/2010/06/modpython-project-is-now-officially.html>`_
|
||||
.. [2] `mod_wsgi vs mod_python <http://www.modpython.org/pipermail/mod_python/2007-July/024080.html>`_
|
||||
.. [2] `mod_wsgi vs mod_python <http://modpython.org/pipermail/mod_python/2007-July/024080.html>`_
|
||||
.. [3] `Benchmark of Python WSGI Servers <http://nichol.as/benchmark-of-python-web-servers>`_
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
XML parsing
|
||||
===========
|
||||
|
||||
.. image:: https://farm3.staticflickr.com/2808/33888714601_a1f7d020a2_k_d.jpg
|
||||
.. image:: /_static/photos/33888714601_a1f7d020a2_k_d.jpg
|
||||
|
||||
untangle
|
||||
--------
|
||||
|
||||
@@ -4,27 +4,27 @@
|
||||
Freezing Your Code
|
||||
==================
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4227/33907151034_e0a9e53402_k_d.jpg
|
||||
.. image:: /_static/photos/33907151034_e0a9e53402_k_d.jpg
|
||||
|
||||
"Freezing" your code is creating a single-file executable file to distribute
|
||||
to end-users, that contains all of your application code as well as the
|
||||
"Freezing" your code is creating a single-file executable file to distribute
|
||||
to end-users, that contains all of your application code as well as the
|
||||
Python interpreter.
|
||||
|
||||
Applications such as 'Dropbox', 'Eve Online', 'Civilization IV', and
|
||||
BitTorrent clients do this.
|
||||
|
||||
The advantage of distributing this way is that your application will "just work",
|
||||
even if the user doesn't already have the required version of Python (or any)
|
||||
even if the user doesn't already have the required version of Python (or any)
|
||||
installed. On Windows, and even on many Linux distributions and OS X, the right
|
||||
version of Python will not already be installed.
|
||||
|
||||
Besides, end-user software should always be in an executable format. Files
|
||||
ending in ``.py`` are for software engineers and system administrators.
|
||||
Besides, end-user software should always be in an executable format. Files
|
||||
ending in ``.py`` are for software engineers and system administrators.
|
||||
|
||||
One disadvantage of freezing is that it will increase the size of your
|
||||
One disadvantage of freezing is that it will increase the size of your
|
||||
distribution by about 2–12MB. Also, you will be responsible for shipping
|
||||
updated versions of your application when security vulnerabilities to
|
||||
Python are patched.
|
||||
updated versions of your application when security vulnerabilities to
|
||||
Python are patched.
|
||||
|
||||
Alternatives to Freezing
|
||||
------------------------
|
||||
@@ -75,34 +75,34 @@ Prerequisite is to install :ref:`Python, Setuptools and pywin32 dependency on Wi
|
||||
1. Install :code:`bbfreeze`:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
|
||||
$ pip install bbfreeze
|
||||
|
||||
|
||||
2. Write most basic :file:`bb_setup.py`
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from bbfreeze import Freezer
|
||||
|
||||
|
||||
freezer = Freezer(distdir='dist')
|
||||
freezer.addScript('foobar.py', gui_only=True)
|
||||
freezer()
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
|
||||
This will work for the most basic one file scripts. For more advanced freezing you will have to provide
|
||||
include and exclude paths like so
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
||||
freezer = Freezer(distdir='dist', includes=['my_code'], excludes=['docs'])
|
||||
|
||||
3. (Optionally) include icon
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
||||
freezer.setIcon('my_awesome_icon.ico')
|
||||
|
||||
|
||||
4. Provide the Microsoft Visual C runtime DLL for the freezer. It might be possible to append your :code:`sys.path`
|
||||
with Microsoft Visual Studio path but I find it easier to drop :file:`msvcp90.dll` in the same folder where your script
|
||||
resides.
|
||||
@@ -110,13 +110,13 @@ resides.
|
||||
5. Freeze!
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
|
||||
$ python bb_setup.py
|
||||
|
||||
py2exe
|
||||
~~~~~~
|
||||
|
||||
Prerequisite is to install :ref:`Python on Windows <install-windows>`.
|
||||
Prerequisite is to install :ref:`Python on Windows <install-windows>`. The last release of py2exe is from the year 2014. There is not active development.
|
||||
|
||||
1. Download and install http://sourceforge.net/projects/py2exe/files/py2exe/
|
||||
|
||||
@@ -204,7 +204,7 @@ To create a standalone windowed OS X application, use the :code:`--windowed` opt
|
||||
|
||||
This creates a :code:`script.app` in the :code:`dist` folder. Make sure to use GUI packages in your Python code, like `PyQt <https://riverbankcomputing.com/software/pyqt/intro>`_ or `PySide <http://wiki.qt.io/About-PySide>`_, to control the graphical parts of the app.
|
||||
|
||||
There are several options in :code:`script.spec` related to Mac OS X app bundles `here <http://pythonhosted.org/PyInstaller/spec-files.html#spec-file-options-for-a-mac-os-x-bundle>`_. For example, to specify an icon for the app, use the :code:`icon=\path\to\icon.icns` option.
|
||||
There are several options in :code:`script.spec` related to Mac OS X app bundles `here <http://pythonhosted.org/PyInstaller/spec-files.html#spec-file-options-for-a-mac-os-x-bundle>`_. For example, to specify an icon for the app, use the :code:`icon=\path\to\icon.icns` option.
|
||||
|
||||
|
||||
Linux
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
Packaging Your Code
|
||||
===================
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4325/36137234682_be6898bf57_k_d.jpg
|
||||
.. image:: /_static/photos/36137234682_be6898bf57_k_d.jpg
|
||||
|
||||
Package your code to share it with other developers. For example
|
||||
to share a library for other developers to use in their application,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Installing Python 2 on Linux
|
||||
=============================
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4268/34435688560_4cc2a7bcbb_k_d.jpg
|
||||
.. image:: /_static/photos/34435688560_4cc2a7bcbb_k_d.jpg
|
||||
|
||||
.. note::
|
||||
Check out our :ref:`guide for installing Python 3 on Linux<install3-linux>`.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Installing Python 2 on Mac OS X
|
||||
===============================
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4268/34435688560_4cc2a7bcbb_k_d.jpg
|
||||
.. image:: /_static/photos/34435688560_4cc2a7bcbb_k_d.jpg
|
||||
|
||||
.. note::
|
||||
Check out our :ref:`guide for installing Python 3 on OS X<install3-osx>`.
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
Installing Python 2 on Windows
|
||||
==============================
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4268/34435688560_4cc2a7bcbb_k_d.jpg
|
||||
.. image:: /_static/photos/34435688560_4cc2a7bcbb_k_d.jpg
|
||||
|
||||
.. note::
|
||||
Check out our :ref:`guide for installing Python 3 on Windows<install3-windows>`.
|
||||
|
||||
First, download the `latest version <https://www.python.org/ftp/python/2.7.14/python-2.7.14.msi>`_
|
||||
First, download the `latest version <https://www.python.org/ftp/python/2.7.15/python-2.7.15.msi>`_
|
||||
of Python 2.7 from the official website. If you want to be sure you are installing a fully
|
||||
up-to-date version, click the Downloads > Windows link from the home page of the
|
||||
`Python.org web site <http://python.org>`_ .
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Installing Python 3 on Linux
|
||||
============================
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4276/34435689480_2e6f358510_k_d.jpg
|
||||
.. image:: /_static/photos/34435689480_2e6f358510_k_d.jpg
|
||||
|
||||
This document describes how to install Python 3.6 on Ubuntu Linux machines.
|
||||
|
||||
@@ -93,7 +93,7 @@ care about that.
|
||||
Pipenv & Virtual Environments
|
||||
-----------------------------
|
||||
|
||||
The next step is to install Pipenv, so you can install dependencies and manage virtual environments.
|
||||
The next step is to install Pipenv, so you can install dependencies and manage virtual environments.
|
||||
|
||||
A Virtual Environment is a tool to keep the dependencies required by different projects
|
||||
in separate places, by creating virtual Python environments for them. It solves the
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
Installing Python 3 on Mac OS X
|
||||
===============================
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4276/34435689480_2e6f358510_k_d.jpg
|
||||
.. image:: /_static/photos/34435689480_2e6f358510_k_d.jpg
|
||||
|
||||
The latest version of Mac OS X, High Sierra, **comes with Python 2.7 out of the box**.
|
||||
|
||||
@@ -112,13 +112,13 @@ The rest of the guide will assume that ``python`` references Python 3.
|
||||
|
||||
# Do I have a Python 3 installed?
|
||||
$ python --version
|
||||
Python 3.6.4 # Success!
|
||||
# If you still see 2.7 ensure in PATH /usr/local/bin/ takes precedence over /usr/bin/
|
||||
Python 3.7.1 # Success!
|
||||
|
||||
|
||||
Pipenv & Virtual Environments
|
||||
-----------------------------
|
||||
|
||||
The next step is to install Pipenv, so you can install dependencies and manage virtual environments.
|
||||
The next step is to install Pipenv, so you can install dependencies and manage virtual environments.
|
||||
|
||||
A Virtual Environment is a tool to keep the dependencies required by different projects
|
||||
in separate places, by creating virtual Python environments for them. It solves the
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Installing Python 3 on Windows
|
||||
==============================
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4276/34435689480_2e6f358510_k_d.jpg
|
||||
.. image:: /_static/photos/34435689480_2e6f358510_k_d.jpg
|
||||
|
||||
First, follow the installation instructions for `Chocolatey <https://chocolatey.org/install>`_.
|
||||
It's a community system packager manager for Windows 7+. (It's very much like Homebrew on OSX.)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Properly Installing Python
|
||||
==========================
|
||||
|
||||
.. image:: https://farm5.staticflickr.com/4303/36137232412_fdcb0f84eb_k_d.jpg
|
||||
.. image:: /_static/photos/36137232412_fdcb0f84eb_k_d.jpg
|
||||
|
||||
There's a good chance that you already have Python on your operating system.
|
||||
|
||||
@@ -16,8 +16,8 @@ other third-party Python libraries.
|
||||
|
||||
.. note:: The use of **Python 3** is *highly* preferred over Python 2. Consider upgrading your applications and infrastructure if you find yourself *still* using Python 2 in production today. If you are using Python 3, congratulations — you are indeed a person of excellent taste.
|
||||
—*Kenneth Reitz*
|
||||
|
||||
|
||||
|
||||
|
||||
Installation Guides
|
||||
-------------------
|
||||
|
||||
|
||||