Class Scope::Scope

A Scope. A scope is the lexical extent over which all identifiers with the same name refer to the same variable. Modules, Classes and Functions are all Scopes. There are no other scopes. The scopes for expressions that create new scopes, lambdas and comprehensions, are handled by creating an anonymous Function.

Direct supertypes

Indirect supertypes

Known direct subtypes

Predicates

contains
containsInScope

Whether this contains inner syntactically and inner has the same scope as this

getANormalExit

Gets an exit from this Scope’s control flow graph, that does not result from an exception

getAStmt

Gets a top-level statement in this scope

getAnExitNode

Gets an exit from this Scope’s control flow graph

getBody

Gets the statements forming the body of this scope

getDocString

Gets the docstring for this scope

getEnclosingModule
getEnclosingScope

Gets the scope enclosing this scope (modules have no enclosing scope)

getEntryNode

Gets the entry point into this Scope’s control flow graph

getEvaluatingScope

Gets the evaluation scope for code in this (lexical) scope. This is usually the scope itself, but may be an enclosing scope. Notably, for list comprehensions in Python 2.

getFallthroughNode

Gets the non-explicit exit from this Scope’s control flow graph

getLastStatement
getLocation
getName

Gets the name of this scope

getReturnNode

Gets the exit of this scope following from a return statement

getScope

This method will be deprecated in the next release. Please use getEnclosingScope() instead. The reason for this is to avoid confusion around use of x.getScope+() where x might be an AstNode or a Variable. Forcing the users to write x.getScope().getEnclosingScope*() ensures that the apparent semantics and the actual semantics coincide. [ Gets the scope enclosing this scope (modules have no enclosing scope) ]

getStmt

Gets the nth statement of this scope

inSource

Holds if this scope is in the source archive, that is it is part of the code specified, not library code

isPublic

Holds if this scope is deemed to be public

isTopLevel

Holds if this a top-level (non-nested) class or function

precedes

Holds if this scope can be expected to execute before other. Modules precede functions and methods in those modules __init__ precedes other methods. __enter__ precedes __exit__. NOTE that this is context-insensitive, so a module “precedes” a function in that module, even if that function is called from the module scope.

Inherited predicates