Converting a list of lists to a single list

2013-07-23 Thread steve
I think that itertools may be able to do what I want but I have not been able 
to figure out how.

I want to convert an arbitrary number of lists with an arbitrary number of 
elements in each list into a single list as follows.

Say I have three lists:

[[A0,A1,A2], [B0,B1,B2] [C0,C1,C2]]

I would like to convert those to a single list that looks like this:

[A0,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2,A1,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2,A2,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2]

An easier way to visualize the pattern I want is as a tree.

A0
B0
C0
C1
C2
B1
C0
C1
C2
B2
C0
C1
C2
A1
B0
C0
C1
C2
B1
C0
C1
C2
B2
C0
C1
C2
A2
B0
C0
C1
C2
B1
C0
C1
C2
B2
C0
C1
C2
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Converting a list of lists to a single list

2013-07-24 Thread steve
Wow, thanks everyone. Very helpful indeed!

On Tuesday, July 23, 2013 2:52:21 PM UTC-7, st...@divillo.com wrote:
> I think that itertools may be able to do what I want but I have not been able 
> to figure out how.
> 
> 
> 
> I want to convert an arbitrary number of lists with an arbitrary number of 
> elements in each list into a single list as follows.
> 
> 
> 
> Say I have three lists:
> 
> 
> 
> [[A0,A1,A2], [B0,B1,B2] [C0,C1,C2]]
> 
> 
> 
> I would like to convert those to a single list that looks like this:
> 
> 
> 
> [A0,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2,A1,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2,A2,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2]
> 
> 
> 
> An easier way to visualize the pattern I want is as a tree.
> 
> 
> 
> A0
> 
>   B0
> 
>   C0
> 
>   C1
> 
>   C2
> 
>   B1
> 
>   C0
> 
>   C1
> 
>   C2
> 
>   B2
> 
>   C0
> 
>   C1
> 
>   C2
> 
> A1
> 
>   B0
> 
>   C0
> 
>   C1
> 
>   C2
> 
>   B1
> 
>   C0
> 
>   C1
> 
>   C2
> 
>   B2
> 
>   C0
> 
>   C1
> 
>   C2
> 
> A2
> 
>   B0
> 
>   C0
> 
>   C1
> 
>   C2
> 
>   B1
> 
>   C0
> 
>   C1
> 
>   C2
> 
>   B2
> 
>   C0
> 
>   C1
> 
>   C2

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.system()

2012-04-19 Thread Steve
"Yigit Turgut"  wrote in message 
news:b9a8bb28-3003-4a36-86fb-339ef697b...@i2g2000vbd.googlegroups.com...



When I use os.system() function, script waits for termination of the

windows that is opened by os.system() to continue thus throwing errors
and etc. How can i tell Python to let it go and keep on with the next
execution after os.system() ?

Can you make use of subprocess.Popen() ? 


--
http://mail.python.org/mailman/listinfo/python-list


Why does this leak memory?

2012-06-07 Thread Steve

When I run this program:

import configparser, sys, gc
def test():
   config=configparser.ConfigParser()
   #del(config)
   #gc.collect()
test()
sys.stderr.write(sys.version)
gc.set_debug(gc.DEBUG_LEAK|gc.DEBUG_STATS)

It reports:

3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)]gc: 
collecting generation 2...

gc: objects in each generation: 453 258 4553
gc: collectable 
gc: collectable 
gc: collectable 
gc: collectable <_Link 02713300>
gc: collectable 
gc: collectable 
gc: collectable 
gc: collectable <_Link 02713350>
gc: collectable 
gc: collectable 
gc: collectable 
gc: collectable <_Link 02713378>
gc: collectable 
gc: collectable 
gc: collectable 
gc: collectable 
gc: collectable <_Link 02713328>
gc: collectable 
gc: collectable 
gc: done, 19 unreachable, 0 uncollectable, 0.s elapsed.

The leaks can be removed by uncommenting both lines shown.

This strikes me as very odd behaviour.  Can anyone explain it, or is it a 
bug?


Thanks,

S.




--
http://mail.python.org/mailman/listinfo/python-list


Re: Why does this leak memory?

2012-06-08 Thread Steve

"John Gordon"  wrote in message news:jqr3v5$src$1...@reader1.panix.com...

I'm unfamiliar with gc output, but just glancing over it I don't see
anything that looks like a leak.  It reported that there were 19 objects
which are unreachable and therefore are candidates for being collected.

What makes you think there is a leak?


Well, I guess I was confused by the terminology. I thought there were leaked 
objects _after_ a garbage collection had been run (as it said "collecting 
generation 2"). Also, "unreachable" actually appears to mean "unreferenced". 
You live n learn...


Cheers.


--
http://mail.python.org/mailman/listinfo/python-list


Tcl wasn't installed properly

2011-03-10 Thread Steve
I'm a frequent user of matplotlib on my Windows XP machine.  I
recently attempted to install a program that modified my Tcl
installation, and I now get an error message when I attempt to plot
anything in matplotlib.  Here is the error message:
---
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\lib-tk\Tkinter.py", line 3758, in _test
root = Tk()
  File "C:\Python25\lib\lib-tk\Tkinter.py", line 1647, in __init__
self.tk = _tkinter.create(screenName, baseName, className,
interactive, want
objects, useTk, sync, use)
_tkinter.TclError: Can't find a usable init.tcl in the following
directories:
{C:\Program Files\Tcl\lib\tcl8.3} {C:\Program Files\Tcl\lib
\tcl8.3} {C:/Prog
ram Files/Tcl/lib/tcl8.4} C:/Python25/lib/tcl8.4 C:/lib/tcl8.4 C:/
library



This probably means that Tcl wasn't installed properly.
---
I attempted a complete reinstall of python (hoping it would reinstall
Tcl with correct file paths), but I get the same error.  Any
suggestions would be appreciated.
Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tcl wasn't installed properly

2011-03-10 Thread Steve
On Mar 10, 11:00 am, MRAB  wrote:
> On 10/03/2011 15:39, Steve wrote:
>
>
>
>
>
>
>
>
>
> > I'm a frequent user of matplotlib on my Windows XP machine.  I
> > recently attempted to install a program that modified my Tcl
> > installation, and I now get an error message when I attempt to plot
> > anything in matplotlib.  Here is the error message:
> > ---
> > Traceback (most recent call last):
> >    File "", line 1, in
> >    File "C:\Python25\lib\lib-tk\Tkinter.py", line 3758, in _test
> >      root = Tk()
> >    File "C:\Python25\lib\lib-tk\Tkinter.py", line 1647, in __init__
> >      self.tk = _tkinter.create(screenName, baseName, className,
> > interactive, want
> > objects, useTk, sync, use)
> > _tkinter.TclError: Can't find a usable init.tcl in the following
> > directories:
> >      {C:\Program Files\Tcl\lib\tcl8.3} {C:\Program Files\Tcl\lib
> > \tcl8.3} {C:/Prog
> > ram Files/Tcl/lib/tcl8.4} C:/Python25/lib/tcl8.4 C:/lib/tcl8.4 C:/
> > library
>
> > This probably means that Tcl wasn't installed properly.
> > ---
> > I attempted a complete reinstall of python (hoping it would reinstall
> > Tcl with correct file paths), but I get the same error.  Any
> > suggestions would be appreciated.
> > Thanks!
>
> In my installation Tcl is in "C:\Python25\tcl", if that helps.

That is where my installation is located too.  Why is it insisting on
looking in "C:\Python25\lib\tcl8.4"?  Can I change where it is looking?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tcl wasn't installed properly

2011-03-10 Thread Steve
On Mar 10, 11:30 am, Steve  wrote:
> On Mar 10, 11:00 am, MRAB  wrote:
>
>
>
>
>
>
>
>
>
> > On 10/03/2011 15:39, Steve wrote:
>
> > > I'm a frequent user of matplotlib on my Windows XP machine.  I
> > > recently attempted to install a program that modified my Tcl
> > > installation, and I now get an error message when I attempt to plot
> > > anything in matplotlib.  Here is the error message:
> > > ---
> > > Traceback (most recent call last):
> > >    File "", line 1, in
> > >    File "C:\Python25\lib\lib-tk\Tkinter.py", line 3758, in _test
> > >      root = Tk()
> > >    File "C:\Python25\lib\lib-tk\Tkinter.py", line 1647, in __init__
> > >      self.tk = _tkinter.create(screenName, baseName, className,
> > > interactive, want
> > > objects, useTk, sync, use)
> > > _tkinter.TclError: Can't find a usable init.tcl in the following
> > > directories:
> > >      {C:\Program Files\Tcl\lib\tcl8.3} {C:\Program Files\Tcl\lib
> > > \tcl8.3} {C:/Prog
> > > ram Files/Tcl/lib/tcl8.4} C:/Python25/lib/tcl8.4 C:/lib/tcl8.4 C:/
> > > library
>
> > > This probably means that Tcl wasn't installed properly.
> > > ---
> > > I attempted a complete reinstall of python (hoping it would reinstall
> > > Tcl with correct file paths), but I get the same error.  Any
> > > suggestions would be appreciated.
> > > Thanks!
>
> > In my installation Tcl is in "C:\Python25\tcl", if that helps.
>
> That is where my installation is located too.  Why is it insisting on
> looking in "C:\Python25\lib\tcl8.4"?  Can I change where it is looking?

I figured out the solution.  The program I installed must have changed
my windows path names.  I changed TCL_LIBRARY and TK_LIBRARY to the
location of my tcl installation, and it works fine now.
-- 
http://mail.python.org/mailman/listinfo/python-list


Trying to read from a text file to generate a graph

2021-07-28 Thread Steve
I am going though a struggle with this and just don't see where it fails.
I am using the Dual Bar Graph.py program from 
https://matplotlib.org/stable/gallery/index.html website.
The file from the web site works so that shows that all my installations are 
complete.

My program, LibreGraphics 05.py program runs but the graph is all smutched up.  
I am pulling data from the EXCEL-FILE.txt into the program, selecting three 
values for each line and creating three variables formatted as is shown in the 
original demo file.

When you run the program, choose 112 when prompted. You will see the values of 
the variables I want to pass to the graph section of the code.  If the values 
are hardcoded, the graphs look good.  When the variables generated by my 
section of the code, it does not. 

I am not sure what more to explain.
Please help me
Steve

I am attaching a zip file.  I hope it gets through.





 George Melly remarked to Mike Jagger on how lined his face was for one so 
young. Jagger replied “They’re laughter lines George” to which Melly countered: 
“Mick, nothing’s that f**king funny!”.

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Trying to read from a text file to generate a graph

2021-07-28 Thread Steve
I forgot about the no-file rule...

On 28Jul2021 02:55, Steve  wrote:
>I am going though a struggle with this and just don't see where it fails.
>I am using the Dual Bar Graph.py program from
https://matplotlib.org/stable/gallery/index.html website.
>The file from the web site works so that shows that all my installations
are complete.
>
>My program, LibreGraphics 05.py program runs but the graph is all smutched
up.  I am pulling data from the EXCEL-FILE.txt into the program, selecting
three values for each line and creating three variables formatted as is
shown in the original demo file.
>
>When you run the program, choose 112 when prompted. You will see the values
of the variables I want to pass to the graph section of the code.  If the
values are hardcoded, the graphs look good.  When the variables generated by
my section of the code, it does not.
>
>I am not sure what more to explain.
>Please help me
>Steve
>
>I am attaching a zip file.  I hope it gets through.

Alas, the python-list is text only, and attachments are discarded.

Here is my code for the main program:
=

#https://matplotlib.org/stable/gallery/index.html

import matplotlib.pyplot as plt
import numpy as np

## In this first half of the program, I am reading lines of data from
## a file and reformatting them to create comms separated values into
## three variables.

Sensors = ""
TestStrips = ""
SampleNumber = ""
   
x = 1
SensorNumber = input("Enter senaor number: ")
with open("_EXCEL-FILE.txt" , 'r') as infile:
 for lineEQN in infile: # loop to find each line in the file for that
dose 
   if (lineEQN[0:1]== "."):
   SN = lineEQN[44:48].strip()
   if (SensorNumber == SN):
   SN = x
   sn = "'" + str(SN) + "', "
   SampleNumber = SampleNumber + sn
   
   sv = lineEQN[25:29].strip()
   sv = sv + ", "
   Sensors = Sensors + sv

   tv = lineEQN[32:37].strip()
   tv = tv + ", "
   TestStrips = TestStrips + tv
   
   x += 1

SnLen = len(SampleNumber) -2
SampleNumber = SampleNumber[0:SnLen]
labels = "[" + SampleNumber + "]"
print("labels = " + labels)

SenLen = len(Sensors) -2
Sensors = Sensors[0:SenLen]
Sensors = "[" + Sensors + "]"
print("Sensors = " + Sensors)

TsLen = len(TestStrips) -2
TestStrips = TestStrips[0:TsLen]
TestStrips = "[" + TestStrips + "]"
print("TestStrips = " + TestStrips)

labels = SampleNumber

## =

## In this second half of the program, I want to use the three
## variables ## to populate a fraph. 

## There are problems with this technique.

## =
## With the following 6 lines of code commented-out, the graphing
## program uses the variables from the first half of the program
## and the graph fails

## =

## Uncommented, the following works by overwriting the variables
## from the previous code and generates a proper graph.

#label = ['1', '2', '3', '4', '5']
#Sensor = [150, 132, 182, 75, 117]
#TestStrip = [211, 144, 219, 99, 142]

#labels = label
#Sensors = Sensor
#TestStrips = TestStrip

## ===

## The follows is the original cose from the sample program
## with minor variable names and label changes.

x = np.arange(len(labels))  # the label locations
width = 0.35  # the width of the bars

fig, ax = plt.subplots()
rects1 = ax.bar(x - width/2, Sensors, width, label='Sensors')
rects2 = ax.bar(x + width/2, TestStrips, width, label='TestStrips')

# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel('Glucose Readings')
ax.set_title('Sensors VS Test Strip')
ax.set_xticks(x)
ax.set_xticklabels(labels)
ax.legend()

ax.bar_label(rects1, padding=3)
ax.bar_label(rects2, padding=3)

fig.tight_layout()

plt.show()

===
And here is a sample of the data file:

.Thu Jul 22, 2021 20:47   250   27727   111   2 

.Fri Jul 23, 2021 00:05   188   194 6   111   3 
.Fri Jul 23, 2021 09:08   142   16624   111   3 
.Fri Jul 23, 2021 12:58   138   16527   111   3 
.Fri Jul 23, 2021 22:32   356   39135   111   3 

.Sat Jul 24, 2021 09:44   150   21161   112   4 
.Sat Jul 24, 2021 13:24   132   14412   112   4 
.Sat Jul 24, 2021 16:40   182   21331   112   4 
.Sat Jul 24, 2021 19:52759924   112   4 
.Sat Jul 24, 2021 23:19   117   14225   112   4

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Trying to read from a text file to generate a graph

2021-07-29 Thread Steve
Thank you, the responses here have been extremely helpful.
Steve



Footnote:
There's 99 bugs in the code, in the code.
99 bugs in the code.
Take one down and patch it all around.
Now there's 117 bugs in the code.





-Original Message-
From: Python-list  On
Behalf Of Stephen Berman
Sent: Wednesday, July 28, 2021 5:36 PM
To: python-list@python.org
Subject: Re: Trying to read from a text file to generate a graph

[Resending to the list only, since I couldn't post it without subscribing.]

On Wed, 28 Jul 2021 11:58:21 -0400 "Steve"  wrote:

> I forgot about the no-file rule...
>
>> On 28Jul2021 02:55, Steve  wrote:
>> I am going though a struggle with this and just don't see where it 
>> fails.  I am using the Dual Bar Graph.py program from 
>> https://matplotlib.org/stable/gallery/index.html website.  The file 
>> from the web site works so that shows that all my installations are 
>> complete.
>>
>> My program, LibreGraphics 05.py program runs but the graph is all 
>> smutched up.  I am pulling data from the EXCEL-FILE.txt into the 
>> program, selecting three values for each line and creating three 
>> variables formatted as is shown in the original demo file.
>>
>> When you run the program, choose 112 when prompted. You will see the 
>> values of the variables I want to pass to the graph section of the 
>> code.  If the values are hardcoded, the graphs look good.  When the 
>> variables generated by my section of the code, it does not.

The problem is due to the values of Sensors, TestStrips and SampleNumber
being strings; what you want is for them to be lists, as in the assignments
you commented out.  And since the data from the file is read in as strings,
you have to cast the elements of the Sensors and TestStrips lists to
integers, since you want the numerical values.  The following code does the
job:

Sensors = []
TestStrips = []
SampleNumber = []

x = 1
SensorNumber = input("Enter senaor number: ")
with open("_EXCEL-FILE.txt", 'r') as infile:
for lineEQN in infile:
if (lineEQN[0:1]== "."):
SN = lineEQN[44:48].strip()
if (SensorNumber == SN):
SN = x
SampleNumber.append(SN)

sv = lineEQN[25:29].strip()
Sensors.append(int(sv))

tv = lineEQN[32:37].strip()
    TestStrips.append(int(tv))

x += 1

labels = SampleNumber

Add the rest of your code from the second half to make the desired bar
chart.

Steve Berman
--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


How do I modify a bar graph?

2021-07-29 Thread Steve
The following code is from the site: 
https://matplotlib.org/stable/gallery/index.html  bar graph.
Sometimes I want to project a graph that contains almost 100 elements. The 
program shows everything crammed into a default size graph.  Can I modify the 
size of the graph and make it longer?

Also, the numbers in the graph are horizontal, can I make them vertical?
100
Vs
1
0
0
?


=
Import matplotlib.pyplot as plt
import numpy as np


labels = ['G1', 'G2', 'G3', 'G4', 'G5']
men_means = [20, 34, 30, 35, 27]
women_means = [25, 32, 34, 20, 25]

x = np.arange(len(labels))  # the label locations
width = 0.35  # the width of the bars

fig, ax = plt.subplots()
rects1 = ax.bar(x - width/2, men_means, width, label='Men')
rects2 = ax.bar(x + width/2, women_means, width, label='Women')

# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(x)
ax.set_xticklabels(labels)
ax.legend()

ax.bar_label(rects1, padding=3)
ax.bar_label(rects2, padding=3)

fig.tight_layout()

plt.show()

Steve



-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Regarding inability of Python Module Winsound to produce beep in decimal frequency

2021-08-17 Thread Steve


"The HAL (hardware abstraction layer) function HalMakeBeep()"
Is the beep that opens the pod bay doors?


Footnote:
 George Melly remarked to Mike Jagger on how lined his face was for one so
young. Jagger replied “They’re laughter lines George” to which Melly
countered: “Mick, nothing’s that f**king funny!”.

-Original Message-
From: Python-list  On
Behalf Of Eryk Sun
Sent: Tuesday, August 17, 2021 6:23 PM
To: Dennis Lee Bieber 
Cc: python-list@python.org
Subject: Re: Regarding inability of Python Module Winsound to produce beep
in decimal frequency

On 8/17/21, Dennis Lee Bieber  wrote:
> On Tue, 17 Aug 2021 15:11:05 +1000, Chris Angelico  
> declaimed the following:
>
>>Huh. Okay. Then I withdraw the concern from this list, and instead lay 
>>it at Microsoft's feet. That is, I maintain, a bizarre choice. Surely 
>>there are better ways to trigger audio on the sound card?
>
>   Possibly there is a section of code that determines if a sound card 
> is available, and if not, routes to the basic internal speaker. The 
> rest of the wave form logic is probably still of use for that.

It may be that there's a fallback audio device that uses the PC speaker on
systems that lack even basic audio support in their chipset. But in common
practice, Beep() does not use the PC speaker.

The "beep.sys" driver in Windows 7+ has no code path that starts a PC
speaker beep via HalMakeBeep(frequency) and ends it after a timeout via
HalMakeBeep(0), which was the old implementation of "beep.sys"
that can still be seen in ReactOS [1].

The HAL (hardware abstraction layer) function HalMakeBeep() is still
implemented in Windows 10, but without the connection to an IOCTL in
"\Device\Beep", or some other installed device driver, there's no way for
user-mode code to make a beep with the classic PC speaker.

In Windows 7+, the beep device's IOCTL_BEEP_SET function is just a relay.
It's implemented by searching for and completing a queued IOCTL request from
a task in the user's session (i.e. an inverted callback from kernel mode to
user mode). This task, which is scheduled to run at logon in every
interactive session, executes the "PlaySoundSrv.dll"
module in an instance of "taskhostw.exe". Upon completion of its queued
IOCTL, from which it gets the beep frequency and duration, the sound server
generates the requested beep waveform and plays it on the default audio
output device via WinAPI PlaySound().

Notably, the "beep.sys" driver doesn't support manually starting the
sound-server task in the user's session. So if one terminates the
"taskhostw.exe" process that's hosting "PlaySoundSrv.dll", WinAPI
Beep() will no longer work. To get it back, the
"\Microsoft\Windows\Multimedia\SystemSoundsService" task has to be restarted
manually.

---

[1]
https://github.com/reactos/reactos/blob/master/drivers/base/beep/beep.c#L295
--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Regarding inability of Python Module Winsound to produce beep in decimal frequency

2021-08-18 Thread Steve
-Original Message-
From: Python-list  On
Behalf Of Greg Ewing
Sent: Wednesday, August 18, 2021 11:49 AM
To: python-list@python.org
Subject: Re: Regarding inability of Python Module Winsound to produce beep
in decimal frequency

On 18/08/21 4:43 pm, Steve wrote:
>> 
>> "The HAL (hardware abstraction layer) function HalMakeBeep()"
>> Is the beep that opens the pod bay doors?

> def HalMakeBeepUsingPCSpeaker():
> raise IOError("I'm sorry, I can't do that, Dave.")

I tried that but all it reported was a very slow:
"Daisy, Daisy, give me your answer do"

And that is when I figured that I knew I should have done that backup

-- 
https://mail.python.org/mailman/listinfo/python-list


matplotlib questions

2021-08-26 Thread Steve
I am trying to modify the "Bar Graph Demo" at
https://matplotlib.org/stable/gallery/index.html,  Lines, bars, and markers
but the more I experiment and change the code, the more messed up it
becomes.  I have the demo code working. This is my second attempt.  I guess
I accidentally got my first chart working but this second one, not so good.

Is there any source to help me understand how the code works and how to
change it?
Among many others options, how do I change the font size? 
How are the labels placed on the X-axis and Y-axis?





-- 
https://mail.python.org/mailman/listinfo/python-list


RE: matplotlib questions

2021-08-27 Thread Steve
I would like to know how the data is placed on the Y-axis and at the tops of
the bars.
The data is not being shown properly.  With some exceptions, it looks as if
the data is getting sorted independently from the dates.


OK, here is the code:
==
# https://matplotlib.org/stable/gallery/index.html
import matplotlib.pyplot as plt
import numpy as np

width = 12 #Width of the graph
height = 6  #Height of the graph

plt.rcParams["figure.figsize"] = (width,height)
plt.rcParams["font.size"] = (9.0)


Count = 0
datesList = []   # Each date showing end of bottle use
hoursList = []   # Number of hours 
# daysList = []  # Number of days calculated from hours/24
countList = []   # simple tally

with open("__Insulin_Tracker.txt", 'r') as infile:
for lineEQN in infile:
  insulinHours = lineEQN[47:52].strip()
  print("Hours = " + insulinHours)
  hoursList.append(insulinHours)
  
  insulinDates = lineEQN[20:30].strip()
  datesList.append(insulinDates)
  
  #insulinDays= lineEQN[57:62].strip()
  #daysList.append(insulinDays)
  
  Count += 1
  countList.append(str(Count))
 # print("" + str(Count) + "  " + insulinDates + " Hours: " +
insulinHours)
x = Count
count = str(Count)

