<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Thu, Oct 13, 2016 at 5:10 PM Steven D'Aprano <<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, Oct 13, 2016 at 10:37:35AM +0200, Sven R. Kunze wrote:<br class="gmail_msg">
> About the list constructor: we construct a list by writing [a,b,c] or by<br class="gmail_msg">
> writing [b for b in bs]. The end result is a list<br class="gmail_msg">
<br class="gmail_msg">
I construct lists using all sorts of ways:<br class="gmail_msg"></blockquote><div> </div><div>I think there is a terminology problem here<span class="inbox-inbox-Apple-converted-space"> </span>(again). "Constructor" in OOP has a specific meaning, and "constructor" in functional terminology has a slightly different meaning. I guess Sven uses the latter terminology because pattern matching is the dual of the constructor - it is a "destructor" - and it feels appropriate, although admittedly confusing. In this terminology, map(), zip() etc. are definitely not constructors. there is only one "constructor" (list()), and there are functions that may use it as their implementation detail. In a way, [1, 2, 3] is just a syntactic shorthand for list construction, so it is reasonable to a call it a constructor.</div><div><br></div><div>This terminology is not a perfect fit into the object-oriented world of Python, but it is very helpful in discussion of patterns how to apply them uniformly, since they were pretty much invented in the functional world (ML, I think, and mathematics). One only needs to be aware of the two different meaning, and qualify if needed, so that we won't get lost in terminology arguments again.</div><div><br></div><div>Elazar</div></div></div>