Deep vs. shallow copy?
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Thu Mar 13 19:41:03 EDT 2014
On Thu, 13 Mar 2014 14:27:48 +0200, Marko Rauhamaa wrote:
> Roy Smith <roy at panix.com>:
>
>> Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
>>
>>> Because Python doesn't have true procedures
>>
>> What do you mean by "true procedure"? Are you just talking about
>> subroutines that don't return any value, i.e. fortran's SUBROUTINE vs.
>> FUNCTION?
>
> Ah, the "no true procedure" argument:
>
> - No true procedure returns a value.
>
> - That's false. Python's procedures return None.
Are you trolling again?
I'm sure that you know quite well that Python doesn't have a procedure
type. It uses a single keyword, def, for creating both functions and
functions-that-return-None.
We should all agree that functions-that-return-None are used for the same
purpose as procedures, but they are still functions, and they have a
return result, namely None. If you don't believe me, believe Python:
py> def func():
... return 42
...
py> def proc():
... pass
...
py> type(func)
<class 'function'>
py> type(proc)
<class 'function'>
py> repr(proc())
'None'
In languages with procedures, that last line would be an error (either at
compile-time, or run-time) since a procedure wouldn't return anything to
use as argument to repr. But I'm sure that you know that.
> - They are not true procedures.
Correct. They are functions that return None, rather than a subroutine
that doesn't have any return value at all. But I'm sure you know that.
--
Steven D'Aprano
http://import-that.dreamwidth.org/
More information about the Python-list
mailing list