Level 10 : What is the output for the below code?


class D:
    def __get__(self, obj, objtype):
        return "desc"

class C:
    x = D()

c = C()
c.__dict__['x'] = "instance"

print(c.x)

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