# Each date indicated the date on which a bottle of insulin has been
depleted
# The bar is to show the number of hours that the bottle has been in use.

Labels = datesList
Xdata= hoursList

Title = ("Bottle List   Number of entries: " + count)
x = np.arange(len(Labels))  # the label locations

width = 0.35  # the width of the bars
margin = 0

fig, ax = plt.subplots()
fig.tight_layout(pad=10) # Sets the size of the graph

rects1 = ax.bar(x - width/2, Xdata, width, label='Hours') #Populates the x
axis

# Add some text for labels, title and custom x-axis tick labels, etc.
# fontsize = 20

ax.set_ylabel('Hours of use for each bottle')
ax.set_title(Title) 
ax.set_xticks(x)
ax.set_xticklabels((datesList), rotation = 90) #Dates at bottom of the graph
ax.legend()
ax.bar_label(rects1, padding=0,rotation = 90)

plt.show()

===
Here is my data in __Insulin_Tracker.txt (with indents)
===

Sat Jan 02, 2021 15 29   1.21
Thu Jan 07, 2021 01116   4.83
Tue Jan 12, 2021 01120   5.00
Fri Jan 15, 2021 23 74   3.08
Tue Jan 19, 2021 22 95   3.96
Fri Jan 22, 2021 21 71   2.96
Tue Jan 26, 2021 08103   4.29
Sun Jan 31, 2021 23115   4.79
Fri Feb 05, 2021 01118   4.92
Mon Feb 08, 2021 20 71   2.96
Thu Feb 11, 2021 18 80   3.33
Tue Feb 16, 2021 08120   5.00
Fri Feb 19, 2021 18 72   3.00
Wed Feb 24, 2021 01113   4.71
Sun Feb 28, 2021 22 97   4.04
Thu Mar 04, 2021 11 95   3.96
Mon Mar 08, 2021 18103   4.29
Sat Mar 13, 2021 15117   4.88
Wed Mar 17, 2021 10 91   3.79
Sun Mar 21, 2021 00 96   4.00
Fri Mar 26, 2021 00120   5.00
Tue Mar 30, 2021 17103   4.29
Sat Apr 03, 2021 00 89   3.71
Wed Apr 07, 2021 23 99   4.12
Sun Apr 11, 2021 05 98   4.08
Thu Apr 15, 2021 14 95   3.96
Sun Apr 18, 2021 23 71   2.96
Fri Apr 23, 2021 23120   5.00
Tue Apr 27, 2021 17100   4.17
Tue Jul 27, 2021 21   2178  90.75
Sun Aug 01, 2021 18127   5.29
Thu Aug 05, 2021 23 91   3.79
Tue Aug 10, 2021 17124   5.17
Sat Aug 14, 2021 21 90   3.75
Thu Aug 19, 2021 09128   5.33
Wed Aug 25, 2021 02137   5.71






-Original Message-
From: Python-list  On
Behalf Of David Lowry-Duda
Sent: Friday, August 27, 2021 3:25 PM
To: python-list@python.org
Subject: Re: matplotlib questions

> I am trying to modify the "Bar Graph Demo" at 
> https://matplotlib.org/stable/gallery/index.html,  Lines, bars, and 
> markers but the more I experiment and change the code, the more messed 
> up it becomes.

It is much easier to give constructive suggestions if you give a minimum
runna

matplotlib graph white space

2021-10-04 Thread Steve


I am using the first bar graph listed at this site:
https://matplotlib.org/stable/gallery/index.html

The problem I have is that there is too much white space around the graph.
My data would be better displayed if I could widen the graph into the space
to the right and left of the chart.

Steve

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: matplotlib graph white space

2021-10-04 Thread Steve


Yes, I saw that but it is a change for all sides. 
 Is there a setting to change just the left and right padding?




-Original Message-
From: Michel Alwan  
Sent: Monday, October 4, 2021 7:56 AM
To: Steve 
Cc: python-list@python.org
Subject: Re: matplotlib graph white space

In the plot window, you can click on the settings (up), and select the
option "tight layout" by pressing that button... I think this is what you
are looking for...


On 21/10/04 04:39AM, Steve wrote:
> 
> I am using the first bar graph listed at this site:
> https://matplotlib.org/stable/gallery/index.html
> 
> The problem I have is that there is too much white space around the graph.
> My data would be better displayed if I could widen the graph into the 
> space to the right and left of the chart.
> 
> Steve
> 
> --
> https://mail.python.org/mailman/listinfo/python-list

--
Michel Alwan


( support Stallman : stallmansupport.org )

-- 
https://mail.python.org/mailman/listinfo/python-list


Custom designed alarm clock

2021-12-18 Thread Steve


I have designed a simple alarm using Python. It has about 10 limes.
How do I convert it to an app that I can on my android Moto E power 2021
phone?

Steve

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Custom designed alarm clock

2021-12-18 Thread Steve
Most of what is in that tutorial is old-hat for me. I have been coding Python 
for 10 years now and have a program with over 3000 lines of code.

 

However, I am reminded that Kivy has to be reinstalled on my system and now I 
see that using Linux is the way to go.  Buildozer? I also have to get the s14a 
library…

Oh well, nothing is as simple as it first seems.  It may take a while but I am 
willing to give it a go.

 

Steve

 

 

 George Melly remarked to Mike Jagger on how lined his face was for one so 
young. Jagger replied “They’re laughter lines George” to which Melly countered: 
“Mick, nothing’s that f**king funny!”.

 

From: Paul Bryan  
Sent: Saturday, December 18, 2021 7:50 PM
To: Steve ; 'Python Main' 
Subject: Re: Custom designed alarm clock

 

Suggested reading:

 

https://pypi.org/project/python-for-android/

https://play.google.com/store/apps/details?id=org.qpython.qpy3

https://www.androidauthority.com/an-introduction-to-python-on-android-759685/

https://data-flair.training/blogs/android-app-using-python/

 

On Sat, 2021-12-18 at 18:36 -0500, Steve wrote:

 

I have designed a simple alarm using Python. It has about 10 lines.

How do I convert it to an app that I can on my android Moto E power 2021

phone?

 

Steve

 

 

-- 
https://mail.python.org/mailman/listinfo/python-list


[tkinter] question about correct use of validation

2019-01-15 Thread steve

for determine the maximum number of characters in an entry

I have read several interpretations for the solution of the problem, but 
I wanted to find an alternative way (for convenience of the code)


I kindly ask for an opinion on the use of validation in this way.

-

problem: limit number of characters in different entries of a form.

code:

#!/usr/bin/python
# -*- coding: utf-8 -*

from Tkinter import *


class View():

def __init__(self, parent):
self.parent = parent
self.make_ui()

def make_ui(self):
''' create user interface '''
self.id_entry = Entry(self.parent, width=6)
# take out the properties for understanding

vcmd = (self.parent.register(self.maxlength_validate), '%P', 4)
# 4 is my question

self.id_entry.configure(validate="key", validatecommand=vcmd)
self.id_entry.pack()

self.name_entry = Entry(self.parent, width=30)
# take out the properties for understanding

vcmd = (self.parent.register(self.maxlength_validate), '%P', 20)
# 20 is my question

self.name_entry.configure(validate="key", validatecommand=vcmd)
self.name_entry.pack()

def maxlength_validate(self, value, maxlength):
''' function validated for maximum number of characters '''
maxlength = int(maxlength)
if len(value) > maxlength:
value = value[:maxlength]
return (value == ' ')
return True


def run():
root = Tk()
root.title('test')
View(root)
root.mainloop()

if __name__ == "__main__":
run()

The code works well :-) but...

in vcmd i use this:

vcmd = (self.parent.register(self.maxlength_validate), '%P', 20)
# '20' argument is my question, is not default value (is max length of 
char, different for each entry... very comfortable for me)


is it all right, according to you, to pass a non-default argument? (no 
error from the interpreter)


Without this way I would not know how to pass the maximum number of 
characters to the validation function, I can not use one variable

self.--- for each entry ... it would become aesthetically unattractive.

I would not even like to add a textvariable variable because anyway then

I should always pass the comparison value.

thank you in advance

Steve
--
https://mail.python.org/mailman/listinfo/python-list


Re: [tkinter] question about correct use of validation

2019-01-15 Thread steve

On 15/01/2019 14:16, Rick Johnson wrote:

steve wrote:

Then it's just a matter of passing a keyword argument:

 myEntry = MyEntry(master, maxlen=20)

What you have above is a tightly coiled, steaming dogpile that will litter your 
code base. Encapsulate that stench, would ya?



sure, everything will go into a "label_entry" function

It's similar to this:

def __label_entry (self, frame, text_label, width_label, width_entry, 
maxlen):

 '' 'Private utility function for a couple of labels + entry.
 Return istance of entry itself.
 '' '
 Label (frame, padx=10, pady=10, width=width_label,
text=text_label) .Pack (side=LEFT)
 entry = Entry (frame, width=width_entry)
 entry.configure (highlightcolor='blue')
 entry.pack (side=LEFT)
..
 return entry

I wrote voluntarily in order to better understand the question
--
https://mail.python.org/mailman/listinfo/python-list


Re: [tkinter] question about correct use of validation

2019-01-17 Thread steve

Il 16/01/19 08:51, Peter Otten ha scritto:


 def make_ui(self):
 ''' create user interface '''

 def vcmd(maxlength):
 return self.parent.register(
 partial(self.maxlength_validate, maxlength=maxlength)
 ), "%P"


...

ok following your advice and that of Rick in the previous post, I 
developed 2 solutions, one without classes and one with classes. I write 
to you if you need someone:



1) solution with class

(taking a cue from here: 
http://effbot.org/zone/tkinter-entry-validate.htm - I wanted to reduce 
the code, I'm working on it)


from Tkinter import *


class View():
''' example for set max length of char in Entry widget.
  -Class implantation-
'''
def __init__(self, parent):
self.parent = parent
self.make_ui()

def make_ui(self):
''' create user interface '''
self.id1_entry = self.make_entry(self.parent, maxlen=1).pack()
self.id2_entry = self.make_entry(self.parent, maxlen=2).pack()
self.id3_entry = self.make_entry(self.parent, maxlen=3).pack()
self.id4_entry = self.make_entry(self.parent, maxlen=4).pack()
self.id5_entry = self.make_entry(self.parent, maxlen=5).pack()

def make_entry(self, parent, width=50, maxlen=30, 
highlightcolor='blue',

   validate='key'):
entry = MyEntry(parent, maxlen=maxlen)
entry.configure(width=width, highlightcolor=highlightcolor)
return entry


class ValidatingEntry(Entry):
# base class for validating entry widgets
def __init__(self, master, value="", **kw):
apply(Entry.__init__, (self, master), kw)
self.__value = value
self.__variable = StringVar()
self.__variable.set(value)
self.__variable.trace("w", self.__callback)
self.config(textvariable=self.__variable)
self.configure(highlightcolor='blue')

def __callback(self, *dummy):
value = self.__variable.get()
newvalue = self.validate(value)
if newvalue is None:
self.__variable.set(self.__value)
elif newvalue != value:
self.__value = newvalue
self.__variable.set(newvalue)
else:
self.__value = value

def validate(self, value):
# override: return value, new value, or None if invalid
return value


class MyEntry(ValidatingEntry):
def __init__(self, master, value="", maxlen=None, **kw):
self.maxlength = maxlen
apply(ValidatingEntry.__init__, (self, master), kw)

def validate(self, value):
return value[:self.maxlength]

def run():
root = Tk()
root.title('test')
View(root)
root.mainloop()

if __name__ == "__main__":
run()




2) classless solution (part of your code)

from Tkinter import *

from functools import partial


class View():
''' example for set max length of char in Entry widget.
  -Functions implantation-
'''
def __init__(self, parent):
self.parent = parent
self.make_ui()

def make_ui(self):
''' create user interface '''
self.id1_entry = self.make_entry(self.parent, maxlen=1).pack()
self.id2_entry = self.make_entry(self.parent, maxlen=2).pack()
self.id3_entry = self.make_entry(self.parent, maxlen=3).pack()
self.id4_entry = self.make_entry(self.parent, maxlen=4).pack()
self.id5_entry = self.make_entry(self.parent, maxlen=5).pack()

def make_entry(self, parent, width=50, maxlen=30, 
highlightcolor='blue',

   validate='key'):
def vcmd(maxlength):
return self.parent.register(partial(self.maxlength_validate,
   maxlength=maxlength)), "%P"
entry = Entry(parent)
entry.configure(width=width, highlightcolor=highlightcolor,
validate='key', validatecommand=vcmd(maxlen))
return entry

def maxlength_validate(self, value, maxlength):
return len(value) <= maxlength


def run():
root = Tk()
root.title('test')
View(root)
root.mainloop()

if __name__ == "__main__":
run()


Thank you all
--
https://mail.python.org/mailman/listinfo/python-list


Re: [tkinter] question about correct use of validation

2019-01-17 Thread steve

Il 17/01/19 14:08, Peter Otten ha scritto:


