Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'read.': 0.03; 'syntax': 0.04; 'subject:Python': 0.06; 'plenty': 0.07; '22,': 0.09; 'arguments': 0.09; 'pep': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'jan': 0.12; '->': 0.16; 'factory': 0.16; 'messy': 0.16; 'welcomed': 0.16; 'thursday,': 0.16; 'wrote:': 0.18; 'things.': 0.19; 'thu,': 0.19; 'seems': 0.21; 'example': 0.22; 'email addr:gmail.com>': 0.22; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'rapidly': 0.24; 'cc:2**0': 0.24; "i've": 0.25; '>': 0.26; 'possibly': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'chris': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'ordinary': 0.31; 'sense': 0.34; 'could': 0.34; 'common': 0.35; 'definition': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'sequence': 0.36; 'employee': 0.37; 'january': 0.37; 'two': 0.37; 'pm,': 0.38; 'little': 0.38; 'itself': 0.39; 'how': 0.40; 'skip:u 10': 0.60; 'new': 0.61; 'kind': 0.63; 'places': 0.64; 'become': 0.64; 'more': 0.64; 'different': 0.65; 'to:addr:gmail.com': 0.65; 'here': 0.66; 'hang': 0.67; 'union': 0.69; 'subject:! ': 0.74; '2015': 0.84; 'float,': 0.84; 'functions:': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=0Od8uRqAo5lRi0bFS1KDvuxEh1IFVZvRl8uD3dXV/Jc=; b=KD34ueHdAgE/8p9BSOnHJZ7MUneiT1YH+pQRgKltzQIis+yHd7VZFpj0w7ISeEpMjV GASfBvB+1R8cROY0ICVMIQoRxtrbJzG0pDfHfmWhJiMxsbwHhpC0T6Mt8w77qX77FRHs 8mKjFFbFS9GFOKdqFeMogxmYfZ//AYv1hT+/K6/OiJRojixvm6+3PbXGSRk0qw+LKJQR SulOnUeOFD+h6u4F1Vl77wfZzZqk3RKnl8u1fgvFhENTEy2hOIAAOkixBKdpNT4FZMna HLSqWNilj+EoCf6Jf9CBiH+ZivZtnICmb0KfssOQs8Nf9AxKmSggXkJmn19stDFv1rC2 IWfg== MIME-Version: 1.0 X-Received: by 10.112.30.42 with SMTP id p10mr794981lbh.70.1421923578761; Thu, 22 Jan 2015 02:46:18 -0800 (PST) In-Reply-To: References: <54c07d04$0$13012$c3e8da3$5496439d@news.astraweb.com> <54c0a571$0$13002$c3e8da3$5496439d@news.astraweb.com> Date: Thu, 22 Jan 2015 10:46:18 +0000 Subject: Python is DOOMED! Again! From: Nicholas Cole To: Chris Angelico Content-Type: multipart/alternative; boundary=001a11347b22cf5a95050d3b610b Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 88 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1421923580 news.xs4all.nl 2951 [2001:888:2000:d::a6]:49000 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:84222 --001a11347b22cf5a95050d3b610b Content-Type: text/plain; charset=UTF-8 On Thursday, 22 January 2015, Chris Angelico > wrote: > On Thu, Jan 22, 2015 at 7:10 PM, Mario Figueiredo > wrote: > > Possibly one common use case will be Unions. And that factory syntax is > > really awful and long when you look at a function definition with as > > little as 3 arguments. The one below has only 2 arguments. > > > > def handle_employees(emp: Union[Employee, Sequence[Employee]], raise: > > Union[float, Sequence[float]]) -> Union[Employee, Sequence[Employee], > > None]: > > Hold on a moment, how often do you really do this kind of thing with > "might be one of them or a sequence"? Do you really have a function > that could take an Employee and a float, or a sequence of Employees > and a single float, or a single Employee and a sequence of floats, or > a sequence of both? Or do you, much more likely, actually have two > separate functions: > > def handle_employee(emp: Employee, raise: float) -> Optional[Employee]: > > def handle_employees(emp: Sequence[Employee], raise: Sequence[float]) > -> List[Employee]: > > The union in the return value seems particularly unlikely... and unhelpful. > Hang on! The particular example may not make a lot of sense but there are plenty of places in ordinary Python where functions can accept different objects in arguments and return different things. The point here is that that will become rapidly messy and hard to read. Perhaps the new PEP will discourage this kind of thing and perhaps that is to be welcomed not feared, but I don't think the example itself was particularly contrived. I've seen it in plenty of code in the wild. --001a11347b22cf5a95050d3b610b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

On Thursday, 22 January 2015, Chris Angelico <rosuav@gmail.com> wrote:
On Thu,= Jan 22, 2015 at 7:10 PM, Mario Figueiredo <marfig@gmail.com> = wrote:
> Possibly one common use case will be Unions. And that factory syntax i= s
> really awful and long when you look at a function definition with as > little as 3 arguments. The one below has only 2 arguments.
>
> def handle_employees(emp: Union[Employee, Sequence[Employee]], raise:<= br> > Union[float, Sequence[float]]) -> Union[Employee, Sequence[Employee= ],
> None]:

Hold on a moment, how often do you really do this kind of thing with
"might be one of them or a sequence"? Do you really have a functi= on
that could take an Employee and a float, or a sequence of Employees
and a single float, or a single Employee and a sequence of floats, or
a sequence of both? Or do you, much more likely, actually have two
separate functions:

def handle_employee(emp: Employee, raise: float) -> Optional[Employee]:<= br>
def handle_employees(emp: Sequence[Employee], raise: Sequence[float])
-> List[Employee]:

The union in the return value seems particularly unlikely... and unhelpful.=

Hang on! The particular example may not ma= ke a lot of sense=C2=A0but there are plenty of places in ordinary Python wh= ere functions can accept different objects in arguments and return differen= t things. The point here is that that will become rapidly messy and hard to= read.=C2=A0

Perhaps the new PEP will= discourage this kind of thing and perhaps that is to be welcomed not feare= d, but I don't think the example itself was particularly contrived. I&#= 39;ve seen it in plenty of code in the wild.=C2=A0
--001a11347b22cf5a95050d3b610b--