Skip to content

Commit 1f3b781

Browse files
committed
some updates
1 parent a9453ee commit 1f3b781

File tree

8 files changed

+112
-54
lines changed

8 files changed

+112
-54
lines changed

source/docs/boilerplate/bin.rst

+64-19
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,71 @@
1-
====
2-
real
3-
====
1+
Shebang (Unix)
2+
From Wikipedia, the free encyclopedia
3+
It has been suggested that this article be merged with Interpreter directive. (Discuss) Proposed since June 2014.
4+
A "shebang" character sequence
45

5-
Description
6-
-----------
7-
Retrieves the real component of this number.
6+
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.
7+
8+
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:
9+
10+
#!/bin/sh
11+
12+
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.
13+
14+
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]
15+
16+
Contents
17+
18+
1 Syntax
19+
2 Examples
20+
3 Purpose
21+
3.1 Strengths
22+
4 Portability
23+
4.1 Magic number
24+
4.2 Security issues
25+
5 Etymology
26+
6 History
27+
7 Notes
28+
8 See also
29+
9 References
30+
10 External links
831

932
Syntax
10-
------
11-
**complex**. *real*
1233

13-
Return Value
14-
------------
15-
**float**
34+
The form of a shebang interpreter directive is as follows:[8]
35+
36+
#! interpreter [optional-arg]
37+
38+
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).
39+
Examples
40+
41+
Some typical shebang lines:
42+
43+
#!/bin/sh — Execute the file using sh, the Bourne shell, or a compatible shell
44+
#!/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
45+
#!/usr/bin/perl -T — Execute using Perl with the option for taint checks
46+
47+
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.
48+
Purpose
49+
50+
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.
51+
52+
Consider a Bourne shell script that is identified by the path "some/path/to/foo" and that has the following as its initial line:
53+
54+
#!/bin/sh -x
55+
56+
If the user attempts to run this script with the following command line (specifying "bar" and "baz" as arguments):
57+
58+
some/path/to/foo bar baz
59+
60+
then the result would be similar to having actually executed the following command line instead:
61+
62+
/bin/sh -x some/path/to/foo bar baz
63+
64+
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.
1665

17-
Example
18-
-------
19-
>>> (1+3j).real
20-
1.0
66+
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:
2167

22-
See Also
23-
--------
24-
`imag`_
68+
#!/bin/cat
69+
Hello world!
2570

26-
.. _imag: ../complex/imag.html
71+
Strengt

source/docs/boilerplate/localbin.rst

+1-26
Original file line numberDiff line numberDiff line change
@@ -1,26 +1 @@
1-
====
2-
real
3-
====
4-
5-
Description
6-
-----------
7-
Retrieves the real component of this number.
8-
9-
Syntax
10-
------
11-
**complex**. *real*
12-
13-
Return Value
14-
------------
15-
**float**
16-
17-
Example
18-
-------
19-
>>> (1+3j).real
20-
1.0
21-
22-
See Also
23-
--------
24-
`imag`_
25-
26-
.. _imag: ../complex/imag.html
1+
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-

source/docs/list/index.rst

+9
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ Information
7373
Returns the index of the first occurrence of the specified list item.
7474
`count`_
7575
Returns the number of times the specified item appears in the list.
76+
77+
Modifying
78+
----
79+
`sort`_
80+
Sorts the list in place.
81+
`reverse`_
82+
Reverses the elements of the list, in place.
7683

7784
.. _[] (index operator): ../brackets/indexing.html
7885
.. _[::] (slicing): ../brackets/slicing.html
@@ -86,6 +93,8 @@ Information
8693
.. _remove: remove.html
8794
.. _index: lindex.html
8895
.. _count: count.html
96+
.. _reverse: reverse.html
97+
.. _sort: sort.html
8998
.. _enumerate: ../functions/enumerate.html
9099
.. _len: ../functions/len.html
91100
.. _reversed: ../functions/reversed.html

source/docs/list/sort.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Example 1
3838

