Re: [Tutor] What are all those letters after terminal commands?

2012-08-23 Thread William Ray Wing
On Aug 23, 2012, at 9:18 AM, Cecilia Chavana-Bryant  
wrote:

> Hola,
> 
> I'm going through the 'Command line crash course' by Zed Shaw, thanks to the 
> people that recommended this book, its quite a good course, I can see what 
> the author was going for with the title but if it wasn't for your 
> recommendations, it would have put me off. At the beginning of Chapter 8 - 
> Moving around (pushd, popd) on Source: 13 exercise 8 I found this command: 
> mkdir -p i/like/icecream. I am guessing that the -p stands for directory 
> path? I have seen other such letters sometimes with or without the ' - ' 
> before them (I think) in commands so my question is, what are these letters 
> for? what are they called? and could someone please point me to where I can 
> find a list of these with descriptions of what they do. I have tried googling 
> with no positive results as I don't  know what they are called or I get just 
> the information for the command they are used with.
> 
> Many thanks in advance for the help, Cecilia
> ___
> 
Those letters are options (sometimes called switches) and they modify the 
action of the command. Thus "$ ls" gives you a very terse list of the files in 
a directory.  $ ls -a gives you a list of all the files, including invisible 
ones.  $ ls -l gives you a long list that includes size, date, and protections. 
 And $ ls -al does both. If you open a terminal session and enter $ man 
ls, you will get the "man page" for the ls command that will document 
these and several others. 

Don't worry you're doing great..
Bill
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Changing the interpreter prompt symbol from ">>>" to ???

2016-03-11 Thread William Ray Wing

> On Mar 11, 2016, at 10:31 PM, boB Stepp  wrote:
> 
> I must be bored tonight.  I have to confess that when copying and
> pasting from the interpreter into a plain text email, I often find it
> cluttered to confusing by all the ">>>..." that can result from nested
> quoting.  So I poked around on the Internet and found that I can
> temporarily change the prompt symbol using sys.ps1.  My initial trials
> are:
> 
> Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:54:25) [MSC v.1900
> 64 bit (AMD64)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
 import sys
 sys.ps1 = '=>'
> =>sys.ps1 = chr(26)
> →sys.ps1 = chr(16)
> ►
> 
> I personally like the last of these.  My question is, will this show
> up as a black, filled-in arrowhead pointing to the right on everyone's
> email?  

Can't answer for "everyone" but it certainly shows up that way in Apple Mail. 
And I agree, I rather like it too, and for the same reason: false 
interpretation of the standard prompt as nested quotes. 
-Bill

> I have yet to delve into Unicode display issues, but I have
> vague recollections that the old ASCII table values might not always
> display the same thing from one person's display to another one's.  Is
> this correct?
> 
> And a related question:  I often have the IDLE version of the Python
> shell open.  How can I make this sort of change for IDLE?  I have done
> some Googling on this as well, but haven't found the right search
> query yet.  I also poked into some of the idlelib files, but so far
> the only ">>>" I've found have been in specialized displays like IDLE
> debug.
> 
> TIA!
> 
> -- 
> boB
> ___
> 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] Study Tips

2016-06-01 Thread William Ray Wing

> On May 30, 2016, at 1:45 AM, Steve Lett  wrote:
> 
> Hi folks,
> Just started learning python. I've been having a really hard time in
> getting started, and still am! I have a slight learning difficulty,
> including a stroke in Jan.2010. You wouldnt know even if u were here
> looking at me! Praise God for the great salvation!
> I have a slight learning difficulty. Has anyone got any tips on how to
> study programming and what approach would be best for me?
> 

Quick question - just to be sure everyone is on the same page.  Is Python your 
first programming language?  That is, are you comfortable with the process of 
decomposing a problem into a series of steps (an algorithm) that will yield an 
answer?  Do you already know how to program in some OTHER language.  If yes - 
the answers you have gotten are great.  If NOT, then we should be talking on a 
whole different level.

-Thanks,
-Bill


> Out of a long list of books that I have collected ( python, Blender, etc )
> I have decided to start on Introducing Python (hard copy 2nd Ed, ebook 3rd
> ed) by Bill Lubanovic. Before that I was going to start with Python
> Programming for the Absolute Beginner, Michael Dawson.
> 
> Any thoughts on these issues and especially the study tips already
> mentioned.
> 
> Thank you, Steve
> ___
> 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] 10+ Different Python Script?

2016-07-13 Thread William Ray Wing

> On Jul 13, 2016, at 8:03 AM, Crusier  wrote:
> 
> Dear All,
> 
> I am currently using:
> Python 3.5
> Window 7
> 
> 
> I have a python script which is used for downloading Real Time Stocks.
> Currently, there is over a 1000 stocks in the Portfolio.
> 
> If I download the market info during market hours, it would take over
> 40 minutes to finish downloading all the market info. Since I am

Do you know where this (seeming) throughput limitation is _actually_ occurring?
I don’t know what format you are getting the data in, but if each stock is 
represented by it’s 1-4 character symbol, followed by a current quote (perhaps 
both bid and asked), then this adds up to around a dozen characters.  Lets be 
generous and say 20 bytes.  Twenty bytes times 1000 stocks is 20 kB.  Even a 
“slow” connection these days should give you a 2 Mbs throughput or 200 kBs 
(including overhead), so your 20 kB of data should download in roughly one 
tenth of a second. 


> trading stock real time, I am thinking of breaking it down into 100
> stocks per group, so I could make the download time shorter. For the
> market info, I will put into database and for data analysis.
> 

In other words, don’t waste time solving the wrong problem.

> My Question is as follows:
> 
> Please advise if I should put the portfolio and split it into 10
> different scripts, so each scripts consists a list of 100+ number of
> stocks. Or is there any Pythonic way to approach this problem??
> 
> I am currently using Multi Thread but there is an Operational Error
> 
> 
> I am having a hard time to approach OOP. I just can't grasp the
> understanding of it as it seems so abstract. Please advise.
> 
> Thank you
> 
> Regards,
> Hank
> ___
> 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] python on ipad

2013-03-10 Thread William Ray Wing
On Mar 10, 2013, at 6:18 PM, Sven  wrote:

