On 30 Mar 2007 08:38:27 -0700, kevinliu23 <[EMAIL PROTECTED]> wrote: > Hey guys, > > I want to be able to insert a '-' character in front of all numeric > values in a string. I want to insert the '-' character to use in > conjunction with the getopt.getopt() function. ... > "2a 3ab" into "-2a -3ab".
Are you sure you want getopt, or are you just reusing it because you don't know enough about string parsing and REs? -2a -3ab is a bit limited: if you run out of digits and have to use 10, 11, ... then getopt will treat '-10ab' as '-1' without argument and -0 with 'ab' as argument. It will probably choke on the argumentless -1, too. /Jorgen -- // Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org> R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list