Mercurial > js4py
diff source/know-in-python.rst @ 211:4e6cfa066d1a
Use double backticks for inline code everywhere
| author | Radomir Dopieralski <radomir.dopieralski@allegro.pl> |
|---|---|
| date | Fri, 18 May 2012 16:56:15 +0200 |
| parents | 1ba803131dd9 |
| children |
line wrap: on
line diff
--- a/source/know-in-python.rst Thu May 17 12:50:41 2012 +0200 +++ b/source/know-in-python.rst Fri May 18 16:56:15 2012 +0200 @@ -47,7 +47,8 @@ (when you are at the module scope, it's equal to the *global* scope). You don't need to do anything special to make that happen. -In JavaScript, variables go to the global object by default. You have to use the *var* keyword to have them defined locally. +In JavaScript, variables go to the global object by default. You have to use +the ``var`` keyword to have them defined locally. Functions passed as parameters @@ -56,7 +57,7 @@ Everything is an object in Python. In particular, a function is an object. This means that you can assign a function to a variable or pass it as a function argument. This may be useful when you want to have some generic algorithms. -This is used in the *sort* method so that you can, for example, sort strings in +This is used in the ``sort`` method so that you can, for example, sort strings in case-insensitive way: .. code-block:: python @@ -102,7 +103,7 @@ closure. An example use of a closure is a "private" variable that can be only accessed -by *get* and *set* functions. +by ``get`` and ``set`` functions. .. code-block:: python @@ -122,8 +123,8 @@ return get, set -The *value* variable stays in the memory even after *create_get_set* finishes, -because the *get* and *set* functions still hold a reference to it. Because +The ``value`` variable stays in the memory even after ``create_get_set`` finishes, +because the ``get`` and ``set`` functions still hold a reference to it. Because they are the only objects holding reference to it, the variable is effectively hidden from other code. You could have a similar effect by using an object: @@ -149,8 +150,8 @@ return getset.get, getset.set -Here instead of a closure we have an explicit *getset* object. Again, this -object stays in memory because the bound methods *get* and *set* hold a +Here instead of a closure we have an explicit ``getset`` object. Again, this +object stays in memory because the bound methods ``get`` and ``set`` hold a reference to it. This couldn't be done in JavaScript.
