From chigga101 at gmail.com  Mon Sep  2 14:36:47 2019
From: chigga101 at gmail.com (Matthew Ngaha)
Date: Mon, 2 Sep 2019 19:36:47 +0100
Subject: [Tutor] Noob seeking help (Linux related)
Message-ID: <CACzNyA2ZDE7=M+KXK751ypCq4Dq1Ov6f_8B=jYM5M5gVVLFd_A@mail.gmail.com>

I'm thinking about installing openSuse Linux. They have 2 versions
available. 1) Leap (A stable release) 2) Tumbleweed (A rolling
release). Stable means all software remains the same and does not get
upgraded. To upgrade you need some proficiency in Linux. So if you
have Python 3.5 you will have to upgrade yourself and I hear this
might not be safe. Rolling release means the repositories are updated
constantly and if you run a command on the command line your OS will
be updated where by all the software installed on your computer gets
automatically upgraded to match the repositories.

Okay with that out of the way, and as a Python user, I need advise on
which to get and which is better for a developer (beginner noob with
little Linux experience). I will mainly use Python and Django. Django
releases new versions really regularly and these newer versions stop
supporting older Python versions. so if I get Leap (stable version)
there will come a time where I will need to update Python, or get
stuck with an out of date Django version. I won't have this trouble if
I install Tumbleweed (rolling release) as Python will be updated but
my concern is if I write code for say Python 3.6 or 3.7 then months
later 3.8 comes out, will it break my code or is porting over code
fairly easy to do?

Lastly, someone I asked said something about virtualenv. If my OS has
Python 3.6, can that same OS without updating Python use virtualenv to
install Python 3.7, even though the installed Python on the system is
Python 3.6?

Please put yourself in my shoes and tell me which OS out of the 2 is
better for me or a developer.

Thanks and all the best.

From mats at wichmann.us  Mon Sep  2 16:08:09 2019
From: mats at wichmann.us (Mats Wichmann)
Date: Mon, 2 Sep 2019 14:08:09 -0600
Subject: [Tutor] Noob seeking help (Linux related)
In-Reply-To: <CACzNyA2ZDE7=M+KXK751ypCq4Dq1Ov6f_8B=jYM5M5gVVLFd_A@mail.gmail.com>
References: <CACzNyA2ZDE7=M+KXK751ypCq4Dq1Ov6f_8B=jYM5M5gVVLFd_A@mail.gmail.com>
Message-ID: <584c2000-af44-3549-cc2e-5d5543d8684f@wichmann.us>

On 9/2/19 12:36 PM, Matthew Ngaha wrote:
> I'm thinking about installing openSuse Linux. They have 2 versions
> available. 1) Leap (A stable release) 2) Tumbleweed (A rolling
> release). Stable means all software remains the same and does not get
> upgraded. To upgrade you need some proficiency in Linux. So if you
> have Python 3.5 you will have to upgrade yourself and I hear this
> might not be safe.

Just don't replace the system Python and everything's fine.  It's easy
enough to pull whatever version you want to work with and install it in
some suitable place.

> Rolling release means the repositories are updated
> constantly and if you run a command on the command line your OS will
> be updated where by all the software installed on your computer gets
> automatically upgraded to match the repositories.
> 
> Okay with that out of the way, and as a Python user, I need advise on
> which to get and which is better for a developer (beginner noob with
> little Linux experience). I will mainly use Python and Django. Django
> releases new versions really regularly and these newer versions stop
> supporting older Python versions. so if I get Leap (stable version)
> there will come a time where I will need to update Python, or get
> stuck with an out of date Django version. I won't have this trouble if
> I install Tumbleweed (rolling release) as Python will be updated but
> my concern is if I write code for say Python 3.6 or 3.7 then months
> later 3.8 comes out, will it break my code or is porting over code
> fairly easy to do?
> 
> Lastly, someone I asked said something about virtualenv. If my OS has
> Python 3.6, can that same OS without updating Python use virtualenv to
> install Python 3.7, even though the installed Python on the system is
> Python 3.6?

See above.

I use a package called pyenv to help manage lots of versions of Python,
works for me but isn't the only solution out there.

$ pyenv install --list    # all the available versions (*)
$ pyenv install 3.7.4     # pick one
$ pyenv virtualenv 3.7.4 mypy374   # create a virtualenv from it
$ pyenv activate mypy374  # start the virtualenv
$ python -m pip install django     # theoretical: there are actually
many Django pieces

https://github.com/pyenv/pyenv
https://github.com/pyenv/pyenv-installer

and a useful offsite tutorial:
https://realpython.com/intro-to-pyenv/

(*) note these versions are actually recipes to build, pyenv will
arrange to compile the python using the recipe. Just glanced at the
tutorial and it talks more about this.

> Please put yourself in my shoes and tell me which OS out of the 2 is
> better for me or a developer.

Not gonna tell you that, because we still can't know which is better for
your case, it depends on many more factors.  Using an isolated
environment for Python and Django should protect you from whatever the
distribution is doing.  There was a time in the past I would have
suggested a newcomer to always use something more stable but people
doing rolling distributions, and build-your-own distributions, and other
variants that keep changing, have gotten quite good at making it go
smoothly so as long as you can arrange your key work not to be
disrupted, either way could work.  You can even do both.... install the
stable version, make a virtual machine and install the rolling version
in it and you can test things both ways if you have something you're
worried about.





From aishan0403 at gmail.com  Wed Sep  4 10:39:02 2019
From: aishan0403 at gmail.com (A S)
Date: Wed, 4 Sep 2019 22:39:02 +0800
Subject: [Tutor] How to only read words within brackets/ parentheses (in
 .txt file) using Python
Message-ID: <CAD=0mP_8wWh6B2LL=FcMRTt2XFz=vGB+477SnTsXYbdeCJuguw@mail.gmail.com>

Hi there,

I am not sure if this page is active. But I came across this page and
thought I'd like to give it a go. Hope to hear from you soon, thank you:)

I understand that reading lines in .txt files would look something like
this in Python:

with open('filename','r') as fd:
   lines = fd.readlines()

However, how do I run my code to only read the words in my .txt files that
are within each balanced parenthesis?

I am not sure how to go about this problem but here is a sample of my .txt
file contents:

kkkkk;

select xx("xE'", PUT(xx.xxxx.),"'") jdfjhf:jhfjj from xxxx_x_xx_L ;
quit;
/* 1.xxxxx FROM xxxx_x_Ex_x */
proc sql; "TRUuuuth");
hhhjhfjs as fdsjfsj:
select * from djfkjd to jfkjs(SELECT abc AS abc1, abc_2_ AS efg,
abc_fg, fkdkfj_vv, jjsflkl_ff, fjkdsf_jfkj
FROM &xxx..xxx_xxx_xxE
   where (xxx(xx_ix as format 'xxxx-xx') gff &jfjfsj_jfjfj.) and
  (xxx(xx_ix as format 'xxxx-xx') lec &jgjsd_vnv.));

From joffrey.schilling at hotmail.com  Wed Sep  4 06:11:10 2019
From: joffrey.schilling at hotmail.com (Joffrey Schilling)
Date: Wed, 4 Sep 2019 10:11:10 +0000
Subject: [Tutor] python3 is not recognized
Message-ID: <AM6PR05MB5379D492B5D04AD5FFE70D28FBB80@AM6PR05MB5379.eurprd05.prod.outlook.com>

Hi


I am trying to get a robot to follow and unfollow instagram users.

After downloading Atom and the robot at https://github.com/instabot-py/instabot.py I ve coded :
C:\Users\Asus\Documents\Logiciels\instabot.py-master
pip3 install --upgrade pip
pip3 install -e .
python3 run.py

Then fort he last line I ve got : 'python3' is not recognized as an internal or external command.
Could you help me please?

King regards


Schilling Joffrey

+33.6.21.399.714

From alan.gauld at btinternet.com  Wed Sep  4 13:29:49 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Wed, 4 Sep 2019 18:29:49 +0100
Subject: [Tutor] How to only read words within brackets/ parentheses (in
 .txt file) using Python
In-Reply-To: <CAD=0mP_8wWh6B2LL=FcMRTt2XFz=vGB+477SnTsXYbdeCJuguw@mail.gmail.com>
References: <CAD=0mP_8wWh6B2LL=FcMRTt2XFz=vGB+477SnTsXYbdeCJuguw@mail.gmail.com>
Message-ID: <12ed9959-1c8d-d46b-6584-11c7491a3cd9@btinternet.com>

On 04/09/2019 15:39, A S wrote:
> Hi there,
>
> I am not sure if this page is active. 

I'm not sure what "page" you are looking at, but this is a mailing list
although it is archived on several web sites etc.

It is alive although we did have a technical hitch last week which
disrupted service for a few days.


> I understand that reading lines in .txt files would look something like
> this in Python:
>
> with open('filename','r') as fd:
>    lines = fd.readlines()
>
> However, how do I run my code to only read the words in my .txt files that
> are within each balanced parenthesis?


Normally you'd store the line ina variable and then process the line
to extract what you want. That could be by using string searches/splits,
or regular expressions or it may require a more powerful parser


If the pattern you want spans lines and especially if it can be nested
then a parser might be the best solution..


> kkkkk;
>
> select xx("xE'", PUT(xx.xxxx.),"'") jdfjhf:jhfjj from xxxx_x_xx_L ;
> quit;
> /* 1.xxxxx FROM xxxx_x_Ex_x */
> proc sql; "TRUuuuth");
> hhhjhfjs as fdsjfsj:
> select * from djfkjd to jfkjs(SELECT abc AS abc1, abc_2_ AS efg,
> abc_fg, fkdkfj_vv, jjsflkl_ff, fjkdsf_jfkj
> FROM &xxx..xxx_xxx_xxE
>    where (xxx(xx_ix as format 'xxxx-xx') gff &jfjfsj_jfjfj.) and
>   (xxx(xx_ix as format 'xxxx-xx') lec &jgjsd_vnv.));

Its good to see the data but what is not clear is what you want that data
to produce. Can you also show us what output "words" you expect to see?

For example in the first select line the first opening paren doesn't find a
matching close until the 3rd line down. And inside that pair there is
the PUT(...) clause. How should that be handled?
What constitutes words here?

And what should happen to the text that is not in parens?

like the opening kkkk;?


-- 

Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From mats at wichmann.us  Wed Sep  4 13:43:57 2019
From: mats at wichmann.us (Mats Wichmann)
Date: Wed, 4 Sep 2019 11:43:57 -0600
Subject: [Tutor] python3 is not recognized
In-Reply-To: <AM6PR05MB5379D492B5D04AD5FFE70D28FBB80@AM6PR05MB5379.eurprd05.prod.outlook.com>
References: <AM6PR05MB5379D492B5D04AD5FFE70D28FBB80@AM6PR05MB5379.eurprd05.prod.outlook.com>
Message-ID: <8ebbdfc2-13fa-e7e6-0fde-725862d099bc@wichmann.us>

On 9/4/19 4:11 AM, Joffrey Schilling wrote:
> Hi
> 
> 
> I am trying to get a robot to follow and unfollow instagram users.
> 
> After downloading Atom and the robot at https://github.com/instabot-py/instabot.py I ve coded :
> C:\Users\Asus\Documents\Logiciels\instabot.py-master
> pip3 install --upgrade pip
> pip3 install -e .
> python3 run.py
> 
> Then fort he last line I ve got : 'python3' is not recognized as an internal or external command.
> Could you help me please?

Do you have Python 3 installed?

Most Windows Python problems are path related, assuming you've installed
Python at all. If it isn't installed, that's the reason for your error.
If it is installed, it's paths.  On windows, the command usually doesn't
end up named "python3" even if it is Python 3, so the page you're
looking at may have been written from a Linux viewpoint, and you'll have
to mentally adjust.

On Windows you should, when you install Python, let it install the
Python launcher, a tool letting you run Python with a single command
even if you have several versions, if Python was installed without also
setting it in the system PATH environment variable, if it got installed
in a non-standard place, etc.

Your steps above should then look like this:


py --version

:: stop there if you don't get an expected answer, things aren't
installed right. Fix, restart.

py -m pip install --upgrade pip
py -m pip install -e .
py run.py


In other words, use "py" wherever docs say "python" or "python3".
Use "py -m pip [commands]" wherever docs say "pip [commands]" or "pip3
[commands]".



From alan.gauld at btinternet.com  Wed Sep  4 13:22:01 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Wed, 4 Sep 2019 18:22:01 +0100
Subject: [Tutor] python3 is not recognized
In-Reply-To: <AM6PR05MB5379D492B5D04AD5FFE70D28FBB80@AM6PR05MB5379.eurprd05.prod.outlook.com>
References: <AM6PR05MB5379D492B5D04AD5FFE70D28FBB80@AM6PR05MB5379.eurprd05.prod.outlook.com>
Message-ID: <28f86b07-ae81-646f-7265-9900c86e7d01@btinternet.com>

On 04/09/2019 11:11, Joffrey Schilling wrote:
> python3 run.py
>
> Then fort he last line I ve got : 'python3' is not recognized as an internal or external command.

That suggests Python3 is either not installed or not on your PATH.

It looks like you are using Windows, in which case the recommended way
of running Python is
to use the Python launcher program py.exe. I'm not a regular Windows
python user so I can't
help with that, but googling for py.exe might help.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From eryksun at gmail.com  Wed Sep  4 15:15:20 2019
From: eryksun at gmail.com (Eryk Sun)
Date: Wed, 4 Sep 2019 14:15:20 -0500
Subject: [Tutor] python3 is not recognized
In-Reply-To: <AM6PR05MB5379D492B5D04AD5FFE70D28FBB80@AM6PR05MB5379.eurprd05.prod.outlook.com>
References: <AM6PR05MB5379D492B5D04AD5FFE70D28FBB80@AM6PR05MB5379.eurprd05.prod.outlook.com>
Message-ID: <CACL+1asOXOTeM9hr0X=NeLbivjbC1KdQSrKyAN-NxOf-OaROpQ@mail.gmail.com>

On 9/4/19, Joffrey Schilling <joffrey.schilling at hotmail.com> wrote:
> Hi
>
>
> I am trying to get a robot to follow and unfollow instagram users.
>
> After downloading Atom and the robot at
> https://github.com/instabot-py/instabot.py I ve coded :
> C:\Users\Asus\Documents\Logiciels\instabot.py-master
> pip3 install --upgrade pip
> pip3 install -e .
> python3 run.py

The standard installation of Python only has python.exe and
pythonw.exe. It does not include python3.exe, pythonw3.exe,
python3.7.exe, or pythonw3.7.exe. venv virtual environments also do
not include executable files or links with these names. On the other
hand, the Windows 10 app distribution that's available in the
Microsoft Store does include appexec links with these names.

As others have suggested, the most reliable way to run a particular,
registered installation of Python in Windows is via the py.exe
launcher, or pyw.exe if you don't want a console window. This takes a
-X[.Y][-32|-64] option to specify the version to run. `py -h` lists
all available options.

To run the highest available version of Python 3, use `py -3`. To run
Python 3.7, if it's installed, use `py -3.7`.  If you need 32-bit for
some reason, and have a 32-bit Python 3 installed, run `py -3-32`. To
list available versions, run `py -0`, or `py -0p` to include the
executable paths in the list.

The default version for py.exe can be set in the PY_PYTHON environment
variable -- e.g. `PY_PYTHON=3.7-32`. To set the default specifically
for the -2 and -3 options, set `PY_PYTHON2` and `PY_PYTHON3`,
respectively.

From alan.gauld at btinternet.com  Tue Sep  3 17:31:14 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Tue, 3 Sep 2019 22:31:14 +0100
Subject: [Tutor] Comparison code (was blank)
In-Reply-To: <CAFTUiY5ZHjwFn2VH8oKCiYqNwAfaOAtAa3r4k7ZvWUL4KmsdSw@mail.gmail.com>
References: <CAFTUiY5ZHjwFn2VH8oKCiYqNwAfaOAtAa3r4k7ZvWUL4KmsdSw@mail.gmail.com>
Message-ID: <9a999a19-8769-b8bc-ced1-31057fdedd80@btinternet.com>

Please provide a subject line - it helps in the archive!
Also provide a question, don;t make us guess what you want
to know. It may be obvious to you but its bot to us and we
don't have time to examine it in minute detail just in case.

That said, here are some general comments below...


On 03/09/2019 15:38, super ball xy wrote:
>
> n1 = int (input())
> n2 = int (input())
> n3 = int (input())
> if n1 > n2 and n1 > n3:
> ??? print (n1,"es el mayor")
> if n2 > n1 and n2 > n3:
> ??? print (n2,"es el mayor")
> if n3 > n1 and n2 > n2:
>
I think the last one should be n3 > n2?? ???

> ??? print (n3,"es el mayor")
> if n1 < n2 and n1 < n3:
> ??? print (n1,"es el menor")
> if n2 < n1 and n2 < n3:
> ??? print (n2,"es el menor")
> if n3 < n1 and n2 < n2:
> ??? print (n3,"es el menor")
>
You could have used the max and min functions to do the same job:

data = (n1,n2,n3)

print( "The biggest is: ", max(data) )

print("The smallest is:", min(data) )




> if n1>n2 and n1>n3:
> ??? n1 = a
>
I think you mean


a = n1

You can't assign a to n1 because a doesn't have a value yet!


> if n2>n1 and n2>n3:
> ??? n2 = a
> if n3>n1 and n3>n2:
> ??? n3 = a
> if n1<n2 and n1<n3:
> ??? n1 = b
> if n2<n1 and n2<n3:
> ??? n2 = b
> if n3<n1 and n3<n2:
> ??? n3 = b
>

Same for the above. But you could have done this in the
first set of comparisons. No need to go through them
all a second time.


