Python (programming language) - Wikipedia, the free encyclopedia. Python. Paradigmmulti- paradigm: object- oriented, imperative, functional, procedural, reflective. Designed by. Guido van Rossum. Developer. Python Software Foundation. First appeared. 20 February 1. It features a dynamic type system and automatic memory management and has a large and comprehensive standard library. Using third- party tools, such as Py. Pyinstaller. CPython is managed by the non- profit Python Software Foundation. History. I decided to write an interpreter for the new scripting language I had been thinking about lately: a descendant of ABC that would appeal to Unix/Chackers. I chose Python as a working title for the project, being in a slightly irreverent mood (and a big fan of Monty Python's Flying Circus). Python 2. 0 was released on 1. October 2. 00. 0 and had many major new features, including a cycle- detecting garbage collector and support for Unicode. With this release the development process was changed and became more transparent and community- backed. Many of its major features have been backported to the backwards- compatible Python 2. An important feature of Python is dynamic name resolution (late binding), which binds method and variable names during program execution. The design of Python offers some support for functional programming in the Lisp tradition. The language has map(), reduce() and filter() functions; list comprehensions, dictionaries, and sets; and generator expressions. Python can also be embedded in existing applications that need a programmable interface. This design of a small core language with a large standard library and an easily extensible interpreter was intended by Van Rossum from the start because of his frustrations with ABC, which espoused the opposite mindset. As Alex Martelli put it: . Cython is also available, which translates a Python script into C and makes direct C- level API calls into the Python interpreter. An important goal of Python's developers is making it fun to use. This is reflected in the origin of the name, which comes from Monty Python. To say that code is pythonic is to say that it uses Python idioms well, that it is natural or shows fluency in the language, that it conforms with Python's minimalist philosophy and emphasis on readability. In contrast, code that is difficult to understand or reads like a rough transcription from another programming language is called unpythonic. Users and admirers of Python, especially those considered knowledgeable or experienced, are often referred to as Pythonists, Pythonistas, and Pythoneers. It is designed to have an uncluttered visual layout, often using English keywords where other languages use punctuation. Further, Python has fewer syntactic exceptions and special cases than C or Pascal. An increase in indentation comes after certain statements; a decrease in indentation signifies the end of the current block. This operates differently than in traditional imperative programming languages, and this fundamental mechanism (including the nature of Python's version of variables) illuminates many other features of the language. Assignment in C, e. The (right- hand) value is copied into an allocated storage location for which the (left- hand) variable name is the symbolic address. The memory allocated to the variable is large enough (potentially quite large) for the declared type. In the simplest case of Python assignment, using the same example, x = 2, translates to . Since the name's storage location doesn't contain the indicated value, it is improper to call it a variable. Names may be subsequently rebound at any time to objects of greatly varying types, including strings, procedures, complex objects with data and methods, etc. Successive assignments of a common value to multiple names, e. Since a name is a generic reference holder it is unreasonable to associate a fixed data type with it. However at a given time a name will be bound to some object, which will have a type; thus there is dynamic typing. The if statement, which conditionally executes a block of code, along with else and elif (a contraction of else- if). The for statement, which iterates over an iterable object, capturing each element to a local variable for use by the attached block. The while statement, which executes a block of code as long as its condition is true. The try statement, which allows exceptions raised in its attached code block to be caught and handled by except clauses; it also ensures that clean- up code in a finally block will always be run regardless of how the block exits. The class statement, which executes a block of code and attaches its local namespace to a class, for use in object- oriented programming. The def statement, which defines a function or method. The with statement (from Python 2. Resource Acquisition Is Initialization (RAII)- like behavior. You Used Python to Write WHAT. The frameworks for these languages tend to have more sophisticated development tools and the resulting programs are often easier. Games & Entertainment. Scripts & Programs. Scripts from Hot Scripts. Review before you use or buy a script! Let Hot Scripts uncover the best free, open source. Python is a language and an interpreter that executes other programs. Get a quick look at program execution, how to launch code and how Python runs it. Program Arcade Games With Python And Pygame. Appendix A: Example code and programs. A.1: Text examples; A.2: Graphics examples; A.3: Sprite. Financial Accounting Tutorial. Python provides interfaces to all major commercial. Python 3D Software Collection. The Python Computer Graphics Kit is a collection of. I agree with you fully that python is no longer a prototyping language. There are many good applications in PyS60 which can be commercial. But the main thing that. The dark side of the beloved Python. The pass statement, which serves as a NOP. It is syntactically needed to create an empty code block. The assert statement, used during debugging to check for conditions that ought to apply. The yield statement, which returns a value from a generator function. From Python 2. 5, yield is also an operator. This form is used to implement coroutines. The import statement, which is used to import modules whose functions or variables can be used in the current program. The print statement was changed to the print() function in Python 3. As of Python 2. 5, it is possible to pass information back into a generator function, and as of Python 3. Python also added the ** operator for exponentiation. As of Python 3. 5, it supports matrix multiplication directly with the @ operator, versus C and Java, which implement these as library functions. Earlier versions of Python also used methods instead of an infix operator. In Python, comparisons may be chained, for example a < = b < = c. Python uses the words and, or, not for its boolean operators rather than the symbolic & & , ! Python 2. 4 extended list comprehensions into a more general expression termed a generator expression.? Lists are written as . Tuples are written as (1, 2, 3), are immutable and thus can be used as the keys of dictionaries, provided all elements of the tuple are immutable. The parentheses around the tuple are optional in some contexts. Tuples can appear on the left side of an equal sign; hence a statement like x, y = y, x can be used to swap two variables. Python has a . This functions analogous to printf format strings in C, e. In Python 3 and 2. Unlike in Unix shells, Perl and Perl- influenced languages, single quote marks and double quote marks function identically. Both kinds of string use the backslash (\) as an escape character and there is no implicit string interpolation such as . They may span multiple lines and function like here documents in shells, Perl and Ruby. Raw string varieties, denoted by prefixing the string literal with an r. No escape sequences are interpreted; hence raw strings are useful where literal backslashes are common, such as regular expressions and Windows- style paths. Indexes are zero- based, and negative indexes are relative to the end. Slices take elements from the start index up to, but not including, the stop index. The third slice parameter, called step or stride, allows elements to be skipped and reversed. Slice indexes may be omitted, for example a. Each element of a slice is a shallow copy. In Python, a distinction between expressions and statements is rigidly enforced, in contrast to languages such as Common Lisp, Scheme, or Ruby. This leads to duplicating some functionality. For example: List comprehensions vs. A particular case of this is that an assignment statement such as a = 1 cannot form part of the conditional expression of a conditional statement. This has the advantage of avoiding a classic C error of mistaking an assignment operator = for an equality operator == in conditions: if (c = 1) . Python methods have an explicit self parameter to access instance data, in contrast to the implicit self (or this) in some other object- oriented programming languages (e. C++, Java, Objective- C, or Ruby). Type constraints are not checked at compile time; rather, operations on an object may fail, signifying that the given object is not of a suitable type. Despite being dynamically typed, Python is strongly typed, forbidding operations that are not well- defined (for example, adding a number to a string) rather than silently attempting to make sense of them. Python allows programmers to define their own types using classes, which are most often used for object- oriented programming. New instances of classes are constructed by calling the class (for example, Spam. Class() or Eggs. Class()), and the classes are instances of the metaclasstype (itself an instance of itself), allowing metaprogramming and reflection. Before version 3. Python had two kinds of classes: old- style and new- style. In versions between 2. The syntax of both styles is the same, the difference being whether the class object is inherited from, directly or indirectly (all new- style classes inherit from object and are instances of type). Summary of Python 3's built- in types. Type. Mutable. Description. Syntax examplestr. Immutable. A character string: sequence of Unicode codepoints'Wikipedia'. It also has ** for exponentiation, e. The / operator is integer division if both operands are integers, and floating- point division otherwise. Integer division rounds towards 0, e. Python 2. 2 changes integer division to round towards negative infinity, e. The floor division // operator is introduced. So 7 // 3 == 2, - 7 // 3 == - 3, 7. In Python terms, the pre- 3. Rounding towards negative infinity, though different from most languages, adds consistency. For instance, it means that the equation (a+b) // b == a // b + 1 is always true. It also means that the equation b * (a // b) + a % b == a is valid for both positive and negative values of a.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2017
Categories |