text
stringlengths 0
7.06k
|
---|
Python provides a round function for rounding a float to the nearest integer . For tie @-@ breaking , versions before 3 use round @-@ away @-@ from @-@ zero : round ( 0 @.@ 5 ) is 1 @.@ 0 , round ( <unk> ) is β 1 @.@ 0 . Python 3 uses round to even : round ( 1 @.@ 5 ) is 2 , round ( 2 @.@ 5 ) is 2 .
|
Python allows boolean expressions with multiple equality relations in a manner that is consistent with general use in mathematics . For example , the expression a < b < c tests whether a is less than b and b is less than c . C @-@ derived languages interpret this expression differently : in C , the expression would first evaluate a < b , resulting in 0 or 1 , and that result would then be compared with c .
|
Python has extensive built @-@ in support for arbitrary precision arithmetic . Integers are transparently switched from the machine @-@ supported maximum fixed @-@ precision ( usually 32 or 64 bits ) , belonging to the python type int , to arbitrary precision , belonging to the python type long , where needed . The latter have an " L " suffix in their textual representation . The Decimal type / class in module decimal ( since version 2 @.@ 4 ) provides decimal floating point numbers to arbitrary precision and several rounding modes . The Fraction type in module fractions ( since version 2 @.@ 6 ) provides arbitrary precision for rational numbers .
|
Due to Python 's extensive mathematics library , it is frequently used as a scientific scripting language to aid in problems such as numerical data processing and manipulation .
|
= = Libraries = =
|
Python has a large standard library , commonly cited as one of Python 's greatest strengths , providing tools suited to many tasks . This is deliberate and has been described as a " batteries included " Python philosophy . For Internet @-@ facing applications , many standard formats and protocols ( such as MIME and HTTP ) are supported . Modules for creating graphical user interfaces , connecting to relational databases , pseudorandom number generators , arithmetic with arbitrary precision decimals , manipulating regular expressions , and doing unit testing are also included .
|
Some parts of the standard library are covered by specifications ( for example , the Web Server Gateway Interface ( <unk> ) implementation <unk> follows PEP 333 ) , but most modules are not . They are specified by their code , internal documentation , and test suite ( if supplied ) . However , because most of the standard library is cross @-@ platform Python code , only a few modules need altering or rewriting for variant implementations .
|
The standard library is not needed to run Python or embed it in an application . For example , Blender 2 @.@ 49 omits most of the standard library .
|
As of January 2016 , the Python Package Index , the official repository of third @-@ party software for Python , contains more than 72 @,@ 000 packages offering a wide range of functionality , including :
|
graphical user interfaces , web frameworks , multimedia , databases , networking and communications
|
test frameworks , automation and web scraping , documentation tools , system administration
|
scientific computing , text processing , image processing
|
= = Development environments = =
|
Most Python implementations ( including CPython ) can function as a command line interpreter , for which the user enters statements sequentially and receives the results immediately ( read β eval β print loop ( <unk> ) ) . In short , Python acts as a command @-@ line interface or shell .
|
Other shells add abilities beyond those in the basic interpreter , including <unk> and <unk> . While generally following the visual style of the Python shell , they implement features like auto @-@ completion , session state retention , and syntax highlighting .
|
In addition to standard desktop integrated development environments ( Python <unk> ) , there are also web browser @-@ based <unk> , Sage ( intended for developing science and math @-@ related Python programs ) , and a browser @-@ based <unk> and hosting environment , <unk> .
|
= = Implementations = =
|
The main Python implementation , named CPython , is written in C meeting the <unk> standard . It compiles Python programs into intermediate bytecode , which is executed by the virtual machine . CPython is distributed with a large standard library written in a mixture of C and Python . It is available in versions for many platforms , including Windows and most modern Unix @-@ like systems . CPython was intended from almost its very conception to be cross @-@ platform .
|
PyPy is a fast , compliant interpreter of Python 2 @.@ 7 and 3 @.@ 2 . Its just @-@ in @-@ time compiler brings a significant speed improvement over CPython . A version taking advantage of multi @-@ core processors using software transactional memory is being created .
|
<unk> Python is a significant fork of CPython that implements <unk> ; it does not use the C memory stack , thus allowing massively concurrent programs . PyPy also has a <unk> version .
|
<unk> is a lean , fast Python 3 variant that is optimised to run on <unk> .
|
Other just @-@ in @-@ time compilers have been developed in the past , but are now unsupported :
|
Google began a project named <unk> Swallow in 2009 with the aims of speeding up the Python interpreter by 5 times , by using the <unk> , and of improving its multithreading ability to scale to thousands of cores .
|
<unk> is a just @-@ in @-@ time specialising compiler that integrates with CPython and transforms bytecode to machine code at runtime . The emitted code is specialised for certain data types and is faster than standard Python code .
|
In 2005 , Nokia released a Python interpreter for the Series 60 mobile phones named <unk> . It includes many of the modules from the CPython implementations and some added modules to integrate with the Symbian operating system . This project has been kept up to date to run on all variants of the S60 platform and there are several third party modules available . The Nokia <unk> also supports Python with GTK widget libraries , with the feature that programs can be both written and run on the target device .
|
There are several compilers to high @-@ level object languages , with either unrestricted Python , a restricted subset of Python , or a language similar to Python as the source language :
|
<unk> compiles into Java byte code , which can then be executed by every Java virtual machine implementation . This also enables the use of Java class library functions from the Python program .
|
<unk> follows a similar approach in order to run Python programs on the .NET Common Language Runtime .
|
The <unk> language can be compiled to C , Java bytecode , or Common Intermediate Language , and is used to build the PyPy interpreter of Python .
|
Pyjamas compiles Python to JavaScript .
|
Shed Skin compiles Python to C + + .
|
<unk> and Pyrex compile to C.
|
A performance comparison of various Python implementations on a non @-@ numerical ( combinatorial ) workload was presented at <unk> ' 13 .
|
= = Development = =
|
Python 's development is conducted largely through the Python Enhancement Proposal ( PEP ) process . The PEP process is the primary mechanism for proposing major new features , for collecting community input on an issue , and for documenting the design decisions that have gone into Python . Outstanding <unk> are reviewed and commented upon by the Python community and by Van Rossum , the Python project 's benevolent dictator for life .
|
Enhancement of the language goes along with development of the CPython reference implementation . The mailing list python @-@ dev is the primary forum for discussion about the language 's development ; specific issues are discussed in the Roundup bug tracker maintained at <unk> Development takes place on a self @-@ hosted source code repository running Mercurial .
|
CPython 's public releases come in three types , distinguished by which part of the version number is incremented :
|
Backwards @-@ incompatible versions , where code is expected to break and must be manually ported . The first part of the version number is incremented . These releases happen infrequently β for example , version 3 @.@ 0 was released 8 years after 2 @.@ 0 .
|
Major or " feature " releases , which are largely compatible but introduce new features . The second part of the version number is incremented . These releases are scheduled to occur roughly every 18 months , and each major version is supported by bugfixes for several years after its release .
|
<unk> releases , which introduce no new features but fix bugs . The third and final part of the version number is incremented . These releases are made whenever a sufficient number of bugs have been fixed upstream since the last release , or roughly every 3 months . Security vulnerabilities are also patched in <unk> releases .
|
Many alpha , beta , and release @-@ candidates are also released as previews , and for testing before final releases . Although there is a rough schedule for each release , this is often pushed back if the code is not ready . The development team monitors the state of the code by running the large unit test suite during development , and using the <unk> continuous integration system .
|
The community of Python developers has also contributed over 72 @,@ 000 software modules ( as of January 2016 ) to the Python Package Index ( <unk> ) , the official repository of third @-@ party libraries for Python .
|
The major academic conference on Python is named <unk> . There are special mentoring programmes like the <unk> .
|
= = Naming = =
|
Python 's name is derived from the television series Monty Python 's Flying Circus , and it is common to use Monty Python references in example code . For example , the <unk> variables often used in Python literature are spam and eggs , instead of the traditional foo and bar . Also , the official Python documentation often contains various obscure Monty Python references .
|
The prefix <unk> is used to show that something is related to Python . Examples of the use of this prefix in names of Python applications or libraries include <unk> , a binding of SDL to Python ( commonly used to create games ) ; <unk> , an implementation for the Symbian S60 operating system ; <unk> and <unk> , which bind <unk> and GTK , respectively , to Python ; and PyPy , a Python implementation originally written in Python .
|
= = Uses = =
|
Since 2003 , Python has consistently ranked in the top ten most popular programming languages as measured by the TIOBE Programming Community Index . As of June 2016 , it is the fourth most popular language . It was ranked as Programming Language of the Year for the year 2007 and 2010 . It is the third most popular language whose grammatical syntax is not predominantly based on C , e.g. C + + , Objective @-@ C ( note , C # and Java only have partial syntactic similarity to C , such as the use of curly braces , and are closer in similarity to each other than C ) .
|
An empirical study found scripting languages ( such as Python ) more productive than conventional languages ( such as C and Java ) for a programming problem involving string manipulation and search in a dictionary . Memory consumption was often " better than Java and not much worse than C or C + + " .
|
Large organizations that make use of Python include Google , Yahoo ! , CERN , NASA , and some smaller ones like ILM , and ITA . The social news networking site , Reddit , is written entirely in Python .
|
Python can serve as a scripting language for web applications , e.g. , via mod _ <unk> for the Apache web server . With Web Server Gateway Interface , a standard API has evolved to facilitate these applications . Web frameworks like Django , Pylons , Pyramid , <unk> , <unk> , Tornado , Flask , Bottle and <unk> support developers in the design and maintenance of complex applications . Pyjamas and <unk> can be used to develop the client @-@ side of Ajax @-@ based applications . <unk> can be used as data mapper to a relational database . Twisted is a framework to program communications between computers , and is used ( for example ) by Dropbox .
|
Libraries like <unk> , <unk> and <unk> allow the effective use of Python in scientific computing , with specialized libraries such as <unk> and <unk> providing domain @-@ specific functionality . Sage is a mathematical software with a " notebook " programmable in Python : its library covers many aspects of mathematics , including algebra , combinatorics , numerical mathematics , number theory , and calculus .
|
Python has been successfully embedded in many software products as a scripting language , including in finite element method software such as <unk> , 3D parametric modeler like <unk> , 3D animation packages such as 3ds Max , Blender , Cinema 4D , Lightwave , Houdini , Maya , modo , <unk> , Softimage , the visual effects compositor Nuke , 2D imaging programs like <unk> , <unk> , <unk> and Paint Shop Pro , and musical notation program or <unk> capella . GNU Debugger uses Python as a pretty printer to show complex structures such as C + + containers . <unk> promotes Python as the best choice for writing scripts in <unk> . It has also been used in several video games , and has been adopted as first of the three available programming languages in Google App Engine , the other two being Java and Go .
|
Python has been used in artificial intelligence tasks . As a scripting language with module architecture , simple syntax and rich text processing tools , Python is often used for natural language processing tasks .
|
Many operating systems include Python as a standard component ; the language ships with most Linux distributions , AmigaOS 4 , FreeBSD , NetBSD , OpenBSD and OS X , and can be used from the terminal . Many Linux distributions use installers written in Python : Ubuntu uses the <unk> installer , while Red Hat Linux and Fedora use the Anaconda installer . Gentoo Linux uses Python in its package management system , Portage .
|
Python has also seen extensive use in the information security industry , including in exploit development .
|
Most of the Sugar software for the One Laptop per Child XO , now developed at Sugar Labs , is written in Python .
|
The Raspberry Pi single @-@ board computer project has adopted Python as its main user @-@ programming language .
|
<unk> includes Python and intends to replace Java with Python . Python Scripting Provider is a core feature since Version 4 @.@ 0 from 7 February 2013 .
|
= = Languages influenced by Python = =
|
Python 's design and philosophy have influenced several programming languages , including :
|
Boo uses indentation , a similar syntax , and a similar object model . However , Boo uses static typing ( and optional duck typing ) and is closely integrated with the .NET Framework .
|
Cobra uses indentation and a similar syntax . Cobra 's " Acknowledgements " document lists Python first among languages that influenced it . However , Cobra directly supports design @-@ by @-@ contract , unit tests , and optional static typing .
|
<unk> borrowed <unk> , generators , and list comprehensions from Python .
|
Go is described as incorporating the " development speed of working in a dynamic language like Python " .
|
Groovy was motivated by the desire to bring the Python design philosophy to Java .
|
Julia was designed " with true macros [ .. and to be ] as usable for general programming as Python [ and ] should be as fast as C " . Calling to or from Julia is possible ; to with <unk> and a Python package <unk> allows calling , in the other direction , from Python .
|
OCaml has an optional syntax , named <unk> ( The <unk> Thing ) , inspired by Python and Haskell .
|
Ruby 's creator , Yukihiro Matsumoto , has said : " I wanted a scripting language that was more powerful than Perl , and more object @-@ oriented than Python . That 's why I decided to design my own language . "
|
<unk> is a programming language that cross @-@ compiles to JavaScript ; it has Python @-@ inspired syntax .
|
Swift is a programming language invented by Apple ; it has some Python @-@ inspired syntax .
|
Python 's development practices have also been emulated by other languages . The practice of requiring a document describing the rationale for , and issues surrounding , a change to the language ( in Python 's case , a PEP ) is also used in Tcl and <unk> because of Python 's influence .
|
Python has been awarded a TIOBE Programming Language of the Year award twice ( in 2007 and 2010 ) , which is given to the language with the greatest growth in popularity over the course of a year , as measured by the TIOBE index .
|
= Lisa the Vegetarian =
|
" Lisa the Vegetarian " is the fifth episode of the seventh season of the American television series The Simpsons . It originally aired on the Fox network in the United States on October 15 , 1995 . In the episode , Lisa decides to stop eating meat after bonding with a lamb at a petting zoo . Her schoolmates and family members ridicule her for her beliefs , but with the help of Apu , Paul , and Linda McCartney , she commits to vegetarianism .
|
Directed by Mark Kirkland , " Lisa the Vegetarian " is the first full @-@ length episode David S. Cohen wrote for The Simpsons . David Mirkin , the show runner at the time , supported the episode in part because he had just become a vegetarian himself . Former Beatle Paul McCartney and his then wife Linda McCartney guest star in the episode . Paul McCartney 's condition for appearing was that Lisa would remain a vegetarian for the rest of the series . The episode makes several references to McCartney 's musical career , and his song " Maybe I 'm Amazed " plays during the closing credits .
|
The inaugural airing of " Lisa the Vegetarian " was watched by 14 @.@ 6 million viewers and finished 47th in the ratings for the week of October 9 β 15 , 1995 , with a 9 @.@ 0 Nielsen rating . It was the fourth highest @-@ rated show on the Fox network that week . The episode received generally positive reviews from television critics . It has won two awards , an Environmental Media Award and a Genesis Award , for highlighting environmental and animal issues .
|
= = Plot = =
|
The Simpson family visit Story Town Village , an amusement park for babies , as a special treat for Maggie . In the village , there is a petting zoo , where Lisa is enamored by a cute lamb . That night , Marge serves lamb chops for dinner , but Lisa is troubled by the connection between the dish and its living counterpart , and announces that she will no longer eat meat . In response , Bart and Homer mock her relentlessly . Reaction at school is no better ; when Lisa requests a vegetarian alternative to the cafeteria food , Principal Skinner labels her an " agitator " . The students are then forced to watch a Meat Council propaganda film , " The Meat Council Presents Meat and You : Partners in Patriotism " , starring Troy McClure , which portrays eating meat as a patriotic duty , and criticizes vegetarianism . Lisa is unimpressed by the film , but her classmates tease her .
|
Homer and Bart continue to give Lisa a hard time at home , particularly since Homer is preparing to host a barbecue , complete with roast pig . Bart and Homer even form a conga line and sing , " You don 't win friends with salad ! " On the day of the barbecue , Lisa makes gazpacho for all the guests as an alternative to meat , but the partygoers laugh in her face . Enraged and deeply hurt , she climbs aboard a riding mower and drives away with the roast pig in tow . Homer and Bart chase her , but she pushes the pig off a slope and they are too late . The pig rolls through bushes , into a river , and is shot into the air by a dam spillway 's suction .
|
At home , Homer reprimands Lisa for ruining his party and demands an apology , but Lisa refuses to apologize and chews him out for serving a meat @-@ based dish . They fight and she leaves the house , not wanting to live in a house with a " prehistoric carnivore . " As Lisa walks along , she decides that she can no longer fight the pressure to eat meat , prompting her to grab a hot dog from the grill at the Kwik @-@ E @-@ Mart and take a bite . However , Apu , himself a vegan , reveals that she has eaten a tofu dog , which he subtly switched out and none of his loyal customers had noticed the change .
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.