What am I doing wrong here?

Aahz aahz at pythoncraft.com
Mon Jun 30 00:31:13 EDT 2003


In article <7sNLa.30264$Kg7.14786 at nwrdny01.gnilink.net>,
Bill C. Wong <bcw at rave.ch> wrote:
>
>################################
>def func( s ):
>    s1, s2 = s.split( ' ', 1 )
>    try:
>        raise s1
>    except "aaaa":
>        print 'except "aaaa"'
>    except:
>        print 'except:'
>
>s = "aaaa "
>func( s )
>################################
>If I manually assign s1 with s1 = "aaaa", then it works fine! What am I
>doing wrong here?

Let me repeat and emphasize Gerhard's second post:

    DO NOT USE STRING EXCEPTIONS

String exceptions are informally deprecated (and have been since Python
1.5.2); they will likely be formally deprecated in Python 2.4; they will
disappear in Python 3.0.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Usenet is not a democracy.  It is a weird cross between an anarchy and a
dictatorship.  




More information about the Python-list mailing list