Hello Tim, I found that I have to edit the py script file (they are from the
book download) using gedit and then
save as and specify unix EOL and saving the same file. This of course works
fine but a bit awkward
I really don't think I know how to generate a script that would modify ,
say, all of the files (*.py) in a folder.
This would be a perfect way for you to increase your knowledge of Python. It’s just the kind of thing that a quick Python script can handle.
But, I have to edit the files anyhow as none of them have the hash bang line
in the script(s). So, I am thinking I might as well
just edit the file and then save it with the unix end of line format (?).
OK, but remember that you only need a hash-bang line in files that you intend to run from the command line by name. Python files that are only imported into other files don’t need it.
Further, the hash-bang is only needed as a shortcut. If you have a main program called “gui-program.py”, there are two ways to start it. One is to turn it into a Linux executable, and for that you need a hash-band:
chmod +x gui-program.py
./gui-program.py
The other is to run Python by hand; for that, you don’t need a hash-bang line:
python gui-program.py
But, I would be interested in using a script as you mentioned if you can
share an example. I am thinking you might be referring to a BASH script and
using the dos2unix utility? Once again, thanks for your suggestion(s)
BTW, I am using Linux(Ubuntu14.10) and not Windows.
Obviously, because the hash-bang is strictly a Unix thing.
Yes, you could do a simple bash command:
for i in *.py
do
mv $i $i.bak
dos2unix <$i.bak >$i
done
···
On Jun 6, 2015, at 8:18 PM, eightbits <jlala2010@gmail.com> wrote:
—
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.