Re: [Tutor] reading files in Python 3

2017-03-31 Thread Mats Wichmann
On 03/30/2017 11:02 AM, Rafael Knuth wrote: > I can read files like this (relative path): > > with open("Testfile_B.txt") as file_object: > contents = file_object.read() > print(contents) > > But how do I read files if I want to specify the location (absolute path): > > file_path = "C:\U

Re: [Tutor] HTML module for Python

2017-03-31 Thread ਪੰਜਾਬ ਪੰਜਾਬੀ
Thank you Alan. I needed to generate a report using a python script (will become part of a web service) and send it as an email. For now I put the required HTML tags wherever they were needed. Thanks Sri Kavi. I'll check out your suggestion. On Wed, Mar 22, 2017 at 12:29 AM, Alan Gauld via Tut

Re: [Tutor] super constructor usage

2017-03-31 Thread Mats Wichmann
On 03/30/2017 05:39 AM, Rafael Knuth wrote: I am trying to wrap my head around the super constructor. > > Is it possible to embed a super constructor into an if / elif > statement within the child class? > > if message == "string A": return X > elif: return Y > > How should I modify my code

[Tutor] All Entry Boxes taking the same value

2017-03-31 Thread Pooja Bhalode
Hi, I am working on a GUI application where I have a multiple number of entry boxes and I created a loop for the label and entry boxes depending upon the number of times it needs to be shown. However, I tried assigning different values to each label and entry boxes in the for loop using lists, so t

Re: [Tutor] super constructor usage

2017-03-31 Thread Alan Gauld via Tutor
On 30/03/17 21:08, Alan Gauld via Tutor wrote: > Of course, the __init__ methods are special in any way Should have said *not special* in any way... > But remember that not calling super potentially leaves > some attributes of your superclass uninitialized. By not > calling super you assume full

Re: [Tutor] python gtk serial loop thread readind data close

2017-03-31 Thread Alan Gauld via Tutor
On 30/03/17 13:40, Alexandru Achim via Tutor wrote: > Dear users, > I had a problem regarding Threads in python and Gtk3. This list is really for the core language and library, I suspect you might get a better response by asking on the PyGTK forum where there are more likely to be people who have

Re: [Tutor] All Entry Boxes taking the same value

2017-03-31 Thread Peter Otten
Pooja Bhalode wrote: > average = [" ", " ", " "] > for i in range(len(reactants)): > Entry(root, textvariable = average[i], width = 15, > state=DISABLED).grid(row = 3+i, column = 1, sticky = W) Hint: What is passed as textvariable? What should be? Unfortunately the Entry accepts both St

Re: [Tutor] All Entry Boxes taking the same value

2017-03-31 Thread Alan Gauld via Tutor
On 30/03/17 21:35, Pooja Bhalode wrote: > *However, when I execute it, and type something in one entrybox, it shows > in all the entry boxes using multi-cursor option. * I'm not sure whats going on and don;t habe tome to experiment but one thing I noticed: > average = [" ", " ", " "] > lowest =

[Tutor] Using an XML file for web crawling

2017-03-31 Thread Igor Alexandre
Hi! I'm a newbie in the Python/Web crawling world. I've been trying to find an answer to the following question since last week, but I couldn't so far, so I decided to ask it myself here: I have a sitemap in XML and I want to use it to save as text the various pages of the site. Do you guys know

[Tutor] Extract Block of Data from a 2D Array

2017-03-31 Thread Stephen P. Molnar
I have a block of data extracted from a quantum mechanical calculation: CARTESIAN COORDINATES (A.U.) NO LB ZAFRAG MASS X Y Z 0 C 6.012.011 -3.2656360.1988940.090858 1 C 6.012.01

Re: [Tutor] Using an XML file for web crawling

2017-03-31 Thread Alan Gauld via Tutor
On 31/03/17 12:23, Igor Alexandre wrote: > I have a sitemap in XML and I want to use it to save as text the various pages What about non-text pages such as images and media files? > I'm looking for some code on the web where I can just type the xml address > and wait for the crawler to do it's

Re: [Tutor] Extract Block of Data from a 2D Array

2017-03-31 Thread Alan Gauld via Tutor
On 31/03/17 13:19, Stephen P. Molnar wrote: > I have a block of data extracted from a quantum mechanical calculation: How is this data stored? On paper? In a database? In XML? A CSV file? Plain text? The answer to that will go a long way to pointing you in the right direction for a solution. > CA

Re: [Tutor] Extract Block of Data from a 2D Array

2017-03-31 Thread Karim
On 31/03/2017 14:19, Stephen P. Molnar wrote: I have a block of data extracted from a quantum mechanical calculation: CARTESIAN COORDINATES (A.U.) NO LB ZAFRAG MASS X Y Z 0 C 6.012.011 -3.2656360.

Re: [Tutor] subprocess.Popen / proc.communicate issue

2017-03-31 Thread bruce
Cameron!!! You are 'da man!! Read your exaplanation.. good stuff to recheck/test and investigate over time In the short term, I'll implement some tests!! thanks! On Thu, Mar 30, 2017 at 6:51 PM, Cameron Simpson wrote: > I wrote a long description of how .communicate can deadlock. > > The

