[Tutor] [ANN] Gajja 0.1 (was: How do I test file operations (Such as opening, reading, writing, etc.)?)

2016-01-28 Thread Ben Finney
Ben Finney writes: > I have today published a different approach, which I designed for one > code base ad is to date its only user. I'm looking for more feedback. > > https://pypi.python.org/pypi/gajja/> I forgot to mention the appropriate channels for feedback: Please contact me at if you

Re: [Tutor] How do I test file operations (Such as opening, reading, writing, etc.)?

2016-01-28 Thread boB Stepp
On Thu, Jan 28, 2016 at 2:03 PM, Danny Yoo wrote: > Just to emphasize what I think is an essential point: the basic > approach we're doing is here parameterization: to take something that > used to be hardcoded, and turn it into a parameter that allows us to > substitute with something else. Tha

Re: [Tutor] How do I test file operations (Such as opening, reading, writing, etc.)?

2016-01-28 Thread Martin A. Brown
Hello there, >> I'll add one option to the mix, and summarize the other options I saw listed >> earlier. >> >> Option A (tempfile): >> >> Create a directory and copy your pristine tree into the directory >> and make the base directory for the important data files configurable. >> Also known

Re: [Tutor] How do I test file operations (Such as opening, reading, writing, etc.)?

2016-01-28 Thread boB Stepp
On Thu, Jan 28, 2016 at 5:09 PM, Martin A. Brown wrote: > I'll add one option to the mix, and summarize the other options I saw listed > earlier. > > Option A (tempfile): > > Create a directory and copy your pristine tree into the directory > and make the base directory for the important data

Re: [Tutor] How do I test file operations (Such as opening, reading, writing, etc.)?

2016-01-28 Thread boB Stepp
On Thu, Jan 28, 2016 at 4:14 PM, Alan Gauld wrote: > On 28/01/16 20:03, Danny Yoo wrote: >> (Aside: this is somewhat why I think the topic of inheritance and >> inheritance >> hierarchies are entirely the wrong things to focus on when we're >> teaching OOP. > > Absolutely. > I always try to focus

Re: [Tutor] How do I test file operations (Such as opening, reading, writing, etc.)?

2016-01-28 Thread boB Stepp
On Thu, Jan 28, 2016 at 2:44 AM, Alan Gauld wrote: > Danny has shown you one way using a mocked filesystem. > But for your case can't you just specify a file location > as an environment variable or argv? That way you get the > advantage of using real files, which can be an important > factor in

Re: [Tutor] How do I test file operations (Such as opening, reading, writing, etc.)?

2016-01-28 Thread boB Stepp
On Wed, Jan 27, 2016 at 11:24 PM, Danny Yoo wrote: > You can make the file input/output interface a parameter of your editor. > > ### > class Editor(object): > def __init__(self, filesystem): > self.filesystem = filesystem > ... > ##

Re: [Tutor] How do I test file operations (Such as opening, reading, writing, etc.)?

2016-01-28 Thread Martin A. Brown
Hello all, [much snipped] boB>> >> I don't want to mess with what will become the program's *real* boB>> >> classifiers.txt (And other needed text files to come, that will boB>> >> likewise be editable.), so how do I simulate these various needed file boB>> >> operations in a way that tests the

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

2016-01-28 Thread Ek Esawi
Thank you SO MUCH Oscar and others. This is exactly what i wanted to get. I think i can take it form here. I spent hours looking at different ways to figure it out and i came close. I tried numpy.genfromtxt, numpy.loadtext, json, etc. I am at the moment learning how to open various data files with

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

2016-01-28 Thread Albert-Jan Roskam
> Date: Wed, 27 Jan 2016 02:24:35 +1100 > From: st...@pearwood.info > To: tutor@python.org > Subject: Re: [Tutor] Why is an OrderedDict not sliceable? > > On Sun, Jan 24, 2016 at 07:47:47PM +, Albert-Jan Roskam wrote: > >>> You appear to be confusing o

Re: [Tutor] How do I test file operations (Such as opening, reading, writing, etc.)?

2016-01-28 Thread Alan Gauld
On 28/01/16 20:03, Danny Yoo wrote: > (Aside: this is somewhat why I think the topic of inheritance and > inheritance > hierarchies are entirely the wrong things to focus on when we're > teaching OOP. Absolutely. I always try to focus on the objects passing, and responding to, *messages* as the k

Re: [Tutor] How do I test file operations (Such as opening, reading, writing, etc.)?

2016-01-28 Thread Matt Williams
This is a problem I have come up against often, and I don't think I have a good answer, so if anyone else does, I would be glad to hear it! I would be tempted to generate a 'test data.CSV" file, and run the tests on that. It means that as you write the code, and find some edge cases, you can alter

Re: [Tutor] How do I test file operations (Such as opening, reading, writing, etc.)?

2016-01-28 Thread Danny Yoo
On Thu, Jan 28, 2016 at 12:44 AM, Alan Gauld wrote: > On 28/01/16 04:23, boB Stepp wrote: > >> I don't want to mess with what will become the program's *real* >> classifiers.txt (And other needed text files to come, that will >> likewise be editable.), so how do I simulate these various needed fil

[Tutor] lc_ctype and re.LOCALE

2016-01-28 Thread Albert-Jan Roskam
Hi, Out of curiosity, I wrote the throw-away script below to find a character that is classified (--> LC_CTYPE) as digit in one locale, but not in another. I ran it with 5000 locale combinations in Python 2 but did not find any (somebody shut down my computer!). I just modified the code so it al

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

2016-01-28 Thread Oscar Benjamin
On 27 January 2016 at 23:00, Ek Esawi wrote: > Ops..here is the text file.; previously i copied and pasted from either > Word or Excel. > > > AA,BB,CC,DD,EE > 1,A1,B1,11.2,11/20/2011 > 2,A2,B2,2.5,10/21/2011 > 3,A3,B3,13.67,9/21/2011 > 4,A4,B4,14.2,8/22/2011 > 5,A5,B5,20,7/23/2011 Finally! That's

Re: [Tutor] How do I test file operations (Such as opening, reading, writing, etc.)?

2016-01-28 Thread Alan Gauld
On 28/01/16 04:23, boB Stepp wrote: > I don't want to mess with what will become the program's *real* > classifiers.txt (And other needed text files to come, that will > likewise be editable.), so how do I simulate these various needed file > operations in a way that tests the actual program code,