Re: [Tutor] Can This Script Be Modified to Read Many Files?..

2016-01-25 Thread Bob Gailer
On Jan 25, 2016 6:26 PM, "Sam Starfas via Tutor" wrote: > > Hi,I am very new to Python, but having fun learning. > I need to have a script read all of the XML files contents that are in a directory, pull out the contents of an element, in my case , and list them in an output file. I have this scri

Re: [Tutor] Can This Script Be Modified to Read Many Files?..

2016-01-25 Thread Alan Gauld
On 25/01/16 21:34, Sam Starfas via Tutor wrote: > Can the below script be modified to scan/read all of the XML files in a > directory You could do it manually using for file in glob.glob("*.xml"): But you need to think about all the other possible file endings too. Or you could look at the fi

[Tutor] Can This Script Be Modified to Read Many Files?..

2016-01-25 Thread Sam Starfas via Tutor
Hi,I am very new to Python, but having fun learning.  I need to have a script read all of the XML files contents that are in a directory, pull out the contents of an element, in my case , and list them in an output file. I have this script that does exactly what I need. But in my beginning Pytho

Re: [Tutor] Variation in game of life in python solution by numpy method

2016-01-25 Thread Alan Gauld
On 25/01/16 17:53, Mahesh Dabhade wrote: > Now I am not even able to count the neighbors Then start with that as a first step. > Can u plzz help me out in counting neighbours... We need to see what you are doing to be able to help > N even better can u plzz send the program code No, w

Re: [Tutor] Noob: nested if-clauses

2016-01-25 Thread Alan Gauld
On 25/01/16 15:52, STF wrote: > It's a total fluke. I put the indentation like this to *visually* help > myself understand what I was going to write. That's one of the good things about Python, if it looks right it very often is right. > In the Python tutorial that I was using, the author only

Re: [Tutor] Variation in game of life in python solution by numpy method

2016-01-25 Thread Mark Lawrence
On 25/01/2016 17:53, Mahesh Dabhade wrote: Hi...I have problem in game of life... But I have 4 states rather than just two states like live and dead... These are 0 : bare earth 1: grass 2: prey 3: predator And rules are 1 )if 2 surrounded by less than 2 of 1 then 2 becomes 1.starvation 2)if 0

Re: [Tutor] Need Help

2016-01-25 Thread Mark Lawrence
On 25/01/2016 16:09, Parinay Mahakur wrote: Hello Tutors, I need a program that should enable me to read values from a large number of ASCII files and then I have to plot desired values - In this file headings for all columns are also given. The link for the file is - http://jsoc.stanford.edu/S

Re: [Tutor] Noob: nested if-clauses

2016-01-25 Thread Danny Yoo
> if condition_C: > instruction_10 >instruction_11 > instruction_12 > > There are 4 spaces in front of instruction_10, 3 spaces in front of > instruction_11 and 5 spaces in front of instruction_12. > > What would happen to instruction_11 and instruction_12? Would Python > ignore

Re: [Tutor] Help!

2016-01-25 Thread Alan Gauld
On 25/01/16 17:39, Chelsea G wrote: > Hi, > I am trying to create a keyword search, so that someone can type in a key > phrase and then the output be the value with the key. I'm not completely clear what you mean by a key phrase? Do you mean a phrase matching the keys in your dictionary?(In whic

Re: [Tutor] Need Help

2016-01-25 Thread Alan Gauld
On 25/01/16 16:09, Parinay Mahakur wrote: > I need a program that should enable me to read values from a large number > of ASCII files and then I have to plot desired values Have you considered a spreadsheet like Excel? You could write a couple of macros to read the files and to generate the plot

Re: [Tutor] What's pure OO? [was Re: Why do I not get an error when I mistakenly type ...]

2016-01-25 Thread Alan Gauld
On 25/01/16 15:02, Steven D'Aprano wrote: > On Sat, Jan 23, 2016 at 08:30:48PM +1100, Cameron Simpson wrote: > >> That is the pure OO way; > > Is this the room for an argument? I'd like the full half hour please. Personally I see OOP as a style thing rather than a language issue. And I do think

[Tutor] Variation in game of life in python solution by numpy method

2016-01-25 Thread Mahesh Dabhade
Hi...I have problem in game of life... But I have 4 states rather than just two states like live and dead... These are 0 : bare earth 1: grass 2: prey 3: predator And rules are 1 )if 2 surrounded by less than 2 of 1 then 2 becomes 1.starvation 2)if 0 surrounded by more than 0 of 1 then 0 become

