Skip to content

Commit

Permalink
some updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jprzywoski committed Jun 17, 2015
1 parent a9453ee commit 1f3b781
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 54 deletions.
83 changes: 64 additions & 19 deletions source/docs/boilerplate/bin.rst
Original file line number Diff line number Diff line change
@@ -1,26 +1,71 @@
====
real
====
Shebang (Unix)
From Wikipedia, the free encyclopedia
It has been suggested that this article be merged with Interpreter directive. (Discuss) Proposed since June 2014.
A "shebang" character sequence

Description
-----------
Retrieves the real component of this number.
In computing, a shebang (also called a sha-bang,[1][2][3] hashbang,[4][5] pound-bang,[2][6] or hash-pling[2][7]), is the character sequence consisting of the characters number sign and exclamation mark (that is, "#!") at the beginning of a script.

Under Unix-like operating systems, when a script with a shebang is run as a program, the program loader parses the rest of the script's initial line as an interpreter directive; the specified interpreter program is run instead, passing to it as an argument the path that was initially used when attempting to run the script.[8] For example, if a script is named with the path "path/to/script", and it starts with the following line:

#!/bin/sh

then the program loader is instructed to run the program "/bin/sh" instead (usually this is the Bourne shell or a compatible shell), passing "path/to/script" as the first argument.

The shebang line is usually ignored by the interpreter because the "#" character is a comment marker in many scripting languages; some language interpreters that do not use the hash mark to begin comments (such as Scheme) still may ignore the shebang line in recognition of its purpose.[9]

Contents

1 Syntax
2 Examples
3 Purpose
3.1 Strengths
4 Portability
4.1 Magic number
4.2 Security issues
5 Etymology
6 History
7 Notes
8 See also
9 References
10 External links

Syntax
------
**complex**. *real*

Return Value
------------
**float**
The form of a shebang interpreter directive is as follows:[8]

#! interpreter [optional-arg]

The interpreter must be an absolute path to an executable[1] program (if this interpreter program is a script, it must contain a shebang as well). The optional‑arg should either not be included or it should be a string that is meant to be a single argument (for reasons of portability, it should not contain any whitespace).
Examples

Some typical shebang lines:

#!/bin/sh — Execute the file using sh, the Bourne shell, or a compatible shell
#!/bin/csh -f — Execute the file using csh, the C shell, or a compatible shell, and suppress the execution of the user’s .cshrc file on startup
#!/usr/bin/perl -T — Execute using Perl with the option for taint checks

Shebang lines may include specific options that are passed to the interpreter (see the Perl example above). However, implementations vary in the parsing behavior of options; for portability, only one option should be specified (if any) without any embedded whitespace. Further portability guidelines are found below.
Purpose

Interpreter directives allow scripts and data files to be used as system commands, hiding the details of their implementation from users and other programs, by removing the need to prefix scripts with their interpreter on the command line.

Consider a Bourne shell script that is identified by the path "some/path/to/foo" and that has the following as its initial line:

#!/bin/sh -x

If the user attempts to run this script with the following command line (specifying "bar" and "baz" as arguments):

some/path/to/foo bar baz

then the result would be similar to having actually executed the following command line instead:

/bin/sh -x some/path/to/foo bar baz

If "/bin/sh" specifies the Bourne shell, then the end result is that all of the shell commands in the file "some/path/to/foo" are executed with the positional variables $1 and $2 set to "bar" and "baz", respectively. Also, because the initial number sign is the character used to introduce comments in the Bourne shell language (and in the languages understood by many other interpreters), the entire shebang line is ignored by the interpreter.

Example
-------
>>> (1+3j).real
1.0
However, it is up to the interpreter to ignore the shebang line; thus, a script consisting of the following two lines simply echos both lines to standard output when run:

See Also
--------
`imag`_
#!/bin/cat
Hello world!

.. _imag: ../complex/imag.html
Strengt
27 changes: 1 addition & 26 deletions source/docs/boilerplate/localbin.rst
Original file line number Diff line number Diff line change
@@ -1,26 +1 @@
====
real
====

Description
-----------
Retrieves the real component of this number.

Syntax
------
**complex**. *real*

Return Value
------------
**float**

Example
-------
>>> (1+3j).real
1.0

See Also
--------
`imag`_

.. _imag: ../complex/imag.html
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-
9 changes: 9 additions & 0 deletions source/docs/list/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ Information
Returns the index of the first occurrence of the specified list item.
`count`_
Returns the number of times the specified item appears in the list.

Modifying
----
`sort`_
Sorts the list in place.
`reverse`_
Reverses the elements of the list, in place.