> print ("la suma de" ,a, "+" ,b, "=" ,a+b,
> print ("la multiplicaci?n de" ,a, "x" ,b, "=" ,a*b,
> print ("la potencia de" ,a, "sobre" ,b, "=" ,a**b,
>

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From alan.gauld at btinternet.com  Mon Sep  2 19:57:24 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Tue, 3 Sep 2019 00:57:24 +0100
Subject: [Tutor] Noob seeking help (Linux related)
In-Reply-To: <CACzNyA2ZDE7=M+KXK751ypCq4Dq1Ov6f_8B=jYM5M5gVVLFd_A@mail.gmail.com>
References: <CACzNyA2ZDE7=M+KXK751ypCq4Dq1Ov6f_8B=jYM5M5gVVLFd_A@mail.gmail.com>
Message-ID: <ce07e087-79bf-4c2d-49d8-1f8f5c2db25e@btinternet.com>

On 02/09/2019 19:36, Matthew Ngaha wrote:
> I'm thinking about installing openSuse Linux.


I have not used Suse in over 10 years but I suspect they follow
the model of other distros...


>  They have 2 versions
> available. 1) Leap (A stable release) 2) Tumbleweed (A rolling
> release). Stable means all software remains the same and does not get
> upgraded. 

Usually its not quite that hard and fast. You do get security upgrades
for example.

And the repositories will be updated just not necessarily installed.

Personally I take a very conservative approach to software updates. I only
install updates if I know I need them. I'm still running Python 3.6 for
example
not having seen anything in 3.7 that I need.

I also run a LTS version of Mint. LTS is like an ultra stable version so
updates are even more belated,? but frankly things don't change
that much. I'm still running Python 3.5 on my netbook and I haven't
broken anything yet.



> To upgrade you need some proficiency in Linux. So if you
> have Python 3.5 you will have to upgrade yourself and I hear this
> might not be safe. 

It should be a case of setting your software manager to point at the
right site
and simply letting it get on with it. Provided you don't want to be on
the bleeding
edge there shouldn't be any problem.

> Rolling release means the repositories are updated
> constantly and if you run a command on the command line your OS will
> be updated where by all the software installed on your computer gets
> automatically upgraded to match the repositories.

You can usually use a GUI tool too if you aren't keen on CLIs.


> which to get and which is better for a developer (beginner noob with
> little Linux experience). 
Only you can know for sure. Do you do any work that might be lost if an
upgrade went wrong? If so be more cautious. If? you do all your real work
on a server then it doesn't matter too much. If its just for fun/personal
use then you can probably afford to live on the edge.


> my concern is if I write code for say Python 3.6 or 3.7 then months
> later 3.8 comes out, will it break my code or is porting over code
> fairly easy to do?

Python usually only issues one major upgrade per year and most tools will
support at least 2 older versions (I don't know about Django but I'd be
amazed if they didn't support at least 2 versions.) So you should be good
for well over a year, if not more. Certainly more than a "few months".


> Lastly, someone I asked said something about virtualenv. If my OS has
> Python 3.6, can that same OS without updating Python use virtualenv to
> install Python 3.7, even though the installed Python on the system is
> Python 3.6?

Yes, that's kind of the idea of virtual envs.

That said I don't use them and still have both 3.6 and 2.7 installed on
my PC.

Seems to be working just fine. In the worst case I tweak the PYTHONPATH
environment value.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From chris_roysmith at internode.on.net  Thu Sep  5 02:45:11 2019
From: chris_roysmith at internode.on.net (Chris Roy-Smith)
Date: Thu, 5 Sep 2019 16:45:11 +1000
Subject: [Tutor] problem clearing a text widget
Message-ID: <bc19fc80-bc59-2aea-ff5c-97fd0e480b76@internode.on.net>

Hi
setup: python 3.6.8, OS Linux (ubuntu 18.04)

I have been trying to clear a text widget using the delete method, but I 
only get the traceback below, when I click on delete button. I get this 
message irrespective of how much text I have put into it. I'm missing 
something, but I can't figure out what. Please can somebody point me in 
the right direction?

regards, Chris Roy-Smith

==============================================================
chris at chris-X451MA:~/Scripts/python3/experiments$ ./text.py
Exception in Tkinter callback
Traceback (most recent call last):
   File "/usr/lib/python3.6/tkinter/__init__.py", line 1705, in __call__
     return self.func(*args)
   File "./text.py", line 11, in DeleteText
     tfield.delete(0,END)
   File "/usr/lib/python3.6/tkinter/__init__.py", line 3139, in delete
     self.tk.call(self._w, 'delete', index1, index2)
_tkinter.TclError: bad text index "0"

=================================================================

code

#! /usr/bin/python3
'''
demo for text widget delete method
'''
from tkinter import *

def InsertText():
     tfield.insert(END,"Demo only\n")

def DeleteText():
     tfield.delete(0,END)

master=Tk()

tfield = Text(master, height=15, width=60)
S=Scrollbar(master)
tfield.configure(yscrollcommand=S.set)
S.configure(command=tfield.yview)
S.grid(row=0, column=2)
tfield.grid(row=0, column=0, columnspan=2)
S.config(command=tfield.yview)
tfield.config(yscrollcommand=S.set)

Button(master, text="Insert", command=InsertText).grid(row=5, column=0)
Button(master, text="Delete", command=DeleteText).grid(row=5, column=1)
Button(master, text="Exit", command=master.destroy).grid(row=5, column=2)

master.mainloop()

From chris_roysmith at internode.on.net  Thu Sep  5 02:51:02 2019
From: chris_roysmith at internode.on.net (Chris Roy-Smith)
Date: Thu, 5 Sep 2019 16:51:02 +1000
Subject: [Tutor] problem clearing a text widget
In-Reply-To: <bc19fc80-bc59-2aea-ff5c-97fd0e480b76@internode.on.net>
References: <bc19fc80-bc59-2aea-ff5c-97fd0e480b76@internode.on.net>
Message-ID: <4b27a11e-295a-cb67-d042-b0a096fc2d98@internode.on.net>

On 5/9/19 4:45 pm, Chris Roy-Smith wrote:
> Hi
> setup: python 3.6.8, OS Linux (ubuntu 18.04)
> 
> I have been trying to clear a text widget using the delete method, but I 
> only get the traceback below, when I click on delete button. I get this 
> message irrespective of how much text I have put into it. I'm missing 
> something, but I can't figure out what. Please can somebody point me in 
> the right direction?
> 
> regards, Chris Roy-Smith
> 
> ==============================================================
> chris at chris-X451MA:~/Scripts/python3/experiments$ ./text.py
> Exception in Tkinter callback
> Traceback (most recent call last):
>  ? File "/usr/lib/python3.6/tkinter/__init__.py", line 1705, in __call__
>  ??? return self.func(*args)
>  ? File "./text.py", line 11, in DeleteText
>  ??? tfield.delete(0,END)
>  ? File "/usr/lib/python3.6/tkinter/__init__.py", line 3139, in delete
>  ??? self.tk.call(self._w, 'delete', index1, index2)
> _tkinter.TclError: bad text index "0"
> 
> =================================================================
> 
> code
> 
> #! /usr/bin/python3
> '''
> demo for text widget delete method
> '''
> from tkinter import *
> 
> def InsertText():
>  ??? tfield.insert(END,"Demo only\n")
> 
> def DeleteText():
>  ??? tfield.delete(0,END)
> 
> master=Tk()
> 
> tfield = Text(master, height=15, width=60)
> S=Scrollbar(master)
> tfield.configure(yscrollcommand=S.set)
> S.configure(command=tfield.yview)
> S.grid(row=0, column=2)
> tfield.grid(row=0, column=0, columnspan=2)
> S.config(command=tfield.yview)
> tfield.config(yscrollcommand=S.set)
> 
> Button(master, text="Insert", command=InsertText).grid(row=5, column=0)
> Button(master, text="Delete", command=DeleteText).grid(row=5, column=1)
> Button(master, text="Exit", command=master.destroy).grid(row=5, column=2)
> 
> master.mainloop()
> _______________________________________________
> Tutor maillist? -? Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
> 
Never mind, the penny just dropped! The zero should be "0.0".

regards, Chris Roy-Smith

From sfrazier8689 at gmail.com  Sat Sep  7 08:22:44 2019
From: sfrazier8689 at gmail.com (Sean Frazier)
Date: Sat, 7 Sep 2019 14:22:44 +0200
Subject: [Tutor] Please Help
Message-ID: <5d73a112.1c69fb81.7c68.24ee@mx.google.com>

I am running a problem in 'Think Python' and was having no issues with:

fin = open('words.txt') 

Then when I was working with the reference file, running a function, my IDLE crashed and is no longer able to locate files using [var = open('file.txt')]

I have tried opening as 'r' and 'w', with no luck.

Also, sometimes I do not get an error, but when I go to read the list, it is empty ''.

Fixes Tried:

Repairing Python
Uninstalled and reinstalled python
Using the path to the file in the code
Designating ?r? and ?w?
Installed Eclipse and placed the file.txt in the workspace folder



Thank you for helping in advance. This is most certainly not a bug in Python and should just be user error.

-Sean


Sent from Mail for Windows 10


From alan.gauld at btinternet.com  Sat Sep  7 14:47:29 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Sat, 7 Sep 2019 19:47:29 +0100
Subject: [Tutor] Please Help
In-Reply-To: <5d73a112.1c69fb81.7c68.24ee@mx.google.com>
References: <5d73a112.1c69fb81.7c68.24ee@mx.google.com>
Message-ID: <bda5c7f5-7b32-f4aa-2166-9c8e6448520b@btinternet.com>

On 07/09/2019 13:22, Sean Frazier wrote:
> Then when I was working with the reference file, running a function, my IDLE crashed and is no longer able to locate files using [var = open('file.txt')]
>
> I have tried opening as 'r' and 'w', with no luck.
>
> Also, sometimes I do not get an error, but when I go to read the list, it is empty ''.

Start with basic investigations.


Check the path. What does:


>>> import os

>>> os.getcwd()

>>> os.listdir('.')

Produce?

Is it the folder with your fdile in it - does it appear in the listdir()
result?

If so then open the file with an ordinary text editor (or IDLE) and see
what it holds.
Is it corrupted?

What are the file permissions? Do they allow you to read/write etc?


If everything looks OK at this stage then try opening the file the old
shool way:


f = open(fname)

try examining the file objects attributes.

Try reading a single line. What do you get back?

Does it match ghe results using the text editor?


That should suffice to start with,. IF nothing shows up that explains
things
then let us know what you found.

A cut 'n paste of the session will be helpful...


-- 

Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From david at lowryduda.com  Sat Sep  7 14:48:58 2019
From: david at lowryduda.com (David Lowry-Duda)
Date: Sat, 7 Sep 2019 14:48:58 -0400
Subject: [Tutor] Please Help
In-Reply-To: <5d73a112.1c69fb81.7c68.24ee@mx.google.com>
References: <5d73a112.1c69fb81.7c68.24ee@mx.google.com>
Message-ID: <20190907184858.GA25061@mail.lowryduda.com>

On Sat, Sep 07, 2019 at 02:22:44PM +0200, Sean Frazier wrote:
> I am running a problem in 'Think Python' and was having no issues with:
> fin = open('words.txt')
> Then when I was working with the reference file, running a function, 
> my IDLE crashed and is no longer able to locate files using [var = 
> open('file.txt')]
> 
> I have tried opening as 'r' and 'w', with no luck.
> 
> Also, sometimes I do not get an error, but when I go to read the list, 
> it is empty ''.

I wonder whether or not you have deleted or emptied the file `file.txt`. 
Have you tried opening it in a text editor to see if it still has 
content?

David Lowry-Duda

From mats at wichmann.us  Sat Sep  7 15:25:58 2019
From: mats at wichmann.us (Mats Wichmann)
Date: Sat, 7 Sep 2019 13:25:58 -0600
Subject: [Tutor] Please Help
In-Reply-To: <5d73a112.1c69fb81.7c68.24ee@mx.google.com>
References: <5d73a112.1c69fb81.7c68.24ee@mx.google.com>
Message-ID: <88628c36-2f14-a358-bdd2-14ee324b5ab9@wichmann.us>

On 9/7/19 6:22 AM, Sean Frazier wrote:
> I am running a problem in 'Think Python' and was having no issues with:

[var = open('file.txt')]

> I have tried opening as 'r' and 'w', with no luck.
> 
> Also, sometimes I do not get an error, but when I go to read the list, it is empty ''.


what you have written is invalid - you are trying to do an assignment
inside a list specifier, Python's syntax doesn't allow that.

I'm guessing the brackets were just for emphasis for the email, but it
helps when asking questions if you're really precise!!!


From eryksun at gmail.com  Sat Sep  7 17:03:44 2019
From: eryksun at gmail.com (Eryk Sun)
Date: Sat, 7 Sep 2019 16:03:44 -0500
Subject: [Tutor] Please Help
In-Reply-To: <88628c36-2f14-a358-bdd2-14ee324b5ab9@wichmann.us>
References: <5d73a112.1c69fb81.7c68.24ee@mx.google.com>
 <88628c36-2f14-a358-bdd2-14ee324b5ab9@wichmann.us>
Message-ID: <CACL+1aussedx5dM+NAOOn5-MoH8RVEFLP87xP960kaBdwXT0tQ@mail.gmail.com>

On 9/7/19, Mats Wichmann <mats at wichmann.us> wrote:
> On 9/7/19 6:22 AM, Sean Frazier wrote:
>>
>> > [var = open('file.txt')]
>
> what you have written is invalid - you are trying to do an assignment
> inside a list specifier, Python's syntax doesn't allow that.

True, since the above is using the regular assignment operator (=) for
an assignment statement. However, starting with 3.8, it's no longer
the case that all assignment is disallowed in expressions. We now have
the walrus operator (:=) for assignment *expressions*. Thus, now for
something completely different:

    >>> files = [spam := open('spam.txt'), eggs := open('eggs.txt')]
    >>> spam.name, eggs.name
    ('spam.txt', 'eggs.txt')

From mats at wichmann.us  Sat Sep  7 17:32:59 2019
From: mats at wichmann.us (Mats Wichmann)
Date: Sat, 7 Sep 2019 15:32:59 -0600
Subject: [Tutor] Please Help
In-Reply-To: <CACL+1aussedx5dM+NAOOn5-MoH8RVEFLP87xP960kaBdwXT0tQ@mail.gmail.com>
References: <5d73a112.1c69fb81.7c68.24ee@mx.google.com>
 <88628c36-2f14-a358-bdd2-14ee324b5ab9@wichmann.us>
 <CACL+1aussedx5dM+NAOOn5-MoH8RVEFLP87xP960kaBdwXT0tQ@mail.gmail.com>
Message-ID: <9f3778a2-64b3-28d1-5811-a64c5f6228a6@wichmann.us>

On 9/7/19 3:03 PM, Eryk Sun wrote:
> On 9/7/19, Mats Wichmann <mats at wichmann.us> wrote:
>> On 9/7/19 6:22 AM, Sean Frazier wrote:
>>>
>>>> [var = open('file.txt')]
>>
>> what you have written is invalid - you are trying to do an assignment
>> inside a list specifier, Python's syntax doesn't allow that.
> 
> True, since the above is using the regular assignment operator (=) for
> an assignment statement. However, starting with 3.8, it's no longer
> the case that all assignment is disallowed in expressions. We now have
> the walrus operator (:=) for assignment *expressions*. Thus, now for
> something completely different:
> 
>     >>> files = [spam := open('spam.txt'), eggs := open('eggs.txt')]
>     >>> spam.name, eggs.name
>     ('spam.txt', 'eggs.txt')

yeah, and I'm looking forward to using this... once I get myself off of
projects that try to carry compat for a whole bunch of older Python
versions, that is :)



From aishan0403 at gmail.com  Sun Sep  8 12:05:50 2019
From: aishan0403 at gmail.com (A S)
Date: Mon, 9 Sep 2019 00:05:50 +0800
Subject: [Tutor] Finding lines in .txt file that contain keywords from two
 different set()
Message-ID: <CAD=0mP9MtG=pTKmQmaZNdZOgXjjV7nJED=5SOAWHhshbGFgPYQ@mail.gmail.com>

Hi,

My problem is seemingly profound but I hope to make it sound as simplified
as possible.....Let me unpack the details..:

*1*. I have one folder of Excel (.xlsx) files that serve as a data
dictionary.

-In Cell A1, the data source name is written in between brackets

-In Cols C:D, it contains the data field names (It could be in either col C
or D in my actual Excel sheet. So I had to search both columns

-*Important: I need to know which data source the field names come from

*2*. I have another folder of Text (.txt) files that I need to parse
through to find these keywords.

These are the folders used for a better reference here. The files are found
in the folder
<https://drive.google.com/open?id=1_LcceqcDhHnWW3Nrnwf5RkXPcnDfesq_>

This is the code I have thus far...:

import os, sysfrom os.pathimport joinimport reimport xlrdfrom xlrd
import open_workbookimport openpyxlfrom openpyxl.reader.excel import
load_workbookimport xlsxwriter

#All the paths
dict_folder = 'C:/Users/xxxx/Documents/xxxx/Test Excel'
text_folder = 'C:/Users/xxxx/Documents/xxxx/Text'

words = set()
fieldset = set()for file in os.listdir(dict_folder):if file.endswith(".xlsx"):
    wb1 = load_workbook(join(dict_folder, file), data_only = True)
    ws = wb1.active
   #Here I am reading and printing all the data source names
set(words) in the excel dictionaries:
    cellvalues = ws["A1"].value
    wordsextract = re.findall(r"\((.+?)\)", str(cellvalues))
    results = wordsextract[0]
    words.add(results)
    print(results)

    for rowofcellobj in ws["C" : "D"]:
        for cellobj in rowofcellobj:
           #2. Here I am printing all the field names in col C & D in
the excel dictionaries:
            data = re.findall(r"\w+_.*?\w+", str(cellobj.value))
            if data != []:
                fields = data[0]
                fieldset.add(fields)
                print(fieldset)
                #listing = str.remove("")
                #print(listing)

#Here I am reading the name of each .txt file to the separate .xlsx
file:for r, name in enumerate(os.listdir(text_folder)):
    if name.endswith(".txt"):
        print(name)
#Reading .txt file and trying to make the sentence into words instead
of lines so that I can compare the individual .txt file words with the
.xlsx file
txtfilespath = os.chdir("C:/Users/xxxx/Documents/xxxx/Text")

#Here I am reading and printing all the words in the .txt files and
compare with the excel Cell A1:for name in os.listdir(txtfilespath):
    if name.endswith(".txt"):
        with open (name, "r") as texts:
            # Read each line of the file:
            s = texts.read()
            print(s)


            #if .txt files contain.....() or select or from or words
from sets..search that sentence and extract the common fields

            result1 = []
            parens = 0
            buff = ""
            for line in s:
                if line == "(":
                    parens += 1
                if parens > 0:
                    buff += line
                if line == ")":
                    parens -= 1
               if not parens and buff:
                    result1.append(buff)
                    buff = ""
                    set(result1)
#Here, I include other keywords other than those found in the Excel workbooks
   checkhere = set()
   checkhere.add("Select")
   checkhere.add("From")
   checkhere.add("select")
   checkhere.add("from")
   checkhere.add("SELECT")
   checkhere.add("FROM")
   # k = list(checkhere)
   # print(k)

   #I only want to read/ extract the lines containing brackets () as
well as the keywords in the checkhere set. So that I can check capture
the source and field in each line:
   #I tried this but nothing was printed......
   for element in checkhere:
       if element in result1:
        print(result1)

*My desired output for the code that could not be printed when I tried is:*

(/* 1.select_no., biiiiiyyyy FROM apple_x_Ex_x */
 proc sql; "TRUuuuth")
(/* 1.xxxxx FROM xxxxx*/
proc sql; "TRUuuuth")
(SELECT abc AS abc1, ab33_2_ AS mon, a_rr, iirir_vf, jk_ff, sfa_jfkj
    FROM &orange..xxx_xxx_xxE
 where (asre(kkk_ix as format 'xxxx-xx') gff &bcbcb_hhaha.) and
  (axx(xx_ix as format 'xxxx-xx') lec &jgjsd_vnv.)
 )

 (/* 1.select_no. FROM apple_x_Ex_x */
 proc sql; "TRUuuuth")

 (SELECT abc AS kfcccc, mcfg_2_ AS dokn, b_rr, jjhj_vf, jjjk_hj, fjjh_jhjkj
    FROM &bfbd..pear_xxx_xxE
 where (afdfe(kkffk_ix as format 'xxxxd-xx') gdaff &bcdadabcb_hdahaha.) and
  (axx(xx_ix as format 'xxxx-xx') lec &jgjsdfdf_vnv.)
 )

After which, if I'm able to get the desired output above, I will then
compare these lines against the word set() and the fieldset set().

Any help would really be appreciated here..thank you

From alan.gauld at btinternet.com  Sun Sep  8 19:35:13 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Mon, 9 Sep 2019 00:35:13 +0100
Subject: [Tutor] Finding lines in .txt file that contain keywords from
 two different set()
In-Reply-To: <CAD=0mP9MtG=pTKmQmaZNdZOgXjjV7nJED=5SOAWHhshbGFgPYQ@mail.gmail.com>
References: <CAD=0mP9MtG=pTKmQmaZNdZOgXjjV7nJED=5SOAWHhshbGFgPYQ@mail.gmail.com>
Message-ID: <985aed76-de2f-4ff4-5446-09fc292f9cd8@btinternet.com>

On 08/09/2019 17:05, A S wrote:
> This is the code I have thus far...:

The formatting is all messed up, you need to post in plain text to
ensure the indentation is preserved.


I've tried to disentangle it but may have got it wrong...

> import os, sys
> from os.path import join
> import re
> import xlrd from xlrd
> import open_workbook
> import openpyxl from openpyxl.reader.excel 
> import load_workbook
> import xlsxwriter
>
> #All the paths
> dict_folder = 'C:/Users/xxxx/Documents/xxxx/Test Excel'
> text_folder = 'C:/Users/xxxx/Documents/xxxx/Text'
>
> words = set()
> fieldset = set()
> for file in os.listdir(dict_folder):
>   if file.endswith(".xlsx"):
>     wb1 = load_workbook(join(dict_folder, file), data_only = True)
>     ws = wb1.active
>     #Here I am reading and printing all the data source names
>     #set(words) in the excel dictionaries:
>     cellvalues = ws["A1"].value
>     wordsextract = re.findall(r"\((.+?)\)", str(cellvalues))
>     results = wordsextract[0]
>     words.add(results)
>     print(results)
>
>     for rowofcellobj in ws["C" : "D"]:
>         for cellobj in rowofcellobj:
>            #2. Here I am printing all the field names in col C & D in
>            # the excel dictionaries:
>            data = re.findall(r"\w+_.*?\w+", str(cellobj.value))
>            if data != []:
>                 fields = data[0]
>                 fieldset.add(fields)
>                 print(fieldset)
>                 #listing = str.remove("")
>                 #print(listing)
>
> #Here I am reading the name of each .txt file to the separate .xlsx
> file:

> for r, name in enumerate(os.listdir(text_folder)):
>     if name.endswith(".txt"):
>         print(name)
>         #Reading .txt file and trying to make the sentence 
>         # into words instead of lines so that I can compare 
>         # the individual .txt file words with the .xlsx file
>         txtfilespath = os.chdir("C:/Users/xxxx/Documents/xxxx/Text")
>
> #Here I am reading and printing all the words in 
> # the .txt files and compare with the excel Cell A1:

> for name in os.listdir(txtfilespath):
>     if name.endswith(".txt"):
>         with open (name, "r") as texts:
>             # Read each line of the file:
>             s = texts.read()
>             print(s)
>
>
>             #if .txt files contain.....() or select or 
>             # from or words from sets..search that sentence 
>             # and extract the common fields
>
>             result1 = []
>             parens = 0
>             buff = ""
>             for line in s:
>                 if line == "(":
>                     parens += 1
>                 if parens > 0:
>                     buff += line
>                 if line == ")":
>                     parens -= 1
>                if not parens and buff:
>                     result1.append(buff)
>                     buff = ""
>                     set(result1)

That last line does nothing useful. It declares a set but does not assign
it to anything so it is immediately destroyed again.



> #Here, I include other keywords other than those found in the Excel workbooks
>    checkhere = set()
>    checkhere.add("Select")
>    checkhere.add("From")
>    checkhere.add("select")
>    checkhere.add("from")
>    checkhere.add("SELECT")
>    checkhere.add("FROM")
>    # k = list(checkhere)
>    # print(k)

I assume all of that should be at the outer level since you wouldn't
want to do it inside a loop?


But why use add()? You can just declare theset using the literal notation:


checkhere = {"Select", "From",...."SELECT","FROM"}


>    #I only want to read/ extract the lines containing brackets () as
> well as the keywords in the checkhere set. So that I can check capture
> the source and field in each line:
>    #I tried this but nothing was printed......
>    for element in checkhere:
>        if element in result1:
>         print(result1)
>
> *My desired output for the code that could not be printed when I tried is:*
>
> (/* 1.select_no., biiiiiyyyy FROM apple_x_Ex_x */
>  proc sql; "TRUuuuth")
> (/* 1.xxxxx FROM xxxxx*/
> proc sql; "TRUuuuth")
> (SELECT abc AS abc1, ab33_2_ AS mon, a_rr, iirir_vf, jk_ff, sfa_jfkj
>     FROM &orange..xxx_xxx_xxE
>  where (asre(kkk_ix as format 'xxxx-xx') gff &bcbcb_hhaha.) and
>   (axx(xx_ix as format 'xxxx-xx') lec &jgjsd_vnv.)
>  )
>
>  (/* 1.select_no. FROM apple_x_Ex_x */
>  proc sql; "TRUuuuth")
>
>  (SELECT abc AS kfcccc, mcfg_2_ AS dokn, b_rr, jjhj_vf, jjjk_hj, fjjh_jhjkj
>     FROM &bfbd..pear_xxx_xxE
>  where (afdfe(kkffk_ix as format 'xxxxd-xx') gdaff &bcdadabcb_hdahaha.) and
>   (axx(xx_ix as format 'xxxx-xx') lec &jgjsdfdf_vnv.)
>  )

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From PyTutor at DancesWithMice.info  Sun Sep  8 19:42:53 2019
From: PyTutor at DancesWithMice.info (David L Neil)
Date: Mon, 9 Sep 2019 11:42:53 +1200
Subject: [Tutor] Finding lines in .txt file that contain keywords from
 two different set()
In-Reply-To: <CAD=0mP9MtG=pTKmQmaZNdZOgXjjV7nJED=5SOAWHhshbGFgPYQ@mail.gmail.com>
References: <CAD=0mP9MtG=pTKmQmaZNdZOgXjjV7nJED=5SOAWHhshbGFgPYQ@mail.gmail.com>
Message-ID: <8d74c808-72f0-9c86-6291-283f0479637a@DancesWithMice.info>

Cross-posted from Python list.
Multiple responses there!
-- 
Regards =dn

From anilduggirala at fastmail.fm  Sun Sep  8 18:16:27 2019
From: anilduggirala at fastmail.fm (Anil Felipe Duggirala)
Date: Sun, 08 Sep 2019 17:16:27 -0500
Subject: [Tutor] how to pass arguments to script
Message-ID: <c0a9c63d27d075ae3b11ce826637e4d9fd8633ef.camel@fastmail.fm>

hello,
I am currently completing the Python tutorial, in python.org.
I wonder, if I write a script.py defining a function, and the function
requires an argument to produce a result; how do I specify this
argument when executing script.py in my console?
Is there a way to run the script in interactive mode and also quickly
pass the function's argument?
I am using python3.
thank you,


From alan.gauld at btinternet.com  Mon Sep  9 04:47:49 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Mon, 9 Sep 2019 09:47:49 +0100
Subject: [Tutor] how to pass arguments to script
In-Reply-To: <c0a9c63d27d075ae3b11ce826637e4d9fd8633ef.camel@fastmail.fm>
References: <c0a9c63d27d075ae3b11ce826637e4d9fd8633ef.camel@fastmail.fm>
Message-ID: <da2a83cc-71ee-ffdd-e053-40a89e7038d5@btinternet.com>

On 08/09/2019 23:16, Anil Felipe Duggirala wrote:
> I am currently completing the Python tutorial, in python.org.
> I wonder, if I write a script.py defining a function, and the function
> requires an argument to produce a result; how do I specify this
> argument when executing script.py in my console?

Take a look at the "Talking to the User" topic in my tutorial(link below)

About 3/4 way down there is a section "Command Line Parameters"

that describes how to do what you want.


Or read the documentation on sys.stdin

> Is there a way to run the script in interactive mode and also quickly
> pass the function's argument?

You can't easily run scripts at the interactive prompt (ie >>>). You can
import a module and if your script is written such that you can execute
it by calling a function then that's the simplest option.

This usually means having your script code look like:


######## MyModule.py ######

import sys

def something:....

def another......

def main(arg):

????? # my main code here

if __name__ == "__main__":

????? args = sys.argv

????? main(args[1])

####################


Then you


>>> import MyModule

>>> MyModule.main(myArg)

HTH

-- 

Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From alan.gauld at btinternet.com  Mon Sep  9 05:40:31 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Mon, 9 Sep 2019 10:40:31 +0100
Subject: [Tutor] how to pass arguments to script
In-Reply-To: <da2a83cc-71ee-ffdd-e053-40a89e7038d5@btinternet.com>
References: <c0a9c63d27d075ae3b11ce826637e4d9fd8633ef.camel@fastmail.fm>
 <da2a83cc-71ee-ffdd-e053-40a89e7038d5@btinternet.com>
Message-ID: <bdac1794-8bca-3715-7df3-1da90b1ad727@btinternet.com>

On 09/09/2019 09:47, Alan Gauld via Tutor wrote:
>
> Or read the documentation on sys.stdin

Sorry, that was meant to be sys.argv...

Although you could use sys.stdin too, if you use stdin instead of
a file for input via a pipe....

-- 

Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From fiddie23 at gmail.com  Mon Sep  9 23:10:39 2019
From: fiddie23 at gmail.com (Fidel Amoah)
Date: Tue, 10 Sep 2019 03:10:39 +0000
Subject: [Tutor] Facebook script for keywords
Message-ID: <CAFLBzrokDK75=EuCVxc-DUPxhNw6Hu_gGoyJGysbK5YMPWX09A@mail.gmail.com>

Hello all, I?m new to Python so pardon my ignorance.

I?d like to find out, is there a way of creating a Facebook ads script that
targets audiences based on keywords? For instance, targeting an audience
with the keyword ?I?m interested?, while narrowing it down to a specific
product category.

Many thanks.

From mats at wichmann.us  Tue Sep 10 11:09:27 2019
From: mats at wichmann.us (Mats Wichmann)
Date: Tue, 10 Sep 2019 09:09:27 -0600
Subject: [Tutor] Facebook script for keywords
In-Reply-To: <CAFLBzrokDK75=EuCVxc-DUPxhNw6Hu_gGoyJGysbK5YMPWX09A@mail.gmail.com>
References: <CAFLBzrokDK75=EuCVxc-DUPxhNw6Hu_gGoyJGysbK5YMPWX09A@mail.gmail.com>
Message-ID: <a637cd92-4e4e-2cf6-1396-eebb704120fa@wichmann.us>

On 9/9/19 9:10 PM, Fidel Amoah wrote:
> Hello all, I?m new to Python so pardon my ignorance.
> 
> I?d like to find out, is there a way of creating a Facebook ads script that
> targets audiences based on keywords? For instance, targeting an audience
> with the keyword ?I?m interested?, while narrowing it down to a specific
> product category.

I don't think you're going to get any help on that here.

Facebook will tell you what you can and cannot do with advertising,
which is the basis of their entire business. Random people who would
love to help you with actual Python problems can't do that. And you
haven't asked a real question anyway (answer: "it's a programming
language, there's always a way, but it might not be worth going that way")

From alan.gauld at btinternet.com  Tue Sep 10 04:44:05 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Tue, 10 Sep 2019 09:44:05 +0100
Subject: [Tutor] Facebook script for keywords
In-Reply-To: <CAFLBzrokDK75=EuCVxc-DUPxhNw6Hu_gGoyJGysbK5YMPWX09A@mail.gmail.com>
References: <CAFLBzrokDK75=EuCVxc-DUPxhNw6Hu_gGoyJGysbK5YMPWX09A@mail.gmail.com>
Message-ID: <1c77e317-4c01-6124-cbf9-8bbe74f9a222@btinternet.com>

On 10/09/2019 04:10, Fidel Amoah wrote:
> Hello all, I?m new to Python so pardon my ignorance.

Are you an experienced programmer in any other languages?
If so, then python should be a very small part of your problem.

If not then you are probably biting off a bit more than you can
chew in the short term...

> I?d like to find out, is there a way of creating a Facebook ads script that
> targets audiences based on keywords? For instance, targeting an audience
> with the keyword ?I?m interested?, while narrowing it down to a specific
> product category.


I know nothing of Facebook's public API and indeed only occasionally
use Facebook as a platform. However, it seems unlikely that they would
expose that algorithm to external agencies since it could be greatly
abused and seriously upset their customer base. So unless you work
for Facebook and have access to their core code I suspect its not possible.

On the other hand in this open-source age I'm possibly being overly
sceptical.

Do you have a Facebook interface specification you can share?
Then we might be able to help.

-- 

Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From alan.gauld at btinternet.com  Tue Sep 10 21:48:31 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Wed, 11 Sep 2019 01:48:31 -0000
Subject: [Tutor] Comment
In-Reply-To: <70e9467014a745db85477518e7dd142c@HPEXCH05.HealthPartners.int>
References: <70e9467014a745db85477518e7dd142c@HPEXCH05.HealthPartners.int>
Message-ID: <230125b5-a33e-a92d-02e3-5482f287bae4@btinternet.com>

On 23/08/2019 23:36, Olsen, Avalow Y wrote:
> Is there a mechanism to comment out large blocks of Python code?

You have correctly identified the options but there is usually tool support
in IDEs and intelligent editors. Look for a "comment out" menu option
where you can use the mouse (or keyboard)to select a region and
have the editor comment it out.

Eclipse, Netbeans, vim and IDLE all have it (the ones I use most)
and I'm sure most of the others do too.


Also many editors include folding support where the editor will
hide lines inside , for example, class or function definitions, to make
code more readable.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From alan.gauld at btinternet.com  Tue Sep 10 23:12:04 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Wed, 11 Sep 2019 03:12:04 -0000
Subject: [Tutor] The Reading Documentation problem
In-Reply-To: <BN8PR11MB3764D9349AFADB0BE805A7F6E0A70@BN8PR11MB3764.namprd11.prod.outlook.com>
References: <BN8PR11MB3764D9349AFADB0BE805A7F6E0A70@BN8PR11MB3764.namprd11.prod.outlook.com>
Message-ID: <938f2c86-9192-e22c-6576-41eca5a04316@btinternet.com>

On 25/08/2019 00:04, Mike Barnett wrote:
> Sorry this is so long, but it's a real problem I'm witnessing and I'm 
> wondering if it's only a certain portion of the programming world 
> (self-taught people) or the internet-generation in general does 
> this regardless of educational training.

My own opinion, based on? anecdotal evidence only, is that its a symptom of
the YouTube generation.

People now learn from YouTube - which is invariably a shallow learning
process
driven by example rather than deeper explanation. (I'm biased since I write
books and a website! :-)

But if you "learn" by video, any documentation seems dull and boring.

So unless there is a short (one paragraph) text or a video these folks turn
to forums etc and ask for an answer (not an explanation, they only want
the immediate answer).

This is an issue in all manner of areas. I am a keen photographer and I see
the same thing there. Just tell me how to improve this shot, No interest in
understanding the deeper reasons why the image is wrong and how
to avoid the problem in future.

There are exceptions of course, but YouTube has created an expectation
that you can learn anything from a 15 minute video clip.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From mhysnm1964 at gmail.com  Wed Sep 11 04:44:35 2019
From: mhysnm1964 at gmail.com (Sean Murphy)
Date: Wed, 11 Sep 2019 18:44:35 +1000
Subject: [Tutor] The Reading Documentation problem
In-Reply-To: <938f2c86-9192-e22c-6576-41eca5a04316@btinternet.com>
References: <BN8PR11MB3764D9349AFADB0BE805A7F6E0A70@BN8PR11MB3764.namprd11.prod.outlook.com>
 <938f2c86-9192-e22c-6576-41eca5a04316@btinternet.com>
Message-ID: <9EE23530-A3AB-41FA-92BC-94455E5E3CF8@gmail.com>

Nicely summarised I fully agree. I recall of study done many years ago comparing a person who read information via book and someone who looked on the Internet. The concentration and retention with Farlow for someone is getting information via the Internet due to the weight designed. Please excuse any errors because I?m using Siri.

My experience is the part 

> On 25 Aug 2019, at 5:57 pm, Alan Gauld via Tutor <tutor at python.org> wrote:
> 
>> On 25/08/2019 00:04, Mike Barnett wrote:
>> Sorry this is so long, but it's a real problem I'm witnessing and I'm 
>> wondering if it's only a certain portion of the programming world 
>> (self-taught people) or the internet-generation in general does 
>> this regardless of educational training.
> 
> My own opinion, based on  anecdotal evidence only, is that its a symptom of
> the YouTube generation.
> 
> People now learn from YouTube - which is invariably a shallow learning
> process
> driven by example rather than deeper explanation. (I'm biased since I write
> books and a website! :-)
> 
> But if you "learn" by video, any documentation seems dull and boring.
> 
> So unless there is a short (one paragraph) text or a video these folks turn
> to forums etc and ask for an answer (not an explanation, they only want
> the immediate answer).
> 
> This is an issue in all manner of areas. I am a keen photographer and I see
> the same thing there. Just tell me how to improve this shot, No interest in
> understanding the deeper reasons why the image is wrong and how
> to avoid the problem in future.
> 
> There are exceptions of course, but YouTube has created an expectation
> that you can learn anything from a 15 minute video clip.
> 
> -- 
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor

From PyTutor at DancesWithMice.info  Wed Sep 11 05:13:36 2019
From: PyTutor at DancesWithMice.info (David L Neil)
Date: Wed, 11 Sep 2019 21:13:36 +1200
Subject: [Tutor] The Reading Documentation problem
In-Reply-To: <9EE23530-A3AB-41FA-92BC-94455E5E3CF8@gmail.com>
References: <BN8PR11MB3764D9349AFADB0BE805A7F6E0A70@BN8PR11MB3764.namprd11.prod.outlook.com>
 <938f2c86-9192-e22c-6576-41eca5a04316@btinternet.com>
 <9EE23530-A3AB-41FA-92BC-94455E5E3CF8@gmail.com>
Message-ID: <f5441cea-d46b-4a00-f8c7-60f00d7bb546@DancesWithMice.info>

There is a growing body of serious research proving that people 
generally learn better from a printed-page than from a screen. Indeed a 
visit to a tertiary library will immediately provide you with anecdotal 
evidence that many "digerati" have come to the same conclusion - and 
given a choice will take the 'dead-tree' option.

In my own experience, looking at statistics for EdX courses, the number 
of trainees who actually complete a video lecture is staggeringly small. 
One person criticised that observation by suggesting that the stats were 
biased by second-views: whereby folk (having watched the presentation 
from start-to-finish once) returned to a video later - perhaps for 
'revision' or perhaps to check facts/ensure had absorbed the information 
or particular technique. Unfortunately, if that were significant, then 
the number of (unique) people who actually started a video, would be 
less than 50% of those 'completing' the lesson!
NB trainees don't have to endure my ugly-mug* in the videos, so don't 
have that excuse for bailing - however eminently-reasonable!

* British slang for face/visage (small hat-tip to Alan)

Personally I don't have confidence in *my* learning from video - or even 
an audio lecture. At first I put that down to my (personal) learning 
experience. However, the reality is that we talk to each other 'all day' 
and have no major difficulty remembering the pertinent parts of 
conversations; so maybe that's not a very accurate self-diagnosis.

Interestingly, discussing this with (current) tertiary students, 
revealed their idea that reading was slower than watching video. 
However, my (again, personal) experience is that I read video 
transcripts faster than the video will play - and quite possibly with 
higher comprehension and retention. Accordingly, I began losing faith in 
videos as a learning media, and have found few points to reverse such 
decline.

Perhaps then, the issue may be influenced by reading speed? A slow 
reader may prefer the video approach and ultimately learn more 
effectively that way (I'm not including specific conditions/cases, eg 
dyslexia, in these general cases).

To top that off, the literature generally reveals that if one media 
enables people to read more quickly, either they are essentially equal 
or the advantage/facility lies with books over screens.

That said, another popular view is that training should be oriented 
towards presentation on a smart-phone screen. Good luck (learning) 
coding within such visual constraints! Nevertheless, it is a sound 
marketing observation as to 'medium'. Whether "marketing" (attention 
span, brevity of communication opportunity, 'sizzle over steak', etc, 
etc) closely relates to pedagogy, underlies much of this discussion!



On 11/09/19 8:44 PM, Sean Murphy wrote:
> Nicely summarised I fully agree. I recall of study done many years ago comparing a person who read information via book and someone who looked on the Internet. The concentration and retention with Farlow for someone is getting information via the Internet due to the weight designed. Please excuse any errors because I?m using Siri.
> 
> My experience is the part
> 
>> On 25 Aug 2019, at 5:57 pm, Alan Gauld via Tutor <tutor at python.org> wrote:
>>
>>> On 25/08/2019 00:04, Mike Barnett wrote:
>>> Sorry this is so long, but it's a real problem I'm witnessing and I'm
>>> wondering if it's only a certain portion of the programming world
>>> (self-taught people) or the internet-generation in general does
>>> this regardless of educational training.
>>
>> My own opinion, based on  anecdotal evidence only, is that its a symptom of
>> the YouTube generation.
>>
>> People now learn from YouTube - which is invariably a shallow learning
>> process
>> driven by example rather than deeper explanation. (I'm biased since I write
>> books and a website! :-)
>>
>> But if you "learn" by video, any documentation seems dull and boring.
>>
>> So unless there is a short (one paragraph) text or a video these folks turn
>> to forums etc and ask for an answer (not an explanation, they only want
>> the immediate answer).
>>
>> This is an issue in all manner of areas. I am a keen photographer and I see
>> the same thing there. Just tell me how to improve this shot, No interest in
>> understanding the deeper reasons why the image is wrong and how
>> to avoid the problem in future.
>>
>> There are exceptions of course, but YouTube has created an expectation
>> that you can learn anything from a 15 minute video clip.
>>
>> -- 
>> Alan G
>> Author of the Learn to Program web site
>> http://www.alan-g.me.uk/
>> http://www.amazon.com/author/alan_gauld
>> Follow my photo-blog on Flickr at:
>> http://www.flickr.com/photos/alangauldphotos
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> https://mail.python.org/mailman/listinfo/tutor
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
> 

-- 
Regards =dn

From robertvstepp at gmail.com  Thu Sep 12 22:49:13 2019
From: robertvstepp at gmail.com (boB Stepp)
Date: Thu, 12 Sep 2019 21:49:13 -0500
Subject: [Tutor] problem clearing a text widget
In-Reply-To: <4b27a11e-295a-cb67-d042-b0a096fc2d98@internode.on.net>
References: <bc19fc80-bc59-2aea-ff5c-97fd0e480b76@internode.on.net>
 <4b27a11e-295a-cb67-d042-b0a096fc2d98@internode.on.net>
Message-ID: <CANDiX9KkFqT2kM3yH-nNyZoOFfBEUZY-A2XPac_is+PO3pwbog@mail.gmail.com>

On Thu, Sep 5, 2019 at 1:51 AM Chris Roy-Smith
<chris_roysmith at internode.on.net> wrote:

> > from tkinter import *
> >
> > def InsertText():
> >      tfield.insert(END,"Demo only\n")
> >
> > def DeleteText():
> >      tfield.delete(0,END)
> >
> > master=Tk()
> >
> > tfield = Text(master, height=15, width=60)
> > S=Scrollbar(master)
> > tfield.configure(yscrollcommand=S.set)
> > S.configure(command=tfield.yview)
> > S.grid(row=0, column=2)
> > tfield.grid(row=0, column=0, columnspan=2)
> > S.config(command=tfield.yview)
> > tfield.config(yscrollcommand=S.set)
> >
> > Button(master, text="Insert", command=InsertText).grid(row=5, column=0)
> > Button(master, text="Delete", command=DeleteText).grid(row=5, column=1)
> > Button(master, text="Exit", command=master.destroy).grid(row=5, column=2)
> >
> > master.mainloop()

> Never mind, the penny just dropped! The zero should be "0.0".

Actually shouldn't that be "1.0"?  Tkinter indexes lines of test
widgets starting with 1 not 0.  However, characters on a row/line
start with an index of 0!  See
https://web.archive.org/web/20190212094653/http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/text-index.html

I presume you successfully tested your code with "0.0", so what
trouble you might get into using that instead of the documented "1.0"
I have no idea...


-- 
boB

From gursimran.maken at gmail.com  Sat Sep 14 13:25:08 2019
From: gursimran.maken at gmail.com (Gursimran Maken)
Date: Sat, 14 Sep 2019 22:55:08 +0530
Subject: [Tutor] Details regarding namedtuple
Message-ID: <CAPug6na+u+J9UgK-ru5zyaUUCmw6V2woA3PqO5F1ihAHXwq9kQ@mail.gmail.com>

Hi All,

I would like to understand the use of first argument i.e. typename in
namedtuple collection.
collections.namedtuple (typename, field_names)

Example 1:
from collections import namedtuple
person = namedtuple ('person', 'age gender')
Sam = person(age=12, gender='M')
Sam.age

Example 2:
from collections import namedtuple
person = namedtuple ('xyz', 'age gender')
Sam = person(age=12, gender='M')
Sam.age
Pam = xyz(age=22, gender='F')
Pam.age

In example 1, both typename and variable name are same i.e. "person", and
we we print Sam.age we get output as 12.

In example 2, both typename and variable name are different i.e. "person"
and "xyz" respectively, and we we print Sam.age we get output as 12 but
when we type below statement we get an error, why?
Pam = xyz(age=22, gender='F')

Thanks in advance,
Gursimran.

From mats at wichmann.us  Sat Sep 14 13:51:50 2019
From: mats at wichmann.us (Mats Wichmann)
Date: Sat, 14 Sep 2019 11:51:50 -0600
Subject: [Tutor] Details regarding namedtuple
In-Reply-To: <CAPug6na+u+J9UgK-ru5zyaUUCmw6V2woA3PqO5F1ihAHXwq9kQ@mail.gmail.com>
References: <CAPug6na+u+J9UgK-ru5zyaUUCmw6V2woA3PqO5F1ihAHXwq9kQ@mail.gmail.com>
Message-ID: <d0aaeb40-58bb-802f-7a84-dec7a94a8c6c@wichmann.us>

On 9/14/19 11:25 AM, Gursimran Maken wrote:
> Hi All,
> 
> I would like to understand the use of first argument i.e. typename in
> namedtuple collection.
> collections.namedtuple (typename, field_names)
> 
> Example 1:
> from collections import namedtuple
> person = namedtuple ('person', 'age gender')
> Sam = person(age=12, gender='M')
> Sam.age
> 
> Example 2:
> from collections import namedtuple
> person = namedtuple ('xyz', 'age gender')
> Sam = person(age=12, gender='M')
> Sam.age
> Pam = xyz(age=22, gender='F')
> Pam.age
> 
> In example 1, both typename and variable name are same i.e. "person", and
> we we print Sam.age we get output as 12.
> 
> In example 2, both typename and variable name are different i.e. "person"
> and "xyz" respectively, and we we print Sam.age we get output as 12 but
> when we type below statement we get an error, why?
> Pam = xyz(age=22, gender='F')

it's used to set the name of the generated class.

>>> Sam = person(age=12, gender='M')
>>> Sam
xyz(age=12, gender='M')
>>> person.__name__
'xyz'
>>>



From marcelhendrickxpython at yahoo.com  Sun Sep 15 02:17:18 2019
From: marcelhendrickxpython at yahoo.com (Hendrickx Marcel)
Date: Sun, 15 Sep 2019 08:17:18 +0200
Subject: [Tutor] Python3 : Yes --- Python2 : No ?
Message-ID: <46WK0f6VdJzndf8@mail.python.org>


Link with the info =>

https://www.python.org/doc/sunset-python-2/

News for me...

Greetings.


From alan.gauld at btinternet.com  Sun Sep 15 03:48:14 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Sun, 15 Sep 2019 08:48:14 +0100
Subject: [Tutor] Python3 : Yes --- Python2 : No ?
In-Reply-To: <46WK0f6VdJzndf8@mail.python.org>
References: <46WK0f6VdJzndf8@mail.python.org>
Message-ID: <b3d0c78c-93a8-63a9-0fb3-73d2311c0b58@btinternet.com>

On 15/09/2019 07:17, Hendrickx Marcel via Tutor wrote:
> Link with the info =>
>
> https://www.python.org/doc/sunset-python-2/
>
> News for me...

It really shouldn't be a surprise. As the link says its
been announced several times and was always
the intent.

Python 2 will have been around for 20 years,

Python 3 has been out for 10.


In fact what is more surprising is that there doesn't
seem to be any plans for Python 4. Based on history
Python drops a new major version every 10 years or so...
But a major version implies significant change
and there are not many big changes in the pipeline.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From py.ohayo at sunrise.ch  Wed Sep 18 10:46:19 2019
From: py.ohayo at sunrise.ch (Pavel Yermolenko)
Date: Wed, 18 Sep 2019 16:46:19 +0200
Subject: [Tutor] matplotlib isn't recognized after installation
Message-ID: <20190918144619.63A6960456@smtp2.smx.sunrise.ch>

Hello,

I've installed matplotlib using the following command:
python -m pip install matplotlib

But when I try use it in my code I get this message:
ModuleNotFoundError: No module named 'matplotlib'

Any comments ?

Thanks.


From mariamhaji01 at gmail.com  Wed Sep 18 12:49:26 2019
From: mariamhaji01 at gmail.com (Mariam Haji)
Date: Wed, 18 Sep 2019 19:49:26 +0300
Subject: [Tutor] matplotlib isn't recognized after installation
In-Reply-To: <20190918144619.63A6960456@smtp2.smx.sunrise.ch>
References: <20190918144619.63A6960456@smtp2.smx.sunrise.ch>
Message-ID: <CAL3-qMwFUxDKD1KKJ2Mo9MwY4zEfAUWkVG=KPvie2___C40c+A@mail.gmail.com>

Are you running it on the terminal or anaconda?

Regards,
Mariam.





On Wed, Sep 18, 2019 at 7:39 PM Pavel Yermolenko <py.ohayo at sunrise.ch>
wrote:

> Hello,
>
> I've installed matplotlib using the following command:
> python -m pip install matplotlib
>
> But when I try use it in my code I get this message:
> ModuleNotFoundError: No module named 'matplotlib'
>
> Any comments ?
>
> Thanks.
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>

From py.ohayo at sunrise.ch  Wed Sep 18 12:53:05 2019
From: py.ohayo at sunrise.ch (Pavel Yermolenko)
Date: Wed, 18 Sep 2019 18:53:05 +0200
Subject: [Tutor] matplotlib isn't recognized after installation
In-Reply-To: <CAL3-qMwFUxDKD1KKJ2Mo9MwY4zEfAUWkVG=KPvie2___C40c+A@mail.gmail.com>
References: <20190918144619.63A6960456@smtp2.smx.sunrise.ch>
 <CAL3-qMwFUxDKD1KKJ2Mo9MwY4zEfAUWkVG=KPvie2___C40c+A@mail.gmail.com>
Message-ID: <20190918165305.9F07520A18@smtp2.smx.sunrise.ch>

I run it on Jupyter.

Provenance?: Courrier pour Windows 10

De?: Mariam Haji
Envoy? le?:mercredi, 18 septembre 2019 18:49
??: Pavel Yermolenko
Cc?: tutor at python.org
Objet?:Re: [Tutor] matplotlib isn't recognized after installation

Are you running it on the terminal or anaconda?


Regards,
Mariam.




On Wed, Sep 18, 2019 at 7:39 PM Pavel Yermolenko <py.ohayo at sunrise.ch> wrote:
Hello,

I've installed matplotlib using the following command:
python -m pip install matplotlib

But when I try use it in my code I get this message:
ModuleNotFoundError: No module named 'matplotlib'

Any comments ?

Thanks.

_______________________________________________
Tutor maillist? -? Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


From mariamhaji01 at gmail.com  Wed Sep 18 13:19:54 2019
From: mariamhaji01 at gmail.com (Mariam Haji)
Date: Wed, 18 Sep 2019 20:19:54 +0300
Subject: [Tutor] matplotlib isn't recognized after installation
In-Reply-To: <20190918165305.9F07520A18@smtp2.smx.sunrise.ch>
References: <20190918144619.63A6960456@smtp2.smx.sunrise.ch>
 <CAL3-qMwFUxDKD1KKJ2Mo9MwY4zEfAUWkVG=KPvie2___C40c+A@mail.gmail.com>
 <20190918165305.9F07520A18@smtp2.smx.sunrise.ch>
Message-ID: <02FAF831-73AD-4FED-A801-E8E73C445BD8@gmail.com>

Ok so here is what you could do

Under the environments tab on anaconda navigator make sure it?s installed in packages you could search for it. 

Also restarting anaconda could help. 

According to the docs it should be 
python -m pip install -U matplotlib

try this too even if it shows up in the environment as it could be an old version and the above will install the latest version 

Regards,
Mariam

> On 18 Sep 2019, at 7:53 PM, Pavel Yermolenko <py.ohayo at sunrise.ch> wrote:
> 
> I run it on Jupyter.
>  
> Provenance : Courrier pour Windows 10
>  
> De : Mariam Haji
> Envoy? le :mercredi, 18 septembre 2019 18:49
> ? : Pavel Yermolenko
> Cc : tutor at python.org
> Objet :Re: [Tutor] matplotlib isn't recognized after installation
>  
> Are you running it on the terminal or anaconda?
>  
> Regards,
> Mariam.
>  
>  
> 
>  
>  
> On Wed, Sep 18, 2019 at 7:39 PM Pavel Yermolenko <py.ohayo at sunrise.ch> wrote:
> Hello,
> 
> I've installed matplotlib using the following command:
> python -m pip install matplotlib
> 
> But when I try use it in my code I get this message:
> ModuleNotFoundError: No module named 'matplotlib'
> 
> Any comments ?
> 
> Thanks.
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>  

From mats at wichmann.us  Wed Sep 18 13:23:10 2019
From: mats at wichmann.us (Mats Wichmann)
Date: Wed, 18 Sep 2019 11:23:10 -0600
Subject: [Tutor] matplotlib isn't recognized after installation
In-Reply-To: <20190918165305.9F07520A18@smtp2.smx.sunrise.ch>
References: <20190918144619.63A6960456@smtp2.smx.sunrise.ch>
 <CAL3-qMwFUxDKD1KKJ2Mo9MwY4zEfAUWkVG=KPvie2___C40c+A@mail.gmail.com>
 <20190918165305.9F07520A18@smtp2.smx.sunrise.ch>
Message-ID: <ecb0dac9-2d99-8ba6-93fd-930baf8eb359@wichmann.us>

On 9/18/19 10:53 AM, Pavel Yermolenko wrote:
> I run it on Jupyter.
> 

> On Wed, Sep 18, 2019 at 7:39 PM Pavel Yermolenko <py.ohayo at sunrise.ch> wrote:
> Hello,
> 
> I've installed matplotlib using the following command:
> python -m pip install matplotlib
> 
> But when I try use it in my code I get this message:
> ModuleNotFoundError: No module named 'matplotlib'
> 
> Any comments ?

The problem is Jupyter wants to live it its own little world, so your
matplotlib undoubtedly went a place jupyter doesn't know to find it.

there are about a thousand different takes on this topic... maybe this
blog post will prove helpful:

https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/



From Yuanyuan.A.Olsen at HealthPartners.Com  Wed Sep 18 13:23:53 2019
From: Yuanyuan.A.Olsen at HealthPartners.Com (Olsen, Avalow Y)
Date: Wed, 18 Sep 2019 17:23:53 +0000
Subject: [Tutor] matplotlib isn't recognized after installation
In-Reply-To: <02FAF831-73AD-4FED-A801-E8E73C445BD8@gmail.com>
References: <20190918144619.63A6960456@smtp2.smx.sunrise.ch>
 <CAL3-qMwFUxDKD1KKJ2Mo9MwY4zEfAUWkVG=KPvie2___C40c+A@mail.gmail.com>
 <20190918165305.9F07520A18@smtp2.smx.sunrise.ch>
 <02FAF831-73AD-4FED-A801-E8E73C445BD8@gmail.com>
Message-ID: <c25f092f6b4d4b52bcc34bb9b845071b@HPEXCH05.HealthPartners.int>

Try add the following to your PATH
https://dev.to/hygull/setting-anaconda-path-on-windows-2dmn

C:\Anaconda5.1Python3.6
C:\Anaconda5.1Python3.6\Library\mingw-w64\bin
C:\Anaconda5.1Python3.6\Library\usr\bin
C:\Anaconda5.1Python3.6\Library\bin
C:\Anaconda5.1Python3.6\Scripts

Then in the cmd prompt, type in
pip install ?trusted-host pypi.org ?trusted-host files.pythonhosted.org <packages>


give a try. Good luck!




-----Original Message-----
From: Tutor [mailto:tutor-bounces+yuanyuan.a.olsen=healthpartners.com at python.org] On Behalf Of Mariam Haji
Sent: Wednesday, September 18, 2019 12:20 PM
To: Pavel Yermolenko <py.ohayo at sunrise.ch>
Cc: tutor at python.org
Subject: Re: [Tutor] matplotlib isn't recognized after installation

External Email: Do not click any links or attachments unless you recognize the sender.

Ok so here is what you could do

Under the environments tab on anaconda navigator make sure it?s installed in packages you could search for it.

Also restarting anaconda could help.

According to the docs it should be
python -m pip install -U matplotlib

try this too even if it shows up in the environment as it could be an old version and the above will install the latest version

Regards,
Mariam

> On 18 Sep 2019, at 7:53 PM, Pavel Yermolenko <py.ohayo at sunrise.ch> wrote:
>
> I run it on Jupyter.
>
> Provenance : Courrier pour Windows 10
>
> De : Mariam Haji
> Envoy? le :mercredi, 18 septembre 2019 18:49 ? : Pavel Yermolenko Cc :
> tutor at python.org Objet :Re: [Tutor] matplotlib isn't recognized after
> installation
>
> Are you running it on the terminal or anaconda?
>
> Regards,
> Mariam.
>
>
>
>
>
> On Wed, Sep 18, 2019 at 7:39 PM Pavel Yermolenko <py.ohayo at sunrise.ch> wrote:
> Hello,
>
> I've installed matplotlib using the following command:
> python -m pip install matplotlib
>
> But when I try use it in my code I get this message:
> ModuleNotFoundError: No module named 'matplotlib'
>
> Any comments ?
>
> Thanks.
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

________________________________

This e-mail and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient or the individual responsible for delivering the e-mail to the intended recipient, please be advised that you have received this e-mail in error and that any use, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited.

If you have received this communication in error, please return it to the sender immediately and delete the original message and any copy of it from your computer system. If you have any questions concerning this message, please contact the sender. Disclaimer R001.0

From bouncingcats at gmail.com  Thu Sep 19 03:28:41 2019
From: bouncingcats at gmail.com (David)
Date: Thu, 19 Sep 2019 17:28:41 +1000
Subject: [Tutor] Why does matplotlib error message say that 1 is not a
 scalar?
Message-ID: <CAMPXz=r-ZDgwLaARO-zRiX+a0n6DdBJF1vVL_=UOborgCKBLkw@mail.gmail.com>

Hi

I am just making some initial attempts to use matplotlib.
I don't understand the below error message.

h means height, b means bottom, these words are used
in the documentation.

$ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> x = [1, 2, 3]
>>> h = [1, 1, 1]
>>> b = [1, 2, 3]
>>> plt.bar(x, h, bottom=b)
<Container object of 3 artists>
>>> plt.show()
### here the plot displays, and then I close its window ###
>>> plt.bar(x, 1, bottom=b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 2705, in bar
    **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/__init__.py", line
1894, in inner
    return func(ax, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/axes/_axes.py", line
2079, in bar
    "must be length %d or scalar" % nbars)
ValueError: incompatible sizes: argument 'height' must be length 3 or scalar
>>>

What happens above is that first I pass h = [1,1,1]
to plt.bar() to individually specify the height of each box
in the plot.
This works and the call to plt.show() above successfully
draws the plot I expect.

According to the matplotlib documentation, and the error
message, the height (2nd) argument of plt.bar() can be a
scalar. The use case is when you want all boxes to have
the same height.

The docs
https://matplotlib.org/api/_as_gen/matplotlib.pyplot.bar.html#matplotlib.pyplot.bar
says
"""
Each of x, height, width, and bottom may either be a scalar applying
to all bars, or it may be a sequence of length N providing a separate
value for each bar.
"""

So I try to pass 1 as the height of all bars, and I expect
to get an identical plot. Instead I get the above error.

Any clues what is going wrong please?

From py.ohayo at sunrise.ch  Wed Sep 18 13:31:12 2019
From: py.ohayo at sunrise.ch (Pavel Yermolenko)
Date: Wed, 18 Sep 2019 19:31:12 +0200
Subject: [Tutor] matplotlib isn't recognized after installation
In-Reply-To: <c25f092f6b4d4b52bcc34bb9b845071b@HPEXCH05.HealthPartners.int>
References: <20190918144619.63A6960456@smtp2.smx.sunrise.ch>
 <CAL3-qMwFUxDKD1KKJ2Mo9MwY4zEfAUWkVG=KPvie2___C40c+A@mail.gmail.com>
 <20190918165305.9F07520A18@smtp2.smx.sunrise.ch>
 <02FAF831-73AD-4FED-A801-E8E73C445BD8@gmail.com>
 <c25f092f6b4d4b52bcc34bb9b845071b@HPEXCH05.HealthPartners.int>
Message-ID: <20190918173112.CB5532024E@smtp2.smx.sunrise.ch>

Resolved.
The problem was that installation instruction I used to install matplotlib, installed this library to Python 2.7, whereas Jupyter uses Python 3.6.
The instruction sudo apt-get install python3-matplotlib fixed the problem.
Thanks. 

Provenance?: Courrier pour Windows 10

De?: Olsen, Avalow Y
Envoy? le?:mercredi, 18 septembre 2019 19:24
??: 'Mariam Haji'; Pavel Yermolenko
Cc?: tutor at python.org
Objet?:RE: [Tutor] matplotlib isn't recognized after installation

Try add the following to your PATH
https://dev.to/hygull/setting-anaconda-path-on-windows-2dmn

C:\Anaconda5.1Python3.6
C:\Anaconda5.1Python3.6\Library\mingw-w64\bin
C:\Anaconda5.1Python3.6\Library\usr\bin
C:\Anaconda5.1Python3.6\Library\bin
C:\Anaconda5.1Python3.6\Scripts

Then in the cmd prompt, type in
pip install ?trusted-host pypi.org ?trusted-host files.pythonhosted.org <packages>


give a try. Good luck!




-----Original Message-----
From: Tutor [mailto:tutor-bounces+yuanyuan.a.olsen=healthpartners.com at python.org] On Behalf Of Mariam Haji
Sent: Wednesday, September 18, 2019 12:20 PM
To: Pavel Yermolenko <py.ohayo at sunrise.ch>
Cc: tutor at python.org
Subject: Re: [Tutor] matplotlib isn't recognized after installation

External Email: Do not click any links or attachments unless you recognize the sender.

Ok so here is what you could do

Under the environments tab on anaconda navigator make sure it?s installed in packages you could search for it.

Also restarting anaconda could help.

According to the docs it should be
python -m pip install -U matplotlib

try this too even if it shows up in the environment as it could be an old version and the above will install the latest version

Regards,
Mariam

> On 18 Sep 2019, at 7:53 PM, Pavel Yermolenko <py.ohayo at sunrise.ch> wrote:
>
> I run it on Jupyter.
>
> Provenance : Courrier pour Windows 10
>
> De : Mariam Haji
> Envoy? le :mercredi, 18 septembre 2019 18:49 ? : Pavel Yermolenko Cc :
> tutor at python.org Objet :Re: [Tutor] matplotlib isn't recognized after
> installation
>
> Are you running it on the terminal or anaconda?
>
> Regards,
> Mariam.
>
>
>
>
>
> On Wed, Sep 18, 2019 at 7:39 PM Pavel Yermolenko <py.ohayo at sunrise.ch> wrote:
> Hello,
>
> I've installed matplotlib using the following command:
> python -m pip install matplotlib
>
> But when I try use it in my code I get this message:
> ModuleNotFoundError: No module named 'matplotlib'
>
> Any comments ?
>
> Thanks.
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

________________________________

This e-mail and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient or the individual responsible for delivering the e-mail to the intended recipient, please be advised that you have received this e-mail in error and that any use, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited.

If you have received this communication in error, please return it to the sender immediately and delete the original message and any copy of it from your computer system. If you have any questions concerning this message, please contact the sender. Disclaimer R001.0


From alan.gauld at btinternet.com  Wed Sep 18 13:08:13 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Wed, 18 Sep 2019 18:08:13 +0100
Subject: [Tutor] matplotlib isn't recognized after installation
In-Reply-To: <20190918144619.63A6960456@smtp2.smx.sunrise.ch>
References: <20190918144619.63A6960456@smtp2.smx.sunrise.ch>
Message-ID: <311db492-d9b4-fef8-0f8e-bc2e76089626@btinternet.com>

On 18/09/2019 15:46, Pavel Yermolenko wrote:
> Hello,
>
> I've installed matplotlib using the following command:
> python -m pip install matplotlib

That probably invokes Python 2.x


If your development tool is using v3 then thats the error I'd expect.

What happens if you try

python --version



-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From alan.gauld at btinternet.com  Thu Sep 19 20:03:34 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Fri, 20 Sep 2019 01:03:34 +0100
Subject: [Tutor] matplotlib isn't recognized after installation
In-Reply-To: <311db492-d9b4-fef8-0f8e-bc2e76089626@btinternet.com>
References: <20190918144619.63A6960456@smtp2.smx.sunrise.ch>
 <311db492-d9b4-fef8-0f8e-bc2e76089626@btinternet.com>
Message-ID: <02937696-4c55-6fb7-8c3b-13917e547aa8@btinternet.com>

> On 18/09/2019 18:08, Alan Gauld via Tutor wrote:


As a matter of interest, is anyone else seeing very slow responses?
I wrote the cited message over 30 hours ago and it has just shown
up on my email tool. Did anyone else see it earlier? - in which case
it must be my Python list settings? - or is everyone getting long
delays between posting and seeing the post appear?

If the latter I'll chase the server team to see if there's an issue.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From asad.hasan2004 at gmail.com  Fri Sep 20 04:09:52 2019
From: asad.hasan2004 at gmail.com (Asad)
Date: Fri, 20 Sep 2019 13:39:52 +0530
Subject: [Tutor] Failing regex to identify error stack
Message-ID: <CAG3LsKFuNEMweRvB8UgGa6dyerPp5V916iwoaF9VNA+h-ASJdg@mail.gmail.com>

Hi All ,

I am writing a script in python to read a logfile and identify the first
error stack :

?/test/admin/nothing.sql

PL/SQL procedure successfully completed.
Session altered.
Package created.
Session altered.
Session altered.
Package body created.
No errors.
Session altered.
PL/SQL procedure successfully completed.

ERROR at line 9:
Fal-11144: size of object not allowed


I am trying to use the following regex :

^.*/test/admin/.*(?=ERROR at line .*)(?=Fal-.*)

using lookahead because seems in regex there is no && operator

Please advice .

Thanks,
-- 
Asad Hasan
+91 9582111698

From alan.gauld at btinternet.com  Fri Sep 20 03:51:39 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Fri, 20 Sep 2019 08:51:39 +0100
Subject: [Tutor] matplotlib isn't recognized after installation
In-Reply-To: <02937696-4c55-6fb7-8c3b-13917e547aa8@btinternet.com>
References: <20190918144619.63A6960456@smtp2.smx.sunrise.ch>
 <311db492-d9b4-fef8-0f8e-bc2e76089626@btinternet.com>
 <02937696-4c55-6fb7-8c3b-13917e547aa8@btinternet.com>
Message-ID: <0a05dbde-1141-81e0-a6f4-1e94caa8b9af@btinternet.com>

On 20/09/2019 01:03, Alan Gauld via Tutor wrote:
>> On 18/09/2019 18:08, Alan Gauld via Tutor wrote:
>
> As a matter of interest, is anyone else seeing very slow responses?
> I wrote the cited message over 30 hours ago and it has just shown
> up on my email tool. Did anyone else see it earlier? - in which case
> it must be my Python list settings? - or is everyone getting long
> delays between posting and seeing the post appear?
>
> If the latter I'll chase the server team to see if there's an issue.
>
OK, This came through in minutes so its obviously not a list issue.
Must have been something holding things up between my ISP and here.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From PyTutor at DancesWithMice.info  Fri Sep 20 04:30:46 2019
From: PyTutor at DancesWithMice.info (David L Neil)
Date: Fri, 20 Sep 2019 20:30:46 +1200
Subject: [Tutor] Failing regex to identify error stack
In-Reply-To: <CAG3LsKFuNEMweRvB8UgGa6dyerPp5V916iwoaF9VNA+h-ASJdg@mail.gmail.com>
References: <CAG3LsKFuNEMweRvB8UgGa6dyerPp5V916iwoaF9VNA+h-ASJdg@mail.gmail.com>
Message-ID: <efaa3421-7b90-2f82-c10d-edfca6e534d3@DancesWithMice.info>

Hi Asad,

On 20/09/19 8:09 PM, Asad wrote:
> I am writing a script in python to read a logfile and identify the first
> error stack :
> ?/test/admin/nothing.sql
> PL/SQL procedure successfully completed.
> Session altered.
> Package created.
> Session altered.
> Session altered.
> Package body created.
> No errors.
> Session altered.
> PL/SQL procedure successfully completed.
> ERROR at line 9:
> Fal-11144: size of object not allowed
> I am trying to use the following regex :
> ^.*/test/admin/.*(?=ERROR at line .*)(?=Fal-.*)
> using lookahead because seems in regex there is no && operator


It would be helpful to provide your actual code, together with (any) 
actual results - particularly error messages.

It appears as if the entire log file is read, then the regex is applied. 
Do you know that these log files are ALL fairly short? (I'm debugging an 
email server at the moment, and one inbound message results in perhaps 
100 lines of debug log entries!)

I like to keep things simple. Something like:

open the file using a context manager ("with")
	read a line from the log
	look for ERROR in the first five characters
	if present, report it and the next line

Regex can be difficult - but it is useful to learn how to use them. 
However, it is worth remembering that sometimes their execution can be 
'expensive' - compared to find(), or a five-character slice string 
comparison!

-- 
Regards =dn

From alan.gauld at btinternet.com  Fri Sep 20 04:46:55 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Fri, 20 Sep 2019 09:46:55 +0100
Subject: [Tutor] Failing regex to identify error stack
In-Reply-To: <CAG3LsKFuNEMweRvB8UgGa6dyerPp5V916iwoaF9VNA+h-ASJdg@mail.gmail.com>
References: <CAG3LsKFuNEMweRvB8UgGa6dyerPp5V916iwoaF9VNA+h-ASJdg@mail.gmail.com>
Message-ID: <7ad6d9fd-7f85-1c57-3e42-aa76ece570a1@btinternet.com>

On 20/09/2019 09:09, Asad wrote:
> Hi All ,
>
> I am writing a script in python to read a logfile and identify the first
> error stack :
>
> ?/test/admin/nothing.sql
>
> PL/SQL procedure successfully completed.
> Session altered.
> Package created.
> Session altered.
> Session altered.
> Package body created.
> No errors.
> Session altered.
> PL/SQL procedure successfully completed.
>
> ERROR at line 9:
> Fal-11144: size of object not allowed
>
>
> I am trying to use the following regex :
>
> ^.*/test/admin/.*(?=ERROR at line .*)(?=Fal-.*)

Regex are complex things and hard to debug, I'd probably
use simpler string comparisons and a sentinel.

Something like (untested pseudo code):


inStack = False

stack = []

errorCode = ''

for line in logfile:

???? if line.startswith('?/test/admin/'):?? #start stack

???????? inStack = true

???????? continue

??? if line.startswith('ERROR'):?? # end of stack

??????? inStack = False

??????? continue

??? if inStack:

?????? stack.append(line)

??? else:

?????? errorCode = line

?????? break


You should wind up with stack containing all the lines
between the filename and ERROR and errorCode with
the line after ERROR.


Finally, you could wrap it in a function that returns a
tuple containing stack and errorCode...


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From Steve.Flynn at capita.co.uk  Fri Sep 20 04:29:25 2019
From: Steve.Flynn at capita.co.uk (Flynn, Stephen (Life & Pensions))
Date: Fri, 20 Sep 2019 08:29:25 +0000
Subject: [Tutor] Failing regex to identify error stack
In-Reply-To: <CAG3LsKFuNEMweRvB8UgGa6dyerPp5V916iwoaF9VNA+h-ASJdg@mail.gmail.com>
References: <CAG3LsKFuNEMweRvB8UgGa6dyerPp5V916iwoaF9VNA+h-ASJdg@mail.gmail.com>
Message-ID: <LO2P265MB1375A40ED6868C690D44EA73CA880@LO2P265MB1375.GBRP265.PROD.OUTLOOK.COM>

Oracle error messages are pretty standardised - do you have a pressing need to use RegEx's?

Why not something straightforward such as

If log_line contains "ERROR at line":

Or make use of

log_line.startswith("Fal-")

You're probably going to have to write a regex for each and every Oracle error prefix, like "ORA-" and so forth, so I can't see much benefit in using a RegEx anyway...


S.
-----Original Message-----
From: Tutor <tutor-bounces+steve.flynn=capita.co.uk at python.org> On Behalf Of Asad
Sent: 20 September 2019 09:10
To: tutor at python.org
Subject: [Tutor] Failing regex to identify error stack

Hi All ,

I am writing a script in python to read a logfile and identify the first error stack :

?/test/admin/nothing.sql

PL/SQL procedure successfully completed.
Session altered.
Package created.
Session altered.
Session altered.
Package body created.
No errors.
Session altered.
PL/SQL procedure successfully completed.

ERROR at line 9:
Fal-11144: size of object not allowed


I am trying to use the following regex :

^.*/test/admin/.*(?=ERROR at line .*)(?=Fal-.*)

using lookahead because seems in regex there is no && operator

Please advice .

Thanks,
--
Asad Hasan
+91 9582111698
_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


This message has been scanned by Capita systems, but if you believe it to be spam, please send it to spam at forcepoint.com.

Messages sent to spam at forcepoint.com are queued for email analysis by Forcepoint Threat Lab.


This email is security checked and subject to the disclaimer on web-page: http://www.capita.co.uk/email-disclaimer.aspx

From mats at wichmann.us  Fri Sep 20 10:15:02 2019
From: mats at wichmann.us (Mats Wichmann)
Date: Fri, 20 Sep 2019 08:15:02 -0600
Subject: [Tutor] Failing regex to identify error stack
In-Reply-To: <CAG3LsKFuNEMweRvB8UgGa6dyerPp5V916iwoaF9VNA+h-ASJdg@mail.gmail.com>
References: <CAG3LsKFuNEMweRvB8UgGa6dyerPp5V916iwoaF9VNA+h-ASJdg@mail.gmail.com>
Message-ID: <2c71391f-7df7-f375-76b8-770a8b0c8e50@wichmann.us>

On 9/20/19 2:09 AM, Asad wrote:
> Hi All ,
> 
> I am writing a script in python to read a logfile and identify the first
> error stack :
> 
> ?/test/admin/nothing.sql
> 
> PL/SQL procedure successfully completed.
> Session altered.
> Package created.
> Session altered.
> Session altered.
> Package body created.
> No errors.
> Session altered.
> PL/SQL procedure successfully completed.
> 
> ERROR at line 9:
> Fal-11144: size of object not allowed
> 
> 
> I am trying to use the following regex :
> 
> ^.*/test/admin/.*(?=ERROR at line .*)(?=Fal-.*)
> 
> using lookahead because seems in regex there is no && operator
> 
> Please advice .

As others have said, regexes are hard, and quite probably not the right
tool for this job.

You have not included any code, so we can't tell if you've properly set
up the search in MULTILINE mode, without that a regex has no hope of
doing the right thing when what you are looking for is, well, multiline.

If you *must* persist with a regex, debug the regex separately from the
Python code, they're really two different languages and you don't want
to have problems in one make you waste time debugging problems in the
other.  There are a number of online regex checkers you can paste into,
I like this one because it doesn't nag you with signups, etc.  There's a
button you can click to get it to believe you're using the Python flavor
of regex.

https://regex101.com/



From sjeik_appie at hotmail.com  Fri Sep 20 12:50:27 2019
From: sjeik_appie at hotmail.com (Albert-Jan Roskam)
Date: Fri, 20 Sep 2019 16:50:27 +0000
Subject: [Tutor] Python3 : Yes --- Python2 : No ?
In-Reply-To: <b3d0c78c-93a8-63a9-0fb3-73d2311c0b58@btinternet.com>
Message-ID: <AM7P191MB066450E4EB76258372293CEA83880@AM7P191MB0664.EURP191.PROD.OUTLOOK.COM>



On 15 Sep 2019 09:48, Alan Gauld via Tutor <tutor at python.org> wrote:

On 15/09/2019 07:17, Hendrickx Marcel via Tutor wrote:
> Link with the info =>
>
> https://www.python.org/doc/sunset-python-2/
>
> News for me...

It really shouldn't be a surprise. As the link says its
been announced several times and was always
the intent.

==>> Some bankers pretend to be surprised:
https://www.techrepublic.com/google-amp/article/jpmorgans-athena-has-35-million-lines-of-python-code-and-wont-be-updated-to-python-3-in-time/

From PyTutor at DancesWithMice.info  Fri Sep 20 18:40:45 2019
From: PyTutor at DancesWithMice.info (David L Neil)
Date: Sat, 21 Sep 2019 10:40:45 +1200
Subject: [Tutor] Python3 : Yes --- Python2 : No ?
In-Reply-To: <AM7P191MB066450E4EB76258372293CEA83880@AM7P191MB0664.EURP191.PROD.OUTLOOK.COM>
References: <AM7P191MB066450E4EB76258372293CEA83880@AM7P191MB0664.EURP191.PROD.OUTLOOK.COM>
Message-ID: <f7379c7a-38e4-91a0-4f3a-221044687336@DancesWithMice.info>

On 21/09/19 4:50 AM, Albert-Jan Roskam wrote:
> On 15 Sep 2019 09:48, Alan Gauld via Tutor <tutor at python.org> wrote:
> On 15/09/2019 07:17, Hendrickx Marcel via Tutor wrote:
>> Link with the info =>
>> https://www.python.org/doc/sunset-python-2/
>> News for me...
> It really shouldn't be a surprise. As the link says its
> been announced several times and was always
> the intent.
> ==>> Some bankers pretend to be surprised:
> https://www.techrepublic.com/google-amp/article/jpmorgans-athena-has-35-million-lines-of-python-code-and-wont-be-updated-to-python-3-in-time/


My first temptation is to comment that business decisions are often made 
by managers and board members who have little understanding of computers 
and technology - which leads into *two* reasons why the same (type) 
demand that their specialist staff have five years' experience in some 
facility which has only been around for two!
(read Dilbert cartoons for similar)

Banking is no exception to this. To gain a good idea of banking 
management's understanding of technology (and finance!) ask yourself the 
'who' and the 'how' of the Global Financial Crisis?
(sorry, my sympathies require a microscope to see - and my advice, 
should your bank be acting similarly, is to consider moving elsewhere!)


That said, it is very difficult to put either a cost or a benefit on 
'technical upgrades'. Which is why the text-books say "there are no 
technical projects".

The business benefit of changing from Python2 to 3 has been dubious in 
the present, and difficult to comprehend in the future tense. There is 
no direct benefit in the sense of marginal income. Even on the technical 
side there have been pythonista feeling forced/quite comfortable staying 
with Python2 because the libraries they wish to employ are not (yet) 
available in Python3. I was reviewing a system yesterday for a PoC, and 
discovered (to my horror) that they have yet to complete their Py3 
upgrade. Plus the old saw: "if it ain't broke, don't fix it".

Thus, the technical viewpoint and criteria for assessment are a long way 
from those of our 'business' colleagues!


Further to Alan's dates: (*ten* years already!) I've just finished 
reading (a somewhat irreverent article, laced with British sardonic 
humor - which many other cultures just don't 'get') this week's "The 
Register":

<<<
At the turn of the century, panicked organisations found themselves 
calling in COBOL coders, often those responsible for the decades-old 
systems in the first place, to deal with the impact of those crucial 
extra digits.

That some today reckon the event was a bit of a damp squib, manufactured 
by highly paid contractors to add a Ferrari or two to the garage, is 
testament to the monumental efforts by those involved at the time. 
You're welcome.
 >>>

They are talking about a time when a *FORTY* year old language (and its 
code-base) was in need of checking and amelioration - a need which had 
been identified for about the same length of time as the language had 
been in-use (certainly, my education included an observation that 
two-digit year-dates were going to become an ever-greater problem).

	if this_year - birth_year > minimum_age: # allow...

	if 19 - 91 > 18: 	# ok
	else: 			# no, you're not old-enough to vote!
				# even though (you think) you're 28

Oops! Whereas:

	if 2019 - 1991 > 18:	# welcome to 21st century democracy!

So, this problem of 'delay' is nothing new!


WebRef:
COBOL: Five little letters that if put on a CV would ensure stable 
income for many a greybeard coder
EVALUATE COBOL-AGE WHEN 60 CONTINUE
By Richard Speed 16 Sep 2019 at 09:09
https://www.theregister.co.uk/2019/09/16/cobol_at_60/


Disclaimers:
1. This is no apologia, I have (almost) only used Py3 for the last five 
years (and probably longer) - that said, am keenly awaiting the release 
of CentOS8 (next week, dv), which upgrade will under-pin the migration 
of a long-running Py2 system. Once again: a project which is very hard 
to justify from the stand-point of 'conducting our business' and only 
comes under the 'technical debt'/don't store-up trouble for the future, 
headings!

2. I was PM on a Y2K Project, which became the first significant (and 
real-time) operation to enter the new century, and by 'living or dying' 
act as a bellwether for organisations world-wide. Somewhere, I have 
(multiple) certificates from organisations such as Microsoft, because we 
found issues before they did themselves - so it's not only bankers then! 
I've heard many criticise Y2K as 'overblown' or 'manufactured into a 
legend', however we 'sweated bullets' to make it look easy - and some 
who didn't paid a significant price, up-to, or is that down-to, the 
eventual collapse of whole companies.

3. I do have a gray/grey beard, but no, I don't drive a Ferrari - in 
fact, if you own a car, chances are it is newer and more 'flash' than mine!

-- 
Regards =dn

From robertvstepp at gmail.com  Sat Sep 21 00:34:45 2019
From: robertvstepp at gmail.com (boB Stepp)
Date: Fri, 20 Sep 2019 23:34:45 -0500
Subject: [Tutor] Interesting book: "Python GUI Programming with Tkinter"
In-Reply-To: <CANDiX9Li2figMmYAffkG9PKcvbseP3PQ_Du1R7sdj_qCdLA+Hg@mail.gmail.com>
References: <CANDiX9Li2figMmYAffkG9PKcvbseP3PQ_Du1R7sdj_qCdLA+Hg@mail.gmail.com>
Message-ID: <CANDiX9KVZMzBZsDbvc+PZ60rAvT=Oy_=A5FGLNJN5G52wXB3Gg@mail.gmail.com>

I have been enjoying working with the book "Python GUI Programming
with Tkinter -- Develop responsive and powerful GUI applications with
Tkinter" by Alan D. Moore, c. 2018, published by Packt.

At the time of the book's writing Python 3.6.4 was current, though the
author frequently mentions the imminent arrival of Python 3.7 by
publishing time.  The book uses Tcl/Tk 8.6 though the author takes
pain to mention when something is 8.6 specific.  It emphasizes the use
of the ttk widgets, which typically give a more modern look and feel
than the tk widgets.  It does not cover tix widgets at all other than
mentioning they should be considered deprecated in terms of providing
a modern look and feel.

I like the approach the author is taking.  He states you are a
programmer for the fictional company ABQ AgriLabs.  You are assigned
the project of developing a simple data entry form which stores the
data as a CSV file.  The idea is to make data entry for the lab
technicians easier, quicker and error resistant.  Starting from this
beginning you are introduced to most of the functionality of tkinter.
The book assumes a basic grasp of Python 3 from the reader, including
the ability to write custom classes.  As your simple data entry form
gets used and receives user feedback from the fictional lab techs,
your program grows in scope.  The author addresses how to handle this
growth intelligently and speaks to good design and programming
practices.  By the end of the book your program has a PostgreSQL
backend, connects to the cloud, uses asynchronous program where
appropriate, uses both unit and integration testing and is packaged
for either PyPI or distributed as an executable for Windows, Mac or
Linux.

The author sometimes is brief, but other than basic Python knowledge
seems to assume nothing else on the part of the reader.  So, for
instance, he gives a crash course in SQL and relational databases
before getting into developing the database backend for PostgreSQL.
I'm several chapters into the book and feel I have learned a lot.

A coarse table of contents:

Preface
Ch. 1:  Introduction to Tkinter
    Introducing Tkinter and Tk
    Introducing IDLE  # Uses as an example of what can be done with tkinter.
    Creating a Tkinter Hello World

Ch. 2:  Designing GUI Applications with Tkinter
    A problem at ABQ AgriLabs
    Documenting specification requirements
    Designing the application

Ch. 3:  Creating Basic Forms with Tkinter and ttk Widgets
    Evaluating our technology choices
    Exploring Tkinter widgets
    Implementing the application

Ch. 4:  Reducing User Error with Validation and Automation
    Validating user input
    Validation in Tkinter
    Implementing validated widgets in our form
    Automating input

Ch. 5:  Planning for the Expansion of Our Application
    Separating concerns
        The MVC pattern
    Structuring our application directory
    Splitting our application into multiple  files
    Using version control software  # Gives a quick intro to Git

Ch. 6:  Creating Menus with Menu and Tkinter Dialogs
    Solving problems in our application
    Implementing simple Tkinter dialogs
    Designing our menu
    Making our settings work
        Persisting settings  # Introduces json for this purpose

Ch. 7:  Navigating Records with Treeview
    Implementing read and update in the model
    Implementing a record list view
    Modifying the record form for read and update
    Updating the rest of the application

Ch. 8:  Improving the Look with Styles and Themes
    Working with images in Tkinter
    Styling Tkinter widgets
    Styling Ttk widgets

Ch. 9:  Maintaining Cross-Platform Compatibility
    Writing cross-platform Python
        Filenames and filepaths across platforms
        Inconsistent library and feature support
        The dangers of the subprocess module
        Text file encodings and formats
        Graphical and console modes
        Writing code that changes according to the platform
    Writing cross-platform Tkinter
        Tkinter version differences across platforms
        Application menus across platforms
        Accelerator keys
        Fonts
        Theme support
        Window zoomed state
    Improving our application's cross-platform compatibility
        Storing preferences correctly
        Specifying an encoding for our CSV file
        Making platform-appropriate menus

Ch. 10:  Creating Automated Tests with unittest
    Automated testing basics
    Testing Tkinter code
        Managing asynchronous code
        Simulating user actions
        Managing focus and grab
        Getting widget information
    Writing tests for our application

Ch. 11:  Improving Data Storage with SQL
    PostgreSQL
    SQL and relational database basics
    Modeling relational data
    Creating the ABQ database
    Integrating SQL into our application

Ch. 12:  Connecting to the Cloud
    HTTP using urllib
    HTTP using requests
    FTP using ftplib

Ch. 13:  Asynchronous Programming with Thread and Queue
    Tkinter's event queue
    Running code in the background with threading
    Passing messages using a queue

Ch. 14:  Visualizing Data Using the Canvas Widget
    Drawing and animation with Tkinter's Canvas
    Creating simple graphs on the canvas
    Advanced graphs using Matplotlib and Tkinter

Ch. 15:  Packaging with setuptools and cx_Freeze
    Using setuptools
    Using cx_Freeze
    Building Windows executables with cx_Freeze
    Building macOS executables with cx_Freeze

--
boB


-- 
boB

From robertvstepp at gmail.com  Sat Sep 21 00:47:10 2019
From: robertvstepp at gmail.com (boB Stepp)
Date: Fri, 20 Sep 2019 23:47:10 -0500
Subject: [Tutor] super() vs. explicitly calling base class?
Message-ID: <CANDiX9JgJdt0NVdMqmqEtnCAjDz2qjRh==_zbZt6xCpPJr+UVA@mail.gmail.com>

Python 3.7.4 on Linux Mint

Assumption:  I have only TWO classes (Not concerned about 3+ class
inheritance scenario), Base and Child.  Is there any advantage to
using super() over explicitly calling Base from within Child?  My
following trivial example does not suggest any difference:

>>> class Base:
    def __init__(self):
        print("This is the Base class!")
>>> class Child(Base):
    def __init__(self):
        print("This is the Child class!")
    def call_base(self):
        print("About to call the Base class with super!")
        super().__init__()
        print("Now explicitly calling the Base class!")
        Base.__init__(self)
>>> a = Base()
This is the Base class!
>>> b = Child()
This is the Child class!
>>> b.call_base()
About to call the Base class with super!
This is the Base class!
Now explicitly calling the Base class!
This is the Base class!

-- 
boB

From PyTutor at DancesWithMice.info  Sat Sep 21 00:55:12 2019
From: PyTutor at DancesWithMice.info (David L Neil)
Date: Sat, 21 Sep 2019 16:55:12 +1200
Subject: [Tutor] Python3 : Yes --- Python2 : No ?
In-Reply-To: <BN8PR11MB37648EFE76DEC4FC9CC93A2CE08B0@BN8PR11MB3764.namprd11.prod.outlook.com>
References: <AM7P191MB066450E4EB76258372293CEA83880@AM7P191MB0664.EURP191.PROD.OUTLOOK.COM>
 <f7379c7a-38e4-91a0-4f3a-221044687336@DancesWithMice.info>
 <BN8PR11MB37648EFE76DEC4FC9CC93A2CE08B0@BN8PR11MB3764.namprd11.prod.outlook.com>
Message-ID: <ed32d01a-2c97-37e1-5133-6b2ab5da5012@DancesWithMice.info>

On 21/09/19 12:04 PM, Mike Barnett wrote:
> I have a python package that's pip installable.
> 
> The python 3 version stats:
> 
> Date	Downloads
> 2019-09-19	861
> 2019-09-18	771
> 2019-09-17	1,076
> 2019-09-16	787
> 2019-09-15	496
> 2019-09-14	662
> 2019-09-13	1,075
> 
> 
> The python 2 version stats:
> 
> Date	Downloads
> 2019-09-19	215
> 2019-09-18	211
> 2019-09-17	478
> 2019-09-16	268
> 2019-09-15	20
> 2019-09-14	252
> 2019-09-13	593
> 
> 
> As much as I WANT Python 2 to be gone it appears to be far from it.  I've given notice multiple times that the code is frozen, it's going away, and have pledged to delete the Python 2 release from the GitHub on Dec 31 2019.  And yet the 2.7 installs are as strong as ever.


Is this pkg possibly/often used in conjunction with others which are not 
Python3-based?

To be fair, some of us do forget to pip3.

Even so, these numbers are scary!
-- 
Regards =dn

From PyTutor at danceswithmice.info  Sat Sep 21 04:23:42 2019
From: PyTutor at danceswithmice.info (DL Neil)
Date: Sat, 21 Sep 2019 20:23:42 +1200
Subject: [Tutor] super() vs. explicitly calling base class?
In-Reply-To: <CANDiX9JgJdt0NVdMqmqEtnCAjDz2qjRh==_zbZt6xCpPJr+UVA@mail.gmail.com>
References: <CANDiX9JgJdt0NVdMqmqEtnCAjDz2qjRh==_zbZt6xCpPJr+UVA@mail.gmail.com>
Message-ID: <0d91dd04-cae9-4861-e918-1eeaca53e42b@DancesWithMice.info>

On 21/09/19 4:47 PM, boB Stepp wrote:
> Python 3.7.4 on Linux Mint
> 
> Assumption:  I have only TWO classes (Not concerned about 3+ class
> inheritance scenario), Base and Child.  Is there any advantage to
> using super() over explicitly calling Base from within Child?  My
> following trivial example does not suggest any difference:
> 
>>>> class Base:
>      def __init__(self):
>          print("This is the Base class!")
>>>> class Child(Base):
>      def __init__(self):
>          print("This is the Child class!")
>      def call_base(self):
>          print("About to call the Base class with super!")
>          super().__init__()
>          print("Now explicitly calling the Base class!")
>          Base.__init__(self)

super() is usually considered the more 'pythonic'.
Should the name of the super class ever change, the Child class 
declaration will need to be changed accordingly. However, nothing else. 
If the super class is mentioned by name, then in that case every mention 
of the name would have to be changed.

That said, how often are classNMs changed?
-- 
Regards =dn

From cs at cskk.id.au  Sat Sep 21 04:19:12 2019
From: cs at cskk.id.au (Cameron Simpson)
Date: Sat, 21 Sep 2019 18:19:12 +1000
Subject: [Tutor] super() vs. explicitly calling base class?
In-Reply-To: <CANDiX9JgJdt0NVdMqmqEtnCAjDz2qjRh==_zbZt6xCpPJr+UVA@mail.gmail.com>
References: <CANDiX9JgJdt0NVdMqmqEtnCAjDz2qjRh==_zbZt6xCpPJr+UVA@mail.gmail.com>
Message-ID: <20190921081912.GA66289@cskk.homeip.net>

On 20Sep2019 23:47, boB Stepp <robertvstepp at gmail.com> wrote:
>Assumption:  I have only TWO classes (Not concerned about 3+ class
>inheritance scenario), Base and Child.  Is there any advantage to
>using super() over explicitly calling Base from within Child?  My
>following trivial example does not suggest any difference:
>
>>>> class Base:
>    def __init__(self):
>        print("This is the Base class!")
>>>> class Child(Base):
>    def __init__(self):
>        print("This is the Child class!")
>    def call_base(self):
>        print("About to call the Base class with super!")
>        super().__init__()
>        print("Now explicitly calling the Base class!")
>        Base.__init__(self)
[...]

Well you wouldn't do both of course.

If you have the setup above, then super() is equivalent to directly 
calling the base class.

Personally I tend to use super() so that in the future when I make the 
class more complex (or just change the superclass from Base to 
OtherBase) it reduces the number of things needing modification.

Cheers,
Cameron Simpson <cs at cskk.id.au>

From mats at wichmann.us  Sat Sep 21 08:46:12 2019
From: mats at wichmann.us (Mats Wichmann)
Date: Sat, 21 Sep 2019 06:46:12 -0600
Subject: [Tutor] Python3 : Yes --- Python2 : No ?
In-Reply-To: <AM7P191MB066450E4EB76258372293CEA83880@AM7P191MB0664.EURP191.PROD.OUTLOOK.COM>
References: <AM7P191MB066450E4EB76258372293CEA83880@AM7P191MB0664.EURP191.PROD.OUTLOOK.COM>
Message-ID: <0794395f-570b-b342-b79b-4a6810032eb9@wichmann.us>

On 9/20/19 10:50 AM, Albert-Jan Roskam wrote:
> 
> 
> On 15 Sep 2019 09:48, Alan Gauld via Tutor <tutor at python.org> wrote:
> 
> On 15/09/2019 07:17, Hendrickx Marcel via Tutor wrote:
>> Link with the info =>
>>
>> https://www.python.org/doc/sunset-python-2/
>>
>> News for me...
> 
> It really shouldn't be a surprise. As the link says its
> been announced several times and was always
> the intent.
> 
> ==>> Some bankers pretend to be surprised:
> https://www.techrepublic.com/google-amp/article/jpmorgans-athena-has-35-million-lines-of-python-code-and-wont-be-updated-to-python-3-in-time/

There are also millions - perhaps billions - of lines of COBOL still in
use... so we should NOT pretend to be surprised they're surprised :)

Python 2 has no time bomb, it won't stop working.  The Python
development community has decided not to split their efforts any longer,
and lots of projects agree to go along, so it will become ever harder to
get "the current version" of something if you're on Py2, as it will
probably only be available for Py3.  But that doesn't cause a complete
already working project just to fails...

As one who is helping maintain a 2+3 capable code base, it's a pain; in
addition to always fighting little surprises, you leave a lot of
productivity on the table by always having to fall back to the oldest
stuff, or else try to backport (or find someone else who has backported).



From mats at wichmann.us  Sat Sep 21 11:31:15 2019
From: mats at wichmann.us (Mats Wichmann)
Date: Sat, 21 Sep 2019 09:31:15 -0600
Subject: [Tutor] super() vs. explicitly calling base class?
In-Reply-To: <CANDiX9JgJdt0NVdMqmqEtnCAjDz2qjRh==_zbZt6xCpPJr+UVA@mail.gmail.com>
References: <CANDiX9JgJdt0NVdMqmqEtnCAjDz2qjRh==_zbZt6xCpPJr+UVA@mail.gmail.com>
Message-ID: <6f12256b-1c95-457d-f229-32c442eaef44@wichmann.us>

On 9/20/19 10:47 PM, boB Stepp wrote:
> Python 3.7.4 on Linux Mint
> 
> Assumption:  I have only TWO classes (Not concerned about 3+ class
> inheritance scenario), Base and Child.  Is there any advantage to
> using super() over explicitly calling Base from within Child?  My
> following trivial example does not suggest any difference:

The difference is that one way is hardwired and the other (as befits a
dynamic language) is a computed indirect reference. That means in
addition to protecting you from having to change references if you
change the class hierarchy, you also have the opportunity to influence
the way it resolves to the class it will delegate to.

If all that sounds too much it may actually be: if you *really* know for
sure there will only ever be these two classes and you know exactly how
they will be used, then fine, hardwire the relationship.  There are some
people who don't think super is useful.  There's a famous paper that was
written under the title "Python's Super Considered Harmful" - the author
later retitled it "Python's Super is nifty, but you can't use it".
Naturally, there's also work entitled "Super Considered Super"!

Would just like to remind: that function there which prints "This is the
Base class!" - isn't really "in" it.  The def statement causes a
function object to be created, and a reference to that function object,
with the name "__init__", goes into the dictionary that was created by
the Base class definition. But it has no phyical attachment to Base...
all it knows about is the instance object (plus remaining args - none in
this case) it is passed - and the 2nd and 3rd times it runs it is
actually running with a Child object. That makes zero difference if the
work you're asking it to do is print a string, but it does have
implications in designing more complex methods if super is going to be
in play.  In particular, it means harmonizing the way arguments are
handled by methods of the same name in a class hierarchy. Classes are
... "different" in Python :)


>>>> class Base:
>     def __init__(self):
>         print("This is the Base class!")
>>>> class Child(Base):
>     def __init__(self):
>         print("This is the Child class!")
>     def call_base(self):
>         print("About to call the Base class with super!")
>         super().__init__()
>         print("Now explicitly calling the Base class!")
>         Base.__init__(self)
>>>> a = Base()
> This is the Base class!
>>>> b = Child()
> This is the Child class!
>>>> b.call_base()
> About to call the Base class with super!
> This is the Base class!
> Now explicitly calling the Base class!
> This is the Base class!
> 


From robertvstepp at gmail.com  Sat Sep 21 16:44:11 2019
From: robertvstepp at gmail.com (boB Stepp)
Date: Sat, 21 Sep 2019 15:44:11 -0500
Subject: [Tutor] super() vs. explicitly calling base class?
In-Reply-To: <6f12256b-1c95-457d-f229-32c442eaef44@wichmann.us>
References: <CANDiX9JgJdt0NVdMqmqEtnCAjDz2qjRh==_zbZt6xCpPJr+UVA@mail.gmail.com>
 <6f12256b-1c95-457d-f229-32c442eaef44@wichmann.us>
Message-ID: <CANDiX9Jq6Zs16OAsm2aTjy81FVfNsh+HwAOxNwXSw+q5u=D77w@mail.gmail.com>

On Sat, Sep 21, 2019 at 10:31 AM Mats Wichmann <mats at wichmann.us> wrote:
>
> On 9/20/19 10:47 PM, boB Stepp wrote:
> > Python 3.7.4 on Linux Mint
> >
> > Assumption:  I have only TWO classes (Not concerned about 3+ class
> > inheritance scenario), Base and Child.  Is there any advantage to
> > using super() over explicitly calling Base from within Child?  My
> > following trivial example does not suggest any difference:
>
> The difference is that one way is hardwired and the other (as befits a
> dynamic language) is a computed indirect reference. That means in
> addition to protecting you from having to change references if you
> change the class hierarchy, you also have the opportunity to influence
> the way it resolves to the class it will delegate to.

My main point on asking about this is to be sure that I am not
overlooking any subtleties going on behind the scenes that could make
a meaningful difference.  Thankfully there do not seem to be any this
time!

So from your answer and the others', what I am taking away from this
is that super() is more flexible and easier to maintain IF I am happy
with super() triggering on the method or attribute in the immediate
next superclass with that name.  However, I imagine that if I *did*
have more than two classes involved in the inheritance chain *and* I
wanted not the next higher, say __init__(), but say the one a
superclass higher, then in that circumstance I would need to use that
class' actual name to access its __init__() method or whichever I am
interested in.

> If all that sounds too much it may actually be: if you *really* know for
> sure there will only ever be these two classes and you know exactly how
> they will be used, then fine, hardwire the relationship.  There are some
> people who don't think super is useful.  There's a famous paper that was
> written under the title "Python's Super Considered Harmful" - the author
> later retitled it "Python's Super is nifty, but you can't use it".
> Naturally, there's also work entitled "Super Considered Super"!

I'll have to search for links to these; sound interesting.  The "Super
Considered Super" sounds like a video I may have already viewed, but I
won't know until I check.

> Would just like to remind: that function there which prints "This is the
> Base class!" - isn't really "in" it.  The def statement causes a
> function object to be created, and a reference to that function object,
> with the name "__init__", goes into the dictionary that was created by
> the Base class definition. But it has no phyical attachment to Base...
> all it knows about is the instance object (plus remaining args - none in
> this case) it is passed - and the 2nd and 3rd times it runs it is
> actually running with a Child object. That makes zero difference if the
> work you're asking it to do is print a string, but it does have
> implications in designing more complex methods if super is going to be
> in play.  In particular, it means harmonizing the way arguments are
> handled by methods of the same name in a class hierarchy. Classes are
> ... "different" in Python :)

You got me on a technicality here!  I will try to be more precise next
time.  But this reminds me of a technique that I am repeatedly seeing
of "cleaning up" the remaining arguments using **kwargs.  I'm still
not sure I understand this in practice, so I will eventually pose a
more targeted question about this technique.

Thanks everyone!


-- 
boB

From alan.gauld at yahoo.co.uk  Sat Sep 21 17:39:32 2019
From: alan.gauld at yahoo.co.uk (Alan G)
Date: Sat, 21 Sep 2019 22:39:32 +0100
Subject: [Tutor] super() vs. explicitly calling base class?
In-Reply-To: <CANDiX9Jq6Zs16OAsm2aTjy81FVfNsh+HwAOxNwXSw+q5u=D77w@mail.gmail.com>
References: <8878a638-ab9b-411f-a2e8-0c139c9faba0.ref@email.android.com>
Message-ID: <8878a638-ab9b-411f-a2e8-0c139c9faba0@email.android.com>

   Using my phone so super(sic) short. Be very very careful about jumping a
   class, especially in init(). It could leave the immediate superclass
   improperly initialised (or not initialised at all). That can lead to very
   odd behaviour when you call other methods. You need an intimate knowledge
   of all superclasses and their code to do that safely.
   Alan G.?
   On 21 Sep 2019 21:44, boB Stepp <robertvstepp at gmail.com> wrote:

     On Sat, Sep 21, 2019 at 10:31 AM Mats Wichmann <mats at wichmann.us>
     wrote:
     >
     > On 9/20/19 10:47 PM, boB Stepp wrote:
     > > Python 3.7.4 on Linux Mint
     > >
     > > Assumption:? I have only TWO classes (Not concerned about 3+ class
     > > inheritance scenario), Base and Child.? Is there any advantage to
     > > using super() over explicitly calling Base from within Child?? My
     > > following trivial example does not suggest any difference:
     >
     > The difference is that one way is hardwired and the other (as befits
     a
     > dynamic language) is a computed indirect reference. That means in
     > addition to protecting you from having to change references if you
     > change the class hierarchy, you also have the opportunity to
     influence
     > the way it resolves to the class it will delegate to.

     My main point on asking about this is to be sure that I am not
     overlooking any subtleties going on behind the scenes that could make
     a meaningful difference.? Thankfully there do not seem to be any this
     time!

     So from your answer and the others', what I am taking away from this
     is that super() is more flexible and easier to maintain IF I am happy
     with super() triggering on the method or attribute in the immediate
     next superclass with that name.? However, I imagine that if I *did*
     have more than two classes involved in the inheritance chain *and* I
     wanted not the next higher, say __init__(), but say the one a
     superclass higher, then in that circumstance I would need to use that
     class' actual name to access its __init__() method or whichever I am
     interested in.

     > If all that sounds too much it may actually be: if you *really* know
     for
     > sure there will only ever be these two classes and you know exactly
     how
     > they will be used, then fine, hardwire the relationship.? There are
     some
     > people who don't think super is useful.? There's a famous paper that
     was
     > written under the title "Python's Super Considered Harmful" - the
     author
     > later retitled it "Python's Super is nifty, but you can't use it".
     > Naturally, there's also work entitled "Super Considered Super"!

     I'll have to search for links to these; sound interesting.? The "Super
     Considered Super" sounds like a video I may have already viewed, but I
     won't know until I check.

     > Would just like to remind: that function there which prints "This is
     the
     > Base class!" - isn't really "in" it.? The def statement causes a
     > function object to be created, and a reference to that function
     object,
     > with the name "__init__", goes into the dictionary that was created
     by
     > the Base class definition. But it has no phyical attachment to
     Base...
     > all it knows about is the instance object (plus remaining args - none
     in
     > this case) it is passed - and the 2nd and 3rd times it runs it is
     > actually running with a Child object. That makes zero difference if
     the
     > work you're asking it to do is print a string, but it does have
     > implications in designing more complex methods if super is going to
     be
     > in play.? In particular, it means harmonizing the way arguments are
     > handled by methods of the same name in a class hierarchy. Classes are
     > ... "different" in Python :)

     You got me on a technicality here!? I will try to be more precise next
     time.? But this reminds me of a technique that I am repeatedly seeing
     of "cleaning up" the remaining arguments using **kwargs.? I'm still
     not sure I understand this in practice, so I will eventually pose a
     more targeted question about this technique.

     Thanks everyone!


     --
     boB
     _______________________________________________
     Tutor maillist? -? Tutor at python.org
     To unsubscribe or change subscription options:
     https://mail.python.org/mailman/listinfo/tutor

From alan.gauld at yahoo.co.uk  Sat Sep 21 17:39:32 2019
From: alan.gauld at yahoo.co.uk (Alan G)
Date: Sat, 21 Sep 2019 22:39:32 +0100
Subject: [Tutor] super() vs. explicitly calling base class?
In-Reply-To: <CANDiX9Jq6Zs16OAsm2aTjy81FVfNsh+HwAOxNwXSw+q5u=D77w@mail.gmail.com>
References: <8878a638-ab9b-411f-a2e8-0c139c9faba0.ref@email.android.com>
Message-ID: <8878a638-ab9b-411f-a2e8-0c139c9faba0@email.android.com>

   Using my phone so super(sic) short. Be very very careful about jumping a
   class, especially in init(). It could leave the immediate superclass
   improperly initialised (or not initialised at all). That can lead to very
   odd behaviour when you call other methods. You need an intimate knowledge
   of all superclasses and their code to do that safely.
   Alan G.?
   On 21 Sep 2019 21:44, boB Stepp <robertvstepp at gmail.com> wrote:

     On Sat, Sep 21, 2019 at 10:31 AM Mats Wichmann <mats at wichmann.us>
     wrote:
     >
     > On 9/20/19 10:47 PM, boB Stepp wrote:
     > > Python 3.7.4 on Linux Mint
     > >
     > > Assumption:? I have only TWO classes (Not concerned about 3+ class
     > > inheritance scenario), Base and Child.? Is there any advantage to
     > > using super() over explicitly calling Base from within Child?? My
     > > following trivial example does not suggest any difference:
     >
     > The difference is that one way is hardwired and the other (as befits
     a
     > dynamic language) is a computed indirect reference. That means in
     > addition to protecting you from having to change references if you
     > change the class hierarchy, you also have the opportunity to
     influence
     > the way it resolves to the class it will delegate to.

     My main point on asking about this is to be sure that I am not
     overlooking any subtleties going on behind the scenes that could make
     a meaningful difference.? Thankfully there do not seem to be any this
     time!

     So from your answer and the others', what I am taking away from this
     is that super() is more flexible and easier to maintain IF I am happy
     with super() triggering on the method or attribute in the immediate
     next superclass with that name.? However, I imagine that if I *did*
     have more than two classes involved in the inheritance chain *and* I
     wanted not the next higher, say __init__(), but say the one a
     superclass higher, then in that circumstance I would need to use that
     class' actual name to access its __init__() method or whichever I am
     interested in.

     > If all that sounds too much it may actually be: if you *really* know
     for
     > sure there will only ever be these two classes and you know exactly
     how
     > they will be used, then fine, hardwire the relationship.? There are
     some
     > people who don't think super is useful.? There's a famous paper that
     was
     > written under the title "Python's Super Considered Harmful" - the
     author
     > later retitled it "Python's Super is nifty, but you can't use it".
     > Naturally, there's also work entitled "Super Considered Super"!

     I'll have to search for links to these; sound interesting.? The "Super
     Considered Super" sounds like a video I may have already viewed, but I
     won't know until I check.

     > Would just like to remind: that function there which prints "This is
     the
     > Base class!" - isn't really "in" it.? The def statement causes a
     > function object to be created, and a reference to that function
     object,
     > with the name "__init__", goes into the dictionary that was created
     by
     > the Base class definition. But it has no phyical attachment to
     Base...
     > all it knows about is the instance object (plus remaining args - none
     in
     > this case) it is passed - and the 2nd and 3rd times it runs it is
     > actually running with a Child object. That makes zero difference if
     the
     > work you're asking it to do is print a string, but it does have
     > implications in designing more complex methods if super is going to
     be
     > in play.? In particular, it means harmonizing the way arguments are
     > handled by methods of the same name in a class hierarchy. Classes are
     > ... "different" in Python :)

     You got me on a technicality here!? I will try to be more precise next
     time.? But this reminds me of a technique that I am repeatedly seeing
     of "cleaning up" the remaining arguments using **kwargs.? I'm still
     not sure I understand this in practice, so I will eventually pose a
     more targeted question about this technique.

     Thanks everyone!


     --
     boB
     _______________________________________________
     Tutor maillist? -? Tutor at python.org
     To unsubscribe or change subscription options:
     https://mail.python.org/mailman/listinfo/tutor