Two remarks:


  self.id1_entry = self.make_entry(self.parent, maxlen=1).pack()


You set all idX_entry attributes to None, as that's what pack() returns.


you mean..

self.idx_entry = self.make_entry(self.parent, width=50, maxlen=30, 
highlightcolor='blue', validate='key') ?


or

self.idx_entry.pack() ?

I did not understand :-D




  apply(Entry.__init__, (self, master), kw)


You can write that in way compatible with Python 3 as

Entry.__init__(self, master, **kw)



Ok this i understood
--
https://mail.python.org/mailman/listinfo/python-list


Re: [tkinter] question about correct use of validation

2019-01-17 Thread steve

Il 17/01/19 14:08, Peter Otten ha scritto:

Alternatives:

- If you know that you'll always just call pack() you can change the
make_entry() method accordingly

def make_entry(...):
 ...
 entry.pack()
 return entry


- Write a helper function

def pack(widget):
 widget.pack()
 return widget

and then use it

self.id1_entry = pack(self.make_entry(...))  # create and layout widget




it's true! they are important things that make the difference and help 
in understanding.


Thanks a lot of support ;-)
--
https://mail.python.org/mailman/listinfo/python-list


How do I get a python program to work on my phone?

2019-01-28 Thread Steve
This is my first message to this forum, I am not sure how to submit it so
please correct me if I am not doing this properly.
 ===

Being new to python as of a year ago December and have extensive programming
experience: C++, VBasic, HTML etc...  I installed Python and wrote a program
that documents my blood readings enough that my A1c results went from 9.1 to
6.4 in about two months and have had low numbers since.

I now want to run it on my MotoG phone.  The program accepts keyed in data
and will access two text files to keep data and I would like to have the
program chime my phone to remind me to take the next reading.

First step is to get it running in my phone
How do I do it?  What software do I need to make the transfer?

Steve

= 
Footnote:
Zamboni locks up after running into a large patch of loose teeth.

-- 
https://mail.python.org/mailman/listinfo/python-list


Python program to phone?

2019-02-04 Thread Steve
I have written my first python program (600 lines!) to help control my blood
sugar and it has been so successful that my A1c dropped form 9.3 to an
impressive 6.4.  It will be much more useful if I had it on my phone.
(MotoG, Android)  The .py file reads/writes to two txt files.

 

About a year ago, I installed Kivy and managed to transfer the "Hello World"
app to my phone and it worked.  I am not on a different computer and believe
that I got all the way through the installation but I do not see how to
invoke it.  I am sure that I can go through the tutorial again and use my
program instead.

 

How do I figure out what is wrong and might there ne a better way to get the
program onto my phone?

 

Steve

 

P.S.  Yes, I tried to post this about two weeks ago but could not seem to
respond to the replies I received.  I could contact one or two individuals
but apparently not the masses.  How do I find out how this list works?

 

 

Foornote:
There's 99 bugs in the code, in the code.

99 bugs in the code.

Take one down and patch it all around.

Now there's 117 bugs in the code.

 

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Loop with else clause

2019-02-04 Thread Steve
Would it be a hyphythonitical question?

= 
Footnote:
Zamboni locks up after running into large patch of loose teeth.

-Original Message-
From: Python-list  On
Behalf Of DL Neil
Sent: Monday, February 4, 2019 11:29 PM
To: 'Python' 
Subject: Loop with else clause

What is the pythonic way to handle the situation where if a condition exists
the loop should be executed, but if it does not something else should be
done?


Why am I asking?
Today's code review included a for...else structure. I've rarely seen such a
thing, and even knowing it exists, cannot recall ever using it! 
The coder intended to implement the scenario (above) but did not realise
that the else-clause means 'execute if the loop ended without using break'.
She thought it meant 'if there's nothing in the iterable, execute the else
clause' (per if...then...else... ie the two clauses are
mutually-exclusive*) - which one assumes is the reason why the BDfL is
claimed to have said it should never have been implemented (this way). 
She neglected to test the exception properly, and was lulled into a false
sense of security by the coverage reporting 100%. Oops!

*see also the more commonly-used try...except...else...[finally...]


When/how does this occur?
Our client is more than a little commercially-sensitive. So as a really
simple scenario, imagine a report is required, naming people who have become
eligible for something, eg students qualified to enter an advanced class,
Oscar film award nominees, entrants who have fulfilled the requirements of a
competition from which a winner will be randomly selected...

The names all appear in a list, so the most frequent use-case is trivial:

print( "And the winners are:" )
for name in list:
print( name )

but, if no-one actually qualifies, a warning message is required, eg

print( "Sorry, no-one is eligible" )


Possible solution:
To make anything more than the trivial case readable, I think I'd put the
list processing into one function, and the exception into another (except
that this case is so trivial), ie

