copy.copy

Jon Ribbens jon+usenet at unequivocal.eu
Mon Nov 22 10:02:05 EST 2021


On 2021-11-22, ast <ast at invalid> wrote:
> Hi,
>
> >>> a = 6
> >>> b = 6
> >>> a is b
> True
>
> ok, we all know that Python creates a sole instance
> with small integers, but:
>
> >>> import copy
> >>> b = copy.copy(a)
> >>> a is b
> True
>
> I was expecting False

Why did you expect False?

For immutable types, copy(foo) just returns foo.


More information about the Python-list mailing list