Re: New user: Windows, Postgresql, Python - Mailing list pgsql-general

From Michael Fuhr
Subject Re: New user: Windows, Postgresql, Python
Date
Msg-id 20050316143454.GA14572@winnie.fuhr.org
Whole thread Raw
In response to Re: New user: Windows, Postgresql, Python  ("Magnus Hagander" <mha@sollentuna.net>)
Responses Re: New user: Windows, Postgresql, Python  (Marco Colombo <pgsql@esiway.net>)
List pgsql-general
On Wed, Mar 16, 2005 at 01:46:23PM +0100, Marco Colombo wrote:
>
> It seems python documentation is plain wrong, or I'm not able to
> read it at all:
>
> http://docs.python.org/ref/physical.html
>
> "A physical line ends in whatever the current platform's convention is for
> terminating lines. On Unix, this is the ASCII LF (linefeed) character. On
> Windows, it is the ASCII sequence CR LF (return followed by linefeed). On
> Macintosh, it is the ASCII CR (return) character."

Perhaps the Python documentation could use some clarification about
when the platform's convention is required and when it isn't.

The "Embedding Python" documentation shows embedded code with lines
ending in \n and without saying anything about requiring the
platform's convention:

http://docs.python.org/ext/high-level-embedding.html

> This is the language _reference_ manual, btw. I'm very surprised to hear
> python on windows is so broken.
>
> Anyway, that makes life simpler for us. plpython programs are \n separated,
> no matter what platform the server runs on.

That the behavior makes life simpler is an argument against it being
broken (although it would be even less broken if it were more
flexible about what line endings it allows).  A detailed response
would be getting off-topic for PostgreSQL, but I'll stand by what
I said earlier: I would find it bizarre if embedded Python code had
to use different line endings on different platforms.  That would
mean the programmer couldn't simply do this:

    PyRun_SimpleString("x = 1\n"
                       "print x\n");

Instead, the programmer would have to do a compile-time or run-time
check and build the string in a platform-dependent manner.  What
problem would the language be solving by requiring that?

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

pgsql-general by date:

Previous
From: Miroslav Šulc
Date:
Subject: psql file restore - problem with encoding
Next
From: Miroslav Šulc
Date:
Subject: Re: psql file restore - problem with encoding