os.path.join doubt

2011-02-02 Thread harryos
In windows ,I tried this p1 = C:\Users\me\Documents p2 = ..\Pictures\images\my.jpg print os.path.join(p1,p2) This gives 'C:\\Users\\me\\Documents\\..\\Pictures\\images\\my.jpg' I expected I would get 'C:\\Users\\me\\Pictures\\images\\my.jpg' I thought os.path.join would join the paths more

imaplib AND date format

2010-10-14 Thread harryos
In imaplib.IMAP4.search() the search string SENTON can be used '(SENTON 22-Jun-2010)' . But the RFC 2060 defines search key as SENTON date Messages whose [RFC-822] Date: header is within the specified date. and in RFC822 it is given as, date= 1*2DIGIT month 2DIGIT

can I use more than one status condition name in imaplib.status()

2010-10-13 Thread harryos
Hi In the signature of of imaplib.status() method MAP4.status(mailbox, names) why is the 'names ' argument plural?Can I pass more than one name to the method? I can get correct result when I call, imapclient.status('Inbox', (UNSEEN)) or imapclient.status('Inbox', (RECENT)) Is it possible to

how to find difference in number of characters

2010-10-09 Thread harryos
hi I am trying to write a compare method which takes two strings and find how many characters have changed. def compare_strings(s1,s2): pass text1=goat milk text2=cow milk print compare_strings(text1,text2) This must give 3 ,since 3 characters are changed between strings.I was advised to

Re: how to find difference in number of characters

2010-10-09 Thread harryos
On Oct 9, 2:45 pm, Peter Otten __pete...@web.de wrote: What would be an acceptable time? Thanks for the reply Peter, I was using python functions I came across the net..not cpython implementations..Probably my low config machine is also to blame..(I am no expert at judging algorithm

Re: how to find difference in number of characters

2010-10-09 Thread harryos
On Oct 9, 4:52 pm, Peter Otten __pete...@web.de wrote: You might get more/better answers if you tell us more about the context of the problem and add some details that may be relevant. Peter I am trying to determine if a wep page is updated by x number of characters..Mozilla firefox plugin

Re: Testing for changes on a web page (was: how to find difference in number of characters)

2010-10-09 Thread harryos
On Oct 9, 5:41 pm, Stefan Behnel stefan...@behnel.de wrote: Number of characters sounds like a rather useless measure here. What I meant by number of characters was the number of edits happened between the two versions..Levenshtein distance may be one way for this..but I was wondering if

how to handle network failures

2010-10-08 Thread harryos
hi I am trying to write a DataGrabber which reads some data from given url..I made DataGrabber as a Thread and want to wait for some interval of time in case there is a network failure that prevents read(). I am not very sure how to implement this class DataGrabber(threading.Thread): def

singleton problems

2010-10-03 Thread harryos
hi I have been trying out singleton design pattern implementations..I wrote this, class Singleton(object): _instance = None def __new__(self, *args, **kwargs): if not self._instance: self._instance = super(Singleton, self).__new__(self, *args, **kwargs) return

Re: singleton problems

2010-10-03 Thread harryos
thanks Steven..that was very helpful..thanks a lot harry Since __new__ is called before the instance exists, it doesn't receive an instance as the first argument. Instead it receives the class. While you can call the parameter anything you like, it is conventional to call it cls rather than

Re: singleton problems

2010-10-03 Thread harryos
thanks Arnold..that made it quite clear harry On Oct 3, 4:11 pm, Arnaud Delobelle arno...@gmail.com wrote: Arnaud Delobelle arno...@gmail.com writes: -- http://mail.python.org/mailman/listinfo/python-list

scheduler or infinite loop

2010-09-29 Thread harryos
hi I am trying to write a program to read data from a site url. The program must read the data from site every 5 minutes. def get_data_from_site(pageurlstr): h=urllib.urlopen(pageurlstr) data=h.read() process_data(data) At first, I thought of using the sched module ,but then it

Re: scheduler or infinite loop

2010-09-29 Thread harryos
thanks Frank Here is a technique that allows the loop to run in the background, in its own thread, leaving the main program to do other processing - import threading class DataGetter(threading.Thread): -- http://mail.python.org/mailman/listinfo/python-list

tix problem in ubuntu karmic

2010-09-28 Thread harryos
hi I posted this question in ubuntu users forum but no help was forthcoming.. I hope someone can help me here. I had been using jaunty as o.s and was coding in python 2.6. While using Tix widgets in my code I came across a bug as mentioned in

elementwise multiplication of 2 lists of numbers

2010-09-20 Thread harryos
hi I have 2 lists of numbers,say x=[2,4,3,1] y=[5,9,10,6] I need to create another list containing z=[2*5, 4*9, 3*10, 1*6] ie =[10,36,30,6] I did not want to use numpy or any Array types.I tried to implement this in python .I tried the following z=[] for a,b in zip(x,y): z.append(a*b)

Re: elementwise multiplication of 2 lists of numbers

2010-09-20 Thread harryos
On Sep 20, 7:28 pm, Bruno wrote: A list comp comes to mind, as well as using itertools.izip thanks Bruno,thanks Gary.. Should have thought of list comprehension.. Thanks for the pointer about izip harry -- http://mail.python.org/mailman/listinfo/python-list

use of super

2010-01-19 Thread harryos
hi I was going thru the weblog appln in practical django book by bennet .I came across this class Entry(Model): def save(self): dosomething() super(Entry,self).save() I couldn't make out why Entry and self are passed as arguments to super ().Can someone

Re: use of super

2010-01-19 Thread harryos
thanks Simon..I should have checked it -- http://mail.python.org/mailman/listinfo/python-list

Re: how to list all installed modules

2009-02-19 Thread harryos
On Feb 18, 11:10 pm, Scott David Daniels scott.dani...@acm.org Are you running F:\Python25\python.exe (or F:\Python25\pythonw.exe)? open a command window (run cmd), and type:      C:\ python      ...       import sys       for dirname in  sys.path:              print sys.path I suspect

how to list all installed modules

2009-02-18 Thread harryos
hi Is there a way to list all the installed modules in my python installation.I recently installed pygame and when i tried to import it like import pygame it complained that no such module was found.I can see the pygame directory in F:\Python25\Lib\site-packages in my machine,but am unable to

Re: how to list all installed modules

2009-02-18 Thread harryos
On Feb 18, 9:42 pm, Peter Otten __pete...@web.de wrote: help(modules) thanks Peter.That helped. Regarding the original problem, do you have multiple Python installations? If so, you may accidentally be running the wrong python. I have only one installation.It shows all other modules.I will

class definition syntax

2008-08-29 Thread harryos
hi i have seen some class definitions like class MyClass(object): def __init__(self): what does the object keyword inside the braces in MyClass() mean? Has it got any significance? thanks in advance harry -- http://mail.python.org/mailman/listinfo/python-list

ImageTk.Photoimage not displayed

2008-08-28 Thread harryos
hi i am trying to display an image on a canvas in a gui made with Tkinter widgets class PhotoDisplay: def __init__(self,parent): self.mainframe = Frame(parent,background=grey) . #added a subframe to hold canvas and button

Re: finding euclidean distance,better code?

2008-03-28 Thread harryos
The code is pretty legible as it is now. Anyway, using min() and a generator: hi is this calculated distance really Euclidean distance? When i checked wikipedia http://en.wikipedia.org/wiki/Euclidean_distance it shows a calculation involving sum of squares of the differences of elements.Here

Re: finding euclidean distance,better code?

2008-03-28 Thread harryos
the norm from which it is derived is called norm-1, or L1; the usual euclidean distance is derived from norm-2. If you only want to see if two things are close enough, this provides a faster measure than the euclidean distance. thanks Gabriel for the detailed explanation.. if i were to

how to create eigenface image

2008-02-27 Thread harryos
hi all I am new to python and learning PCA method by reading up TurkPetland papers etc while trying out PCA on a set of greyscale images using python, and numpy I tried to create eigenvectors and facespace. i have facesarray--- an NXP numpy.ndarray that contains data of images N=numof

Re: using PIL for PCA analysis

2008-02-26 Thread harryos
Paul McGuire wrote # following approx fromhttp://www.dfanning.com/ip_tips/color2gray.html grayscale = lambda (R,G,B) : int(0.3*R + 0.59*G + 0.11*B) print [ [ grayscale(rgb) for rgb in row ] for row in sampledata ] Paul in PIL handbook ,they mention a Luma transform on page15, under the