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