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


Groups > comp.lang.python > #26013

Re: assert expressions

References <9f6bed70-1ec1-4e3e-bdd0-c96013bf7df2@googlegroups.com> <mailman.2553.1343161917.4697.python-list@python.org> <8c5da998-e428-4000-adba-f5eee86ac971@d32g2000yqn.googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2012-07-24 15:22 -0600
Subject Re: assert expressions
Newsgroups comp.lang.python
Message-ID <mailman.2554.1343165006.4697.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Jul 24, 2012 at 2:44 PM, Wanderer <wanderer@dialup4less.com> wrote:
> I'm using getopt but not at that point. I really don't have a problem.
> I'm just curious. I've never seen anything else after
> assert False,
>
> Here is some code.

It doesn't matter what you put after the assert False, because that
line is not actually reached.  When getopt sees the -q, it immediately
raises a getopt.error, which you catch and then immediately reraise as
a Usage exception, which is then caught and printed at the end.  The
chained ifs with the assert statement never even execute in this
scenario.

Seeing the assert in context, it makes more sense.  It's not
intercepting some unimplemented option and preventing the program from
proceeding; it's there as a development tool to catch programming
errors where an option is added to the getopt configuration but is not
implemented in the if chain.

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


Thread

assert expressions Wanderer <wanderer@dialup4less.com> - 2012-07-24 12:57 -0700
  Re: assert expressions Ian Kelly <ian.g.kelly@gmail.com> - 2012-07-24 14:31 -0600
    Re: assert expressions Wanderer <wanderer@dialup4less.com> - 2012-07-24 13:47 -0700
      Re: assert expressions Wanderer <wanderer@dialup4less.com> - 2012-07-24 13:56 -0700
    Re: assert expressions Wanderer <wanderer@dialup4less.com> - 2012-07-24 13:44 -0700
      Re: assert expressions Ian Kelly <ian.g.kelly@gmail.com> - 2012-07-24 15:22 -0600
        Re: assert expressions Wanderer <wanderer@dialup4less.com> - 2012-07-24 14:25 -0700

csiph-web