First program
Peter Otten
__peter__ at web.de
Sat Jun 12 06:51:18 EDT 2010
Phil H wrote:
> On Sat, 12 Jun 2010 09:03:43 +0000, Phil H wrote:
>
>> Hi,
>> Trying my hand with Python but have had a small hiccup. Reading 'A byte
>> of Python' and created helloworld.py as directed.
>><snip>
>> Any help appreciated
>> Phil
>
> Thanks Peter & Chris for your prompt replies.
> The line ending was the problem.
> The script was written using Gedit on Ubuntu.
Strange. Did you perhaps start with a file that you got from elsewhere and
modified that? Gedit may have left the CRs untouched then.
> Cannot find a setting in Gedit to set the line ending but it must be
> there somewhere so will keep looking.
> Also how do you see or check the line endings of a file?
cat -v filename
is one option. CR (or "\r", or chr(13), or carriage return) shows up as ^M.
The ^ means "subtract 64 from the byte value", e. g.
^M = chr(ord("M")-64) = chr(77-64) = chr(13)
Peter
More information about the Python-list
mailing list