if list:
process_list() #the heading and for-loop, as above
else:
print( "Sorry...


Others wanted to add a semaphore/flag inside the loop to indicate if it was
executed at least once. Yes, could even use the else clause then!

The ideas went (rapidly) down-hill from there...


Is there another, more pythonic, approach to conditional (for/while) loop
processing?

--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Python program to phone?

2019-02-07 Thread Steve
BeeWare looks as if it requires Java, does it?
Is it exclusively java?

= 
Footnote:
Zamboni locks up after running into large patch of loose teeth.

-Original Message-
From: Python-list  On
Behalf Of Mario R. Osorio
Sent: Tuesday, February 5, 2019 8:58 AM
To: python-list@python.org
Subject: Re: Python program to phone?


Hi there Steve. Did you check BeeWare? (https://pybee.org/)

-- 
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


A limit to writing to a file from a loop?

2019-02-12 Thread Steve
My program reads from a text file (A), modifies the data, and writes to another 
file (B).
This works until I reach about 300 writes and no more lines are written to file 
(B).

I had to create a Counter and increment it to 250 when it gets reset.  

Upon reset, I close the file (B) being written and reopen it for append.  

Then it accepts the entire list of lines of data.

 

Bizarre?

 

CycleCounter += 1

if CycleCounter > 250:

  CycleCounter = 1

  DateReadings.close()

  DateReadings=open("Date-ReadingsAndDoses.txt", "a")   
 

  DateReadings.write("{0:15} {1:>8} {2:>8} {3:>8} {4:<2} {5:>8} 
{6:>8} {7:>10}".format

  (ThisTimeDate, ThisReading, ThisDose1, 
ThisSensor, ThisTrend,

   ThisTS, ThisPercent, SensorNumberDay2) + "\n")



-- 
https://mail.python.org/mailman/listinfo/python-list


I cannot seem to write time/date to the file.

2019-02-12 Thread Steve
I am using nowTimeDate2 elsewhere in my program and it can be printed to the 
screen.

The file exists and the program successfully opens the file, writes to it, and 
closes the file.

All is working as designed.

 

However,

Now I want to place an entry into the first line of the file to note the 
time/date the file was created.
It doesn’t show up in the file.

How do I fix this?

 

from time import gmtime, strftime 

nowTimeDate2=strftime("%Y %a %b %d %H:%M") 

print(nowTimeDate2)  #This works

DateReading=open("Date-ReadingsAndDoses.txt", "w")

DateReading.write = (nowTimeDate2 + "\n")

DateReading.close()

 

I also tried to append but that did not work either.

Interestingly enough, this is a feature that really has no real purpose in the 
final product yet it is hounding me.

 

 

 

Footnote:

 

 Ultrasound Technician Asks Pregnant Woman If She’d Like To Know Baby’s Name

 

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: A limit to writing to a file from a loop?

2019-02-12 Thread Steve
Very good points.  In short, I wrote two test programs.  
One to write 400 lines of data into a file.  
Another to read it, modify it, and write to a new file.  

With some questionable spacing in the final file, I was able to read/write 400 
lines of code disproving my original suspicion. Back to the drawing board but 
at least I can write all the lines using my work around in the original 
program.  The question is why is there a difference?.  I will post again if I 
find something.
The plot thickens.
TTKMAWAN...


>>> Test one: Prove that there is valid input
>>> - is the code successfully reading more than '250' records?

Yes, when I close the file and reopen it, all 500 records are read/written.
I placed an additional line of data into the file being written which should 
have pushed an offending line of data to the 251st position. 250 lines were 
read/written and the original 250th line was not written.

>>> Test two: Check the actual data
>>> - is there anything strange about the '250th' record (the one that first 
>>> exhibits the problem)?

I placed an additional line of data at the beginning of file being read, the 
writing of said data should have pushed an offending line of data being written 
to the 251st position. 250 lines were read/written and the original 250th line 
was not written.

>>> Test three: Prove that it is not some Python<->file system issue
>>> - what happens if the first input record is written (to a 'junk file') 
>>> 250+ times?

>>> Test four: (possibly unnecessary after the above) Disprove a size issue
>>> - what happens if you output a simple/hello world string (of the same 
>>> number of bytes) instead of the incoming data, 250+ times?


Footnote:
Ultrasound Technician Asks Pregnant Woman If She’d Like to Know Baby’s Name...

-Original Message-
From: DL Neil  
Sent: Tuesday, February 12, 2019 2:13 PM
To: Steve ; python-list@python.org
Subject: Re: A limit to writing to a file from a loop?

Steve,

On 13/02/19 7:56 AM, Steve wrote:
> My program reads from a text file (A), modifies the data, and writes to 
> another file (B).
> This works until I reach about 300 writes and no more lines are written to 
> file (B).
> I had to create a Counter and increment it to 250 when it gets reset.
> Upon reset, I close the file (B) being written and reopen it for append.
> Then it accepts the entire list of lines of data.
> Bizarre?
> 
>   
>  CycleCounter += 1
>  if CycleCounter > 250:
>CycleCounter = 1
>DateReadings.close()
>DateReadings=open("Date-ReadingsAndDoses.txt", "a")
>DateReadings.write("{0:15} {1:>8} {2:>8} {3:>8} {4:<2} {5:>8} 
> {6:>8} {7:>10}".format
>(ThisTimeDate, ThisReading, ThisDose1, 
> ThisSensor, ThisTrend,
> ThisTS, ThisPercent, SensorNumberDay2) 
> + "\n")


Perhaps part of the transfer to email, but won't this code only output once per 
250 records, cf 250 records per cycle?


Some suggestions:-

Test one: Prove that there is valid input
- is the code successfully reading more than '250' records?

Test two: Check the actual data
- is there anything strange about the '250th' record (the one that first 
exhibits the problem)?

Test three: Prove that it is not some Python<->file system issue
- what happens if the first input record is written (to a 'junk file') 
250+ times?

Test four: (possibly unnecessary after the above) Disprove a size issue
- what happens if you output a simple/hello world string (of the same 
number of bytes) instead of the incoming data, 250+ times?


Report back. If there are still problems, please show the original code 
and exception report...

-- 
Regards =dn


Footnote:
Ultrasound Technician Asks Pregnant Woman If She’d Like To Know Baby’s Name

-Original Message-
From: DL Neil  
Sent: Tuesday, February 12, 2019 2:13 PM
To: Steve ; python-list@python.org
Subject: Re: A limit to writing to a file from a loop?

Steve,

On 13/02/19 7:56 AM, Steve wrote:
> My program reads from a text file (A), modifies the data, and writes to 
> another file (B).
> This works until I reach about 300 writes and no more lines are written to 
> file (B).
> I had to create a Counter and increment it to 250 when it gets reset.
> Upon reset, I close the file (B) being written and reopen it for append.
> Then it accepts the entire list of lines of data.
> Bizarre?
> 
>   
>  CycleCounter += 1
>  if CycleCounter > 250:
>CycleCounter = 1
>DateReadings.close()
>DateReadings=open(&qu

RE: I cannot seem to write time/date to the file.

2019-02-12 Thread Steve
That was it, will wonders never cease?
Thanks



Footnote:
Ultrasound Technician Asks Pregnant Woman If She’d Like To Know Baby’s Name

-Original Message-
From: Python-list  On Behalf 
Of David Raymond
Sent: Tuesday, February 12, 2019 2:28 PM
To: python-list@python.org
Subject: RE: I cannot seem to write time/date to the file.

DateReading.write = (nowTimeDate2 + "\n")

You're re-assigning the write method to be a string here. You want to call the 
method with the string as the argument.

DateReading.write(nowTimeDate2 + "\n")



-Original Message-
From: Python-list 
[mailto:python-list-bounces+david.raymond=tomtom@python.org] On Behalf Of 
Steve
Sent: Tuesday, February 12, 2019 2:20 PM
To: python-list@python.org
Subject: I cannot seem to write time/date to the file.

I am using nowTimeDate2 elsewhere in my program and it can be printed to the 
screen.

The file exists and the program successfully opens the file, writes to it, and 
closes the file.

All is working as designed.

 

However,

Now I want to place an entry into the first line of the file to note the 
time/date the file was created.
It doesn’t show up in the file.

How do I fix this?

 

from time import gmtime, strftime 

nowTimeDate2=strftime("%Y %a %b %d %H:%M") 

print(nowTimeDate2)  #This works

DateReading=open("Date-ReadingsAndDoses.txt", "w")

DateReading.write = (nowTimeDate2 + "\n")

DateReading.close()

 

I also tried to append but that did not work either.

Interestingly enough, this is a feature that really has no real purpose in the 
final product yet it is hounding me.

 

 

 

Footnote:

 
<http://click1.email.theonion.com/fdhhznrjhrcwhhsdwbqczwybqhwgsbrpzdlbfybhqbhhj_bjcgpjgcpypgjzzbfqdd.html?a=TheOnion_Daily_RSS&b=&c=>
 Ultrasound Technician Asks Pregnant Woman If She’d Like To Know Baby’s Name

 

-- 
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


New rules for scope in a function?

2019-02-18 Thread Steve
I have been programming for more years than I want to admit and believe that I 
have a good understanding when it comes to the Scope of Variables when using 
functions. Are the rules different when using python?

It looks as if I have to pass all variables to and from the function before it 
works.  Are variables used in the main program not also visible for use within 
the function?  Do these variables have to be declared as global?

Steve


Footnote:
Ultrasound Technician Asks Pregnant Woman If She’d Like To Know Baby’s Name
 

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: New rules for scope in a function?

2019-02-18 Thread Steve


OK, I wrote:

x = "A"
print("x = " + x)

def f(y):
print("x= " + x + "  y= "+ y)

f(x)

and it worked, inspite of what I was seeing in my own program.  
How quick I am to blame Python. (:
When I isolate my function that stumped me, I will post it.
Thanks.
Steve


Footnote:
Ultrasound Technician Asks Pregnant Woman If She'd Like To Know Baby's Name

-Original Message-
From: Python-list  On
Behalf Of Chris Angelico
Sent: Monday, February 18, 2019 12:40 PM
To: Python 
Subject: Re: New rules for scope in a function?

On Tue, Feb 19, 2019 at 4:36 AM Steve  wrote:
>
> I have been programming for more years than I want to admit and believe
that I have a good understanding when it comes to the Scope of Variables
when using functions. Are the rules different when using python?
>
> It looks as if I have to pass all variables to and from the function
before it works.  Are variables used in the main program not also visible
for use within the function?  Do these variables have to be declared as
global?
>
> Steve
>

Functions in Python have access to everything in the surrounding scopes,
usually a module. Any name that's ever *assigned to* in the function
(including its parameters) is local to that function, and anything that you
look up without assigning comes from the outer scope.

x = 1
def f(y):
print(x, y)

This function is happily able to see its own parameter (a local) and the
name from outside it (a global). It's also able to see the "print"
function, which comes from the builtins - that's just another scope.

ChrisA
--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: ajax with pyside webview

2019-02-19 Thread Steve



Try BonAmi.

Footnote:
Ultrasound Technician Asks Pregnant Woman If She'd Like To Know Baby's Name

-Original Message-
From: Python-list  On
Behalf Of Abdur-Rahmaan Janhangeer
Sent: Tuesday, February 19, 2019 2:08 AM
To: Python 
Subject: ajax with pyside webview

greetings, i'm using pyside webview to view a localhost app, all works fine,
just  ajax via jquery does not work. other requests work fine.

ajax works fine in web browser though.

any ideas?

Abdur-Rahmaan Janhangeer
http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ Mauritius
--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Unable to Install Python 3.7.2 64 bit version on my Windows 8.1

2019-02-20 Thread Steve
Is your .py file represented with the python icon? If not then you probably
have a path problem.

You can check to see if python is working if you copy a .py file into the
same folder where python.exe exists.  If you can execute the .py file from
that folder then and not elsewhere, it is probably a path problem.

>From my bad experience installing Python, apparently the installation did
not handle the path modification very well.  I had to add the python path
into the environment manually.

To check this, open a CMD screen and enter "path" as a command.  Check to
see if the path to Python is listed.

I struggled with this in my first installation of Python until I learned how
to manually modify the environment path.  I had to install python on a
second computer but did not remember what magic I had to do to get the
system to remember where the python.exe was located. So that second computer
still does not have it working properly.





Footnote:
Ultrasound Technician Asks Pregnant Woman If She'd Like To Know Baby's Name

-Original Message-
From: Python-list  On
Behalf Of Subash Netha
Sent: Tuesday, February 19, 2019 8:08 PM
To: python-list@python.org
Subject: Unable to Install Python 3.7.2 64 bit version on my Windows 8.1

Hello Team,

I'm trying to install Python 3.7.2  64 bit version on my Windows 8.1
Operating system with Robot framework ride with Selenium Libraries.

However, Python is getting installed in local drive installed of C drive and
unable to open the ride.py.

Please let me know, if there is work around for the same or any
documentation would be greatly appreciated.

Hoping to hear from you soon.

Thanks,
Subash
--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: my idle doesn't work

2019-02-20 Thread Steve
I had this once. I uninstalled/reinstalled python and IDLE worked.



Footnote:
Ultrasound Technician Asks Pregnant Woman If She'd Like To Know Baby's Name

-Original Message-
From: Python-list  On
Behalf Of Sithmi Assalaarachchi
Sent: Wednesday, February 20, 2019 7:53 AM
To: python-list@python.org
Subject: my idle doesn't work



Sent from Mail for Windows 10

-- 
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Connector/Python, MySQL Workbench Issue

2019-02-25 Thread Steve
Check to see if the path was updated.


Footnote:
Ultrasound Technician Asks Pregnant Woman If She'd Like To Know Baby's Name

-Original Message-
From: Python-list  On
Behalf Of Scott Sorgent
Sent: Monday, February 25, 2019 8:16 PM
To: python-list@python.org
Subject: Connector/Python, MySQL Workbench Issue


I was trying to install MySQL Workbench and it asked me to install the
Connector/Python 3.7.  I installed Python 3.7.2, restarted the computer and
tried to install MySQL workbench again and it told me again that I needed to
install Connector/Python 3.7.  I found the download for MySQL
Connector/Python 3.7 then downloaded and tried installing, but immediately,
I get a popup saying Python v3.7 not installed.  Why is this happening and
what should I do to get everything installed and working?

Thanks,
Scott
-- 
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Quirk difference between classes and functions

2019-02-26 Thread Steve
I have been a silent reader on this and am interested in understanding more
about the scope of variables in Python.  They do not seem to behave as I
have experienced in other programming languages.

I have used functions in python but was not aware of class.
It would benefit me very well if someone could post a simple example of each
on which I might experiment.
Steve




Footnote:
There's 99 bugs in the code, in the code.
99 bugs in the code.
Take one down and patch it all around.
Now there's 117 bugs in the code.

-Original Message-
From: Python-list  On
Behalf Of Gregory Ewing
Sent: Tuesday, February 26, 2019 4:27 PM
To: python-list@python.org
Subject: Re: Quirk difference between classes and functions

Thomas Jollans wrote:
> I imagine there's a justification for the difference in behaviour to 
> do with the fact that the body of a class is only ever executed once, 
> while the body of a function is executed multiple times.

I suspect there isn't any deep reason for it, rather it's just something
that fell out of the implementation, in particular the decision to optimise
local variable access in functions but not other scopes.

When compiling a function, the compiler needs to know which variables are
local so that it can allocate slots for them in the stack frame. But when
executing a class body, the locals are kept in a dict and are looked up
dynamically.

The compiler *could* be made to treat class bodies the same way as functions
in this regard, but it would be extra work for little or no benefit. Most
code in class bodies just defines new names without referring to anything
else in the same scope.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


System Beep?

2019-03-08 Thread Steve
How can I cause a system beep using code?
This is using the computer's internal speaker, not an audio external
speaker.
Do I have control of duration or volume?

Steve





Footnote:
Every minute, every single day, the equivalent of a truckload of plastic
enters our oceans.


-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Duplicates

2019-03-08 Thread Steve
Are they going to the same or another eddress?
Do you have a second e-mail address in the list?


Footnote:
Ultrasound Technician Asks Pregnant Woman If She'd Like To Know Baby's Name

-Original Message-
From: Python-list  On
Behalf Of Milt
Sent: Friday, March 8, 2019 2:37 PM
To: python-list@python.org
Subject: Duplicates

I get two messages for every post - p...@netrh.com
-- 
Regards,

Milt
m...@ratcliffnet.com

-- 
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: System Beep?

2019-03-08 Thread Steve
= RESTART: C:\Gork\Med Insulin codes\MedReminder 127.py
=
Traceback (most recent call last):
  File "C:\Gork\Med Insulin codes\MedReminder 127.py", line 13, in

windsound.Beep  #(frequency, duration)
NameError: name 'windsound' is not defined

Something missing in my code?


98% of lawyers give the other 2% a bad name.


-Original Message-
From: Python-list  On
Behalf Of David Raymond
Sent: Friday, March 8, 2019 3:02 PM
To: python-list@python.org
Subject: RE: System Beep?

Windows has the built in winsound module that lets you set frequency and
duration, not sure about other OS's.

https://docs.python.org/3.7/library/winsound.html


-Original Message-
From: Python-list
[mailto:python-list-bounces+david.raymond=tomtom@python.org] On Behalf
Of Steve
Sent: Friday, March 08, 2019 1:14 PM
To: python-list@python.org
Subject: System Beep?

How can I cause a system beep using code?
This is using the computer's internal speaker, not an audio external
speaker.
Do I have control of duration or volume?

Steve





Footnote:
Every minute, every single day, the equivalent of a truckload of plastic
enters our oceans.


--
https://mail.python.org/mailman/listinfo/python-list
--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: System Beep?

2019-03-08 Thread Steve
I used print(0x07) as the system called for parentheses but no error but also 
no sound.
Should this use a default or do I have to specify frequency and duration?


Footnote:
Ultrasound Technician Asks Pregnant Woman If She’d Like To Know Baby’s Name

-Original Message-
From: Igor Korot  
Sent: Friday, March 8, 2019 2:56 PM
To: Steve 
Cc: python-list@python.org
Subject: Re: System Beep?

Hi,

On Fri, Mar 8, 2019 at 1:35 PM Steve  wrote:
>
> How can I cause a system beep using code?
> This is using the computer's internal speaker, not an audio external 
> speaker.

Print 0x07.

Thank you.

> Do I have control of duration or volume?
>
> Steve
>
>
>
>
>
> Footnote:
> Every minute, every single day, the equivalent of a truckload of 
> plastic enters our oceans.
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: System Beep?

2019-03-08 Thread Steve
Yes, I saw that.  It still failed with, or without, the “d”.  I played with 
case and the use of ().
They all produced similar errors

 

 

Footnote:

 
<http://click1.email.theonion.com/fdhhznrjhrcwhhsdwbqczwybqhwgsbrpzdlbfybhqbhhj_bjcgpjgcpypgjzzbfqdd.html?a=TheOnion_Daily_RSS&b=&c=>
 Ultrasound Technician Asks Pregnant Woman If She’d Like To Know Baby’s Name

 

From: Ivan "Rambius" Ivanov  
Sent: Friday, March 8, 2019 3:25 PM
To: Steve 
Cc: David Raymond ; python-list@python.org
Subject: Re: System Beep?

 

Hello,

On Fri, Mar 8, 2019, 3:19 PM Steve mailto:Gronicus@sga.ninja> > wrote:

= RESTART: C:\Gork\Med Insulin codes\MedReminder 127.py
=
Traceback (most recent call last):
  File "C:\Gork\Med Insulin codes\MedReminder 127.py", line 13, in

windsound.Beep  #(frequency, duration)
NameError: name 'windsound' is not defined

Something missing in my code?

 

You have a typo. It is winsound, not winDsound.

 

Regards

rambius

 



98% of lawyers give the other 2% a bad name.


-Original Message-
From: Python-list mailto:sga.ni...@python.org> > On
Behalf Of David Raymond
Sent: Friday, March 8, 2019 3:02 PM
To: python-list@python.org <mailto:python-list@python.org> 
Subject: RE: System Beep?

Windows has the built in winsound module that lets you set frequency and
duration, not sure about other OS's.

https://docs.python.org/3.7/library/winsound.html


-Original Message-
From: Python-list
[mailto:python-list-bounces+david.raymond 
<mailto:python-list-bounces%2Bdavid.raymond> =tomtom@python.org 
<mailto:tomtom@python.org> ] On Behalf
Of Steve
Sent: Friday, March 08, 2019 1:14 PM
To: python-list@python.org <mailto:python-list@python.org> 
Subject: System Beep?

How can I cause a system beep using code?
This is using the computer's internal speaker, not an audio external
speaker.
Do I have control of duration or volume?

Steve





Footnote:
Every minute, every single day, the equivalent of a truckload of plastic
enters our oceans.


--
https://mail.python.org/mailman/listinfo/python-list
--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: System Beep?

2019-03-08 Thread Steve
I tried all three, nothing audio.  I am beginning to wonder if something I the 
operating system is at fault.
The three lines do produce symbols.  The first two are a rectangle with a space 
in the middle and the last one spelled out "bel" in short/small characters.





There's 99 bugs in the code, in the code.
99 bugs in the code.
Take one down and patch it all around.
Now there's 117 bugs in the code.

-Original Message-
From: Python-list  On Behalf 
Of DL Neil
Sent: Friday, March 8, 2019 3:51 PM
To: python-list@python.org
Subject: Re: System Beep?

Dear Squeak, sorry, Dear Steve,

Back in the ?good, old days when we used to walk alongside a mainframe CPU 
whilst it cogitated, we would often use the BEL character to alert us to job 
completion (and meantime bunk-off to go have a coffee, cakes,
...) - more seriously, it alerted telegraph and telex operators to an incoming 
message (you can still hear similar "beeps" on some emergency-worker radio 
systems, NASA moon mission video-replays, etc).

In the grips of nostalgia, I tried to make it work using the REPL, and failed, 
but first...


On 9/03/19 7:13 AM, Steve wrote:
> How can I cause a system beep using code?
> This is using the computer's internal speaker, not an audio external
> speaker.
> Do I have control of duration or volume?

The BEL character was included in the ASCII standard as chr(7)*. Back in 
those days, the rest of the world didn't exist - the "A" stands for 
"American". Accordingly, the huge advance was that we would be allowed 
to use lower-case letters, instead of all-caps (capital letters). Using 
French accents or German umlauts (etc), anything beyond the "standard" 
26-letters of "the" alphabet, would have been infra-dig to a well 
brought-up, clean-cut, American boy ("truth, justice, and the American 
way"*) - excepting that he wouldn't have understood the term, because 
didn't know of any other language than English. This problem was 
acknowledged and solved with Unicode. Viva Python 3!

Before you laugh, perhaps in disbelief that at one time computers ran 
exclusively in upper-case, take a closer look at ASCII, because even 
then there was no "$" or "£", only a generic currency symbol, "¤". What 
were they thinking? Simple: computers worked with numbers - why 
clutter-up the place by adding pesky letters, labelling 'answers', and 
stuff like that?

Whilst we have protocols or understandings in Python, eg a file simply 
ends, there is no need for any special indication or code; back in those 
?good, old days there were a number of different ways to encode 
characters AND to indicate other features of a file. Accordingly, the 
"II" part of ASCII - Information Interchange.

So, it was not merely a character set in terms of an alphabet, but by 
standardising some universal 'understandings' made "interchange" 
possible between computer systems (without which the Internet would 
never have become a possibility!). We knew these non-alpha components as 
"control characters". They still exist in various forms today - I was 
helping a Network Tech revise for his exams, and we ran through the 
exchanges necessary to establish a computer on a network using DHCP, and 
instead of "right" or "correct" I joked with him by saying "ACK" (and 
later, when he made a mistake "NAK") which really made him blink!

The really 'fun' ones today (because there is a difference between Linux 
and MS-Windows, ie we've lost the "standard") are "carriage return" (the 
process of pushing a typewriter's "carriage" (roller holding the paper) 
from the (right-hand!) end of one line all the way to the left again), 
"line feed" which was the second half of the typewriter process, when 
you first pulled the big handle at the top-right of the machine, it 
rolled the paper upward (normally) one line - sometimes called "New 
line". Thus "CR", "LF", and often "CRLF", and "NL". (why have two codes 
to perform what is (now!) one action?)

"BEL" is one of those "control characters".

If you are familiar with Python's chr() and ord(), you will remember 
that characters can be represented both as strings and as integers (in 
the case of ASCII, one character occupied one byte; but now that Python 
3 uses Unicode, the one-to-one is no longer necessarily true). Thus 
control characters can be expressed in either representation*. In the 
case of BEL, my elephantine memory immediately recalled it as 7! As if 
that wasn't enough, Python also has its set of string literals and 
escape characters*.

Just for fun, I sta

RE: System Beep?

2019-03-08 Thread Steve
Import winsound
winsound

No error, no beep either.


-
Footnote
A cat looks up and sees a bird in a tree and says"
"Hey, let's do lunch someday..."


-Original Message-
From: Python-list  On Behalf 
Of Peter Otten
Sent: Friday, March 8, 2019 3:42 PM
To: python-list@python.org
Subject: RE: System Beep?

Steve wrote:

>> You have a typo. It is winsound, not winDsound.

> Yes, I saw that.  It still failed with, or without, the “d”.  I played 
> with case and the use of (). They all produced similar errors

Did you import the winsound module before trying to use it?

--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: System Beep?

2019-03-08 Thread Steve
Thank you, both work for me too.
Mischief managed.
Steve



Footnote:
I am simply a thing that thinks.
Rene Descartes

-Original Message-
From: Python-list  On
Behalf Of Terry Reedy
Sent: Saturday, March 9, 2019 12:53 AM
To: python-list@python.org
Subject: Re: System Beep?

On 3/8/2019 1:13 PM, Steve wrote:
> How can I cause a system beep using code?

 >>> import winsound as ws
 >>> ws.Beep(500, 1000)

and

 >>> from tkinter import Tk
 >>> root = Tk()
 >>> root.bell()

work for me.  The bell is not exactly a bell, but different from a monotone
beep.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: System Beep?

2019-03-08 Thread Steve
Mischief almost managed.
They both work when using IDLE but the second one leaves an empty window to
be closed.
I do like the second one.  Is there a follow up command to close that
window?

Steve



Footnote:
I am simply a thing that thinks.
Rene Descartes

-Original Message-
From: Python-list  On
Behalf Of Terry Reedy
Sent: Saturday, March 9, 2019 12:53 AM
To: python-list@python.org
Subject: Re: System Beep?

On 3/8/2019 1:13 PM, Steve wrote:
> How can I cause a system beep using code?

 >>> import winsound as ws
 >>> ws.Beep(500, 1000)

and

 >>> from tkinter import Tk
 >>> root = Tk()
 >>> root.bell()

work for me.  The bell is not exactly a bell, but different from a monotone
beep.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Can my python program send me a text message?

2019-03-19 Thread Steve
I have a program that triggers a reminder timer.  When that timer is done, I 
would like to receive a text message on my phone to tell me that it is time to 
reset the experiment.

Can this be done using Python?

Steve

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Can my python program send me a text message?

2019-03-19 Thread Steve
Thanks for all the suggestions.  It is going to take a while to sift through
them.  I will continue to watch for more discussion and will check back in
if/when I get something working or if I get stuck.

Steve


Footnote:
Fight the hand that feeds the hate.

-Original Message-
From: Python-list  On
Behalf Of Larry Martell
Sent: Tuesday, March 19, 2019 3:46 PM
To: Python 
Subject: Re: Can my python program send me a text message?

On Tue, Mar 19, 2019 at 3:30 PM Steve  wrote:
>
> I have a program that triggers a reminder timer.  When that timer is done,
I would like to receive a text message on my phone to tell me that it is
time to reset the experiment.
>
> Can this be done using Python?

You can send a text with email if you know the carrier:

Alltel [insert 10-digit number]@message.alltel.com 
AT&T [insert 10-digit number]@txt.att.net 
Boost Mobile [insert 10-digit number]@myboostmobile.com 
Cricket Wireless [insert 10-digit number]@mms.cricketwireless.net 
Sprint [insert 10-digit number]@messaging.sprintpcs.com 
T-Mobile [insert 10-digit number]@tmomail.net 
U.S. Cellular [insert 10-digit number]@email.uscc.net 
Verizon [insert 10-digit number]@vtext.com 
Virgin Mobile [insert 10-digit number]@vmobl.com

--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Can my python program send me a text message?

2019-03-20 Thread Steve
This is a very good point since I am already finding that the arrival of
texts, and voice mail, seem to be irregular with respect to delivery times
with my phone as it is.

On the other hand, I was not thinking fourth dimensionally when I thought
about using text mail for this project. Since I am planning to migrate this
program into my phone eventually, I can just use the beep in the phone
instead.  When I get the transfer done, I can then think about how to get
the phone to make the sounds.

Still, Python-to-text messaging code is an interesting concept to explore
should I want to use it the future. 


Footnote:
98% of lawyers give the other 2% a bad name.


-Original Message-
From: Python-list  On
Behalf Of Rhodri James
Sent: Wednesday, March 20, 2019 9:20 AM
To: python-list@python.org
Subject: Re: Can my python program send me a text message?

On 19/03/2019 19:33, Abdur-Rahmaan Janhangeer wrote:
> - 1) use pi with gsm module.
> or
> - 2) find some free sms api for python then use

Slightly off-topic, but you (the OP) should be aware that carriers do not
guarantee that texts will be delivered in a timely manner.  In fact they
don't guarantee to deliver the texts at all.  We have had clients become
very unhappy when confronted with the reality of that.

--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


What is the difference between "ws.Messagebeep(1)" and "ws.Messagebeep(-1)" ?

2019-03-21 Thread Steve
Also: What is the code for other tones that I can call?

 

 

Footnote:

When someone asks "A penny for your thoughts" and you give your 2c worth,  

I wonder what happens to that other penny?

TTKMAWAN

 

-- 
https://mail.python.org/mailman/listinfo/python-list


Timing problem?

2019-03-21 Thread Steve
I believe I can see what is happening here but maybe someone can explain least 
I run into this again.

Situation 1: I am using "ws.MessageBeep(1)" to generate a tone through the 
speakers. I wanted two tones to separate it from other tones that might happen 
and placed that code a second time in the next line.  Sometimes it would not 
beep, others just one beep.

Situation 2" At the end of my program a report is generated and then it calls 
timer1.py to remind me when to enter the next readings from the lab.  It looks 
as if the report generation is interrupted when timer1.py is called.

If I place "time.sleep(1)" between the commands for the beep, I get two beeps 
one second apart reliably.
If I place "time.sleep(5)" between the report generation the call for timer1.py 
is called then apparently there is enough time for the report to be generated.

What is happening?



Footnote:
There's 99 bugs in the code, in the code.
99 bugs in the code.
Take one down and patch it all around.
Now there's 117 bugs in the code.

-- 
https://mail.python.org/mailman/listinfo/python-list


convert .py to Android ?

2019-05-13 Thread Steve
I tried this before and suddenly had a more pressing issue.  Now that I want
to get back into it, I cannot seem to find the responses that were offered
here.

I have a working .py program that I want to get into my Android Moto G
phone.

A bit more than a year ago, I went through the Kivy set up and actually had
the Good Morning World program in my phone but at that time I did not seem
to be able to do it again.  Now that I am on a different computer, I hope I
don't have to go through all that set up again.

Is there an easier way to achieve my task?
Steve


Footnote:
Sometimes I feel as if I am a down slinky on an up escalator

-- 
https://mail.python.org/mailman/listinfo/python-list


App for Moto e6 using Python?

2020-07-13 Thread Steve
I am looking for an app for my Moto e6 android phone that will accept a
number of hours and count down.  Then will beep every minute until I cancel
the app.  This is to remind me when to take my insulin.

 

It has been written in python but I do not know how to convert it to an app.
I wonder how much of the python code will still apply. When I was into this
in the past, I installed Kivy and was able to finally generate a "Hello
World" app and managed to get it to my phone. Then life called me back to
reality and I lost track of what I was doing for a few years. )-:  I doubt I
can go through that installation and learning curve again.

 

It works on my computer but I have projects that interfere with the alarm.  
This is why I would prefer to have it on my phone.

I appreciate any assistance you can provide.

Steve




Footnote:

There's 99 bugs in the code, in the code.

99 bugs in the code.

So I take one down and patch it all around.

Now there's 117 bugs in the code.

 

-

## Copyright Ambrosini 2017

#import re
#import random
import time
#import datetime
#from datetime import datetime

import winsound #as ws

#global delayTime
#global DelayTime

print()
print(" Enter 0 to test the alarm section.")
delayTime = input(" How many hours to next insulin check? (3) ")
if delayTime == "":
delayTime = 3
DelayTime = int(delayTime)
winsound.MessageBeep(-1)
print()
# =

def Alarm(D):
AX = 0
while D >= 1:
   
d = str(D)
AX += 1
ax = str(AX)
print(' ' + ax, end='...' + "\n") # minutes late
   
time.sleep(60)
D -= 1

import winsound #as wsBeep
winsound.MessageBeep(1)

def countdown(DelayTime):
import time
t = str(DelayTime)
if t == "1":
   print(" An alarm will start sounding in " + t + " hour...")
else:
   print(" An alarm will start sounding in " + t + " hours...")
   
while DelayTime >= 1:
t = str(DelayTime)
time.sleep(3600)
DelayTime -= 1
import winsound as wsBeep
wsBeep.MessageBeep(1)
 
print(' More Insuin? \n')
Alarm(3)

countdown(DelayTime)
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Fake news Detect

2020-07-17 Thread Steve
I posted a request for assistance about a week ago, no response.  I also see
very little traffic here, less than there used to be.  Has something gone
wrong with my set up?



Footnote:
There's 99 bugs in the code, in the code.
99 bugs in the code.
Take one down and patch it all around.
Now there's 117 bugs in the code.

-Original Message-
From: Python-list  On
Behalf Of Gazu
Sent: Friday, July 17, 2020 12:02 PM
To: python-list@python.org
Subject: Fake news Detect

Hey Guys I am new to python and i am building a fake news detection system
my goal is that when some one post a news the system will check it by
searching that news on Web and find solution that whether that news is Fake
or Not.
But the issue is that i have no idea how to search on Web or which algorithm
to use. However i know about web scrapping and other stuff, so guys help me
out on this by giving your remarks.
thanks in advance.
--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


An I connected here?

2020-07-17 Thread Steve
Sorry folks, I really messed that one up.  I tried to doctor up a reply to
get the address correct but failed to delete enough to own the message...

My message did not have anything to do with the "Fake News Detect" subject. 

I posted a request for assistance about a week ago, no response.  I also see
very little traffic here, less than there used to be.  Has something gone
wrong with my set up?

My goof, sorry about that.


Footnote:
There's 99 bugs in the code, in the code.
99 bugs in the code.
Take one down and patch it all around.
Now there's 117 bugs in the code.

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: An I connected here?

2020-07-17 Thread Steve
Thanks for the verification.  I received my original message back and that
also shows success in my attempt.  The first message had no such copy back
so it went off somewhere...

Thanks for the guidance but I always try to make the subject line pertinent
and explanatory.  It is the selling point to get results.

I will repost it later.

FootNote:
If money does not grow on trees, then why do banks have branches?

-Original Message-
From: Python-list  On
Behalf Of Grant Edwards
Sent: Friday, July 17, 2020 4:13 PM
To: python-list@python.org
Subject: Re: An I connected here?

On 2020-07-17, Rhodri James  wrote:
> On 17/07/2020 19:33, Steve wrote:
>
>> I posted a request for assistance about a week ago, no response.  I 
>> also see very little traffic here, less than there used to be.  Has 
>> something gone wrong with my set up?
>
> No, nothing's wrong.  I can't answer for anyone else and I can't 
> recall your specific question, but I suspect you were asking about 
> something I know nothing about and wasn't sufficiently intrigued to go
find out about.

And if it's not clear from the subject line that it _is_ something somebody
knows/cares about, then that somebody is unlikely to read the body of the
message.

Subject lines like "help me please" or "Python doesn't work" or "An I
connected here" are likely to be ignored by most of the people who probably
know how to help.  There are a few kind souls who make a habit of reading
those, dog bless em.  [I'm not one of them, I only read this by accident.]

That said, there is definitely less traffic these days.  I assume it's a
continuation the gradual abandonment of usenet/email in favor of various
almost-entirely-useless web "forums".

--
Grant


--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Seeking to convert a py timer app for my Moto E6

2020-07-17 Thread Steve
I am looking for an app for my Moto e6 android phone that will accept a number 
of hours and then count down.  Once the hours have been executed, it will 
quietly beep every minute until I cancel the app.  This is to remind me  (and 
keep on reminding me) when to take my insulin.

It has been written in python but I do not know how to convert it to an app. I 
wonder how much of the python code will still apply. When I was into this in 
the past, I installed Kivy and was able to finally generate a "Hello World" app 
and managed to get it to my phone. Then life called me back to reality and I 
lost track of what I was doing for a few years. )-:  I doubt I can go through 
that installation and learning curve again.

It works on my computer but I have projects that interfere with the alarm.  
This is why I would prefer to have it on my phone.
I appreciate any assistance you can provide.

Steve

I attached the py code but wonder if it will carry with the message.  It is 
about 100 lines of code but that includes a few ops and whistles that are 
probably not needed in the app.

There's 99 bugs in the code, in the code.
99 bugs in the code.
Take one down and patch it all around.
Now there's 117 bugs in the code.
## Copyright Ambrosini 2017

import re
import random
import time
import datetime
from datetime import datetime

global AX
global ax
AX = 0
AX += 1
ax = str(AX)
#print(" ax = " + ax)


import winsound #as ws


from time import gmtime, strftime ##define strftime as time/date right now
nowTimeDate2=strftime("%Y %a %b %d %H:%M") ##Capture right now Time/date.

print()
print()
print(" " + nowTimeDate2)
print()

global delayTime
global DelayTime

print()
print()
print(" Enter 0 to test the alarm section.")
delayTime = input(" How many hours to next insulin check? (3) ")
if delayTime == "":
delayTime = 3
DelayTime = int(delayTime)
winsound.MessageBeep(-1)
print()
# =

def Alarm(D):
AX = 0
while D >= 1:
   
d = str(D)
AX += 1
ax = str(AX)
print(' ' + ax, end='...' + "\n")
   
time.sleep(60)
D -= 1

import winsound #as wsBeep
winsound.MessageBeep(1)

def countdown(DelayTime):
import time
t = str(DelayTime)
if t == "1":
   print(" An alarm will start sounding in " + t + " hour...")
else:
   print(" An alarm will start sounding in " + t + " hours...")
   
while DelayTime >= 1:
t = str(DelayTime)
import datetime
from datetime import datetime
from time import gmtime, strftime ##define strftime as time/date right 
now
nowTimeDate2=strftime("%Y %a %b %d %H:%M") ##Capture right now 
Time/date.

Yz=nowTimeDate2[0:4]  
mz=nowTimeDate2[9:12]
dz=nowTimeDate2[13:15]
Hz=nowTimeDate2[16:18]
Mz=nowTimeDate2[19:22]

def month_converter(month): ##convert text month to number
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 
'Sep', 'Oct', 'Nov', 'Dec']
return months.index(month) + 1

