[Nottingham] Python scripts and Fwd: Thursday 16 May
NIGEL Black
rnjblack at virginmedia.com
Wed May 15 11:14:00 UTC 2019
Daryl.
Thanks. I have information about IDLE but haven't tried it. It would be good to go through some of the basics with you - I only need to get started - but that will have to wait for a while as I'm not at tomorrow's meeting.
Regards,
Nigel
> On 15 May 2019 at 10:56 Daryl via Nottingham <nottingham at mailman.lug.org.uk> wrote:
>
> Nigel,
>
> I should apologise too. I did read your email and was suggesting it might be easier to show you in person on Linux night than explain in email. I didn't however end up replying to your message, my fault.
>
> Martin has of course explained it very well. There is also Python IDLE which is a very easy to use GUI that will be installable from the software/package manager on your Linux distribution of choice. Ensure the versions match though - I would always suggest using Python 3 for everything now.
>
> I've been doing a LOT of Python development recently. I'm going to try and come along this Thursday (although no guarantee for reasons beyond my control) and happy to go through some things with you.
>
>
> Regards,
> Daryl.
>
> On Wed, 15 May 2019 at 10:24, Martin via Nottingham < nottingham at mailman.lug.org.uk mailto:nottingham at mailman.lug.org.uk > wrote:
>
> > > Nigel,
> >
> > Surprised none has come back to you on this one. Sorry for the slow
> > response!
> >
> >
> > We're over in Ye Olde Trip this Thursday for fun bits and pieces. Hope
> > you can make it!
> >
> >
> > For the Python bits, there's a few bits of syntax to follow...
> >
> > The ">>>" indicates that you are in a Python interpreter. To run script
> > files from that prompt, you need to do a few Python gymnastics! See:
> >
> > How to execute a file within the python interpreter?
> > https://stackoverflow.com/questions/1027714/how-to-execute-a-file-within-the-python-interpreter
> >
> > Another way is to format your script as a module and then "import" it
> > and execute the module...
> >
> >
> > For an example of running a python script from a *bash prompt* on my
> > machine for various versions of python, I get:
> >
> > #####
> >
> > martin :) $ chmod +x hello_world.py
> > martin :) $ chmod +x hello_world.py.no_hash_pling
> > martin :) $
> > martin :) $ ./hello_world.py
> > Hello World
> > martin :) $ ./hello_world.py.no_hash_pling
> > ./hello_world.py.no_hash_pling: line 5: syntax error near unexpected
> > token `'Hello World''
> > ./hello_world.py.no_hash_pling: line 5: `print( 'Hello World' )'
> > martin :( $
> > martin :( $ python ./hello_world.py
> > Hello World
> > martin :) $ python2 ./hello_world.py
> > Hello World
> > martin :) $ python3 ./hello_world.py
> > Hello World
> > martin :) $ python3.6 ./hello_world.py
> > Hello World
> > martin :) $ python hello_world.py.no_hash_pling
> > Hello World
> > martin :) $ python --version
> > Python 3.5.5
> > martin :) $ python2 --version
> > Python 2.7.15
> > martin :) $ python3 --version
> > Python 3.5.5
> > martin :) $ python3.6 --version
> > Python 3.6.5
> > martin :) $
> > martin :) $ python2
> > Python 2.7.15 (default, Sep 13 2018, 09:29:39)
> > [GCC 7.3.0] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> ./hello_world.py
> > File "<stdin>", line 1
> > ./hello_world.py
> > ^
> > SyntaxError: invalid syntax
> > >>> hello_world.py
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in <module>
> > NameError: name 'hello_world' is not defined
> > >>>
> > martin :) $ python
> > Python 3.5.5 (default, Apr 18 2018, 13:08:30)
> > [GCC 6.4.0] on linux
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> hello_world.py
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in <module>
> > NameError: name 'hello_world' is not defined
> > >>>
> > >>> exec(open("hello_world.py").read())
> > Hello World
> > >>>
> >
> > #####
> >
> >
> > The two files are attached for reference.
> >
> >
> > Hope that explains?
> >
> > Note also that in unix/linux, the filesystem and program names are case
> > sensitive! (As compared to the case insensitive world of Windows...).
> >
> >
> > Good luck!
> >
> > Cheers,
> > Martin
> >
> >
> >
> > On 12/05/2019 18:54, NIGEL Black via Nottingham wrote:
> > > nottingham at mailman.lug.org.uk mailto:nottingham at mailman.lug.org.uk
> > >
> > >> ---------- Original Message ----------
> > >> From: NIGEL Black < rnjblack at virginmedia.com mailto:rnjblack at virginmedia.com >
> > >> To: mailman-owner at mailman.lug.org.uk mailto:mailman-owner at mailman.lug.org.uk
> > >> Date: 10 May 2019 at 20:01
> > >> Subject: Thursday 16 May
> > >>
> > >> Fellow Penguins,
> > >>
> > >> 1. I might not be at the next NLUG meeting so have attached a
> > >> reference on how to dual boot Linux mint and Windows 10. It might be
> > >> of particular interest to Boris.
> > >>
> > >> https://itsfoss.com/guide-install-linux-mint-16-dual-boot-windows/
> > >> < https://itsfoss.com/guide-install-linux-mint-16-dual-boot-windows/>
> > >>
> > >> 2. I've recently started on Python programming using version 3.6.7.
> > >> Calling up python3.6 on the terminal followed by
> > >>
> > >> >>>print( 'Hello Nigel' ) works. However the editor version saved as
> > >> "hello" in a folder called Python36 doesn't.
> > >>
> > >> >>> Python36 hello
> > >> File "<stdin>", line 1
> > >> Python36 hello
> > >> ^
> > >>
> > >> SyntaxError: invalid syntax
> > >>
> > >> Do I have to set up a path to Python36? My reference book doesn't
> > >> mention that. What exactly do I have to type to get this to work?
> > >> Any polite advice welcome.
> > >>
> > >> See you soon.
> > >>
> > >> Nigel
> > >>
> > >
> > >
> > >
> > >
> >
> > --
> > Nottingham mailing list
> > Nottingham at mailman.lug.org.uk mailto:Nottingham at mailman.lug.org.uk
> > https://mailman.lug.org.uk/mailman/listinfo/nottingham
> >
> > > --
> Nottingham mailing list
> Nottingham at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/nottingham
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/nottingham/attachments/20190515/e0131742/attachment.html>
More information about the Nottingham
mailing list