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

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