Level 9 : What is the output for the below code?


class Meta(type):
    def __new__(cls, name, bases, dct):
        dct['id'] = 100
        return super().__new__(cls, name, bases, dct)

class MyClass(metaclass=Meta):
    pass

print(MyClass.id)

Author: VenuEmmela | Tags: classes | 1859+ Python FAQs | Share
thread | iterators | data-structures-in-python | comprehension | boolean-and-non-boolean | heap-memory | advanced-file-operations | basic | iterable | complex | bitwise-operator | list-comprehensions | assert | data-type | indentation | indexing | class | filter | complex-number | formal-and-actual-parameter | conditional-statement | creating-and-starting-threads | deep-copy | library | matrix-list-comprehension | filter-function | operator-overloading | loop-control-statements | math-copysign | name-mangling | mapping-function | list-mutation | list,-set,-and-dictionary-comprehensions | namedtuple | max-min | list-methods-and-slicing | print-statement | split | constructor | error-handling | mysql | parameter | matrix | sets | software-design | namespace | operator | reading:-read(),-readline(),-readlines() | shallow-copy | list-operation | touples | string-formatting | numeric | string-iteration | string-methods | booleans | python-history | loop | python-operators | recursion | strings | using-map()-for-transformations | tuple-methods | reading-and-writing-files | multiple-except-blocks | loops | floats | zip-function | functions | encapsulation | installation | membership-operators-(in,-not-in) | dictionary-methods | else-statement | binary-operation | why-use-multiprocessing-over-threading?-(gil) | condition | string | overriding-methods | zip | thread-synchronization | encoding | data-type | counter | list-comprehension | tuple-unpacking | while-loop | recurssion | logical-operators | context-manager | variable | lists | logical-operator | operator-or | writing:-write(),-writelines() | immutable-data-type | tuple | int | integers | memory-management | matplotlib | set | generators-in-python | version-check | else | multithreading | __init_subclass__ | class-and-instance-variable | oop | function-argument | arithmetic-expression | sys-module | exception-handling | pickling--unpickling | match | parsing-with-strptime | error-handling | decorator | format | list-vs-tuple | working-with-temporary-files-using-tempfile | center | built-in-modules | virtual-environment | benefit | range | introduction-to-python | list-slicing | fabs-function | integer | swapping | generators | identity-operators-(is,-is-not) | introduction-to-threads | lambda-function | datatype | dictionary-comprehensions | dataframe-and-series-objects | init | bitwise | string-manipulation | functional-programming | conditional-statements | postfix | debugging | unit-testing | string-slicing | syntax | set-operation | expand-tab | classes | objects | keyword | quantifiers-(*,-+,-?,-{}) | loop-control | dicts | time-series-with-pandas | min-function | identifier | math | using-the-threading-module | iterator | zfill-function | default-arguments | goto-function | raise-statement | intering | async | lambda | operators | copy | turtle | indexing:-loc-vs-iloc | static-method | for | opening-files-(open()) | python-django | type-conversion | using-join()-and-is_alive()-methods | yield | list-method | comparison | global-variable | magic-method | type-conversion | class-and-inheritance | odd-number | regex | method-overloading | string-slicing | version | built-in-function | multiprocessing | module | method | while-else-loop | syntax-error | return-statement | using-lists-as-stacks | design-principle | array | python-syntax-and-structure | numpy | syntax-error | control-flow | python-module | function | class-decorators | managing-directories-with-os-and-shutil | choice | asyncio | creating-custom-modules | pass | function-and-scope | functional-programming | round | staticmethod | using-yield-in-functions | update | oops | collection | test-discovery | precedence | comment | using-else-and-finally | join | feature | input-function | joining-and-merging-dataframes | working-with-file-paths | key-value-pairs | input | data-types | input-function | escape-operator | sys | mathematics | syntaxerror | working-with-dates-and-times | filtering-and-indexing | error | file-handling | multiple-inheritance | data-type-conversions | data-structure | exception | random | id-function | anchors-(^,-$) | list | type-conversion-and-casting | enumerate() | python_version | inheritance | logical-operator | list-comprehension | mathematical-function | frozenset | virtual-environment | built-in | arbitrary-arguments-(*args,-**kwargs) | conditional-statement | single-inheritance | docstring | access-modifier | mutable | global-variable | literal-characters-and-special-characters | compute | gil | immutability | using-os-and-pathlib-modules | slice | handling-missing-values-(fillna,-dropna) | object-attribute | factorial-function | thread-safe-data-structures-(queue.queue) | string-method | destructor | data-structures | sorting-and-ranking | formatting-with-strftime | list-join | pandas | methods | lambdas | higher-order-function | data-structure | generator | multiple-inheritance | slicing | dictionaries | map-function | sorting | aggregating-data-with-functools.reduce() | sum() | typeerror | working-with-binary-files-(rb,-wb) | introduction-to-multiprocessing | implementation | file-handling | rollback | application | nested-loop | memory | polymorphism | min-max-function | exception-handling | descriptors | while-and-for-loop | directory-operations | datetime | overflow | lambda-functions | head-and-tail | boolean-masking | bitwise-operator | with-statement | sum-function | file | exponentiation | random-function | built-in-function | package-management | list-indexing | default-mutable-argument | decimal | global | difference-between-threads-and-processes | asyncio-module | python-repl | tuples | scientific-notation | identity-operator | file_handling | invalid-list | global-keyword | arithmetic-operation | type_conversion | assignment-operators | inherit | __future__ | walking-through-directories-using-os.walk() | regular-expressions | identity-operator | operator-and | round-function | expression | floating-point-precision | string-method | while-loops | string-formatting | interpreter | import-method | defining-functions | using-assertions-(assertequal,-assertraises) | append | pseudocode | operand | threading | __all__-attribute | control-statement | control-flow | conversion | datetime.date,-datetime.time,-datetime.datetime | attribute | sorted | print | reading-and-writing-large-files-efficiently | dictionary | python | boolean | pep | regular-expression | string-concatenation | raise | operations | call | assignment-operator | precedence-and-associativity | counter-function | def | stack | logical-operation | collections | data_structure | binary | statement | command-line-parsing | class-and-object ...