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