[ANN] Leipzig Python User Group - Meeting, June 12, 2007, 08:00pm
=== Leipzig Python User Group === We will meet on Tuesday, June 12 at 08:00pm at the training center of Python Academy in Leipzig, Germany ( http://www.python-academy.com/center/find.html ). Food and soft drinks are provided. Please send a short confirmation mail to [EMAIL PROTECTED], so we can prepare appropriately. Everybody who uses Python, plans to do so or is interested in learning more about the language is encouraged to participate. While the meeting language will be mainly German, we will provide English translation if needed. Current information about the meetings are at http://www.python-academy.com/user-group . Mike === Leipzig Python User Group === Wir treffen uns am Dienstag, 12.06.2007 um 20:00 Uhr im Schulungszentrum der Python Academy in Leipzig ( http://www.python-academy.de/Schulungszentrum/anfahrt.html ). Für das leibliche Wohl wird gesorgt. Eine Anmeldung unter [EMAIL PROTECTED] wäre nett, damit wir genug Essen besorgen können. Willkommen ist jeder, der Interesse an Python hat, die Sprache bereits nutzt oder nutzen möchte. Aktuelle Informationen zu den Treffen sind unter http://www.python-academy.de/User-Group zu finden. Viele Grüße Mike -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Integer division
In [EMAIL PROTECTED], Dan Bishop wrote: On Jun 7, 8:30 pm, Some Other Guy [EMAIL PROTECTED] wrote: Since this just involves doubling you can avoid multiplying altogether and just use this: def rounddiv(a,b): return int((a+a+b)/(b+b)) That's 3 integer adds and 1 integer divide. The int() cast is just there is case somebody passes in floats for a or b; if you know you're only going to have integer arguments you don't need it. The // operator was added to the language for a reason. I'm surprised at how few Pythonistas are using it six years later. It would just document intent here because it still gives `float` results if used with at least one `float` as operands: In [1]: 10.0 // 2 Out[1]: 5.0 Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Bragging about Python
Steve Howell wrote: --- Georg Brandl [EMAIL PROTECTED] wrote: 15 small programs here: http://wiki.python.org/moin/SimplePrograms IMHO a few python goodies are missing there. It's a Wiki. ;) Yes indeed. Please feel free to add to the page, or make your own fork. See link above. the title of a program shouldn't be part of the code (or it should at least start with #) sorry i'm too lazy now to fix it, but imho it needs nicer layout to be used as 'bragging about python' site btw nice idea a good example worth a 100 pages of documentation -- http://mail.python.org/mailman/listinfo/python-list
Re: howto obtain directory where current (running) py-file is placed?
dmitrey wrote: Hi all, I guess this question was asked many times before, but I don't know keywords for web search. Thank you in advance, D. In the future, please ask your question in the body of your message (not just in the subject line). This question has no answer in general. There are some things like __file__ that may be good enough depending on your usage, but keep in mind in general that: 1. __file__ may be altered directly by the program and give an answer that has no past or current relationship to any filename for the file that contains the code currently being run. 2. Even if you make no changes, it can contain arbitrary results in not uncommon situations (e.g. in my local install, an interactive python session--or one from a here-document in the shell--lists ~/.pythonrc or stdin in __file__, even though in neither case was I running my .pythonrc or a file named stdin 3. Without that, any file may have 0, 1, or many names; those names may differ now from what they were when the file was first accessed. So __file__ may refer to an unlinked name (even in the case where at least one name that existed when you first executed the file is still valid), or may even e the name of another, different file that was created (or linked/renamed) after you started running things. Depending on your needs, those factors may or may not matter. They're certainly worth being aware of, and for some applications they may have massive security implications. -- http://mail.python.org/mailman/listinfo/python-list
Re: Where can I suggest an enchantment for Python Zip lib?
Hi Larry! durumdara wrote: You can easily find out roughly how many bytes are in your .ZIP archive by using following: zipbytes=Zobj.fp.tell() The main problem is not this. I want to write a backup software, and I want to: - see the progress in the processing of the actual file - abort the progress if I need it If I compress small files, I don't have problems. But with larger files (10-20 MB) I get problems, because the zipfile's method is uninterruptable. Only one way I have to control this: if I modify the ZipFile module. dd On Jun 7, 8:26 pm, Larry Bates [EMAIL PROTECTED] wrote: Where Zobj is your zipfile instance. You don't need a callback. Problem is ill defined for a better solution. You don't know how much the next file will compress. It may compress a lot, not at all or in some situations actually grow. So it is difficult (impossible?) to know how many bytes are remaining. I have a rough calculation where I limit the files to 2Gb, but you must set aside some space for the table of contents that gets added at the end (whose size you don't actually know either). So I use: maxzipbytesupperlimit=int((1L31)-(8*(120))) That is 2Gb-8Mb maximum TOC limit of a zip file. I look at zipbytes add the uncompressed size of the next file, if it exceeds maxzipbytesupperlimit, I close the file and move to the next zip archive. If it is smaller, I add the file to the archive. Hope this helps. -Larry -- http://mail.python.org/mailman/listinfo/python-list
Re: howto obtain directory where current (running) py-file is placed?
On Jun 8, 1:01 am, Stef Mientki [EMAIL PROTECTED] wrote: Gerard Flanagan wrote: On Jun 7, 8:39 am, dmitrey [EMAIL PROTECTED] wrote: Hi all, I guess this question was asked many times before, but I don't know keywords for web search. Thank you in advance, D. import os d1 = os.path.dirname(__file__) here I get an error __file__ is not defined ?? The code must be run from a script or module. If you run it from an interactive prompt, then you will get a NameError. d2 = os.path.dirname(os.__file__) here I get a completely different path ?? Is it the path of the os module? You can expect pure Python modules to have a __file__ attribute, but not every module has one - see the docs. print d1 print d2 This seems to work (but I doubt it's always working !! ) print os.getcwd() so what's the real answer ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Sorry for the multiple posts
Sorry for the multiple posts. I kept getting network errors and it looked like the posts weren't getting through. Regards, Vinay -- http://mail.python.org/mailman/listinfo/python-list
Re: compiling python and calling it from C/C++
Russ schrieb: Is it possible to compile python code into a library (on unix), then link to it and call it from C/C++? If so, where can I learn how. You can't compile python, but what you can do is create a library-wrapping around it using elmer which will make it C-callable. http://elmer.sourceforge.net/ diez -- http://mail.python.org/mailman/listinfo/python-list
wxPython / Dabo demo shell ?
hello, I was impressed by the demo shell of wxPython, and a few days ago (finally getting Dabo to work), I saw Dabo uses the same demo shell. Is there any more information available about this shell, because it seems a very nice / good way to show (many) demos, in an organized way to newbies. thanks, Stef mientki -- http://mail.python.org/mailman/listinfo/python-list
EuroPython: Draft program posted, today last day of early registration
Dear Pythonistas! On www.euroypython.org the draft program and timetable has been posted! http://www.europython.org/sections/tracks_and_talks/draft-timetable Do a click and check out the fabulous talks. Then check in, best today, the 8th of June, the last day of early bird registration. EuroPython 2007 will take place at the Reval Hotel Lietuva in Vilnius, Lithuania from Monday 9th July to Wednesday 11th July. See you there! Best wishes, Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: howto obtain directory where current (running) py-file is placed?
On 7, 10:39, dmitrey [EMAIL PROTECTED] wrote: Hi all, I guess this question was asked many times before, but I don't know keywords for web search. Thank you in advance, D. import sys file_name = sys.argv[0] this? -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug/Weak Implementation? popen* routines can't handle simultaneousread/write?
dmoore [EMAIL PROTECTED] wrote: 8 --- description of full duplex problem Anybody have any thoughts on this? Do I have my story straight? (the popen variants can't handle this case and there are no other alternatives in the standard python distro) Is there some place I can submit this as a feature request? (Python dev?) I think this is a hassle in the file implementation - I have had it also on serial ports, where it acts as if the file driver is inherently half duplex. It manifests as: My characters don't come out I don't know if it is python or the underlying stuff. I use fcntl to unblock and generally mess around to solve it, but I don't think my solution is portable. It is a real issue though - you are not imagining the dragon, it is right at the door... - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Minimize Bandwidth
Hello Chaps, I have a python application that hits a web service on a regular basis to post a string of CSV log data and I'm looking to minimize the amount of bandwidth that the application uses to send the log data. Is there any way to encode the string into base64 or something, that I can then post and decode at the other end? Is that likely to save me bandwidth perhaps? I don't really know much about this encoding stuff, but the smaller I can compress the string the better. Thanks, Rob -- http://mail.python.org/mailman/listinfo/python-list
Case-Insensitive Sorting of Multi-Dimensional Lists
I have a list of lists that I would like to sort utilizing a certain index of the nested list. I am able to successfully use: Import operator list = [[Apple, 1], [airplane, 2]] list.sort(key=operator.itemgetter(0)) But, unfortunately, this will be case sensitive (Apple will come before airplane because the A is capital) and I need it to be insensitive. Can someone provide some input, please? Thanks in advance! Jough -- http://mail.python.org/mailman/listinfo/python-list
Re: Determinant of Large Matrix
James Stroud j@mbia.edu wrote: James Stroud wrote: [pointless stuff] OK. Nevermind. I'm rebinding encodings and so taking a sample from the sample and thus getting the sample back. Terribly sorry. There is truly nothing to be sorry about. It takes guts to come right out and say that you made a mistake. Well done! start rant One of my pet peeves are people who pretend that they never make mistakes. Strangely enough, when you ask them to walk on water, they never quite manage it. This sort of thing should be cause for rejoicing, - when you think about it, its a proof that the body of knowledge that has to do with sampling is solid and reliable, independently of the experimenter - these days that is quite a comforting thought. The sanitised stuff you read in the scientific journals does not represent the true course of the progress of science - in reality, progress is the incidental by-product of a progressive series of blunders. But nobody involved will acknowledge this, for fear of their precious reputations... end rant - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: running a random function
On 8, 00:07, Dustan [EMAIL PROTECTED] wrote: On Jun 7, 1:30 pm, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-06-07, Stebanoid [EMAIL PROTECTED] wrote: if you have a list of functions you can try this: import random import math m[int(math.floor(len(m)*random.random()))]() # seems like Lisp Or rather m[random.randint(0, len(m))]() Or rather random.choice(m)() # seems like Python -- Neil Cerutti Caution: Cape does not enable user to fly. --Kenner's Batman costume Sorry :( I have no experience using this module in Python, and forget this functions because I newer use this. Sorry for my terrible English. :P -- http://mail.python.org/mailman/listinfo/python-list
Re: *Naming Conventions*
Neil Cerutti a écrit : On 2007-06-06, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Neil Cerutti a écrit : On 2007-06-04, Michael Hoffman [EMAIL PROTECTED] wrote: Wildemar Wildenburger wrote: I agree with Bruno that i and j should be used only for indices, but I'm usually less terse than that. I find i and j preferable to overly generic terms like item. Since 'i' and 'j' are canonically loop indices, I find it totally confusing to use them to name the iteration variable - which is not an index. At least, 'item' suggests that it's an object, and a part of the collection - not just an index you'll have to use to subscript the container. Also, and as far as I'm concerned, I certainly dont find 'i' and 'j' *less* generic than 'item' !-) Thanks, I didn't say clearly what I meant. Certainly i and j are just as generic, but they have the advantage over 'item' of being more terse. I'm not sure this is really an advantage here. -- http://mail.python.org/mailman/listinfo/python-list
Re: Bragging about Python
--- Szabolcs Nagy [EMAIL PROTECTED] wrote: the title of a program shouldn't be part of the code (or it should at least start with #) sorry i'm too lazy now to fix it, but imho it needs nicer layout to be used as 'bragging about python' site Agreed. I just spruced up the layout a tiny bit, but it could still use improvement. http://wiki.python.org/moin/SimplePrograms btw nice idea a good example worth a 100 pages of documentation Thanks, I agree. :) Shape Yahoo! in your own image. Join our Network Research Panel today! http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 -- http://mail.python.org/mailman/listinfo/python-list
Re: Minimize Bandwidth
Robert Rawlins - Think Blue wrote: I have a python application that hits a web service on a regular basis to post a string of CSV log data and I'm looking to minimize the amount of bandwidth that the application uses to send the log data. Is there any way to encode the string into base64 or something, that I can then post and decode at the other end? Is that likely to save me bandwidth perhaps? I don't really know much about this encoding stuff, but the smaller I can compress the string the better. You could zip the csv data up first (assuming you control both ends of the conversation). Obviously compression ratios depend on various things. code import zlib data = BAN X08 001 / 00 01 BAN X08 004 / 00 04 BAN X08 013 / 00 01 BAN X08 016 / 00 01 BAN X08 017 / 00 02 BAN X08 018 / 00 03 BAN X08 010 / 00 01 BAN X08 019 / 00 01 BAN X08 022 / 00 01 BAN X08 025 / 00 01 MAI X01 001 / 00 01 MAI X01 002 / 00 01 MAI X01 003 / 00 01 MAI X01 004 / 00 01 MAI X01 005 / 00 01 MAI X01 006 / 00 01 MAI X01 008 / 00 01 MAI X01 009 / 00 01 MAI X01 010 / 00 01 MAI X01 011 / 00 01 MAI X01 012 / 00 01 MAI X01 013 / 00 01 TOW P02 015 / 00 01 BET C01 006 / 00 BL BET C01 006 / 00 TL BET T01 011 / 00 01 BET T01 012 / 02 01 BET P01 010 / 00 01 BET P01 030 / 00 01 BET P02 022 / 00 01 STO C02 031 / 00 01 BON P01 003 / 01 01 compressed_data = zlib.compress (data, 9) print len (data), len (compressed_data) /code TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: ten small Python programs
In article [EMAIL PROTECTED], Steve Howell [EMAIL PROTECTED] wrote: I've always thought that the best way to introduce new programmers to Python is to show them small code examples. Something like this: http://www.lava.se/sam/ Jacob Hallén -- -- http://mail.python.org/mailman/listinfo/python-list
Re: How to wrap a Japanese text in Python
On Jun 7, 5:12 am, [EMAIL PROTECTED] wrote: Hi All, I am trying to wrap a japanese text in Python, by the following code. if len(message) 54: message = message.decode(UTF8) strlist = textwrap.wrap(message,54) After this I am wirting it to you a CAD Software window. While displaying in this window some Japanese characters at the end of the line some at the begining of the line are not displayed at all. Meaning the text wrapping is not happening correctly. Can any body please help me out in resolving this problem. First of all you should move message.decode('utf-8') call out of if and you don't need if anyway because if the line is less than 54 textwrap won't touch it: message = message.decode('utf-8') strlist = textwrap.wrap(message, 54) I don't know Japanese but the following example *seems* to work fine for me: # -*- coding: utf-8 -*- sample=u import textwrap for line in textwrap.wrap(sample, 6): print line Result: Can you post a short example that clearly demonstrates the problem? -- Leo -- http://mail.python.org/mailman/listinfo/python-list
Re: How to wrap a Japanese text in Python
On Jun 8, 2:24 am, Leo Kislov [EMAIL PROTECTED] wrote: On Jun 7, 5:12 am, [EMAIL PROTECTED] wrote: Hi All, I am trying to wrap a japanese text in Python, by the following code. if len(message) 54: message = message.decode(UTF8) strlist = textwrap.wrap(message,54) After this I am wirting it to you a CAD Software window. While displaying in this window some Japanese characters at the end of the line some at the begining of the line are not displayed at all. Meaning the text wrapping is not happening correctly. Can any body please help me out in resolving this problem. First of all you should move message.decode('utf-8') call out of if and you don't need if anyway because if the line is less than 54 textwrap won't touch it: message = message.decode('utf-8') strlist = textwrap.wrap(message, 54) I don't know Japanese but the following example *seems* to work fine for me: # -*- coding: utf-8 -*- sample=u import textwrap for line in textwrap.wrap(sample, 6): print line Result: Oh, my. IE7 and/or Google groups ate my Japanese text :( But I hope you've got the idea: try to work on a small example python program in a unicode-friendly IDE like for example IDLE. Can you post a short example that clearly demonstrates the problem? This question is still valid. -- Leo. -- http://mail.python.org/mailman/listinfo/python-list
Re: Running a process every N days
Hi Dan FWIW I'd use logrotate for this. Regards Mark Westwood On Jun 7, 11:27 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: What's the best way to run either an entire python process or a python thread every N days. I'm running Python 2.4.3 on Fedora Core 5 Linux. My code consists of a test and measurement system that runs 24/7 in a factory setting. It collects alot of data and I'd like to remove all data older than 30 days. My ideal solution would be something that runs in the background but only wakes up to run every few days to check for old data. Thanks, Dan McLeran -- http://mail.python.org/mailman/listinfo/python-list
Does python 2.3.3 pty module has a bug?
Hi, System: Solaris Python version: 2.3.3 For a automation job, I used pexpect module together with python for creating a ftp session automatically and downloading the file. I notice that after closing the child. The file descriptor is not closed (check /proc/process id/fd) After running the script for a while, I start seeing too many files open error. I have a development machine running Linux using python 2.3.3. I execute the same code on it. The file descriptor is closed everytime after the pexpect child is closed. My question is - Is this a bug with pty module for solaris for python 2.3.3? Appreciate your comments Thanks, Alex -- http://mail.python.org/mailman/listinfo/python-list
Does python 2.3.3 pty module has a bug?
Hi, System: Solaris Python version: 2.3.3 For a automation job, I used pexpect module together with python for creating a ftp session automatically and downloading the file. I notice that after closing the child. The file descriptor is not closed (check /proc/process id/fd) After running the script for a while, I start seeing too many files open error. I have a development machine running Linux using python 2.3.3. I execute the same code on it. The file descriptor is closed everytime after the pexpect child is closed. My question is - Is this a bug with pty module for solaris for python 2.3.3? Appreciate your comments Thanks, Alex -- http://mail.python.org/mailman/listinfo/python-list
soap - sessions ?
H! When I use php code nusoap everything works but with python I get everytime Your session key does not exist or has expired I use this code below: test = SOAPpy.SOAPProxy(http://secure.easynic.com/com/iomart/ easynicWSv2.cfc?wsdl) data = test.login(_id='test',_pass='pass') for item in data: for item2 in item: if item2['key']=='KEY': EASYKEY = item2['value'] # now I have the EASYKEY # create a customer with the key, # print output = Your session key does not exist or has expired print test.createOrUpdateContact(key=EASYKEY, title=row[0], firstname=row[2], initials=row[3], lastname=row[4], company=row[5], phone=row[9], fax='', email=row[13], address1=straat, address2='', address3='', area=row[12], city=row[8], country=row[12], postcode=row[7], acc_username='', acc_password='', domaincontactid='') # logout , and this works ! (using the same key) test.logout(key=EASYKEY) With php this works: // get the key $_SESSION[CODElogin] $result = $soapClient-call('login',$params,$_SESSION[serverip], $_SESSION[serverip]) // make a customer $params = array( 'key' = $_SESSION[CODElogin], 'title' = $_POST[title], 'firstname' = $_POST[firstname], 'initials' = $_POST[initials], 'lastname' = $_POST[lastname], 'company' = $_POST[company], 'phone' = $_POST[phone], 'fax' = $_POST[fax], 'email' = $_POST[email], 'address1' = $_POST[address1], 'address2' = $_POST[address2], 'address3' = $_POST[address3], 'area' = $_POST[area], 'city' = $_POST[city], 'country' = $_POST[area], 'postcode' = $_POST[postcode], 'acc_username' = $_POST[acc_username], 'acc_password' = $_POST[acc_password], 'domaincontactid'= $_POST[domaincontactid] ); // send $result = $soapClient-call('createOrUpdateContact',$params,'http:// secure.easynic.com/com/iomart/easynicWSv2.cfc?wsdl','http:// secure.easynic.com/com/iomart/easynicWSv2.cfc?wsdl'); and everything works, what can I do to make this with python ? or must I use exec(phpprogram.php) ? (I hope not) Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython / Dabo demo shell ?
On Jun 8, 2007, at 3:14 AM, stef wrote: I was impressed by the demo shell of wxPython, and a few days ago (finally getting Dabo to work), I saw Dabo uses the same demo shell. Is there any more information available about this shell, because it seems a very nice / good way to show (many) demos, in an organized way to newbies. There isn't a common shell. I wrote DaboDemo from scratch, using the Dabo Class Designer visual tools; you can actually open up the demo in the Class Designer and edit the entire thing! I just thought that the wxPython demo was such a great way to explore wxPython and try out new things that I blatantly copied it. ;-) -- Ed Leafe -- http://leafe.com -- http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: *Naming Conventions*
On 2007-06-08, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Neil Cerutti a écrit : On 2007-06-06, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Neil Cerutti a écrit : On 2007-06-04, Michael Hoffman [EMAIL PROTECTED] wrote: Wildemar Wildenburger wrote: I agree with Bruno that i and j should be used only for indices, but I'm usually less terse than that. I find i and j preferable to overly generic terms like item. Since 'i' and 'j' are canonically loop indices, I find it totally confusing to use them to name the iteration variable - which is not an index. At least, 'item' suggests that it's an object, and a part of the collection - not just an index you'll have to use to subscript the container. Also, and as far as I'm concerned, I certainly dont find 'i' and 'j' *less* generic than 'item' !-) Thanks, I didn't say clearly what I meant. Certainly i and j are just as generic, but they have the advantage over 'item' of being more terse. I'm not sure this is really an advantage here. Why not? -- Neil Cerutti Beethoven's symphonies had more balls, if you will, than say a Mozart. --Music Lit Essay -- http://mail.python.org/mailman/listinfo/python-list
Re: how to do reading of binary files?
jvdb schrieb: Hi all, I need some help on the following issue. I can't seem to solve it. I have a binary (pcl) file. In this file i want to search for specific codes (like 0C). I have tried to solve it by reading the file character by character, but this is very slow. Especially when it comes to files which are large (10MB) this is consuming quite some time. Does anyone has a hint/clue/solution on this? What has the searching to do with the reading? 10MB easily fit into the main memory of a decent PC, so just do contents = open(file).read() # yes I know I should close the file... print contents.find('\x0c') Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: how to do reading of binary files?
On 8 jun, 14:07, Diez B. Roggisch [EMAIL PROTECTED] wrote: jvdb schrieb: .. What has the searching to do with the reading? 10MB easily fit into the main memory of a decent PC, so just do contents = open(file).read() # yes I know I should close the file... print contents.find('\x0c') Diez True. But there is another issue attached to the one i wrote. When i know how much this occurs, i know the amount of pages in the file. After that i would like to be able to extract a given amount of data: file x contains 20 0C. then for example i would like to extract from instance 5 to instance 12 from the file. The reason why i want to do this: The 0C stands for a pagebreak in PCL language. This way i would be absle to extract a certain amount of pages from the file. -- http://mail.python.org/mailman/listinfo/python-list
Re: soap - sessions ?
When I use SOAPpy.Config.dumpSOAPOut = 1 SOAPpy.Config.dumpSOAPIn = 1 will display: *** Outgoing SOAP ** ?xml version=1.0 encoding=UTF-8? SOAP-ENV:Envelope SOAP-ENV:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/; xmlns:SOAP-ENC=http://schemas.xmlsoap.org/soap/encoding/; xmlns:xsi=http://www.w3.org/1999/XMLSchema-instance; xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/; xmlns:xsd=http://www.w3.org/1999/XMLSchema; SOAP-ENV:Body createOrUpdateContact SOAP-ENC:root=1 domaincontactid href=#i1/ city href=#i2/ fax href=#i1/ firstname href=#i3/ area href=#i4/ country href=#i4/ address2 href=#i1/ address3 href=#i1/ phone href=#i5/ title href=#i6/ postcode href=#i7/ key href=#i8/ lastname href=#i9/ acc_password href=#i1/ address1 href=#i10/ company href=#i11/ email href=#i12/ acc_username href=#i1/ initials href=#i13/ /createOrUpdateContact domaincontactid xsi:type=xsd:string id=i1 SOAP-ENC:root=0/ domaincontactid city xsi:type=xsd:string id=i2 SOAP-ENC:root=0fsdfsd/city firstname xsi:type=xsd:string id=i3 SOAP-ENC:root=0sdfsad/ firstname area xsi:type=xsd:string id=i4 SOAP-ENC:root=0NL/area phone xsi:type=xsd:string id=i5 SOAP-ENC:root=0+31.243770011/ phone title xsi:type=xsd:string id=i6 SOAP-ENC:root=0M/title postcode xsi:type=xsd:string id=i7 SOAP-ENC:root=03432VD/ postcode key xsi:type=xsd:string id=i8 SOAP- ENC:root=0EASYNICAPI2_3057578_53854283/key lastname xsi:type=xsd:string id=i9 SOAP-ENC:root=0dfasdf/ lastname address1 xsi:type=xsd:string id=i10 SOAP-ENC:root=0dfasdf 3/ address1 company xsi:type=xsd:string id=i11 SOAP-ENC:root=0safasdf/ company email xsi:type=xsd:string id=i12 SOAP- ENC:root=0[EMAIL PROTECTED]/email initials xsi:type=xsd:string id=i13 SOAP-ENC:root=0fsdfas/ initials /SOAP-ENV:Body /SOAP-ENV:Envelope *** Incoming SOAP ** ?xml version=1.0 encoding=UTF-8? soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/ envelope/ xmlns:xsd=http://www.w3.org/1999/XMLSchema; xmlns:xsi=http://www.w3.org/1999/XMLSchema-instance; soapenv:Body createOrUpdateContactResponse soapenv:encodingStyle=http:// schemas.xmlsoap.org/soap/encoding/ createOrUpdateContactReturn href=#id0/ /createOrUpdateContactResponse multiRef id=id0 soapenc:root=0 soapenv:encodingStyle=http:// schemas.xmlsoap.org/soap/encoding/ xsi:type=ns1:Map xmlns:soapenc=http://schemas.xmlsoap.org/soap/encoding/; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:ns1=http://xml.apache.org/xml-soap; item key xsi:type=ns2:string xmlns:ns2=http://www.w3.org/2001/ XMLSchemaRESPONSECODE/key value xsi:type=ns3:string xmlns:ns3=http://www.w3.org/2001/ XMLSchema999/value /item item key xsi:type=ns4:string xmlns:ns4=http://www.w3.org/2001/ XMLSchemaRESPONSETEXT/key value xsi:type=ns5:string xmlns:ns5=http://www.w3.org/2001/ XMLSchemaYour session key does not exist or has expired/value /item /multiRef /soapenv:Body /soapenv:Envelope -- http://mail.python.org/mailman/listinfo/python-list
Re: compiling python and calling it from C/C++
Russ wrote: Is it possible to compile python code into a library (on unix), then link to it and call it from C/C++? If so, where can I learn how. Thanks. not really but you may want to look into these: http://codespeak.net/pypy http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/ http://sourceforge.net/projects/shedskin/ -- http://mail.python.org/mailman/listinfo/python-list
how to do reading of binary files?
Hi all, I need some help on the following issue. I can't seem to solve it. I have a binary (pcl) file. In this file i want to search for specific codes (like 0C). I have tried to solve it by reading the file character by character, but this is very slow. Especially when it comes to files which are large (10MB) this is consuming quite some time. Does anyone has a hint/clue/solution on this? thanks already! Jeroen -- http://mail.python.org/mailman/listinfo/python-list
Correct auto line break in mail headers lines (subject)?
can anyone contribute to this question about correct auto line break in mail header lines: https://sourceforge.net/tracker/?func=detailaid=1645148group_id=5470atid=105470 -- http://mail.python.org/mailman/listinfo/python-list
MI5 Persecution: Options 21/9/95 (562)
From: john heelan [EMAIL PROTECTED] Newsgroups: uk.misc,alt.current-events.net-abuse,alt.journalism Subject: Re: CENSORHSIP IS IMMORAL, UNJUST AND WRONG Date: Thu, 21 Sep 95 19:17:30 GMT Organization: (Private) Lines: 65 Message-ID: [EMAIL PROTECTED] References: [EMAIL PROTECTED] [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] X-NNTP-Posting-Host: lorca.demon.co.uk X-Newsreader: Demon Internet Simple News v1.29 You have to admit that Mike is persistent and obviously feels deeply that he is being hounded by the Security Services and there is a Conspiracy out to get him personally. If that is true, then we should be concerned; if he is just paranoid, then we should empathise with his sickness. What we should not do is to invite censorshipthat just could be implicitly joining in the putative Conspiracy. Let's look at Mike's potential options (and the alleged responses he has received): 1. Complain to the Police: (their alleged response Don't be silly, Sir; Mike's rationale They are part of the Conspiracy) I don't think the police as an organisation are part of it. They're certainly not the source. The officer I spoke to at Easter clearly didn't know anything about it. And that was at my local police station in London - if anyone in the police knew you would think the people at your local cop shop would. A couple of years ago I had to go into the station after a motoring infraction, the guy I spoke to then said something about brain like a computer sir which my suspicions latched on to - (I'm alleged to be a programmer as some people reading this know) - but as per the usual can';t prove nuthin and you ask yourself if you're just being stupid suspecting on the basis of a straw 2. Complain to a Member of Parliament (Mike's rationale: Can't because they are part of the Conspiracy) I could do that actually. But he would probably tell me to go see the police, for which see above. 3. Make it visible through the UK Press. (Mike's rationale: Can't because they are part of the Conspiracy) They are actually. There's a difference though in the way journalists react to this stuff when they're got to by the security service. This is completely giving the game away, but the trouble originally started with my reading into stuff that was being written by Times columnists, in particular our antagonistic friend Mr Levin. But you see that some journalists are taking part in the conspiracy and others are only doing it because their puppet masters have been feeding them information which they can't allow themselves to ignore. The security services have their hooks into the UK media, this case shows that very explicitly. You also see how things get gradualkly wqorse with a particular journalist; a couple of weeks ago Peter Tory in the Express was writing about nerds seeking their revenge on him through the Net, guess what that was about. 4. Complain to the UK Security Services. (Mike's rationale: Can't because they ARE the Cnspiracy) Quis custodiet ipsos custodes? If the fascist Gestapo bastards plot to see you dead then who's going to deal with it? Not the security services, that's for sure. 5. Make it visible through Internet: (Mike has done this suvccessfully; but any gainsayers are part of the Conspiracy. I don;t think you';re part of the consipracy if you refuse to believe or email the postmaster. Those
error when calling method of class
Hi: I have defined a class in that class is a method defined as follows: def splitTime(n): seconds =float(n) I call the method in another procedure as follows: sefl.splitTime(200) the traceback states that splitTime takes one argument two given. why is this occuring? if I try calling it like: splitTime(200) I get a name resultion error saying that the global name splitTime is not defined. Any help apreciated. Sean. -- http://mail.python.org/mailman/listinfo/python-list
MI5 Persecution: Goldfish and Piranha 29/9/95 (5104)
I just thought I'd let you know what I've been reading into the Crusader spam. I don't want to post this to usenet because somebody might try to tie that in to my posts in some way (someone already has, in uk.misc). First of all, I'd like to ask you to believe that my phone line in my apartment is bugged, and has been for many months. I have moved a couple of times this year, but they have faithfully been on my trail. Anyway, let's suppose my phone line is bugged. Now, when I talk to my internet service provider, it's over a SLIP (now PPP) connection. So if you wanted to bug what was said, either you'd listen in over the line and have to decode the transmission, or you could go to the service provider (more difficult) and ask them to decode a particular user's connection. OK, so now they're listening to everything I do over my SLIP/PPP connection. A couple of months ago I was messing around with faking articles through nntp servers and through anonymous remailers. I chose a nice inconspicuous newsgroup for my little tests, something no-one would ever notice. Guess which newsgroup I chose??? Yes, _FISH_!!! or rec.aquaria to be precise And guess what articles I tried to post? Goldfish, Koi carp and, you'll never guess... PIRANHA!!! The goldfish article and the Koi went through, but the piranha didn';t appear. by now you probably think this is too silly for words. But if you look in the papers a few eeks ago you will find John Major, Tonny Blair and Paddy Ashdown sharing a private joke about Major's sunburnt goldfish. We haven't had anything about Koi yet (they must be too dull ). Now, sent by someone who clearly knew what they were doing (they chose an Italian backbone site for their launch point) we have many thousands of messages to people all over the globe. All about piranha, and with the punchline that gives you something to think about, doesn't it? The way it works is that they're trying to kill two birds with one stone again. I don't knoiw why they should be against these national alliance people, but my interpretation is that they simultaneously try to discredit them, and stem the flow of Corley articles. = In article [EMAIL PROTECTED], Mike Corley [EMAIL PROTECTED] wrote: John J Smith ([EMAIL PROTECTED]) wrote: : b) we do know who you are. Or are you someone else we don't know about? : You are currently known as That bloody persistant net nutter, who's : expanding from uk.misc to the rest of the world. I think the point I was trying to make is that I could tell you things from my personal life, at home and at work, which would add credibility to my story. But if I named people, then (a) they would object violently to being included in this shenanigans, and (b) I would be revealing my identity which would be bad for my personal life and my work life. Of course some people in my personal life, and at work, do know who mike corley is. But at least we're observing a studied silence for now. :People can always be called MR X, to save them being named. : :I'm completely perplexed as to what you mean by b). Revealing identity? :To who? And why would this be bad for any part of your life when you :already have a less than respectful reputation here? I'll just enumerate one or two things that I can still remember. Sometime around August/Sept 1992 I was living in a house in Oxford, and coming out of the house was physically attacked by someone - not punched, just grabbed by the coat, with some verbals thrown in for good measure. That was something the people at work shouldn't have known about... but soon after a couple of people were talking right in front of me about, yeah, I heard he was attacked. Again, one I went for a walk in some woods outside Oxford. The next day, at work, someone said you know he went to the forest yesterday. I don't want to put details on usenet of what happened because to do so would be to risk it happening again. If you put ideas in peoples' heads then you can find them reflecting back at you, and I don't want that. Also I can't remember that much from three years ago. From november 1992 I started taking major tranquilizers and just blotted the whole thing from my mind. This is a feature time and time again, that the security services (presumed) get at you by manipulating other people around you to get at you. If you have their contacts, manpower, resources and technology then you can do that sort of thing. :But why? Are you a threat? They pretend they have to get at me. After the first few weeks they had to find a reason to spy and abuse. You can't abuse someone unless they're in the wrong in some way. What I did wrong was to be ill. So it became nutter and monster and he's going to attack us coupled with ha ha ha, he can't do anything to defend himself, it was so funny. That obvious contradiction within their propaganda is something they blithely ignore. :So, the Security Services never
Re: python-ldap for Python 2.5 on Windows?
Benedict Verheyen wrote: i found python-ldap for version Python 2.4. Is there i place i can find a version for 2.5? If not, how can i build it myself for Windows? Depending on what you need you might want to dive into OpenLDAP's FAQ: http://www.openldap.org/faq/data/cache/300.html There has been some discussion on the python-ldap-dev mailing list about that. But there were no contributions coming out of that. Ciao, Michael. -- http://mail.python.org/mailman/listinfo/python-list
Obtaining hte currently running script under windows
Hi: Is there any way to obtain the full path to the currently running script under win32? I am using the pythonw.exe file is that helps. Sean. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to do reading of binary files?
On 8 jun, 15:19, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: In [EMAIL PROTECTED], Diez B. Roggisch wrote: jvdb schrieb: True. But there is another issue attached to the one i wrote. When i know how much this occurs, i know the amount of pages in the file. After that i would like to be able to extract a given amount of data: file x contains 20 0C. then for example i would like to extract from instance 5 to instance 12 from the file. The reason why i want to do this: The 0C stands for a pagebreak in PCL language. This way i would be absle to extract a certain amount of pages from the file. And? Finding the respective indices by using last_needle_position = 0 positions = [] while last_needle_position != -1: last_needle_position = contents.find(needle, last_needle_position+1) if last_needle_position != -1: positions.append(last_needle_position) will find all the pagepbreaks. then just slice contents appropriatly. Did you read the python tutorial? Maybe splitting at '\x0c', selecting/slicing the wanted pages and joining them again is enough, depending of the size of the files and memory of course. One problem I see is that '\x0c' may not always be the page end. It may occur in rastered image data too I guess. Ciao, Marc 'BlackJack' Rintsch Hi, your last comment is also something i have noticed. There are a number of occasions where this will happen. I also have to deal with this. I will dive into this on monday, after this hot weekend. cheers, Jeroen -- http://mail.python.org/mailman/listinfo/python-list
Binary / SOAPpy
Hello Guys, I have a WebService call which returns an array, the first element in that array is the binary for a zip file, however I'm having trouble writing that binary string into an actual file when it arrives, I've tried the following method. Result = call to the webservice that returns the array. file = open(Zips/1.zip, wb) file.write(result[0]) file.close() But this throws the error message: file.write(result[0]) TypeError: argument 1 must be string or read-only buffer, not instance Does anyone know what I might be doing wrong? Once I've resaved this file can then unzip it and get at all its lovely content. Thanks for any input guys, Rob -- http://mail.python.org/mailman/listinfo/python-list
Re: ftplib error- Large file
[EMAIL PROTECTED] wrote: Ok. I guess that makes sense. But what about the other questions...mainly: Why would it throw an exception even though the file was properly transferred? Je, well, I answered the one I knew about, :) Regarding the error... es hard to say. What happens if you transmit the file using a standard ftp program? Or better, could you sniff your network to see what is the TCP dialog? I guess this could be blamed on the FTP server. Maybe. Maybe not... -- . Facundo . Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ -- http://mail.python.org/mailman/listinfo/python-list
MI5 Persecution: Watch Out, Forger About 27/9/95 (3590)
From: [EMAIL PROTECTED] (Ray Dunn) Newsgroups: uk.misc,soc.culture.british Subject: Re: An apology from Mike Corley Date: Wed Sep 27 14:20:36 1995 In referenced article, David Wooding says... Well, Mike Corley might or might not have written the apologies, but I think not. I thought the following line both witty and imaginative. It was the razor blades stuffed down between the keys that told me. Corley himself denies posting this apology, but I'm impressed if it is a forgery. Here's the header of my received email. It looks very genuine except for the fact that postings to newsgroups are directed through demon's mail to news gateway, which is strange. Also the message id is [EMAIL PROTECTED] which seems to be in a different format from previous Corley postings, e.g. [EMAIL PROTECTED] The mail seems to have been received directly from mail.torfree.net. One way of telling for sure would be if anyone on the recipient list contacted torfree, but did not publish any complaints on the newsgroups - he would not have had access to their address in that case. Received: from SpoolDir by ULTIMATE (Mercury 1.20); 26 Sep 95 12:00:14 +0500 Return-path: [EMAIL PROTECTED] Received: from mail.torfree.net by smtp.ultimate-tech.com (Mercury 1.20); 26 Sep 95 12:00:04 +0500 Received: from bloor.torfree.net ([199.71.188.18]) by mail.torfree.net (/\==/\ Smail3.1.28.1 #28.6; 16-jun-94) via sendmail with smtp id [EMAIL PROTECTED] for [EMAIL PROTECTED]; Tue, 26 Sep 95 11:31 EDT Received: from torfree.net by bloor.torfree.net with smtp (Smail3.1.28.1 #6) id m0sxbx2-000JEeC; Tue, 26 Sep 95 11:29 EDT Message-Id: [EMAIL PROTECTED] Apparently-To: [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED] Newsgroups: uk.misc, uk.media, soc.culture.british, soc.culture.canada, uk.legal, alt.conspiracy From: [EMAIL PROTECTED] (Mike Corley) Subject: Oops! Sorry! Organization: Toronto Free-Net X-Newsreader: TIN [version 1.2 PL2] Date: Thu, 26 Sep 1995 01:23:45 GMT Lines: 27 X-PMFLAGS: 33554560 -- Ray Dunn (opinions are my own) | Phone: (514) 938 9050 Montreal | Phax : (514) 938 5225 [EMAIL PROTECTED] | Home : (514) 630 3749 3590 -- http://mail.python.org/mailman/listinfo/python-list
python-ldap for Python 2.5 on Windows?
Hi, i found python-ldap for version Python 2.4. Is there i place i can find a version for 2.5? If not, how can i build it myself for Windows? Thanks, Benedict -- http://mail.python.org/mailman/listinfo/python-list
Re: How Can I Increase the Speed of a Large Number of Date Conversions
vdicarlo [EMAIL PROTECTED] writes: I am a programming amateur and a Python newbie who needs to convert about 100,000,000 strings of the form 1999-12-30 into ordinal dates for sorting, comparison, and calculations. Though my script does a ton of heavy calculational lifting (for which numpy and psyco are a blessing) besides converting dates, it still seems to like to linger in the datetime and time libraries. (Maybe there's a hot module in there with a cute little function and an impressive set of attributes.) Anyway, others in this group have said that the date and time libraries are a little on the slow side but, even if that's true, I'm thinking that the best code I could come up with to do the conversion looks so clunky that I'm probably running around the block three times just to go next door. Maybe someone can suggest a faster, and perhaps simpler, way. Here's my code, in which I've used a sample date string instead of its variable name for the sake of clarity. Please don't laugh loud enough for me to hear you in Davis, California. dateTuple = time.strptime(2005-12-19, '%Y-%m-%d') dateTuple = dateTuple[:3] date = datetime.date(dateTuple[0], dateTuple[1], dateTuple[2]) ratingDateOrd = date.toordinal() P.S. Why is an amateur newbie trying to convert 100,000,000 date strings into ordinal dates? To win try to win a million dollars, of course! In case you haven't seen it, the contest is at www.netflixprize.com. There are currently only about 23,648 contestants on 19,164 teams from 151 different countries competing, so I figure my chances are pretty good. ;-) I can't help noticing that dates in '-mm-dd' format are already sortable as strings. '1999-12-30' '1999-12-29' True depending on the pattern of access the slightly slower compare speed _might_ compensate for the conversion speed. Worth a try. Eddie -- http://mail.python.org/mailman/listinfo/python-list
Re: read xml file from compressed file using gzip
On Jun 8, 9:45 pm, flebber [EMAIL PROTECTED] wrote: On Jun 8, 3:31 pm, Stefan Behnel [EMAIL PROTECTED] wrote: flebber wrote: I was working at creating a simple program that would read the content of a playlist file( in this case *.k3b) and write it out . the compressed *.k3b file has two file and the one I was trying to read was maindata.xml. Consider using lxml. It reads in gzip compressed XML files transparently and provides loads of other nice XML goodies. http://codespeak.net/lxml/dev/ Stefan I will, baby steps at the moment for me at the moment though as I am only learning and can't get gzip to work This is my latest attempt #!/usr/bin/python import os import zlib class gzip('/home/flebber/oddalt.k3b', 'rb') main_data = os.system(open(/home/flebber/maindata.xml)); for line in main_data: print line main_data.close() -- http://mail.python.org/mailman/listinfo/python-list
MI5 Persecution: Question and Answer 27/9/95 (2076)
In article [EMAIL PROTECTED] [EMAIL PROTECTED] Mike Corley writes: ##: There were also a few other things said at the trial ##: relating to this which I won't repeat here; it was in the papers ##: at the time anyway. This quote and others said by and about this ##: witness were repeating things that had been said by and about ##: me at around that time. When, where and by whom ? Let's have some details that can be checked. I'm not going to repeat them. They're hurtful to me because they contained abuse that was directed against me by someone else at the time and which got picked up and thrown again in the trial. It is a matter of record but I won't repeat it here. PM: Who's character is being assassinated? It isn't clear from the post. PM: Are we talking about Grenville Janner? I thought he was a spook PM: himself? He's certainly able to hold his own on the issue you cite. ##: Mine, mainly. The reason for putting that episode at the top ##: of the posting is that they tried to kill two birds with one stone ##: at the Beck trial - they simultaneously put words into the mouth ##: of their invented witness to smear Janner, and repeated exactly, ##: word-for-word, stuff which had been said by and about me. Why would they wish to assassinate your character? Well, let's put it this way - just because this is the first time it's happened in this way, from these people, on this scale, doesn't mean that it hasn't happened before, on a lesser scale. At university there were people who quite overtly hated me and would have wished something nasty to happen to me. Because of where I went making the wrong sort of enemies is pretty deadly. They would wish to assassinate my character because it had all been done before, and because they knew I would not be able to react in any other way than I'd reacted previously. ##: They invaded my home with their bugs, they repeated what I ##: was saying in the privacy of my home, and they laughed that it ##: was so funny, that I was impotent and could not even communicate ##: what was going on. Who did this? Our friends on BBC television, ##: our friends in ITN, last but not least our friends in Capital ##: Radio in London and on Radio 1. Please give details of when, where and by whom these comments were made, so that they can be checked. This was four, five years ago... sorry, I don't remember. I can remember individual incidents, words which were repeated by different people at different times in different locations. Around the end of 1992 Private Eye rtan a front-cover with John and Norma Major, with the title Major's support lowest ever and John saying to Norma Come back norma on the front cover. What can you read in to that? Not a lot, seems like standard fare for PE. The first time I saw it I was in the pub with some people from work. One was expressing doubts to the other (let's call the first one Simon, shall we? and the second one Phil?) about whether what was going on was right. Phil's answer was that if Private Eye was doing it then it must be ok, they're usually right. A few days later, again near work, there were some students laughing in the street, Were you COMING BACK later? But I thought you said you were COMING BACK ha ha ha? Play on words, you see. Not very nice, either. I had start medication soon afterwards. Clever people, these chaps who think up PE titles. Just slightly lacking in any sense of morality. ##: How did they do this? I'll give you an example. About a year ago, ##: I was listening to Chris Tarrant (Capital Radio DJ among other ##: pursuits) on his radio morning show, when he said, talking about ##: someone he didn't identify, you know this bloke? he says we're ##: trying to kill him. We should be done for attempted manslaughter ##: which mirrored something I had said a day or two before. ##: Now that got broadcast to the whole of London - if any recordings ##: are kept of the shows then it'll be there. What was the date of the broadcast ? Out of 2 million plus listeners, why should you be the only one that Tarrant was allegedly referring to ? Sometyime in spring 1994. I can't remember the date, I heard the broadcast in the car - I was going into the office from London that day and just happened to snap on the radio, and hey presto! Mr Tarrant gives us the benefit of his excellent understanding. ##: That's exactly what we did. We went to a competent, professional ##: detective agency in London, paid them over 400 quid to debug our house. ##: They found nothing.
Re: running a random function
On 2007-06-08, Stebanoid [EMAIL PROTECTED] wrote: On 8, 00:07, Dustan [EMAIL PROTECTED] wrote: On Jun 7, 1:30 pm, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-06-07, Stebanoid [EMAIL PROTECTED] wrote: if you have a list of functions you can try this: import random import math m[int(math.floor(len(m)*random.random()))]() # seems like Lisp Or rather m[random.randint(0, len(m))]() Or rather random.choice(m)() # seems like Python -- Neil Cerutti Caution: Cape does not enable user to fly. --Kenner's Batman costume Sorry :( I have no experience using this module in Python, and forget this functions because I newer use this. Sorry for my terrible English. :P No need to apologise. My solution above wasn't the best one posted either! -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: read xml file from compressed file using gzip
On Jun 8, 3:31 pm, Stefan Behnel [EMAIL PROTECTED] wrote: flebber wrote: I was working at creating a simple program that would read the content of a playlist file( in this case *.k3b) and write it out . the compressed *.k3b file has two file and the one I was trying to read was maindata.xml. Consider using lxml. It reads in gzip compressed XML files transparently and provides loads of other nice XML goodies. http://codespeak.net/lxml/dev/ Stefan I will, baby steps at the moment for me at the moment though as I am only learning and can't get gzip to work -- http://mail.python.org/mailman/listinfo/python-list
Pyrex problem with cdef'd attribute
I'm using Pyrex 0.9.5.1a. I have this simple Pyrex module: cdef class Foo: cdef public char attr def __init__(self): self.attr = 0 class Bar(Foo): def __init__(self): Foo.__init__(self) self.attr2 = None def mod(self): self.attr = c'B' f = Bar() f.mod() When I run Python and import it an exception is raised: % python Python 2.4.2 (#1, Feb 23 2006, 12:48:31) [GCC 3.4.1] on sunos5 Type help, copyright, credits or license for more information. import badattr Traceback (most recent call last): File stdin, line 1, in ? File badattr.pyx, line 16, in badattr f.mod() File badattr.pyx, line 13, in badattr.Bar.mod self.attr = c'B' TypeError: bad argument type for built-in operation If the mod() method is defined in the base class it works properly. Is this a Pyrex bug or am I not allowed to modify cdef'd attributes in subclasses? (Note that I want Bar visible outside the module, hence no cdef.) Thanks, Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: how to do reading of binary files?
jvdb schrieb: On 8 jun, 14:07, Diez B. Roggisch [EMAIL PROTECTED] wrote: jvdb schrieb: .. What has the searching to do with the reading? 10MB easily fit into the main memory of a decent PC, so just do contents = open(file).read() # yes I know I should close the file... print contents.find('\x0c') Diez True. But there is another issue attached to the one i wrote. When i know how much this occurs, i know the amount of pages in the file. After that i would like to be able to extract a given amount of data: file x contains 20 0C. then for example i would like to extract from instance 5 to instance 12 from the file. The reason why i want to do this: The 0C stands for a pagebreak in PCL language. This way i would be absle to extract a certain amount of pages from the file. And? Finding the respective indices by using last_needle_position = 0 positions = [] while last_needle_position != -1: last_needle_position = contents.find(needle, last_needle_position+1) if last_needle_position != -1: positions.append(last_needle_position) will find all the pagepbreaks. then just slice contents appropriatly. Did you read the python tutorial? diez -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython / Dabo demo shell ?
On 6/8/07, stef [EMAIL PROTECTED] wrote: hello, I was impressed by the demo shell of wxPython, and a few days ago (finally getting Dabo to work), I saw Dabo uses the same demo shell. Is there any more information available about this shell, because it seems a very nice / good way to show (many) demos, in an organized way to newbies. thanks, Stef mientki -- The shell in the wxPython demo (but apparently not in the dabo demo, as per Ed's email) is from the wx.py package. It's quite trivial to add to your own applications, documentation is at http://www.wxpython.org/PyManual.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Case-Insensitive Sorting of Multi-Dimensional Lists
On 6/7/07, Joe [EMAIL PROTECTED] wrote: I have a list of lists that I would like to sort utilizing a certain index of the nested list. I am able to successfully use: Import operator list = [[Apple, 1], [airplane, 2]] list.sort(key=operator.itemgetter(0)) But, unfortunately, this will be case sensitive (Apple will come before airplane because the A is capital) and I need it to be insensitive. Try: list.sort(key=lambda el: el[0].lower()) BUT - it's not a good idea to use list as a name, 'cos list is a built-in, and you're obscuring it. -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Re: how to do reading of binary files?
In [EMAIL PROTECTED], Diez B. Roggisch wrote: jvdb schrieb: True. But there is another issue attached to the one i wrote. When i know how much this occurs, i know the amount of pages in the file. After that i would like to be able to extract a given amount of data: file x contains 20 0C. then for example i would like to extract from instance 5 to instance 12 from the file. The reason why i want to do this: The 0C stands for a pagebreak in PCL language. This way i would be absle to extract a certain amount of pages from the file. And? Finding the respective indices by using last_needle_position = 0 positions = [] while last_needle_position != -1: last_needle_position = contents.find(needle, last_needle_position+1) if last_needle_position != -1: positions.append(last_needle_position) will find all the pagepbreaks. then just slice contents appropriatly. Did you read the python tutorial? Maybe splitting at '\x0c', selecting/slicing the wanted pages and joining them again is enough, depending of the size of the files and memory of course. One problem I see is that '\x0c' may not always be the page end. It may occur in rastered image data too I guess. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Bragging about Python
On Jun 7, 6:15 pm, Steve Howell [EMAIL PROTECTED] wrote: Programs like this were posted on this thread: def fib(): generation, parent_rabbits, baby_rabbits = 1, 1, 1 while True: yield generation, baby_rabbits generation += 1 parent_rabbits, baby_rabbits = \ baby_rabbits, parent_rabbits + baby_rabbits for pair in fib(): if pair[0] 100: break print Generation %d has %d (baby) rabbits. % pair One goal behind the SimplePrograms page is to give people that are new to Python a *gentle* immersion into Python code. I prefer simple: parent_rabbits, baby_rabbits = (1, 1) while baby_rabbits 100: print 'This generation has %d rabbits' % baby_rabbits parent_rabbits, baby_rabbits = (baby_rabbits, parent_rabbits + baby_rabbits) Somebody commented in another reply that they'd prefer the variable names a and b, but other than that, I think it's hard to simplify this. The problem of counting rabbits is not sufficiently rich to motivate a solution with generator functions, and yield statements are just gonna scare people away from the Python, unless they've had a chance to see simpler idioms first. I do think there's a place on the page for a good generators example, but it needs to solve a sufficiently complex problem that the use of generators actually simplifies the solution. So I'm throwing down the gauntlet--can somebody write a short program (maybe 10 to 20 lines) where you solve a problem more simply than a similar non-generator-using solution would solve it? Maybe something like Eight Queens? -- Steve P.S. FWIW the page does already include examples of generator expressions and the itertools module, but it does not yet show any code that actually implements a generator. I would greatly welcome the addition of a good example. ____ Yahoo! oneSearch: Finally, mobile search that gives answers, not web links.http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC- Hide quoted text - - Show quoted text - Well, I misread your gauntlet throwing, and implemented a brief 8- queens using recursion and exceptions. Perhaps this could serve as the before to an after using generators. (I note that neither recursion nor exceptions are covered in your examples.) Also, in googling about for other 8-queens solutions in Python, most are quite complicated - this one uses only 24 lines, and works for boards of any size. I also think this line for printing out the board: print \n.join( .*q+Q+.*(BOARD_SIZE-q-1) for q in queens ) illustrates a couple of interesting idioms of Python (joining a list, generator expression, .*repetition to give ). Worthy of your page? -- Paul BOARD_SIZE = 8 def validate(queens): left = right = col = queens[-1] for r in reversed(queens[:-1]): left,right = left-1,right+1 if r in (left, col, right): raise Exception def add_queen(queens): for i in range(BOARD_SIZE): testQueens = queens+[i] try: validate(testQueens) if len(testQueens)==BOARD_SIZE: return testQueens else: return add_queen(testQueens) except: pass raise Exception queens = add_queen([]) print queens print \n.join( .*q+Q+.*(BOARD_SIZE-q-1) for q in queens ) -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython / Dabo demo shell ?
On Jun 8, 2007, at 8:59 AM, Chris Mellon wrote: The shell in the wxPython demo (but apparently not in the dabo demo, as per Ed's email) is from the wx.py package. It's quite trivial to add to your own applications, documentation is at http://www.wxpython.org/PyManual.html I may be wrong, but I believe that the OP was interested in the overall frame, contents, and inner workings of the wxPython demo application (and DaboDemo), not the PyShell interpreter. -- Ed Leafe -- http://leafe.com -- http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython / Dabo demo shell ?
Ed Leafe wrote: On Jun 8, 2007, at 8:59 AM, Chris Mellon wrote: The shell in the wxPython demo (but apparently not in the dabo demo, as per Ed's email) is from the wx.py package. It's quite trivial to add to your own applications, documentation is at http://www.wxpython.org/PyManual.html I may be wrong, but I believe that the OP was interested in the overall frame, contents, and inner workings of the wxPython demo application (and DaboDemo), not the PyShell interpreter. Yes you're right Ed, I'm interested in the overall demo setup, really beautiful and powerful, just one thing missing (user configurable tree). And if you can copy it, I'm allowed to do so also ;-) thanks, Stef -- Ed Leafe -- http://leafe.com -- http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Using doctest with simple text files ?
I have a problem involving lots of simple text files (Java properties files), for which I'm building Python tools to manage their contents. I'm also writing lots of Python modules and using doctest to embed unit tests within them. Maintenance and shhared code ownership is an issue here. What's the best way to test my file modification operations, within the context of doctest-like testing? I like the simple immediacy of doctest and it's working well for my in-Python testing, but I can't seem to find a simple way of integrating it with the resultant text files (e.g. something like diff) Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: FTP/SSL
I'm trying to figure out how to use FTP/SSL (FTPS) - just as a client. Can I do this in Python? Is everything I need in ftplib? Where else do I look? And - any good newbie references on using FTPS? Hi, Nancy, I'm not sure if ftplib can handle ssh or not, but googling for python sftp turned up this link: http://www.lag.net/paramiko/ It looks like it might do what you want. -Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython / Dabo demo shell ?
On Jun 8, 2007, at 10:01 AM, stef wrote: I'm interested in the overall demo setup, really beautiful and powerful, just one thing missing (user configurable tree). And if you can copy it, I'm allowed to do so also ;-) You can certainly copy and customize the DaboDemo code. There is a folder named 'samples' that contains the the code for each individual demo. If you look at a few of those, you should be able to figure out how to create your own. The tree is created dynamically at startup, based on the files in the 'samples' directory, and each of those files' 'category' attribute. If you have any further questions, it would probably be best to post them to the dabo-users list. You can sign up for it at http:// leafe.com/mailman/listinfo/dabo-users -- Ed Leafe -- http://leafe.com -- http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter custom drawing
from Tkinter import Invisiblecanvas ? The whole web never mentions this Invisiblecanvas. Do you have anything alike to share ? ;) Xavier -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter custom drawing
Now, the problem, is that I have already plenty of widgets on my screen. I just want to draw over them, which is a bit difficult in my comprehension of things. What are you trying to achieve by drawing over widgets? Want I want to do is a sort of GUI builder for Tkinter. I already finished a rough version, but for now I'm making a lighter version of this project. So, my intent, is to create a widget under the widget. While dragging the mouse, I want to see this rectangle that defines the boundaries of the new widget I'm creating. Sorry for being unclear. -- http://mail.python.org/mailman/listinfo/python-list
Re: error when calling method of class
2007/6/8, Sean Farrow [EMAIL PROTECTED]: Hi: I have defined a class in that class is a method defined as follows: def splitTime(n): seconds =float(n) I call the method in another procedure as follows: sefl.splitTime(200) the traceback states that splitTime takes one argument two given. why is this occuring? if I try calling it like: splitTime(200) I get a name resultion error saying that the global name splitTime is not defined. Any help apreciated. In self.splitTime(200), self is considered an argument as well, thus the definition should be done with: def splitTime(self,n): -- Andre Engels, [EMAIL PROTECTED] ICQ: 6260644 -- Skype: a_engels -- http://mail.python.org/mailman/listinfo/python-list
Re: how to do reading of binary files?
On 2007-06-08, jvdb [EMAIL PROTECTED] wrote: I have a binary (pcl) file. In this file i want to search for specific codes (like 0C). I have tried to solve it by reading the file character by character, but this is very slow. Especially when it comes to files which are large (10MB) this is consuming quite some time. Does anyone has a hint/clue/solution on this? I'd memmap the file. http://docs.python.org/lib/module-mmap.html If you prefer it to appear as an array of bytes instead of a string, the various numeric/array packags can do that. Numarray: http://stsdas.stsci.edu/numarray/numarray-1.5.html/module-numarray.memmap.html Vmaps: http://snafu.freedom.org/Vmaps/Vmaps.html Numpy: documentation is not free Since I can't point you to Numpy docs, here's a link to a newsgroup thread with an example for numpy: http://groups.google.com/group/comp.lang.python/browse_frm/thread/c63c3e281df99897/2336baa98386d5e7 -- Grant Edwards grante Yow! I like your SNOOPY at POSTER!! visi.com -- http://mail.python.org/mailman/listinfo/python-list
Binary
I am trying to make a programm that converts a decimal number like 79 to a binary number. where it asks you for a number then produces the binary. so far I have this: x = (input(Enter number: )) b = 2.0 while x 0: print x x = x/b I need it to show the remainder. like remainder 1 or 0 the put all of them in a list that is backwards. Any Ideas ___ Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now. http://uk.answers.yahoo.com/ -- http://mail.python.org/mailman/listinfo/python-list
interating over single element array
Hi all, Can someone please explain to me why I can't do something like this: a = 1 for value in a: print str(value) If I run this I get the error: 'int' object is not iterable Obivously this is an absurd example that I would never do, but in my application the length of 'a' can be anything greater than 0, and I want to be able to handle cases when 'a' has only one element without coding a special case just in the event that len(a) = 1. any suggestions are appreciated, trevis -- http://mail.python.org/mailman/listinfo/python-list
knowledge management in OSS communities
Dear All, I am a PhD student in e-Business in Durham University (UK). My research topic is Knowledge management and innovation in virtual organisations. The aim of my thesis is to assess how and to what extent knowledge is created, shared, and circulated in open source software communities. In my empirical studies I am collecting primary data from members/ developers of OSS communities. I would be grateful if you could spend no more than 15 minutes to answer my questionnaire. (URL: http://www.dur.ac.uk/zilia.iskoujina/qq.htm). There will be some prizes - after finishing the data collection, I will randomly select some respondents and send them gift vouchers for £20 from Amazon. Thank you very much for your time and cooperation. I greatly appreciate your help in contributing to this research endeavour. Kind regards, Zilia Iskoujina PhD Student in e-Business Durham University http://www.dur.ac.uk/zilia.iskoujina/research-abstract.htm -- http://mail.python.org/mailman/listinfo/python-list
RE: Case-Insensitive Sorting of Multi-Dimensional Lists
Try: list.sort(key=lambda el: el[0].lower()) Thanks! Worked like a charm :) BUT - it's not a good idea to use list as a name, 'cos list is a built-in, and you're obscuring it. Oh, don't worry. That was strictly my portrayal of the problem. Thanks again! Jough -- http://mail.python.org/mailman/listinfo/python-list
converting an int to a string
Hi: I have the folling code: def parseTime(self, time): minutes =int(float(time)/60) seconds =int(float(time)-minutes*60) minutes =str(minutes) seconds =str(minutes) the statements that convert the minutes and seconds variables str(minutes) and str(seconds) don't seem to be working. Any idea why? is there any other way of doing this and perhaps using the $d interpolation operator? sean. -- http://mail.python.org/mailman/listinfo/python-list
Re: interating over single element array
In [EMAIL PROTECTED], T. Crane wrote: Can someone please explain to me why I can't do something like this: a = 1 for value in a: print str(value) If I run this I get the error: 'int' object is not iterable Well the message explains why you can't do this. `a` is bound to an integer and integers are not iterable. Obivously this is an absurd example that I would never do, but in my application the length of 'a' can be anything greater than 0, and I want to be able to handle cases when 'a' has only one element without coding a special case just in the event that len(a) = 1. ``len(a)`` wouldn't work either because integers have no length: In [16]: a = 1 In [17]: len(a) --- exceptions.TypeError Traceback (most recent call last) /home/new/ipython console TypeError: len() of unsized object any suggestions are appreciated, Yes, don't try iterating over objects that are not iterable. ;-) What you *can* do is iterating over lists, tuples or other iterables with just one element in them. Try ``a = [1]``. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Binary
On 6/8/07, Brain Murphy [EMAIL PROTECTED] wrote: I need it to show the remainder. like remainder 1 or 0 the put all of them in a list that is backwards. Take a look at the divmod() function. It take the numerator and denominator and returns a tuple of the quotient and remainder. For example: divmod(5, 2) (2, 1) divmod(6, 2) (3, 0) -- Jerry -- http://mail.python.org/mailman/listinfo/python-list
Re: Case-Insensitive Sorting of Multi-Dimensional Lists
On 8 Jun, 14:18, Simon Brunning [EMAIL PROTECTED] wrote: On 6/7/07, Joe [EMAIL PROTECTED] wrote: I have a list of lists that I would like to sort utilizing a certain index of the nested list. I am able to successfully use: Import operator list = [[Apple, 1], [airplane, 2]] list.sort(key=operator.itemgetter(0)) But, unfortunately, this will be case sensitive (Apple will come before airplane because the A is capital) and I need it to be insensitive. Try: list.sort(key=lambda el: el[0].lower()) BUT - it's not a good idea to use list as a name, 'cos list is a built-in, and you're obscuring it. -- Cheers, Simon B. [EMAIL PROTECTED]://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues I have tried the following, for a one dimensional list and it works, but I can not get my head around this lambda. How would this be written, without the lamda ? mylist = ['Fred','bill','PAUL','albert'] mylist.sort(key=lambda el: el.lower()) Any pointer to an idiot's guide appreciated. Richard -- http://mail.python.org/mailman/listinfo/python-list
Re: Case-Insensitive Sorting of Multi-Dimensional Lists
In [EMAIL PROTECTED], mosscliffe wrote: I have tried the following, for a one dimensional list and it works, but I can not get my head around this lambda. How would this be written, without the lamda ? Well ``lambda``\s are just anonymous functions so you can write it with a named function of course. mylist = ['Fred','bill','PAUL','albert'] mylist.sort(key=lambda el: el.lower()) So this becomes: def keyfunc(el): return el.lower() mylist.sort(key=keyfunc) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
launching default browser
Hi, I wonder how to launch from python default Windows browser? In fact I have the same question for Linux. thx in advancve, -- alf -- http://mail.python.org/mailman/listinfo/python-list
Re: converting an int to a string
Sean Farrow schrieb: Hi: I have the folling code: def parseTime(self, time): minutes =int(float(time)/60) seconds =int(float(time)-minutes*60) minutes =str(minutes) seconds =str(minutes) the statements that convert the minutes and seconds variables str(minutes) and str(seconds) don't seem to be working. Any idea why? is there any other way of doing this and perhaps using the $d interpolation operator? What do you mean by don't seem to be working Usually, they do: Python 2.4.4 (#1, Oct 18 2006, 10:34:39) [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin Type help, copyright, credits or license for more information. Welcome to rlcompleter2 0.96 for nice experiences hit tab multiple times str(120) '120' Any change you overdefined str with something weird? Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: interating over single element array
any suggestions are appreciated, Yes, don't try iterating over objects that are not iterable. ;-) Ah, yes... I hadn't thought of that :) thanks, trevis What you *can* do is iterating over lists, tuples or other iterables with just one element in them. Try ``a = [1]``. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
RE: Case-Insensitive Sorting of Multi-Dimensional Lists
Try: list.sort(key=lambda el: el[0].lower()) Now, I would like to be able to specify which index to sort by. I am not able to pass in external variables like: List.sort(key=lambda el: el[indexNumber].lower()) I am new to lambda and have searched for a few hours this morning, coming up empty handed. Is this possible? Thanks! Jough -- http://mail.python.org/mailman/listinfo/python-list
Working with fixed format text db's
Many of the file formats I have to work with are so-called fixed-format records, where every line in the file is a record, and every field in a record takes up a specific amount of space. For example, one of my older Python programs contains the following to create a fixed-format text record for a batch of new students: new = file(new.dat, w) if not new: print Error. Could not open file new.dat for writing. raw_input(Press Return To Exit.) sys.exit(1) for s in freshmen: new.write(s.ssn.ljust(9)) new.write(s.id.ljust(10)) new.write(s.last[:16].ljust(16)) new.write(s.first[:11].ljust(11)) new.write(' '.ljust(10)) # Phone Number new.write(' '.ljust(1254)) # Empty 'filler' space. new.write('2813 ') new.write(s.major.ljust(5)) # Etc... Luckily, the output format has not changed yet, so issues with maintaining the above haven't arisen. However, I'd like something better. Is there already a good module for working with fixed format records available? I couldn't find one. If not, please suggest how I might improve the above code. -- Neil Cerutti When yearn was sung, the performers ounded like they were in a state of yearning. --Music Lit Essay -- http://mail.python.org/mailman/listinfo/python-list
python integration
I am looking for a method to integrate in Python, my problem is that I do not want the summed up result. I need the result in the form of a list (or array) with the x-values (or ranges) and the volume beneath that section of the curve only. Thanks in advance Dee -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug/Weak Implementation? popen* routines can't handle simultaneous read/write?
Noah [EMAIL PROTECTED] wrote: On Jun 7, 9:01 am, dmoore [EMAIL PROTECTED] wrote: popen and friends will never do what you want it to do. Down that path lies bitter disappointment. You need pseduo-ttys and non-blocking IO. I don't know how to do this on Windows, but I know it's possible. Cygwin does it. Anybody have any thoughts on this? Do I have my story straight? (the popen variants can't handle this case and there are no other alternatives in the standard python distro) Is there some place I can submit this as a feature request? (Python dev?) Try Pexpect http://pexpect.sourceforge.net/ It's been around for a long time and is quite complete and stable. The catch is that it's UNIX-only. If you want to tease out the magic code from wxProcess that does non-blocking reads on win32 then I'd be happy to integrate that into the current development branch of Pexpect. Windows has a really strange idea of non-blocking IO - it uses something called overlapped io. You or in the FILE_FLAG_OVERLAPPED flag when you create the file/pipe. You then pass in overlap buffers for reading writing. I implemented this for serial ports in C a while ago. If you look at the code in pyserial (in serialwin32.py) you'll see a very similar implementation of non blocking IO. I assume that the same things will work for pipes, but I've only direct experience with serial ports! I'm sure this is feasible without any C extensions -- it might require some ctypes hacking. pyserial uses win32file and win32event I know Windows has pretty decent async IO, but I don't know what they have as an equivalent for a pty. Maybe it isn't necessary. A pty is only necessary on UNIX because the standard c library, stdio, behaves differently when it's talking to a plain pipe versus a terminal -- it switches buffering between block and line oriented buffer. You don't want block buffering on interactive applications. Pty's probably aren't needed on Windows. BTW I'd love to see pexpect working on windows and also in the standard library. It is the proper answer to controlling other interactive processes IMHO. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Tkinter - Force toplevel window to stay on top of Tk() window
Hi, I have a Tk() window base_win = Tk() with multiple frames on it having a combination of widgets. If I click on say a button widget which launches a new top level window new_win = TopLevel(), I was looking for a way for this new_win to always stay on top of base_win till I close new_win, as a result also not allowing any selections to be made in the base_win . Thanks Rahul -- http://mail.python.org/mailman/listinfo/python-list
Re: launching default browser
alf wrote: Hi, I wonder how to launch from python default Windows browser? In fact I have the same question for Linux. thx in advancve, Via webbrowser module http://docs.python.org/lib/module-webbrowser.html (note: its in top five in google search for Python + launch + browser...) -- http://mail.python.org/mailman/listinfo/python-list
Re: python integration
Dee Asbury [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] |I am looking for a method to integrate in Python, my problem is that I | do not want the summed up result. I need the result in the form of a | list (or array) with the x-values (or ranges) and the volume beneath | that section of the curve only. Run the integrator for each range you want an integration for. tjr -- http://mail.python.org/mailman/listinfo/python-list
Re: converting an int to a string
On Jun 8, 10:40 am, Sean Farrow [EMAIL PROTECTED] wrote: Hi: I have the folling code: def parseTime(self, time): minutes =int(float(time)/60) seconds =int(float(time)-minutes*60) minutes =str(minutes) seconds =str(minutes) the statements that convert the minutes and seconds variables str(minutes) and str(seconds) don't seem to be working. Any idea why? is there any other way of doing this and perhaps using the $d interpolation operator? sean. The divmod builtin function is your friend here. def parseTime(time): seconds = float(time) minutes,seconds = divmod(seconds,60) return %02d:%06.3f % (minutes,seconds) # just guessing divmod divides the first argument by the second, and returns the tuple (quotient,remainder). -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: python-ldap for Python 2.5 on Windows?
On Jun 8, 6:36 am, Benedict Verheyen [EMAIL PROTECTED] wrote: Hi, i found python-ldap for version Python 2.4. Is there i place i can find a version for 2.5? If not, how can i build it myself for Windows? I have managed to build it for myself using MinGW: http://www.osuch.org-a.googlepages.com/python-ldap-2.3.win32-py2.5.exe See if it will work for you Waldemar -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter - Force toplevel window to stay on top of Tk() window
On Jun 8, 11:48 am, [EMAIL PROTECTED] wrote: Hi, I have a Tk() window base_win = Tk() with multiple frames on it having a combination of widgets. If I click on say a button widget which launches a new top level window new_win = TopLevel(), I was looking for a way for this new_win to always stay on top of base_win till I close new_win, as a result also not allowing any selections to be made in the base_win . Thanks Rahul You need to research showing modal dialogs. This link looks promising: http://mail.python.org/pipermail/tkinter-discuss/2005-March/000371.html This one from Lundh's site has better explanations on dialog's in general: http://effbot.org/tkinterbook/tkinter-dialog-windows.htm Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyrex problem with cdef'd attribute
On Jun 8, 6:00 am, [EMAIL PROTECTED] wrote: I'm using Pyrex 0.9.5.1a. I have this simple Pyrex module: You might get more help on the pyrex list. cdef class Foo: cdef public char attr def __init__(self): self.attr = 0 class Bar(Foo): def __init__(self): Foo.__init__(self) self.attr2 = None def mod(self): self.attr = c'B' f = Bar() f.mod() When I run Python and import it an exception is raised: Yes, since you didn't cdef the class, it is essentially python code. Python code cannot assign to a cdef class attribute that is not of type 'object' If the mod() method is defined in the base class it works properly. Is this a Pyrex bug or am I not allowed to modify cdef'd attributes in subclasses? (Note that I want Bar visible outside the module, hence no cdef.) cdef does not affect visibility, IIRC, just whether the class is compiled into an extension type or not. This is just from memory though. Greg would be able to give you a better answer. -Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Working with fixed format text db's
Neil Cerutti [EMAIL PROTECTED] wrote: Luckily, the output format has not changed yet, so issues with maintaining the above haven't arisen. The problem surely is that when you want to change the format you have to do so in all files (and what about the backups then?) and all programs simultaneously. Maintaining the code is the least of your the problems, I'd say. You could change the data layout so that eg each field was terminated by a marker character, then read/write delimited values. But unless you also review all the other parts of your programs, you need to be sure that you don't have any other code anywhere that implicitly relies on a particular field being a known fixed length. However, I'd like something better. What precisely do you want to achieve? -- Jeremy C B Nicoll - my opinions are my own. -- http://mail.python.org/mailman/listinfo/python-list
Re: Obtaining hte currently running script under windows
On Jun 8, 8:45 am, Sean Farrow [EMAIL PROTECTED] wrote: Hi: Is there any way to obtain the full path to the currently running script under win32? I am using the pythonw.exe file is that helps. Sean. Check out Google! I found the following link by typing python os cwd http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/474083 Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyrex problem with cdef'd attribute
I'm using Pyrex 0.9.5.1a. I have this simple Pyrex module: Klaas You might get more help on the pyrex list. Thanks. On the Pyrex website it says that questions are welcome here as well. I was hoping to avoid yet another mailing list subscription. ;-) Klaas Yes, since you didn't cdef the class, it is essentially python Klaas code. Python code cannot assign to a cdef class attribute that Klaas is not of type 'object' So, if I cdef the Bar subclass I should be okay? I'll play around a bit more and if I continue to confuse myself will subscribe to the pyrex mailing list (or at least use the somewhat clunky gmane.org interface). Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Working with fixed format text db's
On 2007-06-08, Jeremy C B Nicoll [EMAIL PROTECTED] wrote: Neil Cerutti [EMAIL PROTECTED] wrote: Luckily, the output format has not changed yet, so issues with maintaining the above haven't arisen. The problem surely is that when you want to change the format you have to do so in all files (and what about the backups then?) and all programs simultaneously. I don't have control of the format, unfortunately. It's an import file format for a commercial database application. Maintaining the code is the least of your the problems, I'd say. You could change the data layout so that eg each field was terminated by a marker character, then read/write delimited values. But unless you also review all the other parts of your programs, you need to be sure that you don't have any other code anywhere that implicitly relies on a particular field being a known fixed length. However, I'd like something better. What precisely do you want to achieve? I was hoping for a module that provides a way for me to specify a fixed file format, along with some sort of interface for writing and reading files that are in said format. It is not actually *hard* to do this with ad-hoc code, but then the program is indecipherable without a hardcopy of the spec in hand. And also, as you say, if the spec ever does change, the hand-written batch of ljust, rjust and slice will be somewhat of a pain to reconfigure. But biggest weakness, to me, is that the specification is not in the code, or read and used by the code, and I think it should be. If nothing exists already I guess I'll roll my own. But I'd like to be lazier, and virtually all published modules are better than what I'll write for myself. ;) The underlying problem, of course, is the archaic flat-file format with fixed-width data fields. Even the Department of Education has moved on to XML for most of it's data files, which are much simpler for me to parse. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython / Dabo demo shell ?
Ed Leafe wrote: On Jun 8, 2007, at 10:01 AM, stef wrote: I'm interested in the overall demo setup, really beautiful and powerful, just one thing missing (user configurable tree). And if you can copy it, I'm allowed to do so also ;-) You can certainly copy and customize the DaboDemo code. There is a folder named 'samples' that contains the the code for each individual demo. If you look at a few of those, you should be able to figure out how to create your own. The tree is created dynamically at startup, based on the files in the 'samples' directory, and each of those files' 'category' attribute. If you have any further questions, it would probably be best to post them to the dabo-users list. You can sign up for it at http://leafe.com/mailman/listinfo/dabo-users Thanks very much for the information, I'll look in that in more detail in the near future. cheers, Stef -- Ed Leafe -- http://leafe.com -- http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Working with fixed format text db's
In [EMAIL PROTECTED], Neil Cerutti wrote: new = file(new.dat, w) if not new: print Error. Could not open file new.dat for writing. raw_input(Press Return To Exit.) sys.exit(1) Hey, Python is not C. File objects should *always* be true. An error is handled via exceptions. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug/Weak Implementation? popen* routines can't handle simultaneous read/write?
On Jun 8, 12:30 pm, Nick Craig-Wood [EMAIL PROTECTED] wrote: Windows has a really strange idea of non-blocking IO - it uses something called overlapped io. You or in the FILE_FLAG_OVERLAPPED flag when you create the file/pipe. You then pass in overlap buffers for reading writing. the wx guys appear to do it differently (unless FILE_FLAG_OVERLAPPED is implicit in the calls they make) take a look at: http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/src/msw/utilsexc.cpp?rev=1.88content-type=text/vnd.viewcvs-markup a reasonably well-documented wxExecute function handles all the messy win32 api calls and wraps the process in a wxProcess object and the streams in wxInputStream / wxOutputStream (also see the wxExecuteDDE function) -- http://mail.python.org/mailman/listinfo/python-list
Re: compiling python and calling it from C/C++
Diez B. Roggisch wrote: Russ schrieb: Is it possible to compile python code into a library (on unix), then link to it and call it from C/C++? If so, where can I learn how. You can't compile python, but what you can do is create a library-wrapping around it using elmer which will make it C-callable. http://elmer.sourceforge.net/ This looks promising. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Repository - file scanner
Greetings, Could someone point my muddled head at a/the python repository. I know that one exists but cannot find it again. In particular I am looking for a standalone search tool that given a path searches files for a text string. Thanks, jvh -- http://mail.python.org/mailman/listinfo/python-list
Re: Working with fixed format text db's
Neil Cerutti wrote: The underlying problem, of course, is the archaic flat-file format with fixed-width data fields. Even the Department of Education has moved on to XML for most of it's data files, :( I'm writing a small app, and was wondering the best way to store data. Currently the fields are separated by spaces. I was toying with the idea of using sqlite, yaml or json, but I think I've settled on CSV. Dull, but it's easy to parse for humans and computers. -- http://mail.python.org/mailman/listinfo/python-list
Re: Binary
Brian, I'm including the list back in on this reply, so that more than just me can see your message and potentially help out. On 6/8/07, Brain Murphy [EMAIL PROTECTED] wrote: this is what i have so far. x= 100 b=2 while x 0: print x x=divmod(x,b) the problem is that since it is a tuple I can not use that last part, x = divmod(x,b) how can I put this in a loop? were it goes through the whole number, as in 100/2=50 50/2 25 ect. but also keeping the remiander? Since divmod() returns a tuple, you need to unpack it. For example: q, r = divmod(10, 3) print q 3 print r 1 If you want to store all the remainders as you go, maybe you could build up a list of remainders by starting with an empty list and append() the values to the list as you go through the loop. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list
Re: how to do reading of binary files?
On Jun 8, 2:07 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: ... What has the searching to do with the reading? 10MB easily fit into the main memory of a decent PC, so just do contents = open(file).read() # yes I know I should close the file... print contents.find('\x0c') Diez Better make that 'open(file, rb). -- http://mail.python.org/mailman/listinfo/python-list
Re: Verify server certificate in HTTPS transaction
I struggled with that months ago. The SSL library that ships with Python is primitive, but M2Crypto can do that. M2Crypto will actually verify the certificate chain. The documentation is weak, it's hard to build, and there are bugs, but it's the best Python has right now. John Nagle Hamish Moffatt wrote: Hi, I'm fetching some files over HTTPS from Python and I want to verify the server certificate. (Not just the name etc provided in certificate.) How can I get access to this information? urllib2 doesn't seem to provide it. Even a raw SSL socket only appears to provide access to the CN, OU etc in string form (not the raw certificate). I tried pycurl, which allows you to setopt(pycurl.SSL_VERIFYPEER) and VERIFYHOST, but the getinfo(pycurl.SSL_VERIFYRESULT) call always returns 0. Perhaps it's unimplememented? I couldn't get the M2Crypto API documentation to generate; perhaps it allows it. TLS Lite on to of M2Crypto? Something else again? Thanks Hamish -- http://mail.python.org/mailman/listinfo/python-list