3939
Example 2
4040
=========
41-
# This example shows how to use cmp argument
41+
>>> # this example shows how to use cmp argument
4242
>>> l = ['a', 'B', 'A', 'c']
4343
>>> l.sort()
4444
>>> l
@@ -72,4 +72,4 @@ See Also
7272
========
7373
`sorted()`_ function
7474

75-
75+
.. _sorted: ../functions/sorted.html

source/docs/str/format.rst

+19-5
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,20 @@ Example 6
195195

196196
Example 7
197197
---------
198+
>>> # this example shows how to format numbers to specified precision
199+
>>> "PI: {:.2f}".format(3.141592653589793)
200+
'PI: 3.14'
201+
>>> "PI: {:.2e}".format(3.141592653589793)
202+
'PI: 3.14e+00'
203+
>>> "PI: {:.2g}".format(3.141592653589793)
204+
'PI: 3.1'
205+
>>> "PI: {:.2n}".format(3.141592653589793)
206+
'PI: 3.1'
207+
>>> "PI: {:.2%}".format(3.141592653589793)
208+
'PI: 314.16%'
209+
210+
Example 8
211+
---------
198212
>>> # replacing %+f, %-f, and % f and specifying a sign:
199213
>>> '{:+f}; {:+f}'.format(3.14, -3.14) # show it always
200214
'+3.140000; -3.140000'
@@ -203,7 +217,7 @@ Example 7
203217
>>> '{:-f}; {:-f}'.format(3.14, -3.14) # show only the minus -- same as '{:f}; {:f}'
204218
'3.140000; -3.140000'
205219

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

216-
Example 9
230+
Example 10
217231
---------
218232
>>> # using the comma as a thousands separator:
219233
>>> '{:,}'.format(1234567890)
220234
'1,234,567,890'
221235

222-
Example 10
236+
Example 11
223237
----------
224238
>>> # expressing a percentage:
225239
>>> points = 19.5
226240
>>> total = 22
227241
>>> 'Correct answers: {:.2%}'.format(points/total)
228242
'Correct answers: 88.64%'
229243

230-
Example 11
244+
Example 12
231245
----------
232246
>>> # using type-specific formatting:
233247
>>> import datetime
234248
>>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)
235249
>>> '{:%Y-%m-%d %H:%M:%S}'.format(d)
236250
'2010-07-04 12:15:58'
237251

238-
Example 12
252+
Example 13
239253
----------
240254
>>> # nesting arguments and more complex examples
241255
>>> for align, text in zip('<^>', ['left', 'center', 'right']):

source/docs/str/index.rst

+12
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ Functions
5656
Returns an enumerate object.
5757
`zip`_
5858
Returns a list of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables.
59+
`chr`_
60+
Returns a string of one character whose ASCII code is the specified number.
61+
`ord`_
62+
Returns an integer representing the code of the character.
63+
`unichr`_
64+
Returns a Unicode character specified by the code.
65+
`format`_
66+
Returns a formatted string.
5967

6068
Methods
6169
====
@@ -220,3 +228,7 @@ Encodings
220228
.. _any: ../functions/any.html
221229
.. _+ (concatenation): ../operators/concatenation.html
222230
.. _* (multiple concatenation): ../operators/multiple_concatenation.html
231+
.. _chr: ../functions/chr.html
232+
.. _ord: ../functions/ord.html
233+
.. _unichr: ../functions/unichr.html
234+
.. _format: ../functions/format.html

source/index.rst

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Contents
99

1010
intro
1111
definitions
12+
guidelines
1213
basic_data_types
1314
docs/functions/index
1415
docs/comprehensions/index
@@ -20,6 +21,8 @@ Contents
2021
exceptions
2122
constants
2223
docs/boilerplate/index
24+
psl
25+
resources
2326
licence
2427

2528
Indices and tables

source/other_types.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ Others
3737
.. _function: docs/function/index.html
3838
.. _generator: docs/generator/index.html
3939
.. _code: docs/code/index.html
40-
.. _classmethod: docs/staticmethod/index.html
41-
.. _staticmethod: docs/classmethod/index.html
40+
.. _classmethod: docs/classmethod/index.html
41+
.. _staticmethod: docs/staticmethod/index.html
4242
.. _property: docs/property/index.html

0 commit comments

Comments
 (0)