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


Groups > comp.lang.python > #81433

Re: I have no class

References (8 earlier) <mailman.16192.1416759279.18130.python-list@python.org> <up347a14v7v65meph33k53kas3jkqgmoo5@4ax.com> <66b13454-3503-4111-bf8e-58ce79ef00aa@googlegroups.com> <5472b24c$0$12979$c3e8da3$5496439d@news.astraweb.com> <5472BE0D.701@davea.name>
Date 2014-11-24 16:21 +1100
Subject Re: I have no class
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.16229.1416806507.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Nov 24, 2014 at 4:11 PM, Dave Angel <davea@davea.name> wrote:
> The case I found astounding in C++ was in the initializer list where the
> line
>
>     value:value
>
> would assume that the first one was  this->value, and the second was a local
> named value (usually an argument to the constructor).

That's occasionally quite useful. You can create a variable which
shadows another, and reference the original in its initialization, as
a simple means of mocking for debug:

//Maybe a global, or at least at wider scope
string separator="whatever... maybe pulled from a MIME document";
...
{
    string separator="** DEBUG **"+separator+"** DEBUG **";
    ...
    code using separator
    ...
}

You can comment or uncomment the debug line, and everything inside the
braces will be affected by its alteration - but nothing outside them
will, because it's shadowed and not altered. Can be extremely handy.

ChrisA

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


Thread

I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 21:47 -0500
  Re: I have no class random832@fastmail.us - 2014-11-22 22:08 -0500
    Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 22:16 -0500
  Re: I have no class Rustom Mody <rustompmody@gmail.com> - 2014-11-22 19:09 -0800
    Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 22:18 -0500
  Re: I have no class Ned Batchelder <ned@nedbatchelder.com> - 2014-11-22 22:14 -0500
    Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 22:35 -0500
      Re: I have no class Joel Goldstick <joel.goldstick@gmail.com> - 2014-11-22 22:52 -0500
        Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 23:15 -0500
          Re: I have no class Chris Angelico <rosuav@gmail.com> - 2014-11-23 17:00 +1100
            Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-23 05:52 -0500
              Re: I have no class Dave Angel <davea@davea.name> - 2014-11-23 10:16 -0500
                Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-23 10:54 -0500
                Re: I have no class Dave Angel <davea@davea.name> - 2014-11-23 11:14 -0500
                Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-23 11:49 -0500
                Re: I have no class Chris Angelico <rosuav@gmail.com> - 2014-11-24 03:59 +1100
                Re: I have no class Rustom Mody <rustompmody@gmail.com> - 2014-11-23 09:02 -0800
                Re: I have no class Steven D'Aprano <steve@pearwood.info> - 2014-11-24 04:21 +0000
                Re: I have no class Dave Angel <davea@davea.name> - 2014-11-24 00:11 -0500
                Re: I have no class Chris Angelico <rosuav@gmail.com> - 2014-11-24 16:11 +1100
                Re: I have no class Dan Sommers <dan@tombstonezero.net> - 2014-11-24 13:44 +0000
                Re: I have no class Chris Angelico <rosuav@gmail.com> - 2014-11-25 00:48 +1100
                Re: I have no class Dave Angel <davea@davea.name> - 2014-11-24 00:20 -0500
                Re: I have no class Chris Angelico <rosuav@gmail.com> - 2014-11-24 16:21 +1100
                Re: I have no class Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-11-24 13:47 -0500
      Re: I have no class Rustom Mody <rustompmody@gmail.com> - 2014-11-22 19:55 -0800
        Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 23:19 -0500
        Re: I have no class Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-23 15:35 +0000

csiph-web