Re: [Tutor] Noob: nested if-clauses

2016-01-25 Thread STF
Thanks to Joel and Alan for replying. On 24 January 2016 at 22:08, Alan Gauld wrote: > On 24/01/16 19:42, STF wrote: > > > Let's see the following instructions: > > > > if condition_A: > > instruction_1 > > instruction_2 > > if condition_B: > > instruction_3 > >

[Tutor] Help!

2016-01-25 Thread Chelsea G
Hi, I am trying to create a keyword search, so that someone can type in a key phrase and then the output be the value with the key. I have some code already done but having some trouble getting it to work. import csv import json import sys from collections import defaultdict from collections impor

[Tutor] Need Help

2016-01-25 Thread Parinay Mahakur
Hello Tutors, I need a program that should enable me to read values from a large number of ASCII files and then I have to plot desired values - In this file headings for all columns are also given. The link for the file is - http://jsoc.stanford.edu/SUM75/D780005879/S0/hmi.rdVfitsf_fd15.2171

[Tutor] What's pure OO? [was Re: Why do I not get an error when I mistakenly type ...]

2016-01-25 Thread Steven D'Aprano
On Sat, Jan 23, 2016 at 08:30:48PM +1100, Cameron Simpson wrote: > That is the pure OO way; Is this the room for an argument? I'd like the full half hour please. http://www.montypython.net/scripts/argument.php Without wishing to single out Cameron specifically, I'd like to take exception to

Re: [Tutor] Change datatype for specific columns in an 2D array & computing the mean

2016-01-25 Thread Oscar Benjamin
On 25 January 2016 at 13:14, Peter Otten <__pete...@web.de> wrote: >> What do you mean by "group rows"? > > Given a table you can specify columns as keys and in the simplest case one > column where you apply an aggregate function over the sets of rows with the > same key. > > If I understand you co

Re: [Tutor] Change datatype for specific columns in an 2D array & computing the mean

2016-01-25 Thread Peter Otten
Oscar Benjamin wrote: > On 24 January 2016 at 17:24, Peter Otten <__pete...@web.de> wrote: >> >> I'm an amateur with numpy, and unfortunately my favourite search engine >> didn't come up with a numpy-specific way to group rows in a 2D array. > > What do you mean by "group rows"? Given a table yo

Re: [Tutor] Change datatype for specific columns in an 2D array & computing the mean

2016-01-25 Thread Oscar Benjamin
On 24 January 2016 at 17:24, Peter Otten <__pete...@web.de> wrote: > > I'm an amateur with numpy, and unfortunately my favourite search engine > didn't come up with a numpy-specific way to group rows in a 2D array. What do you mean by "group rows"? I thought the OP's problem is really to filter r

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-25 Thread Oscar Benjamin
On 24 January 2016 at 20:29, Albert-Jan Roskam wrote: >> I guess that the authors of OrderedDict just didn't really consider >> this to be very useful. Apart from having ordered iteration >> OrderedDict is not really that deeply thought out. There's a thread on >> python-ideas about the inconsiste

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-25 Thread Oscar Benjamin
On 24 January 2016 at 19:47, Albert-Jan Roskam wrote: >> >> You appear to be confusing ordered and sorted. > You are correct. Is there a difference in the way those terms are used > colloquially vs. in the field of Computer Science (Note: English is not my > mother tongue)? Anyway, this page

Re: [Tutor] Why do I not get an error when I mistakenly type "humdrum.sigh_strenght" instead of the correct "humdrum.sigh_strength"?

2016-01-25 Thread Steven D'Aprano
On Sat, Jan 23, 2016 at 04:25:01PM -0600, boB Stepp wrote: > I think I now have this nuked out. I am only just now realizing how > powerful .__dict__ is: [...] > self.__dict__[attribute_name] = attribute_value Indeed, but generally speaking you hardly ever need to manually operate w

Re: [Tutor] Value of tracebacks to malicious attackers?

2016-01-25 Thread Steven D'Aprano
On Sat, Jan 23, 2016 at 10:52:27PM -0600, boB Stepp wrote: > From page 202 of "Python Crash Course": "..., but it's also not a > good idea to let users see tracebacks. [...] > How much concern do you give this in designing and implementing your > production code? Me personally? Absolutely none