mz = month_converter(mz)
Hz = int(Hz)
AmPm = " AM"
if Hz > 12:
Hz = Hz - 12
if Hz == 0:
   Hz = 12
AmPm = " PM"
if Hz == 0:
Hz = 12
AmPm = " AM"

Yz = str(Yz)
mz = str(mz)
dz = str(dz)
Hz = str(Hz)
Mz = str(Mz)

Tz = ("" + mz + "-" + dz + "-" + Yz + " " + Hz + ":" + Mz + AmPm)
print(' ' + t + " " + Tz + "\n")
time.sleep(3600)
DelayTime -= 1
import winsound as wsBeep
wsBeep.MessageBeep(1)
 
print(' More Insuin? \n \n \n \n \n')
Alarm(3)

countdown(DelayTime)


EOB = input(" Strike any key to continue")
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Seeking to convert a py timer app for my Moto E6

2020-07-19 Thread Steve
Interesting "Declaimed"? (-:

I am still trying to see how this system works.  I do not recall receiving
that comment nor do I recall receiving a copy of the original message as I
did with the second one.
Whatever...

That first message did have a suggestion.
I will check it out.
Thanks


FootNote:
If money does not grow on trees, then why do banks have branches?

-Original Message-
From: Python-list  On
Behalf Of Dennis Lee Bieber
Sent: Saturday, July 18, 2020 12:04 PM
To: python-list@python.org
Subject: Re: Seeking to convert a py timer app for my Moto E6

On Sat, 18 Jul 2020 00:32:12 -0400, "Steve"  declaimed
the following:



I have nothing new to add to your inquiry other than to confirm that
I distinctly saw the first time you posted it, about a week ago, and that
you did get a response at that time.

https://groups.google.com/forum/#!topic/comp.lang.python/lCJtqyg0tps


-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/

--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Local access to a file, How To ?

2020-07-28 Thread Steve
 

 

I have a python program that reads and writes to files that are all within
the folder that contains the python program.  There is now a second python
program that is to be run to compile information in said files.

 

I am having difficulty trying to call the local supporting program from
within the main program.  I would it would found easily because everything
is all in the same folder.  Apparently, I have to decipher paths to do the
task.

 

One problem is that the project is portable on a thumb drive and the path
can change based on the computer on which the program is executed.  I look
up use of path and I seem to get all absolute path instruction and not
relative.

 

Where an I steering wrongly here.

 

Steve

 

 

 

 

 

 

 

 

 

 

 

 

Footnote:

In 10 years, are these going to be the "good old times" that we are living
right now?

 

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Local access to a file, How To ?

2020-07-29 Thread Steve
I guess that some things are just too simple to document.  I searched
man-a-site to find this but failed.

 open( "file.in" )

Works exactly as I want.
Thanks.


===
Footnote:
"What rhymes with orange?"
"No it doesn't.."

-Original Message-
From: Python-list  On
Behalf Of DL Neil via Python-list
Sent: Tuesday, July 28, 2020 6:15 PM
To: python-list@python.org
Subject: Re: Local access to a file, How To ?

On 29/07/2020 08:56, Steve wrote:
> I have a python program that reads and writes to files that are all 
> within the folder that contains the python program.  There is now a 
> second python program that is to be run to compile information in said
files.
> 
> I am having difficulty trying to call the local supporting program 
> from within the main program.  I would it would found easily because 
> everything is all in the same folder.  Apparently, I have to decipher 
> paths to do the task.
> 
> One problem is that the project is portable on a thumb drive and the 
> path can change based on the computer on which the program is 
> executed.  I look up use of path and I seem to get all absolute path 
> instruction and not relative.
> 
> Where an I steering wrongly here.


Questions:
- is the second program kept in the same directory as the first, or
somewhere else?
- by "call" do you mean "import", or...


If the program and the data files are in the same directory, then you 
will have noticed that there is no need for absolute addressing, ie

 open( "file.in" )

not

 open( "/home/me/Projets/this/file.in" )

The same applies to import-s. From program_A we can

 import program_B

in the same directory. No need for absolute paths, anywhere!

That is to say, Python works happily with the concept of the "current 
working directory", and when no absolute-path is provided assumes 'this 
directory' - or if a non-absolute-path is provided (doesn't commence 
with "/", in the case of Posix) prefixes the path from 'this directory'. 
Yes, there are many caveats beyond such a simple explanation, but that 
should be enough to get-going. Keeping 'everything' in the single 
directory, and always executing from there, should enable migration.
-- 
Regards =dn
-- 
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Python running in the Command Prompt Window questions

2020-08-02 Thread Steve
When I double click on a .py file, it executes at the command prompt with black 
background and small white font. 

Is there python code to change the font size and background color?

===
FootNote:
Would it be ironic if Popeye’s chicken was fried in Olive Oil?


-- 
https://mail.python.org/mailman/listinfo/python-list


Problems with tool tips...

2020-08-03 Thread Steve


Python/IDLE How do I get rid of the "suggestion" box tool tips that always
blocks the work I need to see when writing code? Do they really have to cram
it right up at the data entry point? Can't it be down in the border and out
of the way?

I don't use it as much as it is interfering with my work. Very distracting.


==
Footnote:
If 666 is considered evil, then technically, 25.8069758 is the root of all
evil.

-- 

-- 
https://mail.python.org/mailman/listinfo/python-list


Updating a variable problem.

2020-08-04 Thread Steve
Why should line 6 fail until line 7 is commented out?
Python complains that MSN is "referenced before assignment".

def ReadTheEQfile():
  global MSN
  MSN = ("1 Monitor") #This line works every time.

def EditTheEQlist():
  print("MSN2 = " + MSN) # Works if the next line is commented out.
  MSN = ("3 Monitor")

# Main()
ReadTheEQfile()
print("MSN1 = " + MSN) # This line works every time
EditTheEQlist()



=
Footnote:
Genie: You have three wishes.
Me: I wish I had more wishes.
Genie: You cannot wish for more wishes.
Me: I wish I could.


-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Updating a variable problem.

2020-08-04 Thread Steve
How is MSN a new variable? It is not intended to be.

If line 8 is commented out, it is printable in all three locations.

If line 8 is not commented out, then MSN in the previous line is determined to 
be undeclared.

It looks as if I am not allowed to change the contents of the variable MSN.

 

FootNote:
If money does not grow on trees, then why do banks have branches?

 

From: Souvik Dutta  
Sent: Tuesday, August 4, 2020 5:12 AM
To: Steve 
Subject: Re: Updating a variable problem.

 

I don't know your exact meaning of fail. But as much as I can say there is a 
new variable MSN being declared in the function that is only seen locally that 
is inside the function. Now python sees this and probably says variable used 
before assigning. You might try declaring a global msn in the function again. 
And then changing msn after the print statement. Also this error occurred 
because python first searches the variable in the local scope which is absent 
earlier and so it searches for the variable in the global scope where it is 
present and so no errors are raised. 

Souvik flutter dev

 

On Tue, Aug 4, 2020, 2:30 PM Steve mailto:Gronicus@sga.ninja> > wrote:

The print statement works in the EditTheEQlist() therefore the variable is seen 
as having been declared.  If I replace the value in the variable in the next 
line then the print statement fails. Is this still a matter of globality?

If it is, how do I fix it?

FootNote:
If money does not grow on trees, then why do banks have branches?

From: Souvik Dutta mailto:souvik.vik...@gmail.com> > 
Sent: Tuesday, August 4, 2020 4:50 AM
To: Steve mailto:Gronicus@sga.ninja> >
Cc: Python List mailto:python-list@python.org> >
Subject: Re: Updating a variable problem.

 Probably because the MSN variable in the second function is not global. 

 On Tue, Aug 4, 2020, 2:08 PM Steve mailto:Gronicus@sga.ninja> > wrote:

Why should line 6 fail until line 7 is commented out?
Python complains that MSN is "referenced before assignment".

def ReadTheEQfile():
  global MSN
  MSN = ("1 Monitor") #This line works every time.

def EditTheEQlist():
  print("MSN2 = " + MSN) # Works if the next line is commented out.
  MSN = ("3 Monitor")

# Main()
ReadTheEQfile()
print("MSN1 = " + MSN) # This line works every time
EditTheEQlist()

=
Footnote:
Genie: You have three wishes.
Me: I wish I had more wishes.
Genie: You cannot wish for more wishes.
Me: I wish I could.


-- 
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Save-to-file code not quite working completely

2020-08-08 Thread Steve


I have a file containing specifications. My .py program can read and
manipulate the data but I cannot seem to get it to update the original file
properly.

The code is simple and works except that the original line remains in the
file after the new updated one has been added.

My code:
===

import fileinput
import sys

def ReplaceLine(file,searchExp,replaceExp):
for line in fileinput.input(file, inplace=1):
   # if searchExp in line:
line = line.replace(searchExp,replaceExp) #.rstrip()
sys.stdout.write(line)

NewLine = "MSN Monitor Serial Number:  1-T4464   ##
\n "
ReplaceLine("Specifications.txt","MSN", NewLine)
print()
PauseHere = input("Paused")
 =
The text file:
1 MSN Monitor Serial Number:  1-T4464 ## 
  Monitor Serial Number:  -T4464  ## 
2 TLN TestStrip Lot Number:   45001 82624  ##
3 SED Strip Expire Date:  2021-02-28  ##
4 SEC Sensor Sequence Code:   68   ##
5 SCN Sensor Code Number: F95  ##
6 SEN Sensor Serial Number:   0M000APJYWM ##
7 SDE Sensor Date to Expire:  2020-12-31   ##
8 SDN Sensor Day Number:  1   ##
9 DTD Data Time Date  Fri Aug 07, 2020 21:30   ##
=
That second line shown was the original line for MSN. The replacement line
should have replaced the original line not just get added to the file.  It
should have been replaced. What is in line 2, should have "1 MSN" at the
beginning but that somehow disappeared.

So close, so simple...
How do I fix this?
Steve

