| 
 
 
 
 hash, sum, super, idlen, max, min, next, sumdelattr, dir, getattr, globals, locals, setattr, varsascii, format, reprinput, open, print __import__breakpoint, @classmethod, compile, eval, exec, help, @staticmethod 
Draft for Information Only ContentPython Built-in Misc. Functions
 delattr()Parameters
 Remarks
 
 dir()Parameters
 Remarks
 
 getattr()Parameters
 Remarks
 
 globals()Parameters
 Remarks
 
 locals()Parameters
 Remarks
 
 setattr()Parameters
 Remarks
 
 vars()Parameters
 Remarks
 Source and Reference
 
Python Built-in Misc. Functions
The Python interpreter has some built-in misc. property functions.
     delattr()
delattr(object, name)Parametersdelattr()to delete the specified attribute from the given object.objectto specify the object to be delete fromnameto specify the attribute name to be deleted.Remarksobjectis an object.nameis a string of the attribute namenamemust be the name of one of theobject's attributesdelattrdeletes the named attribute, provided the object allows it.
 dir()
dir([object])Parametersdir()to return a name list.[object]optional, to specify the object to be returned fromRemarksIf objectis omitted,dirreturns the list of names in the current local scope.If objectis specified,dirreturns a list of valid attributes for theobjectIf objecthas a__dir__()method, this method will be called and must return the list of attributes. This allows objects that implement a custom__getattr__()or__getattribute__()function to customize the waydir()reports their attributes.If the object does not provide __dir__(), the function tries its best to gather information from the object's__dict__attribute, if defined, and from its type object. The resulting list is not necessarily complete, and may be inaccurate when the object has a custom__getattri__().The default dir()mechanism behaves differently with different types of objects, as it attempts to produce the most relevant, rather than complete, information:If the object is a module object, the list contains the names of the module's attributesIf the object is a type or class object, the list contains the names of its attributes, and recursively of the attributes of its bases.Otherwise, the list contains the object's attributes' names, the names of its class's attributes, and recursively of the attributes of its class's base classes.
Because dir()is supplied primarily as a convenience for use at an interactive prompt, it tries to supply an interesting set of names more than it tries to supply a rigorously or consistently defined set of names, and its detailed behavior may change across releases. For example, metaclass attributes are not in the result list when the argument is a class.
 getattr()
getattr(object, name[, default])Parametersgetattr()to return the specifiednameattribute of anobject.objectto specify theobjectto be returned fromnameto specify thenameattribute to be returned fromdefaultoptional, to specify thedefaultattribute whennameattribute does not exist.Remarksgetattr()returns the value of thenameattribute ofobject,namemust be a string. If the string is the name of one of theobject's attributes, the result is the value of that attribute.getattr(object, 'name')is equivalent toobject.nameIf the named attribute does not exist, defualtis returned if providede, otherwiseattributeErroris raised.
 globals()
globals()Parametersglobals()to return aglobalsdictionary representing the current global symbol table.RemarksThis is always the dictionary of the current module (inside a function or method, this is the module where it is defined, not the module from which it is called).
 locals()
locals()Parameterslocals()to return and update the dictionary representing the current local symbol table.RemarksFree variables are returned by localswhen it is called in function blocks, but not in class blocks.Note that at the module level, locals()andglobals()are the same dictionaryThe contents of this dictionary should not be modified; changes may not affect the values of local and free variables used by the interpreter.
 setattr()
setattr(object, name, value)Parameterssetattr()to set the value of the attribute of an object.objectto specify the object to be returned fromnameto specify the attribute to be assigned tovalueto specify the attribute value to be used for assigningRemarksThis is the counterpart of getattr(). The arguments are an object, a string and an arbitrary value. The string may name an existing attribute or a new attribute. The function assigns the value to the attribute, provided the object allows it.
 vars()
vars([object])Parametersvars()to return the type of an object.[object]optional, to specify the object to be returned from.Remarks    Return the __dict__ attribute for a module, class, instance, or any other object with a __dict__ attribute.
    Objects such as modules and instances have an updateable __dict__ attribute; however, other objects may have write restrictions on their __dict__ attributes (for example, classes use a types.MappingProxyType to prevent direct dictionary updates).
    Without an argument, vars() acts like locals(). Note, the locals dictionary is only useful for reads since updates to the locals dictionary are ignored.
 Source and Reference©sideway
 
 ID: 201102902 Last Updated: 11/29/2020 Revision: 0 |  |