Sans-serif

Aa

Serif

Aa

Font size

+ -

Line height

+ -
Light
Dark
Sepia

Python Glossary List

With increasing popularity of the Python programming language comes the need for more visual effects artists to become code savvy. Python is a relatively easy to learn programming language, but it can still be tricky to learn for those who have never coded before. I find myself having to refer back to the documentation numerous times while I’m working and there are common terms that I feel are important for everyone to know. In this article, I will be going through some of the most common terms that you need to know if you are just starting out or needed a little refresher.

Important note: This article will not cover the entire Python glossary list just the most commonly used terms. For the full list, visit the Python documentation website. https://docs.python.org/3/glossary.html

Argument:

A value passed to a function when calling the function. There are two kinds of arguments:

·  Keyword argument: an argument preceded by an identifier in a function call or passed as a value in a dictionary preceded by **

·  Positional argument: an argument that is not a keyword argument. Positional argument can appear at the beginning of an argument list and/or be passed as elements of an iterable preceded by *.

Arguments are assigned to the named local variables in a function body.

Attribute:

A value associated with an object which usually referenced by name using dotted expressions. For example, if an object 0 has an attribute a it would be referenced as o.a.

It is possible to give an object an attribute whose name is not an identifier as defined by identifiers and keywords, for example using setattr(), if the object allows it. Such an attribute will not be accessible using a dotted expression, and would instead need to be retrieved with getatttr().

Callback:

A subroutine function which is passed as an argument to be executed at some point in the future.

Dictionary:

An associative array, where arbitrary keys are mapped to values. The keys can be any object with __hash__() and _eq_() methods. Called a hash in Perl.

Expression:

A piece of syntax which can be evaluated to some value. In other words, an expression is an accumulation of expression elements like literals, names, attribute access, operators or function calls which all return a value. In contrast to many other languages, not all language constructs are expressions. There are also statements which cannot be used as expressions, such as while. Assignments are also statements, not expressions.

Function:

A series of statements which returns some value to a caller. It can also be passed zero or more arguments which may be used in the execution of the body.

Generator:

A function which returns a generator iterator. It looks like a normal function except that it contains yield expressions for producing a series of values usable in a for-loop or that can be retrieved one at a time with the next() function.

Usually refers to a generator function, but may refer to a generator iterator, but may refer to a generator iterator in some contexts. In cases where the intended meaning isn’t clear, using the full terms avoids ambiguity.

IDLE:

An integrated Development and Learning Environment for Python. IDLE is a basic editor and interpreter environment which ships with the standard distribution of Python.

Importing:

The process by which Python code in one module is made available to Python code in another module.

Iterator:

An object representing a stream of data. Repeated calls to the iterator’s __next__() method (or passing it to the built-in function next()) return successive items in the stream. When no more data are available a StopIteration exception is raised instead. At this point, the iterator object is exhausted and any further calls to its __next__() method just raise StopIteration again. Iterators are required to have an __iter__() method that returns the iterator object itself so every iterator is also iterable and may be used in most places where other iterables are accepted. One notable exception is code which attempts multiple iteration passes. A container object (such as a list) produces a fresh new iterator each time you pass it to the iter() function or use it in a for loop. Attempting this with an iterator will just return the same exhausted iterator object used in the previous iteration pass, making it appear like an empty container.

Key Function:

A key function or collation function is a callable that returns a value used for sorting or ordering. For example, locale.strxfrm() is used to produce a sort key that is aware of locale specific sort conventions.

A number of tools in Python accept key functions to control how elements are ordered or grouped. They include min(), max(), sorted(), list.sort(), heapq.merge(), heapq.nsmallest(), heapq.nlargest(), and itertools.groupby().

There are several ways to create a key function. For example. the str.lower() method can serve as a key function for case insensitive sorts. Alternatively, a key function can be built from a lambda expression such as lambda r: (r[0], r[2]). Also, the operator module provides three key function constructors: attrgetter(), itemgetter(), and methodcaller(). See the Sorting HOW TO for examples of how to create and use key functions.

Parameter:

A named entity in a function (or method) definition that specifies an argument that the function can accept. There are five kinds of parameters:

·  Positional-or-keyword: specifies an argument that can be passed either positionally or as a keyword argument. This is the default kind of parameter, for example foo and bar in the following:

Def func(foo, bar=None):

·  positional-only: specifies an argument that can be supplied only by position. Positional-only parameters can be defined by including a / character in the parameter list of the function definition after them, for example posonly1 and posonly2 in the following

def func(posonly1, posonly2, /, positional_or_keyword):

·  Keyword-only: Specifies an argument that can be supplied only be a keyword. Keyword-only parameters can be defined by including a single var-positional parameter or bare * in the parameter list of the function definition before them.

Statement:

A statement is part of a suite (a “block” of code). A statement is either an expression or one of several constructs with a keyword, such as if, while, or for.

Type:

The type of a Python object determines what kind of object it is; every object has a type. An obect’s type is accessible as its class attribute or can be retrieved with type(obj).

These are only a few of the total Python glossary list and if you would like to learn more I would recommend checking out the documentation on their website. https://docs.python.org/3/glossary.html