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