mirror of
https://github.com/kennethreitz/python-guide.git
synced 2026-06-05 23:00:18 +00:00
Changed python into Python where needed
This commit is contained in:
@@ -129,7 +129,7 @@ Anaconda
|
|||||||
|
|
||||||
`Continuum Analytics <http://continuum.io/>`_ offers the `Anaconda
|
`Continuum Analytics <http://continuum.io/>`_ offers the `Anaconda
|
||||||
Python Distribution <https://store.continuum.io/cshop/anaconda>`_ which
|
Python Distribution <https://store.continuum.io/cshop/anaconda>`_ which
|
||||||
includes all the common scientific python packages and additionally many
|
includes all the common scientific Python packages and additionally many
|
||||||
packages related to data analytics and big data. Anaconda itself is free, and
|
packages related to data analytics and big data. Anaconda itself is free, and
|
||||||
Continuum sells a number of proprietary add-ons. Free
|
Continuum sells a number of proprietary add-ons. Free
|
||||||
licenses for the add-ons are available for academics and researchers.
|
licenses for the add-ons are available for academics and researchers.
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ download and install any compliant Python software product with a single
|
|||||||
command. It also enables you to add this network installation capability to
|
command. It also enables you to add this network installation capability to
|
||||||
your own Python software with very little work.
|
your own Python software with very little work.
|
||||||
|
|
||||||
To obtain the latest version of Setuptools for Windows, run the python script
|
To obtain the latest version of Setuptools for Windows, run the Python script
|
||||||
available here: `ez_setup.py <https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py>`_
|
available here: `ez_setup.py <https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py>`_
|
||||||
|
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ considered by many to be deprecated, so we will install its replacement:
|
|||||||
**pip**. Pip allows for uninstallation of packages, and is actively maintained,
|
**pip**. Pip allows for uninstallation of packages, and is actively maintained,
|
||||||
unlike easy_install.
|
unlike easy_install.
|
||||||
|
|
||||||
To install pip, run the python script available here:
|
To install pip, run the Python script available here:
|
||||||
`get-pip.py <https://raw.github.com/pypa/pip/master/contrib/get-pip.py>`_
|
`get-pip.py <https://raw.github.com/pypa/pip/master/contrib/get-pip.py>`_
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ assuming the user knows anything about the project), the url of the
|
|||||||
main source for the software, and some basic credit information. This
|
main source for the software, and some basic credit information. This
|
||||||
file is the main entry point for readers of the code.
|
file is the main entry point for readers of the code.
|
||||||
|
|
||||||
An :file:`INSTALL` file is less necessary with python. The installation
|
An :file:`INSTALL` file is less necessary with Python. The installation
|
||||||
instructions are often reduced to one command, such as ``pip install
|
instructions are often reduced to one command, such as ``pip install
|
||||||
module`` or ``python setup.py install`` and added to the :file:`README`
|
module`` or ``python setup.py install`` and added to the :file:`README`
|
||||||
file.
|
file.
|
||||||
@@ -56,7 +56,7 @@ of the following components:
|
|||||||
Sphinx
|
Sphinx
|
||||||
~~~~~~
|
~~~~~~
|
||||||
|
|
||||||
Sphinx_ is far and away the most popular python documentation
|
Sphinx_ is far and away the most popular Python documentation
|
||||||
tool. **Use it.** It converts :ref:`restructuredtext-ref` markup language
|
tool. **Use it.** It converts :ref:`restructuredtext-ref` markup language
|
||||||
into a range of output formats including HTML, LaTeX (for printable
|
into a range of output formats including HTML, LaTeX (for printable
|
||||||
PDF versions), manual pages, and plain text.
|
PDF versions), manual pages, and plain text.
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ To help you choose one for your project, there's a `license chooser <http://thre
|
|||||||
|
|
||||||
**More Permissive**
|
**More Permissive**
|
||||||
|
|
||||||
- PSFL (Python Software Foundation License) -- for contributing to python itself
|
- PSFL (Python Software Foundation License) -- for contributing to Python itself
|
||||||
- MIT / BSD / ISC
|
- MIT / BSD / ISC
|
||||||
|
|
||||||
+ MIT (X11)
|
+ MIT (X11)
|
||||||
|
|||||||
@@ -92,12 +92,12 @@ environment, or your project's internal modules.
|
|||||||
To keep in line with the style guide, keep module names short, lowercase, and
|
To keep in line with the style guide, keep module names short, lowercase, and
|
||||||
be sure to avoid using special symbols like the dot (.) or question mark (?).
|
be sure to avoid using special symbols like the dot (.) or question mark (?).
|
||||||
So a file name like :file:`my.spam.py` is one you should avoid! Naming this way
|
So a file name like :file:`my.spam.py` is one you should avoid! Naming this way
|
||||||
will interfere with the way python looks for modules.
|
will interfere with the way Python looks for modules.
|
||||||
|
|
||||||
In the case of `my.spam.py` python expects to find a :file:`spam.py` file in a folder named :file:`my`
|
In the case of `my.spam.py` Python expects to find a :file:`spam.py` file in a folder named :file:`my`
|
||||||
which is not the case. There is an
|
which is not the case. There is an
|
||||||
`example <http://docs.python.org/tutorial/modules.html#packages>`_ of how the
|
`example <http://docs.python.org/tutorial/modules.html#packages>`_ of how the
|
||||||
dot notation should be used in the python docs.
|
dot notation should be used in the Python docs.
|
||||||
|
|
||||||
If you'd like you could name it as :file:`my_spam.py` but even our friend the
|
If you'd like you could name it as :file:`my_spam.py` but even our friend the
|
||||||
underscore should not be seen often in module names.
|
underscore should not be seen often in module names.
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ Take the following code for example:
|
|||||||
def lookup_list(l):
|
def lookup_list(l):
|
||||||
return 's' in l
|
return 's' in l
|
||||||
|
|
||||||
Even though both functions look identical, because *lookup_dict* is utilizing the fact that dictionaries in python are hashtables, the lookup performance between the two is very different.
|
Even though both functions look identical, because *lookup_dict* is utilizing the fact that dictionaries in Python are hashtables, the lookup performance between the two is very different.
|
||||||
Python will have to go through each item in the list to find a matching case, which is time consuming. By analysing the hash of the dictionary, finding keys in the dict can be done very quickly.
|
Python will have to go through each item in the list to find a matching case, which is time consuming. By analysing the hash of the dictionary, finding keys in the dict can be done very quickly.
|
||||||
For more information see this `StackOverflow <http://stackoverflow.com/questions/513882/python-list-vs-dict-for-look-up-table>`_ page.
|
For more information see this `StackOverflow <http://stackoverflow.com/questions/513882/python-list-vs-dict-for-look-up-table>`_ page.
|
||||||
|
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ to newer versions of the module easier in the future
|
|||||||
class MyTest(unittest.TestCase):
|
class MyTest(unittest.TestCase):
|
||||||
...
|
...
|
||||||
|
|
||||||
This way if you ever switch to a newer python version and no longer need the
|
This way if you ever switch to a newer Python version and no longer need the
|
||||||
unittest2 module, you can simply change the import in your test module without
|
unittest2 module, you can simply change the import in your test module without
|
||||||
the need to change any other code.
|
the need to change any other code.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user