Re: [Tutor] Programming microsoft excel

2010-05-06 Thread wesley chun
> guys can i use python's win32com module to do the same tasks that i do with > visual basic for applications (vba). I mean automating tasks for excel e.t.c > and accessing Access databases. If win32com doesnt which module can i use? that's definitely the right one, and yes, you can use VB/VBA

Re: [Tutor] Newbie & Unittest ...

2010-05-06 Thread Steven D'Aprano
On Fri, 7 May 2010 03:53:08 am Damon Timm wrote: > Hi Lie - > > Thanks for that idea -- I tried it but am getting an error. I read a > little about the __dict__ feature but couldn't figure it. I am going > to keep searching around for how to dynamically add methods to a > class ... here is the er

Re: [Tutor] Newbie & Unittest ...

2010-05-06 Thread Steven D'Aprano
On Thu, 6 May 2010 10:37:20 am Damon Timm wrote: > class TestFiles(unittest.TestCase): > > # this is the basic test > def test_values(self): > '''see if values from my object match what they should > match''' > for file in FILES: > for k, v in TAG_VA

Re: [Tutor] portability of pickle and shelve across platforms and different python versions?

2010-05-06 Thread Steven D'Aprano
On Thu, 6 May 2010 09:12:24 am Garry Willgoose wrote: > How portable are files containing pickle'd and shelve'd data? I'm > thinking issues like simply O/S portability, through > big-end/little-end hardware (for floats/integers which I use a lot), > and then for unicode/non-unicode string, 64/32

Re: [Tutor] Is the difference in outputs with different size input lists due to limits on memory with PYTHON?

2010-05-06 Thread Dave Angel
Art Kendall wrote: On 5/6/2010 1:51 PM, Dave Angel wrote: Art Kendall wrote: On 5/6/2010 11:14 AM, Dave Angel wrote: Art Kendall wrote: I am running Windows 7 64bit Home premium. with quad cpus and 8G memory. I am using Python 2.6.2. I have all the Federalist Papers concatenated into

[Tutor] Programming microsoft excel

2010-05-06 Thread hbutau
Hi guys can i use python's win32com module to do the same tasks that i do with visual basic for applications (vba). I mean automating tasks for excel e.t.c and accessing Access databases. If win32com doesnt which module can i use? Thanks in advance ---

Re: [Tutor] Is the difference in outputs with different size input lists due to limits on memory with PYTHON?

2010-05-06 Thread Alan Gauld
"Art Kendall" wrote Is there a way to tell python to use more RAM? Only in an arcane way you should never need. This is not Fortran and Python does all the memory management for you so you don't need to worry 99.9% of the time. BTW is Python some kind of a grandchild to Algol which was ar

Re: [Tutor] List comprehension + lambdas - strange behaviour

2010-05-06 Thread Alan Gauld
I found this strange behaviour of lambdas, closures and list comprehensions: funs = [lambda: x for x in range(5)] [f() for f in funs] [4, 4, 4, 4, 4] Of course I was expecting the list [0, 1, 2, 3, 4] as the result. The 'x' was bound to the final value of 'range(5)' expression for

Re: [Tutor] Is the difference in outputs with different size input lists due to limits on memory with PYTHON?

2010-05-06 Thread Art Kendall
On 5/6/2010 1:51 PM, Dave Angel wrote: Art Kendall wrote: On 5/6/2010 11:14 AM, Dave Angel wrote: Art Kendall wrote: I am running Windows 7 64bit Home premium. with quad cpus and 8G memory. I am using Python 2.6.2. I have all the Federalist Papers concatenated into one .txt file. Which

Re: [Tutor] List comprehension + lambdas - strange behaviour

2010-05-06 Thread spir ☣
On Thu, 06 May 2010 16:53:07 -0300 Ricardo Aráoz wrote: > So you see, your functions just return the value of x. That's because > the lambda have no parameter, so x refers to the global name x. In other words, the "upvalue" (the variable captured in the closure) is referenced. Meaning if you la

Re: [Tutor] List comprehension + lambdas - strange behaviour

2010-05-06 Thread Ricardo Aráoz
Artur Siekielski wrote: > Hello. > I found this strange behaviour of lambdas, closures and list > comprehensions: > > funs = [lambda: x for x in range(5)] [f() for f in funs] > [4, 4, 4, 4, 4] > > Of course I was expecting the list [0, 1, 2, 3, 4] as the result. The > 'x'

Re: [Tutor] Newbie & Unittest ...

2010-05-06 Thread Vincent Davis
On Thu, May 6, 2010 at 1:15 PM, Steve Willoughby wrote: > The unit test methods all take message arguments so if you just > want to customize the reported error, that's easily done. > > something like: > self.assertEqual(self.file.tags[k], v, "Failure with key "+k) > > That's easiest. If you re

Re: [Tutor] Newbie & Unittest ...

2010-05-06 Thread Steve Willoughby
The unit test methods all take message arguments so if you just want to customize the reported error, that's easily done. something like: self.assertEqual(self.file.tags[k], v, "Failure with key "+k) That's easiest. If you really want a separate test for each, you may want to create a factory

Re: [Tutor] Newbie & Unittest ...

2010-05-06 Thread Damon Timm
Sorry for the multiple posts ... I'll be quiet for a while until I find a real answer! What I wrote below doesn't actually work -- it appears to work because all the functions have different names but they all reference a single function ... I should have looked more closely at my initial output..

Re: [Tutor] Newbie & Unittest ...

2010-05-06 Thread Damon Timm
Ooh! Wait! I found another method that is similar in style and appears to work ... class TestFileTags(unittest.TestCase): pass for test_name, file, key, value in list_of_tests: def test_func(self): self.assertEqual(file.tags[key], value) setattr(TestFileTags, test_name, tes

Re: [Tutor] Newbie & Unittest ...

2010-05-06 Thread Damon Timm
Hi Lie - Thanks for that idea -- I tried it but am getting an error. I read a little about the __dict__ feature but couldn't figure it. I am going to keep searching around for how to dynamically add methods to a class ... here is the error and then the code. Thanks. # ERROR: $ python tests_ta

Re: [Tutor] Is the difference in outputs with different size input lists due to limits on memory with PYTHON?

2010-05-06 Thread Dave Angel
Art Kendall wrote: On 5/6/2010 11:14 AM, Dave Angel wrote: Art Kendall wrote: I am running Windows 7 64bit Home premium. with quad cpus and 8G memory. I am using Python 2.6.2. I have all the Federalist Papers concatenated into one .txt file. Which is how big? Currently you (unnecessarily

Re: [Tutor] Is the difference in outputs with different size input lists due to limits on memory with PYTHON?

2010-05-06 Thread Art Kendall
On 5/6/2010 11:14 AM, Dave Angel wrote: Art Kendall wrote: I am running Windows 7 64bit Home premium. with quad cpus and 8G memory. I am using Python 2.6.2. I have all the Federalist Papers concatenated into one .txt file. Which is how big? Currently you (unnecessarily) load the entire th

Re: [Tutor] Newbie & Unittest ...

2010-05-06 Thread Lie Ryan
On 05/06/10 10:37, Damon Timm wrote: > Hi - am trying to write some unit tests for my little python project - > I had been hard coding them when necessary here or there but I figured > it was time to try and learn how to do it properly. > > This test works, however, it only runs as *one* test (whi

Re: [Tutor] Newbie & Unittest ...

2010-05-06 Thread Damon Timm
Hi Vincent - Thanks for your input. Where would I put that string ? In the function's doctsring ? Or just as a print method ? I have been looking online some more and it appears there may be a way to create some sort of generator ... it's still a little confusing to me, though. I was hoping th

Re: [Tutor] Is the difference in outputs with different size input lists due to limits on memory with PYTHON?

2010-05-06 Thread Dave Angel
Art Kendall wrote: I am running Windows 7 64bit Home premium. with quad cpus and 8G memory. I am using Python 2.6.2. I have all the Federalist Papers concatenated into one .txt file. Which is how big? Currently you (unnecessarily) load the entire thing into memory with readlines(). And the

Re: [Tutor] portability of pickle and shelve across platforms and different python versions?

2010-05-06 Thread python
Garry, I asked a similar question on Stackoverflow.com and got some great responses including at least one from a member of the Python development team. Best way to save complex Python data structures across program sessions (pickle, json, xml, database, other) http://stackoverflow.com/questions/

Re: [Tutor] portability of pickle and shelve across platforms and different python versions?

2010-05-06 Thread Bjorn Egil Ludvigsen
I do not know all the details, but I think it is NOT portable. The reason I am saying this is from a comment in Mark Summerfields excellent book "Rapid GUI programming with Python and Qt" where he has an example that uses several different load/save methods (chapter 8). He recommends using Qt's QD

Re: [Tutor] Newbie & Unittest ...

2010-05-06 Thread Vincent Davis
By they way you shouldn't need to use str(file) as I did. Unlessit is not a string already. Bad habit. I am used to numbers vincet On Thursday, May 6, 2010, Vincent Davis wrote: > I can't think of a way to do what you ask, without defining a test for each. > ButI think what you might actually wa

Re: [Tutor] Newbie & Unittest ...

2010-05-06 Thread Vincent Davis
I can't think of a way to do what you ask, without defining a test for each. ButI think what you might actually want is the define the error message to report which one failed. ie, it's one test with a meaningful error message. 'Failed to load' + str(file)+' '+ str(k)+', '+str(v) I am not ecpert on

[Tutor] Is the difference in outputs with different size input lists due to limits on memory with PYTHON?

2010-05-06 Thread Art Kendall
I am running Windows 7 64bit Home premium. with quad cpus and 8G memory. I am using Python 2.6.2. I have all the Federalist Papers concatenated into one .txt file. I want to prepare a file with a row for each paper and a column for each term. The cells would contain the count of a term in t