split a string with quoted parts into list
hi there i'm experimanting with imaplib and came across stringts like (\HasNoChildren) "." "INBOX.Sent Items" in which the quotes are part of the string. now i try to convert this into a list. assume the string is in the variable f, then i tried f.split() but i end up with ['(\\HasNoChildren)', '"."', '"INBOX.Sent', 'Items"'] so due to the sapce in "Sent Items" its is sepearted in two entries, what i don't want. is there another way to convert a string with quoted sub entries into a list of strings? thanks a lot, olli -- http://mail.python.org/mailman/listinfo/python-list
get list of member variables from list of class
Hi what will be the fastest solution to following problem class a: def __init__(self): self.varA = 0 self.varB = 0 s.o. ... listA = [a]*10 varA = [] varB = [] for l in listA: varA.append(l.varA) varB.append(l.varB) s.o. ... I could think of: [varA.append(l.varA) for l in listA] [varB.append(l.varB) for l in listA] s.o. ... But is this faster? After all I have to iterate over listA several times. Any better solutions? Oliver -- http://mail.python.org/mailman/listinfo/python-list
convert list of tuples into several lists
Hi, I can find examples to convert lists into a list of tuples like: >>> map(None,[1,2,3],[4,5,6]) [(1,4),(2,5),(3,6)] but how is it done vice versa? Oliver -- http://mail.python.org/mailman/listinfo/python-list
Re: convert list of tuples into several lists
Diez B. Roggisch wrote: > zip(*[(1,4),(2,5),(3,6)]) > Thanks :) I knew it must be simple. The asterics - thing was new to me. By the way: What is faster? this: z = [(1,4),(2,5),(3,6) a,b = zip(*[(x[0], x[0]-x[1]) for x in z]) or: a = [] b = [] for x in z: a.append(x[0]) b.append(x[0]-x[1]) I guess first, isn't it? Oliver -- http://mail.python.org/mailman/listinfo/python-list
Re: convert list of tuples into several lists
Pierre Barbier de Reuille wrote: > Best answer is : try it :) > use the "timeit" module (in the standard lib) to do so ... Ok, import timeit s = """\ a,b,c1,c2 = zip(*[(x[2],x[4], x[2]-x[1], x[2] - x[3]) for x in z]) """ t = timeit.Timer(stmt=s,setup="z = [(1,2,3,4,5)]*1000") print "%.2f usec/pass" % (100 * t.timeit(number=10)/10) s ="""\ for x in z: a = x[2] b = x[4] c1 = x[2] - x[1] c2 = x[2] - x[3] """ t = timeit.Timer(stmt=s,setup="z = [(1,2,3,4,5)]*1000") print "%.2f usec/pass" % (100 * t.timeit(number=10)/10) for 30 elements: [EMAIL PROTECTED]:~/tmp> python test.py 32.90 usec/pass 21.53 usec/pass for 100 elements: [EMAIL PROTECTED]:~/tmp> python test.py 103.32 usec/pass 70.91 usec/pass for 100 elements: [EMAIL PROTECTED]:~/tmp> python test.py 1435.43 usec/pass 710.55 usec/pass What do we learn? It might look elegant but it is slow. I guess mainly because I do the iteration twice with the zip command. The 1000 element run seems to show what Guido means with "abuse of the argument passing machinery" Learned my lesson :) Thanks to all Oliver -- http://mail.python.org/mailman/listinfo/python-list
Re: convert list of tuples into several lists
Pierre Barbier de Reuille wrote: > > Best answer is : try it :) > use the "timeit" module (in the standard lib) to do so ... Ok, (a second time. I hope the first post was cancelled as it was false) import timeit s = """\ a,b,c1,c2 = zip(*[(x[2],x[4], x[2]-x[1], x[2] - x[3]) for x in z]) """ t = timeit.Timer(stmt=s,setup="z = [(1,2,3,4,5)]*1000") print "%.2f usec/pass" % (100 * t.timeit(number=10)/10) s ="""\ a = [] b = [] c1 = [] c2 = [] for x in z: a.append(x[2]) b.append(x[4]) c1.append(x[2] - x[1]) c2.append(x[2] - x[3]) """ t = timeit.Timer(stmt=s,setup="z = [(1,2,3,4,5)]*1000") print "%.2f usec/pass" % (100 * t.timeit(number=10)/10) for 100 elements: [EMAIL PROTECTED]:~/tmp> python test.py 104.67 usec/pass 180.19 usec/pass for 1000 elements: [EMAIL PROTECTED]:~/tmp> python test.py 1432.06 usec/pass 1768.58 usec/pass What do we learn? The zip-thingy is even faster than the for loop Learned my lesson :) Thanks to all Oliver -- http://mail.python.org/mailman/listinfo/python-list
Image.putpalette(Colors)?
Has somebody a example-script how i can put a other palette to a image? (after this the image should have similar outlook) -- http://mail.python.org/mailman/listinfo/python-list
Re: Image.putpalette(Colors)?
Thanks, I've read this page.( out of date ?) http://www.pythonware.com/products/pil/articles/creating-palette-images.htm Very nicely to become answered from the major author and python genius highly personally himself :-D Which I want to do is; convert several "RGB" Images (or "P") with one specified palette (to "P"). Or this (for "P")pattern; if the Source Image has the exact same colors but wrong(other) paletteIds, how can i sort this? With List.sort()? And give each pixel the right paletteId? That is what i mean with similar image (source"RGB" to destinaton"P"). convert() without "WEB"? (sry if i've enough experience with python)>=newbie -- http://mail.python.org/mailman/listinfo/python-list
Re: Image.putpalette(Colors)?
I mean equal outlook. Or as other objective: give some Images (which has all same colors but other palettes) for an Animation the same/one palette and nothings is changed in their outlook -- http://mail.python.org/mailman/listinfo/python-list
Re: Image.putpalette(Colors)?
I think in this Example is an fault lut has the sequence from "im" but not from "lut.putdata(range(256))" ##Getting the Palette Contents Using Resize/Convert assert im.mode == "P" lut = im.resize((256, 1)) lut.putdata(range(256)) lut = im.convert("RGB").getdata() ^^ # lut now contains a sequence of (r, g, b) tuples Fredrik Lundh wrote: > here's one of the first google hits for "PIL putpalette": > > http://effbot.org/zone/pil-pseudocolor.htm -- http://mail.python.org/mailman/listinfo/python-list
Re: search/replace in Python
Hi, 2005/5/28, Vamsee Krishna Gomatam <[EMAIL PROTECTED]>: > Hello, > I'm having some problems understanding Regexps in Python. I want > to replace "PHRASE" with > "http://www.google.com/search?q=PHRASE>PHRASE" in a block of > text. How can I achieve this in Python? Sorry for the naive question but > the documentation is really bad :-( it is pretty easy and straightforward. After you imported the re module, you can do the job with re.sub or if you have to do it often, then you can compile the regex first with re.compile and afterwards use the sub method of the compiled regex. The interesting part is re.sub(r"(.*)",r"http://www.google.com/search?q=\1>\1", text) cause here the job is done. The first raw string is the regex pattern. The second one is the target where \1 is replaced by everything enclosed in () in the first regex. Here is the output of my ipython session. In [15]: text="This is a Python. And some random nonsense test." In [16]: re.sub(r"(.*)",r"http://www.google.com/search?q=\1>\1", text) Out[16]: 'This is a http://www.google.com/search?q=Python>Python. And some random nonsense test.' Best regards, Oliver -- http://mail.python.org/mailman/listinfo/python-list
Re: Questions about wxPython...
Helmutt schrieb: > Whats the name of the event that occur when I press the > exit/cross-button on the frame? > How do I connect a function with that event? Hi, I try just to begin the same. I found this in the docu. wxApp::OnExit http://wxwidgets.org/manuals/2.5.3/wx_wxapp.html#wxapponexit wxWindow::Close http://www.wxpython.org/docs/api/wx.Window-class.html#Close wxCloseEvent http://www.wxpython.org/docs/api/wx.CloseEvent-class.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Nufox : Xul + Python
I would like to test it, but as soon as I try to execute an example my browser is guided to connect to 192.168.0.40. First off it is an non-routeable address and secondly my own too. :))) May be you have to fix your setup another time. Best regards, Oliver 2 Oct 2005 03:40:50 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > Thank you for testing > Indeed it is very interesting :-) > > I've had some problems with my ports forwarding and no-ip.org. > > Here is then the new address : > > http://artyprog.dyndns.org:8080 > > Regards > > Betwise, I live in France so the site is close when i'am at work > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Oliver Andrich <[EMAIL PROTECTED]> --- http://roughbook.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about inheritance...
Hi, 22 Oct 2005 14:40:09 -0700, KraftDiner <[EMAIL PROTECTED]>: > I have a base class called Shape > And then classes like Circle, Square, Triangle etc, that inherit from > Shape: > > My quesiton is can a method of the Shape class call a method in Circle, > or Square etc...? even there would exist a way to accomplish that, I would suggest to rethink your class hierachy. Such requirements can show serious design problems. Best regards, Oliver -- Oliver Andrich <[EMAIL PROTECTED]> --- http://roughbook.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How to separate directory list and file list?
Hi, 2005/10/23, Gonnasi <[EMAIL PROTECTED]>: > With > >glob.glob("*") > > or > >os.listdir(cwd) > > I can get a combined file list with directory list, but I just wanna a > bare file list, no directory list. How to get it? don't know if it is the best solution, but it looks nice. :) path = "/home/test" files = [fn for fn in os.listdir(path) if os.path.isfile(os.path.join(path, fn))] This gives you just the list of files in a given directory. Best regards, Oliver -- Oliver Andrich <[EMAIL PROTECTED]> --- http://roughbook.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Object-Relational Mapping API for Python
Hi, if you enjoyed Hibernate or got intrigued by it, go and look into SQLOject (http://www.sqlobject.org/). And you will be less intrigued by Hibernate, but will start to really like SQLObject. :) Best regards, Oliver -- Oliver Andrich <[EMAIL PROTECTED]> --- http://roughbook.de/ -- http://mail.python.org/mailman/listinfo/python-list
Python and encodings drives me crazy
Hi everybody, I have to write a little skript, that reads some nasty xml formated files. "Nasty xml formated" means, we have a xml like syntax, no dtd, use html entities without declaration and so on. A task as I like it. My task looks like that... 1. read the data from the file. 2. get rid of the html entities 3. parse the stuff to extract the content of two tags. 4. create a new string from the extracted content 5. write it to a cp850 or even better macroman encoded file Well, step 1 is easy and obvious. Step is solved for me by = code = from htmlentitydefs import entitydefs html2text = [] for k,v in entitydefs.items(): if v[0] != "&": html2text.append(["&"+k+";" , v]) else: html2text.append(["&"+k+";", ""]) def remove_html_entities(data): for html, char in html2text: data = apply(string.replace, [data, html, char]) return data = code = Step 3 + 4 also work fine so far. But step 5 drives me completely crazy, cause I get a lot of nice exception from the codecs module. Hopefully someone can help me with that. If my code for processing the file looks like that: def process_file(file_name): data = codecs.open(file_name, "r", "latin1").read() data = remove_html_entities(data) dom = parseString(data) print data I get Traceback (most recent call last): File "ag2blvd.py", line 46, in ? process_file(file_name) File "ag2blvd.py", line 33, in process_file data = remove_html_entities(data) File "ag2blvd.py", line 39, in remove_html_entities data = apply(string.replace, [data, html, char]) File "/usr/lib/python2.4/string.py", line 519, in replace return s.replace(old, new, maxsplit) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0: ordinal not in range(128) I am pretty sure that I have iso-latin-1 files, but after running through my code everything looks pretty broken. If I remove the call to remove_html_entities I get Traceback (most recent call last): File "ag2blvd.py", line 46, in ? process_file(file_name) File "ag2blvd.py", line 35, in process_file print data UnicodeEncodeError: 'ascii' codec can't encode character u'\x96' in position 2482: ordinal not in range(128) And this continues, when I try to write to a file in macroman encoding. As I am pretty sure, that I am doing something completely wrong and I also haven't found a trace in the fantastic cookbook, I like to ask for help here. :) I am also pretty sure, that I do something wrong as writing a unicode string with german umlauts to a macroman file opened via the codecs module works fine. Hopefully someone can help me. :) Best regards, Oliver -- Oliver Andrich <[EMAIL PROTECTED]> --- http://fitheach.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and encodings drives me crazy
> I know this isn't your question, but why write: > > > data = apply(string.replace, [data, html, char]) > > when you could write > > data = data.replace(html, char) > > ?? Cause I guess, that I am already blind. Thanks. Oliver -- Oliver Andrich <[EMAIL PROTECTED]> --- http://fitheach.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: sudoku dictionary attack
Has some one an sodoku-task-generator? Here another solutions-ways: http://www.python-forum.de/viewtopic.php?t=3378 -- input -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and encodings drives me crazy
Well, I narrowed my problem down to writing a macroman or cp850 file using the codecs module. The rest was basically a misunderstanding about codecs module and the wrong assumption, that my input data is iso-latin-1 encode. It is UTF-8 encoded. So, curently I am at the point where I have my data ready for writing Does the following code write headline and caption in MacRoman encoding to the disk? Or better that, is this the way to do it? headline and caption are both unicode strings. f = codecs.open(outfilename, "w", "macroman") f.write(headline) f.write("\n\n") f.write(caption) f.close() Best regards, Oliver -- Oliver Andrich <[EMAIL PROTECTED]> --- http://fitheach.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and encodings drives me crazy
2005/6/21, Konstantin Veretennicov <[EMAIL PROTECTED]>: > It does, as long as headline and caption *can* actually be encoded as > macroman. After you decode headline from utf-8 it will be unicode and > not all unicode characters can be mapped to macroman: > > >>> u'\u0160'.encode('utf8') > '\xc5\xa0' > >>> u'\u0160'.encode('latin2') > '\xa9' > >>> u'\u0160'.encode('macroman') > Traceback (most recent call last): > File "", line 1, in ? > File "D:\python\2.4\lib\encodings\mac_roman.py", line 18, in encode > return codecs.charmap_encode(input,errors,encoding_map) > UnicodeEncodeError: 'charmap' codec can't encode character u'\u0160' in > position > 0: character maps to Yes, this and the coersion problems Diez mentioned were the problems I faced. Now I have written a little cleanup method, that removes the bad characters from the input and finally I guess I have macroman encoded files. But we will see, as soon as I try to open them on the Mac. But now I am more or less satisfied, as only 3 obvious files aren't converted correctly and the other 1000 files are. Thanks for your hints, tips and so on. Good Night. Oliver -- Oliver Andrich <[EMAIL PROTECTED]> --- http://fitheach.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: CONNCET TO SOAP SERVICE
Hi, I am not sure if this addresses your problem, but I access a rich SOAP based webservice set on a Tomcat Server implemented using Axis with SOAPpy. We use basic auth as specified in http for access control to these services. For me it is enough to create my proxy classes this way. proxy = SOAPpy.SOAPProxy("http://user:[EMAIL PROTECTED]:8080/axis/services, "MyService") Afterwards I have access to the system. Bye, Oliver 2005/7/12, Slaheddine Haouel <[EMAIL PROTECTED]>: > > > > Can you help me plz ? I want to wonnect to SOAP webservices but before I > must be authentificated on a apache server, I used SOAPpy module but I don't > know how I can be authentified on the apache server > > > > thx > > > > Slaheddine Haouel > > Unilog NORD > > tél : 03 59 56 60 25 > > tél support : 03 59 56 60 68 > > Email : [EMAIL PROTECTED] > > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- Oliver Andrich <[EMAIL PROTECTED]> --- http://fitheach.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP on path module for standard library
Hi, 2005/7/22, Michael Hoffman <[EMAIL PROTECTED]>: > What is this Java Path class? I have been STFWing and have found nothing > on it in the. Indeed if you search for "Java Path class" (with quotes) > almost half of the pages are this message from Guido. ;) > > Any Java hackers here want to tell us of the wonders of the Java Path > class? I would be interested in seeing how other OO languages deal with > paths. I guess the nearest Java class comparable with path is the File class. http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html And as I am a so called Java hacker, I highly appreciate path as a module for my python projects and in my eyes it is the natural way to address files/paths. At least it is more natural to me then the os, os.path, etc. pp. bundle, that has grown over the time. I would love to see path inside Python's stdlib. Best regards, Oliver -- Oliver Andrich <[EMAIL PROTECTED]> --- http://fitheach.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: SOAPpy and http authentication
2 Aug 2005 11:38:51 GMT, Lutz Horn <[EMAIL PROTECTED]>: > On 2005-08-02, Odd-R. <[EMAIL PROTECTED]> wrote: > > from SOAPpy import WSDL > > from SOAPpy import URLopener > > url= ' http://someserver/somewebservice > > url1 = URLopener.URLopener(username='user',passwd='pass') > > server=WSDL.Proxy(url1.open(url)) > > Is it possible to call WSDL.Proxy with a String? Then you could build > the URL als http://user:[EMAIL PROTECTED]/somewebservice. This works > with SOAPpy.SOAPProxy. Yes, you can actually call it that way, but then the wsdl retrieval is done using the authentication, but all the service calls are done without. This is something, that is also puzzling me. So far I can perfectly live with SOAPProxy, but it would be nice to solve this puzzle. Best regards, Oliver -- Oliver Andrich <[EMAIL PROTECTED]> --- http://fitheach.de/ -- http://mail.python.org/mailman/listinfo/python-list
httplib or urllib2 tomcat username and password
I am trying to write a Python client to access a Tomcat servlet using Tomcat Realm authentication with no success. I can use the httplib to connect to localhost port 8080 ok and post and get and all that is fine, but when I try to set username and password and access a protected part of tomcat it fails with an Unauthorized. Does anyone have an example of connecting to Tomcat using the Tomcat Realm (.i.e. tomcat-users.xml) authentication? I have also tried urllib2 and the example in the header comments still gives me a HTTP Error 401: Unauthorized when I try to open http://localhost:8080/slide/ Thanks. Highly Cohesive and Loosely Coupled Mike Oliver CTO Alarius Systems LLC 6800 E. Lake Mead Blvd Apt 1096 Las Vegas, NV 89156 [EMAIL PROTECTED] http://www.alariussystems.com/ tel: fax: mobile: (702)953-8949 (702)974-0341 (518)378-6154 Add me to your address book... Want a signature like this? -- http://mail.python.org/mailman/listinfo/python-list
Tomcat username and password2
Still trying to get python to access my local tomcat secured with the tomcat realm import urllib2 handler = urllib2.HTTPBasicAuthHandler() handler.add_password(None, 'localhost:8080/manager/html', 'root', 'root') opener = urllib2.build_opener(handler) urllib2.install_opener(opener) try: f = urllib2.urlopen( 'http://localhost:8080/manager/html' ) except urllib2.HTTPError, e: if e.code == 401: print 'not authorized' elif e.code == 404: print 'not found' elif e.code == 503: print 'service unavailable' else: print 'unknown error: ' else: print 'success' for line in f: print line, [Mike Oliver>>] this returns 'not authorized' no matter what I put in for 'realm' or 'host' to the add_password() method. I have tried None, 'tomcat' for realm and 'localhost' and about every combination I can think of for 'host' if I go to that URL with a browser it asks for username and password as above and that works. I can access it with code from PHP or Java just fine. -- http://mail.python.org/mailman/listinfo/python-list
Python Client accessing Tomcat
I am trying to write a Python client to access a Tomcat servlet using Tomcat Realm authentication with no success. I can use the httplib to connect to localhost port 8080 ok and post and get and all that is fine, but when I try to set username and password and access a protected part of tomcat it fails with an Unauthorized. Does anyone have an example of connecting to Tomcat using the Tomcat Realm (.i.e. tomcat-users.xml) authentication? Thanks. Highly Cohesive and Loosely Coupled Mike Oliver CTO Alarius Systems LLC 6800 E. Lake Mead Blvd Apt 1096 Las Vegas, NV 89156 [EMAIL PROTECTED] http://www.alariussystems.com/ tel: fax: mobile: (702)953-8949 (702)974-0341 (518)378-6154 Add me to your address book... Want a signature like this? -- http://mail.python.org/mailman/listinfo/python-list
Tomcat authentication from python
I need to access tomcat applications from python, some are Axis/SOAP web services, and some are file/WebDAV operations. But so far I cannot get python to authenticate and access http://localhost:8080/manager/html much less to any of the other applications. I have found examples for httplib with a base64 Basic Authentication header, and a urllib2 Authentication Handler, but neither one works. I am not an experienced python developer, but I am an experienced Java Developer. I am using PyDev plugin for Eclipse, I am using Python24. I can connect to tomcat without authentication for those pages/uri’s that do not require authentication on that tomcat server, so the problem is with the authentication mechanism in python. Obviously I can connect to the entire site and all applications with a browser and programmatically from Java. Any help greatly appreciated. Highly Cohesive and Loosely Coupled Mike Oliver CTO Alarius Systems LLC 6800 E. Lake Mead Blvd Apt 1096 Las Vegas, NV 89156 [EMAIL PROTECTED] http://www.alariussystems.com/ tel: fax: mobile: (702)953-8949 (702)974-0341 (518)378-6154 Add me to your address book... Want a signature like this? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Jabber client?
Hi Paul, take this one. http://xmpppy.sourceforge.net/ It is used inside gajim, my favorite jabber client. http://gajim.org/ It works like a charm. And I am also using xmpppy for some monitoring tools, that alert our admins. Best regards, Oliver -- Oliver Andrich <[EMAIL PROTECTED]> --- http://roughbook.de/ -- http://mail.python.org/mailman/listinfo/python-list
exceptions from logging on Windows
Hi, I experience several exceptions from python's logging system when using the rollover feature on Windows. Traceback (most recent call last): File "c:\Python24\lib\logging\handlers.py", line 62, in emit if self.shouldRollover(record): File "c:\Python24\lib\logging\handlers.py", line 132, in shouldRollover self.stream.seek(0, 2) #due to non-posix-compliant Windows feature ValueError: I/O operation on closed file Googeling revealed that this has been experienced by others, too, however no workaround or solution has been provided. Is this the latest status on this topic? Do I miss something? Thanks for help, Oliver -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs versus Spaces in Source Code
Xah Lee wrote: > Tabs versus Spaces in Source Code > > Xah Lee, 2006-05-13 > > In coding a computer program, there's often the choices of tabs or > spaces for code indentation. There is a large amount of confusion about > which is better. It has become what's known as “religious war” — > a heated fight over trivia. In this essay, i like to explain what is > the situation behind it, and which is proper. > > Simply put, tabs is proper, and spaces are improper. [...] I fullheartedly disagree :) So, no "essay" on this is necessary to read :-> Ciao, Oliver -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs versus Spaces in Source Code
[EMAIL PROTECTED] opalinski from opalpaweb wrote: >>Simply put, tabs is proper, and spaces are improper. >>Why? This may seem >>ridiculously simple given the de facto ball of confusion: the semantics >>of tabs is what indenting is about, while, using spaces to align code >>is a hack. > > > The reality of programming practice trumps original intent of tab > characters. The tab character and space character are pliable in that > if their use changes their semantics change. [...] Yes, as I started programming I also preferred tabs. And with growing experience on how to handle this in true life (different editors/systems/languages...) I saw, that converting the "so fine tabs" was annoying. The only thing that always worked were spaces. Tab: nice idea but makes programming an annoyance. Ciao, Oliver -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs versus Spaces in Source Code
Jonathon McKitrick wrote: > Pascal Bourguignon wrote: > >>(defun ιοτα (&key (номер 10) (단계 1) (בכוכ 0)) >> (loop :for i :from בכוכ :to номер :by 단계 :collect i)) > > > How do you even *enter* these characters? My browser seems to trap all > the special character combinations, and I *know* you don't mean > selecting from a character palette. Didn't you heard of that big keyboards? 12 meter x 2 meter wide I think you need a long stick (maybe if you play golf, that can help). The you have all UTF-8 characters there, that's fine, but typing needs some time. But it's good, because when ready with typing your email, it's not necessary to go to sports after work. So your boss can insist that you longer stay at work. Ciao, Oliver ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs versus Spaces in Source Code
"Jonathon McKitrick" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Pascal Bourguignon wrote: >> (defun ιοτα (&key (номер 10) (단계 1) (בכוכ 0)) >> (loop :for i :from בכוכ :to номер :by 단계 :collect i)) > > How do you even *enter* these characters? My browser seems to trap all > the special character combinations, and I *know* you don't mean > selecting from a character palette. > > hey, this is weird... > > î > > I've got something happening, but I can't tell what. > > Yes, I'm an ignorant Western world ASCII user. :-) What OS are you using? In Windows XP, you'd have to let the XP know that you're interested in input in languages other than English via "Control Panel -> Regional Settings -> Languages -> Text Services and Input Languages". There, you'd add input methods other than English. Each "input method" works in a sort of unique way, so you'll just have to learn them. For example, under English, you can use the "keyboard" input method which probably is what you're using now, or the "handwriting recognition" input method, or the "speech recognition" input method to insert english text. There are other input methods for the Asian languages (e.g. Chinese, Japanese, etc.) - Oliver -- http://mail.python.org/mailman/listinfo/python-list
Question about decorators (with context?)
Hi, sorry for the vague subject, but I can't come up with a better one so far. I am currently writing a wrapper around ImageMagicks MagickWand library using the ctypes module. During this development i have to handle exceptions in an slightly different way, then python normally handles them. I am wrapping the libraries functionality in a class that looks like that. (I leave out the ctypes calls and stuff as far as it is possible.) class MagickWand(object): def __init__(self): self._wand = @my_funky_decorator def read_image(self, filename): return You can see, I plan to have my own MagickWand object, which wraps the C struct and functions. The normal habit of MagickWand is to call a function, that returns either True or False. Based on this the user has to check for an exception or not. I will have to wrap a lot of methods to get all the functionality I need. And the checking for an exception looks always the same. So I want to write short methods, which are decorated by my_funky_decorator which handles the error checking and exception handling. Sadly, this decorator needs access to self._wand from the current object. So far I can only think of a solution, where I have to do something like that. @my_funky_decorator(wand=) def read_image(self, filename): pass So, I like to ask, if someone could enlighten me how to implement the easy decorator I mentioned in my first "example". Thanks and best regards, Oliver -- Oliver Andrich <[EMAIL PROTECTED]> --- http://roughbook.de/ -- http://mail.python.org/mailman/listinfo/python-list
ctypes question about call by reference
Hi, hopefully someone with some ctypes experience can help me. I guess this is a trivial task again, but I have been googling, reading, experimenting the whole afternoon without any success. I have a given C function signature: char *MagickGetException(MagickWand *wand,ExceptionType *severity) - ExceptionType is an enum - MagickWand is somewhat strange, but so far it works fine without any type mangling. How would I wrap this thing using ctypes? Can anybody help me with that? Best regards, Oliver -- Oliver Andrich <[EMAIL PROTECTED]> --- http://roughbook.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Re: ctypes question about call by reference
On 9/24/06, Lawrence Oluyede <[EMAIL PROTECTED]> wrote: > Oliver Andrich <[EMAIL PROTECTED]> wrote: > > - ExceptionType is an enum > > - MagickWand is somewhat strange, but so far it works fine without any > > type mangling. > > > > How would I wrap this thing using ctypes? Can anybody help me with that? > > First thing first: you have to identify how ExceptionType and MagickWand > are composed of. Then you can start wrapping them following the > instructions in the tutorial: > http://docs.python.org/lib/ctypes-ctypes-tutorial.html Well, what I learned so far from the documentation, which I already have read more then once today, is that there is no example for an enum in this situation. But looking at pygame-sdl and another project, it looks like the enum is just an c_int or c_long. And concerning MagickWand, I think I have learned, that I don't need to define the structure, if I don't want to access it. And I don't want to, cause this is handled by the library itself. Another point in this context is also, that it is not defined in the header files distributed with the library, but only in the source from which the library is built. As the file is named magick-wand-private.h it is also not meant to be edited. Is it at all possbile to use a struct without defining it with ctypes? Is it okay, to just use the int which is returned by default? Most of my library works with that configuration, so I thought it is working. Based on this, can you give me some more hints? Best regards, Oliver -- Oliver Andrich <[EMAIL PROTECTED]> --- http://roughbook.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Re: ctypes question about call by reference
After a walk outside, some fresh air around my nose and some time to relax, I finally found out how to do, what I want to do. First, define the argument types and the result type. _dll.MagickGetException.argtypes = (c_long, POINTER(c_long)) _dll.MagickGetException.restype = c_char_p Second, write correct code as it is documented. :) def get_magick_exception(wand): severity = c_long() description = _dll.MagickGetException(wand, byref(severity)) return (severity, description) And thats all. I just did the call to POINTER(c_long) in the wrong location. Now I do it as documented, and I get everything I want. I can btw live perfectly without definining what actually a MagickWand is, cause from the point of the developer just using the library and documentation, he doesn't know about the actual structure of it. The definition is hidden the C source of the library, and is not documented in the public interface. Thanks and Regards, Oliver. -- Oliver Andrich <[EMAIL PROTECTED]> --- http://roughbook.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: PyXML not supported, what to use next?
Hi PaulOn 9/30/06, Paul Watson <[EMAIL PROTECTED]> wrote: It would appear that xml.dom.minidom or xml.sax.* might be the bestthing to use since PyXML is going without support. Best of all it isincluded in the base Python distribution, so no addition hunting required. Is this right thinking? Is there a better solution?I am using lxml as my standard tool of choice. It includes the easy interface of ElementTree and the speed and power of being backed by libxml2 and libxslt. But this mainly cause I have to deal with large XMLs in a fast way. Otherwise pure ElementTree is a very, very nice choice. And it is also our "backup" choice, when lxml is not available on a system. Best regards,Oliver-- Oliver Andrich <[EMAIL PROTECTED]> --- http://roughbook.de/ -- http://mail.python.org/mailman/listinfo/python-list
Ctypes and freeing memory
Hi everybody, I am currently playing around with ctypes and a C library (libWand from ImageMagick), and as I want to easily deploy it on Mac, Linux and Windows, I prefer a ctypes solution over a C module. At least on windows, I would have resource problems to compile the C module. So, ctypes is the perfect choice for me. But I am currently encountering a pattern inside the C library, that has to be used to free memory. Coding in C I have to do the following char *description; long severity; description = MagickGetException(wand, &severity); /* do something with the description: print it, log it, ... */ description = (char *) MagickRelinquishMemory(description); exit(-1); /* or something else what I want to after an exception occured */ So, this looks easy and is sensible from C's point of view. Now I try to translate this to Python and ctypes. dll.MagickGetException.argtypes = [c_long, POINTER(c_long)] dll.MagickGetException.restype = c_char_p severity = c_long() description = dll.MagickGetException(byref(severity)) # So far so good. The above works like a charm, but the problem follows now # ctypes already converted the char * for description to a String object. # That means description has arrived in an area under Python's control. # these definitions are the easy part dll.MagickRelinquishMemory.argtypes = [c_void_p] dll.MagickRelinquishMemory.restype = c_char_p # but this obviously must cause problems and causes problems dll.MagickRelinquishMemory(description) So, my question is, how do I deal with this situation? Can I ignore the call to MagickRelinquishMemory, cause Python takes care of the resources already? Or is it impossible to use it at all, and I have to think about a different solution? Best regards, Oliver -- Oliver Andrich <[EMAIL PROTECTED]> --- http://roughbook.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to use a non open source bug tracker?
Hi, On 10/3/06, Giovanni Bajo <[EMAIL PROTECTED]> wrote: > I just read this mail by Brett Cannon: > http://mail.python.org/pipermail/python-dev/2006-October/069139.html > where the "PSF infrastracture committee", after weeks of evaluation, > recommends > using a non open source tracker (called JIRA - never heard before of course) > for Python itself. > > Does this smell "Bitkeeper fiasco" to anyone else than me? No, this doesn't smell like the BK fiasco, it is just the decision to use a certain tool. But it is easy to change or influence this recommondation. Step up as an admin for Roundup. :) Best regards, Oliver -- Oliver Andrich <[EMAIL PROTECTED]> --- http://roughbook.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Re: Ctypes and freeing memory
On 10/3/06, Chris Mellon <[EMAIL PROTECTED]> wrote: > Not a ctypes expert but I can pretty much guaranteee that Python won't > correctly release that memory by itself. Are you sure that description > is actually a string object? I also think, that Python won't release the memory, and the returned string isn't helpful either. :) > If it doesn't, then you can use a more literal translation of the C > code, and use a c_void_p instead, using ctypes.string_at(description) > to get a string out of the buffer. This works and is a great tip! Thanks a lot. Best regards, Oliver -- Oliver Andrich <[EMAIL PROTECTED]> --- http://roughbook.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Re: Ctypes and freeing memory
On 10/6/06, Thomas Heller <[EMAIL PROTECTED]> wrote: > Chris Mellon has already pointed out a possible solution, but there is also a > different way. You could use a subclass of c_char_p as the restype > attribute: > > class String(c_char_p): > def __del__(self): > MagickRelinquishMemory(self) > > The difference is that you will receive an instance of this class > when you call the MagickGetException funcion. To access the 'char *' > value, you can access the .value attribute (which is inherited from > c_char_p), and to free the memory call MagickRelinquishMemory > in the __del__ method. These is an even better solution, cause it lets me drop one decorator, I have been using at the moment, to handle these things. Thanks a lot. ctypes is so much fun to use. Lately I had to use JNI, and well, compared to this experience I am now in heaven. :) Sadly, I can't provide my team members an equal solution in the Java world, cause one of them starts to hate me for assigning him on another JNI job in our project. Best regards, Oliver -- Oliver Andrich <[EMAIL PROTECTED]> --- http://roughbook.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: languages with full unicode support
こんいちわ Xah-Lee san ;-) Xah Lee wrote: > Languages with Full Unicode Support > > As far as i know, Java and JavaScript are languages with full, complete > unicode support. That is, they allow names to be defined using unicode. Can you explain what you mena with the names here? > (the JavaScript engine used by FireFox support this) > > As far as i know, here's few other lang's status: > > C → No. Well, is this (only) a language issue? On Plan-9 all things seem to be UTF-8 based, and when you use C for programming, I would think that C can handle this also. But I only have read some papers about Plan-9 and did not developed on it Only a try to have a different view on it. If someone knows more, please let us know :) Ciao, Oliver -- http://mail.python.org/mailman/listinfo/python-list
Re: languages with full unicode support
"Oliver Bandel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Xah Lee wrote: > >> >> As far as i know, Java and JavaScript are languages with full, complete >> unicode support. That is, they allow names to be defined using unicode. > > Can you explain what you mena with the names here? As in variable names, function names, class names, etc. - Oliver -- http://mail.python.org/mailman/listinfo/python-list
Re: languages with full unicode support
Matthias Blume wrote: > Tin Gherdanarra <[EMAIL PROTECTED]> writes: > > >>Oliver Bandel wrote: >> >>>こんいちわ Xah-Lee san ;-) >> >>Uhm, I'd guess that Xah is Chinese. Be careful >>with such things in real life; Koreans might >>beat you up for this. Stay alive! > > > And the Japanese might beat him up, too. For butchering their > language. :-) OK, back to ISO-8859-1 :) no one needs so much symbols, this is enough: äöüÄÖÜß :) Ciao, Oliver -- http://mail.python.org/mailman/listinfo/python-list
Re: calling a class instance of function
Hi, Methods i.e functions bound to a class instance (or object) the self argument in their definition: [code] class pid: def add(self, toadd): pass #or some sensible code [/code] If you want to define a method without that implicit self argument you'll have to make this method a static: [code] class pid: @staticmethod def staticadd (param1, param2): pass #or some sensible code [/code] Furthermore, your test() seems to be rather a function than a class: You want to use this function to test the pid class but what you do with your code below is to define a class test which inherits pid. I'm not really sure what the following lines do ... this would usually be the place to introduce class variables. Hope that Helps! Greetings Nils Original-Nachricht Datum: 21 Dec 2006 11:09:32 +1100 Von: Pyenos <[EMAIL PROTECTED]> An: python-list@python.org Betreff: calling a class instance of function > > class pid: > "pid" > def add(original_pid,toadd): > "add pid" > original_pid.append(toadd) > return original_pid > def remove(something_to_remove_from,what): > "remove pid" > something_to_remove_from.remove(what) > return something_to_remove_from > def modify(source,element,changewiththis): > "modify pid" > source[source.index(element)]=changewiththis > return source > > class test(pid): > pid.original=[1,2,3] > pid.toadd=4 > pid.add(pid.original,pid.toadd) # error here says that > # it expects pid instance as first arg > # not a list that it got. > > why do i get an error? > -- > http://mail.python.org/mailman/listinfo/python-list -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer -- http://mail.python.org/mailman/listinfo/python-list
Re: what is wrong with my code?
Hi, this is the line that breaks your code: def progressTable(progress_table, action, task, pid=len(progress_table) your parameter progress_table is known inside the function, not inside its definition. So "pid=len(progress_table)" won't do. If you really think that it is possible that pid is anything else but "len(progress_table)", you should use for example -1 as the default value and calculate the length inside your functions if the parameter is not different. Otherwise dump this parameter. Hope that helps! Greetings Nils Original-Nachricht Datum: 21 Dec 2006 09:16:58 +1100 Von: Pyenos <[EMAIL PROTECTED]> An: python-list@python.org Betreff: what is wrong with my code? > import cPickle, shelve > > could someone tell me what things are wrong with my code? > > class progress: > > PROGRESS_TABLE_ACTIONS=["new","remove","modify"] > DEFAULT_PROGRESS_DATA_FILE="progress_data" > PROGRESS_OUTCOMES=["pass", "fail"] > > > def unpickleProgressTable(pickled_progress_data_file): > > return unpickled_progress_table > > def pickleProgressTable(progress_table_to_pickle): > > return pickled_progress_data_file > > # Of course, you get progress_table is unpickled progress table. > def progressTable(progress_table, action, task, > pid=len(progress_table), outcome=PROGRESS_OUTCOMES[1]): > pid_column_list=progress_table[0] > task_column_list=progress_table[1] > outcome_column_list=progress_table[2] > > # But a task must also come with an outcome! > def newEntry(new_task, new_outcome): > new_pid=len(task_column_list) > > pid_column_list.extend(new_pid) > task_column_list.extend(new_task) > outcome_column_list.extend(new_outcome) > > def removeEntry(pid_to_remove, task_to_remove): > > if > pid_column_list.index(pid_to_remove)==task_column_list.index(task_to_remove): > # Must remove all columns for that task > index_for_removal=pid_column_list.index(pid_to_remove) > > pid_column_list.remove(index_for_removal) > task_column_list.remove(index_for_removal) > outcome_column_list.remove(index_for_removal) > > # Default action is to modify to pass > def modifyEntry(pid_to_modify, > outcome_to_modify=PROGRESS_OUTCOMES[0]): > index_for_modifying=pid_column_list.index(pid_to_modify) > > # Modify the outcome > outcome_column_list[index_for_modifying]=outcome_to_modify > -- > http://mail.python.org/mailman/listinfo/python-list -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer -- http://mail.python.org/mailman/listinfo/python-list
Re: pdf to text
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 have a look at the pdflib (www.pdflib.com). Their Text Extraction Toolkit might be what you are looking for, though I'm not sure whether you can use it detached from the pdflib itself. hth Nils tubby schrieb: > I know this question comes up a lot, so here goes again. I want to read > text from a PDF file, run re searches on the text, etc. I do not care > about layout, fonts, borders, etc. I just want the text. I've been > reading Adobe's PDF Reference Guide and I'm beginning to develop a > better understanding of PDF in general, but I need a bit of help... this > seems like it should be easier than it is. Here's some code: > > import zlib > > fp = open('test.pdf', 'rb') > bytes = [] > while 1: > byte = fp.read(1) > #print byte > bytes.append(byte) > if not byte: > break > > for byte in bytes: > > op = open('pdf.txt', 'a') > > dco = zlib.decompressobj() > > try: > s = dco.decompress(byte) > #print >> op, s > print s > except Exception, e: > print e > > op.close() > > fp.close() > > I know the text is compressed... that it would have stream and endstream > makers and BT (Begin Text) and ET (End Text) and that the uncompressed > text is enclosed in parenthesis (this is my text). Has anyone here done > this in a simple fashion? I've played with the pyPdf library some, but > it seems overly complex for my needs (merge PDFs, write PDFs, etc). I > just want a simple PDF text extractor. > > Thanks -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.3 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFuSPozvGJy8WEGTcRAnY0AJ0VZez3XRbLm/JXZKhn/rgHP0R3qwCfWAnT EupBECHab2kG33Rmnh+xf74= =INM5 -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
I need a crack for pyext1.2.5 plugin
Hi pythoneros. I'm a cuban guy interested in python and I need the crack of an Eclipse plugin: pyext 1.2.5 Thanks very much cheers Oliver Sosa -- http://mail.python.org/mailman/listinfo/python-list
RE: I need a crack for pyext1.2.5 plugin
Sorry if this is the wrong place to make that question. Pyext is a plugin that acoplate with pydev, it's 'software privativo' like said Stallman, but it's very interesting. I have version 1.2.5. I use Eclipse 'cos it's simply great!! If somebody could tell me some alternative... Thanks (sorry my english) On Feb 18, 8:07 pm, "Oliver Sosa Cano" <[EMAIL PROTECTED]> wrote: > Hi pythoneros. I'm a cuban guy interested in python and I need the crack of an Eclipse plugin: pyext 1.2.5 > > Thanks very much > > cheers > > Oliver Sosa Never heard of pyext - Google turns up this link http://g.org/ext/py/, but this is pyext 0.2.0. If by "crack" you mean "bootlegged user key for commercial software," this is the wrong place for that stuff. On the other hand, if you tell us what kind of Eclipse work you are doing that requires this elusive plug-in, someone may have a suggestion on where to find it, or an equivalent. -- Paul -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Letting a Python application phone home
Am Freitag, 14. Juli 2006 15:26 schrieb Dieter Vanderelst: This is surely possible. You need to define a protocol for the communication between client and server. As you are planning to send data over the internet you should build it on top of tcp. Look at the python module "socket" resp. "SocketServer" for low level tcp functions. As the data should not be visible to everyone you need some kind of encryption. Either you rely on the ssl capabilities of the "socket" module, this way securing the transport layer (tcp) or you build encryption into your newly designed application layer protocol. For the latter have a look at the "python cryptography toolkit". Sorry I have no url at hand, simply google. Concerning the question of stopping the program when the internet connection breaks: let your program contact the server periodically. If this fails quit the program. Regards Nils -- http://mail.python.org/mailman/listinfo/python-list