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