Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #26031

Re: from future import pass_function

Date 2012-07-25 12:30 +0200
From Philipp Hagemeister <phihag@phihag.de>
Subject Re: from future import pass_function
References <d1o4e9-tlr.ln1@satorlaser.homedns.org>
Newsgroups comp.lang.python
Message-ID <mailman.2565.1343212216.4697.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Unlike the print statement, pass has no overboarding complexity (like
>>, printing tuples, etc.) - it just serves as a marker (and
practicality beats purity).

And you don't ever want to use pass as a value (say, for map() or the
right side of an assignment). In fact, if pass were a function, users
could construct strange code like

x = pass()

def pass():
   raise Exception('Are you slacking off? Get back to work!')

And don't forget that while the parentheses mainly confuse users,
they're also making it harder to type, and feel like useless overhead
(similar to the parentheses in  if (x):  ). In fact, I'd argue that if
pass were a function, None would be the better placeholder:

try:
    do_something()
except:
    None # 2 hard-to-type (on a German keyboard) characters shorter
    # (and probably way faster: No function call overhead and no need
    #  to actually find out what pass happens to be in this context)

- Philipp


On 07/25/2012 10:40 AM, Ulrich Eckhardt wrote:
> Hi!
>
> I just had an idea, it occurred to me that the pass statement is pretty
> similar to the print statement, and similarly to the print() function,
> there could be a pass() function that does and returns nothing.
>
> Example:
>    def pass():
>        return
>
>    try:
>        do_something()
>    except:
>        pass()
>
>
> One thing I don't like about this is the syntax
>
>    class foo(object):
>        pass()
>
>
> What do you think?
>
> Uli

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

from future import pass_function Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-07-25 10:40 +0200
  Re: from future import pass_function Philipp Hagemeister <phihag@phihag.de> - 2012-07-25 12:30 +0200
  Re: from future import pass_function Nicholas Cole <nicholas.cole@gmail.com> - 2012-07-25 11:33 +0100
  Re: from future import pass_function Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-07-25 07:02 -0400
  Re: from future import pass_function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-25 11:33 +0000
    Re: from future import pass_function Ross Ridge <rridge@csclub.uwaterloo.ca> - 2012-07-25 21:42 -0400
      Re: from future import pass_function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-26 02:38 +0000
        Re: from future import pass_function Ross Ridge <rridge@csclub.uwaterloo.ca> - 2012-07-25 23:30 -0400
          Re: from future import pass_function Chris Angelico <rosuav@gmail.com> - 2012-07-26 13:53 +1000
            Re: from future import pass_function Ross Ridge <rridge@csclub.uwaterloo.ca> - 2012-07-26 00:03 -0400
              Re: from future import pass_function Ethan Furman <ethan@stoneleaf.us> - 2012-07-25 21:32 -0700
                Re: from future import pass_function John Ladasky <john_ladasky@sbcglobal.net> - 2012-07-26 13:55 -0700
                Re: from future import pass_function Ethan Furman <ethan@stoneleaf.us> - 2012-07-26 14:23 -0700
                Re: from future import pass_function John Ladasky <john_ladasky@sbcglobal.net> - 2012-07-26 15:20 -0700
                Re: from future import pass_function John Ladasky <john_ladasky@sbcglobal.net> - 2012-07-26 15:20 -0700
                Re: from future import pass_function John Ladasky <john_ladasky@sbcglobal.net> - 2012-07-26 13:55 -0700
              Re: from future import pass_function Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-26 08:43 +0100
          Re: from future import pass_function alex23 <wuwei23@gmail.com> - 2012-07-25 21:20 -0700
        Re: from future import pass_function Rusi <rustompmody@gmail.com> - 2012-07-25 22:09 -0700
        Re: from future import pass_function Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-07-26 08:59 +0200
          Re: from future import pass_function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-26 09:26 +0000
            Re: from future import pass_function Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-07-26 13:45 +0200
              Re: from future import pass_function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-26 15:21 +0000
                Re: from future import pass_function Joel Goldstick <joel.goldstick@gmail.com> - 2012-07-26 12:55 -0400
                RE: from future import pass_function "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-07-26 17:19 +0000
                Re: from future import pass_function Chris Angelico <rosuav@gmail.com> - 2012-07-27 03:33 +1000
                Re: from future import pass_function Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-27 00:25 +0100
                Re: from future import pass_function Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-27 00:23 +0100
      Re: from future import pass_function alex23 <wuwei23@gmail.com> - 2012-07-25 21:17 -0700
  Re: from future import pass_function Chris Angelico <rosuav@gmail.com> - 2012-07-26 02:05 +1000
    Re: from future import pass_function Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-07-26 08:39 +0200
      Re: from future import pass_function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-26 08:36 +0000
      Re: from future import pass_function Terry Reedy <tjreedy@udel.edu> - 2012-07-26 10:38 -0400
  Re: from future import pass_function Ethan Furman <ethan@stoneleaf.us> - 2012-07-25 09:28 -0700
  Re: from future import pass_function Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-07-25 12:48 -0400
  Re: from future import pass_function Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-07-25 14:17 -0400
  Re: from future import pass_function Michael Hrivnak <mhrivnak@hrivnak.org> - 2012-07-26 01:20 -0400
    Re: from future import pass_function Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-07-26 08:42 +0200
      Re: from future import pass_function Michael Hrivnak <mhrivnak@hrivnak.org> - 2012-07-26 17:15 -0400
  Re: from future import pass_function Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-26 08:50 +0100
    Re: from future import pass_function Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-07-27 08:39 +0200
  Re: from future import pass_function Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-07-26 05:16 -0400
  Re: from future import pass_function Chris Angelico <rosuav@gmail.com> - 2012-07-26 19:42 +1000
  Re: from future import pass_function Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-07-26 06:00 -0400
  Re: from future import pass_function rusi <rustompmody@gmail.com> - 2012-07-26 08:01 -0700
  Re: from future import pass_function Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-26 14:01 -0400
  Re: from future import pass_function Chris Angelico <rosuav@gmail.com> - 2012-07-27 04:14 +1000
  Re: from future import pass_function John Ladasky <john_ladasky@sbcglobal.net> - 2012-07-26 13:48 -0700
    Re: from future import pass_function Ian Kelly <ian.g.kelly@gmail.com> - 2012-07-26 15:18 -0600
    Re: from future import pass_function Ethan Furman <ethan@stoneleaf.us> - 2012-07-26 15:35 -0700
    Re: from future import pass_function Terry Reedy <tjreedy@udel.edu> - 2012-07-27 00:21 -0400
  Re: from future import pass_function Michael Hrivnak <mhrivnak@hrivnak.org> - 2012-07-26 17:20 -0400

csiph-web