Level 9 : What is the difference between a shallow copy and a deep copy in Python?

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