Re: String Exceptions (PEP 352)

2006-05-05 Thread bruno at modulix
Paul Rubin wrote:
> bruno at modulix <[EMAIL PROTECTED]> writes:
> 
>>What's wrong with:
>>
>>assert foo and bar and i > 10, \
>>  "if foo and bar i must not be greater than 10"
> 
> 
> It doesn't necessarily do anything.  With optimization enable, assert
> is a no-op.

quoting the OP (emphasis is mine):
"""
I use string exceptions if the condition for an *assertion* is
to complex:
"""

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String Exceptions (PEP 352)

2006-04-29 Thread Paul Rubin
bruno at modulix <[EMAIL PROTECTED]> writes:
> What's wrong with:
> 
> assert foo and bar and i > 10, \
>   "if foo and bar i must not be greater than 10"

It doesn't necessarily do anything.  With optimization enable, assert
is a no-op.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String Exceptions (PEP 352)

2006-04-27 Thread Ben Finney
Thomas Guettler <[EMAIL PROTECTED]> writes:

> I like python because it is compatible to old versions.

I like it because it has a documented, manageable procedure for
breaking compatibility with old versions.

> if foo and bar and i>10:
> raise "if foo and bar i must not be greater than 10"

Others have pointed out that this is a job for 'assert'.

> Is it too late to change this?

Yes. PEP-0352 has a status of "Final".

> Way not make this line
> 
> raise "..."
> 
> behave like this:
> 
> raise Exception("...")   
> 
> in the future?

Because explicit is better than implicit, and special magic behaviour
is to be deprecated (or never implemented) when possible.

> Please keep Python compatible to old versions.

Have a read of PEP 0005:

http://www.python.org/dev/peps/pep-0005>

Also note that the transition plan (documented in the PEP that
concerns you) shows the support for the old behaviour is not to be
dropped until Python 3.0, a release explicitly targeted at breaking
backward compatibility to clean out crufty behaviour.

-- 
 \"I went to the hardware store and bought some used paint. It |
  `\   was in the shape of a house."  -- Steven Wright |
_o__)  |
Ben Finney

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String Exceptions (PEP 352)

2006-04-27 Thread Terry Reedy

"Thomas Guettler" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>I like python because it is compatible to old versions.

Python 3 will be a new and mostly improved dialect of Python.
Some 2.x code will run unchanged.  Much will not.  Transition tools will be 
written.

> That's way I think string exceptions should not be deprecated.
> Is it too late to change this?

Yes.

> Way not make this line raise "..."
> behave like this: raise Exception("...")

Part of the motivation for 3.0 is to remove duplication and *simply* the 
language (= easier to learn), parser, compiler, and interpreter.

Terry Jan Reedy



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String Exceptions (PEP 352)

2006-04-27 Thread bruno at modulix
bruno at modulix wrote:
> Thomas Guettler wrote:
> 
>>Hi,
>>
>>I like python because it is compatible to old versions. That's way I think
>>string exceptions should not be deprecated.
>>
>>I use string exceptions if the condition for an assertion is
>>to complex:
>>
>>if foo and bar and i>10:
>>raise "if foo and bar i must not be greater than 10"
> 
> 
> What's wrong with:
> 
> assert foo and bar and i > 10, \
>   "if foo and bar i must not be greater than 10"
> 

oops ! I meant:
if foo and bar:
  assert i > 10,  "if foo and bar i must not be greater than 10"

My bad :(


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String Exceptions (PEP 352)

2006-04-27 Thread bruno at modulix
Thomas Guettler wrote:
> Hi,
> 
> I like python because it is compatible to old versions. That's way I think
> string exceptions should not be deprecated.
> 
> I use string exceptions if the condition for an assertion is
> to complex:
> 
> if foo and bar and i>10:
> raise "if foo and bar i must not be greater than 10"

What's wrong with:

assert foo and bar and i > 10, \
  "if foo and bar i must not be greater than 10"



(snip)
>
> Please keep Python compatible to old versions.


When there's too much hysterical cruft and warts accumulated from the
past, it's time to throw away and clean up, even if it breaks a lot of
things. Trying to keep compatibility at any price would be just suicidal
IMHO - time to get rid of old warts and come back to simplicity. "one
obvious way to do it" rules.


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String Exceptions (PEP 352)

2006-04-27 Thread infidel
You could also use the "assert" statement:

>>> if foo and bar:
... assert i <= 10, "if foo and bar then i must not be greater than
10"
...

-- 
http://mail.python.org/mailman/listinfo/python-list


String Exceptions (PEP 352)

2006-04-27 Thread Thomas Guettler

Hi,

I like python because it is compatible to old versions. That's way I think
string exceptions should not be deprecated.

I use string exceptions if the condition for an assertion is
to complex:

if foo and bar and i>10:
raise "if foo and bar i must not be greater than 10"

This way I can easily add "checkpoints" to my code.

Is it too late to change this? Way not make this line

raise "..."

behave like this:

raise Exception("...")   

in the future?

I know that catching string exceptions and reading the
string is different from Exception("..."). This could
become deprecated.

Please keep Python compatible to old versions.

 Thomas Güttler

-- 
Thomas Güttler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de
Spam Catcher: [EMAIL PROTECTED]

-- 
http://mail.python.org/mailman/listinfo/python-list