> On 10 March 2013 21:42, Benjamin Fishbein  wrote:
> Hello. I wrote some python programs for my small business that I run on my 
> computer...macbook air. I'm planning to backpack around Mexico and perhaps 
> south america. I'll still be working though. Basically my computer does all 
> the work, I just need to have internet connections and run the programs, and 
> periodically click here and there.
> I don't want to take my macbook with me because I'd have anxiety that it'd 
> get stolen and I wouldn't have any fun.
> So I'm debating if I should get a cheap computer for a couple hundred bucks 
> and run the python scripts on it. I think this is possible because I hear the 
> code is the same whether it's mac or PC or whatever.
> Or I might take my ipad with me. Or just run it on my iphone.
> Do you know if it's possible to run python scripts on a ipad/iphone, and if 
> so how to do it?
> 
> 
> Do these scripts have GUIs or are they just CLI scripts?
> 
> If they are CLI scripts then you can certainly run them on a jailbroken device
> http://www.rioleo.org/python-on-the-ipad.php
> 
> or if you don't want to jailbreak http://omz-software.com/pythonista/
> 
> although I have no idea how featured that is.
> 

I have Pythonista on my iPad, and it seems to be a pretty complete 
implementation of Python and the standard libraries.  It doesn't have Tkinter 
or ttk, but does have a "scene" library that supports GUI interfaces and games. 
 It has a fairly active discussion forum and if you Google Pythonista you will 
get hits to several reviews - all positive.  At $6.95, it would be worth 
checking out.

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


Re: [Tutor] (no subject)

2013-03-24 Thread William Ray Wing
On Mar 24, 2013, at 8:13 PM, Mandi Seger  wrote:

> Hello, everyone,
> 
> I am looking for suggestions on a beginner's book for learning Python. I have 
> a nursing background with basic science and math education. I have no 
> programming experience in any computer language.
> 
> I am currently enrolled in a Master's program for Geographic Information 
> Science and will be learning Python with an eye toward applying it in GIS 
> software programs such as ESRI's ArcMap.
> 
> I prefer to start with a book for ease of reference, and then move forward 
> with online resources.
> 
> Thank you for any input.
> 
> Mandi Seger
> ___

Mandi,
I've looked at both Alan and Robert's replies.  They are both good and 
relevant - but I'm a bit concerned with your statement that: "I have no 
programming experience in any computer language."  In and of itself, this is 
NOT a problem, and with a nursing background and a math and science education, 
you are obviously more than smart enough.  What I'm focused on is the initial 
a-ha! moment when you suddenly see just what programming is all about - or more 
properly, how you examine a problem you want to solve and express that problem 
as a series of steps that the computer can carry out.  Most of the folks on 
this list experienced that a-ha moment so long ago, they've forgotten what it 
was like.  Different people get to that moment in different ways, and through 
different learning experiences.  But that moment IS critical.  Without it, you 
are writing programs by rote, and that will be frustrating and you won't get 
very far - let alone enjoy it, which you should.  With it, and after l
 earning your first computer language (and Python is an excellent choice), then 