From Richard at Damon-Family.org  Sat Sep 21 17:55:30 2019
From: Richard at Damon-Family.org (Richard Damon)
Date: Sat, 21 Sep 2019 17:55:30 -0400
Subject: [Tutor] super() vs. explicitly calling base class?
In-Reply-To: <8878a638-ab9b-411f-a2e8-0c139c9faba0@email.android.com>
References: <8878a638-ab9b-411f-a2e8-0c139c9faba0.ref@email.android.com>
 <8878a638-ab9b-411f-a2e8-0c139c9faba0@email.android.com>
Message-ID: <1c4f4aaf-735a-28ca-a20f-0ca07ee11f0c@Damon-Family.org>

One other thing to note, even if you know who you are derived from, (or
not derived from anyone), you should still use super if someone might
derive from you, as that can change the proper initialization order (if
ANYONE uses multiple inheritance).

-- 
Richard Damon


From alan.gauld at yahoo.co.uk  Sat Sep 21 18:06:24 2019
From: alan.gauld at yahoo.co.uk (Alan G)
Date: Sat, 21 Sep 2019 23:06:24 +0100
Subject: [Tutor] Python3 : Yes --- Python2 : No ?
In-Reply-To: <0794395f-570b-b342-b79b-4a6810032eb9@wichmann.us>
References: <90a28d43-e341-48b7-86f6-2809519def52.ref@email.android.com>
Message-ID: <90a28d43-e341-48b7-86f6-2809519def52@email.android.com>

   I'm using my phone so format may be messed up, sorry...?
   <There are also millions - perhaps billions - of lines of COBOL still in
   use...?
   That's a slightly different case since COBOL is a language still in active
   development with new versions coming out regularly (as in every 10 years
   or so.) and there is even an object oriented variant(in fact more than
   one!) . Indeed there are many new COBOL projects being written because
   COBOL has unique features that make it the best language for high volume
   batch processing of data, especially file based data on a mainframe
   architecture.?
   It's not a single version that is now obsolescent. That having been said
   there will doubtless be systems still using COBOL from the Y2K period. But
   most COBOL compilers are commercial and provide full support(at a price)
   for old versions. Very different from an open source language like
   Python.?
   Anyone still using a 1970s or earlier version of cobol deserves all they
   get but most large organisations update their OS and compiler more often
   than that. Just because the language is 60 years old don't assume the
   version is.?

     Alan G.?

