Mercurial > python-for-js-programmers
changeset 16:a53f8b3f8666
Added section on the import statement.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Thu, 05 Jun 2008 20:18:51 -0700 |
parents | 01712d2193d3 |
children | b4d176c2bf39 |
files | PythonForJsProgrammers.txt |
diffstat | 1 files changed, 16 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/PythonForJsProgrammers.txt Thu Jun 05 20:06:30 2008 -0700 +++ b/PythonForJsProgrammers.txt Thu Jun 05 20:18:51 2008 -0700 @@ -129,7 +129,21 @@ more. Extensive documentation for it all is contained in the `Python Library Reference`_. +To use the functionality of a module, you'll use Python's ``import`` +statement, like so: + + >>> import sha + +This particular line imports the `sha`_ module, which provides access +to the SHA-1 message digest algorithm. At this point, ``sha`` is an +object in your namespace and can be used, for instance, to create a +``sha`` object from which to generate a hex digest: + + >>> sha.sha("hello").hexdigest() + 'aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d' + .. _`Python Library Reference`: http://docs.python.org/lib/lib.html +.. _`sha`: http://docs.python.org/lib/module-sha.html Expressions =========== @@ -531,7 +545,8 @@ TODO: Mention TinyPy. -TODO: Mention the import statement, and modules. +TODO: Link to instructions on how to make your own modules, packages, +etc. TODO: Mention generators, generator comprehensions/expressions, array comprehensions, other stuff lifted from Python by JS.