learning other languages is trivial.  This is a VERY long winded and indirect 
recommendation to spend a couple of days in your university's book store.  It 
should have a sizable section on various computer languages and a selection of 
beginner books.  Look at the first chapter in several (and look at the first 
section of Alan's on-line tutorial, in which he talks about this subject).  
What you are looking for is a book that speaks to YOU, and gets you over that 
very first conceptual hump.
I might also suggest that as a first problem, pick something that is almost 
a pure exercise in simple mathematical logic - searching for prime numbers for 
example, or for perfect numbers.  Once you can break a problem like that down 
into simple declarative steps, you are on your way.

Welcome to the wonderful world of Python

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


Re: [Tutor] Resetting state of http.client/httplib HTTPSConnection objects

2013-08-26 Thread William Ray Wing
On Aug 26, 2013, at 5:28 AM, Chris Down  wrote:

> On 2013-08-26 01:23, Alan Gauld wrote:
>> While this is technically within the remit of this list, since its
>> about a standard library module, I suspect you might be better
>> off asking on the main tutor list. It's at a deeper level of
>> skill/experience than most of the tutor queries.
> 
> Hm, I guess I don't understand the remit of the two lists then. Tutor has
> always seemed very... non-tutory. I'll post it there, anyway. Thanks!
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

I'd be willing to bet that Alan simply foobar'd his answer - he _meant_ to say 
the main python list, not the main tutor list.

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


Re: [Tutor] Load Entire File into memory

2013-11-04 Thread William Ray Wing
On Nov 4, 2013, at 8:30 AM, Amal Thomas  wrote:

> Yes I have found that after loading to RAM and then reading lines by lines 
> saves a huge amount of time since my text files are very huge.
> 

[huge snip]

> -- 
> AMAL THOMAS
> Fourth Year Undergraduate Student
> Department of Biotechnology
> IIT KHARAGPUR-721302
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor

How long are the lines in your file?  In particular, are they many hundreds or 
thousands of characters long, or are they only few hundred characters, say 200 
or less?

Unless they are so long as to exceed the normal buffer size of your OS's 
read-ahead buffer, I strongly suspect that the big time sink in your attempt to 
read line-by-line was some inadvertent inefficiency that you introduced.  
Normally, when reading from a text file, python buffers the reads (or uses the 
host OS buffering).  Those reads pull in huge chunks of text WAY ahead of where 
the actual python processing is going on, and are VERY efficient.

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


Re: [Tutor] Load Entire File into memory

2013-11-05 Thread William Ray Wing
On Nov 5, 2013, at 11:12 AM, Alan Gauld  wrote:

> On 05/11/13 02:02, Danny Yoo wrote:
> 
>> To visualize the sheer scale of the problem, see:
>> 
>> http://i.imgur.com/X1Hi1.gif
>> 
>> which would normally be funny, except that it's not quite a joke.  :P
> 
> I think I'm missing something. All I see in Firefox is
> a vertical red bar. And in Chrome I don't even get that,
> just a blank screen...
> 
> ???
> 
> -- 
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.flickr.com/photos/alangauldphotos

It took me a while…  If you put your cursor up in the extreme upper left hand 
corner of that red bar, you get a + sign that allows you to expand the image.  
In the expansion you will see text that explains the graphical scales in 
question.  A pixel (L1 cache), a short bar of pixels (L2 cache), a longer bar 
(RAM) and finally that huge block of pixels that represent disk latency.

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


Re: [Tutor] Subprocess communications query

2013-12-11 Thread William Ray Wing
On Dec 10, 2013, at 2:28 PM, Reuben  wrote:

> Hi,
> 
> There exists two Linux machines A and B. Machine B contains python script 
> which needs to be run e.g. Test.py
> 
> In order to run that script, machine A needs to telnet into machine B and 
> then execute "python Test.py"
> 
> How can this be implemented? Is subprocess library to be used?if yes, an 
> example would help
> 
> Regards,
> Reuben
> 
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor

Check out pexpect here:  http://pexpect.sourceforge.net/pexpect.html

Should do exactly what you want, and Googling for pexpect examples will turn up 
lots of stuff.

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


Re: [Tutor] Quantum computing

2013-12-14 Thread William Ray Wing
On Dec 14, 2013, at 1:22 PM, Mark Lawrence  wrote:

> On 14/12/2013 17:14, Alan Gauld wrote:
>> On 14/12/13 15:37, Mark Lawrence wrote:
>>> 
>>> I believe that quantum computing is way OT for the Python tutor mailing
>>> list.
>> 
>> Yeah, you are probably right. Although there are precedents where we
>> have discussed general topics about the future of computing and
>> where/whether Python fits in.
>> 
>> But QC is probably a but more esoteric than any of those were!
>> 
> 
> True.  As it happens I'm happy to see things go OT on Python threads. It 
> makes for more interesting reading, plus people might well pick up on 
> something that otherwise they'd not have learned.  However I draw a line 
> firmly in the sand at quantum computing here.  Let's stick with the wonders 
> of list comprehensions, recursive functions and why can't Python do floating 
> point arithmetic correctly?
> 
> -- 
> My fellow Pythonistas, ask not what our language can do for you, ask what you 
> can do for our language.
> 
> Mark Lawrence

Well, as it turns out, there actually *IS* a commercially available quantum 
computer on the market today.  It is built by a Canadian company "D-Wave 
Systems" and early prototypes have been bought by companies like Google and 
Lockeed Martin and some Government labs.  Unfortunately, it isn't clear whether 
or not it is living up to expectations…

You can read a summary and sort of intro here:  
http://spectrum.ieee.org/computing/hardware/dwaves-year-of-computing-dangerously

-Bill

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


Re: [Tutor] same python script now running much slower

2013-12-30 Thread William Ray Wing
On Dec 30, 2013, at 1:37 PM, "Protas, Meredith"  wrote:

> Hi,
> 
> I'm very new to python so I'm sorry about such a basic question.
> 
> I am using a python script generated by another person.  I have used this 
> script multiple times before and it takes around 24 hours to run.  Recently, 
> I have tried to run the script again (the same exact command lines) and it is 
> much much slower.  I have tried on two different computers with the same 
> result.  I used top to see if there were any suspicious functions that were 
> happening but there seems to not be.  I also ran another python script I used 
> before and that went at the same speed as before so the problem seems unique 
> to the first python script.
> 
> Does anyone have any idea why it is so much slower now than it used to be 
> (just around a month ago).
> 
> Thanks for your help!
> 
> Meredith

Meredith,  This is just a slight expansion on the note you received from Alan.  
Is there any chance that the script now is paging itself to death?  That is, if 
you are reading a huge amount of data into a structure in memory, and if it no 
longer fits in available physical memory (either because the amount of data to 
be read has grown or the number of other processes that are occupying memory 
have grown), then that data structure may have gone virtual and the OS may be 
swapping it out to disk.  That would dramatically increase the amount of 
elapsed wall time the program takes to run.

If you can tell us more about what the program actually is doing or 
calculating, we might be able to offer more help.

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


Re: [Tutor] same python script now running much slower

2013-12-30 Thread William Ray Wing
On Dec 30, 2013, at 7:54 PM, "Protas, Meredith"  wrote:

> Thanks for all of your comments!  I am working with human genome information 
> which is in the form of many very short DNA sequence reads.  I am using a 
> script that sorts through all of these sequences and picks out ones that 
> contain a particular sequence I'm interested in.  Because my data set is so 
> big, I have the data on an external hard drive (but that's where I had it 
> before when it was faster too).
> 
> As for how much slower it is running, I don't know because I keep having to 
> move my computer before it is finished.  The size of the data is the same, 
> the script has not been modified, and the data is still in the same place.  
> Essentially, I'm doing exactly what I did before (as a test) but it is now 
> slower.
> 
> How would I test your suggestion, Bill, that the script is paging itself to 
> death?  The data has not grown and I don't think the number of processes 
> occupying memory has changed.
> 
> By the way, I am using a Mac and I've tried two different computers.  
> 
> Thanks so much for all of your help!
> 
> Meredith
> 

Meredith,  look in your Utilities folder for an application called Activity 
Monitor.  Launch it and then in the little tab bar close to the bottom of the 
window, select System Memory.  This will get you several statistics, but the 
quick and dirty check is the pie chart to the right of the stats.  If the green 
wedge is tiny or nonexistent, then you've essentially run out of "free" 
physical memory and the system is almost certainly paging.

As a double check, reboot your Mac (which I assume is a laptop).  Relaunch the 
Activity Monitor and again, select System Memory.  Right now, immediately after 
a reboot, the green wedge should be quite large, possibly occupying 3/4 of the 
circle.  Now launch your script again and watch what happens.  If the wedge 
shrinks down to zero, you've found the problem and we need to figure out why 
and what has changed.
-

If memory use is NOT the problem, then we need to know more about the context.  
What version of Mac OS are you running?  Are you running the system version of 
python or did you install your own?  Did you recently upgrade to 10.9 (the 
version of python Apple ships with 10.9 is different from the one that came on 
10.8)?

-

Finally, I assume the Mac has both USB and Firewire ports.  Most Mac-compatible 
external drives also have both USB and Firewire.  Is there an chance that you 
were using Firewire to hook up the drive previously and are using USB now?

Hope this helps (or at least helps us get closer to an answer).

-Bill

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


Re: [Tutor] Help with Guess the number script

2014-03-11 Thread William Ray Wing
On Mar 11, 2014, at 8:06 PM, Scott W Dunning  wrote:

[mega byte]

>> 
> Yeah, I had no idea that my messages were coming through in HTML, nor what it 
> looked like until someone sent me a section showing me what it looked like, I 
> can see how that would be frustrating.  
> 
> I’m using the mail app on my macbook pro, any suggestions on how to stop it 
> from going out as html?  Do I need to change the font?  Also, I think last 
> time I sent a section of my code I copy and pasted it from my script, could 
> that be the problem?
> 
> Thanks again!

Simple.  In Mail Preferences -> Composing -> Message Format -> Plain Text  
(Your setting is probably currently Rich Text.)

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


Re: [Tutor] which is faster

2014-06-10 Thread William Ray Wing
On Jun 10, 2014, at 2:42 AM, diliup gabadamudalige  wrote:

> Hi All,
> 
> This is a Pygame related question and if not answered it's ok and I apologise 
> for asking. But if someone can answer it is much appreciated.
> 
> In Pygame Which is faster?
> 
> 1. filling the screen with a colour
> or
> 2. blitting an image to screen
> 
> Thank you for the time.
> May you be well.
> 
> 
> -- 
> Diliup Gabadamudalige
> 

I don’t use Pygame, but it seems to me the answer is likely to depend on what 
graphics hardware is available on the computer in question.

-Bill



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


Re: [Tutor] What are your favourite unofficial resources

2014-06-29 Thread William Ray Wing
Probably obvious (meaning you will get them both 50+ times), but I like both 
Stackoverflow.com and Doug Hellmann’s site.

Thanks,
Bill

On Jun 29, 2014, at 6:41 PM, Alan Gauld  wrote:

> I'm looking for tips for an appendix to a book that
> I'm working on.
> 
> What are the best unofficial (ie not python.org)
> resources for people who have learned the basics
> but are not experts yet? ie Typical tutor list
> "graduates"...
> 
> I'm thinking about web sites, blogs, books, videos etc.
> Anything that might be worth knowing about.
> 
> I've got a few of my own - Activestate, O'Reilly,
> ByteOfPython, PythonChallenge, ShowMeDo etc.
> 
> But I thought the tutor list readers might be an
> interesting source of alternatives that I hadn't
> thought of, or even heard of.
> 
> All contributions considered :-)
> 
> -- 
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> 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] how do I set variables in Python 3.4

2014-07-11 Thread William Ray Wing
On Jul 11, 2014, at 1:50 AM, Danielle Salaz  wrote:

> I'm a noob to Python and cannot figure out how to complete one of my 
> assignments. 
> 

Welcome to Python - I’d hope you’ve been monitoring this Tutor list for at 
least a few days -

> I am supposed to use operand1=2 and operand2=7 
> To complete: result= operand1+operand2 etc, but I keep getting invalid syntax 
> either on the " or operand1. Please help
> 

If you have been, you would see that we need to know which version of Python, 
what operating system, and then see a complete copy and paste of the traceback 
and the code you were executing.

In this case, that would be particularly relevant, because it would appear that 
you have typo’d your iPhone e-mail since there is no " character anyplace in 
any of the three assignment statements you have given us. Worse, on an iPhone 
keypad, the “ character isn’t close to anything else you might logically have 
used.

-Bill



> Sent from my iPhone
> ___
> 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] debug and execute python code in Mac

2014-08-28 Thread William Ray Wing
On Aug 27, 2014, at 8:08 PM, Sebastian Silva  wrote:

> I stumbled today upon this IDE for the mac http://plotdevice.io/
> 
> From the looks of it, it seems like a nice tool for teaching/learning Python. 
> Too bad it's mac only. If you try it, do share your experience. I don't use 
> non-free operating systems, so I can't try it myself.
> 
> Regards,
> 
> Sebastian

Just as an aside — Apple has stopped charging for OS-X.

-Bill

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


Re: [Tutor] usage difference between tabs and spaces

2014-09-09 Thread William Ray Wing
On Sep 9, 2014, at 8:27 AM, Mirage Web Studio  wrote:

> 
> Hello,
> 
> I am not an advanced programmer, but am very good with keyboard and find
> using tabs for syntax and formatting very helpful. But in this list and
> other python documentation i have repeatedly seen people recommending
> use of spaces.
> 
> I know that i can use any of them and use tabs as my preference.  But i
> would like to understand why hitting the poor keyboard 4/8/12 times is
> preferred than just hitting it 1/2/3 times.
> 
> Thank you
> 
> George

Most of us use editors that expand tabs to a programmable number of spaces.

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


Re: [Tutor] Hi

2015-04-11 Thread William Ray Wing

> On Apr 11, 2015, at 8:32 AM, Vick  wrote:
> 

[byte]

> However I recently talked to a guy online and he told me the following,
> which actually intrigued and surprised me:
> 
> "The vast majority of numerical codes in science, including positional
> astronomy, are written in Fortran and C/C++.  If you wish to use these codes
> in minority and less efficient languages such as Python and VBA, learning to
> translate this code into those languages is a skill you will have to
> acquire."
> 
> The "codes" in question are referring to a query I posed to him regarding
> the GUST86 theory on the computational position of Uranus' natural
> satellites authored by Laskar and Jacobson in 1987. The "code" is readily
> downloadable in Fortran at the IMCCE ftp site.
> 
> But his statement is insinuating that Python is inferior to Fortran as a
> mathematical tool and that all of the scientific community prefers to use
> Fortran.
> 
> My question is simple: Is he right or wrong?
> 
> 

He is probably right, but only because most large scientific codes have 
historical roots that date back to the days when FORTRAN was the only language 
readily available on the computers scientists used.  Even today, FORTRAN 
compilers can frequently optimize typical scientific code to tighter (faster) 
executable code than the compilers for other, more modern, richer languages.  
HOWEVER, that said, more and more scientific code is being written with Python 
as the organizing language which calls mathematical libraries written in 
FORTRAN.  Libraries like numpy make heavy use of FORTRAN arrays, while allowing 
the scientific programmer to concentrate on the higher levels of the science 
being modeled.

Bill

> 
> Thanks
> 
> Vick
> 
> ___
> 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] coding help with maxwell-boltzmann distribution

2017-10-12 Thread William Ray Wing


> On Oct 12, 2017, at 4:22 PM, Cameron McKay  wrote:
> 
> Hello,
> 
> I've never used python trying to plot a graph. Thus I am having
> difficulties trying to plot the maxwell-boltzmann distribution. right now
> i've defined the y-axis given the probability, but the difficult part is
> trying to plot x in the form of:
> 
> x = v/(2kT/m)^(1/2)

First of all, this only part of the formula for the Maxwell Boltzmann 
distribution function.  It is usually written as:

F(v) = (m/2 pi kT)^3/2 * 4 pi v^2 exp(-mv^2/2kT)

The independent variable is v, everything else is constants.  So what you want 
is an array of values of v (which will be the x axis).  Then use a for loop to 
calculate F(v) for each v in the range. Finally, importing matplotlib, and 
plotting F(v), the y axis, as a function of the x axis will give you your (sort 
of) bell curve. 
Hope these hints help. 
Bill




> 
> before i used the linspace function but i believe that was wrong as it just
> gave me an exponential growth function as i need a bellcurve.
> 
> Thanks for looking into this,
> 
> Cameron
> ___
> 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] AttributeError: 'BezierPath' object has no attribute '_draw_solid'

2017-11-19 Thread William Ray Wing

> On Nov 19, 2017, at 11:36 AM, Stephen P. Molnar  
> wrote:
> 
> I have written a short Python 3 script to plot three curves (one plot) of 
> data from a FORTRAN program.  Initially the code worked and produced the plot 
> which is attached.  I have also attached the code and the input data,
> 

The data made it through, neither the script nor the plot did.  If the script 
really is short, perhaps you could just cut and paste it into a follow-up msg.  
Absent that, no one here can help you.

Thanks,
Bill

> In all candor, I don't have the faintest idea as to whst the problem (or 
> problens) might be and would greatly appreciate a pointer towards the 
> solution.
> 
> Thanks in advance.
> 
> -- 
> Stephen P. Molnar, Ph.D.  Life is a fuzzy set
> www.molecular-modeling.netStochastic and multivariate
> (614)312-7528 (c)
> Skype: smolnar1
> 
> ___
> 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] AttributeError: 'BezierPath' object has no attribute '_draw_solid'

2017-11-19 Thread William Ray Wing

> On Nov 19, 2017, at 3:14 PM, Stephen P. Molnar  wrote:
> 
> 
> On 11/19/2017 03:10 PM, William Ray Wing wrote:
>>> On Nov 19, 2017, at 11:36 AM, Stephen P. Molnar  
>>> wrote:
>>> 
>>> I have written a short Python 3 script to plot three curves (one plot) of 
>>> data from a FORTRAN program.  Initially the code worked and produced the 
>>> plot which is attached.  I have also attached the code and the input data,
>>> 
>> The data made it through, neither the script nor the plot did.  If the 
>> script really is short, perhaps you could just cut and paste it into a 
>> follow-up msg.  Absent that, no one here can help you.
>> 
>> Thanks,
>> Bill
>> 
>>> In all candor, I don't have the faintest idea as to whst the problem (or 
>>> problens) might be and would greatly appreciate a pointer towards the 
>>> solution.
>>> 
>>> Thanks in advance.
>>> 
>>> -- 
>>> Stephen P. Molnar, Ph.D.Life is a fuzzy set
>>> www.molecular-modeling.net  Stochastic and multivariate
>>> (614)312-7528 (c)
>>> Skype: smolnar1
>>> 
>>> ___
>>> Tutor maillist  -  Tutor@python.org
>>> To unsubscribe or change subscription options:
>>> https://mail.python.org/mailman/listinfo/tutor
>> 
> 

Unfortunately your mail reader/program has pasted it in as an RTF file and this 
makes it almost impossible to look at in a text editor or hand to the Python 
interpreter.  What we see looks like the following (I’ve pasted in the first 
few lines).
———
Multiple_Plots_2_b.py\
\
Copyright (c) 2017 Stephen P. Molnar, Ph.D. \'a0All rights reserved.\
\
"""\
import numpy as np\
from mpl_toolkits.axes_grid1 import host_subplot\
import mpl_toolkits.axisartist as AA\
import matplotlib.pyplot as plt\
\
data = []\
name = input("Enter Molecule ID: ")\
\
name_in = name+'_poutput'\
data = np.genfromtxt(name_in)\
\
s = data[:,0]\
FTm = data[:,1] \'a0\'a0\'a0\'a0#atomic number\
FTe = data[:,2] \'a0\'a0\'a0\'a0#atomic mass\
FTc = data[:,3] \'a0\'a0\'a0\'a0#atom electron density\
\
\
fig = plt.figure(figsize=(7.6,4))\
\
host = host_subplot(111, axes_class=AA.Axes)\
plt.subplots_adjust(right=0.75)\
\
par1 = host.twinx()\
par2 = host.twinx()\
\
offset = 60\
new_fixed_axis = par2.get_grid_helper().new_fixed_axis\
par2.axis["right"] = new_fixed_axis(loc="right", axes=par2,\
\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0offset=(offset,
 0))\
\

---


> Here it is:
> 
> #!/usr/bin/env python3
> # -*- coding: utf-8 -*-
> """
> Multiple_Plots_2_b.py
> 
> Copyright (c) 2017 Stephen P. Molnar, Ph.D.  All rights reserved.
> 
> """
> import numpy as np
> from mpl_toolkits.axes_grid1 import host_subplot
> import mpl_toolkits.axisartist as AA
> import matplotlib.pyplot as plt
> 
> data = []
> name = input("Enter Molecule ID: ")
> 
> name_in = name+'_poutput'
> data = np.genfromtxt(name_in)
> 
> s = data[:,0]
> FTm = data[:,1] #atomic number
> FTe = data[:,2] #atomic mass
> FTc = data[:,3] #atom electron density
> 
> 
> fig = plt.figure(figsize=(7.6,4))
> 
> host = host_subplot(111, axes_class=AA.Axes)
> plt.subplots_adjust(right=0.75)
> 
> par1 = host.twinx()
> par2 = host.twinx()
> 
> offset = 60
> new_fixed_axis = par2.get_grid_helper().new_fixed_axis
> par2.axis["right"] = new_fixed_axis(loc="right", axes=par2,
>offset=(offset, 0))
> 
> par2.axis["right"].toggle(all=True)
> 
> host.set_xlim(0, 30)
> """
> host.set_ylim(min(FTm), max(FTm))
> """
> 
> host.set_xlabel("Distance ($\AA$)")
> host.set_ylabel("Atomic Number")
> par1.set_ylabel("Atom Mass")
> par2.set_ylabel("Atom Electron Density")
> 
> p1, = host.plot(data[:,0], data[:,1])#, label="Atomic Number")
> p2, = par1.plot(data[:,0], data[:,2])#, label="Atom Mass")
> p3, = par2.plot(data[:,0], data[:,3])#, label="Atom Electron Density")
> 
> """
> par1.set_ylim(min(FTe), max(FTe))
> par2.set_ylim(min(FTc),max(FTc))
> """
> 
> #host.legend()
> 
> host.axis["left"].label.set_color(p1.get_color())
> par1.axis["right"].label.set_color(p2.get_color())
> par2.axis["right"].label.set_color(p3.get_color())
> 
> host.title.set_text('Molecule {0} - Molecular Transforms'.format(name))
> plt.draw()
> plt.show()
> 
> name_plt = name+'-fig1.png'
> fig.savefig(name_plt,bbox_inches='tight')
> 
> 
> -- 
> Stephen P. Molnar, Ph.D.  Life is a fuzzy set
> www.molecular-modeling.netStochastic and multivariate
> (614)312-7528 (c)
> Skype: smolnar1
> 

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