Re: [Tutor] Extract Block of Data from a 2D Array

2017-03-31 Thread Peter Otten
Stephen P. Molnar wrote: > I have a block of data extracted from a quantum mechanical calculation: > > CARTESIAN COORDINATES (A.U.) > >NO LB ZAFRAG MASS X Y Z > 0 C 6.012.011 -3.2656360.1988940

Re: [Tutor] reading files in Python 3

2017-03-31 Thread Alex Kleider
On 2017-03-30 13:45, Mats Wichmann wrote: Yeah, fun. You need to escape the \ that the idiot MS-DOS people chose for the file path separator. I also believe that the "MS-DOS people" are making a poor choice but to call them idiots is perhaps a bit strong. Remember that for many the use of Mi

Re: [Tutor] Using an XML file for web crawling

2017-03-31 Thread Mats Wichmann
On 03/31/2017 05:23 AM, Igor Alexandre wrote: > Hi! > I'm a newbie in the Python/Web crawling world. I've been trying to find an > answer to the following question since last week, but I couldn't so far, so I > decided to ask it myself here: I have a sitemap in XML and I want to use it > to save

Re: [Tutor] reading files in Python 3

2017-03-31 Thread Mats Wichmann
On 03/31/2017 09:44 AM, Alex Kleider wrote: > On 2017-03-30 13:45, Mats Wichmann wrote: > >> >> Yeah, fun. You need to escape the \ that the idiot MS-DOS people chose >> for the file path separator. > > I also believe that the "MS-DOS people" are making a poor choice > but to call them idiots is

Re: [Tutor] Extract Block of Data from a 2D Array

2017-03-31 Thread Stephen P. Molnar
On 03/31/2017 10:29 AM, Alan Gauld via Tutor wrote: On 31/03/17 13:19, Stephen P. Molnar wrote: I have a block of data extracted from a quantum mechanical calculation: How is this data stored? On paper? In a database? In XML? A CSV file? Plain text? The answer to that will go a long way to poi

Re: [Tutor] All Entry Boxes taking the same value

2017-03-31 Thread Pooja Bhalode
Hi Peter and Alan, Yes, thank you for your suggestions. I really appreciate it. I would look into a proper tutorial and try to follow it up. The suggestion regarding this piece of code worked when I tried StringVar instead of " ". Thank you once again. Yours truly, Pooja On Fri, Mar 31, 2017 at

Re: [Tutor] Extract Block of Data from a 2D Array

2017-03-31 Thread Stephen P. Molnar
On 03/31/2017 10:50 AM, Peter Otten wrote: Stephen P. Molnar wrote: I have a block of data extracted from a quantum mechanical calculation: CARTESIAN COORDINATES (A.U.) NO LB ZAFRAG MASS X Y Z 0 C 6.0

Re: [Tutor] reading files in Python 3

2017-03-31 Thread eryk sun
On Thu, Mar 30, 2017 at 8:45 PM, Mats Wichmann wrote: > Yeah, fun. You need to escape the \ that the idiot MS-DOS people chose > for the file path separator. Because \ is treated as an escape character. The COMMAND.COM shell inherited command-line switches (options) that use slash from TOPS-10 b

Re: [Tutor] subprocess.Popen / proc.communicate issue

2017-03-31 Thread Cameron Simpson
On 31Mar2017 06:13, eryk sun wrote: On Thu, Mar 30, 2017 at 10:51 PM, Cameron Simpson wrote: This suggests that .communicate uses Threads to send and to gather data independently, and that therefore the deadlock situation may not arise. For Unix, communicate() uses select or poll. It uses th

[Tutor] Validating String contains IP address

2017-03-31 Thread Ed Manning
What's the best way to validate a string contains a IP address Sent from my iPad ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Validating String contains IP address

2017-03-31 Thread Alan Gauld via Tutor
On 01/04/17 00:35, Ed Manning wrote: > > What's the best way to validate a string contains a IP address It depends on how thorough you want to be. You can define a regex to check that its 4 groups of numbers separated by periods. Or you can split the string into fields and validate that the val

Re: [Tutor] Validating String contains IP address

2017-03-31 Thread Martin A. Brown
Hello there, >What's the best way to validate a string contains a IP address If you are only talking about validating that something is an IP address, then I can even give you a little Python2 / Python3 snippet that can do that. I like the EAFP [0] approach for this sort of thing. There ar

Re: [Tutor] Validating String contains IP address

2017-03-31 Thread Alex Kleider
On 2017-03-31 16:35, Ed Manning wrote: What's the best way to validate a string contains a IP address Sent from my iPad ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Validating String contains IP address

2017-03-31 Thread Steven D'Aprano
On Fri, Mar 31, 2017 at 07:35:48PM -0400, Ed Manning wrote: > > What's the best way to validate a string contains a IP address Don't reinvent the wheel, use the ipaddress module. py> import ipaddress py> ipaddress.ip_address('99.99.99.99') IPv4Address('99.99.99.99') If the address is not a va