P.S. I read to add ".rstrip()" but that messed things even more...  (-:


===
Footnote:
 logomachist - someone given to disputes over words. logomach.
controversialist, disputant, eristic - a person who disputes; who is good at
or enjoys controversy.





 

-- 
https://mail.python.org/mailman/listinfo/python-list


Mischief Managed: Save-to-file code not quite working completely

2020-08-08 Thread Steve
A simple solution is to know better how the operation works. (-:
I was thinking that the operation would search for the keyword (MSN) and 
replace the line.  Instead of passing the key word, I passed the entire line to 
be replaced and it's correction..

def ReplaceLine(file,searchExp,replaceExp):
for line in fileinput.input(file, inplace=1):
  #if searchExp in line:
line = line.replace(searchExp,replaceExp)
sys.stdout.write(line)

ReplaceLine("Specifications.txt",OldLine, NewLine)


Footnote:
If 666 is evil then
25.8 is the root of all evil.

-Original Message-
From: MRAB  
Sent: Saturday, August 8, 2020 9:08 PM
To: Steve 
Subject: Re: Save-to-file code not quite working completely

On 2020-08-09 00:51, Steve wrote:
> I don't see that. What I do see is that it placing the new string but 
> leaving most of the old one.

That's how the .replace method works. It searches for matches and replaces any 
matched portion(s) with the replacement string. It leaves the rest of the 
string alone.

You told it to replace all occurrences of "MSN" with something else. It did 
that. It didn't make any other changes.

What do you want it to do?

If you want it to replace the line that contains "MSN" with the new line, but 
retain the number, then you need to write code to do that. 
Something like this:

 if searchExp in line:
 # Retain the number from the line.
 line = line.split()[0] + ' ' + replaceExp

> -Original Message-
> From: Python-list  
> On Behalf Of MRAB
> Sent: Saturday, August 8, 2020 6:02 PM
> To: python-list@python.org
> Subject: Re: Save-to-file code not quite working completely
>
> On 2020-08-08 21:51, Steve wrote:
> > 
> > I have a file containing specifications. My .py program can read and 
> > manipulate the data but I cannot seem to get it to update the 
> > original file properly.
> > 
> > The code is simple and works except that the original line remains 
> > in the file after the new updated one has been added.
> > 
> > My code:
> > ===
> > 
> > import fileinput
> > import sys
> > 
> > def ReplaceLine(file,searchExp,replaceExp):
> >  for line in fileinput.input(file, inplace=1):
> > # if searchExp in line:
> >  line = line.replace(searchExp,replaceExp) #.rstrip()
> >  sys.stdout.write(line)
> >  
> > NewLine = "MSN Monitor Serial Number:  1-T4464
> ##
> > \n "
> > ReplaceLine("Specifications.txt","MSN", NewLine)
> > print()
> > PauseHere = input("Paused")
> >   =
> > The text file:
> > 1 MSN Monitor Serial Number:  1-T4464 ##
> >Monitor Serial Number:  -T4464  ##
> > 2 TLN TestStrip Lot Number:   45001 82624  ##
> > 3 SED Strip Expire Date:  2021-02-28  ##
> > 4 SEC Sensor Sequence Code:   68   ##
> > 5 SCN Sensor Code Number: F95  ##
> > 6 SEN Sensor Serial Number:   0M000APJYWM ##
> > 7 SDE Sensor Date to Expire:  2020-12-31   ##
> > 8 SDN Sensor Day Number:  1   ##
> > 9 DTD Data Time Date  Fri Aug 07, 2020 21:30   ##
> > =====
> > That second line shown was the original line for MSN. The 
> > replacement line should have replaced the original line not just get 
> > added to the file.  It should have been replaced. What is in line 2, 
> > should have "1 MSN" at the beginning but that somehow disappeared.
> > 
> > So close, so simple...
> > How do I fix this?
> > Steve
> > 
> > P.S. I read to add ".rstrip()" but that messed things even more...  (-:
> > 
> In the .replace line you're asking it to replace any occurrence of "MSN"
> in the line with a new string.
>
> It's doing that.
>
> I'll add <<...>> around the replacement to make its position clearer:
>
>   >>> line = " 1 MSN Monitor Serial Number:  1-T4464 ##\n"
>   >>> line.replace("MSN", "<##\n >>")
> ' 1 <   >> Monitor Serial Number:  1-T4464 ##'

-- 
https://mail.python.org/mailman/listinfo/python-list


IDLE: New Feature?

2020-08-09 Thread Steve
Where would the conversation have to happen to get the forces-that-be to
install a pull-down/history menu for the Find option in IDLE?  To have to
retype the search option over and over when I am toggling between two or
more searches gets tiresome.  I would rather spend my brain cells and
bandwidth thinking about coding.

Steve


Footnote:
There's 99 bugs in the code, in the code.
99 bugs in the code.
Take one down and patch it all around.
Now there's 117 bugs in the code.

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: IDLE: New Feature?

2020-08-11 Thread Steve
<< Simplest specification:
<< one list for all 3 search boxes;
<< start fresh each session

I do not understand what this means...



Footnote:
The only time "incorrectly" is spelled incorrectly 
is when it is spelled "incorrectly".

-Original Message-
From: Python-list  On
Behalf Of Terry Reedy
Sent: Sunday, August 9, 2020 9:51 PM
To: python-list@python.org
Subject: Re: IDLE: New Feature?

On 8/9/2020 7:39 PM, Steve wrote:
> Where would the conversation have to happen to get the forces-that-be 
> to install a pull-down/history menu for the Find option in IDLE?  To 
> have to retype the search option over and over when I am toggling 
> between two or more searches gets tiresome.  I would rather spend my 
> brain cells and bandwidth thinking about coding.
The IDLE-dev mail list
https://mail.python.org/mailman/listinfo/idle-dev
may or may not be active at any time.

Simplest specification:
one list for all 3 search boxes;
start fresh each session

If search boxes were non-modal, it might work to have two open for same
editor (not sure).

> Footnote:
> There's 99 bugs in the code, in the code.
> 99 bugs in the code.
> Take one down and patch it all around.
> Now there's 117 bugs in the code.

Argh!  I sometimes find a bug fixing a bug, but more often think of multiple
possible improvement when implementing one.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Python Pandas split Date in day month year and hour

2020-08-19 Thread Steve
0   2017-11-01 00:00:00

If you are reading it is as a line into python, then it is a tuple and can be 
parsed accordingly:

   Nb  = YourdataLIne[0:1] #Line Number
   Yr   = YourDataLine[3:7]#Year
   Da  = YourDataLine[9:11]   #Day
   Mo = YourDataLine[13:14] #Month
   Hr   = YourDataLine[16:18]  #hour
   Mn = YourDataLine[20:21]  #minute
   Sc   = YourDataLine[22:23] #second 

Use 
Print ("Year =  " + Yr + ",   Month = " + Mo + ",  Day = " +  Da  + ",   Hour = 
" + Hr)
You may have to adjust the numbers depending on how the line is read.
Is that what you want?


FootNote:
If money does not grow on trees, then why do banks have branches?

-Original Message-
From: Python-list  On Behalf 
Of Brian Oney via Python-list
Sent: Wednesday, August 19, 2020 2:01 PM
To: python-list@python.org
Subject: Re: Python Pandas split Date in day month year and hour



On August 19, 2020 7:32:45 PM GMT+02:00, J Conrado  
wrote:
>
>
>Hi,
>
>
>I'm satarting using Pandas to read excel. I have a meteorological 
>synoptic data and I have for date:
>
>
>0   2017-11-01 00:00:00
>1   2017-11-01 03:00:00
>2   2017-11-01 06:00:00
>3   2017-11-01 09:00:00
>4   2017-11-01 12:00:00
>..  ...
>229 2017-11-30 09:00:00
>230 2017-11-30 12:00:00
>231 2017-11-30 15:00:00
>232 2017-11-30 18:00:00
>233 2017-11-30 21:00:00
>
>
>I would like know how can I get for this array the values for day, 
>month and hour:
>
>2017-11-01 03:00:00   year = 2017  month = 11day = 1and
>hour = 3
>
>From the hip, I would use the strptime function (in the time module?)

time.strptime(string_value, '%F %T')

If I recall correctly, the doc for the specific strings is in the strptime 
function's doc.

This is just a starting point. Good luck! 

HTH
--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


How do I use the data entered in a form?

2020-08-21 Thread Steve
I have a simple form that I copied/modified from a python web site.  A lot
of it makes sense but I do not see how the form in activated.  

Is there some call in there that I am just not seeing?


How do I use the information entered into the  form.  Everything works here
except for line 30 where I get a "fetch not defined" error.  I can send the
entered information to the screen but I do not see how I can use the
information outside the functions defined. 

 Do I need a "return SR, TSR"? 

def Data_Entry(entries):
   SR = (entries['Sensor_Reading'].get())
   print("SR:   ", SR) #This line prints
   TSR = (entries['Test_Strip_Reading'].get())
   print("TSR:  ", TSR)  #This line prints

def SubmitForm(entries):
   print("Form Submitted")
   SR = entries['Sensor_Reading'].get()
   print("SR inside = " + SR)  #This line prints
   
def makeform(root, fields):
   entries = {}
   for field in fields:
  row = Frame(root)
  lab = Label(row, width=22, text=field+": ", anchor='w')
  ent = Entry(row)
  ent.insert(0,"0")
  row.pack(side = TOP, fill = X, padx = 5 , pady = 5)
  lab.pack(side = LEFT)
  ent.pack(side = RIGHT, expand = YES, fill = X)
  entries[field] = ent
   return entries

if __name__ == '__main__':
   root = Tk()
   ents = makeform(root, fields)
  # root.bind('', (lambda event, e = ents: fetch(e)))
   #"fetch not defined" reported here
   b1 = Button(root, text = 'Submit',
  command=(lambda e = ents: SubmitForm(e)))
   b1.pack(side = LEFT, padx = 5, pady = 5)

   b2 = Button(root, text = 'Quit', command = root.quit)
   b2.pack(side = LEFT, padx = 5, pady = 5)
   root.mainloop()

SR = (entries['Sensor_Reading'].get())   
print ("SR Outside = " + SR)

==
The last two lines were guesses but they still failed.

Steve


==

Footnote:
English speakers on a roller coaster: "W"
Spanish speakers on a rollercoaster:  " Nosostros"

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: How do I use the data entered in a form?

2020-08-22 Thread Steve


The only thing I can add to that program as far as errors go is that "SR is
Not Defined" after the program focus is outside of any def in the last line
or two.  Is there any location where I should place "return (SR)" or a
"global SR"?

I take it that "fetch" is not an inside command or reserved word.  The code
is everything what was posted.  Nothing was indicated in the comments that
any code or def was missing.
I commented it out because it was causing the program to dump out preventing
me from exploring the error or developing code for other purposes. Maybe I
don't need it.

Still the value for SR does not seem to be visible outside any of the def
calls. The system reports that "SR is not defined" at the end of the file.

=
Footnote:
If you double major in psychology and reverse psychology, to they cacel each
other out?

-Original Message-
From: Python-list  On
Behalf Of Peter Otten
Sent: Saturday, August 22, 2020 2:26 AM
To: python-list@python.org
Subject: Re: How do I use the data entered in a form?

Steve wrote:

> def makeform(root, fields):
>entries = {}
>for field in fields:
...
>return entries
> 
> if __name__ == '__main__':
>root = Tk()
>ents = makeform(root, fields)

> 
> SR = (entries['Sensor_Reading'].get()) print ("SR Outside = " + SR)
> 
> ==
> The last two lines were guesses but they still failed.

[Always tell us how your code fails, please. If there's an exception include
it and the complete traceback in your post.]

In this case you probably get a NameError because 'entries' is a local
variable in makeform(). In the global namespace the person you copied the
code from used 'ents' -- so you have to either use ents, too,

> if __name__ == '__main__':
>root = Tk()
 ents = makeform(root, fields)
 ...
 SR = ents['Sensor_Reading'].get()


or rename it

> if __name__ == '__main__':
>root = Tk()
 entries = makeform(root, fields)
 ...
 SR = entries['Sensor_Reading'].get()

>  # root.bind('', (lambda event, e = ents: fetch(e)))
>   #"fetch not defined" reported here

Again, the author of the original code probably defined a fetch() function;
if you want to use it you have to copy it into your script.


--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


How do I close a form without closing the entire program?

2020-08-23 Thread Steve
This program is fully operational with the exception of not being able to
close the form when I have completed the data entry. If I have code for a
second form, both remain visible.
Thoughts appreciated


from tkinter import *

def ShowForm1():
  
  fields1 = ('Sensor_Reading', 'Test_Strip_Reading', 'Dose', 'o2')

  def Data_Entry1(entries1):
   SR = (entries['Sensor_Reading'].get())
   TSR = (entries['Test_Strip_Reading'].get())
   Dose = (entries['Dose'].get())
   o2 = (entries['o2'].get())

  def SubmitForm(entries1):
   SR = entries1['Sensor_Reading'].get()
   TSR = entries1['Test_Strip_Reading'].get()
   Dose = (entries1['Dose'].get())
   o2 = (entries1['o2'].get())
   
   FormDataInfo=open("Form1Data.txt", "w") # Start a new file
   FormDataInfo.write("\n" + "   SR = " + SR + "\n")
   FormDataInfo.write("  TSR = " + TSR + "\n")
   FormDataInfo.write(" Dose = " + Dose + "\n")
   FormDataInfo.write("   o2 = " + o2 + "\n")
   FormDataInfo.close()
   print("Line written to file1")
   
  def makeform1(root, fields1):
   entries1 = {}
   for field1 in fields1:
  row = Frame(root)
  lab = Label(row, width=22, text=field1+": ", anchor='w')
  ent = Entry(row)
  ent.insert(0,"0")
  row.pack(side = TOP, fill = X, padx = 5 , pady = 5)
  lab.pack(side = LEFT)
  ent.pack(side = RIGHT, expand = YES, fill = X)
  entries1[field1] = ent
   return entries1

  if __name__ == '__main__':
   root1 = Tk()
   ents = makeform1(root1, fields1)
   
   b1 = Button(root1, text = 'Submit',
  command=(lambda e = ents: SubmitForm(e)))
   b1.pack(side = LEFT, padx = 5, pady = 5)
 
   b2 = Button(root1, text = 'Quit', command = root1.quit)
   b2.pack(side = LEFT, padx = 5, pady = 5)
   root1.mainloop()
# ===
ShowForm1()
print(" End ")
# ===


Steve


Footnote:
The human brain is one of the most complex things known to man.
according to the human brain.

-- 
https://mail.python.org/mailman/listinfo/python-list


How do I place a preset into the text box?

2020-08-28 Thread Steve


The following program compiles but does not quite do what I would like it to
do. Line 19 is the preset information but I do not seem to be able to get it
into the form by code.  My purpose is to let the user make changes without
having to re-enter the entire code.

Suggestions welcome.
Steve

#===
import tkinter as tk
from tkinter import ttk
import sys

window = tk.Tk()
window.title("Python Tkinter Text Box")
window.minsize(600,400)

def Submit():
label.configure(text= 'The new code is: ' + NewCode.get())

def ClickExit():
#This exit closes the program but the form remains and is still active.
# I want only to close the form.
print("Exiting")
sys.exit()

OldCode = ("1234-abcd")

label = ttk.Label(window, text = "Enter the new code")
label.grid(column = 1, row = 1)

NewCode = tk.StringVar()
CodeEntered = ttk.Entry(window, width = 15, textvariable = NewCode)
CodeEntered.grid(column = 2, row = 3)

button = ttk.Button(window, text = "Submit", command = Submit)
button.grid(column= 2, row = 5)

button = ttk.Button(window, text = "Quit", command = ClickExit)
button.grid(column= 2, row = 7)

window.mainloop()

x = (NewCode.get())
print("The new code entered is: " + x)
  
#=



Footnote: 
Mars is the only known planet in our solar system solely inhabited by
functioning robots.


-- 
https://mail.python.org/mailman/listinfo/python-list


RE: How do I place a preset into the text box?

2020-08-28 Thread Steve
Works like a charm, special thanks.
Steve

=

Footnote:
He called his wife to see if he should pick up Fish and Chips on the way
home.  She hung up on him.  She is still fuming over letting him name the
kids.

-Original Message-
From: Python-list  On
Behalf Of Cousin Stanley
Sent: Friday, August 28, 2020 7:47 AM
To: python-list@python.org
Subject: Re: How do I place a preset into the text box?

Steve wrote:

> The following program compiles but does not quite do what I would like 
> it to do. Line 19 is the preset information but I do not seem to be 
> able to get it into the form by code.  My purpose is to let the user 
> make changes without having to re-enter the entire code.
> 

You might consider moving the entry  get()  function into the  Submit()
call back 

def Submit() :

label.configure( text = 'The new code is : ' + NewCode.get() )

x = ( NewCode.get() )

print( "\n  The new code entered is :  " + x )



The following  insert  function will show the OldCode in the  entry  box

 
OldCode = ( "1234-abcd" )

# 

CodeEntered = ttk.Entry( window , width = 15 , textvariable = NewCode )

CodeEntered.grid( column = 2 , row = 3 , pady = 10 )

CodeEntered.insert( 0 , OldCode )


--
Stanley C. Kitching
Human Being
Phoenix, Arizona

--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: How do I place a preset into the text box?

2020-08-28 Thread Steve
Yes, the form/window now closes properly.

Removal of sys.exit() and inserting window.destroy() cleared up the exiting
problem.

 

Thanks.  

I saw several variations on that but I guess I just never twerked it enough.

 

 

Footnote:
"What rhymes with orange?"
"No it doesn't.."

 

From: Colin McPhail  
Sent: Friday, August 28, 2020 7:46 AM
To: Chris Narkiewicz via Python-list 
Cc: Steve 
Subject: Re: How do I place a preset into the text box?

 

Hi Steve,





On 28 Aug 2020, at 11:03, Steve mailto:Gronicus@SGA.Ninja> > wrote:

 


The following program compiles but does not quite do what I would like it to
do. Line 19 is the preset information but I do not seem to be able to get it
into the form by code.  My purpose is to let the user make changes without
having to re-enter the entire code.

 

I'm no Tk expert but does the following do what you want? (Strictly
speaking, the parentheses in ("1234-abcd") are not wrong just unnecessary.)

 

#===

import tkinter as tk

from tkinter import ttk

import sys

 

window = tk.Tk()

window.title("Python Tkinter Text Box")

window.minsize(600,400)

 

def Submit():

   label.configure(text= 'The new code is: ' + NewCode.get())

 

def ClickExit():

   #This exit closes the program but the form remains and is still active.

   # I want only to close the form.

   print("Exiting")

   #sys.exit()

   window.destroy()

 

#OldCode = ("1234-abcd")

OldCode = "1234-abcd"

 

label = ttk.Label(window, text = "Enter the new code")

label.grid(column = 1, row = 1)

 

#NewCode = tk.StringVar()

NewCode = tk.StringVar(value=OldCode)

 

CodeEntered = ttk.Entry(window, width = 15, textvariable = NewCode)

CodeEntered.grid(column = 2, row = 3)

 

button = ttk.Button(window, text = "Submit", command = Submit)

button.grid(column= 2, row = 5)

 

button = ttk.Button(window, text = "Quit", command = ClickExit)

button.grid(column= 2, row = 7)

 

window.mainloop()

 

x = (NewCode.get())

print("The new code entered is: " + x)

 

#=

 

Regards,

Colin

 

-- 
https://mail.python.org/mailman/listinfo/python-list


Problem running a FOR loop

2020-08-30 Thread Steve
Compiles, no syntax errors however, line 82 seems to run only once when the
FOR loop has completed.
Why is that?  All fields are to contain the specifications, not just the
last one.

Steve

--
ThisList = ["start"]

#===
def FillTheList():
   x=0
   ThisList = []
   with open("Specifications.txt", 'r') as infile:
 for lineEQN in infile: # loop to find each line in the file for that
dose
 if lineEQN[0:1] == "-":
   ListItem = lineEQN[1:6].strip()
   ThisList.append(ListItem)

   return(ThisList)

#

def EditDataByForm():

import tkinter as tk
from tkinter import ttk
import sys

window = tk.Tk()

window.title("Python Tkinter Text Box")
window.minsize(700,700) #height, width

#===
def GetLineByItem(DataType):  #get line by item in column 3 - 5
#print("DataType = " + DataType)
DataLetter = DataType[0:1]

if DataLetter.isupper(): # == "Specs":
FileToBeEdited = "Specifications.txt"
else:
FileToBeEdited = "DataSpecifications.txt"

with open(FileToBeEdited, 'r') as infile:
 for lineEQN in infile: # loop to find each line in the file for
that dose
   if ((lineEQN[1:2]== DataLetter)):
   A = lineEQN[1:46]# Whole Line
   a = lineEQN[34:46].strip()   # Just the Data
   # print("A = " + A )
   # print("a = " + a)
  
return(A, a)

#===

def ClickSubmit():
window.destroy()
#===

label = ttk.Label(window, text = "Enter the new readings")
label.grid(column = 1, row = 1)
 
ThisList = FillTheList()
x = 3  # Allows for two rows at the top of the form used for headers
y = 0  # Scans the datafile to fill the list

for lineItem in range(len(ThisList)):

 SpecLine, Spec = GetLineByItem(ThisList[y])
 OldSpec = Spec
 #print("OldSpec = " + OldSpec)
 NewSpec = " "

 SVRlabel = ttk.Label(window, text = SpecLine + "  "*5)
 SVRlabel.grid(column = 1, row = x)
 
 NewSpec = tk.StringVar()
 SVRCodeEntered = ttk.Entry(window, width = 15, textvariable =
NewSpec)
 SVRCodeEntered.grid(column = 2, row = x, pady = 15)

 print("x , y = " + str(x) + ", " + str(y))
 
 print("OldSpec2 = <" + OldSpec + "> ") #Use of <> show spaces if
any

 #81 The next line seems to run only once at the end of the FOR loop
<<<<<<<<<<<<<<
 SVRCodeEntered.insert(0, OldSpec)

 SVRCodeEntered.focus_set()

 x += 1 
 y += 1
#===
button = ttk.Button(window, text = "Submit", command = ClickSubmit)
button.grid(column= 2, row = 15)

window.mainloop()  
--
Specifications.txt.  This will align when using Notepad++.

A LTD Last Time Date  2020-08-29 00:55:18.610102   ##   
 B LDL Last Dose Line  2020-08-29 00:55:18.610102   ##   
 C LLL Last LTD line   2020-08-29 00:55:18.610102   ##   
 D LTD Last Time Date  2020-08-29 00:55:18.610102   ##   
 -
-E MSN Monitor Serial Number   JNGY263-T4464##   
 -
-F TSL TestStrip Lot Number45001 82990  ##   
-G SED Strip Expire Date   2021-05-31   ##   
 -
-H SSC Sensor Sequence Code71   ##   
-I SCN Sensor Code Number  G03  ##   
-J SSN Sensor Serial Number2021-01-31   ##   
-K SDE Sensor Date to Expire   2021-01-31   ##   
-L SDN Sensor Day Number   12##   
-M FDS First Date for Sensor   Fri Aug 17, 2020 09:34   ##
 -
-N IDT Insulin Dose Total  450  ##

 O DTD Data Time Date  Fri Aug 07, 2020 21:30   ##   
 P PTD Previous Time Date  Thu Nov 27, 1952 14:30   ##   
 -
 Q HL1 Half Life 1 1##

 R HL2 Half LIfe 2 2##   
 S HL

RE: Problem running a FOR loop

2020-08-30 Thread Steve
Yes, that first option worked.
Special thanks...
Steve
===

Footnote:
If 666 is considered evil, then technically, 25.8069758 is the root of all
evil.

-Original Message-
From: Python-list  On
Behalf Of Peter Otten
Sent: Sunday, August 30, 2020 5:29 AM
To: python-list@python.org
Subject: Re: Problem running a FOR loop

Steve wrote:

> Compiles, no syntax errors however, line 82 seems to run only once 
> when the FOR loop has completed.
> Why is that?  All fields are to contain the specifications, not just 
> the last one.

It seems that passing the StringVar to the Entry widget is not sufficient to
keep it alive.

> for lineItem in range(len(ThisList)):

>  NewSpec = tk.StringVar()
>  SVRCodeEntered = ttk.Entry(window, width = 15, textvariable =
> NewSpec)

When the previous NewSpec is overwritten with the current one the previous
gets garbage-collected and its value is lost. 

The straight-forward fix is to introduce a list:

  new_specs = []
> for lineItem in range(len(ThisList)):

>  NewSpec = tk.StringVar()
   new_specs.append(NewSpec)
>  SVRCodeEntered = ttk.Entry(window, width = 15, textvariable =
> NewSpec)

Another option is to store the StringVar as an attribute of the Entry:

> for lineItem in range(len(ThisList)):

>  NewSpec = tk.StringVar()
>  SVRCodeEntered = ttk.Entry(window, width = 15, textvariable =
> NewSpec)
   SVRCodeEntered.new_spec = NewSpec


--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


How do I left-justify the information in the labels?

2020-08-30 Thread Steve
for lineItem in range(len(ThisList)):

 SpecLine, Spec = GetLineByItem(ThisList[y])
 OldSpec = Spec
 NewSpec = " "

 SVRlabel = ttk.Label(window, text = SpecLine + "  "*5)
 SVRlabel.grid(column = 1, row = x)
 
 NewSpec = tk.StringVar()
 New_Specs.append(NewSpec)
 SVRCodeEntered = ttk.Entry(window, width = 15, textvariable =
NewSpec)
 SVRCodeEntered.grid(column = 2, row = x, pady = 15)
 SVRCodeEntered.insert(0, OldSpec)
 x += 1 
     y += 1

Steve



Footnote:
Some mornings it just isn't worth chewing through the leather straps.

- 

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: How do I left-justify the information in the labels?

2020-08-30 Thread Steve
It turned out to be "sticky=tk.W" instead of "sticky=tkinter.w"
Probably because I have   "import tkinter as tk"
It does work though.

Mischief Managed
Steve


FootNote:
If money does not grow on trees, then why do banks have branches?

-Original Message-
From: Python-list  On
Behalf Of Peter Otten
Sent: Sunday, August 30, 2020 10:32 AM
To: python-list@python.org
Subject: Re: How do I left-justify the information in the labels?

Steve wrote:

> How do I left-justify the information in the labels?

>  SVRlabel = ttk.Label(window, text = SpecLine + "  "*5)
>  SVRlabel.grid(column = 1, row = x)

The text in the labels already is left-justified -- but the labels
themselves are centered inside the grid cells.

You can change that with

label = ttk.Label(window, text=SpecLine) label.grid(column=1, row=x,
sticky=tkinter.W)  # W for "west"

See https://tkdocs.com/shipman/grid.html.

--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


How do I pull the updated information from a tkinter form?

2020-08-30 Thread Steve
#  With this program, I can read the information from
#  Specifications.txt file and display it on a form.
#  The user can then update/modify the fields. This is
#  all working fine and beeautifully...
#  
#  I now need to reverse the process and replace the
#  adjusted lines of data back into the Specifications.txt
#  file.  Fortunately, that code has already been
#  written .

#  What I cannot seem to do is to pull the adjusted
#  information from the form into variables, or a
#  list/array, so that can be used for the update to the file.

#  Suggestions for what to look up to study this
#  through will help.
#
#  Thank you
#  Steve
# ---

import tkinter as tk
from tkinter import ttk
import sys

ThisList = ["start"]

#===
def FillTheList():
   x=0
   ThisList = []
   with open("Specifications.txt", 'r') as infile:
 for lineEQN in infile: # loop to find each line in the file for that
dose
 if lineEQN[0:1] == "-": # Lines with "-" in space 1 have special
recognition for this form
   ListItem = lineEQN[1:6].strip() # Remove any spaces before and
after
   ThisList.append(ListItem) #Add the ListItem to ThisList
   return(ThisList)

#

def EditDataByForm():
window = tk.Tk()
window.title("Python Tkinter Text Box")
window.minsize(700,700) #height, width

#===
def GetLineByItem(DataType):  #get line by item in column 3 - 5
#print("DataType = " + DataType)
DataLetter = DataType[0:1] #Capture item letter ID for file check

if DataLetter.isupper(): # == "Specs":
FileToBeEdited = "Specifications.txt"
else:
FileToBeEdited = "DataSpecifications.txt"

with open(FileToBeEdited, 'r') as infile:
 for lineEQN in infile: # loop to find each line in the file for
that dose
   if ((lineEQN[1:2]== DataLetter)):
   A = lineEQN[1:46]# Whole Line
   a = lineEQN[34:46].strip()   # Just the Data
   # print("A = " + A )
   # print("a = " + a)
  
return(A, a) #Return the line and Data separately

#===
def ClickSubmit():
window.destroy()
#===

label = ttk.Label(window, text = "Enter the new readings")
label.grid(column = 1, row = 1)
 
ThisList = FillTheList()
x = 3  # Allows for two rows at the top of the form used for headers
y = 0  # Scans the datafile to fill the list

New_Specs = []
#SpecsToUpdate = []

for lineItem in range(len(ThisList)):

 SpecLine, Spec = GetLineByItem(ThisList[y])
 OldSpec = Spec
 NewSpec = " "

 SVRlabel = ttk.Label(window, text = SpecLine + "  "*5)
 SVRlabel.grid(column = 1, row = x,  sticky=tk.W)

 NewSpec = tk.StringVar()
 New_Specs.append(NewSpec)
 SVRCodeEntered = ttk.Entry(window, width = 15, textvariable =
NewSpec)
 
 SVRCodeEntered.grid(column = 2, row = x, pady = 15, sticky=tk.W)
 SVRCodeEntered.insert(0, OldSpec)
 x += 1 
 y += 1

#===
button = ttk.Button(window, text = "Submit", command = ClickSubmit)
button.grid(column= 2, row = 15)
window.mainloop()  
#===

EditDataByForm()
print ("Done")
#  Code needed to pull the updated fields from the form
#  as variables or in a list/array.  Once I have that, the code to replace 
#  code in the specifications.txt file has already been written.

#  Here is a sample of the Specifications.txt file:

---
-E MSN Monitor Serial Number   JNGY263-T4464##   
 -
-F TSL TestStrip Lot Number45001 82990  ##   
-G SED Strip Expire Date   2021-05-31   ##   
 -
-H SSC Sensor Sequence Code71   ##   
-I SCN Sensor Code Number  G03  ##   
-J SSN Sensor Serial Number2021-01-31   ##   
-K SDE Sensor Date to Expire   2021-01-31   ##   
-L SDN 

RE: How do I pull the updated information from a tkinter form?

2020-08-30 Thread Steve
OK, I was closer than I thought.

Two weeks ago, the concept of tkinter and these forms were totally new to me
as well as, about  two days ago, python list was totally new too. I somehow
thought that "window.mainloop()" was supposed to be the last entry in the
function, silly me...
I did not think of returning the list.

Thank you, now it is back for another 30 hours of continuous programming...
(:
Steve


Footnote:
"What rhymes with orange?"
"No it doesn't.."

-Original Message-
From: Python-list  On
Behalf Of Peter Otten
Sent: Sunday, August 30, 2020 1:55 PM
To: python-list@python.org
Subject: Re: How do I pull the updated information from a tkinter form?

Steve wrote:

> #What I cannot seem to do is to pull the adjusted #information from 
> the form into variables, or a #list/array, so that can be used for the 
> update to the file.

The updated data is in the StringVar-s, which, fortunately, you have
available in a list ;)

So:

> def EditDataByForm():
[...]
> window.mainloop()
  return [spec.get() for spec in New_Specs]

  print(EditDataByForm())
> print ("Done")


--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: How do I pull the updated information from a tkinter form?

2020-08-31 Thread Steve
At least it is working and lets me continue to develop the overall program.
I am working on the option to cancel the update if the user wants.

Since I do not know of a better way, is it not the best at the moment? (-:

My original design to edit the specifications by form was approaching 200
lines of code.  With the loops, probably now is 75.


Steve


FootNote:
If money does not grow on trees, then why do banks have branches?

-Original Message-
From: Python-list  On
Behalf Of Peter Otten
Sent: Monday, August 31, 2020 3:56 AM
To: python-list@python.org
Subject: RE: How do I pull the updated information from a tkinter form?

Steve wrote:

> OK, I was closer than I thought.
> 
> Two weeks ago, the concept of tkinter and these forms were totally new 
> to me as well as, about  two days ago, python list was totally new 
> too. I somehow thought that "window.mainloop()" was supposed to be the 
> last entry in the function, silly me...
> I did not think of returning the list.

Note that what I showed is probably not the best option.

Usually you would add a button that allows the user to trigger the write
operation.

--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


What kind of magic do I need to get python to talk to Excel xlsm file?

2020-09-01 Thread Steve
Glutton for punishment, I am looking into designing another .py program.  I
would like to pull two columns of information from Excel but the more I look
into coding on the 'net, the more confusing it looks.  I don't understand
what I need to import or install to get the link.

Steve




Footnote:
Some mornings it just isn't worth chewing through the leather straps.

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: What kind of magic do I need to get python to talk to Excel xlsm file?

2020-09-01 Thread Steve
Ok, I think I ran into this about a year ago when this was suggested back then.

I entered “pip install pandas”

I am told to “install Anaconda which can be deleted later”   (huh?)
Then it tells me “Installing with “Miniconda” (huh? Huh?)
Then “Installing from PyPl which is what I used to get the same page that is 
telling me all this…

ActivePython, then finally Linux which I am not using.

 

Ok, then I see:

Installing from source

See the contributing guide for complete instructions on building from the git 
source tree. Further, see creating a development environment if you wish to 
create a pandas development environment.

 

And the music goes round and round…..

 

 

 

 

FootNote:
If money does not grow on trees, then why do banks have branches?

 

From: Jeffrey Powell  
Sent: Tuesday, September 1, 2020 5:33 AM
To: Steve 
Subject: Re: What kind of magic do I need to get python to talk to Excel xlsm 
file?

 

Hi Steve,

 

Yes, you need to install pandas first.  I use pip install pandas


Kind regards,

Jeffrey Powell 

 

On Tue, 1 Sep 2020, 11:15 Steve, mailto:Gronicus@sga.ninja> > wrote:

ModuleNotFoundError: No module named 'pandas'

 

I take it that this is an installation.
Is there anything I need to know about this first?

 

Steve

 

 

FootNote:
If money does not grow on trees, then why do banks have branches?

 

From: Jeffrey Powell mailto:jparkerpow...@gmail.com> 
> 
Sent: Tuesday, September 1, 2020 4:30 AM
To: Steve mailto:Gronicus@sga.ninja> >
Subject: Re: What kind of magic do I need to get python to talk to Excel xlsm 
file?

 

Hi Steve,

 

Maybe something like this:

 

import pandas as pd

dt = pd.read_excel("myData.xls", sheet_name="mySheetName", skiprows=0, 
usecols=list(range(0,11)))

 

where usecols are the column numbers you want.

 

Kind regards,

Jeff

 

 

 

On Tue, Sep 1, 2020 at 10:24 AM Steve mailto:Gronicus@sga.ninja> > wrote:

Glutton for punishment, I am looking into designing another .py program.  I
would like to pull two columns of information from Excel but the more I look
into coding on the 'net, the more confusing it looks.  I don't understand
what I need to import or install to get the link.

Steve




Footnote:
Some mornings it just isn't worth chewing through the leather straps.

-- 
https://mail.python.org/mailman/listinfo/python-list




 

-- 

Jeffrey Powell, PhD.  Senior Data Scientist, Dataworkz.nl

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: What kind of magic do I need to get python to talk to Excel xlsm file?

2020-09-01 Thread Steve
Wow, that is quite a list
Here is what I narrowed it down to. What does that paragraph starting with 
"Requires" mean?

===
Pandas: a cross-section and time series data analysis toolkit.

Requires numpy, dateutil, pytz, setuptools, and optionally numexpr, bottleneck, 
scipy, matplotlib, pytables, lxml, xarray, blosc, snappy, brotlipy, 
backports.lzma, statsmodels, sqlalchemy, psycopg2, and whatnot.

pandas‑1.1.1‑cp39‑cp39‑win_amd64.whl


Footnote: 
Mars is the only known planet in our solar system solely inhabited by 
functioning robots.

-Original Message-
From: Python-list  On Behalf 
Of Chris Angelico
Sent: Tuesday, September 1, 2020 4:44 PM
To: Python 
Subject: Re: What kind of magic do I need to get python to talk to Excel xlsm 
file?

On Wed, Sep 2, 2020 at 6:17 AM Steve  wrote:
>
> Ok, I think I ran into this about a year ago when this was suggested back 
> then.
>
> I entered “pip install pandas”
>
> I am told to “install Anaconda which can be deleted later”   (huh?)
> Then it tells me “Installing with “Miniconda” (huh? Huh?) Then 
> “Installing from PyPl which is what I used to get the same page that 
> is telling me all this…
>
> ActivePython, then finally Linux which I am not using.
>

You're on Windows? Get your pandas here:

https://www.lfd.uci.edu/~gohlke/pythonlibs/

ChrisA
--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: What kind of magic do I need to get python to talk to Excel xlsm file?

2020-09-01 Thread Steve
>> Requires numpy, dateutil, pytz, setuptools, and optionally numexpr, 
>> bottleneck, scipy, matplotlib, pytables, lxml, xarray, blosc, snappy, 
>> brotlipy, backports.lzma, statsmodels, sqlalchemy, psycopg2, and whatnot.

>It means you need all those things installed before you can install Pandas.

If that is the case, then it is just not worth it.  However, I am seeing it 
more as a poorly constructed sentence.

How about:

>> Requires numpy, dateutil, pytz, setuptools , 
and optionally:  
numexpr, bottleneck, scipy, matplotlib, pytables, lxml, xarray, blosc, snappy, 
brotlipy, backports.lzma, statsmodels, sqlalchemy, psycopg2, and whatnot.

Does it suggest that the first four are required and the rest are optional?
Even then, it is still ambiguous.



FootNote:
If money does not grow on trees, then why do banks have branches?

-Original Message-
From: Chris Angelico  
Sent: Tuesday, September 1, 2020 5:08 PM
To: Steve 
Cc: Python 
Subject: Re: What kind of magic do I need to get python to talk to Excel xlsm 
file?

On Wed, Sep 2, 2020 at 6:59 AM Steve  wrote:
>
> Wow, that is quite a list
> Here is what I narrowed it down to. What does that paragraph starting with 
> "Requires" mean?
>
> ===
> Pandas: a cross-section and time series data analysis toolkit.
>
> Requires numpy, dateutil, pytz, setuptools, and optionally numexpr, 
> bottleneck, scipy, matplotlib, pytables, lxml, xarray, blosc, snappy, 
> brotlipy, backports.lzma, statsmodels, sqlalchemy, psycopg2, and whatnot.
>

It means you need all those things installed before you can install Pandas.

ChrisA

-- 
https://mail.python.org/mailman/listinfo/python-list


tinker Form question(s)

2020-09-07 Thread Steve
I am not sure how to post the code for my file here, is copy/paste the best
way? Is there another? I understand that attachments are stripped off.

"""
The following segment of code returns values of "spec".
I would like to have it return the associated value of
"DataLine" with each spec. It would also be nice to understand 
how this code works to hold/return the information.

In pseudocode, a line something like:

DataReturned = DataLine + " " + spec)
New_Specs.append(DataReturned)

explains what I would like to have returned.


"""
 New_Specs = []
 OldSpec = ItemID 
 NewSpec = " "
 OldLine = ItemID
 x = 3
 y = 0
 
 for lineItem in range(len(ThisList)):
 DataLine, Spec = GetLineByItem(ThisList[y])
 
 SVRlabel = ttk.Label(window, width = BoxWidth1, text = DataLine)
 SVRlabel.grid(column = 1, row = x,  sticky=tk.W)
 
 SVRlabel = ttk.Label(window, width = BoxWidth2, text = Spec)
 SVRlabel.grid(column = 2, row = x)

 NewSpec = tk.StringVar()
 New_Specs.append(NewSpec)
  
 SVRCodeEntered = ttk.Entry(window, width = BoxWidth3, textvariable
= NewSpec)
 SVRlabel = ttk.Entry(window, width = BoxWidth3, textvariable =
NewSpec)

 SVRlabel.grid(column = 3, row = x, pady = 5, sticky=tk.W)
 
 SVRCodeEntered.grid(column = 3, row = x, pady = 5, padx = 15,
sticky=tk.W)
 SVRCodeEntered.insert(0, OldSpec)
 
 x += 1 
 y += 1    

 return ([spec.get()for spec in New_Specs])

==
Steve
=
Footnote:
Some mornings it just isn't worth chewing through the leather straps.


-- 
https://mail.python.org/mailman/listinfo/python-list


Audacity and pipe_test.py

2020-09-09 Thread Steve
I am trying to adapt this short file to be used for simple control of the
Audacity audio recording program.
I can get the following does to work:
   do_command("Record1stChoice")  #Creates a new track and starts
recording
do_command("AddLabel:")  #Places a label in the label track
do_command("Stop") # stops the recording

But not this one:
do_command("SetLabel:Label='1' Text='Hello' ")

This is supposed to place "Hello" into the label.
Steve


Foonote:
The patient shall strive to suffer the symptoms of the disease that has been
diagnosed by the doctor.


-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Audacity and pipe_test.py

2020-09-10 Thread Steve
I used the line you supplied but trying it again, I began to solve the
problem through a series of accidents and errors. As it is, apparently the
Pipe_Test.py has some peculiar features.

>The first is that it will not tell you anything about errors, even whether
or not there is one.
>The commands are space-delimited so Text=Hello is not the same as Text =
Hello even if you have the quotes.
>It tolerates no variables. Label=X, if you have X in a loop, will always
have the value of text X and not a changing number.  As a matter of fact,
since Label has to have a numeric value, and seeing X will place the value
of label to be the default of 0.

So, yes, placing the 1 in the line and no spaces, it worked. I was able to
send text to the Label.

One thing I would really appreciate is getting the line as follows to work:
 do_command("SetLabel:Label=T Text=ThisList[T] ")
which it a total violation of what I described previously. (-:

The object is to pull the text out of ThisList and increment by looping on T
to populate the labels.

Unfortunately, road bump may well put the kibosh on my project
But I can dream, can't I?






FootNote:
If money does not grow on trees, then why do banks have branches?

-Original Message-
From: Python-list  On
Behalf Of Dennis Lee Bieber
Sent: Wednesday, September 9, 2020 11:17 AM
To: python-list@python.org
Subject: Re: Audacity and pipe_test.py

On Wed, 9 Sep 2020 03:12:59 -0400, "Steve"  declaimed
the following:


>But not this one:
>do_command("SetLabel:Label='1' Text='Hello' ")
>
>This is supposed to place "Hello" into the label.

As I interpret
https://manual.audacityteam.org/man/scripting.html#Using_Scripting the label
is identified by an integer, not a string. Try

do_command("SetLabel: Label=1 Text='Hello'")


-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/

--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Audacity and pipe_test.py

2020-09-10 Thread Steve


Yes, certainly loving the progress now...
Great learning curve.

Your line worked except that I used copy/paste to place it in the program.
I kept on getting something like "improper indentation or tab" and pointing
to the end of that line.  I guess hidden characters were imbedded and when I
deleted all spaces before and after the paste, then placed them in again,
those hiddens went away.

Also, this language certainly does not like spaces at all except where IT
wants them. The values for ThisList[T] entries were two words, words with
spaces between. No go  I removed spaces and replaced them with - where I
wanted them, and it is working really nicely.

My time.sleep(60) or the do_command("'Start Time'=0, 'End Time'=150")  lines
do not seem to work unless they are immediately after the Record1stChoice
instruction.  This means that placement of the labels happen after the track
is recorded and before the recording is stopped.  I can live with that

Now I am going to see if I can name the label track and the recording
Track...

Steve





FootNote:
If money does not grow on trees, then why do banks have branches?

-Original Message-
From: Python-list  On
Behalf Of Dennis Lee Bieber
Sent: Thursday, September 10, 2020 1:51 PM
To: python-list@python.org
Subject: Re: Audacity and pipe_test.py


CORRECTION

On Thu, 10 Sep 2020 03:55:46 -0400, "Steve"  declaimed
the following:


>One thing I would really appreciate is getting the line as follows to work:
> do_command("SetLabel:Label=T Text=ThisList[T] ") which it a total 
>violation of what I described previously. (-:

Forgot the ' quotes...

do_command("SetLabel:Label=%s Text='%s'" % (T, ThisList[T]))



-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/

--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Audacity and pipe_test.py

2020-09-10 Thread Steve
PS: and YES I got the track name to happen.
Sooo cool

=
Yes, certainly loving the progress now...
Great learning curve.

Your line worked except that I used copy/paste to place it in the program.
I kept on getting something like "improper indentation or tab" and pointing
to the end of that line.  I guess hidden characters were imbedded and when I
deleted all spaces before and after the paste, then placed them in again,
those hiddens went away.

Also, this language certainly does not like spaces at all except where IT
wants them. The values for ThisList[T] entries were two words, words with
spaces between. No go  I removed spaces and replaced them with - where I
wanted them, and it is working really nicely.

My time.sleep(60) or the do_command("'Start Time'=0, 'End Time'=150")  lines
do not seem to work unless they are immediately after the Record1stChoice
instruction.  This means that placement of the labels happen after the track
is recorded and before the recording is stopped.  I can live with that

Now I am going to see if I can name the label track and the recording
Track...

Steve





FootNote:
If money does not grow on trees, then why do banks have branches?

-Original Message-
From: Python-list  On
Behalf Of Dennis Lee Bieber
Sent: Thursday, September 10, 2020 1:51 PM
To: python-list@python.org
Subject: Re: Audacity and pipe_test.py


CORRECTION

On Thu, 10 Sep 2020 03:55:46 -0400, "Steve"  declaimed
the following:


>One thing I would really appreciate is getting the line as follows to work:
> do_command("SetLabel:Label=T Text=ThisList[T] ") which it a total 
>violation of what I described previously. (-:

Forgot the ' quotes...

do_command("SetLabel:Label=%s Text='%s'" % (T, ThisList[T]))



-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/

--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Difficulty getting started with Pipeclient.py

2020-09-10 Thread Steve
I downloaded the software and have been given a few test commands to use.
When I run it as it is, I get the request to enter the commands manually and
they work.

I do not see how to get the commands to work automatically. Somehow, I have
to bypass the "Enter command or 'Q' to quit"
How do I do this? Is it a batch file?

Commands given:
SelectTime:End="5" RelativeTo="ProjectStart" Start="5"
AddLabel:
SetLabel:Label="0" Text="Hello"
SelectTime:End="16" RelativeTo="ProjectStart" Start="15"
AddLabel:
SetLabel:Label="1" Text="World"  


==

Footnote:]
So a priest, a minister, and a rabbit walk into a bar and seat themselves at
the counter. The priest orders wine and the minister a glass of water. The
bartender turns to the rabbit and asks, "So what'll you have?"
"I dunno," the rabbit says with a shrug, "I'm only here because of
autocorrect."


-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Audacity and pipe_test.py

2020-09-12 Thread Steve
>>My time.sleep(60) or the do_command("'Start Time'=0, 'End Time'=150")  
>>lines

>   The first does nothing for Audacity processing -- it only blocks the
>Python script itself. And you haven't provided the Audacity command
>completely -- since I can't find that on the script reference page.

You are correct.  I use the py timer to pause the commands being sent to the
pipe.  There seems to be something fluky about that too.  It looks as if
when I have four or more do_commands, it doesn't run as a timer.  Takes more
scrutiny...

I am not sure how I lost the entire Audacity command for the Audacity time
control. Still, I need a timer in there somewhere. 
Time will tell (-:

"ENDIF, ENDFOR, ENDWHILE statements" do exist in my python program.  I place
them as comments to document the end of the operations. It makes it easier
for me to follow the logic especially if they are nested.

-Original Message-
From: Python-list  On
Behalf Of Dennis Lee Bieber
Sent: Friday, September 11, 2020 1:32 PM
To: python-list@python.org
Subject: Re: Audacity and pipe_test.py

On Thu, 10 Sep 2020 18:22:29 -0400, "Steve"  declaimed
the following:

>Your line worked except that I used copy/paste to place it in the program.
>I kept on getting something like "improper indentation or tab" and 
>pointing to the end of that line.  I guess hidden characters were 
>imbedded and when I deleted all spaces before and after the paste, then 
>placed them in again, those hiddens went away.
>
Most likely your source had a series of spaces, my post had a
leading .

In Python, a  is counted as EIGHT spaces, even if an editor
only moved in by four spaces.

Python uses indentation to indicate the block structure of the
language
-- you'll note there are no { } (C or Java), nor ENDIF, ENDFOR, ENDWHILE
statements.

>Also, this language certainly does not like spaces at all except where 
>IT wants them. The values for ThisList[T] entries were two words, words 
>with spaces between. No go  I removed spaces and replaced them with 
>- where I wanted them, and it is working really nicely.
>

If this is in response to my /first/ post, I forgot to include the '
'
delimiters around the string argument. That meant the command you were
sending to Audacity was seeing three or more parameters, not two. Python
didn't care at that point. If you have the ' ' in place, then Audacity is
the application that is complaining.

>My time.sleep(60) or the do_command("'Start Time'=0, 'End Time'=150")  
>lines

The first does nothing for Audacity processing -- it only blocks the
Python script itself. And you haven't provided the Audacity command
completely -- since I can't find that on the script reference page.



-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/

--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Audacity and pipe_test.py

2020-09-13 Thread Steve
"There is no promise on time.sleep() that the program will restart exactly
when the time expires."

No precision needed, +- two minutes is acceptable, even three..  In my
tests, I see scarcely three seconds difference.  No problem.

As for ENDIF, ENDWHILE, 
"But they have no syntactic meaning, and may get out of sync with the
indentation."

Being comments, will have no effect of indents. I use them strictly to see
the structure and usually for long segments of code only.






-Original Message-
From: Python-list  On
Behalf Of Dennis Lee Bieber
Sent: Sunday, September 13, 2020 3:06 PM
To: python-list@python.org
Subject: Re: Audacity and pipe_test.py

On Sat, 12 Sep 2020 14:23:25 -0400, "Steve"  declaimed
the following:

>
>You are correct.  I use the py timer to pause the commands being sent 
>to the pipe.  There seems to be something fluky about that too.  It 
>looks as if when I have four or more do_commands, it doesn't run as a 
>timer.  Takes more scrutiny...

time.sleep() is not a "timer" per se. In most implementations it is
a blocking call to the operating system; the OS suspends the task and gives
the CPU to another task until the requested delay expires, after which the
task is placed onto the "ready queue" to /eventually/ continue running. In a
system with lots of high priority tasks, that "eventually" could be a long
time.

There is no promise on time.sleep() that the program will restart
exactly when the time expires.

>"ENDIF, ENDFOR, ENDWHILE statements" do exist in my python program.  I 
>place them as comments to document the end of the operations. It makes 
>it easier for me to follow the logic especially if they are nested.

But they have no syntactic meaning, and may get out of sync with the
indentation.


-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/

--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Audacity and pipe_test.py

2020-09-13 Thread Steve
" The problem is that since they're comments, the compiler can't warn you
when there's a mistake.  After the code has been edited a few times, they
will end up being wrong and misleading."

If that is the case, then I would suspect that you are doing it incorrectly.
It works especially well for me.  It goes a long way to help with indents.
It also prevents a lot of excessive scrolling.

I do something similar with HTML.  A comment at the end of a data structure
that explains the purpose of the DS is extremely helpful.





-Original Message-
From: Python-list  On
Behalf Of Grant Edwards
Sent: Sunday, September 13, 2020 9:41 PM
To: python-list@python.org
Subject: Re: Audacity and pipe_test.py

On 2020-09-13, Steve  wrote:
> "There is no promise on time.sleep() that the program will restart 
> exactly when the time expires."
>
> No precision needed, +- two minutes is acceptable, even three..  In my 
> tests, I see scarcely three seconds difference.  No problem.
>
> As for ENDIF, ENDWHILE,
> "But they have no syntactic meaning, and may get out of sync with the 
> indentation."
>
> Being comments, will have no effect of indents.

Exactly. That's the problem.

> I use them strictly to see the structure and usually for long segments 
> of code only.

The problem is that since they're comments, the compiler can't warn you when
there's a mistake.  After the code has been edited a few times, they will
end up being wrong and misleading.

If you can't see the structure of the code by looking at the code, then
you're doing something wrong.  Fix the code (or use a better editor). Adding
comments to try to clarify the flow of poorly structured code just ends up
making the problem worse later on when the comments are wrong.  And they
will end up being wrong.








--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Problem saving datetime to file and reading it back for a calculation

2020-10-10 Thread Steve
I would like to use the line:
HoursDiff = int((d2-d1).total_seconds()/3600)
to determine the difference in hours between two timedate entries.

The variable d2 is from datetime.now()
and d1 is read from a text file.

I can save d2 to the file only if I convert it to string and, at a later
date, it gets read back in as d1 as string.   The variable d1 as string will
not work in the HoursDiff statement.

To me, it looks like a problem in formatting.
How do I fix this?

Steve


-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Problem saving datetime to file and reading it back for a calculation

2020-10-11 Thread Steve
Thanks for the response.

I must have spent hours looking on-line for a method to treat datetime
variables yet not one site mentioned the "pickle" module you indicatged.  I
did, however solve my problem.  It may be a kluge but it seems to work.

I learned that I cannot use print() to display the value of datetime but
once I saved it to a file, I could see it.  If I used "d3 = d2.isoformat" it
could be sent to a file with a write statement.  Apparently, it gives a
write/read format and places a T between the date and time as a separator. 

In trying to read it back into the program and work the calculation, I had
to replace the T with a space and some formatting. It all worked.
#===

LBD = "LBD"
d2 =  datetime.now()
d2i = d2.isoformat()

with open("TimeDate.txt", 'r') as infile:
 for BottleInfo in infile: # loop to find each line in the file for that
dose
   BottleInfo = BottleInfo.strip()

   if ((BottleInfo[0:3]== "LBD")):
BottleData = BottleInfo[0:43].strip()

BottleDataA = BottleData[4:14].strip()
BottleDataB = BottleData[16:30].strip()
BottleDataC = BottleDataA + " " + BottleDataB
print("BottleDataC = <" + BottleDataC + ">")
# I guess I could have searched for the "T" and replaced it.
print()
d1 = BottleDataC

import datetime
dto = datetime.datetime.strptime(d1, '%Y-%m-%d %H:%M:%S.%f')
dti = dto.isoformat()

HoursDiff = int((d2-dto).total_seconds()/3600)
print("HoursDiff = " + str(HoursDiff))
print()

TimeDateInfo=open("TimeDate.txt", "a") 
TimeDateInfo.write("{0:>5} {1:>25} {2:>5}\n".format (LBD, d2i, HoursDiff))
TimeDateInfo.close()

# ===

Granted, there may be other ways to do this but I actually enjoy the
exploration...
Still, I would like to see other methods.
Steve

-Original Message-----
From: Dieter Maurer  
Sent: Sunday, October 11, 2020 12:48 PM
To: Steve 
Subject: Re: Problem saving datetime to file and reading it back for a
calculation

Steve wrote at 2020-10-10 18:17 -0400:
>I would like to use the line:
>HoursDiff = int((d2-d1).total_seconds()/3600) to determine the 
>difference in hours between two timedate entries.
>
>The variable d2 is from datetime.now()
>and d1 is read from a text file.
>
>I can save d2 to the file only if I convert it to string and, at a later
>date, it gets read back in as d1 as string.   The variable d1 as string
will
>not work in the HoursDiff statement.

Python's "pickle" module provides support for storing (most) objects to
files and read them back.

-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   7   8   9   10   >