MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / Symbol

Class Symbol

tools/python-3.11.9-amd64/Lib/symtable.py:219–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217
218
219class Symbol:
220
221 def __init__(self, name, flags, namespaces=None, *, module_scope=False):
222 self.__name = name
223 self.__flags = flags
224 self.__scope = (flags >> SCOPE_OFF) & SCOPE_MASK # like PyST_GetScope()
225 self.__namespaces = namespaces or ()
226 self.__module_scope = module_scope
227
228 def __repr__(self):
229 return "<symbol {0!r}>".format(self.__name)
230
231 def get_name(self):
232 """Return a name of a symbol.
233 """
234 return self.__name
235
236 def is_referenced(self):
237 """Return *True* if the symbol is used in
238 its block.
239 """
240 return bool(self.__flags & _symtable.USE)
241
242 def is_parameter(self):
243 """Return *True* if the symbol is a parameter.
244 """
245 return bool(self.__flags & DEF_PARAM)
246
247 def is_global(self):
248 """Return *True* if the symbol is global.
249 """
250 return bool(self.__scope in (GLOBAL_IMPLICIT, GLOBAL_EXPLICIT)
251 or (self.__module_scope and self.__flags & DEF_BOUND))
252
253 def is_nonlocal(self):
254 """Return *True* if the symbol is nonlocal."""
255 return bool(self.__flags & DEF_NONLOCAL)
256
257 def is_declared_global(self):
258 """Return *True* if the symbol is declared global
259 with a global statement."""
260 return bool(self.__scope == GLOBAL_EXPLICIT)
261
262 def is_local(self):
263 """Return *True* if the symbol is local.
264 """
265 return bool(self.__scope in (LOCAL, CELL)
266 or (self.__module_scope and self.__flags & DEF_BOUND))
267
268 def is_annotated(self):
269 """Return *True* if the symbol is annotated.
270 """
271 return bool(self.__flags & DEF_ANNOT)
272
273 def is_free(self):
274 """Return *True* if a referenced symbol is
275 not assigned to.
276 """

Callers 1

lookupMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected