[Tutor] Rép. : string to list

2010-08-05 Thread Luhmann
Try this: >>> def f(mystring):     charlist = list(mystring)     tmplist = [ [''] ]     for a in charlist:         if tmplist[-1][-1] == '/' or a == '/':             tmplist[-1].append(a)         else:             tmplist.append( [a] )     return  [''.join(a) for a in tmplist][1:] >>>  #Thusly:

[Tutor] Images on Python 3k

2010-01-16 Thread Luhmann
Hello List, Does anyone know of a way simple way to display JPG and PNG images on python 3? My program uses tkinter, and currently my solution is to use ImageMagick's convert through std to convert the images to gif. However the conversion is too time consuming. I have only started using pytho

Re: [Tutor] How to open the closed file again?

2010-01-05 Thread Luhmann
When there are no more references to an open file object, will it close, or the file will just remain open, forever unreachable? Découvrez les styles qui font sensation sur Yahoo! Québec Avatars. http://cf.avatars.yahoo.com/___ Tutor maillist

[Tutor] Rép. : How can I make this run faster ?

2009-12-21 Thread Luhmann
#Here's my try: vowel_killer_dict = { ord(a): None for a in 'aeiou'} def devocalize(word):     return word.translate(vowel_killer_dict) vowelled = ['him', 'ham', 'hum', 'fun', 'fan'] vowelled = set(vowelled) devocalise_dict={} for a in vowelled:     devocalise_dict[a]= devocalize(a)     un

[Tutor] faster substring replacement

2009-12-15 Thread Luhmann
Hi folks, I'm trying to do something like this: >>> evildict= {'good' : 'bad' , 'love' : 'hate' , 'God': 'Satan'} >>> def make_evil(text) ...        for a in evildict: ...              text=text.replace(a, evildict[a]) ...              return text     This works fine, but it soon gets too slow

[Tutor] Rép. : parsing Spreadsheet document

2009-12-10 Thread Luhmann
If you just want to load the data into python one time, rather than connecting to the file, it would be more handy to paste the cells from the clipboard.  Here's how I do it on windows: from win32clipboard import * #("pywin32" module required) def pastetable(): OpenClipboard() try: a=GetCli

[Tutor] Is there any way to move the print cursor in IDLE?

2009-11-25 Thread Luhmann
I wanted to display a counter for my loops like this: >>> for a in range(int(1e+307)):... a=str(a)... b='\b'*len(a)... >>> print(b,a, sep='',end='') But this only works on the command prompt, in IDLE it will flood the screen. How do I do it? Découvrez les photos les plus i