Python

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
m (Sample files)
 
(45 intermediate revisions by 7 users not shown)
Line 1: Line 1:
Python is a [[Programming Languages|programming language]]. It has a number of file endings associated with it, including .py, .pyc, .pyo, and .pyd
+
{{FormatInfo
 +
|formattype=Languages
 +
|subcat=Programming Languages
 +
|extensions={{ext|py}}, {{ext|pyc}}, {{ext|pyo}}, {{ext|pyd}}, {{ext|whl}}
 +
|pronom={{PRONOM|fmt/938}}, {{PRONOM|fmt/939}}, {{PRONOM|fmt/1118}}, others
 +
|kaitai struct=python_pyc_27
 +
|released=1991
 +
}}
 +
'''Python''' is a [[Programming Languages|programming language]].  
 +
 
 +
It is one of the possibilities for the P in LAMP (a set of technologies used in many web back-ends, including Linux, Apache, and MySQL, notable for being free, open-source software in contrast to proprietary technologies such as those from Microsoft) along with [[Perl]] and [[PHP]].
 +
 
 +
Media reports of [http://www.cbc.ca/news/canada/story/2013/08/06/f-exotic-animals-laws-canada.html python-linked deaths] have nothing to do with the safety of this language, honest! Actually, the name of the language was inspired by [[Wikipedia:Monty Python|Monty Python]], not any actual reptile (or even [http://www.youtube.com/watch?v=R4yBv4sSKTw fictional ones]).
 +
 
 +
A notable feature of Python is its use of whitespace as a syntactically-significant part of its structure; the level of indenting of code blocks actually determines its place structurally, in contrast to most other languages which use explicit items such as curly braces or keywords such as [[Pascal]]'s '''begin''' and '''end''' (though in those languages it is still customary to indent code blocks for readability). Other novel features of Python include native support of complex arithmetic (involving both real and imaginary numbers and sums of them).
 +
 
 +
The easy learnability of the language is enhanced by the fact that it has a command-line interpreter which lets you type commands from a prompt in immediate mode, much like the old-time [[BASIC]] interpreters on which so many people first learned to program back in the days of the Apple II and Commodore 64. However, any program of significant length is likely to be created in a text editor and saved in files.
 +
 
 +
Python is often affiliated with [[reStructuredText]] documents.  Python comments are often formatted with reStructuredText markup.
 +
 
 +
Versions 2 and 3 of Python (with various sub-versions of each) are both in wide use, with version 2 still usually being the default version included in Linux/Unix distributions, but version 3 gaining popularity; there are a number of minor syntax differences between the two.
 +
 
 +
O'Reilly's technical books are famous for having animals on their covers. Their book, ''Programming Python'', has a snake on the cover, logically enough. However, other Python-related books from this publisher have different animals, and, in particular, the introductory book ''Learning Python'' has a rodent. Pythons ''eat'' rodents, so is this trying to imply that the Python community will eat newbies whole?
 +
 
 +
== File extensions ==
 +
 
 +
Python has a number of file endings associated with it, including .py, .pyc, .pyo, and .pyd. When people have desired a MIME type for Python code, they run into the fact that no standard has been established, and even the nonstandard types don't seem to have reached any degree of consistency; people have tried ''text/python'', ''text/python3'', ''application/python'', ''text/x-python'', and others.
  
 
;.py
 
;.py
Line 8: Line 34:
 
:  Optimized compiled [[bytecode]]
 
:  Optimized compiled [[bytecode]]
 
;.pyd
 
;.pyd
:  A python version of a Windows [[.dll]] file
+
:  A python version of a Windows [[Dynamic-link library (Windows)|.dll]] file
 +
;.whl
 +
: A python wheel which is a package distribution for using a "[[ZIP|ZIP-formated]] archive  with a specially formatted filename" <ref>Wheel, Python Package Index https://pypi.python.org/pypi/wheel</ref>
  
 +
== Identifiers ==
 +
{| class="wikitable"
 +
! Format !! Version !! Ext. !! PRONOM
 +
|-
 +
|Python Script File  ||    || .py  || {{PRONOM|fmt/938}}
 +
|-
 +
|rowspan="15"|Python Compiled File || 2.0 ||rowspan="15"| .pyc || {{PRONOM|fmt/1106}}
 +
|-
 +
|2.1 || {{PRONOM|fmt/1107}}
 +
|-
 +
|2.2 || {{PRONOM|fmt/1108}}
 +
|-
 +
|2.3 || {{PRONOM|fmt/1109}}
 +
|-
 +
|2.4 || {{PRONOM|fmt/1110}}
 +
|-
 +
|2.5 || {{PRONOM|fmt/1111}}
 +
|-
 +
|2.6 || {{PRONOM|fmt/1112}}
 +
|-
 +
|2.7 || {{PRONOM|fmt/939}}
 +
|-
 +
|3.0 || {{PRONOM|fmt/1113}}
 +
|-
 +
|3.1 || {{PRONOM|fmt/1114}}
 +
|-
 +
|3.2 || {{PRONOM|fmt/1115}}
 +
|-
 +
|3.3 || {{PRONOM|fmt/1116}}
 +
|-
 +
|3.4 || {{PRONOM|fmt/940}}
 +
|-
 +
|3.5 || {{PRONOM|fmt/1117}}
 +
|-
 +
|3.6 || {{PRONOM|fmt/1118}}
 +
|}
  
Python is often affiliated with [[reStructuredText]] documents. Python comments are often formatted with reStructuredText markup.
+
== See also ==
 +
* [[Pickle]]
 +
* [[Cython (Pyrex)]]
 +
 
 +
== Sample files ==
 +
* {{DexvertSamples|document/pythonCompiled}}
 +
* {{DexvertSamples|text/pythonSource}}
 +
 
 +
== Links ==
 +
 
 +
=== References ===
 +
<references/>
 +
 
 +
=== Specifications and file format info ===
 +
* [http://daeken.com/2010-02-20_Python_Marshal_Format.html Python Marshal Format (bytecode)]
 +
 
 +
=== Programming tips and tutorials ===
 +
* [http://docs.python.org/2/tutorial/index.html Python 2 tutorial]
 +
* [http://docs.python.org/3/tutorial/index.html Python 3 tutorial]
 +
* [http://www.python.org/dev/peps/pep-0008/ PEP 8: Style guide for Python code]
 +
* [http://hubsec.eu/blog/introduction-to-python.html Python for Investigative Journalists: An introduction]
 +
* [http://www.greenteapress.com/thinkpython/thinkpython.html Think Python (free online book)]
 +
 
 +
=== Program code, libraries, and APIs ===
 +
* [https://pypi.python.org/pypi/internetarchive Python interface to archive.org]
 +
* [https://github.com/LindseyB/starwars-dot-gif Python script to generate GIFs from Star Wars based on input dialogue line]
 +
* [http://www.pkcarlisle.com/blog.html#tth Python script to create 'Tweet this' link that doesn't require JavaScript]
 +
* [http://www.brython.info/ Brython: Python implemented in JavaScript]
 +
 
 +
=== Online utilities ===
 +
* [http://pypyjs.org/ In-browser Python interpreter]
 +
 
 +
=== Metaformat files ===
 +
* [https://www.synalysis.net/Grammars/pyc.grammar Synalysis grammar file for Python bytecode] (for Hexinator / Synalize It!; [[Synalysis grammar file|more details]])
 +
 
 +
=== Commentary ===
 +
* [http://blogs.computerworlduk.com/simon-says/2013/02/responding-to-pythons-batsignal/index.htm Python trademark filer ignorant of Python?]
 +
* [http://www.linuxjournal.com/article/3882 Why Python?]
 +
* [http://www.developerdrive.com/2014/11/should-you-be-using-python-for-web-development/ Should you be using Python for web development?]
 +
* [https://www.hackerfactor.com/blog/index.php?/archives/825-8-Reasons-Python-Sucks.html 8 reasons Python sucks]
 +
 
 +
=== Other links and references ===
 +
* [http://www.python.org/ Official website]
 +
* [[Wikipedia:Python (programming_language)|Python (Wikipedia)]]
 +
* [http://www.quora.com/Why-does-the-lifetime-of-a-variable-defined-in-a-loop-last-after-the-loop-in-Python/ Why does the lifetime of a variable defined in a loop last after the loop in Python?]
 +
* [http://cacm.acm.org/blogs/blog-cacm/176450-python-is-now-the-most-popular-introductory-teaching-language-at-top-us-universities/fulltext Python is now the most popular introductory teaching language at top U.S. universities]

Latest revision as of 15:35, 30 July 2024

File Format
Name Python
Ontology
Extension(s) .py, .pyc, .pyo, .pyd, .whl
PRONOM fmt/938, fmt/939, fmt/1118, others
Kaitai Struct Spec python_pyc_27.ksy
Released 1991

Python is a programming language.

It is one of the possibilities for the P in LAMP (a set of technologies used in many web back-ends, including Linux, Apache, and MySQL, notable for being free, open-source software in contrast to proprietary technologies such as those from Microsoft) along with Perl and PHP.

Media reports of python-linked deaths have nothing to do with the safety of this language, honest! Actually, the name of the language was inspired by Monty Python, not any actual reptile (or even fictional ones).

A notable feature of Python is its use of whitespace as a syntactically-significant part of its structure; the level of indenting of code blocks actually determines its place structurally, in contrast to most other languages which use explicit items such as curly braces or keywords such as Pascal's begin and end (though in those languages it is still customary to indent code blocks for readability). Other novel features of Python include native support of complex arithmetic (involving both real and imaginary numbers and sums of them).

The easy learnability of the language is enhanced by the fact that it has a command-line interpreter which lets you type commands from a prompt in immediate mode, much like the old-time BASIC interpreters on which so many people first learned to program back in the days of the Apple II and Commodore 64. However, any program of significant length is likely to be created in a text editor and saved in files.

Python is often affiliated with reStructuredText documents. Python comments are often formatted with reStructuredText markup.

Versions 2 and 3 of Python (with various sub-versions of each) are both in wide use, with version 2 still usually being the default version included in Linux/Unix distributions, but version 3 gaining popularity; there are a number of minor syntax differences between the two.

O'Reilly's technical books are famous for having animals on their covers. Their book, Programming Python, has a snake on the cover, logically enough. However, other Python-related books from this publisher have different animals, and, in particular, the introductory book Learning Python has a rodent. Pythons eat rodents, so is this trying to imply that the Python community will eat newbies whole?

Contents

[edit] File extensions

Python has a number of file endings associated with it, including .py, .pyc, .pyo, and .pyd. When people have desired a MIME type for Python code, they run into the fact that no standard has been established, and even the nonstandard types don't seem to have reached any degree of consistency; people have tried text/python, text/python3, application/python, text/x-python, and others.

.py
A text file that contains python source code. It is often utf-8 encoded, but it does not have to be.
.pyc
Compiled bytecode of a python source file
.pyo
Optimized compiled bytecode
.pyd
A python version of a Windows .dll file
.whl
A python wheel which is a package distribution for using a "ZIP-formated archive with a specially formatted filename" [1]

[edit] Identifiers

Format Version Ext. PRONOM
Python Script File .py fmt/938
Python Compiled File 2.0 .pyc fmt/1106
2.1 fmt/1107
2.2 fmt/1108
2.3 fmt/1109
2.4 fmt/1110
2.5 fmt/1111
2.6 fmt/1112
2.7 fmt/939
3.0 fmt/1113
3.1 fmt/1114
3.2 fmt/1115
3.3 fmt/1116
3.4 fmt/940
3.5 fmt/1117
3.6 fmt/1118

[edit] See also

[edit] Sample files

[edit] Links

[edit] References

  1. Wheel, Python Package Index https://pypi.python.org/pypi/wheel

[edit] Specifications and file format info

[edit] Programming tips and tutorials

[edit] Program code, libraries, and APIs

[edit] Online utilities

[edit] Metaformat files

[edit] Commentary

[edit] Other links and references

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox