[Tutor] running a .py file from the comand line

2018-04-02 Thread Rex Florian via Tutor
Hello, I am running Python 3.6 in a Window 7 environment. I have a python script that I am trying to run from the command line. The script is from a Learning to Program file demonstrating event driven programming. I have copied it to a file named Ascii Keys.py into my user directory c:\Users

Re: [Tutor] running a .py file from the comand line

2018-04-02 Thread Alan Gauld via Tutor
On 02/04/18 01:46, Rex Florian via Tutor wrote: > Hello, > > I am running Python 3.6 in a Window 7 environment. > I have a python script > that I am trying to run from the command line. > I have copied it to a file named Ascii Keys.py into my user directory > c:\Users\Rex > > I try to execute

Re: [Tutor] pythonic

2018-04-02 Thread Alan Gauld via Tutor
On 02/04/18 04:19, Steven D'Aprano wrote: > On Sun, Apr 01, 2018 at 10:58:51PM +0100, Alan Gauld via Tutor wrote: >> On01/04/18 20:20, Albert-Jan Roskam wrote: >>> fmt="%Y-%m-%d %H:%M\n" >>> f.write(now.strftime(fmt)) >>> Lately I've been using format(), which uses __format__, because I find it >>

Re: [Tutor] pythonic

2018-04-02 Thread Mats Wichmann
On 04/02/2018 02:56 AM, Alan Gauld via Tutor wrote: > On 02/04/18 04:19, Steven D'Aprano wrote: >> On Sun, Apr 01, 2018 at 10:58:51PM +0100, Alan Gauld via Tutor wrote: >>> On01/04/18 20:20, Albert-Jan Roskam wrote: fmt="%Y-%m-%d %H:%M\n" f.write(now.strftime(fmt)) Lately I've been u

Re: [Tutor] pythonic

2018-04-02 Thread David Rock
> On Mar 30, 2018, at 04:15, George Fischhof wrote: > > 2.) > argparse > > it is good, but you can write more Pythonic code using click > https://pypi.python.org/pypi/click/ > it is also Pythonic to use / know the Python ecosystem (the packages) It’s just as (if not more) pythonic to use the s

Re: [Tutor] pythonic

2018-04-02 Thread leam hall
On Mon, Apr 2, 2018 at 9:01 AM, David Rock wrote: > It’s just as (if not more) pythonic to use the standard libraries. It’s very > common in a professional environment to not have access to outside (i.e., > internet) resources. I wouldn’t venture into Pypi unless there’s something > you can’t

Re: [Tutor] pythonic

2018-04-02 Thread Steven D'Aprano
On Mon, Apr 02, 2018 at 06:49:52AM -0600, Mats Wichmann wrote: > On 04/02/2018 02:56 AM, Alan Gauld via Tutor wrote: > > On 02/04/18 04:19, Steven D'Aprano wrote: > >> On Sun, Apr 01, 2018 at 10:58:51PM +0100, Alan Gauld via Tutor wrote: > >>> On01/04/18 20:20, Albert-Jan Roskam wrote: > fmt="

Re: [Tutor] pythonic

2018-04-02 Thread Peter Otten
Steven D'Aprano wrote: > On Mon, Apr 02, 2018 at 06:49:52AM -0600, Mats Wichmann wrote: >> so since we're all learning things here, how would this play out with >> the new f-strings? > > I don't think f-strings are even a bit Pythonic. > > They look like string constants, but they're actually a

Re: [Tutor] pythonic

2018-04-02 Thread Mats Wichmann
On 04/02/2018 08:28 AM, Peter Otten wrote: > Steven D'Aprano wrote: > >> On Mon, Apr 02, 2018 at 06:49:52AM -0600, Mats Wichmann wrote: > >>> so since we're all learning things here, how would this play out with >>> the new f-strings? >> >> I don't think f-strings are even a bit Pythonic. >> >> T

Re: [Tutor] running a .py file from the comand line

2018-04-02 Thread eryk sun
On Mon, Apr 2, 2018 at 8:53 AM, Alan Gauld via Tutor wrote: > > Try > > python c:\Users\Rex\"ascii keys.py" > > Note the quotes to cater for the space. > >> python: can't open file 'Ascii': [errno2] no such file or directory > > The space confuses windows CMD, so it thinks you have > two files c

Re: [Tutor] running a .py file from the comand line

2018-04-02 Thread Mats Wichmann
On 04/02/2018 11:41 AM, eryk sun wrote: > On Mon, Apr 2, 2018 at 8:53 AM, Alan Gauld via Tutor wrote: >> >> Try >> >> python c:\Users\Rex\"ascii keys.py" >> >> Note the quotes to cater for the space. >> >>> python: can't open file 'Ascii': [errno2] no such file or directory >> >> The space confu

[Tutor] Python help

2018-04-02 Thread Shannon Evans via Tutor
Hi, I am trying to write a code with if statements but the code keeps just repeating and not carrying on. I am trying to get user to input a grade, either A, B, C, D, E or F and trying to have an error message if anything but these values are inputted. This is what i've wrote so far: while True:

Re: [Tutor] pythonic

2018-04-02 Thread Steven D'Aprano
On Mon, Apr 02, 2018 at 04:28:10PM +0200, Peter Otten wrote: > > They look like string constants, but they're actually a hidden call to > > eval(). > > But because you cannot f-ify a string variable (without an additional eval() > call) you aren't tempted to feed them user-provided data. If onl

Re: [Tutor] Python help

2018-04-02 Thread Steven D'Aprano
On Mon, Apr 02, 2018 at 11:44:39PM +0100, Shannon Evans via Tutor wrote: > Hi, I am trying to write a code with if statements but the code keeps just > repeating and not carrying on. > I am trying to get user to input a grade, either A, B, C, D, E or F and > trying to have an error message if anyth

Re: [Tutor] Python help

2018-04-02 Thread Alan Gauld via Tutor
On 02/04/18 23:44, Shannon Evans via Tutor wrote: > Hi, I am trying to write a code with if statements but the code keeps just > repeating and not carrying on. There are quite a few problems here, see comments below. > while True: > try: > Grade = int(raw_input("Please enter your Grad

Re: [Tutor] Python help

2018-04-02 Thread Steven D'Aprano
On Tue, Apr 03, 2018 at 01:00:59AM +0100, Alan Gauld via Tutor wrote: > You need to use 'in' instead. That will check whether > or not Grade is *one* of the values in the tuple. > > if Grade not in 'A','B','C','D','E','F': Actually, that returns a tuple consisting of a flag plus five more s

Re: [Tutor] Python help

2018-04-02 Thread Alan Gauld via Tutor
On 03/04/18 01:19, Steven D'Aprano wrote: > On Tue, Apr 03, 2018 at 01:00:59AM +0100, Alan Gauld via Tutor wrote: > >> You need to use 'in' instead. That will check whether >> or not Grade is *one* of the values in the tuple. >> >> if Grade not in 'A','B','C','D','E','F': > Actually, that retur

Re: [Tutor] Python help

2018-04-02 Thread Alan Gauld via Tutor
On 03/04/18 01:19, Steven D'Aprano wrote: > >> if Grade not in 'A','B','C','D','E','F': > Actually, that returns a tuple consisting of a flag plus five more > strings: > > py> 'A' in 'A','B','C', 'D', 'E', 'F' > (True, 'B','C', 'D', 'E', 'F') Although in the context of the program the colon a