Re: [Tutor] AttributeError: 'BezierPath' object has no attribute '_draw_solid'

2017-11-20 Thread William Ray Wing

> On Nov 19, 2017, at 3:14 PM, Stephen P. Molnar  wrote:
> 
> 
> On 11/19/2017 03:10 PM, William Ray Wing wrote:
>>> On Nov 19, 2017, at 11:36 AM, Stephen P. Molnar  
>>> wrote:
>>> 
>>> I have written a short Python 3 script to plot three curves (one plot) of 
>>> data from a FORTRAN program.  Initially the code worked and produced the 
>>> plot which is attached.  I have also attached the code and the input data,
>>> 
>> The data made it through, neither the script nor the plot did.  If the 
>> script really is short, perhaps you could just cut and paste it into a 
>> follow-up msg.  Absent that, no one here can help you.
>> 
>> Thanks,
>> Bill
>> 

As an experiment, I took the code and moved it to my laptop (MacOS, running 
10.12.6 where there is a complete Anaconda installation that contains 
self-consistent versions of everything Dr. Molnar imports (Python 3.6.1 
incidentally).  There the code runs perfectly.  I’m appending a copy of the 
.png file it produced, and although I expect it to be scraped off by the 
gateway list-server, it should show up in Dr. Molnar’s e-mail.

Bill



>>> In all candor, I don't have the faintest idea as to whst the problem (or 
>>> problens) might be and would greatly appreciate a pointer towards the 
>>> solution.
>>> 
>>> Thanks in advance.
>>> 
>>> -- 
>>> Stephen P. Molnar, Ph.D.Life is a fuzzy set
>>> www.molecular-modeling.net  Stochastic and multivariate
>>> (614)312-7528 (c)
>>> Skype: smolnar1
>>> 
>>> ___
>>> Tutor maillist  -  Tutor@python.org
>>> To unsubscribe or change subscription options:
>>> https://mail.python.org/mailman/listinfo/tutor
>> 
> 
> Here it is:
> 
> #!/usr/bin/env python3
> # -*- coding: utf-8 -*-
> """
> Multiple_Plots_2_b.py
> 
> Copyright (c) 2017 Stephen P. Molnar, Ph.D.  All rights reserved.
> 
> """
> import numpy as np
> from mpl_toolkits.axes_grid1 import host_subplot
> import mpl_toolkits.axisartist as AA
> import matplotlib.pyplot as plt
> 
> data = []
> name = input("Enter Molecule ID: ")
> 
> name_in = name+'_poutput'
> data = np.genfromtxt(name_in)
> 
> s = data[:,0]
> FTm = data[:,1] #atomic number
> FTe = data[:,2] #atomic mass
> FTc = data[:,3] #atom electron density
> 
> 
> fig = plt.figure(figsize=(7.6,4))
> 
> host = host_subplot(111, axes_class=AA.Axes)
> plt.subplots_adjust(right=0.75)
> 
> par1 = host.twinx()
> par2 = host.twinx()
> 
> offset = 60
> new_fixed_axis = par2.get_grid_helper().new_fixed_axis
> par2.axis["right"] = new_fixed_axis(loc="right", axes=par2,
>offset=(offset, 0))
> 
> par2.axis["right"].toggle(all=True)
> 
> host.set_xlim(0, 30)
> """
> host.set_ylim(min(FTm), max(FTm))
> """
> 
> host.set_xlabel("Distance ($\AA$)")
> host.set_ylabel("Atomic Number")
> par1.set_ylabel("Atom Mass")
> par2.set_ylabel("Atom Electron Density")
> 
> p1, = host.plot(data[:,0], data[:,1])#, label="Atomic Number")
> p2, = par1.plot(data[:,0], data[:,2])#, label="Atom Mass")
> p3, = par2.plot(data[:,0], data[:,3])#, label="Atom Electron Density")
> 
> """
> par1.set_ylim(min(FTe), max(FTe))
> par2.set_ylim(min(FTc),max(FTc))
> """
> 
> #host.legend()
> 
> host.axis["left"].label.set_color(p1.get_color())
> par1.axis["right"].label.set_color(p2.get_color())
> par2.axis["right"].label.set_color(p3.get_color())
> 
> host.title.set_text('Molecule {0} - Molecular Transforms'.format(name))
> plt.draw()
> plt.show()
> 
> name_plt = name+'-fig1.png'
> fig.savefig(name_plt,bbox_inches='tight')
> 
> 
> -- 
> Stephen P. Molnar, Ph.D.  Life is a fuzzy set
> www.molecular-modeling.netStochastic and multivariate
> (614)312-7528 (c)
> Skype: smolnar1
> 
> ___
> 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] AttributeError: 'BezierPath' object has no attribute '_draw_solid'

2017-11-20 Thread William Ray Wing

> On Nov 20, 2017, at 9:55 AM, Stephen P. Molnar  wrote:
> 
> 
> On 11/20/2017 09:34 AM, William Ray Wing wrote:


[byte]

>> As an experiment, I took the code and moved it to my laptop (MacOS, running 
>> 10.12.6 where there is a complete Anaconda installation that contains 
>> self-consistent versions of everything Dr. Molnar imports (Python 3.6.1 
>> incidentally).  There the code runs perfectly.  I’m appending a copy of the 
>> .png file it produced, and although I expect it to be scraped off by the 
>> gateway list-server, it should show up in Dr. Molnar’s e-mail.
>> 
>> Bill
>> 
>> 
>> 


[big byte]


> Hmm!  I'm relieved that the code works!
> 
> I've just encountered something strange.
> 
> I haven't been using Python very long, only about six months or so.  When I 
> started I  look at a number of different IDE, and settled on Spyder, 
> although not in Anaconda.  I just installed Canopy in order to use the 
> ipython notebook, and the code ran perfectly in the Canopy editor  
> Perhaps I should switch IDE's, but I rather like the Variable Explorer 
> feature in Spyder.
> -- 
There are lots of IDEs.  Some of them have more trouble than others dealing 
with graphics from within a GUI window.  I happen to use (and like WingIDE - 
the name collision is purely an accident).  It supports multiple sub-windows, 
including ones for examining variables, and also running short snippets of code 
independently of the main code (thus, and very handy in science, plot an array 
as it exists at a break point to see what it “looks” like, and not just look at 
numbers).  I would highly recommend you explore alternative IDEs.

Bill


> Stephen P. Molnar, Ph.D.  Life is a fuzzy set
> www.molecular-modeling.net <http://www.molecular-modeling.net/>   
> Stochastic and multivariate
> (614)312-7528 (c)
> Skype: smolnar1

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


Re: [Tutor] Problem python script

2017-12-19 Thread William Ray Wing


Sent from my iPhone

> On Dec 19, 2017, at 3:47 AM, Antoan Hristov  wrote:
> 
> Hello,
> 
> I am using a script which extracts data from internet every Monday, but
> sometimes I have a problem that the script is not finishing properly. In
> terminal I stop it with Ctrl-C and the message it gives me is:
> File "castorama.py", line 255, in main
>p.map(get_all_data,magasins)
>   

As Alan has said, knowing what is going on when the error was triggered by the 
^C is difficult to impossible. 
What you may have to do is insert a fair number of “progress” statements that 
are all directed to a log file. Then, even if you have to stop execution with a 
^C, you can still see what was happening or where it was spinning its wheels. 
With that info at your finger tips, you can zoom in with finer resolution and 
even dump the state of all the relevant variables. 

Bill


> Antoan Hristov
> ___
> 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] Beginner Level Projects

2018-04-19 Thread William Ray Wing

> On Apr 18, 2018, at 9:34 PM, Joshua Nghe  wrote:
> 
> Hi,
> 
> This is Joshua N from Campus Middle School in CO. Our science class is 
> collectively participating in a project that consumes 20% of our classtime 
> every week. For my project, I chose to learn Python, and create something 
> from what I learned. I currently have around 10 hours spent learning Python, 
> and predict to have at least 20 by the time I start my project. According to 
> my level of experience, what would be an interesting project that would 
> exihbit all that I've learned.
> 

Since we don’t know your interests, or how fast your are progressing, it is a 
bit hard to make suggestions.  But if you were to Google “simple python 
projects” you will get a page full of sites with lists and suggestions of fun 
starter projects.

Bill

> 
> Thanks,
> 
>   Joshua
> 
> ___
> 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] Python 3.6.5 for MAC

2018-04-23 Thread William Ray Wing

> On Apr 23, 2018, at 6:29 AM, Giorgio De Angelis  
> wrote:
> 
> Hello guys,
> 
> I have a problem with my MacBook Pro ’13, version 10.13.4, because when I try 
> to open the shell it says that it couldn’t make any connection because it 
> wasn’t able to make a subprocess. Can you help me?
> 

Sorry, do you mean open a shell in the Terminal application, or open a shell in 
a python subprocess?

Bill

> Giorgio
> ___
> 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] Fwd: Can tempfile.NamedTemporaryFile(delete=False) be used to create *permanent* uniquely named files?

2018-10-22 Thread William Ray Wing via Tutor


> On Oct 22, 2018, at 8:30 PM, boB Stepp  wrote:
> 
> On Mon, Oct 22, 2018 at 11:57 AM Mats Wichmann  wrote:
>> 
>> On 10/22/18 8:24 AM, boB Stepp wrote:
>>> Forwarding to the Tutor list.  Herr Maier offers a good idea that
>>> would take away much of a remaining issue -- the name "Temporary".  I
>>> need to look into the functools library to see what "partial" does.
>> 
>> 
>> if you really don't care what the file is called because you will
>> maintain a map which leads you to the filename, you might as well use a
>> uuid.
> 
> Wouldn't I have to write a check to ensure such a named file (However
> unlikely that would be.) did not exist before creating it?  And if
> yes, would not that get into the same potential security issue that
> cause tempfile.mktemp() to be deprecated?
> 

The whole point of UUIDs is to make the probability of a UUID collision so 
infinitesimally small as to make that hypothetical collision simply not worth 
worrying about, even when they are created on different systems.  Since a big 
chunk of a UUID is a high precision time stamp, any UUIDs created on a single 
system are pretty much guaranteed to be unique.

Bill 

> -- 
> boB
> ___
> 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] Questions

2019-04-08 Thread William Ray Wing via Tutor
Diana, I’m answering you via the Tutor list - please, the accepted protocol is 
to send all questions and answers to the list so answers can be seen by (and 
possibly help) others.

Having said that, I should have paid more attention to your original question, 
which is really going to require answers that are beyond the typical Tutor 
question level, so I’m also forwarding to the main Python list where you should 
be able to get pointers.

But let me ask, how much programming do you know? Python is a full-blown 
programming language, like Java or C.  Have you written programs before that, 
for example can accept a file name from a user, open that file, and read its 
contents?  If yes, then I apologize, and would point you at:


https://medium.freecodecamp.org/how-to-scrape-websites-with-python-and-beautifulsoup-5946935d93fe
 


https://towardsdatascience.com/how-to-web-scrape-with-python-in-4-minutes-bc49186a8460

https://realpython.com/python-web-scraping-practical-introduction/
or
https://docs.python-guide.org/scenarios/scrape/

The next steps would probably involve loading that scraped data into Pandas:


https://pandas.pydata.org/pandas-docs/stable/getting_started/tutorials.html


https://data36.com/pandas-tutorial-1-basics-reading-data-files-dataframes-data-selection/

https://www.tutorialspoint.com/python_pandas

On the other hand, if your answer to my question is: “no” - then you should 
take a look at any of the really vast
collection of web sites devoted to Python learning.  Note that Python was 
originally designed to be a language that would be easy for beginners to learn. 
 It still is - I’d claim it is about the easiest -

>>> print( "Hello world!" ) 
Hello world!

Those lines were lifted from Alan Gauld’s learn to program web site.

Let us know how we can help.

Bill


