Class Module::Module

A module. This is the top level element in an AST, corresponding to a source file. It is also a Scope; the scope of global variables.

Direct supertypes

Indirect supertypes

Known direct subtypes

Predicates

contains

Whether this contains inner syntactically

containsInScope

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

declaredInAll

Whether name is declared in the all list of this module

getAChildNode

Gets a child node of this node in the AST. This predicate exists to aid exploration of the AST and other experiments. The child-parent relation may not be meaningful. For a more meaningful relation in terms of dependency use Expr.getASubExpression(), Stmt.getASubStatement(), Stmt.getASubExpression() or Scope.getAStmt().

getAStmt

Gets a top-level statement in this module

getAnExport

Gets a name exported by this module, that is the names that will be added to a namespace by ‘from this-module import *’

getAnImportedModule

Use ModuleObject.getAnImportedModule() instead. Gets a module imported by this module

getAnImportedModuleName
getBody

Gets the statements forming the body of this module

getEnclosingModule

Gets this module

getEnclosingScope

The enclosing scope of this module (always none)

getFile

Gets the source file for this module

getInitModule

Gets the init module of this module if the module is a package and it has an init module

getKind

Gets the kind of this module.

getLoadPath

Gets the path element from which this module was loaded.

getLocation

Gets the location for this AST node

getMetrics

Gets the metrics for this module

getName

Gets the name of this module

getPackage

Gets the package containing this module (or parent package if this is a package)

getPackageName

Gets the name of the package containing this module

getPath

Gets the source file or folder for this module or package

getScope

This method will be deprecated in the next release. Please use getEnclosingScope() instead. The enclosing scope of this module (always none)

getStmt

Gets the nth statement of this module

getSubModule

Gets a child module or package of this package

hasFromFuture
inStdLib

Holds if this module is in the standard library for version major.minor

inStdLib

Holds if this module is in the standard library

isPackage

Whether this is a package

isPackageInit

Whether this module is a package initializer

toString

Inherited predicates

getAFlowNode

Gets a flow node corresponding directly to this node. NOTE: For some statements and other purely syntactic elements, there may not be a ControlFlowNode

from AstNode
getANormalExit

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

from Scope
getAnExitNode

Gets an exit from this Scope’s control flow graph

from Scope
getDocString

Gets the docstring for this scope

from Scope
getEntryNode

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

from Scope
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.

from Scope
getFallthroughNode

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

from Scope
getHash

Gets the hash (not populated) of this module.

from Module_
getLastStatementfrom Scope
getParentNode

Gets the parent node of this node in the AST. This predicate exists to aid exploration of the AST and other experiments. The child-parent relation may not be meaningful. For a more meaningful relation in terms of dependency use Expr.getASubExpression(), Stmt.getASubStatement(), Stmt.getASubExpression() or Scope.getAStmt() applied to the parent.

from AstNode
getReturnNode

Gets the exit of this scope following from a return statement

from Scope
inSource

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

from Scope
isArtificial

Whether this syntactic element is artificial, that is it is generated by the compiler and is not present in the source

from AstNode
isPublic

Holds if this scope is deemed to be public

from Scope
isTopLevel

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

from Scope
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.

from Scope