Deep vs. shallow copy?

Ian Kelly ian.g.kelly at gmail.com
Thu Mar 13 20:08:47 EDT 2014


On Thu, Mar 13, 2014 at 5:55 PM, Chris Angelico <rosuav at gmail.com> wrote:
> I'm going to troll for a moment and give you a function that has no
> return value.
>
> def procedure():
>     raise Exception

>>> import dis
>>> dis.dis(procedure)
  2           0 LOAD_GLOBAL              0 (Exception)
              3 RAISE_VARARGS            1
              6 LOAD_CONST               0 (None)
              9 RETURN_VALUE
>>> def get_procedure_return_value():
...     """Returns the return value of procedure()."""
...     return procedure.__code__.co_consts[0]
...
>>> print(get_procedure_return_value())
None

Look, there it is!



More information about the Python-list mailing list