> On Apr 8, 2019, at 5:40 PM, Diana Katz  wrote:
> 
> Yes - data would need to be scraped from sec.gov <http://sec.gov/> website. 
> I want to be able to pull up segment data from 10-Q filings of individual 
> companies by putting in a ticker (preferably in excel, but an be done 
> elsewhere).  Trying to figure out how to even start setting this up. 
> 
> Thank you!
> 
> On Sun, Apr 7, 2019 at 8:57 PM William Ray Wing  <mailto:w...@mac.com>> wrote:
> 
> 
> > On Apr 5, 2019, at 8:01 PM, Diana Katz  > <mailto:diana.k...@gmail.com>> wrote:
> > 
> > 1) Can you use python from excel? Or just export to excel?
> 
> Simple answer: no.  Python can read and write excel files through libraries:
> 
>  https://www.datacamp.com/community/tutorials/python-excel-tutorial 
> <https://www.datacamp.com/community/tutorials/python-excel-tutorial> 
> 
> > 2) I am trying to see if there's a way using python to automate all of this
> > work that I need to do. I have to collect quarterly segment data for
> > hundreds of public companies and go back at least 12-16 quarters. We use an
> > aggregator like factset and they actually don't have this option available
> > in an automated way. So I'm trying to see if there's a way to build this.
> 
> We really need more information to be of any help.  Is the starting data 
> coming from a web site?
> Python scripts can interact with web sites, “scrape” data from them or read 
> data from files downloaded in response to the script's interaction with the 
> site. The python library Pandas (named by its originator in the financial 
> field where such data is referred to as “panel” data) is optimized for 
> manipulating spreadsheet-like tables of data (it includes a pivot operation).
> 
> > Basically, I get my data from sec.gov <http://sec.gov/> and they have 
> > interactive data - they
> > even have the data in excel (though it's a messy file and hard to read). I
> > attached some of the steps and the data that i'd want to see.
> > Basically i'd want the excel to look like:
> > old to new quarters - going back 12 to 16 quarters (more if possible but
> > not if it will stop the project).
> > Columns: 3/31/2017, 6/30/2017, 9/30/17, 12/31/17, 3/313/2018...
> > Rows:
> > Sales for segment A
> > Sales for Segment b
> > Sales for SEgment C
> > …(for as many segments as they have)
> > 
> > Earnings for Segment A
> > .Earnings for Segment B
> > 
> > Depreciation for Segment A
> > Depreciation for Segment B
> > Depreciation for Segment C...
> > 
> > I included where I get the data in the attached document.
> 
> Since attachments can contain unknown contents, this list drops them.
> 
> Bill
> 
> > 
> > All the best,
> > 
> > Diana Katz
> > 

Re: [Tutor] How to Scrape Text from PDFs

2019-06-17 Thread William Ray Wing via Tutor


> On Jun 17, 2019, at 1:30 AM, Cem Vardar  wrote:
> 
> Hello,
> 
> I have been working on assignment that was described to me as “fairly 
> trivial” for a couple of days now. I have some PDF files that have links for 
> some websites and I need to extract these links from these files by using 
> Python. I would be very glad if someone could point me in the direction of 
> some resources that would give me the essential skills specific for this task.
> 

Unfortunately, a PDF can contain anything from almost PostScript to a bit map.  
But lets assume your PDFs are of the almost PostScript flavor.  In that case 
you can simply read them as text, and then use standard Python’s standard 
string searching for http:// or https://.  Each time you find one, stop and 
parse (again with string handling) the URL looking for one of the typical 
terminators (e.g. .com, .net, .org etc.).

It might help to cheat a bit and open one of the PDFs with a standard text 
editor and using it, search for http:// and see what turns up.  I’ll bet it 
will be fairly clear.

Bill

> Sincerely,
> Cem
> ___
> 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] data structures general query

2019-06-26 Thread William Ray Wing via Tutor

> On Jun 26, 2019, at 6:40 AM, mhysnm1...@gmail.com wrote:
> 
> All,
> 
> 
> 
> General computer science question for data structures.
> 
> When would you use the below structures and why? If you can provide a real
> life example on when they would be used in a program  This would be great. I
> am not after code, just explanation.
> 

One of the most useful (to me) structures is the double-ended queue ("from 
collections import deque”).  It creates a queue that can quickly remove an item 
from one end and add an item to the other.  Particularly useful for displaying 
a sliding window into time series data, or a moving track of the most recent n 
observations of a physical measurement.

Bill

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


Re: [Tutor] Package which can extract data from pdf

2019-08-14 Thread William Ray Wing via Tutor

> On Aug 14, 2019, at 2:16 PM, Mats Wichmann  wrote:
> 
>> On 8/14/19 10:10 AM, Nupur Jha wrote:
>> Hi All,
>> 
>> I have many pdf invoices with different formats. I want to extract the line
>> items from these pdf files using python coding.
>> 

Treat this as a two part problem: part one is extracting the text; part two is 
parsing that text for your desired information. Unless you have a specific need 
for extracting the text with python, I’d recommend solving part one with an 
image-to-text reader. These have gotten really quite good recently (AI no 
doubt). Then parsing the text with python’s string handling routines should be 
pretty straightforward. 

Bill

>> I would request you all to guide me how can i achieve this.
>> 
> 
> There are many packages that attempt to extract text from pdf.  They
> have varying degrees of success on various different documents: you need
> to be aware that PDF wasn't intended to be used that way, it was written
> to *display* consistently.  Sometimes the pdf is full of instructions
> for rendering that are hard for a reader to figure out, and need to be
> pieced together in possibly unexpected ways.  My experience is that if
> you can select the interesting text in a pdf reader, and paste it into
> an editor, and it doesn't come out looking particularly mangled, then
> reading it programmatically has a pretty good chance of working. If not,
> you may be in trouble. That said...
> 
> pypdf2, textract, and tika all have their supporters. You can search for
> all of these on pypi, which will give you links to the projects' home pages.
> 
> (if it matters, tika is an interface to a bunch of Java code, so you're
> not using Python to read it, but you are using Python to control the
> process)
> 
> There's a product called pdftables which specifically tries to be good
> at spreadsheet-like data, which your invoices *might* be.  That is not a
> free product, however. For that one there's a Python interface that
> sends your data off to a web service and you get answers back.
> 
> There are probably dozens more... this seems to be an area with a lot of
> reinvention going on.
> 
> ___
> 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