using optparser

2010-10-16 Thread jimgardener
hi I have a program which I call findmatch that expects these arguments 1.a person name 2.a group name 3.an integer 4.a float value I thought I would allow user to call this program either using options or using positional arguments in a predefined order ie, findmatch -f schoolmates -i jon -t 3.

Re: how to make all assertions in a unit test execute

2010-10-16 Thread jimgardener
thanks Peter that was good advice jim On Oct 16, 1:44 pm, Peter Otten <__pete...@web.de> wrote: > Keep it simple ;) -- http://mail.python.org/mailman/listinfo/python-list

finding an exact match of filenames

2010-10-16 Thread jimgardener
I am trying to code a function that takes a directory name and a name string and try to return a list of fully qualified names of all files in the directory having an exact match of name. example, I have these files in the directory, 'googlegroup_python__111.txt', 'googlegroup_python__112.txt', 'g

how to make all assertions in a unit test execute

2010-10-16 Thread jimgardener
hi I was testing a function using unittest. def get_filenames(dirname,innerstring): return filenames_containing_innerstring class FileNamesTest(unittest.TestCase): def setUp(self): self.dirname='/home/me/data' def test_get_filenames(self): innerstr='tom'

how to add patch

2010-10-13 Thread jimgardener
hi I have some demo python code hosted on a public host that uses subversion..and I want to modify one of the files using a patch file handed to me by another person..How do I do this?Generally I checkout the code and make the change and then commit again..I have never done through patch..Can some

Re: singleton problems

2010-10-03 Thread jimgardener
hi Steven, can you explain that?I didn't quite get it. I have a module say 'managerutils' where I have a class MyManager.. ie, managerutils.py -- class MyManager(object): def __init__(self): self.myaddresses={} ... from another main program ,if I call , import managerutils

read() returns data of different sizes

2010-10-02 Thread jimgardener
hi while trying out urllib.urlopen ,I wrote this code to read a url and return the data length import datetime,time,urllib def get_page_size(pageurlstr): h=urllib.urlopen(pageurlstr) data=h.read() return len(data) while True: print 'reading url www.google.com at',datetime

solving Tix problem in ubuntu jaunty

2010-07-29 Thread jimgardener
hi, recently I switched to ubuntu jaunty and installed python 2.6.I installed lib-tk so that I can work on my gui apps using Tix and Tkinter.But ,it seems that the python version in jaunty ships a buggy tix version which gives a 'TclError:unknown color' error message (this happens when I try to use

comparing two lists

2010-03-05 Thread jimgardener
hi I have two lists of names.I need to find the difference between these two lists.I tried to do it using sets.But I am wondering if there is a better way to do it.Please tell me if there is a more elegant way. thanks, jim my code snippet follows.. oldlst=['jon','arya','ned','bran'] newlst=['jaim

Re: cannot find object instance

2008-08-28 Thread jimgardener
On Aug 28, 9:35 pm, Bruno Desthuilliers wrote: Such a ping-pong between two classes is more often > than not a design smell. thanks Bruno,i understand my mistake..should have figured it out myself thanks again jim -- http://mail.python.org/mailman/listinfo/python-list

cannot find object instance

2008-08-28 Thread jimgardener
hi, i am a python newbie..while trying out some message passing between two object instances i came across a problem moduleA.py import moduleB class MyClassA: def __init__(self): self.age=0 self.address='' def createClassB(self): self.objB=module

Re: import error between 2 modules

2008-08-27 Thread jimgardener
On Aug 27, 5:37 pm, Laszlo Nagy <[EMAIL PROTECTED]> wrote: > These constructors will be calling each other forever. This will be an > infinite recursion. sorry,that was a quite stupid mistake on my part..thanks for pointing out.. jim -- http://mail.python.org/mailman/listinfo/python-list

import error between 2 modules

2008-08-27 Thread jimgardener
I am new to python,and am learning from the tutorials i created 2 .py files like below and put the main in one of them empmodule.py -- from workmodule import Worker class Employer: def __init__(self,n): self.name=n self.worker=Worker() def getemployerName(self):

PhotoImage problem

2008-06-30 Thread jimgardener
hi I am using Python 2.5.1. In my code i want to use self.myimage=PhotoImage (file=self.myfile) so i can create the image in a canvas self.mycanv.create_image(70,100,image=self.myimg) it works when i add, from ImageTk import PhotoImage but this import caused an error message when i tried to run

converting a text file to image

2008-06-20 Thread jimgardener
i am looking for python code to convert a textfile(.txt) to an image(preferrably Tiff).I believe it involves some scanning and conversion using some font table and probably compression using huffman encoding..is there an open source code doing this?can someone give a pointer? jim -- http://mail.py

Re: problem with listdir

2008-04-26 Thread jimgardener
> * Run cmd.exe and see if you can run "dir f:\\code\\python\pgmgallery/*.*" > that causes a message 'Invalid switch - "*.*".' > * Try using other directories under F: drive in your program and see> when > you start hitting the problem. i tried that..on some directories in the same drive this

problem with listdir

2008-04-26 Thread jimgardener
hi i have a directory containing .pgm files of P5 type.i wanted to read the pixel values of these files ,so as a firststep i wrote code to make a list of filenames using listdir pgmdir="f:\code\python\pgmgallery" # where i have pgm files g2=listdir(pgmdir) i get the following error WindowsError

how to set image from double values of pixels

2008-02-17 Thread jimgardener
hi i am using PIL to get and set image data.Using image.getdata() i can get a tuple of ints for each pixel. also i can use im.putdata(data) to set pixels . suppose i am given a double value as a pixel value (say 7245654.32456 which i may get from some image processing calc..) and thus i have an

Re: packing greyscale values

2008-02-11 Thread jimgardener
>>Are you sure the lists you give belong to the same image? the greyvalues list was printed out by python script on a 3X4 sampleimage i made to check this im=Image.open("mypicgrey.jpg") pixels=im.getdata() for pix in pixels: print pix whereas the integers in the second list were from java cod

packing greyscale values

2008-02-10 Thread jimgardener
hi i am getting value of a pixel of a greyscale image using PIL's image.getdata and need to pack it as an int as below ie greyvalues 127 , 56 , 135 , 99 , 102 , 101 , 146 , 112 , 155 , 154 , 112 , 169 should become -4473925, -8289919, -4144960, -5789785, -5592406, -5658199 ,-3684409, -5131855, -3

Re: getting values from cache

2008-01-27 Thread jimgardener
> > I'd try to avoid duplicating the calculation code. > > Also, if you split the data in two, you can just read the filename list > alone: thanx G those were good suggestions gordon -- http://mail.python.org/mailman/listinfo/python-list

how to deliver an application

2008-01-11 Thread jimgardener
hi i have written a program that takes in user input thru a gui and then does some calculations and then displays a result value.I have split the code into 3 parts 1.the gui code--mygui.py containing a class to handle all ui stuff 2.calculations.py (also has one class to do all processing) 3. doc

Re: copy a numpy array

2008-01-08 Thread jimgardener
thanx guys for the replies need a little clarification srcarray=array([1.2,2.3,3.4,4.5,5.6]) destarray=array(srcarray,copy=False) then srcarray[2]=99.9 will cause the change to be reflected in both src and dest. doesn't that mean data is shared between both arrays? but if i do destarray=array(sr

copy a numpy array

2008-01-08 Thread jimgardener
hi, (i posted this to numpy discussion grp couple of days back ..but it fails to appear..)since it is needed for my work i would appreciate if anyone can help me with this question i have two ndarrays of 1000 elements each and want to copy all elements from srcarray to destarray srcarray=numpy.a

Re: how to use bool

2008-01-06 Thread jimgardener
forget about syntax err.. sorry ..but still would like to know if raising exception inside an except clause the right way? -- http://mail.python.org/mailman/listinfo/python-list

Re: how to use bool

2008-01-06 Thread jimgardener
some more doubts in this area,,forgive the ignorance of a beginner i have class MyError(Exception): def __init__(self,msg) self.msg=msg now my method that can raise this is class SomeClass: ... def mymethod(self): if (somecondition): raise MyError("somec

Re: how to use bool

2008-01-06 Thread jimgardener
hi bukzor & everyone who replied thanks for the detailed replies will try to write that way thanx a lot jim bukzor wrote: > On Jan 4, 8:51 am, bukzor <[EMAIL PROTECTED]> wrote: > > #exercise of the class and error handling > m = myclass() > try: > m.mymethod() > print "Completed success

how to use bool

2008-01-03 Thread jimgardener
hi, i have some code where i set a bool type variable and if the value is false i would like to return from the method with an error msg.. being a beginner I wd like some help here class myclass: . def mymethod(self): success=True msg="all validation OK"

Re: do i need to create new rgbimage class

2007-12-30 Thread jimgardener
> (May I ask why an accessor like getpixellist() instead of simply > rgbimage1.pixellist?) sorry, bad style of coding on my part..was doing java stuff.. > > I don't get the name - why "rgb to double"? This does not return a > "double", but a long integer, actually it was to be of 'long' type not

do i need to create new rgbimage class

2007-12-29 Thread jimgardener
hi am a beginner in python and PIL .I need to read an RGB 8 bit image (am using jpeg )and pack the rgb color values into a double value so i can store the image as a list of pixelvalues.From my application i should be able to call rgbimage1.getpixellist() to retrieve the double values of an image.