CKTIS / Python
type.__name__
Ta atribut razreda vrne preprosto ime tipa brez modula in obdajajočih razredov.
Različica: Python 3.14; repository image, production runtime not attested
Sintaksa
name = type(value).__name__Ta atribut razreda vrne preprosto ime tipa brez modula in obdajajočih razredov.
type.__name__
Kvalificirano __qualname__ ohrani gnezdenje. Različni tipi si lahko delijo preprosto ime. Preimenovanje uporabniškega razreda ne spremeni njegove identitete.
Najprej se izpišeta Item in Outer.Item, po preimenovanju Entry True.
class One:
class Item: pass
class Two:
class Item: pass
assert One.Item.__name__==Two.Item.__name__ and One.Item is not Two.Item
try: One.Item.__name__=3
except TypeError: pass
else: raise AssertionError
Primeri
class Outer:
class Item: pass
item=Outer.Item()
print(type(item).__name__, type(item).__qualname__)
Outer.Item.__name__="Entry"
print(type(item).__name__, Outer.Item is type(item))
Rezultat
Item Outer.Item Entry True
Najprej se izpišeta Item in Outer.Item, po preimenovanju Entry True.