Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.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.034 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'syntax': 0.04; 'subject:Python': 0.06; '22,': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'jan': 0.12; 'factory': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'seems': 0.21; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'possibly': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; 'could': 0.34; 'common': 0.35; 'definition': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'sequence': 0.36; 'employee': 0.37; 'two': 0.37; 'pm,': 0.38; 'little': 0.38; 'how': 0.40; 'skip:u 10': 0.60; 'kind': 0.63; 'more': 0.64; 'union': 0.69; 'subject:! ': 0.74; '2015': 0.84; 'float,': 0.84; 'functions:': 0.84; 'to:none': 0.92 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:cc :content-type; bh=p4HhpIZXieuA9jqSYdkmbMXWQRHZM9Zl1COoYSHSvvM=; b=Qq610xn2kyUjS9BtEw2TZnGBDV9uHKZ9J71JuK/kOI9C4dbPTty2gbgX6qcFcNxxYK jtfqrM6tpZXr/CxxmgZIpY6q/d9sVsnbxM2ZQwKw99BnF+RsLHpNNPsYx5LAl7QWPxsN 3o/H0rmdQqv/kigVB8axp+PcLOH6ephywj2x/Nb0KH0llN9ceUnXDSzVFsKj2Io1pYpu XE84OUNewtVTAq8OT3d7dtcwXzxwVlS7sSyxD9vhG5kFtyd87NZUvPpaCfeiRtdoguPu pKlOWXGp+euU/33snCmAg4CagFxF63u0CrG+xHS35v4wclSQXZFzk5xeSenkFJ+xTaNx 4llA== MIME-Version: 1.0 X-Received: by 10.224.128.196 with SMTP id l4mr930166qas.100.1421921359112; Thu, 22 Jan 2015 02:09:19 -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 21:09:19 +1100 Subject: Re: Python is DOOMED! Again! From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1421921362 news.xs4all.nl 2887 [2001:888:2000:d::a6]:59638 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:84217 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. ChrisA