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