None
). Other uses ofexpression statements are allowed and occasionally useful. The syntax for anexpression statement is:None
, it is converted to a stringusing the built-in repr()
function and the resulting string is written tostandard output on a line by itself (except if the result is None
, so thatprocedure calls do not cause any output.)global
or nonlocal
statement in the current code block: the name is bound to the object in thecurrent local namespace.nonlocal
, respectively.TypeError
is raised. That object is thenasked to assign the assigned object to the given attribute; if it cannotperform the assignment, it raises an exception (usually but not necessarilyAttributeError
).a.x
can accesseither an instance attribute or (if no instance attribute exists) a classattribute. The left-hand side target a.x
is always set as an instance attribute,creating it if necessary. Thus, the two occurrences of a.x
do notnecessarily refer to the same attribute: if the right-hand side expression refers to aclass attribute, the left-hand side creates a new instance attribute as the target of theassignment:property()
.IndexError
israised (assignment to a subscripted sequence cannot add new items to a list).__setitem__()
method is called withappropriate arguments.a,b=b,a
swaps two variables), overlaps within the collection of assigned-tovariables occur left-to-right, sometimes resulting in confusion. For instance,the following program prints [0,2]
:*target
feature.x+=1
can be rewritten as x=x+1
to achieve a similar, but not exactly equal effect. In the augmentedversion, x
is only evaluated once. Also, when possible, the actual operationis performed in-place, meaning that rather than creating a new object andassigning that to the target, the old object is modified instead.a[i]+=f(x)
firstlooks-up a[i]
, then it evaluates f(x)
and performs the addition, andlastly, it writes the result back to a[i]
.__annotations__
that is a dictionary mapping from variable names (mangled if private) toevaluated annotations. This attribute is writable and is automaticallycreated at the start of class or module body execution, if annotationsare found statically.__setitem__()
or __setattr__()
call.typing
module to provide a standardsyntax for type annotations that can be used in static analysis tools andIDEs.assert
statement¶assertexpression
, is equivalent toassertexpression1,expression2
, is equivalent to__debug__
and AssertionError
refer tothe built-in variables with those names. In the current implementation, thebuilt-in variable __debug__
is True
under normal circumstances,False
when optimization is requested (command line option -O
). The currentcode generator emits no code for an assert statement when optimization isrequested at compile time. Note that it is unnecessary to include the sourcecode for the expression that failed in the error message; it will be displayedas part of the stack trace.__debug__
are illegal. The value for the built-in variableis determined when the interpreter starts.pass
statement¶pass
is a null operation — when it is executed, nothing happens.It is useful as a placeholder when a statement is required syntactically, but nocode needs to be executed, for example:del
statement¶global
statementin the same code block. If the name is unbound, a NameError
exceptionwill be raised.return
statement¶return
may only occur syntactically nested in a function definition,not within a nested class definition.None
is substituted.return
leaves the current function call with the expression list (orNone
) as return value.return
passes control out of a try
statement with afinally
clause, that finally
clause is executed beforereally leaving the function.return
statement indicates that thegenerator is done and will cause StopIteration
to be raised. The returnedvalue (if any) is used as an argument to construct StopIteration
andbecomes the StopIteration.value
attribute.return
statementindicates that the asynchronous generator is done and will causeStopAsyncIteration
to be raised. A non-empty return
statement is a syntax error in an asynchronous generator function.yield
statement¶yield
statement is semantically equivalent to a yieldexpression. The yield statement can be used to omit the parenthesesthat would otherwise be required in the equivalent yield expressionstatement. For example, the yield statementsyield
semantics, refer to theYield expressions section.raise
statement¶raise
re-raises the last exceptionthat was active in the current scope. If no exception is active in the currentscope, a RuntimeError
exception is raised indicating that this is anerror.raise
evaluates the first expression as the exceptionobject. It must be either a subclass or an instance of BaseException
.If it is a class, the exception instance will be obtained when needed byinstantiating the class with no arguments.__traceback__
attribute, which is writable.You can create an exception and set your own traceback in one step using thewith_traceback()
exception method (which returns the same exceptioninstance, with its traceback set to its argument), like so:from
clause is used for exception chaining: if given, the secondexpression must be another exception class or instance, which will then beattached to the raised exception as the __cause__
attribute (which iswritable). If the raised exception is not handled, both exceptions will beprinted:finally
clause: the previous exception is thenattached as the new exception’s __context__
attribute:None
inthe from
clause:None
is now permitted as Y
in raiseXfromY
.__suppress_context__
attribute to suppress automatic display of theexception context.break
statement¶break
may only occur syntactically nested in a for
orwhile
loop, but not nested in a function or class definition withinthat loop.else
clause if the loop has one.for
loop is terminated by break
, the loop controltarget keeps its current value.break
passes control out of a try
statement with afinally
clause, that finally
clause is executed beforereally leaving the loop.continue
statement¶continue
may only occur syntactically nested in a for
orwhile
loop, but not nested in a function or class definition withinthat loop. It continues with the next cycle of the nearest enclosing loop.continue
passes control out of a try
statement with afinally
clause, that finally
clause is executed beforereally starting the next loop cycle.import
statement¶from
clause) is executed in twosteps:import
statement occurs.as
, then the namefollowing as
is bound directly to the imported module.from
form uses a slightly more complex process:from
clause, loading andinitializing it if necessary;import
clauses:ImportError
is raised.as
clause if it is present,otherwise using the attribute name'*'
), all publicnames defined in the module are bound in the local namespace for the scopewhere the import
statement occurs.__all__
; if defined, it must be a sequenceof strings which are names defined or imported by that module. The namesgiven in __all__
are all considered public and are required to exist. If__all__
is not defined, the set of public names includes all names foundin the module’s namespace which do not begin with an underscore character('_'
). __all__
should contain the entire public API. It is intendedto avoid accidentally exporting items that are not part of the API (such aslibrary modules which were imported and used within the module).frommoduleimport*
— is only allowed atthe module level. Attempting to use it in class or function definitions willraise a SyntaxError
.from
you can specify how high totraverse up the current package hierarchy without specifying exact names. Oneleading dot means the current package where the module making the importexists. Two dots means up one package level. Three dots is up two levels, etc.So if you execute from.importmod
from a module in the pkg
packagethen you will end up importing pkg.mod
. If you execute from.subpkg2importmod
from within pkg.subpkg1
you will import pkg.subpkg2.mod
.The specification for relative imports is contained inthe Package Relative Imports section.importlib.import_module()
is provided to support applications thatdetermine dynamically the modules to be loaded.import
with arguments module
, filename
, sys.path
, sys.meta_path
, sys.path_hooks
.annotations
(see PEP 563).absolute_import
, division
,generators
, generator_stop
, unicode_literals
,print_function
, nested_scopes
and with_statement
. They areall redundant because they are always enabled, and only kept forbackwards compatibility.__future__
, described later, and it will be imported inthe usual way at the time the future statement is executed.exec()
and compile()
that occur in a module M
containing a future statement will, by default,use the new syntax or semantics associated with the future statement. This canbe controlled by optional arguments to compile()
— see the documentationof that function for details.-i
option, is passed a script name to execute, and the script includesa future statement, it will be in effect in the interactive session startedafter the script is executed.global
statement¶global
statement is a declaration which holds for the entirecurrent code block. It means that the listed identifiers are to be interpretedas globals. It would be impossible to assign to a global variable withoutglobal
, although free variables may refer to globals without beingdeclared global.global
statement must not be used in the same codeblock textually preceding that global
statement.global
statement must not be defined as formalparameters or in a for
loop control target, class
definition, function definition, import
statement, or variableannotation.global
is a directive to the parser. Itapplies only to code parsed at the same time as the global
statement.In particular, a global
statement contained in a string or codeobject supplied to the built-in exec()
function does not affect the codeblock containing the function call, and code contained in such a string isunaffected by global
statements in the code containing the functioncall. The same applies to the eval()
and compile()
functions.nonlocal
statement¶nonlocal
statement causes the listed identifiers to refer topreviously bound variables in the nearest enclosing scope excluding globals.This is important because the default behavior for binding is to search thelocal namespace first. The statement allows encapsulated code to rebindvariables outside of the local scope besides the global (module) scope.nonlocal
statement, unlike those listed in aglobal
statement, must refer to pre-existing bindings in anenclosing scope (the scope in which a new binding should be created cannotbe determined unambiguously).nonlocal
statement must not collide withpre-existing bindings in the local scope.nonlocal
statement.BBEdit editing its own Wikipedia article | |
Developer(s) | Bare Bones Software |
---|---|
Initial release | April 12, 1992; 28 years ago |
Stable release | |
Written in | C (through Carbon API) |
Operating system | macOS |
Type | Text editor |
License | Proprietary |
Website | www.barebones.com/products/bbedit |
R*ch
refers to Rich Siegel, one of Bare Bones Software's founders and the original author of BBEdit.Developer(s) | Bare Bones Software |
---|---|
Initial release | February 25, 2003; 17 years ago |
Stable release | 5.5.2 / September 20, 2016 |
Operating system | macOS |
Type | Text editor |
License | Proprietary |
Website | www.barebones.com/products/textwrangler/ |
With BBEdit version 5.0, in a move sure to win applause from many long-time users, the HTML tools have been moved into their own Markup menu (the palette is still available as well).
Ironically, Bare Bones has added a visual HTML tool to BBEdit 4.5, known as the BBEdit Table Builder. The Table Builder is a separate application and as the name implies, it is used to construct HTML tables.
Starting with BBEdit 6.0, Table Builder is no longer included in the BBEdit package. After thorough consideration, we decided that in order to expand Table Builder’s capabilities sufficiently to meet the needs of a majority of our customers, it would be necessary to replicate much of the functionality presently provided by existing visual HTML editors.