Deep vs. shallow copy?

Rustom Mody rustompmody at gmail.com
Thu Mar 13 22:57:53 EDT 2014


On Friday, March 14, 2014 5:11:03 AM UTC+5:30, Steven D'Aprano wrote:
> On Thu, 13 Mar 2014 14:27:48 +0200, Marko Rauhamaa wrote:

> > Roy Smith :
> >>  Steven D'Aprano  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)
> py> type(proc)
> 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.

I believe that you, Marko (and I) are saying exactly the same thing:

Wear language-lawyer hat: 
Python has no procedures -- just functions which may return None

Wear vanilla programmer hat:
The concept (Pascal) procedure is simulated by function-returning-None



More information about the Python-list mailing list