From alan.gauld at yahoo.co.uk  Sat Sep 21 18:06:24 2019
From: alan.gauld at yahoo.co.uk (Alan G)
Date: Sat, 21 Sep 2019 23:06:24 +0100
Subject: [Tutor] Python3 : Yes --- Python2 : No ?
In-Reply-To: <0794395f-570b-b342-b79b-4a6810032eb9@wichmann.us>
References: <90a28d43-e341-48b7-86f6-2809519def52.ref@email.android.com>
Message-ID: <90a28d43-e341-48b7-86f6-2809519def52@email.android.com>

   I'm using my phone so format may be messed up, sorry...?
   <There are also millions - perhaps billions - of lines of COBOL still in
   use...?
   That's a slightly different case since COBOL is a language still in active
   development with new versions coming out regularly (as in every 10 years
   or so.) and there is even an object oriented variant(in fact more than
   one!) . Indeed there are many new COBOL projects being written because
   COBOL has unique features that make it the best language for high volume
   batch processing of data, especially file based data on a mainframe
   architecture.?
   It's not a single version that is now obsolescent. That having been said
   there will doubtless be systems still using COBOL from the Y2K period. But
   most COBOL compilers are commercial and provide full support(at a price)
   for old versions. Very different from an open source language like
   Python.?
   Anyone still using a 1970s or earlier version of cobol deserves all they
   get but most large organisations update their OS and compiler more often
   than that. Just because the language is 60 years old don't assume the
   version is.?

     Alan G.?

From robertvstepp at gmail.com  Sat Sep 21 18:12:33 2019
From: robertvstepp at gmail.com (boB Stepp)
Date: Sat, 21 Sep 2019 17:12:33 -0500
Subject: [Tutor] super() vs. explicitly calling base class?
In-Reply-To: <1c4f4aaf-735a-28ca-a20f-0ca07ee11f0c@Damon-Family.org>
References: <8878a638-ab9b-411f-a2e8-0c139c9faba0.ref@email.android.com>
 <8878a638-ab9b-411f-a2e8-0c139c9faba0@email.android.com>
 <1c4f4aaf-735a-28ca-a20f-0ca07ee11f0c@Damon-Family.org>
Message-ID: <CANDiX9+tuokig9HiEG-1UiOdntab6SgQF+TEOFJEE4BmzaY3Sw@mail.gmail.com>

Sigh.  Programming is so difficult in attempting to control the
complexity that may ensue!

On Sat, Sep 21, 2019 at 4:56 PM Richard Damon <Richard at damon-family.org> wrote:
>
> One other thing to note, even if you know who you are derived from, (or
> not derived from anyone), you should still use super if someone might
> derive from you, as that can change the proper initialization order (if
> ANYONE uses multiple inheritance).

I just finished reading the first of Mats' references, "Python's Super
is nifty, but you can't use it (Previously: Python's Super Considered
Harmful)" and am about halfway through the other one, "Python?s
super() considered super!".  Your point is well-taken as well as
Alan's warning!  In case one of our readers wishes to be spared
searching for the links to the articles Mats mentioned, they are:

https://fuhm.net/super-harmful/
https://rhettinger.wordpress.com/2011/05/26/super-considered-super/

As a "whining" (poor, poor pitiful me) side note, I can't even
remember which of n iterations I am currently in at having another go
at OOP, taking a long break, back at it again, break, wash and repeat
ad infinitum.  Anyway it seems I understand a bit more during each
wash and rinse cycle.  Perhaps some day... ~(:>))



-- 
boB

From mats at wichmann.us  Sat Sep 21 18:51:00 2019
From: mats at wichmann.us (Mats Wichmann)
Date: Sat, 21 Sep 2019 16:51:00 -0600
Subject: [Tutor] Python3 : Yes --- Python2 : No ?
In-Reply-To: <BN8PR11MB3764F80EB9A3802E0CD0FE3EE08B0@BN8PR11MB3764.namprd11.prod.outlook.com>
References: <AM7P191MB066450E4EB76258372293CEA83880@AM7P191MB0664.EURP191.PROD.OUTLOOK.COM>
 <0794395f-570b-b342-b79b-4a6810032eb9@wichmann.us>
 <BN8PR11MB3764F80EB9A3802E0CD0FE3EE08B0@BN8PR11MB3764.namprd11.prod.outlook.com>
Message-ID: <5015efd9-e5ad-b8b0-aa4c-dad1c430e4ee@wichmann.us>

On 9/21/19 2:57 PM, Mike Barnett wrote:
> Your comment regarding COBOL and pointing out the lack of a "time bomb" in Python 2 really got me thinking.
> 
> I think for my package I need to go the final step and remove the 2.7 version from PyPI.  I hate to be so draconian in forcing users over, but it may be the only way.  Guess I would rather not have those users than have them running 2.7.
> 
> For the users that have reported what it took for them to "upgrade" when using my package, some posted saying it was a trivial 15 minute ordeal and they were done.
> 
> I think a portion of the 2.7 install base is there out of fear... the fear of change and "going backwards" in their development setup.  That's the sense I get from hearing from a few 2.7 users of my stuff.

fear I'm sure is there but so is inertia.

As an example, Fedora is in the Fedora 31 release cycle, continuing an
effort to orphan and then drop the Py2 packages that aren't actually
necessary.  From the F31 wiki page:

"Over a thousand packages in Fedora still depend on Python 2, which will
reach End of Life (EOL) on 2020-01-01, shortly after the expected Fedora
31 release date. "

And that's after a big effort already for F30. A whole bunch of
somebodies have to go over all that stuff and make at least some
changes... ouch.




From markos at c2o.pro.br  Sat Sep 21 18:54:31 2019
From: markos at c2o.pro.br (Markos)
Date: Sat, 21 Sep 2019 19:54:31 -0300
Subject: [Tutor] Fwd: Interesting book: "Python GUI Programming with Tkinter"
In-Reply-To: <CANDiX9KVZMzBZsDbvc+PZ60rAvT=Oy_=A5FGLNJN5G52wXB3Gg@mail.gmail.com>
References: <CANDiX9KVZMzBZsDbvc+PZ60rAvT=Oy_=A5FGLNJN5G52wXB3Gg@mail.gmail.com>
Message-ID: <8ecce0f5-b717-0236-c21b-aa4db7f1ab69@c2o.pro.br>

Hi Bob,

I'm (re) starting to learn Python and I'm very interested in using 
Tkinter, because I already have some experience with Tcl/Tk.

Thank you for your comments,

Markos



-------- Mensagem encaminhada --------
Assunto: 	[Tutor] Interesting book: "Python GUI Programming with Tkinter"
Data: 	Fri, 20 Sep 2019 23:34:45 -0500
De: 	boB Stepp <robertvstepp at gmail.com>
Para: 	tutor <tutor at python.org>



I have been enjoying working with the book "Python GUI Programming
with Tkinter -- Develop responsive and powerful GUI applications with
Tkinter" by Alan D. Moore, c. 2018, published by Packt.

At the time of the book's writing Python 3.6.4 was current, though the
author frequently mentions the imminent arrival of Python 3.7 by
publishing time.  The book uses Tcl/Tk 8.6 though the author takes
pain to mention when something is 8.6 specific.  It emphasizes the use
of the ttk widgets, which typically give a more modern look and feel
than the tk widgets.  It does not cover tix widgets at all other than
mentioning they should be considered deprecated in terms of providing
a modern look and feel.

I like the approach the author is taking.  He states you are a
programmer for the fictional company ABQ AgriLabs.  You are assigned
the project of developing a simple data entry form which stores the
data as a CSV file.  The idea is to make data entry for the lab
technicians easier, quicker and error resistant.  Starting from this
beginning you are introduced to most of the functionality of tkinter.
The book assumes a basic grasp of Python 3 from the reader, including
the ability to write custom classes.  As your simple data entry form
gets used and receives user feedback from the fictional lab techs,
your program grows in scope.  The author addresses how to handle this
growth intelligently and speaks to good design and programming
practices.  By the end of the book your program has a PostgreSQL
backend, connects to the cloud, uses asynchronous program where
appropriate, uses both unit and integration testing and is packaged
for either PyPI or distributed as an executable for Windows, Mac or
Linux.

The author sometimes is brief, but other than basic Python knowledge
seems to assume nothing else on the part of the reader.  So, for
instance, he gives a crash course in SQL and relational databases
before getting into developing the database backend for PostgreSQL.
I'm several chapters into the book and feel I have learned a lot.

A coarse table of contents:

Preface
Ch. 1:  Introduction to Tkinter
     Introducing Tkinter and Tk
     Introducing IDLE  # Uses as an example of what can be done with tkinter.
     Creating a Tkinter Hello World

Ch. 2:  Designing GUI Applications with Tkinter
     A problem at ABQ AgriLabs
     Documenting specification requirements
     Designing the application

Ch. 3:  Creating Basic Forms with Tkinter and ttk Widgets
     Evaluating our technology choices
     Exploring Tkinter widgets
     Implementing the application

Ch. 4:  Reducing User Error with Validation and Automation
     Validating user input
     Validation in Tkinter
     Implementing validated widgets in our form
     Automating input

Ch. 5:  Planning for the Expansion of Our Application
     Separating concerns
         The MVC pattern
     Structuring our application directory
     Splitting our application into multiple  files
     Using version control software  # Gives a quick intro to Git

Ch. 6:  Creating Menus with Menu and Tkinter Dialogs
     Solving problems in our application
     Implementing simple Tkinter dialogs
     Designing our menu
     Making our settings work
         Persisting settings  # Introduces json for this purpose

Ch. 7:  Navigating Records with Treeview
     Implementing read and update in the model
     Implementing a record list view
     Modifying the record form for read and update
     Updating the rest of the application

Ch. 8:  Improving the Look with Styles and Themes
     Working with images in Tkinter
     Styling Tkinter widgets
     Styling Ttk widgets

Ch. 9:  Maintaining Cross-Platform Compatibility
     Writing cross-platform Python
         Filenames and filepaths across platforms
         Inconsistent library and feature support
         The dangers of the subprocess module
         Text file encodings and formats
         Graphical and console modes
         Writing code that changes according to the platform
     Writing cross-platform Tkinter
         Tkinter version differences across platforms
         Application menus across platforms
         Accelerator keys
         Fonts
         Theme support
         Window zoomed state
     Improving our application's cross-platform compatibility
         Storing preferences correctly
         Specifying an encoding for our CSV file
         Making platform-appropriate menus

Ch. 10:  Creating Automated Tests with unittest
     Automated testing basics
     Testing Tkinter code
         Managing asynchronous code
         Simulating user actions
         Managing focus and grab
         Getting widget information
     Writing tests for our application

Ch. 11:  Improving Data Storage with SQL
     PostgreSQL
     SQL and relational database basics
     Modeling relational data
     Creating the ABQ database
     Integrating SQL into our application

Ch. 12:  Connecting to the Cloud
     HTTP using urllib
     HTTP using requests
     FTP using ftplib

Ch. 13:  Asynchronous Programming with Thread and Queue
     Tkinter's event queue
     Running code in the background with threading
     Passing messages using a queue

Ch. 14:  Visualizing Data Using the Canvas Widget
     Drawing and animation with Tkinter's Canvas
     Creating simple graphs on the canvas
     Advanced graphs using Matplotlib and Tkinter

Ch. 15:  Packaging with setuptools and cx_Freeze
     Using setuptools
     Using cx_Freeze
     Building Windows executables with cx_Freeze
     Building macOS executables with cx_Freeze

--
boB


-- 
boB
_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


From robertvstepp at gmail.com  Sat Sep 21 19:29:16 2019
From: robertvstepp at gmail.com (boB Stepp)
Date: Sat, 21 Sep 2019 18:29:16 -0500
Subject: [Tutor] How to get all methods of "object"?
Message-ID: <CANDiX9JpFVb03PcdQ-a0zJk56df9+suf2mCE_9Gb4C01MCfC3Q@mail.gmail.com>

Python 3.7.4

I tried to do this with:

>>> for attribute in dir(object):
    print(attribute)


__class__
__delattr__
__dir__
__doc__
__eq__
__format__
__ge__
__getattribute__
__gt__
__hash__
__init__
__init_subclass__
__le__
__lt__
__ne__
__new__
__reduce__
__reduce_ex__
__repr__
__setattr__
__sizeof__
__str__
__subclasshook__

But I know at least one that is not listed:  __dict__  And I would not
be surprised if there are others.

Basically, I am wondering what are *all* the things inherited from
"object" when one creates one's own class?

I am currently trying to find such a list in the Python 3 docs, but so
far I have been unsuccessful.

-- 
boB

From robertvstepp at gmail.com  Sat Sep 21 19:35:11 2019
From: robertvstepp at gmail.com (boB Stepp)
Date: Sat, 21 Sep 2019 18:35:11 -0500
Subject: [Tutor] Fwd: Interesting book: "Python GUI Programming with
 Tkinter"
In-Reply-To: <8ecce0f5-b717-0236-c21b-aa4db7f1ab69@c2o.pro.br>
References: <CANDiX9KVZMzBZsDbvc+PZ60rAvT=Oy_=A5FGLNJN5G52wXB3Gg@mail.gmail.com>
 <8ecce0f5-b717-0236-c21b-aa4db7f1ab69@c2o.pro.br>
Message-ID: <CANDiX9K39kC=BRhNeXfD4EqBX7sMz==qMdiavGfxX29yxa8jQA@mail.gmail.com>

On Sat, Sep 21, 2019 at 6:19 PM Markos <markos at c2o.pro.br> wrote:
>
> Hi Bob,
>
> I'm (re) starting to learn Python and I'm very interested in using
> Tkinter, because I already have some experience with Tcl/Tk.
>
> Thank you for your comments,

I'm glad you found them of some use!

One thing I forgot to mention in the way of criticism of the physical
book I bought:  I'm starting to feel a little doubtful if the glueing
of the pages to the cover will hold up.  However, I do believe an
electronic version is available as well which would obviate this
possibility.  As a person who enjoys handling physical books I am in
general disappointed these days of the sturdiness of book bindings in
general.  Even hardback books seem to soon have pages falling out from
a variety of publishers!

---
boB

From markos at c2o.pro.br  Sat Sep 21 19:42:31 2019
From: markos at c2o.pro.br (Markos)
Date: Sat, 21 Sep 2019 20:42:31 -0300
Subject: [Tutor] Most efficient way to replace ",
 " with "." in a array and/or dataframe
Message-ID: <ad9c61b0-cb96-2312-ec61-50ace11be7a9@c2o.pro.br>

Hi,

I have a table.csv file with the following structure:

, Polyarene conc ,, mg L-1 ,,,,,,,
Spectrum, Py, Ace, Anth,
1, "0,456", "0,120", "0,168"
2, "0,456", "0,040", "0,280"
3, "0,152", "0,200", "0,280"

I open as dataframe with the command:

data = pd.read_csv ('table.csv', sep = ',', skiprows = 1)

and the variable "data" has the structure:

Spectrum,? Py,? Ace, Anth,
0? 1???????? 0,456? 0,120? 0,168
1? 2???????? 0,456 0,040 0,280
2? 3???????? 0,152 0,200 0,280

I copy the numeric fields to an array with the command:

