[Pythonmac-SIG] \r in string causes eval to fail

Michael Hudson mwh at python.net
Thu Sep 16 13:08:01 CEST 2004


"Chris Barker" <Chris.Barker at noaa.gov> writes:

> Michael Hudson wrote:
>> "Chris Barker" <Chris.Barker at noaa.gov> writes:
>> 
>>>Michael Hudson wrote:
>>>
>>>
>>>>Semi-seriously, I'd guess that everyone who's bumped into this has
>>>>found it easier to normalize the line feeds in Python than hack the
>>>>parser (it's a little scary).
>>>
>>>Would you need to hack the parser? I'd be inclined to simply put a
>>>filter in before the parser, just like I'd do in user code:
>>>
>>>CodeString = FixLineFeeds(CodeString)
>>>eval(CodeString)
>> Did you read what I said?
>
> yes, but I didn't write what I meant, at least not clearly.

Ah, OK :-)

> What I was trying to say was that rather than hack the parser, one
> could just insert a line feed fixer _before_ the parser, INSIDE eval
> and friends, essentially moving the python code I wrote, into eval. I
> can't imagine this would be hard, but it wouldn't get you any
> performance benefits over just writing one extra line of python.

Yes, that would work too.  I'd much rather write line-ending
normalizing code in Python than in C, though...

Oh well, it's not my itch and I'm not going to scratch it.

Cheers,
mwh

-- 
  Lisp nearing the age of 50 is the most modern language out
  there. GC, dynamic, reflective, the best OO model extant including
  GFs, procedural macros, and the only thing old-fashioned about it 
  is that it is compiled and fast.   -- Kenny Tilton, comp.lang.python


More information about the Pythonmac-SIG mailing list