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