data_array = data.values [:, 1:]

And the data_array variable gets the fields in string format:

[['0,456' '0,120' '0,168']
['0,456' '0,040' '0,280']
['0,152' '0,200' '0,280']]

The only way I found to change comma "," to dot "." was using the method 
replace():

for i, line in enumerate (data_array):
data_array [i] = ([float (element.replace (',', '.')) for element in 
data_array [i]])

But I'm wondering if there is another, more "efficient" way to make this 
change without having to "iterate" all elements of the array with a loop 
"for".

Also I'm also wondering if there would be any benefit of making this 
modification in dataframe before extracting the numeric fields to the array.

Please, any comments or tip?

Thanks you,

Markos


From PyTutor at danceswithmice.info  Sat Sep 21 20:12:21 2019
From: PyTutor at danceswithmice.info (DL Neil)
Date: Sun, 22 Sep 2019 12:12:21 +1200
Subject: [Tutor] How to get all methods of "object"?
In-Reply-To: <CANDiX9JpFVb03PcdQ-a0zJk56df9+suf2mCE_9Gb4C01MCfC3Q@mail.gmail.com>
References: <CANDiX9JpFVb03PcdQ-a0zJk56df9+suf2mCE_9Gb4C01MCfC3Q@mail.gmail.com>
Message-ID: <30cf3ce2-a96a-cd5e-ba1a-66e0755056ea@DancesWithMice.info>

On 22/09/19 11:29 AM, boB Stepp wrote:
> Python 3.7.4
> I tried to do this with:
>>>> for attribute in dir(object):
>      print(attribute)
...

> But I know at least one that is not listed:  __dict__  And I would not
> be surprised if there are others.
> Basically, I am wondering what are *all* the things inherited from
> "object" when one creates one's own class?
> I am currently trying to find such a list in the Python 3 docs, but so
> far I have been unsuccessful.

An interesting idea...

Try creating a class (which inherits the basic "object"), then __dict__ 
(and two other 'extra' attributes) will become visible/pertinent.

By definition, doesn't "inheritance" mean that the sub-class includes 
*all* of the attributes (data and code) of its super-class(es)?

(I'm not mentioning "slots" in a bid to preserve @boB's sanity)
-- 
Regards =dn

From cs at cskk.id.au  Sat Sep 21 22:27:18 2019
From: cs at cskk.id.au (Cameron Simpson)
Date: Sun, 22 Sep 2019 12:27:18 +1000
Subject: [Tutor] Most efficient way to replace ",
 " with "." in a array and/or dataframe
In-Reply-To: <ad9c61b0-cb96-2312-ec61-50ace11be7a9@c2o.pro.br>
References: <ad9c61b0-cb96-2312-ec61-50ace11be7a9@c2o.pro.br>
Message-ID: <20190922022718.GA96894@cskk.homeip.net>

On 21Sep2019 20:42, Markos <markos at c2o.pro.br> wrote:
>I have a table.csv file with the following structure:
>
>, Polyarene conc ,, mg L-1 ,,,,,,,
>Spectrum, Py, Ace, Anth,
>1, "0,456", "0,120", "0,168"
>2, "0,456", "0,040", "0,280"
>3, "0,152", "0,200", "0,280"
>
>I open as dataframe with the command:
>data = pd.read_csv ('table.csv', sep = ',', skiprows = 1)
[...]
>And the data_array variable gets the fields in string format:
>[['0,456' '0,120' '0,168']
[...]

Please see the documentation for the read_csv function here:

  https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html?highlight=read_csv#pandas.read_csv

In particular, because you have values formatted in the European style 
with "," for the decimal marker (and possibly "." for the thousands 
marker), you want to set the "decimal=" parameter of read-csv to ",".

This is better than trying to mangle the data yourself, better to just 
correctly specify the dialect (i.e. set decimal= in your call).

Cheers,
Cameron Simpson <cs at cskk.id.au>

From cs at cskk.id.au  Sat Sep 21 22:35:24 2019
From: cs at cskk.id.au (Cameron Simpson)
Date: Sun, 22 Sep 2019 12:35:24 +1000
Subject: [Tutor] How to get all methods of "object"?
In-Reply-To: <30cf3ce2-a96a-cd5e-ba1a-66e0755056ea@DancesWithMice.info>
References: <30cf3ce2-a96a-cd5e-ba1a-66e0755056ea@DancesWithMice.info>
Message-ID: <20190922023524.GA5174@cskk.homeip.net>

On 22Sep2019 12:12, DL Neil <PyTutor at danceswithmice.info> wrote:
>On 22/09/19 11:29 AM, boB Stepp wrote:
>>Python 3.7.4
>>I tried to do this with:
>>>>>for attribute in dir(object):
>>     print(attribute)
>...
>
>>But I know at least one that is not listed:  __dict__

"object" doesn't have a __dict__. Saves space!

>>And I would not
>>be surprised if there are others.

Really, Python tries to be very transparent here. If it isn't listed, it 
probably isn't a direct attribute of the class.

OTOH, the documentation for dir() includes this text:

  Because dir() is supplied primarily as a convenience for use at an 
  interactive prompt, it tries to supply an interesting set of names 
  more than it tries to supply a rigorously or consistently defined set 
  of names

In fact the doco for the dir function says a fair bit, while promising 
less that you might hope.

>>Basically, I am wondering what are *all* the things inherited from
>>"object" when one creates one's own class?

Yopu're probably doing the right thing. In the general case you probably 
need to consult every class in the subclass' __mro__ attribute. And 
instead of dir() you might consult the __dict__ or __slots__ attributes; 
note that __getattr__ lets a class offer attributes-on-demand which 
won't show in __dict__ or __slots__.

>>I am currently trying to find such a list in the Python 3 docs, but so
>>far I have been unsuccessful.

Also see the "inspect" module.

>An interesting idea...
>Try creating a class (which inherits the basic "object"), then __dict__ 
>(and two other 'extra' attributes) will become visible/pertinent.
>
>By definition, doesn't "inheritance" mean that the sub-class includes 
>*all* of the attributes (data and code) of its super-class(es)?

Unless overridden, yeah. But they don't all 

>(I'm not mentioning "slots" in a bid to preserve @boB's sanity)

Too late! In both senses :-)

Cheers,
Cameron Simpson <cs at cskk.id.au>

From eryksun at gmail.com  Sat Sep 21 22:44:47 2019
From: eryksun at gmail.com (Eryk Sun)
Date: Sat, 21 Sep 2019 21:44:47 -0500
Subject: [Tutor] super() vs. explicitly calling base class?
In-Reply-To: <6f12256b-1c95-457d-f229-32c442eaef44@wichmann.us>
References: <CANDiX9JgJdt0NVdMqmqEtnCAjDz2qjRh==_zbZt6xCpPJr+UVA@mail.gmail.com>
 <6f12256b-1c95-457d-f229-32c442eaef44@wichmann.us>
Message-ID: <CACL+1atQuTnXyn0iRjn3EbhwGW15BCe7C1GXW2=9YULHf9Rskg@mail.gmail.com>

On 9/21/19, Mats Wichmann <mats at wichmann.us> wrote:
>
> Would just like to remind: that function there which prints "This is the
> Base class!" - isn't really "in" it.  The def statement causes a
> function object to be created, and a reference to that function object,
> with the name "__init__", goes into the dictionary that was created by
> the Base class definition. But it has no phyical attachment to Base...

That's generally true. But note that, in the context of a class
definition, if a function references the __class__ special name,
either directly by name (without assignment) or indirectly by calling
super(), it gets defined with a closure reference to the defining
class [1].

    >>> class A:
    ...     def eggs(self):
    ...         pass
    ...     def spam(self):
    ...         super()
    ...     def foo(self):
    ...         return __class__

    >>> A.eggs.__code__.co_freevars
    ()

    >>> A.spam.__code__.co_freevars
    ('__class__',)
    >>> A.spam.__closure__[0].cell_contents is A
    True

    >>> A.foo.__code__.co_freevars
    ('__class__',)
    >>> A.foo.__closure__[0].cell_contents is A
    True
    >>> A.foo('whatever') is A
    True

This only pertains to defining a function in the context of a class
definition. Otherwise __class__ is not reserved. Of course, as a
dunder name, it should always be reserved by convention.

    >>> def f(self):
    ...     __class__
    ...
    >>> f.__code__.co_freevars
    ()
    >>> f.__code__.co_names
    ('__class__',)

[1] https://docs.python.org/3/reference/datamodel.html#creating-the-class-object

From PyTutor at danceswithmice.info  Sat Sep 21 22:49:01 2019
From: PyTutor at danceswithmice.info (DL Neil)
Date: Sun, 22 Sep 2019 14:49:01 +1200
Subject: [Tutor] How to get all methods of "object"?
In-Reply-To: <20190922023524.GA5174@cskk.homeip.net>
References: <30cf3ce2-a96a-cd5e-ba1a-66e0755056ea@DancesWithMice.info>
 <20190922023524.GA5174@cskk.homeip.net>
Message-ID: <f5929119-6668-c1db-1ce6-97acefc6a663@DancesWithMice.info>

On 22/09/19 2:35 PM, Cameron Simpson wrote:
> On 22Sep2019 12:12, DL Neil <PyTutor at danceswithmice.info> wrote:
>> On 22/09/19 11:29 AM, boB Stepp wrote:
>>> Python 3.7.4
>>> I tried to do this with:
>>>>>> for attribute in dir(object):
>>> ??? print(attribute)
>> ...

>> By definition, doesn't "inheritance" mean that the sub-class includes 
>> *all* of the attributes (data and code) of its super-class(es)?
> 
> Unless overridden, yeah. But they don't all

Incomplete sentence? Do I sense a master-class in the offing?

Surely though, if an attribute is part of a SuperClass then it will 
'appear' in the SubClass. If SubClass.x overrides SuperClass.x (or x() ) 
then attribute-x still appears, even if it contains different data, a 
different type, or different code?

Granted that SuperClass.x is 'invisible' if SubClass.x has been defined, 
but even so, instead of self.x can't we still access SuperClass.x?
(I can't think of a time when I've tried, but...)

Is there another case when a super class's attribute will not be inherited.

(again: excluding slots or other sleigh-of-hand)


>> (I'm not mentioning "slots" in a bid to preserve @boB's sanity)
> 
> Too late! In both senses :-)

So sad. His parents had such high hopes for him; yet now he is condemned 
to join us in the asylum known as programming...

-- 
Regards =dn

From cs at cskk.id.au  Sat Sep 21 23:44:52 2019
From: cs at cskk.id.au (Cameron Simpson)
Date: Sun, 22 Sep 2019 13:44:52 +1000
Subject: [Tutor] How to get all methods of "object"?
In-Reply-To: <f5929119-6668-c1db-1ce6-97acefc6a663@DancesWithMice.info>
References: <f5929119-6668-c1db-1ce6-97acefc6a663@DancesWithMice.info>
Message-ID: <20190922034452.GA75103@cskk.homeip.net>

On 22Sep2019 14:49, DL Neil <PyTutor at danceswithmice.info> wrote:
>On 22/09/19 2:35 PM, Cameron Simpson wrote:
>>On 22Sep2019 12:12, DL Neil <PyTutor at danceswithmice.info> wrote:
>>>On 22/09/19 11:29 AM, boB Stepp wrote:
>>>>Python 3.7.4
>>>>I tried to do this with:
>>>>>>>for attribute in dir(object):
>>>>??? print(attribute)
>>>...
>
>>>By definition, doesn't "inheritance" mean that the sub-class 
>>>includes *all* of the attributes (data and code) of its 
>>>super-class(es)?
>>
>>Unless overridden, yeah. But they don't all
>
>Incomplete sentence? Do I sense a master-class in the offing?

Incomplete sentence yes. Master class no.

I think I was considering mentioning "attributes presented via 
__getattr__/__getattribute__, which aren't visible in 
__slots__/__dict__, and aren't "listable" - you can only probe for them 
by trying to access the attribute. Which is why classes can define a 
__dir__ dunder method which implements dir(), so that dir() can mention 
extra things like that.

>Surely though, if an attribute is part of a SuperClass then it will 
>'appear' in the SubClass. If SubClass.x overrides SuperClass.x (or x() 
>) then attribute-x still appears, even if it contains different data, 
>a different type, or different code?

Sure. (Of course one could implement __getattribute__ or a property 
which raises AttributeError to conceal an inherited attribute, but that 
would be perverse.)

>Granted that SuperClass.x is 'invisible' if SubClass.x has been 
>defined, but even so, instead of self.x can't we still access 
>SuperClass.x?

Yeah. As: SuperClass.x(self,...) for a method. But remember that these 
are _class_ attributes, not instance attributes. Thus:

  >>> class A:
  ...   attr = 'foo'
  ...
  >>> class B(A):
  ...   attr = 'bah'
  ...
  >>> x = B()
  >>> x.attr
  'bah'
  >>> x.attr = 'zot'
  >>> x.attr
  'zot'
  >>> B.attr
  'bah'
  >>> A.attr
  'foo'

>(I can't think of a time when I've tried, but...)
>Is there another case when a super class's attribute will not be 
>inherited.
>(again: excluding slots or other sleigh-of-hand)

Don't think so.

Cheers,
Cameron Simpson <cs at cskk.id.au>

in rec.moto, jsh wrote:
> Dan Nitschke wrote:
> > Ged Martin wrote:
> > > On Sat, 17 May 1997 16:53:33 +0000, Dan Nitschke scribbled:
> > > >(And you stay *out* of my dreams, you deviant little
> > > >weirdo.)
> > > Yeah, yeah, that's what you're saying in _public_....
> > Feh. You know nothing of my dreams. I dream entirely in text (New Century
> > Schoolbook bold oblique 14 point), and never in color. I once dreamed I
> > was walking down a flowchart of my own code, and a waterfall of semicolons
> > was chasing me. (I hid behind a global variable until they went by.)
> You write code in a proportional serif? No wonder you got extra
> semicolons falling all over the place.
No, I *dream* about writing code in a proportional serif font.
It's much more exciting than my real life.
/* dan: THE Anti-Ged -- Ignorant Yank (tm) #1, none-%er #7 */
Dan Nitschke  peDANtic at best.com  nitschke at redbrick.com

From robertvstepp at gmail.com  Sun Sep 22 01:20:14 2019
From: robertvstepp at gmail.com (boB Stepp)
Date: Sun, 22 Sep 2019 00:20:14 -0500
Subject: [Tutor] How to get all methods of "object"?
In-Reply-To: <20190922023524.GA5174@cskk.homeip.net>
References: <30cf3ce2-a96a-cd5e-ba1a-66e0755056ea@DancesWithMice.info>
 <20190922023524.GA5174@cskk.homeip.net>
Message-ID: <CANDiX9KgvOQXn2hf4pzYT+ppQtTZ80QkXfwX4Av=j2g4b4WFmQ@mail.gmail.com>

On Sat, Sep 21, 2019 at 9:35 PM Cameron Simpson <cs at cskk.id.au> wrote:
>
> On 22Sep2019 12:12, DL Neil <PyTutor at danceswithmice.info> wrote:
> >On 22/09/19 11:29 AM, boB Stepp wrote:
> >>Python 3.7.4
> >>I tried to do this with:
> >>>>>for attribute in dir(object):
> >>     print(attribute)
> >...
> >
> >>But I know at least one that is not listed:  __dict__
>
> "object" doesn't have a __dict__. Saves space!

Huh?  If I do the following, there clearly seems to be an object.__dict__ :

>>> for key in object.__dict__:
    print('{0:20} {1!r:20}'.format(key, object.__dict__[key]))


__repr__             <slot wrapper '__repr__' of 'object' objects>
__hash__             <slot wrapper '__hash__' of 'object' objects>
__str__              <slot wrapper '__str__' of 'object' objects>
__getattribute__     <slot wrapper '__getattribute__' of 'object' objects>
__setattr__          <slot wrapper '__setattr__' of 'object' objects>
__delattr__          <slot wrapper '__delattr__' of 'object' objects>
__lt__               <slot wrapper '__lt__' of 'object' objects>
__le__               <slot wrapper '__le__' of 'object' objects>
__eq__               <slot wrapper '__eq__' of 'object' objects>
__ne__               <slot wrapper '__ne__' of 'object' objects>
__gt__               <slot wrapper '__gt__' of 'object' objects>
__ge__               <slot wrapper '__ge__' of 'object' objects>
__init__             <slot wrapper '__init__' of 'object' objects>
__new__              <built-in method __new__ of type object at 0x55f6cbb7cba0>
__reduce_ex__        <method '__reduce_ex__' of 'object' objects>
__reduce__           <method '__reduce__' of 'object' objects>
__subclasshook__     <method '__subclasshook__' of 'object' objects>
__init_subclass__    <method '__init_subclass__' of 'object' objects>
__format__           <method '__format__' of 'object' objects>
__sizeof__           <method '__sizeof__' of 'object' objects>
__dir__              <method '__dir__' of 'object' objects>
__class__            <attribute '__class__' of 'object' objects>
__doc__              'The most base type'

(Argh!  Gmail messed up my nicely lined up display.)

> >>And I would not
> >>be surprised if there are others.
>
> Really, Python tries to be very transparent here. If it isn't listed, it
> probably isn't a direct attribute of the class.

I find it interesting that you used the phrase "direct attribute of
the class" instead of just attribute of the class.  While searching
through the Python docs on the side trail __slots__ (Should I now be
babbling insanely? :) ) I stumbled onto
https://docs.python.org/3/reference/datamodel.html?highlight=slots#special-method-names
 After scanning through all of this and trying experiments like:

>>> object.__add__ is not None
Traceback (most recent call last):
  File "<pyshell#125>", line 1, in <module>
    object.__add__ is not None
AttributeError: type object 'object' has no attribute '__add__'
>>> object.__init__ is not None
True
>>> object.__slots__ is not None
Traceback (most recent call last):
  File "<pyshell#127>", line 1, in <module>
    object.__slots__ is not None
AttributeError: type object 'object' has no attribute '__slots__'

I realize that there are other special methods that apparently are not
defined for "object".  I am still pondering this, but am currently
concluding that those methods/attributes that dir() does show must
generally be part of every new object creation unless the coder
specifies those methods to be "None".  However, dir() does not show
the existence of "object.__dict__", so I am probably not fully
understanding everything yet.

> OTOH, the documentation for dir() includes this text:
>
>   Because dir() is supplied primarily as a convenience for use at an
>   interactive prompt, it tries to supply an interesting set of names
>   more than it tries to supply a rigorously or consistently defined set
>   of names

This may explain away some of my concerns.

> >>Basically, I am wondering what are *all* the things inherited from
> >>"object" when one creates one's own class?
>
> Yopu're probably doing the right thing. In the general case you probably
> need to consult every class in the subclass' __mro__ attribute. And
> instead of dir() you might consult the __dict__ or __slots__ attributes;
> note that __getattr__ lets a class offer attributes-on-demand which
> won't show in __dict__ or __slots__.

Ugh.  MRO.  Another headache I've been revisiting while looking at the
articles Mats mentioned in the other thread.  At least MRO and super()
are making more sense today than past efforts at understanding these
concepts.

> >>I am currently trying to find such a list in the Python 3 docs, but so
> >>far I have been unsuccessful.
>
> Also see the "inspect" module.

Haven't made it there yet.

> >An interesting idea...
> >Try creating a class (which inherits the basic "object"), then __dict__
> >(and two other 'extra' attributes) will become visible/pertinent.

Tried this and __dict__, __module__ and __weakref__ show up.  The
first two I have passing familiarity with.  __weakref__ I have no
familiarity with.

> >(I'm not mentioning "slots" in a bid to preserve @boB's sanity)
>
> Too late! In both senses :-)

You guys are so bad!  You both KNOW that I will at least give "slots"
a passing glance.  So far it seems like a nice way to set a fixed
group of allowed attributes without allowing any dynamic adding or
subtracting of attributes.  Which suppresses __dict__ creation and
apparently saving on memory where apparently those memory savings only
seriously add up when lots of class instances are created.  But
apparently more recent 3.x versions have reduced how much memory gets
saved.  But now I'm wondering what all of those "slot wrapper"
prefixes mean when I printed out object.__dict__.  Sigh.


-- 
boB

From eryksun at gmail.com  Sun Sep 22 02:05:23 2019
From: eryksun at gmail.com (Eryk Sun)
Date: Sun, 22 Sep 2019 01:05:23 -0500
Subject: [Tutor] How to get all methods of "object"?
In-Reply-To: <CANDiX9JpFVb03PcdQ-a0zJk56df9+suf2mCE_9Gb4C01MCfC3Q@mail.gmail.com>
References: <CANDiX9JpFVb03PcdQ-a0zJk56df9+suf2mCE_9Gb4C01MCfC3Q@mail.gmail.com>
Message-ID: <CACL+1at8U4Uvo87HDdu1LhAemBewNPHF_Xxq1HdfA1z6zMNBeQ@mail.gmail.com>

On 9/21/19, boB Stepp <robertvstepp at gmail.com> wrote:
>
> But I know at least one that is not listed:  __dict__  And I would not
> be surprised if there are others.

The base class `object` has a dict, but it's accessed via the
`__dict__` descriptor from the base metaclass, `type`. dir() does not
show metaclass attributes because that would be confusing when the
metaclass and class implement the same method.

Note that `object` itself doesn't provide its own `__dict__`
descriptor, since instances of `object` do not have a dict.

Builtin descriptor types in CPython happen to have 'descriptor' in
their name (i.e. wrapper_descriptor, method_descriptor,
classmethod_descriptor, getset_descriptor). Let's use this as a
shortcut to list descriptors that are provided by the base class
`object`, the base metaclass `type`, and an empty `SpamClass` that's
derived from `object`:

    >>> isdescr = lambda o: 'descriptor' in type(o).__name__
    >>> names = set(n for n,o in vars(type).items() if isdescr(o))
    >>> meta_names = set(n for n,o in vars(type).items() if isdescr(o))
    >>> sub_names = set(n for n,o in vars(SpamClass).items() if isdescr(o))

Here's what `object` and `type` provide in common:

    >>> print(*sorted(meta_names & names), sep='\n')
    __delattr__
    __dir__
    __getattribute__
    __init__
    __repr__
    __setattr__
    __sizeof__

This means that the above special methods are implemented separately
for classes. Note that the __dir__ method, which is called by builtin
`dir`, is special-cased for classes. Also note the absence of __new__
from this list. object.__new__ and type.__new__ are special cased as
pre-bound class methods:

    >>> object.__new__.__self__ is object
    True
    >>> type.__new__.__self__ is type
    True

If overridden in pure Python,  __new__ is added to a class dict as a
staticmethod, and for class instantiation it gets called implicitly
with the instantiated class as its first argument.

Moving on, here's what base `object` uniquely provides:

    >>> print(*sorted(names - meta_names), sep='\n')
    __class__
    __eq__
    __format__
    __ge__
    __gt__
    __hash__
    __init_subclass__
    __le__
    __lt__
    __ne__
    __reduce__
    __reduce_ex__
    __str__
    __subclasshook__

Notice the lack of __dict__. However, instances of most classes do
have a dict, so let's check what a subclass has that base `object`
does not have:

    >>> print(*sorted(sub_names - names), sep='\n')
    __dict__
    __weakref__

We can force instances of a class to not have either of these 'slots'
by defining __slots__ in the class without including them, e.g.
`__slots__ = ()`.

Finally, here's what `type` uniquely provides for its instances, i.e.
for classes:

    >>> print(*sorted(meta_names - names), sep='\n')
    __abstractmethods__
    __base__
    __bases__
    __basicsize__
    __call__
    __dict__
    __dictoffset__
    __doc__
    __flags__
    __instancecheck__
    __itemsize__
    __module__
    __mro__
    __name__
    __prepare__
    __qualname__
    __subclasscheck__
    __subclasses__
    __text_signature__
    __weakrefoffset__
    mro

Note that the following attributes are CPython extensions that are not
discussed in the docs:

    __abstractmethods__
    __base__
    __basicsize__
    __dictoffset__
    __flags__
    __itemsize__
    __text_signature__
    __weakrefoffset__

Removing these narrows the list down to the following documented attributes:

    __bases__
    __call__
    __dict__
    __doc__
    __instancecheck__
    __module__
    __mro__
    __name__
    __prepare__
    __qualname__
    __subclasscheck__
    __subclasses__
    mro

Refer to the docs for definitions and discussion of these attributes:

https://docs.python.org/3/reference/datamodel.html
https://docs.python.org/3/library/stdtypes.html
https://docs.python.org/3/library/abc.html
https://docs.python.org/3/library/pickle.html

From asad.hasan2004 at gmail.com  Sun Sep 22 03:09:11 2019
From: asad.hasan2004 at gmail.com (Asad)
Date: Sun, 22 Sep 2019 12:39:11 +0530
Subject: [Tutor] PDB for debugging Python Programs
Message-ID: <CAG3LsKE_1XH+Pj975s4xp4+NxD8_o3Aw44dU8G9kVuE7XvZasg@mail.gmail.com>

Hi All ,

 I am looking for a video tutorial which helps me to understand how to
debug a python script .

Would have any good link or pdf which helps to navigate through the python
script.

Thanks,

-- 
Asad Hasan
+91 9582111698

From sjeik_appie at hotmail.com  Sun Sep 22 03:39:48 2019
From: sjeik_appie at hotmail.com (Albert-Jan Roskam)
Date: Sun, 22 Sep 2019 07:39:48 +0000
Subject: [Tutor] Most efficient way to replace ",
 " with "." in a array and/or dataframe
In-Reply-To: <20190922022718.GA96894@cskk.homeip.net>
Message-ID: <AM7P191MB06647008BAB23F3F3F31B739838A0@AM7P191MB0664.EURP191.PROD.OUTLOOK.COM>



On 22 Sep 2019 04:27, Cameron Simpson <cs at cskk.id.au> wrote:

On 21Sep2019 20:42, Markos <markos at c2o.pro.br> wrote:
>I have a table.csv file with the following structure:
>
>, Polyarene conc ,, mg L-1 ,,,,,,,
>Spectrum, Py, Ace, Anth,
>1, "0,456", "0,120", "0,168"
>2, "0,456", "0,040", "0,280"
>3, "0,152", "0,200", "0,280"
>
>I open as dataframe with the command:
>data = pd.read_csv ('table.csv', sep = ',', skiprows = 1)
[...]
>And the data_array variable gets the fields in string format:
>[['0,456' '0,120' '0,168']
[...]

>Please see the documentation for the >read_csv function here:

> https://pandas.pydata.org/pandas

>docs/stable/reference/api/pandas.read_cs> v.html?highlight=read_csv#pandas.read_csv

Do you think it's a deliberate design choice that decimal and thousands where used here as params, and not a 'locale' param? It seems nice to be able to specify e.g. locale='dutch' and then all the right lc_numeric, lc_monetary, lc_time where used. Or even locale='nl_NL.1252' and you also wouldn't need 'encoding' as a separate param. Or might that be bad on windows where there's no locale-gen? Just wondering...

Albert-Jan


From cs at cskk.id.au  Sun Sep 22 04:20:52 2019
From: cs at cskk.id.au (Cameron Simpson)
Date: Sun, 22 Sep 2019 18:20:52 +1000
Subject: [Tutor] Most efficient way to replace ",
 " with "." in a array and/or dataframe
In-Reply-To: <AM7P191MB06647008BAB23F3F3F31B739838A0@AM7P191MB0664.EURP191.PROD.OUTLOOK.COM>
References: <AM7P191MB06647008BAB23F3F3F31B739838A0@AM7P191MB0664.EURP191.PROD.OUTLOOK.COM>
Message-ID: <20190922082052.GA77760@cskk.homeip.net>

On 22Sep2019 07:39, Albert-Jan Roskam <sjeik_appie at hotmail.com> wrote:
>On 22 Sep 2019 04:27, Cameron Simpson <cs at cskk.id.au> wrote:
>On 21Sep2019 20:42, Markos <markos at c2o.pro.br> wrote:
>>I have a table.csv file with the following structure:
>>
>>, Polyarene conc ,, mg L-1 ,,,,,,,
>>Spectrum, Py, Ace, Anth,
>>1, "0,456", "0,120", "0,168"
>>2, "0,456", "0,040", "0,280"
>>3, "0,152", "0,200", "0,280"
>>
>>I open as dataframe with the command:
>>data = pd.read_csv ('table.csv', sep = ',', skiprows = 1)
>[...]
>>And the data_array variable gets the fields in string format:
>>[['0,456' '0,120' '0,168']
>[...]
>
>>Please see the documentation for the >read_csv function here:
>
>> https://pandas.pydata.org/pandas
>
>>docs/stable/reference/api/pandas.read_cs> v.html?highlight=read_csv#pandas.read_csv
>
>Do you think it's a deliberate design choice that decimal and thousands 
>where used here as params, and not a 'locale' param? It seems nice to 
>be able to specify e.g. locale='dutch' and then all the right 
>lc_numeric, lc_monetary, lc_time where used. Or even 
>locale='nl_NL.1252' and you also wouldn't need 'encoding' as a separate 
>param. Or might that be bad on windows where there's no locale-gen? 
>Just wondering...

Locales are tricky; I don't know enough.

A locale parameter might be convenient for some things, but such things 
are table driven. From an arbitrary Linux box nearby:

  % locale -a
  C
  C.UTF-8
  POSIX
  en_AU.utf8

No "dutch" or similar there.

I doubt pandas would ship with such a thing. And the OP probably doesn't 
know the originating locale anyway. Nor do _we_ know that those values 
themselves were driven from some well known locale table.

The advantage of specifical decimal= and thousands= parameters is that 
they do exactly what they say, rather than looking up a locale and 
hoping for a specific side effect. So the specific parameters offer 
better control.

The thousands= itself is a little parachial (for example, in India a 
factor of 100 is a common division point[1]), but it may merely be used 
to strip this character from the left portion of the number.

[1] https://en.wikipedia.org/wiki/Indian_numbering_system

So while I am not a pandas person, I would expect that decimal= and 
thousands= are useful parameters for specific lexical situations (like 
the OP's CSV data) and work regardless of any locale knowledge.

Cheers,
Cameron Simpson <cs at cskk.id.au>

From cs at cskk.id.au  Sun Sep 22 04:34:50 2019
From: cs at cskk.id.au (Cameron Simpson)
Date: Sun, 22 Sep 2019 18:34:50 +1000
Subject: [Tutor] How to get all methods of "object"?
In-Reply-To: <CANDiX9KgvOQXn2hf4pzYT+ppQtTZ80QkXfwX4Av=j2g4b4WFmQ@mail.gmail.com>
References: <CANDiX9KgvOQXn2hf4pzYT+ppQtTZ80QkXfwX4Av=j2g4b4WFmQ@mail.gmail.com>
Message-ID: <20190922083450.GA10747@cskk.homeip.net>

On 22Sep2019 00:20, boB Stepp <robertvstepp at gmail.com> wrote:
>On Sat, Sep 21, 2019 at 9:35 PM Cameron Simpson <cs at cskk.id.au> wrote:
>> On 22Sep2019 12:12, DL Neil <PyTutor at danceswithmice.info> wrote:
>> >On 22/09/19 11:29 AM, boB Stepp wrote:
>> >>Python 3.7.4
>> >>I tried to do this with:
>> >>>>>for attribute in dir(object):
>> >>     print(attribute)
>> >...
>> >
>> >>But I know at least one that is not listed:  __dict__
>>
>> "object" doesn't have a __dict__. Saves space!
>
>Huh?  If I do the following, there clearly seems to be an object.__dict__ :
>
>>>> for key in object.__dict__:
>    print('{0:20} {1!r:20}'.format(key, object.__dict__[key]))

Hmm. Interesting. Sorry: the "object" class has a __dict__. But 
instances of that class do not:

    >>> o=object()
    >>> dir(o)
    ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', 
    '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', 
    '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', 
    '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', 
    '__sizeof__', '__str__', '__subclasshook__']
    >>> o.__dict__
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: 'object' object has no attribute '__dict__'
    >>> o.__slots__
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: 'object' object has no attribute '__slots__'

>__repr__             <slot wrapper '__repr__' of 'object' objects>
>__hash__             <slot wrapper '__hash__' of 'object' objects>
[...]
>(Argh!  Gmail messed up my nicely lined up display.)

Bah! My mutt renders it nicely here! Terminal based mail readers FTW!

>> >>And I would not
>> >>be surprised if there are others.
>>
>> Really, Python tries to be very transparent here. If it isn't listed, it
>> probably isn't a direct attribute of the class.
>
>I find it interesting that you used the phrase "direct attribute of
>the class" instead of just attribute of the class.

I'm just trying to be clear, avoiding confusion with attribute of an 
instance of the class.

> While searching
>through the Python docs on the side trail __slots__ (Should I now be
>babbling insanely? :) ) I stumbled onto
>https://docs.python.org/3/reference/datamodel.html?highlight=slots#special-method-names
> After scanning through all of this and trying experiments like:
>
>>>> object.__add__ is not None
>Traceback (most recent call last):
>  File "<pyshell#125>", line 1, in <module>
>    object.__add__ is not None
>AttributeError: type object 'object' has no attribute '__add__'
>>>> object.__init__ is not None
>True
>>>> object.__slots__ is not None
>Traceback (most recent call last):
>  File "<pyshell#127>", line 1, in <module>
>    object.__slots__ is not None
>AttributeError: type object 'object' has no attribute '__slots__'
>
>I realize that there are other special methods that apparently are not
>defined for "object".

"object" and the other builtin types often have C implementations (in 
CPython) and so their methods are a bit more magic that pure python 
classes/types.

> I am still pondering this, but am currently
>concluding that those methods/attributes that dir() does show must
>generally be part of every new object creation unless the coder
>specifies those methods to be "None".  However, dir() does not show
>the existence of "object.__dict__", so I am probably not fully
>understanding everything yet.

Object and friends are more basic and magic (or, if you like, less fully 
cononically implemented).

>> OTOH, the documentation for dir() includes this text:
>>
>>   Because dir() is supplied primarily as a convenience for use at an
>>   interactive prompt, it tries to supply an interesting set of names
>>   more than it tries to supply a rigorously or consistently defined set
>>   of names
>
>This may explain away some of my concerns.
>
>> >>Basically, I am wondering what are *all* the things inherited from
>> >>"object" when one creates one's own class?
>>
>> Yopu're probably doing the right thing. In the general case you probably
>> need to consult every class in the subclass' __mro__ attribute. And
>> instead of dir() you might consult the __dict__ or __slots__ attributes;
>> note that __getattr__ lets a class offer attributes-on-demand which
>> won't show in __dict__ or __slots__.
>
>Ugh.  MRO.  Another headache I've been revisiting while looking at the
>articles Mats mentioned in the other thread.  At least MRO and super()
>are making more sense today than past efforts at understanding these
>concepts.
>
>> >>I am currently trying to find such a list in the Python 3 docs, but so
>> >>far I have been unsuccessful.
>>
>> Also see the "inspect" module.
>
>Haven't made it there yet.

It is handy for inspecting objects (eg method call signatures, the 
module where something was defined, etc). It may not provide more 
insight, just ways to look at things.

>> >An interesting idea...
>> >Try creating a class (which inherits the basic "object"), then __dict__
>> >(and two other 'extra' attributes) will become visible/pertinent.
>
>Tried this and __dict__, __module__ and __weakref__ show up.  The
>first two I have passing familiarity with.  __weakref__ I have no
>familiarity with.

__weakref__ is used for "weak references", which don't contribute to an 
object's reference count (and thus don't prevent an object being garbage 
collected). Handy for keeping registries of things without forcing 
objects to stay allocated as a side effect (eg when the object becomes 
unused _except_ in that registry).

Not heavily used.

>You guys are so bad!  You both KNOW that I will at least give "slots"
>a passing glance.  So far it seems like a nice way to set a fixed
>group of allowed attributes without allowing any dynamic adding or
>subtracting of attributes.  Which suppresses __dict__ creation and
>apparently saving on memory where apparently those memory savings only
>seriously add up when lots of class instances are created.

It is also faster, since the implementation can translate attribute 
names to a flat offset instead ofdereferencing through a dictionary.

> But
>apparently more recent 3.x versions have reduced how much memory gets
>saved.  But now I'm wondering what all of those "slot wrapper"
>prefixes mean when I printed out object.__dict__.  Sigh.

Just think of them as space efficient inflexible objects.

Cheers,
Cameron Simpson <cs at cskk.id.au>

From eryksun at gmail.com  Sun Sep 22 05:40:57 2019
From: eryksun at gmail.com (Eryk Sun)
Date: Sun, 22 Sep 2019 04:40:57 -0500
Subject: [Tutor] Most efficient way to replace ",
 " with "." in a array and/or dataframe
