[Tutor] Web framework module for Python.

2019-07-15 Thread mhysnm1964
All,

 

I am currently not sure where to start with my query. 

 

I have a SQLite3 database which currently is being accessed by python code.
I am seeking a simple python module which would support a local web app in
order to update and  insert rows, and run reports  . This web app I am
creating is never going to ever see the public  internet. In fact, it will
be using the localhost address. So I do not require a full blown web server
like apache. If there is a simple python module that can run a web server,
this would be great. If there is a python module that can assist in building
the HTMl, this would be great as well. I am not sure how to link python and
the web HTML page together and haven't found anything that is clear on
addressing my needs.

 

Note: PPySimpleWeb does not fulfil my requirements. As there is
accessibility issues with this module preventing me using it for web. EG: My
screen reader that I use complains about most of the elements which are
generated. I thought of this and tested it. Thus why I have ruled it out.

 

The web pages are going to have:

*   Tables containing report outputs
*   Forms with edit and select tags and buttons/links.
*   Some Headers and basic HTML structure elements.

 

The web page is not going to have any fancy structure or visual effects at
all. I am more than happy to hand-code the HTML/JavaScript. I have had a
quick search and found a range of modules. Most of them indicate they are
for CMS web sites and look far to complex for my needs. 

 

If someone could point myself to a module and possibly a tutorial for the
module. I would be grateful. Hopefully this is not to of a open question.

 

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


Re: [Tutor] Blockchain Dev with Python SDK

2019-07-15 Thread mhysnm1964
Matt,

I would suggest you look at the links in the signature for this mailer for
some good tutorials on OOPS. Datacamp also has some good tutorials.

-Original Message-
From: Tutor  On Behalf Of
Matthew Zand
Sent: Monday, 15 July 2019 1:54 AM
To: Tutor@python.org
Subject: [Tutor] Blockchain Dev with Python SDK

Hi Everyone,

I am looking for resources for learning Blockchain development using Python
SDK. I found below tutorial like below but they are too advance:
https://developer.ibm.com/recipes/tutorials/building-transaction-handler-and
-processor-for-hyperledger-sawtooth-with-python-sdk/

Also, I am not familiar with OOP, will that be an issue?

Matt



--
Best,

DC Web Makers 
Coding Bootcamps 
240-200-6131
301-327-8773
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

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


Re: [Tutor] Web framework module for Python.

2019-07-15 Thread Alan Gauld via Tutor
On 15/07/2019 07:56, mhysnm1...@gmail.com wrote:

> like apache. If there is a simple python module that can run a web server,
> this would be great. If there is a python module that can assist in building
> the HTMl, this would be great as well. I am not sure how to link python and
> the web HTML page together and haven't found anything that is clear on
> addressing my needs.

I have 4 topics in my tutorial that address this area.
All you need is in the standard library.

For a basic web server app look at the topic:

Writing Web Server Applications

However if you want more than the very basics then something
like Flask would make life easier (also in my tutorial! :-)

See the topic:
Using web Application Frameworks.

This even covers accessing SQLite data...

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


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


[Tutor] Fwd: RE: pointers or references to variables or sub-sets of variables query.

2019-07-15 Thread Alan Gauld via Tutor
Forwarding to list



 Forwarded Message 
Subject:RE: [Tutor] pointers or references to variables or sub-sets of
variables query.
Date:   Mon, 15 Jul 2019 17:13:23 +1000
From:   mhysnm1...@gmail.com
To: 'Alan Gauld' 



All,

Sorry for the late response. I have moved my program to SQLite. AS I
found I was going down the rabbit hole of wasting time. As allan said,
the select statement and other SQL statements are far easier to work
with then writing the code yourself. What I did I learn a lot and
started my road on OOPS.

The first program I programmed on was an Apple IIE using Applesoft
basic. Tried to learn assembly 6802 myself. But never got there. In the
90's I learnt C Clipper 68 and Turbo Pascal. Never became very strong
with these languages as my roles were never programming focused. Late
90's, early 2000 forget, I learnt some basic Visual Basic 6. Again,
didn't do much with it. I learnt the basic of PERL or enough to get by.

I haven't really touched programming for years and there is a lot I have
forgotten. Never had the need to do tree's, link-lists or any complex
data structures. This time, I am trying to learn Python beyond what I
used to know.

I have used just about every type of PC since the early 80's. Even used
DEC VAX, IBM 3270's as well. Yes, been around for a while now. 







-Original Message-
From: Tutor  On Behalf Of
Alan Gauld via Tutor
Sent: Monday, 8 July 2019 8:55 AM
To: tutor@python.org
Subject: Re: [Tutor] pointers or references to variables or sub-sets of
variables query.

On 07/07/2019 20:54, David L Neil wrote:

> (However, some of us grew-up at a time when RAM was expensive and even
> in our relaxed state, such 'costs' still impinge on our consciousness -

Indeed, my first computer was at the local university and had 64KB.

My second computer was a Sinclair ZX81 (Timex in the USA?) with 16K

My third, a CP/M machine with 64K and 256K RAM disk and dual floppies -
such luxury! :-)

So I agree, it is hard to get out of that mode of thinking. But today
the minimum RAM is typically 4GB or more. My desktop boxes all have 16GB
and even my ancient Netbook has 4G.
My 20 year old iBook has 640M and even that is enough to run Python with
many thousands of data objects instantiated.

> particularly temporary, DB tables into MySQL's MEMORY storage (and
> with almost zero code-change/risk)!

Yes, I use SQLite's MEMORY facility reguilarly. Not for managing high
volumes but where I need flexible search capability.
A SQL SELECT statement is much more flexible and faster than any Python
search I could cobble together.

> (appreciating that I have no difficulty moving from (Python)
> procedural programming to (SQL) declarative, but many of our
> colleagues hate such, and with a passion)

Yes, I've never quite understood why some programmers are reluctant to
use SQL. For complex structured data it is by far the simplest approach
and usually very efficient, especially with big volumes. But simple
searches on small datasets are easier (or as easy) in native Python.

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


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


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


Re: [Tutor] Reading .csv data vs. reading an array

2019-07-15 Thread Mats Wichmann
On 7/15/19 12:35 PM, Chip Wachob wrote:
> Oscar and Mats,
> 
> Thank you for your comments and taking time to look at the snips.
> 
> Yes, I think I had commented that the avg+trigger was = triggervolts in
> my original post.
> 
> I did find that there was an intermediary process which I had forgotten
> to comment out that was adversely affecting the data in one instance and
> not the other.  So it WAS a case of becoming code blind.  But I didn't
> give y'all all of the code so you would not have known that.  My apologies.
> 
> Mats, I'd like to get a better handle on your suggestions about
> improving the code.  Turns out, I've got another couple of 4GByte files
> to sift through, and they are less 'friendly' when it comes to
> determining the start and stop points.  So, I have to basically redo
> about half of my code and I'd like to improve on my Python coding skills.
> 
> Unfortunately, I have gaps in my coding time, and I end up forgetting
> the details of a particular language, especially a new language to me,
> Python.
> 
> I'll admit that my 'C' background keeps me thinking as these data sets
> as arrays.. in fact they are lists, eg:
> 
> [
> [t0, v0],
> [t1, v1],
> [t2, v2],
> .
> .
> .
> [tn, vn]
> ]
> 
> Time and volts are floats and need to be converted from the csv file
> entries.
> 
> I'm not sure that follow the "unpack" assignment in your example of:
> 
> for row in TrigWind:
>     time, voltage = row  # unpack
> 
> I think I 'see' what is happening, but when I read up on unpacking, I
> see that referring to using the * and ** when passing arguments to a
> function...

That's a different aspect of unpacking.  This one is sequnce unpacking,
sometimes called tuple (or seqeucence) assignment.  In the official
Python docs it is described in the latter part of this section:

https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences


> I tried it anyhow, with this being an example of my source data:
> 
> "Record Length",202,"Points",-0.005640001706,1.6363
> "Sample Interval",5e-09,s,-0.005639996706,1.65291
> "Trigger Point",1128000,"Samples",-0.005639991706,1.65291
> "Trigger Time",0.341197,s,-0.005639986706,1.60309
> ,,,-0.005639981706,1.60309
> "Horizontal Offset",-0.00564,s,-0.005639976706,1.6363
> ,,,-0.005639971706,1.65291
> ,,,-0.005639966706,1.65291
> ,,,-0.005639961706,1.6363
> .
> .
> .
> 
> Note that I want the items in the third and fourth column of the csv
> file for my time and voltage.
> 
> When I tried to use the unpack, they all came over as strings.  I can't
> seem to convert them selectively..

That's what the csv module does, unless you tell it not to. Maybe this
will help:

https://docs.python.org/3/library/csv.html#csv.reader

There's an option to convert unquoted values to floats, and leave quoted
values alone as strings, which would seem to match your data above quite
well.

> Desc1, Val1, Desc2, TimeVal, VoltVal = row
> 
> TimeVal and VoltVal return type of str, which makes sense.
> 
> Must I go through yet another iteration of scanning TimeVal and VoltVal
> and converting them using float() by saving them to another array?
> 
> 
> Thanks for your patience.
> 
> Chip
> 
> 
> 
> 
> 
> 
> 
> 
> 
> On Sat, Jul 13, 2019 at 9:36 AM Mats Wichmann  > wrote:
> 
> On 7/11/19 8:15 AM, Chip Wachob wrote:
> 
> kinda restating what Oscar said, he came to the same conclusions, I'm
> just being a lot more wordy:
> 
> 
> > So, here's where it gets interesting.  And, I'm presuming that
> someone out
> > there knows exactly what is going on and can help me get past this
> hurdle.
> 
> Well, each snippet has some "magic" variables (from our point of view,
> since we don't see where they are set up):
> 
> 1: if(voltage > (avg + triglevel)
> 
> 2: if((voltage > triggervolts)
> 
> since the value you're comparing voltage to gates when you decide
> there's a transition, and thus what gets added to the transition list
> you're building, and the list size comes out different, and you claim
> the data are the same, then guess where a process of elimination
> suggests the difference is coming from?
> 
> ===
> 
> Stylistic comment, I know this wasn't your question.
> 
> >         for row in range (len(TrigWind)):
> 
> Don't do this.  It's not a coding error giving you wrong results, but
> it's not efficient and makes for harder to read code.  You already have
> an iterable in TrigWind.  You then find the size of the iterable and use
> that size to generate a range object, which you then iterate over,
> producing index values which you use to index into the original
> iterable.  Why not skip all that?  Just do
> 
> for row in TrigWind:
> 
> now row is actually a row, as the variable name suggests, rather than an
> index you use to go retrieve the row.
> 
> Further, the "row" entries in TrigWind are lists (or tuples, or some
> other inde

Re: [Tutor] Reading .csv data vs. reading an array

2019-07-15 Thread Chip Wachob
Oscar and Mats,

Thank you for your comments and taking time to look at the snips.

Yes, I think I had commented that the avg+trigger was = triggervolts in my
original post.

I did find that there was an intermediary process which I had forgotten to
comment out that was adversely affecting the data in one instance and not
the other.  So it WAS a case of becoming code blind.  But I didn't give
y'all all of the code so you would not have known that.  My apologies.

Mats, I'd like to get a better handle on your suggestions about improving
the code.  Turns out, I've got another couple of 4GByte files to sift
through, and they are less 'friendly' when it comes to determining the
start and stop points.  So, I have to basically redo about half of my code
and I'd like to improve on my Python coding skills.

Unfortunately, I have gaps in my coding time, and I end up forgetting the
details of a particular language, especially a new language to me, Python.

I'll admit that my 'C' background keeps me thinking as these data sets as
arrays.. in fact they are lists, eg:

[
[t0, v0],
[t1, v1],
[t2, v2],
.
.
.
[tn, vn]
]

Time and volts are floats and need to be converted from the csv file
entries.

I'm not sure that follow the "unpack" assignment in your example of:

for row in TrigWind:
time, voltage = row  # unpack

I think I 'see' what is happening, but when I read up on unpacking, I see
that referring to using the * and ** when passing arguments to a function...

I tried it anyhow, with this being an example of my source data:

"Record Length",202,"Points",-0.005640001706,1.6363
"Sample Interval",5e-09,s,-0.005639996706,1.65291
"Trigger Point",1128000,"Samples",-0.005639991706,1.65291
"Trigger Time",0.341197,s,-0.005639986706,1.60309
,,,-0.005639981706,1.60309
"Horizontal Offset",-0.00564,s,-0.005639976706,1.6363
,,,-0.005639971706,1.65291
,,,-0.005639966706,1.65291
,,,-0.005639961706,1.6363
.
.
.

Note that I want the items in the third and fourth column of the csv file
for my time and voltage.

When I tried to use the unpack, they all came over as strings.  I can't
seem to convert them selectively..

Desc1, Val1, Desc2, TimeVal, VoltVal = row

TimeVal and VoltVal return type of str, which makes sense.

Must I go through yet another iteration of scanning TimeVal and VoltVal and
converting them using float() by saving them to another array?


Thanks for your patience.

Chip









On Sat, Jul 13, 2019 at 9:36 AM Mats Wichmann  wrote:

> On 7/11/19 8:15 AM, Chip Wachob wrote:
>
> kinda restating what Oscar said, he came to the same conclusions, I'm
> just being a lot more wordy:
>
>
> > So, here's where it gets interesting.  And, I'm presuming that someone
> out
> > there knows exactly what is going on and can help me get past this
> hurdle.
>
> Well, each snippet has some "magic" variables (from our point of view,
> since we don't see where they are set up):
>
> 1: if(voltage > (avg + triglevel)
>
> 2: if((voltage > triggervolts)
>
> since the value you're comparing voltage to gates when you decide
> there's a transition, and thus what gets added to the transition list
> you're building, and the list size comes out different, and you claim
> the data are the same, then guess where a process of elimination
> suggests the difference is coming from?
>
> ===
>
> Stylistic comment, I know this wasn't your question.
>
> > for row in range (len(TrigWind)):
>
> Don't do this.  It's not a coding error giving you wrong results, but
> it's not efficient and makes for harder to read code.  You already have
> an iterable in TrigWind.  You then find the size of the iterable and use
> that size to generate a range object, which you then iterate over,
> producing index values which you use to index into the original
> iterable.  Why not skip all that?  Just do
>
> for row in TrigWind:
>
> now row is actually a row, as the variable name suggests, rather than an
> index you use to go retrieve the row.
>
> Further, the "row" entries in TrigWind are lists (or tuples, or some
> other indexable iterable, we can't tell), which means you end up
> indexing into two things - into the "array" to get the row, then into
> the row to get the individual values. It's nicer if you unpack the rows
> into variables so they can have meaningful names - indeed you already do
> that with one of them. Lets you avoid code snips like  "x[7][1]"
>
> Conceptually then, you can take this:
>
> for row in range(len(Trigwind)):
> voltage = float(TrigWind[row][1])
> ...
> edgearray.append([float(TrigWind[row][0]),
> float(TrigWind[row][1])])
> ...
>
> and change to this:
>
> for row in TrigWind:
> time, voltage = row  # unpack
> 
> edgearray.append([float)time, float(voltage)])
>
> or even more compactly you can unpack directly at the top:
>
> for time, voltage in TrigWind:
> ...
> edgearray.append([float)time, float(voltage)])
> ...
>
> Now I left an issue to resolve with conversion - voltage

Re: [Tutor] Reading .csv data vs. reading an array

2019-07-15 Thread Mats Wichmann
On 7/15/19 1:59 PM, Chip Wachob wrote:
> Mats,
> 
> Thank you!
> 
> So I included the QUOTE_NONNUMERIC to my csv.reader() call and it almost
> worked.
> 
> Now, how wonderful that the scope's csv file simply wrote an s for
> seconds and didn't include quotes.  Now Python tells me it can't create
> a float of s.  Of course I can't edit a 4G file in any editor that I
> have installed, so I have to work with the fact that there is a bit of
> text in there that isn't quoted.

yeah, the chips don't always fall right...

not sure what you're running, there are "stream editors" that can just
work on data as it passes through, even on Windows you can install
environments (cygwin, mingw) where the old "sed" command exists. Of
course Python can do that too, by working line-at-a-time, explicitly by
calling readlines() or implicitly by looping over the file handle. The
latter looks something like this;

with open("/path/to/datafile", "r") as f:
for line in f:
if REDFLAGTEXT in line:  # skip these
continue
do-something-with line


I don't want to be leading you down further ratholes, just trying to
answer the questions as they come up


> 
> Which leads me to another question related to working with these csv
> files. 
> 
> Is there a way for me to tell the reader to skip the first 'n' rows? 
> Or, for that matter, skip rows in the middle of the file? 

it's usually easier to skip based on a pattern, if you can identify a
pattern, but you can certainly also add a counter used to skip.  If 'n'
is always the same!

> 
> A this point, I think it may be less painful for me to just skip those
> few lines that have text.  I don't believe there will be any loss of
> accuracy.
> 
> But, since row is not really an index, how does one conditionally skip a
> given set of row entries?

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


[Tutor] Lengthy copyright notices?

2019-07-15 Thread James Hartley
help(module_name) will place any text in the *first* module-level docstring
into the description section of the help page in Python 3.4.5.  Subsequent
docstrings found at module level are ignored.

I have been using this factoid for placement of a copyright & licensing
notice.  By placing a rather lengthy copyright & license in the code in a
the second module-level docstring, it is prominent within the code, but not
cluttering up help() output.

Two questions.  Is there a more standardized way of including long license
descriptions in code, & is it documented that any other module-level
docstring will be ignored in help() output?

Thanks!

Jim
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Lengthy copyright notices?

2019-07-15 Thread Mats Wichmann
On 7/15/19 3:25 PM, James Hartley wrote:
> help(module_name) will place any text in the *first* module-level docstring
> into the description section of the help page in Python 3.4.5.  Subsequent
> docstrings found at module level are ignored.
> 
> I have been using this factoid for placement of a copyright & licensing
> notice.  By placing a rather lengthy copyright & license in the code in a
> the second module-level docstring, it is prominent within the code, but not
> cluttering up help() output.
> 
> Two questions.  Is there a more standardized way of including long license
> descriptions in code, & is it documented that any other module-level
> docstring will be ignored in help() output?

Rule #1: it's all opinion in the end...

The common practice is that licence/copyright text is included as a
comment in the code, not in a docstring.

It's only a docstring if it's the first thing in its block, and that is
assigned to the object's __doc__ attribute, and that's what help fishes
out, so yes, that behavior is documented.

Your second dosctring isn't technically a docstring, it's just a string,
which isn't assigned to anything, so it just ends up getting lost as a
runtime thing (no references). Is that what you want?

You're on the right track in your second paragraph - "not cluttering up
help output".  There is _some_ support for this opinion, namely PEP 257

https://www.python.org/dev/peps/pep-0257/#multi-line-docstrings

The 4th, 5th and 6th paragraphs of that section all suggest what should
be in the docstrings, none of them mentions copyright/license, all are
oriented to making the help text usable by users.

I'm sure someone else will have an opinion :)


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


Re: [Tutor] Lengthy copyright notices?

2019-07-15 Thread David L Neil

On 16/07/19 10:34 AM, Mats Wichmann wrote:

On 7/15/19 3:25 PM, James Hartley wrote:

help(module_name) will place any text in the *first* module-level docstring
into the description section of the help page in Python 3.4.5.  Subsequent
docstrings found at module level are ignored.

I have been using this factoid for placement of a copyright & licensing
notice.  By placing a rather lengthy copyright & license in the code in a
the second module-level docstring, it is prominent within the code, but not
cluttering up help() output.

Two questions.  Is there a more standardized way of including long license
descriptions in code, & is it documented that any other module-level
docstring will be ignored in help() output?


Rule #1: it's all opinion in the end...

The common practice is that licence/copyright text is included as a
comment in the code, not in a docstring.


Packaging and project templating offer/recommend a separate file for 
'legal-stuff', eg licensing.


That said, I also include a one-liner at the top of every module, adding 
__license__ to several other similar labels/definitions.


One thing is for-sure: when calling for help or reminding myself of 
method signatures, I'd be greatly irritated by having to wade-through a 
flood of irrelevance.


On the other hand, if 'you' use my work...

Whether either/both of these pass for pythonic, I can't say.

--
Regards =dn
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Reading .csv data vs. reading an array

2019-07-15 Thread Alan Gauld via Tutor
On 15/07/2019 21:28, Mats Wichmann wrote:

>> a float of s.  Of course I can't edit a 4G file in any editor that I
>> have installed, so I have to work with the fact that there is a bit of
>> text in there that isn't quoted.

Try sed, it's on most Unix like OS.
It doesn't read the entire file into memory so file size is not usually
an issue. I've never tried 4G but I have gone over 1GB before with no
issues.

If you have never used sed before its batch oriented so you need to
practice your commands in advance on something like vim or ex then
translate them to a file. But it sounds like it would be a worthwhile
automation step in your workflow. Write once, use often...

> course Python can do that too, by working line-at-a-time, explicitly by
> calling readlines() or implicitly by looping over the file handle. The
> latter looks something like this;
> 
> with open("/path/to/datafile", "r") as f:
> for line in f:
> if REDFLAGTEXT in line:  # skip these
> continue
> do-something-with line

All true, but sed - once you get used to it! - is easier IMHO
and usually faster than Python - it's written in C...

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


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


Re: [Tutor] Reading .csv data vs. reading an array

2019-07-15 Thread Chip Wachob
Mats,

Thank you!

So I included the QUOTE_NONNUMERIC to my csv.reader() call and it almost
worked.

Now, how wonderful that the scope's csv file simply wrote an s for seconds
and didn't include quotes.  Now Python tells me it can't create a float of
s.  Of course I can't edit a 4G file in any editor that I have installed,
so I have to work with the fact that there is a bit of text in there that
isn't quoted.

Which leads me to another question related to working with these csv
files.

Is there a way for me to tell the reader to skip the first 'n' rows?  Or,
for that matter, skip rows in the middle of the file?

A this point, I think it may be less painful for me to just skip those few
lines that have text.  I don't believe there will be any loss of accuracy.

But, since row is not really an index, how does one conditionally skip a
given set of row entries?

I started following the link to iterables but quickly got lost in the
terminology.

Best,


On Mon, Jul 15, 2019 at 3:03 PM Mats Wichmann  wrote:

> On 7/15/19 12:35 PM, Chip Wachob wrote:
> > Oscar and Mats,
> >
> > Thank you for your comments and taking time to look at the snips.
> >
> > Yes, I think I had commented that the avg+trigger was = triggervolts in
> > my original post.
> >
> > I did find that there was an intermediary process which I had forgotten
> > to comment out that was adversely affecting the data in one instance and
> > not the other.  So it WAS a case of becoming code blind.  But I didn't
> > give y'all all of the code so you would not have known that.  My
> apologies.
> >
> > Mats, I'd like to get a better handle on your suggestions about
> > improving the code.  Turns out, I've got another couple of 4GByte files
> > to sift through, and they are less 'friendly' when it comes to
> > determining the start and stop points.  So, I have to basically redo
> > about half of my code and I'd like to improve on my Python coding skills.
> >
> > Unfortunately, I have gaps in my coding time, and I end up forgetting
> > the details of a particular language, especially a new language to me,
> > Python.
> >
> > I'll admit that my 'C' background keeps me thinking as these data sets
> > as arrays.. in fact they are lists, eg:
> >
> > [
> > [t0, v0],
> > [t1, v1],
> > [t2, v2],
> > .
> > .
> > .
> > [tn, vn]
> > ]
> >
> > Time and volts are floats and need to be converted from the csv file
> > entries.
> >
> > I'm not sure that follow the "unpack" assignment in your example of:
> >
> > for row in TrigWind:
> > time, voltage = row  # unpack
> >
> > I think I 'see' what is happening, but when I read up on unpacking, I
> > see that referring to using the * and ** when passing arguments to a
> > function...
>
> That's a different aspect of unpacking.  This one is sequnce unpacking,
> sometimes called tuple (or seqeucence) assignment.  In the official
> Python docs it is described in the latter part of this section:
>
> https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences
>
>
> > I tried it anyhow, with this being an example of my source data:
> >
> > "Record Length",202,"Points",-0.005640001706,1.6363
> > "Sample Interval",5e-09,s,-0.005639996706,1.65291
> > "Trigger Point",1128000,"Samples",-0.005639991706,1.65291
> > "Trigger Time",0.341197,s,-0.005639986706,1.60309
> > ,,,-0.005639981706,1.60309
> > "Horizontal Offset",-0.00564,s,-0.005639976706,1.6363
> > ,,,-0.005639971706,1.65291
> > ,,,-0.005639966706,1.65291
> > ,,,-0.005639961706,1.6363
> > .
> > .
> > .
> >
> > Note that I want the items in the third and fourth column of the csv
> > file for my time and voltage.
> >
> > When I tried to use the unpack, they all came over as strings.  I can't
> > seem to convert them selectively..
>
> That's what the csv module does, unless you tell it not to. Maybe this
> will help:
>
> https://docs.python.org/3/library/csv.html#csv.reader
>
> There's an option to convert unquoted values to floats, and leave quoted
> values alone as strings, which would seem to match your data above quite
> well.
>
> > Desc1, Val1, Desc2, TimeVal, VoltVal = row
> >
> > TimeVal and VoltVal return type of str, which makes sense.
> >
> > Must I go through yet another iteration of scanning TimeVal and VoltVal
> > and converting them using float() by saving them to another array?
> >
> >
> > Thanks for your patience.
> >
> > Chip
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Sat, Jul 13, 2019 at 9:36 AM Mats Wichmann  > > wrote:
> >
> > On 7/11/19 8:15 AM, Chip Wachob wrote:
> >
> > kinda restating what Oscar said, he came to the same conclusions, I'm
> > just being a lot more wordy:
> >
> >
> > > So, here's where it gets interesting.  And, I'm presuming that
> > someone out
> > > there knows exactly what is going on and can help me get past this
> > hurdle.
> >
> > Well, each snippet has some "magic" variables (from our point of
> view,
> > since we don't see where they are set up):
> >
> >   

Re: [Tutor] Lengthy copyright notices?

2019-07-15 Thread Alan Gauld via Tutor
On 15/07/2019 23:34, Mats Wichmann wrote:

> Rule #1: it's all opinion in the end...

ditto...

> The common practice is that licence/copyright text is included as a
> comment in the code, not in a docstring.

I'd second that opinion. I don't like losing the copyright stuff
to a separate file - too easy to get lost. But I certainly don't
want it in my help() output either.

A comment solves both for the downside of some initial scrolling
when reading or editing the file


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


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


[Tutor] Impersonation

2019-07-15 Thread Jim

Mats,

Hopefully you recognize my email address as someone you have given 
advice concerning Python.


Over the last month or so I have received at least 3 emails supposedly 
coming from you that I am sure you did not send.


The from line is:  Mats Wichmann 

The body is: On Monday, July 15, 2019 10:36 AM, Mats Wichmann wrote:
Hope you are well. Just wanted to share something with you 
http://www.bt6q.lnhaxf.info/


I just wanted you to know that it seems someone is trying to impersonate 
you.


Regards,  Jim

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