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