.. _[] (index operator): ../brackets/indexing.html
.. _[::] (slicing): ../brackets/slicing.html
Expand All @@ -86,6 +93,8 @@ Information
.. _remove: remove.html
.. _index: lindex.html
.. _count: count.html
.. _reverse: reverse.html
.. _sort: sort.html
.. _enumerate: ../functions/enumerate.html
.. _len: ../functions/len.html
.. _reversed: ../functions/reversed.html
Expand Down
4 changes: 2 additions & 2 deletions source/docs/list/sort.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Example 1

Example 2
=========
# This example shows how to use cmp argument
>>> # this example shows how to use cmp argument
>>> l = ['a', 'B', 'A', 'c']
>>> l.sort()
>>> l
Expand Down Expand Up @@ -72,4 +72,4 @@ See Also
========
`sorted()`_ function


.. _sorted: ../functions/sorted.html
24 changes: 19 additions & 5 deletions source/docs/str/format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,20 @@ Example 6

Example 7
---------
>>> # this example shows how to format numbers to specified precision
>>> "PI: {:.2f}".format(3.141592653589793)
'PI: 3.14'
>>> "PI: {:.2e}".format(3.141592653589793)
'PI: 3.14e+00'
>>> "PI: {:.2g}".format(3.141592653589793)
'PI: 3.1'
>>> "PI: {:.2n}".format(3.141592653589793)
'PI: 3.1'
>>> "PI: {:.2%}".format(3.141592653589793)
'PI: 314.16%'

Example 8
---------
>>> # replacing %+f, %-f, and % f and specifying a sign:
>>> '{:+f}; {:+f}'.format(3.14, -3.14) # show it always
'+3.140000; -3.140000'
Expand All @@ -203,7 +217,7 @@ Example 7
>>> '{:-f}; {:-f}'.format(3.14, -3.14) # show only the minus -- same as '{:f}; {:f}'
'3.140000; -3.140000'

Example 8
Example 9
---------
>>> # replacing %x and %o and converting the value to different bases:
>>> # format also supports binary numbers
Expand All @@ -213,29 +227,29 @@ Example 8
>>> "int: {0:d}; hex: {0:#x}; oct: {0:#o}; bin: {0:#b}".format(42)
'int: 42; hex: 0x2a; oct: 0o52; bin: 0b101010'

Example 9
Example 10
---------
>>> # using the comma as a thousands separator:
>>> '{:,}'.format(1234567890)
'1,234,567,890'

Example 10
Example 11
----------
>>> # expressing a percentage:
>>> points = 19.5
>>> total = 22
>>> 'Correct answers: {:.2%}'.format(points/total)
'Correct answers: 88.64%'

Example 11
Example 12
----------
>>> # using type-specific formatting:
>>> import datetime
>>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)
>>> '{:%Y-%m-%d %H:%M:%S}'.format(d)
'2010-07-04 12:15:58'

Example 12
Example 13
----------
>>> # nesting arguments and more complex examples
>>> for align, text in zip('<^>', ['left', 'center', 'right']):
Expand Down
12 changes: 12 additions & 0 deletions source/docs/str/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ Functions
Returns an enumerate object.
`zip`_
Returns a list of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables.
`chr`_
Returns a string of one character whose ASCII code is the specified number.
`ord`_
Returns an integer representing the code of the character.
`unichr`_
Returns a Unicode character specified by the code.
`format`_
Returns a formatted string.

Methods
====
Expand Down Expand Up @@ -220,3 +228,7 @@ Encodings
.. _any: ../functions/any.html
.. _+ (concatenation): ../operators/concatenation.html
.. _* (multiple concatenation): ../operators/multiple_concatenation.html
.. _chr: ../functions/chr.html
.. _ord: ../functions/ord.html
.. _unichr: ../functions/unichr.html
.. _format: ../functions/format.html
3 changes: 3 additions & 0 deletions source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Contents

intro
definitions
guidelines
basic_data_types
docs/functions/index
docs/comprehensions/index
Expand All @@ -20,6 +21,8 @@ Contents
exceptions
constants
docs/boilerplate/index
psl
resources
licence

Indices and tables
Expand Down
4 changes: 2 additions & 2 deletions source/other_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ Others
.. _function: docs/function/index.html
.. _generator: docs/generator/index.html
.. _code: docs/code/index.html
.. _classmethod: docs/staticmethod/index.html
.. _staticmethod: docs/classmethod/index.html
.. _classmethod: docs/classmethod/index.html
.. _staticmethod: docs/staticmethod/index.html
.. _property: docs/property/index.html

0 comments on commit 1f3b781

Please sign in to comment.