In-Reply-To: <AM7P191MB06647008BAB23F3F3F31B739838A0@AM7P191MB0664.EURP191.PROD.OUTLOOK.COM>
References: <20190922022718.GA96894@cskk.homeip.net>
 <AM7P191MB06647008BAB23F3F3F31B739838A0@AM7P191MB0664.EURP191.PROD.OUTLOOK.COM>
Message-ID: <CACL+1avxiN==5GqcBqv3YzrxZgYquRnAtvqt0afDk0dc-g9Nkw@mail.gmail.com>

On 9/22/19, Albert-Jan Roskam <sjeik_appie at hotmail.com> wrote:
>
> Do you think it's a deliberate design choice that decimal and thousands
> where used here as params, and not a 'locale' param? It seems nice to be
> able to specify e.g. locale='dutch' and then all the right lc_numeric,
> lc_monetary, lc_time where used. Or even locale='nl_NL.1252' and you also
> wouldn't need 'encoding' as a separate param. Or might that be bad on
> windows where there's no locale-gen? Just wondering...

FYI, while Windows is distributed with many locales and also supports
custom locales (not something I've had to work with), at least based
on standard locale data, "nl_NL.1252" is not a valid locale for use
with C setlocale in Windows.

Classically, the C runtime in Windows supports "C" (but not "POSIX")
and locales based on a language name or its non-standard three-letter
abbreviation. A locale can also include a country/region name (full or
three-letter abbreviation), plus an optional codepage. If the latter
is omitted, it defaults to the ANSI codepage of the language, or of
the system locale if the language has no ANSI codepage .

Examples:

    >>> locale.setlocale(0, 'dutch')
    'Dutch_Netherlands.1252'
    >>> locale.setlocale(0, 'nld')
    'Dutch_Netherlands.1252'
    >>> locale.setlocale(0, 'nld_NLD.850')
    'Dutch_Netherlands.850'

There are also a few compatibility locales such as "american" and "canadian":

    >>> locale.setlocale(0, 'american')
    'English_United States.1252'
    >>> locale.setlocale(0, 'canadian')
    'English_Canada.1252'

Classically, the Windows API represents locales not as language/region
strings but as numeric locale identifiers (LCIDs). However, back in
2006, Windows Vista introduced locale names, plus a new set of
functions that use locale names instead of LCIDs (e.g.
GetLocaleInfoEx). Locale names are based on BCP-47 language tags,
which include at least an ISO 639 language code. They can also include
an optional ISO 15924 script code (e.g. "Latn" or "Cyrl") and an
optional ISO 3166-1 region code. Strictly speaking, the codes in a
BCP-47 language tag are delimited only by hyphens, but newer versions
of Windows in most cases also allow underscore.

The Universal CRT (used by Python 3.5+) supports Vista locale names.
Recently it also supports using underscore instead of hyphen, plus an
optional ".utf8" or ".utf-8" encoding. Only UTF-8 can be specified for
a BCP-47 locale. If the encoding is not specified, BCP-47 locales use
the language's ANSI codepage, or UTF-8 if the language has no ANSI
codepage (e.g. "hi_IN").

Examples:

    >>> locale.setlocale(0, 'nl_NL')
    'nl_NL'
    >>> locale.setlocale(0, 'nl_NL.utf8')
    'nl_NL.utf8'

Older versions of the Universal CRT do not support UTF-8 or underscore
in BCP-47 locale names, so make sure a system is updated if you need
these features.

From mike_barnett at hotmail.com  Fri Sep 20 20:04:16 2019
From: mike_barnett at hotmail.com (Mike Barnett)
Date: Sat, 21 Sep 2019 00:04:16 +0000
Subject: [Tutor] Python3 : Yes --- Python2 : No ?
In-Reply-To: <f7379c7a-38e4-91a0-4f3a-221044687336@DancesWithMice.info>
References: <AM7P191MB066450E4EB76258372293CEA83880@AM7P191MB0664.EURP191.PROD.OUTLOOK.COM>
 <f7379c7a-38e4-91a0-4f3a-221044687336@DancesWithMice.info>
Message-ID: <BN8PR11MB37648EFE76DEC4FC9CC93A2CE08B0@BN8PR11MB3764.namprd11.prod.outlook.com>

I have a python package that's pip installable.

The python 3 version stats:

Date	Downloads
2019-09-19	861
2019-09-18	771
2019-09-17	1,076
2019-09-16	787
2019-09-15	496
2019-09-14	662
2019-09-13	1,075


The python 2 version stats:

Date	Downloads
2019-09-19	215
2019-09-18	211
2019-09-17	478
2019-09-16	268
2019-09-15	20
2019-09-14	252
2019-09-13	593


As much as I WANT Python 2 to be gone it appears to be far from it.  I've given notice multiple times that the code is frozen, it's going away, and have pledged to delete the Python 2 release from the GitHub on Dec 31 2019.  And yet the 2.7 installs are as strong as ever.

From mike_barnett at hotmail.com  Sat Sep 21 16:57:26 2019
From: mike_barnett at hotmail.com (Mike Barnett)
Date: Sat, 21 Sep 2019 20:57:26 +0000
Subject: [Tutor] Python3 : Yes --- Python2 : No ?
In-Reply-To: <0794395f-570b-b342-b79b-4a6810032eb9@wichmann.us>
References: <AM7P191MB066450E4EB76258372293CEA83880@AM7P191MB0664.EURP191.PROD.OUTLOOK.COM>
 <0794395f-570b-b342-b79b-4a6810032eb9@wichmann.us>
Message-ID: <BN8PR11MB3764F80EB9A3802E0CD0FE3EE08B0@BN8PR11MB3764.namprd11.prod.outlook.com>

Your comment regarding COBOL and pointing out the lack of a "time bomb" in Python 2 really got me thinking.

I think for my package I need to go the final step and remove the 2.7 version from PyPI.  I hate to be so draconian in forcing users over, but it may be the only way.  Guess I would rather not have those users than have them running 2.7.

For the users that have reported what it took for them to "upgrade" when using my package, some posted saying it was a trivial 15 minute ordeal and they were done.

I think a portion of the 2.7 install base is there out of fear... the fear of change and "going backwards" in their development setup.  That's the sense I get from hearing from a few 2.7 users of my stuff.




-----Original Message-----
From: Tutor <tutor-bounces+mike=pysimplegui.org at python.org> On Behalf Of Mats Wichmann
Sent: Saturday, September 21, 2019 8:46 AM
To: tutor at python.org
Subject: Re: [Tutor] Python3 : Yes --- Python2 : No ?

On 9/20/19 10:50 AM, Albert-Jan Roskam wrote:
> 
> 
> On 15 Sep 2019 09:48, Alan Gauld via Tutor <tutor at python.org> wrote:
> 
> On 15/09/2019 07:17, Hendrickx Marcel via Tutor wrote:
>> Link with the info =>
>>
>> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww
>> .python.org%2Fdoc%2Fsunset-python-2%2F&amp;data=02%7C01%7C%7Ca1d3d57e
>> 41694c50fefb08d73e91d057%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7
>> C637046668288947556&amp;sdata=oBfbOS1IwumeV05fczolM7IBMp%2FrRrfwZQOY8
>> mzX%2BhI%3D&amp;reserved=0
>>
>> News for me...
> 
> It really shouldn't be a surprise. As the link says its been announced 
> several times and was always the intent.
> 
> ==>> Some bankers pretend to be surprised:
> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.
> techrepublic.com%2Fgoogle-amp%2Farticle%2Fjpmorgans-athena-has-35-mill
> ion-lines-of-python-code-and-wont-be-updated-to-python-3-in-time%2F&am
> p;data=02%7C01%7C%7Ca1d3d57e41694c50fefb08d73e91d057%7C84df9e7fe9f640a
> fb435aaaaaaaaaaaa%7C1%7C0%7C637046668288947556&amp;sdata=EiB4l6t8DY5ue
> d5rdWltXITYrn8rkEHNVoYHYpvdxUU%3D&amp;reserved=0

There are also millions - perhaps billions - of lines of COBOL still in use... so we should NOT pretend to be surprised they're surprised :)

Python 2 has no time bomb, it won't stop working.  The Python development community has decided not to split their efforts any longer, and lots of projects agree to go along, so it will become ever harder to get "the current version" of something if you're on Py2, as it will probably only be available for Py3.  But that doesn't cause a complete already working project just to fails...

As one who is helping maintain a 2+3 capable code base, it's a pain; in addition to always fighting little surprises, you leave a lot of productivity on the table by always having to fall back to the oldest stuff, or else try to backport (or find someone else who has backported).


_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Ftutor&amp;data=02%7C01%7C%7Ca1d3d57e41694c50fefb08d73e91d057%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637046668288947556&amp;sdata=Fm%2BuV%2BEFOqvRrDJZoWejbPV0UZQREF7x0F6FofNNjIw%3D&amp;reserved=0

From sjeik_appie at hotmail.com  Sun Sep 22 13:22:24 2019
From: sjeik_appie at hotmail.com (Albert-Jan Roskam)
Date: Sun, 22 Sep 2019 17:22:24 +0000
Subject: [Tutor] Python3 : Yes --- Python2 : No ?
In-Reply-To: <90a28d43-e341-48b7-86f6-2809519def52@email.android.com>
Message-ID: <AM7P191MB0664971E98C37EE2F23BDBD3838A0@AM7P191MB0664.EURP191.PROD.OUTLOOK.COM>



> On 22 Sep 2019 00:06, Alan G via Tutor > <Tutor at python.org> wrote:



What would the best approach to convert that much code? I mean, with sooooo many dependencies! Each individual project would start with git checkout -b py3. Then run 2to3. Then see what that 2to3 script did to the unittests. Then fix the tests. Then fix the code so the tests pass. Meanwhile py2 bugs may also need to be fixed and git-cherrypicked onto the brittle py3 code. Brrr. But one should have a way to prioritize what needs to be converted, i.e. determine what modules are the most common dependencies. Is there a generic approach for this? Jenkins CI woukd be very useful, I think. It seems daunting!

From oscar.j.benjamin at gmail.com  Sun Sep 22 19:49:49 2019
From: oscar.j.benjamin at gmail.com (Oscar Benjamin)
Date: Mon, 23 Sep 2019 00:49:49 +0100
Subject: [Tutor] Python3 : Yes --- Python2 : No ?
In-Reply-To: <AM7P191MB0664971E98C37EE2F23BDBD3838A0@AM7P191MB0664.EURP191.PROD.OUTLOOK.COM>
References: <90a28d43-e341-48b7-86f6-2809519def52@email.android.com>
 <AM7P191MB0664971E98C37EE2F23BDBD3838A0@AM7P191MB0664.EURP191.PROD.OUTLOOK.COM>
Message-ID: <CAHVvXxTE+X4q2Rsjt8M25Y2RnPrgBKb0-LQOTXDfciU5hVMgyA@mail.gmail.com>

On Sun, 22 Sep 2019 at 18:22, Albert-Jan Roskam <sjeik_appie at hotmail.com> wrote:
> What would the best approach to convert that much code? I mean, with sooooo many dependencies! Each individual project would start with git checkout -b py3. Then run 2to3. Then see what that 2to3 script did to the unittests. Then fix the tests. Then fix the code so the tests pass. Meanwhile py2 bugs may also need to be fixed and git-cherrypicked onto the brittle py3 code. Brrr. But one should have a way to prioritize what needs to be converted, i.e. determine what modules are the most common dependencies. Is there a generic approach for this? Jenkins CI woukd be very useful, I think. It seems daunting!

The obvious approach is to work through it one step at a time from the
bottom of your dependency stack. For each dependency consider whether
it supports Python 3 or whether it can easily be made to support
Python 3 or whether it can be replaced with something newer.

Although it is daunting there are also opportunities in all this to
clean things out, make changes that needed to be made etc. Often the
hardest part of an overhaul is that as you dig into everything you
discover lots of bugs. The parts that fail (and aren't trivially
fixable) under a transition are often those that were not well
designed or implemented in the first place.

The question is: will you fix those bugs or will you make them one
level worse by papering over during the transition?

Oscar

From s.molnar at sbcglobal.net  Tue Sep 24 08:10:59 2019
From: s.molnar at sbcglobal.net (Stephen P. Molnar)
Date: Tue, 24 Sep 2019 08:10:59 -0400
Subject: [Tutor] Pandas Problem?
Message-ID: <5D8A07D3.5090005@sbcglobal.net>

I am using the Spyder3 IDE with Python 3.7.3 and have encountered, what 
to me at least, is a rather strange problem.

The code, at this point is:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Apr  8 15:17:07 2017

@author: comp

"""
#import numpy as np
#import matplotlib.pyplot as plt
import pandas as pd

name = input("Enter Molecule ID: ")

print(name)

ligand_file = name+'_apo-1acl.RMSD'

print('Ligand file = ',ligand_file)

data = pd.read_table('ligand_file',skiprows = 7)

print(data)

The input file, in this example, 17-3_apo-1acl.RMSD is:

     RMSD TABLE
     __________

_____________________________________________________________________
      |      |      |           |         |                 |
Rank | Sub- | Run  | Binding   | Cluster | Reference       | Grep
      | Rank |      | Energy    | RMSD    | RMSD            | Pattern
_____|______|______|___________|_________|_________________|___________
    1      1      8       -7.23      0.00     93.07           RANKING
    1      2      9       -6.79      1.39     92.64           RANKING
    2      1     16       -7.18      0.00     93.19           RANKING
    3      1      2       -6.93      0.00     93.38           RANKING
    3      2     17       -6.84      0.23     93.45           RANKING
    4      1     15       -6.55      0.00     91.83           RANKING
    4      2      7       -6.34      0.33     91.77           RANKING
    5      1      5       -6.41      0.00     93.05           RANKING
    6      1      3       -6.36      0.00     92.84           RANKING
    6      2     10       -6.28      0.47     92.92           RANKING
    6      3      6       -6.27      0.43     92.82           RANKING
    6      4     18       -6.25      0.32     92.88           RANKING
    6      5     13       -6.24      0.96     92.75           RANKING
    6      6      1       -6.24      0.87     92.60           RANKING
    6      7     14       -6.21      0.51     92.90           RANKING
    6      8     11       -6.14      0.98     92.78           RANKING
    6      9     20       -6.11      0.71     92.67           RANKING
    6     10     19       -6.01      1.36     93.00           RANKING
    7      1     12       -6.30      0.00     93.28           RANKING
    8      1      4       -5.85      0.00     92.97           RANKING
_______________________________________________________________________

The output at this point is:

Enter Molecule ID: 17-3
17-3
Ligand file =  17-3_apo-1acl.RMSD
Traceback (most recent call last):

   File "<ipython-input-3-48de0a8fd907>", line 1, in <module>
runfile('/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/RMSDTable_3.py.', 
wdir='/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable')

   File 
"/usr/local/lib/python3.7/dist-packages/spyder_kernels/customize/spydercustomize.py", 
line 827, in runfile
     execfile(filename, namespace)

   File 
"/usr/local/lib/python3.7/dist-packages/spyder_kernels/customize/spydercustomize.py", 
line 110, in execfile
     exec(compile(f.read(), filename, 'exec'), namespace)

   File 
"/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/RMSDTable_3.py.", 
line 23, in <module>
     data = pd.read_table('ligand_file',skiprows = 7)

   File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py", 
line 685, in parser_f
     return _read(filepath_or_buffer, kwds)

   File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py", 
line 457, in _read
     parser = TextFileReader(fp_or_buf, **kwds)

   File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py", 
line 895, in __init__
     self._make_engine(self.engine)

   File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py", 
line 1135, in _make_engine
     self._engine = CParserWrapper(self.f, **self.options)

   File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py", 
line 1917, in __init__
     self._reader = parsers.TextReader(src, **kwds)

   File "pandas/_libs/parsers.pyx", line 382, in 
pandas._libs.parsers.TextReader.__cinit__

   File "pandas/_libs/parsers.pyx", line 689, in 
pandas._libs.parsers.TextReader._setup_parser_source

FileNotFoundError: [Errno 2] File b'ligand_file' does not exist: 
b'ligand_file'


However, if I change the data = line to:

data = pd.read_table('13-7_apo-1acl.RMSD',skiprows = 7)

The output is:

runfile('/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/RMSDTable_3.py.', 
wdir='/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable')

Enter Molecule ID: 13-7
13-7
Ligand file =  13-7_apo-1acl.RMSD
_____|______|______|___________|_________|_________________|___________
0      1      1      8       -7.23      0.00 9...
1      1      2      9       -6.79      1.39 9...
2      2      1     16       -7.18      0.00 9...
3      3      1      2       -6.93      0.00 9...
4      3      2     17       -6.84      0.23 9...
5      4      1     15       -6.55      0.00 9...
6      4      2      7       -6.34      0.33 9...
7      5      1      5       -6.41      0.00 9...
8      6      1      3       -6.36      0.00 9...
9      6      2     10       -6.28      0.47 9...
10     6      3      6       -6.27      0.43 9...
11     6      4     18       -6.25      0.32 9...
12     6      5     13       -6.24      0.96 9...
13     6      6      1       -6.24      0.87 9...
14     6      7     14       -6.21      0.51 9...
15     6      8     11       -6.14      0.98 9...
16     6      9     20       -6.11      0.71 9...
17     6     10     19       -6.01      1.36 9...
18     7      1     12       -6.30      0.00 9...
19     8      1      4       -5.85      0.00 9...
20 ______________________________________________...

I have used the ligand_file = line in other Python script that has 
worked without any errors.

Google has not been a solution in his case.  Pointers towards wolutions 
to this problem will be much appreciated.

Thanks in advance.

-- 
Stephen P. Molnar, Ph.D.            Life is a fuzzy set
http://www.Molecular-Modeling.net   Multivariate and stochastic
614.312.7528 (c)
Skype:  smolnar1


From Steve.Flynn at capita.co.uk  Tue Sep 24 09:16:17 2019
From: Steve.Flynn at capita.co.uk (Flynn, Stephen (Life & Pensions))
Date: Tue, 24 Sep 2019 13:16:17 +0000
Subject: [Tutor] Pandas Problem?
In-Reply-To: <5D8A07D3.5090005@sbcglobal.net>
References: <5D8A07D3.5090005@sbcglobal.net>
Message-ID: <CWXP265MB13681A9EB2D0B6AA2E5573AECA840@CWXP265MB1368.GBRP265.PROD.OUTLOOK.COM>

You're trying to open a file named 'ligand_file', as evidenced by:

FileNotFoundError: [Errno 2] File b'ligand_file' does not exist: 
b'ligand_file'


However, ligand_file is the name of the variable which contains the name of the file you want to open. Remove the quotes from 'ligand_file' in your read_table statement.

S.

-----Original Message-----
From: Tutor <tutor-bounces+steve.flynn=capita.co.uk at python.org> On Behalf Of Stephen P. Molnar
Sent: 24 September 2019 13:11
To: Python Tutor <tutor at python.org>
Subject: [Tutor] Pandas Problem?

I am using the Spyder3 IDE with Python 3.7.3 and have encountered, what to me at least, is a rather strange problem.

The code, at this point is:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Apr  8 15:17:07 2017

@author: comp

"""
#import numpy as np
#import matplotlib.pyplot as plt
import pandas as pd

name = input("Enter Molecule ID: ")

print(name)

ligand_file = name+'_apo-1acl.RMSD'

print('Ligand file = ',ligand_file)

data = pd.read_table('ligand_file',skiprows = 7)

print(data)

The input file, in this example, 17-3_apo-1acl.RMSD is:

     RMSD TABLE
     __________

_____________________________________________________________________
      |      |      |           |         |                 |
Rank | Sub- | Run  | Binding   | Cluster | Reference       | Grep
      | Rank |      | Energy    | RMSD    | RMSD            | Pattern
_____|______|______|___________|_________|_________________|___________
    1      1      8       -7.23      0.00     93.07           RANKING
    1      2      9       -6.79      1.39     92.64           RANKING
    2      1     16       -7.18      0.00     93.19           RANKING
    3      1      2       -6.93      0.00     93.38           RANKING
    3      2     17       -6.84      0.23     93.45           RANKING
    4      1     15       -6.55      0.00     91.83           RANKING
    4      2      7       -6.34      0.33     91.77           RANKING
    5      1      5       -6.41      0.00     93.05           RANKING
    6      1      3       -6.36      0.00     92.84           RANKING
    6      2     10       -6.28      0.47     92.92           RANKING
    6      3      6       -6.27      0.43     92.82           RANKING
    6      4     18       -6.25      0.32     92.88           RANKING
    6      5     13       -6.24      0.96     92.75           RANKING
    6      6      1       -6.24      0.87     92.60           RANKING
    6      7     14       -6.21      0.51     92.90           RANKING
    6      8     11       -6.14      0.98     92.78           RANKING
    6      9     20       -6.11      0.71     92.67           RANKING
    6     10     19       -6.01      1.36     93.00           RANKING
    7      1     12       -6.30      0.00     93.28           RANKING
    8      1      4       -5.85      0.00     92.97           RANKING
_______________________________________________________________________

The output at this point is:

Enter Molecule ID: 17-3
17-3
Ligand file =  17-3_apo-1acl.RMSD
Traceback (most recent call last):

   File "<ipython-input-3-48de0a8fd907>", line 1, in <module> runfile('/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/RMSDTable_3.py.',
wdir='/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable')

   File
"/usr/local/lib/python3.7/dist-packages/spyder_kernels/customize/spydercustomize.py",
line 827, in runfile
     execfile(filename, namespace)

   File
"/usr/local/lib/python3.7/dist-packages/spyder_kernels/customize/spydercustomize.py",
line 110, in execfile
     exec(compile(f.read(), filename, 'exec'), namespace)

   File
"/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/RMSDTable_3.py.",
line 23, in <module>
     data = pd.read_table('ligand_file',skiprows = 7)

   File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py",
line 685, in parser_f
     return _read(filepath_or_buffer, kwds)

   File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py",
line 457, in _read
     parser = TextFileReader(fp_or_buf, **kwds)

   File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py",
line 895, in __init__
     self._make_engine(self.engine)

   File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py",
line 1135, in _make_engine
     self._engine = CParserWrapper(self.f, **self.options)

   File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py",
line 1917, in __init__
     self._reader = parsers.TextReader(src, **kwds)

   File "pandas/_libs/parsers.pyx", line 382, in pandas._libs.parsers.TextReader.__cinit__

   File "pandas/_libs/parsers.pyx", line 689, in pandas._libs.parsers.TextReader._setup_parser_source

FileNotFoundError: [Errno 2] File b'ligand_file' does not exist: 
b'ligand_file'


However, if I change the data = line to:

data = pd.read_table('13-7_apo-1acl.RMSD',skiprows = 7)

The output is:

runfile('/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/RMSDTable_3.py.',
wdir='/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable')

Enter Molecule ID: 13-7
13-7
Ligand file =  13-7_apo-1acl.RMSD
_____|______|______|___________|_________|_________________|___________
0      1      1      8       -7.23      0.00 9...
1      1      2      9       -6.79      1.39 9...
2      2      1     16       -7.18      0.00 9...
3      3      1      2       -6.93      0.00 9...
4      3      2     17       -6.84      0.23 9...
5      4      1     15       -6.55      0.00 9...
6      4      2      7       -6.34      0.33 9...
7      5      1      5       -6.41      0.00 9...
8      6      1      3       -6.36      0.00 9...
9      6      2     10       -6.28      0.47 9...
10     6      3      6       -6.27      0.43 9...
11     6      4     18       -6.25      0.32 9...
12     6      5     13       -6.24      0.96 9...
13     6      6      1       -6.24      0.87 9...
14     6      7     14       -6.21      0.51 9...
15     6      8     11       -6.14      0.98 9...
16     6      9     20       -6.11      0.71 9...
17     6     10     19       -6.01      1.36 9...
18     7      1     12       -6.30      0.00 9...
19     8      1      4       -5.85      0.00 9...
20 ______________________________________________...

I have used the ligand_file = line in other Python script that has worked without any errors.

Google has not been a solution in his case.  Pointers towards wolutions to this problem will be much appreciated.

Thanks in advance.

-- 
Stephen P. Molnar, Ph.D.            Life is a fuzzy set
http://www.Molecular-Modeling.net   Multivariate and stochastic
614.312.7528 (c)
Skype:  smolnar1

_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


This message has been scanned by Capita systems, but if you believe it to be spam, please send it to spam at forcepoint.com.

Messages sent to spam at forcepoint.com are queued for email analysis by Forcepoint Threat Lab.


This email is security checked and subject to the disclaimer on web-page: http://www.capita.co.uk/email-disclaimer.aspx

From s.molnar at sbcglobal.net  Tue Sep 24 09:24:32 2019
From: s.molnar at sbcglobal.net (Stephen P. Molnar)
Date: Tue, 24 Sep 2019 09:24:32 -0400
Subject: [Tutor] Pandas Problem?
In-Reply-To: <CWXP265MB13681A9EB2D0B6AA2E5573AECA840@CWXP265MB1368.GBRP265.PROD.OUTLOOK.COM>
References: <5D8A07D3.5090005@sbcglobal.net>
 <CWXP265MB13681A9EB2D0B6AA2E5573AECA840@CWXP265MB1368.GBRP265.PROD.OUTLOOK.COM>
Message-ID: <5D8A1910.3020609@sbcglobal.net>

Thant did it.

Many thanks.


On 09/24/2019 09:16 AM, Flynn, Stephen (Life & Pensions) wrote:
> You're trying to open a file named 'ligand_file', as evidenced by:
>
> FileNotFoundError: [Errno 2] File b'ligand_file' does not exist:
> b'ligand_file'
>
>
> However, ligand_file is the name of the variable which contains the name of the file you want to open. Remove the quotes from 'ligand_file' in your read_table statement.
>
> S.
>
> -----Original Message-----
> From: Tutor <tutor-bounces+steve.flynn=capita.co.uk at python.org> On Behalf Of Stephen P. Molnar
> Sent: 24 September 2019 13:11
> To: Python Tutor <tutor at python.org>
> Subject: [Tutor] Pandas Problem?
>
> I am using the Spyder3 IDE with Python 3.7.3 and have encountered, what to me at least, is a rather strange problem.
>
> The code, at this point is:
>
> #!/usr/bin/env python3
> # -*- coding: utf-8 -*-
> """
> Created on Sat Apr  8 15:17:07 2017
>
> @author: comp
>
> """
> #import numpy as np
> #import matplotlib.pyplot as plt
> import pandas as pd
>
> name = input("Enter Molecule ID: ")
>
> print(name)
>
> ligand_file = name+'_apo-1acl.RMSD'
>
> print('Ligand file = ',ligand_file)
>
> data = pd.read_table('ligand_file',skiprows = 7)
>
> print(data)
>
> The input file, in this example, 17-3_apo-1acl.RMSD is:
>
>       RMSD TABLE
>       __________
>
> _____________________________________________________________________
>        |      |      |           |         |                 |
> Rank | Sub- | Run  | Binding   | Cluster | Reference       | Grep
>        | Rank |      | Energy    | RMSD    | RMSD            | Pattern
> _____|______|______|___________|_________|_________________|___________
>      1      1      8       -7.23      0.00     93.07           RANKING
>      1      2      9       -6.79      1.39     92.64           RANKING
>      2      1     16       -7.18      0.00     93.19           RANKING
>      3      1      2       -6.93      0.00     93.38           RANKING
>      3      2     17       -6.84      0.23     93.45           RANKING
>      4      1     15       -6.55      0.00     91.83           RANKING
>      4      2      7       -6.34      0.33     91.77           RANKING
>      5      1      5       -6.41      0.00     93.05           RANKING
>      6      1      3       -6.36      0.00     92.84           RANKING
>      6      2     10       -6.28      0.47     92.92           RANKING
>      6      3      6       -6.27      0.43     92.82           RANKING
>      6      4     18       -6.25      0.32     92.88           RANKING
>      6      5     13       -6.24      0.96     92.75           RANKING
>      6      6      1       -6.24      0.87     92.60           RANKING
>      6      7     14       -6.21      0.51     92.90           RANKING
>      6      8     11       -6.14      0.98     92.78           RANKING
>      6      9     20       -6.11      0.71     92.67           RANKING
>      6     10     19       -6.01      1.36     93.00           RANKING
>      7      1     12       -6.30      0.00     93.28           RANKING
>      8      1      4       -5.85      0.00     92.97           RANKING
> _______________________________________________________________________
>
> The output at this point is:
>
> Enter Molecule ID: 17-3
> 17-3
> Ligand file =  17-3_apo-1acl.RMSD
> Traceback (most recent call last):
>
>     File "<ipython-input-3-48de0a8fd907>", line 1, in <module> runfile('/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/RMSDTable_3.py.',
> wdir='/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable')
>
>     File
> "/usr/local/lib/python3.7/dist-packages/spyder_kernels/customize/spydercustomize.py",
> line 827, in runfile
>       execfile(filename, namespace)
>
>     File
> "/usr/local/lib/python3.7/dist-packages/spyder_kernels/customize/spydercustomize.py",
> line 110, in execfile
>       exec(compile(f.read(), filename, 'exec'), namespace)
>
>     File
> "/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/RMSDTable_3.py.",
> line 23, in <module>
>       data = pd.read_table('ligand_file',skiprows = 7)
>
>     File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py",
> line 685, in parser_f
>       return _read(filepath_or_buffer, kwds)
>
>     File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py",
> line 457, in _read
>       parser = TextFileReader(fp_or_buf, **kwds)
>
>     File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py",
> line 895, in __init__
>       self._make_engine(self.engine)
>
>     File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py",
> line 1135, in _make_engine
>       self._engine = CParserWrapper(self.f, **self.options)
>
>     File "/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py",
> line 1917, in __init__
>       self._reader = parsers.TextReader(src, **kwds)
>
>     File "pandas/_libs/parsers.pyx", line 382, in pandas._libs.parsers.TextReader.__cinit__
>
>     File "pandas/_libs/parsers.pyx", line 689, in pandas._libs.parsers.TextReader._setup_parser_source
>
> FileNotFoundError: [Errno 2] File b'ligand_file' does not exist:
> b'ligand_file'
>
>
> However, if I change the data = line to:
>
> data = pd.read_table('13-7_apo-1acl.RMSD',skiprows = 7)
>
> The output is:
>
> runfile('/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/RMSDTable_3.py.',
> wdir='/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable')
>
> Enter Molecule ID: 13-7
> 13-7
> Ligand file =  13-7_apo-1acl.RMSD
> _____|______|______|___________|_________|_________________|___________
> 0      1      1      8       -7.23      0.00 9...
> 1      1      2      9       -6.79      1.39 9...
> 2      2      1     16       -7.18      0.00 9...
> 3      3      1      2       -6.93      0.00 9...
> 4      3      2     17       -6.84      0.23 9...
> 5      4      1     15       -6.55      0.00 9...
> 6      4      2      7       -6.34      0.33 9...
> 7      5      1      5       -6.41      0.00 9...
> 8      6      1      3       -6.36      0.00 9...
> 9      6      2     10       -6.28      0.47 9...
> 10     6      3      6       -6.27      0.43 9...
> 11     6      4     18       -6.25      0.32 9...
> 12     6      5     13       -6.24      0.96 9...
> 13     6      6      1       -6.24      0.87 9...
> 14     6      7     14       -6.21      0.51 9...
> 15     6      8     11       -6.14      0.98 9...
> 16     6      9     20       -6.11      0.71 9...
> 17     6     10     19       -6.01      1.36 9...
> 18     7      1     12       -6.30      0.00 9...
> 19     8      1      4       -5.85      0.00 9...
> 20 ______________________________________________...
>
> I have used the ligand_file = line in other Python script that has worked without any errors.
>
> Google has not been a solution in his case.  Pointers towards wolutions to this problem will be much appreciated.
>
> Thanks in advance.
>

-- 
Stephen P. Molnar, Ph.D.            Life is a fuzzy set
http://www.Molecular-Modeling.net   Multivariate and stochastic
614.312.7528 (c)
Skype:  smolnar1


From s.molnar at sbcglobal.net  Fri Sep 27 07:47:31 2019
From: s.molnar at sbcglobal.net (Stephen P. Molnar)
Date: Fri, 27 Sep 2019 07:47:31 -0400
Subject: [Tutor] NumPy Generates ValueError: Some errors were detected !
 Line #9 (got 42 columns instead of 1)
Message-ID: <5D8DF6D3.8090108@sbcglobal.net>

0

I am writing code to combine text files and I have encountered an error 
that I am having trouble solving. Google is no help.

The code is:

|#!/usr/bin/env python3# -*- coding: utf-8 -*-""" Created on Thu Sep 26 
09:51:55 2019 @author: comp """importnumpy asnp NAME =input("Enter 
Molecule ID: ")NAME_IN =NAME+'_apo-1acl.RMSD'DATA =[]DATA 
=np.genfromtxt(NAME_IN,skip_header=8,dtype=None)|

The text file is:

|RMSD TABLE __________ 
_____________________________________________________________________ 
||||||Rank|Sub-|Run|Binding|Cluster|Reference|Grep|Rank||Energy|RMSD 
|RMSD 
|Pattern_____|______|______|___________|_________|_________________|___________ 
118-7.230.0093.07RANKING 129-6.791.3992.64RANKING 
2116-7.180.0093.19RANKING 312-6.930.0093.38RANKING 
3217-6.840.2393.45RANKING 4115-6.550.0091.83RANKING 
427-6.340.3391.77RANKING 515-6.410.0093.05RANKING 
613-6.360.0092.84RANKING 6210-6.280.4792.92RANKING 
636-6.270.4392.82RANKING 6418-6.250.3292.88RANKING 
6513-6.240.9692.75RANKING 661-6.240.8792.60RANKING 
6714-6.210.5192.90RANKING 6811-6.140.9892.78RANKING 
6920-6.110.7192.67RANKING 61019-6.011.3693.00RANKING 
7112-6.300.0093.28RANKING 814-5.850.0092.97RANKING 
_______________________________________________________________________|

and the error is:

|runfile('/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/CombineRMSDFiles.py') 
Enter Molecule ID: 13-7 13-7_apo-1acl.RMSD Traceback (most recent call 
last): File 
"/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/CombineRMSDFiles.py", 
line 15, in <module> DATA = np.genfromtxt(NAME_IN, dtype=None, 
skip_header=8) File 
"/home/comp/Apps/Miniconda3/lib/python3.7/site-packages/numpy/lib/npyio.py", 
line 2075, in genfromtxt raise ValueError(errmsg) ValueError: Some 
errors were detected ! Line #29 (got 1 columns instead of 7)|

At this point, I'm not even sure how to ask the question.

Thanks in advance.


-- 
Stephen P. Molnar, Ph.D.            Life is a fuzzy set
http://www.Molecular-Modeling.net   Multivariate and stochastic
614.312.7528 (c)
Skype:  smolnar1


From mats at wichmann.us  Fri Sep 27 09:28:26 2019
From: mats at wichmann.us (Mats Wichmann)
Date: Fri, 27 Sep 2019 07:28:26 -0600
Subject: [Tutor] NumPy Generates ValueError: Some errors were detected !
 Line #9 (got 42 columns instead of 1)
In-Reply-To: <5D8DF6D3.8090108@sbcglobal.net>
References: <5D8DF6D3.8090108@sbcglobal.net>
Message-ID: <4f3d0f52-bd66-453d-b68a-ac0627f95861@wichmann.us>

On 9/27/19 5:47 AM, Stephen P. Molnar wrote:
> 0
> 
> I am writing code to combine text files and I have encountered an error 
> that I am having trouble solving. Google is no help.
> 
> The code is:
> 
> |#!/usr/bin/env python3# -*- coding: utf-8 -*-""" Created on Thu Sep 26 
> 09:51:55 2019 @author: comp """importnumpy asnp NAME =input("Enter 
> Molecule ID: ")NAME_IN =NAME+'_apo-1acl.RMSD'DATA =[]DATA 
> =np.genfromtxt(NAME_IN,skip_header=8,dtype=None)|
> 
> The text file is:
> 
> |RMSD TABLE __________ 
> _____________________________________________________________________ 
> ||||||Rank|Sub-|Run|Binding|Cluster|Reference|Grep|Rank||Energy|RMSD 
> |RMSD 
> |Pattern_____|______|______|___________|_________|_________________|___________ 
> 118-7.230.0093.07RANKING 129-6.791.3992.64RANKING 
> 2116-7.180.0093.19RANKING 312-6.930.0093.38RANKING 
> 3217-6.840.2393.45RANKING 4115-6.550.0091.83RANKING 
> 427-6.340.3391.77RANKING 515-6.410.0093.05RANKING 
> 613-6.360.0092.84RANKING 6210-6.280.4792.92RANKING 
> 636-6.270.4392.82RANKING 6418-6.250.3292.88RANKING 
> 6513-6.240.9692.75RANKING 661-6.240.8792.60RANKING 
> 6714-6.210.5192.90RANKING 6811-6.140.9892.78RANKING 
> 6920-6.110.7192.67RANKING 61019-6.011.3693.00RANKING 
> 7112-6.300.0093.28RANKING 814-5.850.0092.97RANKING 
> _______________________________________________________________________|
> 
> and the error is:
> 
> |runfile('/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/CombineRMSDFiles.py') 
> Enter Molecule ID: 13-7 13-7_apo-1acl.RMSD Traceback (most recent call 
> last): File 
> "/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/CombineRMSDFiles.py", 
> line 15, in <module> DATA = np.genfromtxt(NAME_IN, dtype=None, 
> skip_header=8) File 
> "/home/comp/Apps/Miniconda3/lib/python3.7/site-packages/numpy/lib/npyio.py", 
> line 2075, in genfromtxt raise ValueError(errmsg) ValueError: Some 
> errors were detected ! Line #29 (got 1 columns instead of 7)|
> 
> At this point, I'm not even sure how to ask the question.
> 
> Thanks in advance.

your posting has come across mangled, seemingly spaces have been 
stripped.  But trying to disentangle it:

"...pyio.py", line 2075, in genfromtxt
raise ValueError(errmsg)
ValueError: Some errors were detected ! Line #29 (got 1 columns instead 
of 7)|

and in your data you have lines which are clearly not seven columns. 
You've done skip_header=8 and it doesn't look here that's eight lines in 
the data pasted, but maybe that's due to whatever happened to the pasted 
data between the source and the email.  It looks at the very least like 
you should use a skip_footer keyword as well since you show a footer 
line.  Beyond that it's really hard to tell as the data portion of the 
table looks like it has no separators...

From bouncingcats at gmail.com  Fri Sep 27 19:35:15 2019
From: bouncingcats at gmail.com (David)
Date: Sat, 28 Sep 2019 09:35:15 +1000
Subject: [Tutor] NumPy Generates ValueError: Some errors were detected !
 Line #9 (got 42 columns instead of 1)
In-Reply-To: <5D8E4B81.4040508@sbcglobal.net>
References: <5D8DF6D3.8090108@sbcglobal.net>
 <4f3d0f52-bd66-453d-b68a-ac0627f95861@wichmann.us>
 <5D8E14B7.8020008@sbcglobal.net> <5D8E4B81.4040508@sbcglobal.net>
Message-ID: <CAMPXz=rFhmH=nhpRHqGjZoEeidHXEHKoh5oYBZz=jeQBMSW-WQ@mail.gmail.com>

On Sat, 28 Sep 2019 at 03:49, Stephen P. Molnar <s.molnar at sbcglobal.net> wrote:
> On 09/27/2019 09:55 AM, Stephen P. Molnar wrote:
> > On 09/27/2019 09:28 AM, Mats Wichmann wrote:
> >> On 9/27/19 5:47 AM, Stephen P. Molnar wrote:

> >>> I am writing code to combine text files and I have encountered an
> >>> error that I am having trouble solving. Google is no help.
> >>>
> >>> The code is:
> >>>
> >>> |#!/usr/bin/env python3# -*- coding: utf-8 -*-""" Created on Thu Sep
> >>> 26 09:51:55 2019 @author: comp """importnumpy asnp NAME
> >>> =input("Enter Molecule ID: ")NAME_IN =NAME+'_apo-1acl.RMSD'DATA
> >>> =[]DATA =np.genfromtxt(NAME_IN,skip_header=8,dtype=None)|
> >>>
> >>> The text file is:
> >>>
> >>> |RMSD TABLE __________
> >>> _____________________________________________________________________ ||||||Rank|Sub-|Run|Binding|Cluster|Reference|Grep|Rank||Energy|RMSD
> >>> |RMSD
> >>> |Pattern_____|______|______|___________|_________|_________________|___________
> >>> 118-7.230.0093.07RANKING 129-6.791.3992.64RANKING
> >>> 2116-7.180.0093.19RANKING 312-6.930.0093.38RANKING
> >>> 3217-6.840.2393.45RANKING 4115-6.550.0091.83RANKING
> >>> 427-6.340.3391.77RANKING 515-6.410.0093.05RANKING
> >>> 613-6.360.0092.84RANKING 6210-6.280.4792.92RANKING
> >>> 636-6.270.4392.82RANKING 6418-6.250.3292.88RANKING
> >>> 6513-6.240.9692.75RANKING 661-6.240.8792.60RANKING
> >>> 6714-6.210.5192.90RANKING 6811-6.140.9892.78RANKING
> >>> 6920-6.110.7192.67RANKING 61019-6.011.3693.00RANKING
> >>> 7112-6.300.0093.28RANKING 814-5.850.0092.97RANKING
> >>> _______________________________________________________________________|
> >>>
> >>> and the error is:
> >>>
> >>> |runfile('/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/CombineRMSDFiles.py')
> >>> Enter Molecule ID: 13-7 13-7_apo-1acl.RMSD Traceback (most recent
> >>> call last): File
> >>> "/home/comp/Apps/Models/1-PhosphorusLigands/CombinedLigands/MOL/Docking/Results/RMSDTable/CombineRMSDFiles.py",
> >>> line 15, in <module> DATA = np.genfromtxt(NAME_IN, dtype=None,
> >>> skip_header=8) File
> >>> "/home/comp/Apps/Miniconda3/lib/python3.7/site-packages/numpy/lib/npyio.py",
> >>> line 2075, in genfromtxt raise ValueError(errmsg) ValueError: Some
> >>> errors were detected ! Line #29 (got 1 columns instead of 7)|
> >>>
> >>> At this point, I'm not even sure how to ask the question.
> >>>
> >>
> >> your posting has come across mangled, seemingly spaces have been
> >> stripped.  But trying to disentangle it:
> >>
> >> "...pyio.py", line 2075, in genfromtxt
> >> raise ValueError(errmsg)
> >> ValueError: Some errors were detected ! Line #29 (got 1 columns
> >> instead of 7)|
> >>
> >> and in your data you have lines which are clearly not seven columns.
> >> You've done skip_header=8 and it doesn't look here that's eight lines
> >> in the data pasted, but maybe that's due to whatever happened to the
> >> pasted data between the source and the email.  It looks at the very
> >> least like you should use a skip_footer keyword as well since you
> >> show a footer line. Beyond that it's really hard to tell as the data
> >> portion of the table looks like it has no separators...
> >> _______________________________________________
> >> Tutor maillist  -  Tutor at python.org
> >> To unsubscribe or change subscription options:
> >> https://mail.python.org/mailman/listinfo/tutor
> >
> > Sorry about the mangled files.
> >
> >
> > I put both the python script and the data file in my Dropbox account.
> > Here are the URL's:
> >
> > https://www.dropbox.com/s/aattr8qnjwd8b8e/13-7a_apo-1acl.RMSD?dl=0
> > https://www.dropbox.com/s/aattr8qnjwd8b8e/13-7a_apo-1acl.RMSD?dl=0
> >
> Oh, dear. Just noticed my mistake.
>
> Here are the correct URL's:
>
> Data\ File:
> https://www.dropbox.com/s/aattr8qnjwd8b8e/13-7a_apo-1acl.RMSD?dl=0
> Python Script:
> https://www.dropbox.com/s/ni3pk0342q7o0qz/CombineRMSDFiles.py?dl=0

I get the feeling that you don't put much effort into asking questions
on the mailing lists that I see you on.

Here you have:

1) somehow posted your question to Python Tutor <tutor at python.org>, but
posted your followup message to <debian-user at lists.debian.net>

2) somehow ignored the error message from python:
ValueError: Some errors were detected ! Line #29 (got 1 columns instead of 7)|

3) somehow ignored the advice you were given on Python Tutor:
> >> It looks at the very
> >> least like you should use a skip_footer keyword as well since you
> >> show a footer line

I checked your dropbox data file at your corrected URL.
Line 29 is a sequence of 71 underscore characters.
Like Mats Wichmann replied, I think that would explain the error message
"got 1 columns instead of 7", although I haven't bothered to test it.

From savageapple850 at gmail.com  Sat Sep 28 03:48:38 2019
From: savageapple850 at gmail.com (Cravan)
Date: Sat, 28 Sep 2019 15:48:38 +0800
Subject: [Tutor] Type error when doing Pygame
Message-ID: <9A96224D-79E3-4886-91EC-40FB1415888F@gmail.com>

Hi guys, 

??????????????? Recently tried doing a pygame project (which is still half-finished). However I received a TypeError code that 5 positional arguments have been inserted when I have only inserted four in my function. Have no idea why its not working.

Here?s my code:

```

import pygame

import random

import math

import os

import time

import sys

from os import path

from newsettings import *

from spritesdata import *

class Game:

??? def __init__(self):

??????? pygame.init()

??????? self.clock = pygame.time.Clock()

??????? self.screen = pygame.display.set_mode((WIDTH, HEIGHT))

??????? pygame.display.set_caption(TITLE)

??????? self.time = pygame.time.get_ticks()

??????? pygame.key.set_repeat(500, 100)

??????? self.all_sprites = pygame.sprite.Group()

??????? self.console = Console(self, 0)

??????? self.player = Player(self, 390, 595)

??????? self.work = Work(self, 450, 250)

??????? self.food_station = Food_Station(self, 750, 200)

??????? self.food = Food(self, 0, 10)

??????? self.education = Education(self, 300, 10)

??????? self.school = School(self, 100, 200)

??????? self.family = Family(self, 600, 10)

??????? self.money = Money(self, 850, 15)

??????? self.food_bar = 100

 

??? def run(self):

??????? self.playing = True

??????? while self.playing:

??????????? self.dt = self.clock.tick(FPS) / 1000

??????????? self.hunger()

??????????? self.events()

??????????? self.update()

??????????? self.draw()

 

??? def hunger(self):

??????? HUNGEREVENT = pygame.USEREVENT + 1

??????? pygame.time.set_timer(HUNGEREVENT, 10000)

??? def food_food(self, x, y, cool):

??????? if cool < 0:

??????????? cool = 0

??????? BAR_LENGTH = 100

??????? BAR_HEIGHT = 10

??????? fill = (cool / 100) * BAR_LENGTH

??????? outline_rect = pygame.Rect(x, y, BAR_LENGTH, BAR_HEIGHT)

??????? fill_rect = pygame.Rect(x, y, fill, BAR_HEIGHT)

??????? pygame.draw.rect(self, GREEN, fill_rect)

??????? pygame.draw.rect(self, WHITE, outline_rect, 2)

 

??? def quit(self):

??????? pygame.quit()

?????? ?sys.exit()

 

??? def update(self):

??????? self.all_sprites.update()

 

??? def draw(self):

??????? self.screen.fill(BGCOLOR)

??????? self.all_sprites.draw(self.screen)

??????? font = pygame.font.SysFont('Arial', 15, True, False)

??????? self.food_food(screen, 5, 5, self.food_bar)

??????? text = font.render("Number of days:" , True, BLACK)

??????? screen.blit(text, [0, 110])

??????? font = pygame.font.SysFont('Arial', 30, True, False)

??????? text = font.render("=" , True, BLACK)

??????? screen.blit(text, [120, 40])

??????? font = pygame.font.SysFont('Arial', 30, True, False)

??????? text = font.render("=" , True, BLACK)

??????? screen.blit(text, [400, 40])

??????? font = pygame.font.SysFont('Arial', 30, True, False)

??????? text = font.render("=" , True, BLACK)

??????? screen.blit(text, [700, 40])

??????? font = pygame.font.SysFont('Arial', 30, True, False)

??????? text = font.render("=" , True, BLACK)

??????? screen.blit(text, [950, 40])

??????? self.all_sprites.update()

??????? pygame.display.flip()

 

??? def events(self):

??????? # catch all events here

??????? HUNGEREVENT = pygame.USEREVENT + 1

??????? pygame.time.set_timer(HUNGEREVENT, 10000)

???? ???if pygame.event.get(HUNGEREVENT):

??????????? self.food_bar = self.food_bar - 10

??????? for event in pygame.event.get():

??????????? if event.type == pygame.QUIT:

??????????????? self.quit()

??????????????? if event.key == pygame.K_ESCAPE:

??????????????????? self.quit()

 

 

??? def end_screen(self):

??????? screen.fill(BLUE)

??????? font = pygame.font.SysFont('Arial', 30, True, False)

??????? text = font.render("Life Simulator V2" , True, WHITE)

??????? screen.blit(text, [400, 100])

??????? font = pygame.font.SysFont('Arial', 30, True, False)

??????? text = font.render("Controls: F for food, E for education, W for work", True, WHITE)

??????? screen.blit(text, [175, 250])

??????? font = pygame.font.SysFont('Arial', 30, True, False)

??????? text = font.render("Hard mode: h??? Easy mode: e??? Normal mode: m", True, WHITE)

??????? screen.blit(text, [175, 400])

??????? font = pygame.font.SysFont('Arial', 30, True, False)

??????? text = font.render("Start by pressing a key corresponding to that mode", True, WHITE)

??????? screen.blit(text, [150, 600])

??????? pygame.display.flip()

??????? waiting = True

??????? while waiting:

??????????? pygame.init()

??????????? clock = pygame.time.Clock()

??????????? clock.tick(60)

??????????? for event in pygame.event.get():

??????????????? if event.type == pygame.QUIT:

??????????????????? sys.exit()

??????????????? if event.type == pygame.KEYDOWN:

??????????????????? if event.key == pygame.K_h:

??????????????????????? waiting = False

??????????????????????? initial_money = 50

??????????????????????? self.food_bar = 100

??????????????????? if event.key == pygame.K_m:

??????????????????????? waiting = False

??????????????????????? initial_money = 100

??????????????????????? self.food_bar = 100

??????????????????? if event.key == pygame.K_e:

??????????????????????? waiting = False

??????????????????????? initial_money = 200

??????????????????????? self.food_bar = 100

 

g = Game()

g.end_screen()

g.run()

```

 

 

And here?s the Error I?m receiving:

 

################################

Traceback (most recent call last):

? File "final_project.py", line 135, in <module>

??? g.run()

? File "final_project.py", line 37, in run

??? self.draw()

? File "final_project.py", line 65, in draw

??? self.food_food(screen, 5, 5, self.food_bar)

TypeError: food_food() takes 4 positional arguments but 5 were given

 

Any help is appreciated. Thanks in advance!

Cravan


From alan.gauld at btinternet.com  Fri Sep 27 12:22:52 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Fri, 27 Sep 2019 17:22:52 +0100
Subject: [Tutor] NumPy Generates ValueError: Some errors were detected !
 Line #9 (got 42 columns instead of 1)
In-Reply-To: <5D8DF6D3.8090108@sbcglobal.net>
References: <5D8DF6D3.8090108@sbcglobal.net>
Message-ID: <52ad3f42-ff67-2ee9-41ca-5ee9afa47095@btinternet.com>

On 27/09/2019 12:47, Stephen P. Molnar wrote:
> 6714-6.210.5192.90RANKING 6811-6.140.9892.78RANKING 
> 6920-6.110.7192.67RANKING 61019-6.011.3693.00RANKING 
> 7112-6.300.0093.28RANKING 814-5.850.0092.97RANKING 
> _______________________________________________________________________|
>
> and the error is:
>
> errors were detected ! Line #29 (got 1 columns instead of 7)|
>

It looks like your data is separated by periods. But I don't see how you
tell
Python that fact? I suspect there should be something like a
separator='.' argument in there somewhere?


I don't know the numpy stuff at all so can only surmise but that's
what I'd expect.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From PyTutor at DancesWithMice.info  Sat Sep 28 06:20:37 2019
From: PyTutor at DancesWithMice.info (David L Neil)
Date: Sat, 28 Sep 2019 22:20:37 +1200
Subject: [Tutor] Type error when doing Pygame
In-Reply-To: <9A96224D-79E3-4886-91EC-40FB1415888F@gmail.com>
References: <9A96224D-79E3-4886-91EC-40FB1415888F@gmail.com>
Message-ID: <ac33de91-a58d-f66d-80d9-db03fddf25fe@DancesWithMice.info>

On 28/09/19 7:48 PM, Cravan wrote:
> Hi guys,
> 
>  ??????????????? Recently tried doing a pygame project (which is still half-finished). However I received a TypeError code that 5 positional arguments have been inserted when I have only inserted four in my function. Have no idea why its not working.
...

> And here?s the Error I?m receiving:
> Traceback (most recent call last):
> 
>  ? File "final_project.py", line 135, in <module>
> 
>  ??? g.run()
> 
>  ? File "final_project.py", line 37, in run
> 
>  ??? self.draw()
> 
>  ? File "final_project.py", line 65, in draw
> 
>  ??? self.food_food(screen, 5, 5, self.food_bar)
> 
> TypeError: food_food() takes 4 positional arguments but 5 were given


It's always worth looking carefully at the information contained within 
the Traceback. In this case, we're being told that the method is being 
given more arguments than it needs.

Should the first/"screen" argument be included?
(it does not appear to be used within the method)

-- 
Regards =dn

From cs at cskk.id.au  Sat Sep 28 06:47:52 2019
From: cs at cskk.id.au (Cameron Simpson)
Date: Sat, 28 Sep 2019 20:47:52 +1000
Subject: [Tutor] Type error when doing Pygame
In-Reply-To: <ac33de91-a58d-f66d-80d9-db03fddf25fe@DancesWithMice.info>
References: <ac33de91-a58d-f66d-80d9-db03fddf25fe@DancesWithMice.info>
Message-ID: <20190928104752.GA17728@cskk.homeip.net>

On 28Sep2019 22:20, DL Neil <PyTutor at DancesWithMice.info> wrote:
>On 28/09/19 7:48 PM, Cravan wrote:
>> ??????????????? Recently tried doing a pygame project (which is still 
>> half-finished). However I received a TypeError code that 5 positional 
>> arguments have been inserted when I have only inserted four in my 
>> function. Have no idea why its not working.
>...
>
>>And here?s the Error I?m receiving:
>>Traceback (most recent call last):
>> ? File "final_project.py", line 135, in <module>
>> ??? g.run()
>> ? File "final_project.py", line 37, in run
>> ??? self.draw()
>> ? File "final_project.py", line 65, in draw
>> ??? self.food_food(screen, 5, 5, self.food_bar)
>>TypeError: food_food() takes 4 positional arguments but 5 were given
>
>It's always worth looking carefully at the information contained within 
>the Traceback. In this case, we're being told that the method is being 
>given more arguments than it needs.
>
>Should the first/"screen" argument be included?
>(it does not appear to be used within the method)

Additionally, this eror is often confusing.

When you call some method:

  obj.method(a,b)

it calls ObjClass.method(self,a,b).

So you've overtly called it with 2 arguments, but the method is invokes 
with 3 arguments because "self" is automatically supplied.

So in your error message you called:

  self.food_food(screen, 5, 5, self.food_bar)

which has 4 arguments, but "food_food" gets those arguments with "self" 
at the front, so the complaint is that "5 were given".

Cheers,
Cameron Simpson <cs at cskk.id.au>

From alan.gauld at btinternet.com  Sat Sep 28 04:22:13 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Sat, 28 Sep 2019 09:22:13 +0100
Subject: [Tutor] Type error when doing Pygame
In-Reply-To: <9A96224D-79E3-4886-91EC-40FB1415888F@gmail.com>
References: <9A96224D-79E3-4886-91EC-40FB1415888F@gmail.com>
Message-ID: <43fb7485-e468-01d4-7dc7-265e13cf143d@btinternet.com>

On 28/09/2019 08:48, Cravan wrote:
> class Game:
>
> ??? def food_food(self, x, y, cool):
>
>
> And here?s the Error I?m receiving:
>
>  
>
> ################################
>
> Traceback (most recent call last):
>
>
> ? File "final_project.py", line 65, in draw
>
> ??? self.food_food(screen, 5, 5, self.food_bar)
>
> TypeError: food_food() takes 4 positional arguments but 5 were given

The definition says 4 parameters including the implicit self.

But you pass 4 parameters plus self. Hence the error.

It looks as if you are passing an extra value - presumably 'screen'


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From savageapple850 at gmail.com  Sat Sep 28 07:53:57 2019
From: savageapple850 at gmail.com (Cravan)
Date: Sat, 28 Sep 2019 19:53:57 +0800
Subject: [Tutor] Type error when doing Pygame
In-Reply-To: <43fb7485-e468-01d4-7dc7-265e13cf143d@btinternet.com>
References: <9A96224D-79E3-4886-91EC-40FB1415888F@gmail.com>
 <43fb7485-e468-01d4-7dc7-265e13cf143d@btinternet.com>
Message-ID: <AC0D070A-E24B-4AAB-A39C-187898CD23B2@gmail.com>

Dear Alan and Cameron, 
	Thank you for your input. However, after removing the first "screen" argument, I receive another error:
###################
Traceback (most recent call last):
  File "final_project.py", line 134, in <module>
    g.run()
  File "final_project.py", line 37, in run
    self.draw()
  File "final_project.py", line 64, in draw
    self.food_food(5, 5, self.food_bar)
  File "final_project.py", line 50, in food_food
    pygame.draw.rect(self, GREEN, fill_rect)
TypeError: argument 1 must be pygame.Surface, not Game

I apologise if this seems like a really silly question, but I don?t really code much and am not really proficient in coding. May I know how to rectify this?

Thanks,
Cravan

?On 28/9/19, 7:25 PM, "Tutor on behalf of Alan Gauld via Tutor" <tutor-bounces+savageapple850=gmail.com at python.org on behalf of tutor at python.org> wrote:

    On 28/09/2019 08:48, Cravan wrote:
    > class Game:
    >
    >     def food_food(self, x, y, cool):
    >
    >
    > And here?s the Error I?m receiving:
    >
    >  
    >
    > ################################
    >
    > Traceback (most recent call last):
    >
    >
    >   File "final_project.py", line 65, in draw
    >
    >     self.food_food(screen, 5, 5, self.food_bar)
    >
    > TypeError: food_food() takes 4 positional arguments but 5 were given
    
    The definition says 4 parameters including the implicit self.
    
    But you pass 4 parameters plus self. Hence the error.
    
    It looks as if you are passing an extra value - presumably 'screen'
    
    
    -- 
    Alan G
    Author of the Learn to Program web site
    http://www.alan-g.me.uk/
    http://www.amazon.com/author/alan_gauld
    Follow my photo-blog on Flickr at:
    http://www.flickr.com/photos/alangauldphotos
    
    _______________________________________________
    Tutor maillist  -  Tutor at python.org
    To unsubscribe or change subscription options:
    https://mail.python.org/mailman/listinfo/tutor
    



From mats at wichmann.us  Sat Sep 28 10:14:04 2019
From: mats at wichmann.us (Mats Wichmann)
Date: Sat, 28 Sep 2019 08:14:04 -0600
Subject: [Tutor] Type error when doing Pygame
In-Reply-To: <AC0D070A-E24B-4AAB-A39C-187898CD23B2@gmail.com>
References: <9A96224D-79E3-4886-91EC-40FB1415888F@gmail.com>
 <43fb7485-e468-01d4-7dc7-265e13cf143d@btinternet.com>
 <AC0D070A-E24B-4AAB-A39C-187898CD23B2@gmail.com>
Message-ID: <a5ddec2e-61bf-374f-8b92-9bd828e20bf1@wichmann.us>

On 9/28/19 5:53 AM, Cravan wrote:
> Dear Alan and Cameron,
> 	Thank you for your input. However, after removing the first "screen" argument, I receive another error:
> ###################
> Traceback (most recent call last):
>    File "final_project.py", line 134, in <module>
>      g.run()
>    File "final_project.py", line 37, in run
>      self.draw()
>    File "final_project.py", line 64, in draw
>      self.food_food(5, 5, self.food_bar)
>    File "final_project.py", line 50, in food_food
>      pygame.draw.rect(self, GREEN, fill_rect)
> TypeError: argument 1 must be pygame.Surface, not Game
> 
> I apologise if this seems like a really silly question, but I don?t really code much and am not really proficient in coding. May I know how to rectify this?

It's not silly, but you do figure out how Pygame's methods need to be 
called.  Clipped from their docs:

  pygame.draw.rect()
     draw a rectangle
     rect(surface, color, rect) -> Rect
     rect(surface, color, rect, width=0) -> Rect

     Draws a rectangle on the given surface.
     Parameters:	

         surface (Surface) -- surface to draw on


that makes sense... you need something to draw on.

you've passed it "self", which is a Game instance, and it doesn't know 
what to do with that.  You need to pass it a pygame.Surface instance, as 
the exception message says.  Presumably that would be something that has 
been previously set up, then stored as an attribute in "self" so that 
you can access it as needed.  That has happened in your initialization 
method, where you create a Surface by calling pygame.display.set_mode() 
and store the result in self.screen.   So almost certainly your call to 
draw_rect should be passing self.screen as the first aregument, rather 
than self.

Does that make sense?

From savageapple850 at gmail.com  Sat Sep 28 10:20:10 2019
From: savageapple850 at gmail.com (Cravan)
Date: Sat, 28 Sep 2019 22:20:10 +0800
Subject: [Tutor] Type error when doing Pygame
In-Reply-To: <a5ddec2e-61bf-374f-8b92-9bd828e20bf1@wichmann.us>
References: <9A96224D-79E3-4886-91EC-40FB1415888F@gmail.com>
 <43fb7485-e468-01d4-7dc7-265e13cf143d@btinternet.com>
 <AC0D070A-E24B-4AAB-A39C-187898CD23B2@gmail.com>
 <a5ddec2e-61bf-374f-8b92-9bd828e20bf1@wichmann.us>
Message-ID: <78A23E86-358B-481A-9A55-E85443334E60@gmail.com>

Dear Matt,
	Thanks for your help! It works now ( 
Cravan

?On 28/9/19, 10:18 PM, "Tutor on behalf of Mats Wichmann" <tutor-bounces+savageapple850=gmail.com at python.org on behalf of mats at wichmann.us> wrote:

    On 9/28/19 5:53 AM, Cravan wrote:
    > Dear Alan and Cameron,
    > 	Thank you for your input. However, after removing the first "screen" argument, I receive another error:
    > ###################
    > Traceback (most recent call last):
    >    File "final_project.py", line 134, in <module>
    >      g.run()
    >    File "final_project.py", line 37, in run
    >      self.draw()
    >    File "final_project.py", line 64, in draw
    >      self.food_food(5, 5, self.food_bar)
    >    File "final_project.py", line 50, in food_food
    >      pygame.draw.rect(self, GREEN, fill_rect)
    > TypeError: argument 1 must be pygame.Surface, not Game
    > 
    > I apologise if this seems like a really silly question, but I don?t really code much and am not really proficient in coding. May I know how to rectify this?
    
    It's not silly, but you do figure out how Pygame's methods need to be 
    called.  Clipped from their docs:
    
      pygame.draw.rect()
         draw a rectangle
         rect(surface, color, rect) -> Rect
         rect(surface, color, rect, width=0) -> Rect
    
         Draws a rectangle on the given surface.
         Parameters:	
    
             surface (Surface) -- surface to draw on
    
    
    that makes sense... you need something to draw on.
    
    you've passed it "self", which is a Game instance, and it doesn't know 
    what to do with that.  You need to pass it a pygame.Surface instance, as 
    the exception message says.  Presumably that would be something that has 
    been previously set up, then stored as an attribute in "self" so that 
    you can access it as needed.  That has happened in your initialization 
    method, where you create a Surface by calling pygame.display.set_mode() 
    and store the result in self.screen.   So almost certainly your call to 
    draw_rect should be passing self.screen as the first aregument, rather 
    than self.
    
    Does that make sense?
    _______________________________________________
    Tutor maillist  -  Tutor at python.org
    To unsubscribe or change subscription options:
    https://mail.python.org/mailman/listinfo/tutor
    



From s.molnar at sbcglobal.net  Sat Sep 28 12:36:01 2019
From: s.molnar at sbcglobal.net (Stephen P. Molnar)
Date: Sat, 28 Sep 2019 12:36:01 -0400
Subject: [Tutor] NumPy Generates ValueError: Some errors were detected !
 Line #9 (got 42 columns instead of 1)
In-Reply-To: <52ad3f42-ff67-2ee9-41ca-5ee9afa47095@btinternet.com>
References: <5D8DF6D3.8090108@sbcglobal.net>
 <52ad3f42-ff67-2ee9-41ca-5ee9afa47095@btinternet.com>
Message-ID: <5D8F8BF1.6040909@sbcglobal.net>



On 09/27/2019 12:22 PM, Alan Gauld via Tutor wrote:
> On 27/09/2019 12:47, Stephen P. Molnar wrote:
>> 6714-6.210.5192.90RANKING 6811-6.140.9892.78RANKING
>> 6920-6.110.7192.67RANKING 61019-6.011.3693.00RANKING
>> 7112-6.300.0093.28RANKING 814-5.850.0092.97RANKING
>> _______________________________________________________________________|
>>
>> and the error is:
>>
>> errors were detected ! Line #29 (got 1 columns instead of 7)|
>>
> It looks like your data is separated by periods. But I don't see how you
> tell
> Python that fact? I suspect there should be something like a
> separator='.' argument in there somewhere?
>
>
> I don't know the numpy stuff at all so can only surmise but that's
> what I'd expect.
>
  Thank you for your reply. There are, in fact, hidden characters in the 
input file (cat -A ...):

> ^IRMSD TABLE$
> ^I__________$
> $
> _____________________________________________________________________$
>      |      |      |           |         |                 |$
> Rank | Sub- | Run  | Binding   | Cluster | Reference       | Grep$
>      | Rank |      | Energy    | RMSD    | RMSD            | Pattern$
> _____|______|______|___________|_________|_________________|___________$
>    1      1      8       -7.23      0.00     93.07 RANKING$
>    1      2      9       -6.79      1.39     92.64 RANKING$
>    2      1     16       -7.18      0.00     93.19 RANKING$
>    3      1      2       -6.93      0.00     93.38 RANKING$
>    3      2     17       -6.84      0.23     93.45 RANKING$
>    4      1     15       -6.55      0.00     91.83 RANKING$
>    4      2      7       -6.34      0.33     91.77 RANKING$
>    5      1      5       -6.41      0.00     93.05 RANKING$
>    6      1      3       -6.36      0.00     92.84 RANKING$
>    6      2     10       -6.28      0.47     92.92 RANKING$
>    6      3      6       -6.27      0.43     92.82 RANKING$
>    6      4     18       -6.25      0.32     92.88 RANKING$
>    6      5     13       -6.24      0.96     92.75 RANKING$
>    6      6      1       -6.24      0.87     92.60 RANKING$
>    6      7     14       -6.21      0.51     92.90 RANKING$
>    6      8     11       -6.14      0.98     92.78 RANKING$
>    6      9     20       -6.11      0.71     92.67 RANKING$
>    6     10     19       -6.01      1.36     93.00 RANKING$
>    7      1     12       -6.30      0.00     93.28 RANKING$
>    8      1      4       -5.85      0.00     92.97 RANKING$
> _______________________________________________________________________$
but no periods.

-- 
Stephen P. Molnar, Ph.D.            Life is a fuzzy set
http://www.Molecular-Modeling.net   Multivariate and stochastic
614.312.7528 (c)
Skype:  smolnar1


From s.molnar at sbcglobal.net  Sat Sep 28 15:23:37 2019
From: s.molnar at sbcglobal.net (Stephen P. Molnar)
Date: Sat, 28 Sep 2019 15:23:37 -0400
Subject: [Tutor] NumPy Generates ValueError: Some errors were detected !
 Line #9 (got 42 columns instead of 1)
In-Reply-To: <5D8F8BF1.6040909@sbcglobal.net>
References: <5D8DF6D3.8090108@sbcglobal.net>
 <52ad3f42-ff67-2ee9-41ca-5ee9afa47095@btinternet.com>
 <5D8F8BF1.6040909@sbcglobal.net>
Message-ID: <5D8FB339.4000209@sbcglobal.net>



On 09/28/2019 12:36 PM, Stephen P. Molnar wrote:
>
>
> On 09/27/2019 12:22 PM, Alan Gauld via Tutor wrote:
>> On 27/09/2019 12:47, Stephen P. Molnar wrote:
>>> 6714-6.210.5192.90RANKING 6811-6.140.9892.78RANKING
>>> 6920-6.110.7192.67RANKING 61019-6.011.3693.00RANKING
>>> 7112-6.300.0093.28RANKING 814-5.850.0092.97RANKING
>>> _______________________________________________________________________| 
>>>
>>>
>>> and the error is:
>>>
>>> errors were detected ! Line #29 (got 1 columns instead of 7)|
>>>
>> It looks like your data is separated by periods. But I don't see how you
>> tell
>> Python that fact? I suspect there should be something like a
>> separator='.' argument in there somewhere?
>>
>>
>> I don't know the numpy stuff at all so can only surmise but that's
>> what I'd expect.
>>
>  Thank you for your reply. There are, in fact, hidden characters in 
> the input file (cat -A ...):
>
>> ^IRMSD TABLE$
>> ^I__________$
>> $
>> _____________________________________________________________________$
>>      |      |      |           |         |                 |$
>> Rank | Sub- | Run  | Binding   | Cluster | Reference       | Grep$
>>      | Rank |      | Energy    | RMSD    | RMSD            | Pattern$
>> _____|______|______|___________|_________|_________________|___________$
>>    1      1      8       -7.23      0.00     93.07 RANKING$
>>    1      2      9       -6.79      1.39     92.64 RANKING$
>>    2      1     16       -7.18      0.00     93.19 RANKING$
>>    3      1      2       -6.93      0.00     93.38 RANKING$
>>    3      2     17       -6.84      0.23     93.45 RANKING$
>>    4      1     15       -6.55      0.00     91.83 RANKING$
>>    4      2      7       -6.34      0.33     91.77 RANKING$
>>    5      1      5       -6.41      0.00     93.05 RANKING$
>>    6      1      3       -6.36      0.00     92.84 RANKING$
>>    6      2     10       -6.28      0.47     92.92 RANKING$
>>    6      3      6       -6.27      0.43     92.82 RANKING$
>>    6      4     18       -6.25      0.32     92.88 RANKING$
>>    6      5     13       -6.24      0.96     92.75 RANKING$
>>    6      6      1       -6.24      0.87     92.60 RANKING$
>>    6      7     14       -6.21      0.51     92.90 RANKING$
>>    6      8     11       -6.14      0.98     92.78 RANKING$
>>    6      9     20       -6.11      0.71     92.67 RANKING$
>>    6     10     19       -6.01      1.36     93.00 RANKING$
>>    7      1     12       -6.30      0.00     93.28 RANKING$
>>    8      1      4       -5.85      0.00     92.97 RANKING$
>> _______________________________________________________________________$
> but no periods.
>

As much as I wish I could claim that it was a stroke of genius on my 
part, I'm sure that it was just dumb luck, but I have solved the problem.

The correct liner of code is:

data = np.genfromtxt(name_in, usecols=(3), dtype=None, skip_header=8, 
skip_footer=1, encoding=None)

This results in extracting the Binding Energy from the data table, which 
is the desired result.

-- 
Stephen P. Molnar, Ph.D.            Life is a fuzzy set
http://www.Molecular-Modeling.net   Multivariate and stochastic
614.312.7528 (c)
Skype:  smolnar1


From bouncingcats at gmail.com  Sat Sep 28 20:44:20 2019
From: bouncingcats at gmail.com (David)
Date: Sun, 29 Sep 2019 10:44:20 +1000
Subject: [Tutor] NumPy Generates ValueError: Some errors were detected !
 Line #9 (got 42 columns instead of 1)
In-Reply-To: <5D8F8BF1.6040909@sbcglobal.net>
References: <5D8DF6D3.8090108@sbcglobal.net>
 <52ad3f42-ff67-2ee9-41ca-5ee9afa47095@btinternet.com>
 <5D8F8BF1.6040909@sbcglobal.net>
Message-ID: <CAMPXz=pQ-F1cbHh_=4V9WgCCC0hLdeKV-AmD6v_Md9KPOMbs7w@mail.gmail.com>

On Sun, 29 Sep 2019 at 02:36, Stephen P. Molnar <s.molnar at sbcglobal.net> wrote:
> On 09/27/2019 12:22 PM, Alan Gauld via Tutor wrote:
> > On 27/09/2019 12:47, Stephen P. Molnar wrote:

> Thank you for your reply. There are, in fact, hidden characters in the
> input file (cat -A ...):
>
> > ^IRMSD TABLE$
> > ^I__________$
> > $
> > _____________________________________________________________________$
> >      |      |      |           |         |                 |$
> > Rank | Sub- | Run  | Binding   | Cluster | Reference       | Grep$
> >      | Rank |      | Energy    | RMSD    | RMSD            | Pattern$
> > _____|______|______|___________|_________|_________________|___________$
> >    1      1      8       -7.23      0.00     93.07 RANKING$
> >    1      2      9       -6.79      1.39     92.64 RANKING$
> >    2      1     16       -7.18      0.00     93.19 RANKING$
> >    3      1      2       -6.93      0.00     93.38 RANKING$
> >    3      2     17       -6.84      0.23     93.45 RANKING$
> >    4      1     15       -6.55      0.00     91.83 RANKING$
> >    4      2      7       -6.34      0.33     91.77 RANKING$
> >    5      1      5       -6.41      0.00     93.05 RANKING$
> >    6      1      3       -6.36      0.00     92.84 RANKING$
> >    6      2     10       -6.28      0.47     92.92 RANKING$
> >    6      3      6       -6.27      0.43     92.82 RANKING$
> >    6      4     18       -6.25      0.32     92.88 RANKING$
> >    6      5     13       -6.24      0.96     92.75 RANKING$
> >    6      6      1       -6.24      0.87     92.60 RANKING$
> >    6      7     14       -6.21      0.51     92.90 RANKING$
> >    6      8     11       -6.14      0.98     92.78 RANKING$
> >    6      9     20       -6.11      0.71     92.67 RANKING$
> >    6     10     19       -6.01      1.36     93.00 RANKING$
> >    7      1     12       -6.30      0.00     93.28 RANKING$
> >    8      1      4       -5.85      0.00     92.97 RANKING$
> > _______________________________________________________________________$
> but no periods.

Depending on the problem you are having, it can be helpful
to check for non-visible characters that might upset your
parser, so thanks for letting us know that you did this 'cat -A'.

But I wonder why you say "There are, in fact, hidden characters in the
input file".

Are you aware that '^I' is how 'cat -A' represents a tab
character, and that '$' is how it represents a newline character?
I don't think either of these will cause you any trouble in
this case. And I don't see any other hidden characters.

Also when cutting and pasting to show us information,
please also include the command you typed in your cut/
paste. Don't retype it in your explanatory text like you did
above because that vastly degrades your readers
confidence in the quality of the information provided.
If people are trying to help you, it's nice to help them
do so.

From bouncingcats at gmail.com  Sat Sep 28 20:51:15 2019
From: bouncingcats at gmail.com (David)
Date: Sun, 29 Sep 2019 10:51:15 +1000
Subject: [Tutor] NumPy Generates ValueError: Some errors were detected !
 Line #9 (got 42 columns instead of 1)
In-Reply-To: <5D8FB339.4000209@sbcglobal.net>
References: <5D8DF6D3.8090108@sbcglobal.net>
 <52ad3f42-ff67-2ee9-41ca-5ee9afa47095@btinternet.com>
 <5D8F8BF1.6040909@sbcglobal.net> <5D8FB339.4000209@sbcglobal.net>
Message-ID: <CAMPXz=pShbd6Pk01UyN8LQLw8v_DJTW72MF8sJCe8NOHB=L=OQ@mail.gmail.com>

On Sun, 29 Sep 2019 at 05:25, Stephen P. Molnar <s.molnar at sbcglobal.net> wrote:

> As much as I wish I could claim that it was a stroke of genius on my
> part, I'm sure that it was just dumb luck, but I have solved the problem.
>
> The correct liner of code is:
>
> data = np.genfromtxt(name_in, usecols=(3), dtype=None, skip_header=8,
> skip_footer=1, encoding=None)

Thanks for ending the thread with a confirmation of the solution to
your problem.

It is a great way to thank the people who made effort to assist you,
and also helpful to future readers who might be reading this while searching
for help with a similar problem.

From alan.gauld at btinternet.com  Sun Sep 29 04:21:56 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Sun, 29 Sep 2019 09:21:56 +0100
Subject: [Tutor] NumPy Generates ValueError: Some errors were detected !
 Line #9 (got 42 columns instead of 1)
In-Reply-To: <CAMPXz=pQ-F1cbHh_=4V9WgCCC0hLdeKV-AmD6v_Md9KPOMbs7w@mail.gmail.com>
References: <5D8DF6D3.8090108@sbcglobal.net>
 <52ad3f42-ff67-2ee9-41ca-5ee9afa47095@btinternet.com>
 <5D8F8BF1.6040909@sbcglobal.net>
 <CAMPXz=pQ-F1cbHh_=4V9WgCCC0hLdeKV-AmD6v_Md9KPOMbs7w@mail.gmail.com>
Message-ID: <d19f6349-8007-94e1-eb8b-59c51bed2912@btinternet.com>

On 29/09/2019 01:44, David wrote:
> On Sun, 29 Sep 2019 at 02:36, Stephen P. Molnar <s.molnar at sbcglobal.net> wrote:
>> On 09/27/2019 12:22 PM, Alan Gauld via Tutor wrote:
>>
>> Thank you for your reply. There are, in fact, hidden characters in the
>> input file (cat -A ...):
>>
>>> ^IRMSD TABLE$
>>> ^I__________$
>>> $
>>> _____________________________________________________________________$
>>>      |      |      |           |         |                 |$
>>> Rank | Sub- | Run  | Binding   | Cluster | Reference       | Grep$
>>>      | Rank |      | Energy    | RMSD    | RMSD            | Pattern$
>>> _____|______|______|___________|_________|_________________|___________$
>>>    1      1      8       -7.23      0.00     93.07 RANKING$
>>>    1      2      9       -6.79      1.39     92.64 RANKING$
>>>
>>> But I wonder why you say "There are, in fact, hidden characters in the
>>> input file".
>>>
>>> Are you aware that '^I' is how 'cat -A' represents a tab
>>> character, and that '$' is how it represents a newline character?


The hidden characters from my perspective were the spaces betweenthe fields.

In the original post I saw:

|RMSD TABLE __________ 
_____________________________________________________________________ 
||||||Rank|Sub-|Run|Binding|Cluster|Reference|Grep|Rank||Energy|RMSD 
|RMSD 
|Pattern_____|______|______|___________|_________|_________________|___________ 
118-7.230.0093.07RANKING 129-6.791.3992.64RANKING 
2116-7.180.0093.19RANKING 312-6.930.0093.38RANKING 

So it looked like the field separator was the periods.
Which, coincidentally, led to 7 fields exactly as the error 
message stated.

Seeing the spaces gives an entirely different view of the data!


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From s.molnar at sbcglobal.net  Sun Sep 29 14:28:26 2019
From: s.molnar at sbcglobal.net (Stephen P. Molnar)
Date: Sun, 29 Sep 2019 14:28:26 -0400
Subject: [Tutor] Pointers Towards Appropriate Python Methods
Message-ID: <5D90F7CA.5080108@sbcglobal.net>

First, let me state that this is not a homework problem.   I happen to 
be a retired Research Chemist whose rathre meager programming skills are 
in FORTRAN.

I have managed to write, and with help from the list debug, a very short 
Python script to extract a column of data from an ASCII file:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""

Created on Tue Sep 24 07:51:11 2019

"""
import numpy as np

fileName = []

name = input("Enter Molecule ID: ")

name_in = name+'_apo-1acl.RMSD'

data = np.genfromtxt(name_in, usecols=(3), dtype=None, skip_header=8, 
skip_footer=1, encoding=None)


I have uploaded the script and an example of the input file to my 
Dropbox account in order to avoid scrambling of the file format.

https://www.dropbox.com/sh/xwsv17vkh48tsaa/AAAfIe0miWrrk49hqZCkxe-aa?dl=0

My problem is that I have a large number of data files that I wish to 
process for input to several other different Python scripts that I use 
as part of my Computational Chemistry research program.   I've also 
uploaded a bash script that illustrates what I want to do in Python.

At this point what I would like are pointers towards python method for 
processing a large number of data files. I'm not asking anyone to write 
the coed for me.

Thanks in advance.

-- 
Stephen P. Molnar, Ph.D.
www.molecular-modeling.net
614.312.7528 (c)
Skype:  smolnar1


From alan.gauld at btinternet.com  Sun Sep 29 14:49:51 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Sun, 29 Sep 2019 19:49:51 +0100
Subject: [Tutor] Pointers Towards Appropriate Python Methods
In-Reply-To: <5D90F7CA.5080108@sbcglobal.net>
References: <5D90F7CA.5080108@sbcglobal.net>
Message-ID: <ae3f0a5e-dabd-dd83-3771-a2faa512371d@btinternet.com>

On 29/09/2019 19:28, Stephen P. Molnar wrote:
> At this point what I would like are pointers towards python method for 
> processing a large number of data files. I'm not asking anyone to write 
> the coed for me.


While waiting for something more specific you might find the fileinput
module worth reading about, it is designed for processing multiple files.


Alan G

From PyTutor at DancesWithMice.info  Sun Sep 29 15:13:36 2019
From: PyTutor at DancesWithMice.info (David L Neil)
Date: Mon, 30 Sep 2019 08:13:36 +1300
Subject: [Tutor] Pointers Towards Appropriate Python Methods
In-Reply-To: <5D90F7CA.5080108@sbcglobal.net>
References: <5D90F7CA.5080108@sbcglobal.net>
Message-ID: <5b952c30-2ba4-3842-369c-6fde92cee56b@DancesWithMice.info>

On 30/09/19 7:28 AM, Stephen P. Molnar wrote:
> First, let me state that this is not a homework problem.   

You are retired, but not working at home - on 'home work'?


I happen to
> be a retired Research Chemist

Is that a confession?


  whose rathre meager programming skills are
> in FORTRAN.

With such a pedigree, can you do any wrong?


> I have managed to write, and with help from the list debug, a very short 
> Python script to extract a column of data from an ASCII file:
> 
> #!/usr/bin/env python3
> # -*- coding: utf-8 -*-
> """
> 
> Created on Tue Sep 24 07:51:11 2019
> 
> """
> import numpy as np
> 
> fileName = []
> 
> name = input("Enter Molecule ID: ")
> 
> name_in = name+'_apo-1acl.RMSD'
> 
> data = np.genfromtxt(name_in, usecols=(3), dtype=None, skip_header=8, 
> skip_footer=1, encoding=None)
> 
> 
> I have uploaded the script and an example of the input file to my 
> Dropbox account in order to avoid scrambling of the file format.
> 
> https://www.dropbox.com/sh/xwsv17vkh48tsaa/AAAfIe0miWrrk49hqZCkxe-aa?dl=0
> 
> My problem is that I have a large number of data files that I wish to 
> process for input to several other different Python scripts that I use 
> as part of my Computational Chemistry research program.?? I've also 
> uploaded a bash script that illustrates what I want to do in Python.
> 
> At this point what I would like are pointers towards python method for 
> processing a large number of data files. I'm not asking anyone to write 
> the coed for me.
> 
> Thanks in advance.


Have I understood you correctly? You have (sensibly) constructed a 
processor which works on a single file, and now want to expand its scope 
to process a series of similarly-formatted files?
(alternately: that the various files are in different formats?)

One of the (many) beauties of the Python eco-system is that it has 
"batteries included" (or pip-include-able) enabling an extremely wide 
variety of tasks. In this case, there is no need to separate 'Python 
work' from 'File system/BASH work' - it can ALL be done by Python!

Rather than devolving the file system work to BASH, perhaps review 
"pathlib" from the "PSL" (Python Standard Library - 
https://docs.python.org/3/library/pathlib.html).

For example, if the files to be processed are collected into a single 
directory (or 'directory tree'), pathlib will accept the (top-level) 
directory name and then "iterdir" (iterate through all the files in that 
directory/tree). Code this into a loop (or a Python "generator") and the 
already-coded process could be serially applied to each file. This saves 
(a) BASH code, and (b) the "command-line interface" between BASH and 
Python.


At the risk of causing cognitive-overload, may I also suggest reading 
(some on-line articles/book-chapters) about "logging". If you plan to 
follow the FORTRAN tradition of long-running batch programs, then this 
is an ideal way to record progress, results, and errors. (IMHO logging 
is sadly under-rated, but then much code these days is neither "batch" 
nor server-oriented)


Apologies if I'm off on the wrong-track - having solved a long-time 
issue I've had with pathlib incorrectly processing European-language 
fileNMs, yesterday; this morning I'm re-factoring a bunch of programs 
which 'walk a directory tree', to use a common/utility core 'walker' - 
and "to a man with a hammer..."
-- 
Regards =dn

From s.molnar at sbcglobal.net  Sun Sep 29 17:36:56 2019
From: s.molnar at sbcglobal.net (Stephen P. Molnar)
Date: Sun, 29 Sep 2019 17:36:56 -0400
Subject: [Tutor] Pointers Towards Appropriate Python Methods
In-Reply-To: <ae3f0a5e-dabd-dd83-3771-a2faa512371d@btinternet.com>
References: <5D90F7CA.5080108@sbcglobal.net>
 <ae3f0a5e-dabd-dd83-3771-a2faa512371d@btinternet.com>
Message-ID: <5D9123F8.3010507@sbcglobal.net>



On 09/29/2019 02:49 PM, Alan Gauld via Tutor wrote:
> On 29/09/2019 19:28, Stephen P. Molnar wrote:
>> At this point what I would like are pointers towards python method for
>> processing a large number of data files. I'm not asking anyone to write
>> the coed for me.
>
> While waiting for something more specific you might find the fileinput
> module worth reading about, it is designed for processing multiple files.
>
>
> Alan G
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
Many thanks for your reply;  I will do what you suggest.

-- 
Stephen P. Molnar, Ph.D.
614.312.7528 (c)
Skype:  smolnar1


From mats at wichmann.us  Sun Sep 29 18:12:14 2019
From: mats at wichmann.us (Mats Wichmann)
Date: Sun, 29 Sep 2019 16:12:14 -0600
Subject: [Tutor] Pointers Towards Appropriate Python Methods
In-Reply-To: <5D90F7CA.5080108@sbcglobal.net>
References: <5D90F7CA.5080108@sbcglobal.net>
Message-ID: <21cb4005-b63f-3d3d-d7ab-08bee7fd0965@wichmann.us>

On 9/29/19 12:28 PM, Stephen P. Molnar wrote:

> At this point what I would like are pointers towards python method for 
> processing a large number of data files. I'm not asking anyone to write 
> the coed for me.

not quite ignoring the slightly amusing typo :)

if you have to deal with lots of data files, things will probably get a 
bit slow.  many of the things going on in dealing with text files in 
particular - and your recent samples have been text files with fields 
separated by some particular separator character (commonly called csv 
files after the case where the comma is the separator) - aren't that 
speedy.  there's the involvement of calling out to the operating system 
which is going to do the work of reading data off of permanent storage 
and getting it back to you, and there's the issue of type conversion, 
and then there's the issue of stepping through line by line which is 
happening even if it is hidden from you by the particular methods 
involved.  Just the way it is.  One performance idea is to make sure you 
deal with a file in its entirety and then get rid of it (close, or 
whatever happens to suit the circumstances - I don't mean delete the 
file) or your memory usage will become a problem as well.

there's a fairly popular library called Pandas that you could take a 
look at to see if it suits your purposes in any way, might keep you from 
designing the entire application.

https://pandas.pydata.org/



From bouncingcats at gmail.com  Sun Sep 29 22:56:54 2019
From: bouncingcats at gmail.com (David)
Date: Mon, 30 Sep 2019 12:56:54 +1000
Subject: [Tutor] Pointers Towards Appropriate Python Methods
In-Reply-To: <5D90F7CA.5080108@sbcglobal.net>
References: <5D90F7CA.5080108@sbcglobal.net>
Message-ID: <CAMPXz=oJiHR=5r1PcyQ-ycDg52GCd2JLMefQ7EPp88sVegbkUw@mail.gmail.com>

On Mon, 30 Sep 2019 at 04:28, Stephen P. Molnar <s.molnar at sbcglobal.net> wrote:

> First, let me state that this is not a homework problem.   I happen to
> be a retired Research Chemist whose rathre meager programming skills are
> in FORTRAN.
>
> I have managed to write, and with help from the list debug, a very short
> Python script to extract a column of data from an ASCII file:

[...]

> I have uploaded the script and an example of the input file to my
> Dropbox account in order to avoid scrambling of the file format.

[...]

> At this point what I would like are pointers towards python method for
> processing a large number of data files. I'm not asking anyone to write
> the coed for me.

Hi Stephen

Maybe it's just me but I frequently detect a "fish out of water" tone
in programming questions that I've seen you ask. And frequently
underneath the surface complexity that you present, the solution is
simple. And I imagine that the chemistry that you work on is vastly more
complex than any of the programming questions you ask, so I feel that
you're probably well smart enough to handle these basic programming
questions yourself. And I'm writing this message in an attempt to help
and encourage you with that. Please excuse me if I am misreading your
situation, I'm only trying with a possible approach that might help you.

People who have already replied here have responded at a higher level
of complexity than I do. That might be appropriate, I can't tell, but it
in case it helps you I am going to respond as if this is a beginner-level
question (no offense intended) from someone who has barely has any
ability to write anything at all in Python. Please correct me if I am wrong.

For anyone else reading, here's Stephen's "bash script that
illustrates what I want to do in Python.":

for d in $(cat ligand.list) ; do
  cd "${d}_apo-1acl"
  echo "${d}_apo-1acl"
  echo "${d}_apo-1acl.dpf"
  /home/comp/Apps/Autodock/autodock4 -p "${d}_apo-1acl.dpf" -l
"${d}_apo-1acl.dlg"
  cd ..
done

So it appears that you just want to appy some data
processing function or script to various datasets in files whose names
you know. This is an elementary question in any programming language.
No computer would be useful if we couldn't do this.

As an aside, you mention that the data processing functions are in
individual scripts. But given the simplicity and awkward nature of the
above bash script, I wonder how complicated those scripts are, and if
it is necessary for them to be separate scripts. What is the line
count of each of those python scripts you mentioned?

I suggest that if you spent a day or two learning some basic python then
you might realise how simple this could all be for you. We are here to
help if you want to do that. You could read a tutorial, write some toy
scripts, and then you might realise how simple this stuff is, at least
at the level of the problems you wish to solve.

Basically I am suggesting that I think it would be easy for you to reach a
level of competency in Python such that much of this would become
enjoyable and trivial for you, instead of difficult.

If the question boils down to 2 things:
  - There is a list of filenames (or maybe just one filename).
  - There is processing that we want to apply to each file content.
Then pseudo code for this can look like:

for a_file_name in list_of_file_names:
    file_we_are_reading = open_the_file(a_file_name)
    data = read_stuff_from(file_we_are_reading)
    close_the_file(file_we_are_reading)
    do_something_with(data)

And the nice thing about the Python language is that what I
have written there can be valid Python that will run.
Python syntax can be much closer to human readable text
than the Fortran you mentioned you had experience with!

Have you ever looked at the official Python tutorial?
  https://docs.python.org/3/tutorial/index.html

It covers the things you need for this task:
- use of lists:
  https://docs.python.org/3/tutorial/introduction.html#lists
  https://docs.python.org/3/tutorial/datastructures.html#more-on-lists
- using files:
  https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files
- doing something to data
  https://docs.python.org/3/tutorial/controlflow.html#defining-functions

In addition, there's a vast amount of resources for learning Python,
suitable for both beginners and experienced programmers:
  https://wiki.python.org/moin/BeginnersGuide

From s.molnar at sbcglobal.net  Mon Sep 30 07:00:49 2019
From: s.molnar at sbcglobal.net (Stephen P. Molnar)
Date: Mon, 30 Sep 2019 07:00:49 -0400
Subject: [Tutor] Pointers Towards Appropriate Python Methods
In-Reply-To: <CAMPXz=oJiHR=5r1PcyQ-ycDg52GCd2JLMefQ7EPp88sVegbkUw@mail.gmail.com>
References: <5D90F7CA.5080108@sbcglobal.net>
 <CAMPXz=oJiHR=5r1PcyQ-ycDg52GCd2JLMefQ7EPp88sVegbkUw@mail.gmail.com>
Message-ID: <5D91E061.30500@sbcglobal.net>

Cutting out all the superfluous information:
Have you ever looked at the official Python tutorial? 
https://docs.python.org/3/tutorial/index.html It covers the things you 
need for this task: - use of lists: 
https://docs.python.org/3/tutorial/introduction.html#lists 
https://docs.python.org/3/tutorial/datastructures.html#more-on-lists - 
using files: 
https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files 
- doing something to data 
https://docs.python.org/3/tutorial/controlflow.html#defining-functions 
In addition, there's a vast amount of resources for learning Python, 
suitable for both beginners and experienced programmers: 
https://wiki.python.org/moin/BeginnersGuide 
_______________________________________________ Tutor maillist - 
Tutor at python.org To unsubscribe or change subscription options: 
https://mail.python.org/mailman/listinfo/tutor
Thanks for the references.

-- 
Stephen P. Molnar, Ph.D.
www.molecuar-modeling.net
614.312.7528 (c)
Skype:  smolnar1


From s.molnar at sbcglobal.net  Mon Sep 30 07:07:23 2019
From: s.molnar at sbcglobal.net (Stephen P. Molnar)
Date: Mon, 30 Sep 2019 07:07:23 -0400
Subject: [Tutor] Pointers Towards Appropriate Python Methods
In-Reply-To: <21cb4005-b63f-3d3d-d7ab-08bee7fd0965@wichmann.us>
References: <5D90F7CA.5080108@sbcglobal.net>
 <21cb4005-b63f-3d3d-d7ab-08bee7fd0965@wichmann.us>
Message-ID: <5D91E1EB.1000109@sbcglobal.net>



On 09/29/2019 06:12 PM, Mats Wichmann wrote:
> On 9/29/19 12:28 PM, Stephen P. Molnar wrote:
>
>> At this point what I would like are pointers towards python method 
>> for processing a large number of data files. I'm not asking anyone to 
>> write the coed for me.
>
> not quite ignoring the slightly amusing typo :)
true
>
> if you have to deal with lots of data files, things will probably get 
> a bit slow.  many of the things going on in dealing with text files in 
> particular - and your recent samples have been text files with fields 
> separated by some particular separator character (commonly called csv 
> files after the case where the comma is the separator) - aren't that 
> speedy.  there's the involvement of calling out to the operating 
> system which is going to do the work of reading data off of permanent 
> storage and getting it back to you, and there's the issue of type 
> conversion, and then there's the issue of stepping through line by 
> line which is happening even if it is hidden from you by the 
> particular methods involved.  Just the way it is.  One performance 
> idea is to make sure you deal with a file in its entirety and then get 
> rid of it (close, or whatever happens to suit the circumstances - I 
> don't mean delete the file) or your memory usage will become a problem 
> as well.
>
> there's a fairly popular library called Pandas that you could take a 
> look at to see if it suits your purposes in any way, might keep you 
> from designing the entire application.
>
> https://pandas.pydata.org/
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
Thanks for your reply.

I have no particular problem with speed. When I say 'large' data set 
probably not more than a couple of hundred files at a time.

-- 
Stephen P. Molnar, Ph.D.
www.molecular-modeling.net
614.312.7528 (c)
Skype:  smolnar1


From s.molnar at sbcglobal.net  Mon Sep 30 07:28:34 2019
From: s.molnar at sbcglobal.net (Stephen P. Molnar)
Date: Mon, 30 Sep 2019 07:28:34 -0400
Subject: [Tutor] Pointers Towards Appropriate Python Methods
In-Reply-To: <5b952c30-2ba4-3842-369c-6fde92cee56b@DancesWithMice.info>
References: <5D90F7CA.5080108@sbcglobal.net>
 <5b952c30-2ba4-3842-369c-6fde92cee56b@DancesWithMice.info>
Message-ID: <5D91E6E2.5000909@sbcglobal.net>

Please see my interspersed comments.

On 09/29/2019 03:13 PM, David L Neil via Tutor wrote:
> On 30/09/19 7:28 AM, Stephen P. Molnar wrote:
>> First, let me state that this is not a homework problem. 
>
> You are retired, but not working at home - on 'home work'?
homework within the educational definition. My study with three 
networked computers is my laoratory.
>
>
> I happen to
>> be a retired Research Chemist
>
> Is that a confession?
merely a statement of fact
>
>
>  whose rathre meager programming skills are
>> in FORTRAN.
>
> With such a pedigree, can you do any wrong?
Actually, quite a bit!!!!!
>
>
>> I have managed to write, and with help from the list debug, a very 
>> short Python script to extract a column of data from an ASCII file:
>>
>> #!/usr/bin/env python3
>> # -*- coding: utf-8 -*-
>> """
>>
>> Created on Tue Sep 24 07:51:11 2019
>>
>> """
>> import numpy as np
>>
>> fileName = []
>>
>> name = input("Enter Molecule ID: ")
>>
>> name_in = name+'_apo-1acl.RMSD'
>>
>> data = np.genfromtxt(name_in, usecols=(3), dtype=None, skip_header=8, 
>> skip_footer=1, encoding=None)
>>
>>
>> I have uploaded the script and an example of the input file to my 
>> Dropbox account in order to avoid scrambling of the file format.
>>
>> https://www.dropbox.com/sh/xwsv17vkh48tsaa/AAAfIe0miWrrk49hqZCkxe-aa?dl=0 
>>
>>
>> My problem is that I have a large number of data files that I wish to 
>> process for input to several other different Python scripts that I 
>> use as part of my Computational Chemistry research program.   I've 
>> also uploaded a bash script that illustrates what I want to do in 
>> Python.
>>
>> At this point what I would like are pointers towards python method 
>> for processing a large number of data files. I'm not asking anyone to 
>> write the coed for me.
>>
>> Thanks in advance.
>
>
> Have I understood you correctly? You have (sensibly) constructed a 
> processor which works on a single file, and now want to expand its 
> scope to process a series of similarly-formatted files?
The files I wish to process are the same and are extracted from 
molecular modeling software and are in the same format.
> (alternately: that the various files are in different formats?)
>
> One of the (many) beauties of the Python eco-system is that it has 
> "batteries included" (or pip-include-able) enabling an extremely wide 
> variety of tasks. In this case, there is no need to separate 'Python 
> work' from 'File system/BASH work' - it can ALL be done by Python!
I included the bash script in an attempt to illustrate what I would like 
to do with python.
>
> Rather than devolving the file system work to BASH, perhaps review 
> "pathlib" from the "PSL" (Python Standard Library - 
> https://docs.python.org/3/library/pathlib.html).
For example, if the files to be processed are collected into a single 
directory (or 'directory tree'), pathlib will accept the (top-level) 
directory name and then "iterdir" (iterate through all the files in that 
directory/tree). Code this into a loop (or a Python "generator") and the 
already-coded process could be serially applied to each file. This saves 
(a) BASH code, and (b) the "command-line interface" between BASH and 
Python.

This is, in fact the case, I have a series of scripts to use the 
software that produces the files that I wish to process further. 
Evehtually I will, most likely chain the together in some fashion.

>
> At the risk of causing cognitive-overload, may I also suggest reading 
> (some on-line articles/book-chapters) about "logging". If you plan to 
> follow the FORTRAN tradition of long-running batch programs, then this 
> is an ideal way to record progress, results, and errors. (IMHO logging 
> is sadly under-rated, but then much code these days is neither "batch" 
> nor server-oriented)
I have found that running a log script when working is very valuable.
>
>
> Apologies if I'm off on the wrong-track - having solved a long-time 
> issue I've had with pathlib incorrectly processing European-language 
> fileNMs, yesterday; this morning I'm re-factoring a bunch of programs 
> which 'walk a directory tree', to use a common/utility core 'walker' - 
> and "to a man with a hammer..."
I am most appreciative of your helpful comments.

Many thanks,

-- 
Stephen P. Molnar, Ph.D.
www.molecular-modeling.net
614.312.7528 (c)
Skype:  smolnar1


From Raj_patel56 at hotmail.com  Mon Sep 30 19:12:24 2019
From: Raj_patel56 at hotmail.com (Raj Patel)
Date: Mon, 30 Sep 2019 23:12:24 +0000
Subject: [Tutor] Python Calculator Help needed ASAP!!
Message-ID: <YT1PR01MB311647C7D36D033A2EDEC3EF86820@YT1PR01MB3116.CANPRD01.PROD.OUTLOOK.COM>

Hi so Im a university student new to python, and I?ve been given a mini assignment to create a calculate on python, on of the function it must have is that once the user has already calculated something and wants to recalculate something with that result the second time the input calls the result becomes one of the two nums

Ex. Choose an operator: +
Enter the first number: 56
Enter the second number: 8
Result: 64

Choose an operator:+
Enter the first number: (since I?d be leaving this blank the result from the last equation would become the number here)
Enter the second number: 10
Result: 74



From adameyring at gmail.com  Mon Sep 30 20:34:00 2019
From: adameyring at gmail.com (Adam Eyring)
Date: Mon, 30 Sep 2019 20:34:00 -0400
Subject: [Tutor] Python Calculator Help needed ASAP!!
In-Reply-To: <YT1PR01MB311647C7D36D033A2EDEC3EF86820@YT1PR01MB3116.CANPRD01.PROD.OUTLOOK.COM>
References: <YT1PR01MB311647C7D36D033A2EDEC3EF86820@YT1PR01MB3116.CANPRD01.PROD.OUTLOOK.COM>
Message-ID: <CAPStRW_iym_rJb0pSa__u103vL3UZQRTV13=hrFXy=09djPX2w@mail.gmail.com>

A basic way to do this is to store the result of the first calculation in a
variable then use that variable when your reply to the first number of the
second equation is empty. An if statement will check for empty inputs and,
if true, use the result from the first equation.

On Mon, Sep 30, 2019, 7:55 PM Raj Patel <Raj_patel56 at hotmail.com> wrote:

> Hi so Im a university student new to python, and I?ve been given a mini
> assignment to create a calculate on python, on of the function it must have
> is that once the user has already calculated something and wants to
> recalculate something with that result the second time the input calls the
> result becomes one of the two nums
>
> Ex. Choose an operator: +
> Enter the first number: 56
> Enter the second number: 8
> Result: 64
>
> Choose an operator:+
> Enter the first number: (since I?d be leaving this blank the result from
> the last equation would become the number here)
> Enter the second number: 10
> Result: 74
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>

From osaosemwe at yahoo.com  Mon Sep 30 23:18:31 2019
From: osaosemwe at yahoo.com (ose micah)
Date: Tue, 1 Oct 2019 03:18:31 +0000 (UTC)
Subject: [Tutor] print issue
References: <1162792864.1860056.1569899911609.ref@mail.yahoo.com>
Message-ID: <1162792864.1860056.1569899911609@mail.yahoo.com>

Hello I am trying to make a dynamic print format?
Assuming "output.txt" has contents as? ? ? 10.10.10.10/24? ? ? 10.10.20.12/24? ? ? 172.50.10.34/24? ? ? 192.168.230.10/24and "samplefile.txt"? is an empty file
I am trying to get an output such as in file sample.txt? ? ? ? ? ? ? ?- [100, 'sing', 'play',?10.10.10.10/24,??null, null, 500, 500]? ? ? ? ? ? ? ?- [200, 'sing', 'play',?10.10.10.10/24, ?null, null, 800, 800]? ? ? ? ? ? ? ?- [300, 'sing', 'play',?10.10.20.10/24,??null, null, 500, 500]? ? ? ? ? ? ? ?- [400, 'sing', 'play',?10.10.20.10/24,??null, null, 800, 800]? ? ? ? ? ? ? ?- [500, 'sing', 'play',?172.50.10.34/24,??null, null, 500, 500]? ? ? ? ? ? ? ?- [600, 'sing', 'play',?172.50.10.34/24,??null, null, 800, 800]? ? ? ? ? ? ? ?- [700, 'sing', 'play',?192.168.230.10/24,??null, null, 500, 500]? ? ? ? ? ? ? ?- [800, 'sing', 'play',?192.168.230.10/24,??null, null, 800, 800]? here is my the main block of code.
f = open("output.txt").read().count('\n')
sys.stdout=open('samplefile.txt','a')
with open('output.txt', 'r') as reader:

? ? for line in reader.readlines():

? ? ? ? #from __future__ import print_function

? ? ? ? with open ('samplefile.txt', 'a') as p:

? ? ? ? ? ??# allow ingress port 80

? ? ? ? ? ? print(" ? ? ? ? ? ? ? ? ? ? ? ? ?- [100, 'tcp', 'allow', ",line,?" , null, null, 500, 500]")

? ? ? ? ? ? print(" ? ? ? ? ? ? ? ? ? ? ? ? ?- [200, 'tcp', 'allow', ",line,"? , null, null, 800, 800]")





sys.stdout.close()

But here is my current output in samplefile.txt:?
??- [100, 'sing', 'play',?10.10.10.10/24,??null, null, 500, 500]? ? ? ? ? ? ? ?- [200, 'sing', 'play',?10.10.10.10/24,??null, null, 800, 800]? ? ? ? ? ? ? ?- [300, 'sing', 'play',?10.10.20.10/24,??null, null, 500, 500]? ? ? ? ? ? ? ?- [400, 'sing', 'play',?10.10.20.10/24,??null, null, 800, 800]? ? ? ? ? ? ? ?- [500, 'sing', 'play',?172.50.10.34/24,??null, null, 500, 500]? ? ? ? ? ? ? ?- [600, 'sing', 'play',?172.50.10.34/24,??null, null, 800, 800]? ? ? ? ? ? ? ?- [700, 'sing', 'play',?192.168.230.10/24,??null, null, 500, 500]? ? ? ? ? ? ? ?- [800, 'sing', 'play',?192.168.230.10/24,??null, null, 800, 800]



(" ? ? ? ? ? - [100, 'tcp', 'allow', ", '10.10.10.10/24\n', ', null, null, 500, 500]')
 
(" ? ? ? ? ? - [200, 'tcp', 'allow', ", '10.10.10.10/24\n', ', null, null, 800, 800]')
(" ? ? ? ? ? - [100, 'tcp', 'allow', ", ' 10.10.20.10/24\n', ' , null, null, 500, 500]')(" ? ? ? ? ? - [200, 'tcp', 'allow', ", ' 10.10.20.10/24\n', ', null, null, 800, 800]')(" ? ? ? ? ? - [100, 'tcp', 'allow', ", ' 172.50.10.34/24\n', ' , null, null, 500, 500]')(" ? ? ? ? ? - [200, 'tcp', 'allow', ", ' 172.50.10.34/24\n', ', null, null, 800, 800]')(" ? ? ? ? ? - [100, 'tcp', 'allow', ", ' 192.168.230.10/24\n', ' , null, null, 500, 500]')(" ? ? ? ? ? - [200, 'tcp', 'allow', ", ' 192.168.230.10/24\n', ', null, null, 800, 800]')

when I adjust change the print statement to:
print("?? ? ? ? ? ? ? ? ? ? ? ? ?- [100, 'tcp', 'allow', " +?line +?" , null, null, 500, 500]")
print("?? ? ? ? ? ? ? ? ? ? ? ? - [200, 'tcp', 'allow', " +?line??+" , null, null, 800, 800]")


the print get scattered. something like this:
?? ? ? ? ??- [100, 'tcp', 'allow', '10.10.10.10/24\n',?', null, null, 500, 500]
? ? ? ? ??- [200, 'tcp', 'allow', '10.10.10.10/24\n',?', null, null, 800, 800]


Please, how can I get my desired result.
Can anyone be of help to me.?
Thanks

Mike.


From alan.gauld at btinternet.com  Mon Sep 30 20:30:37 2019
From: alan.gauld at btinternet.com (Alan Gauld)
Date: Tue, 1 Oct 2019 01:30:37 +0100
Subject: [Tutor] Python Calculator Help needed ASAP!!
In-Reply-To: <YT1PR01MB311647C7D36D033A2EDEC3EF86820@YT1PR01MB3116.CANPRD01.PROD.OUTLOOK.COM>
References: <YT1PR01MB311647C7D36D033A2EDEC3EF86820@YT1PR01MB3116.CANPRD01.PROD.OUTLOOK.COM>
Message-ID: <30dc6c75-c7b8-6404-c8d7-150f2879809f@btinternet.com>

On 01/10/2019 00:12, Raj Patel wrote:
> Hi so Im a university student new to python, and I?ve been given a mini assignment to create a calculate on python, on of the function it must have is that once the user has already calculated something and wants to recalculate something with that result the second time the input calls the result becomes one of the two nums
>
> Ex. Choose an operator: +
> Enter the first number: 56
> Enter the second number: 8
> Result: 64
>
> Choose an operator:+
> Enter the first number: (since I?d be leaving this blank the result from the last equation would become the number here)
> Enter the second number: 10
> Result: 74

Thanks for the clear explantion of your assignment.
Now what do you want us to help you with?

What have you done so far?

Do you know how to prompt for and read a string from the user?

Do you know how o convert an input string to a number?

Do you know how to add two numbers and store the result?

Do you know how to detect an empty string?

If you know all of the above you know how to solve the problem.

If not tell us what part you don't know.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos