ANN: pyFltk-1.1RC2
This is to announce the second release candidate for pyFltk-1.1, then Python bindings for the cross platform GUI toolkit fltk-1.1 This release candidate has been tested with fltk-1.1.6 and fltk-1.1.7 and requires Python2.4. pyFltk and fltk is a lighweight, easy-to-use GUI toolkit for Python. It can be used where simplicity, small footprint, and ease-of-use are important. Changes: * Now it is possible to extend all widgets in Python * Fl_Preferences has been added. * Various bug fixes A source distribution and a Windows installer (including fltk) can be downloaded from htpp://pyfltk.sourceforge.net. Regards Andreas Held http://pyfltk.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Ann: FarPy GUIE v0.4
GUIE (GUI Editor) provides a simple WYSIWYG GUI editor for wx. The program was made in C# and saves the GUI that was created to a XML format I called GUIML. This GUIML is a pretty standard representation of the GUI created with the program. Next, GUIE takes these GUIML files and translates it to wxPython Python code. You may ask yourself why I took the extra step? Why didn't I go straight from C# controls to wxPython code? Why is GUIML necessary? Well, it isn't. It is there simply for people (or maybe I) to take the GUIML and convert it to other languages. This, by effect can convert this tool from a Python GUI editor, to any programming language with a GUI module GUI editor. http://farpy.holev.com Changes (as of v0.4) Added: wxRuby support! Fixed: Minor bugs More languages to come! -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: ConfigParser: writes a list but reads a string?
funkyj wrote: I'm interested in the same sort of config file issues. Unfortunately the restricted execution has fallen out of favor. My preferred solution would be to have a configEval() function that is just like the regular Python eval() but only accepts a subset of the python language, e.g. creating the basic built in datatypes and variable assignment and perhaps a short list of safe library functions: favoriteColors = [ 'red', 'blue', 'orange'] props = {'fish': 7, 'cow': 'milk'} # a comment otherstuff = (props, favoritColors, 7) While currently I just write my config file in python and eval() it, this sucks from a security standpoint (e.g. someone could replace the config file with a python program that deletes my hard drive). Thanks for the configObj suggestion, I'll look into that. making the config file XML and using xml.dom is another option, although XML is a bit ugly to edit by hand. On the cookbook there is a serialize and de-serialize function that works with the basic datatypes, but doesn't have the associated risks of using eval. ConfigObj is still a better solution IMHO. :-) All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml --jfc -- http://mail.python.org/mailman/listinfo/python-list
Re: Python shell interpreting delete key as tilde?
Leif K-Brooks wrote: I'm running Python 2.3.5 and 2.4.1 under Debian Sarge. Instead of deleting the character after the cursor, pressing my delete key in an interactive Python window causes a system beep and inserts a tilde character. that's probably because the delete key can be set up to send a \e[3~ sequence, and readline isn't properly configured to understand that. This behavior occurs across all of the terminals I've tried (xterm, Konsole, real Linux terminal), but does not occur when running bash instead of python. Other Readline-provided functionality (moving the cursor, history) seems to work fine. The delete key was working fine in Python up until a few days ago, and I don't remember making any changes that should have affected it. If anyone knows what could be causing this problem, please explain. It's driving me crazy! this page might help: http://www.ibb.net/~anne/keyboard.html or you could switch to a less lame operating system ;-) (duck). /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Redirecting standard out in a single namespace
Ido Yehieli wrote: I'm sorry, but i don't see how this will solve the problem? It is exactly the same, only now you've replaced everything in sys except just sys.stdout? In the solution above (which I haven't had a chance to test) you're just chaning hte reference to sys to point to a different module, so you're not messing with sys itself. This won't affect other code that uses the sys module. Because of the builtin status of the sys module I'm not *convinced* it will work. I'll try it though. At any rate, perhapse the code you will write will be more maintainable if instead of redirecting sys.stdout for some of the code just use a different function (instead of print) for the times where you wish it to be redirected somewhere else? it will probably make your code longer, but the maintainer will have one less gotcha to worry about a few months/years down the road. perhapse it is best to not do the clever thing this time ;-) ? We're executing code from another module that uses the print statement a lot. That module isn't our code - other wise we wouldn't have a problem. :-) Changing the module will mean a great deal more to maintain, not less. All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml -- http://mail.python.org/mailman/listinfo/python-list
Re: New Bee
Prasanna wrote: I am new to this group.I am willing to learn PYTHON can anyone suggest me where to start.I have installed PYTHON 2.4 windows platform.Where can I get books for beginners.How to go about?.It would be helpful if anyone is will to guide me. Here is something helpful for newbies: http://www.awaretek.com/tutorials.html#begin http://www.awaretek.com/python/python411_Intro.mp3 -- http://mail.python.org/mailman/listinfo/python-list
Re: New Bee
Thanx for ur info. Prasanna -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: excellent book on information theory
Paul Rubin wrote: The first few pages are a review of probability theory but I think they assume you've seen it before. The book's subject matter is more mathematical by nature than what most programmers deal with from day to day, and as such, the book is not for everyone. And so the cycle repeats itself. We teach our students the world is all about money, and sure enough, the world is all about money. If we would continue to keep the interesting things away from most of the people, by hiding it behind mathematical jargon we end up believing that functional programming is connected to having a math degree and more such self serving and self fullfilling prophecies. An excellent book would break with this jargon advertising salesmanship. Anton but I'll give it one more try -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: excellent book on information theory
In article [EMAIL PROTECTED], Steven D'Aprano [EMAIL PROTECTED] wrote: But the real question is why it is that American publishers believe their readers are so lazy and ignorant that they require special translations of British books. I don't know anyone who has said I'm glad that I read the American edition of [Harry Potter/Discworld/pick your own example], it was much better than the British edition. Not even American fans. Something which irritates me, along with many other British people, is a book written in UK English, but which uses US spelling for the American market. If people can understand the words, then the slight differences in spelling shouldn't be a problem. -- David Wild using RISC OS on broadband -- http://mail.python.org/mailman/listinfo/python-list
Re: How to generate graphics dynamically on the web using Python CGI script?
Steve Holden wrote: Luiz Geron wrote: I don't have experience on this, but I think that you can make the script return the image contents directly to the img tag, without passing it to a img file, so you can use something like this: img src=script_that_return_image_contents wich saves some processing and I/O. No it doesn't, because the script that generates the graphic is then a different script from the one that generates the referring HTML. I agree that scripted generation of the graphical content is a viable option that I overlooked, though it seems from the OP's inquiry that he already uses CGI to generate the HTML. It doesn't save processing/IO, but it can still be done from teh same script. Just pass parameters in the ``src='...'`` tag to tell the script which image to output. Either that or the script can generate static images (and maybe do a cyclic cleanup) and put the correct URL into the image tags. All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How to generate graphics dynamically on the web using Python CGI script?
Steve Holden wrote: Luiz Geron wrote: I don't have experience on this, but I think that you can make the script return the image contents directly to the img tag, without passing it to a img file, so you can use something like this: img src=script_that_return_image_contents wich saves some processing and I/O. No it doesn't, because the script that generates the graphic is then a different script from the one that generates the referring HTML. I agree that scripted generation of the graphical content is a viable option that I overlooked, though it seems from the OP's inquiry that he already uses CGI to generate the HTML. It doesn't save processing/IO, but it can still be done from the same script. Just pass parameters in the ``src='...'`` tag to tell the script which image to output. Either that or the script can generate static images (and maybe do a cyclic cleanup) and put the correct URL into the image tags. All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python shell interpreting delete key as tilde?
Fredrik Lundh wrote: [snip..] this page might help: http://www.ibb.net/~anne/keyboard.html or you could switch to a less lame operating system ;-) (duck). Not like you to duck when sending flames Fredrik ;-) Fuzzy /F -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: introduction to computing clusters?
Cameron Laird [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Bring back VMS. That's creepy, I was just reminiscing about working on VAXen less than 12 hours ago! One of my favorite bits of the VAX documentation was the book VAX/VMS Internals. Each chapter started with a related quote. I think the chapter on the layers of security cited Tolkein's description of the construction of the city of Gondor in concentric rings. But the best quote was one for the chapter on memory, that quoted Joe Walsh: I was in the Eagles? Cool! -- Paul -- http://mail.python.org/mailman/listinfo/python-list
ValueError: need more than 3 values to unpack
Hello All, I have a tab separated input file (data.txt) in text format - the file looks like this SCHOOL DEPART1 DEPART2 DEPART3 Harvard Economics Mathematics Physics StanfordMathematics Physics BerkeleyPhysics U.C.L.A Biology Genetics I have to utilize Python and to generate four files based on my input file. The files would have this structure: First File === Filename: Harvard.txt Harvard Economics Mathematics Physics === Second File === Filename: Stanford.txt Stanford Mathematics Physics === The same pattern would follow for files 3 and 4. I came up with this code, == #! python # -*- coding: cp1252 -*- InputFILENAME = data.txt #Name of the data fule containg all records OutputFileExtension = .txt #File extension of output files for line in open(InputFILENAME): SCHOOL, DEPART1, DEPART2, DEPART3 = line.split('\t') f = open(SCHOOL.strip() + OutputFileExtension, w+) f.write( +SCHOOL.strip() +\n) f.write( +DEPART1.strip() +\n) f.write( +DEPART2.strip() +\n) f.write( +DEPART3.strip() +\n) f.close() #InputFILENAME # end == I am having problems as the program will not work if all three DEPART values are not present. If I populate all DEPART values for all records program functions without issues. When I run the check module, I get the following: Traceback (most recent call last): File D:\Documents and Settings\administrator\Desktop\code\test\testcode.py, line 8, in ? SCHOOL, DEPART1, DEPART2, DEPART3 = line.split('\t') ValueError: need more than 3 values to unpack How do I solve this problem and change the program so it does not stop if a data record has less than three DEPART values. Thanks for your help! Elezar -- http://mail.python.org/mailman/listinfo/python-list
Re: Redirecting standard out in a single namespace
oh, ok... I guess people have to learn to use a logger instead of print in production code... -- http://mail.python.org/mailman/listinfo/python-list
Re: ValueError: need more than 3 values to unpack
Elezar Simeon Papo wrote: Hello All, I have a tab separated input file (data.txt) in text format - the file looks like this SCHOOLDEPART1 DEPART2 DEPART3 Harvard Economics Mathematics Physics Stanford Mathematics Physics Berkeley Physics U.C.L.A Biology Genetics I have to utilize Python and to generate four files based on my input file. The files would have this structure: First File === Filename: Harvard.txt Harvard Economics Mathematics Physics === Second File === Filename: Stanford.txt Stanford Mathematics Physics === The same pattern would follow for files 3 and 4. I came up with this code, == #! python # -*- coding: cp1252 -*- InputFILENAME = data.txt #Name of the data fule containg all records OutputFileExtension = .txt #File extension of output files for line in open(InputFILENAME): SCHOOL, DEPART1, DEPART2, DEPART3 = line.split('\t') f = open(SCHOOL.strip() + OutputFileExtension, w+) f.write( +SCHOOL.strip() +\n) f.write( +DEPART1.strip() +\n) f.write( +DEPART2.strip() +\n) f.write( +DEPART3.strip() +\n) f.close() #InputFILENAME # end == I am having problems as the program will not work if all three DEPART values are not present. If I populate all DEPART values for all records program functions without issues. When I run the check module, I get the following: Traceback (most recent call last): File D:\Documents and Settings\administrator\Desktop\code\test\testcode.py, line 8, in ? SCHOOL, DEPART1, DEPART2, DEPART3 = line.split('\t') ValueError: need more than 3 values to unpack How do I solve this problem and change the program so it does not stop if a data record has less than three DEPART values. Thanks for your help! Sounds like homework ;-) if you do : values = line.split('\t') Then you have a list with all the separate values in it. You can then do the first line : f.write( +values[0].strip() +\n) Then the rest... for entry in values[1:]: f.write( +entry.strip() +\n) This will work whatever the number of values. It won't report any badly formed lines to you though. All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml Elezar -- http://mail.python.org/mailman/listinfo/python-list
Re: python camera
Alex Gittens schrieb: I'm working on a final project for my EE degree that requires the use of digital camera with high resolution. I'd like to do the image capture with Python, preferably in a cross-platform manner, but if necessary, we can limit ourselves to Windows. Any ideas on modules/hardware for doing this? Under Linux, its just a matter of opening the video-device-file and reading the stream from the camera. Some ioctl-calls (module fcntl) may also be necessary to setup things correctly. Peter answered the question for windows. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Read from Serial Port
appropriate platform-specific code. I'll be happy to answer questions about the Posix parts of it, but I had the portion of my brain containing Win32 knowledge cauterized. I'm working on that. Last time I checked there was even some AMIGA pre-AGA-stuff in there. Which I actually think is cute, but could be filled with other more useful stuff. Any suggestions for a good cauterization service? SCNR, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: PyXML: SAX vs. DOM
Original Message From: Matthias Kaeppler [EMAIL PROTECTED] To: Subject: Re:PyXML: SAX vs. DOM Date: 20/1/2006 21:26 Oh and: Where can I find an API reference for PyXML? Am I supposed to /guess/ which methods and attributes e.g. Sax2 supplies? :D Thanks again, Matthias Matthias, your question is valid, and I just tell you how *I* do it... - the core of the methods in DOM are described by the W3C recommendations. I think the most relevant ones are: http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html where you can find all objects and methods that are defined by DOM Level 2 and, as far as I could see, all properly implemented by PyXML. The only caveat is that DOM2 defines the interface in abstract (more exactly, in IDL), and one has to know (or guess) how those are mapped onto Python. Having said that, by looking at the PyXML documentation: http://pyxml.sourceforge.net/topics/howto/ mainly http://pyxml.sourceforge.net/topics/howto/section-DOM.html one can do a very good educated guess so it is not sooo bad as it sounds. I know this is not the ideal answer, but maybe it helps... Ivan -- http://mail.python.org/mailman/listinfo/python-list
Re: Firefox bug in webbrowser module on Ubuntu?!
ncf This section is the cause of the problem: ncf for browser in (mozilla-firefox, mozilla-firebird, ncf mozilla, netscape): ncf if _iscommand(browser): ncf register(browser, None, Netscape(browser)) In SVN trunk (aka 2.5a0) this code is for browser in (mozilla-firefox, firefox, mozilla-firebird, firebird, mozilla, netscape): if _iscommand(browser): register(browser, None, Mozilla(browser)) where Mozilla == Netscape, so your proposed fix appears to be correct. (Which reminds me, I have a patch to webbrowser.py to test...) Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANNOUNCE] MyHDL 0.5 released
Jan Decaluwe wrote: Michael wrote: ... * http://article.gmane.org/gmane.comp.python.myhdl/19/match=mu0 One question I've got, mainly because it strikes me as very intriguing is do you know if the MU0 processor as described is synthesisable or have a feeling as to how much work would be needed for it to be synthesisable? This is a fairly old project (2003). At that time, MyHDL didn't yet have conversion to Verilog. After reviewing the code again, it's clear that it's written in RTL (register-transfer level) style. This means that the building blocks are combinatorial, or triggered on clock edges, closely reflecting an actual implementation. As it is, it's not convertible to Verilog (see the MyHDL manual for conversion constraints), but it's close. Thanks that's great to hear, and from something I find very interesting. To someone with some synthesis experience, it should be fairly straightforward to make the code synthesizable. I don't expect that this would make the code more verbose or less clear. I find that even more intersting :-) I've been watching your project grow over the past couple of years with great interest though little actual need at the moment, but for me seeing MU0 crop up piques my interest because that shows that MyHDL is getting up to a very interesting level. As your interest was apparently triggered by an example, this tells me that I should put more emphasis on publishing practical examples, as conversion to Verilog was already introduced some time ago (beginning of 2004). Practical examples are great, I'd seen that you'd introduced conversion to verilog some time back, but it wasn't clear how much was synthesisable. The example on the website seeing MU0 description made me really wonder. After all MU0 is used as a teaching example of how a very minimal CPU can be constructed. MU0 itself is not that interesting, but for me the fact MyHDL might be able to synthesise it *is* interesting. After all, synthesising such a beast (essentially) directly from python shows to me a very powerful example which can be built upon. Note also that by now, there are designers that use MyHDL in real projects, showing that you really can use it to go from Python to an FPGA (or ASIC). Moreover, with development tools such as Xilinx WebPack (now on Linux also) that start from Verilog, this can be done using a zero-cost development environment. Hmm... Very interesting :-) [different post] I believe it's meaningful because in my view digital hardware design can be regarded as just another specialized software engineering discipline. Of course, things have to be learned, but it's not more difficult than other application domains. I should add that this is not the mainstream view of the hardware design community :-) For what it's worth, I agree. I've had some limited experience with compilation to hardware in the past, specifically to asynchronous hardware, but given you write code that can include loops, conditionals and these can be translated to FPGA descriptions and then run this for me blurs the hardware/software distinction. A specific example that looks like software I'm thinking of is this: http://www.cs.man.ac.uk/fmethods/projects/AHV-PROJECT/node8.html (In particularly it's not really that different from Occam) Maybe I should continue this conversation on the MyHDL list, since I'd be interested in getting started in this in a simple way. (Mainly because my work project Kamaelia is designed, to an extent, with hardware constraints in mind. Implementing some Kamaelia components in MyHDL would be pretty cool. This might well be possible since we also use generators to model concurrency.) Best Regards, Michael. -- http://mail.python.org/mailman/listinfo/python-list
Re: Read from Serial Port
Grant Edwards wrote: On 2006-01-21, Casey Bralla [EMAIL PROTECTED] wrote: I'd like to use only standard built-in modules if possible. Then there aren't going to be any basic level docs because it's just not an easy thing to do. You pretty much have to do exactly what you would do in C. For Win32, you'll have to do all of the nasty Win32 CreateFile() calls and such-like. IMO, And given that win32all is *not* standard and built-in, at least with the standard distribution, you can't do Win32 at all if you insist on builtin modules. But doing so would be unreasonable, and fortunately the OP indicates that that's just his desire, not a firm requirement, so pyserial it is! :-) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Read from Serial Port
How about reading from the USB ports ?-- ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~Runsun Pan, PhD[EMAIL PROTECTED]Nat'l Center for Macromolecular Imaging http://ncmi.bcm.tmc.edu/ncmi/~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ -- http://mail.python.org/mailman/listinfo/python-list
Re: Returning a tuple-struct
On Thu, 18 Jan 2006 [EMAIL PROTECTED] wrote: Is there a better way? Thoughts? I was thinking along these lines: class NamedTuple(tuple): def __init__(self, indices, values): indices should be a map from name to index tuple.__init__(self, values) self.indices = indices def __getattr__(self, name): return self[self.indices[name]] colourNames = {red: 0, green: 1, blue:2} plum = NamedTuple(colourNames, (219, 55, 121)) The idea is that it's a tuple, but it has some metadata alongside (shared with other similarly-shaped tuples) which allows it to resolve names to indices - thus avoiding having two references to everything. However, if i try that, i get: Traceback (most recent call last): File stdin, line 1, in ? TypeError: tuple() takes at most 1 argument (2 given) As far as i can tell, inheriting from tuple is forcing my constructor to only take one argument. Is that the case? If so, anyone got any idea why? If i rewrite it like this: class NamedTuple(tuple): def __init__(self, values): tuple.__init__(self, values) def __getattr__(self, name): return self[self.indices[name]] class ColourTuple(NamedTuple): indices = {red: 0, green: 1, blue:2} plum = ColourTuple((219, 55, 121)) Then it works. This is even an arguably better style. Changing the constructor to take *values rather than values, and to validate the length of the value tuple against the length of the index tuple, would be good, but, since i'm lazy, is left as an exercise to the reader. tom -- Throwin' Lyle's liquor away is like pickin' a fight with a meat packing plant! -- Ray Smuckles -- http://mail.python.org/mailman/listinfo/python-list
Re: ValueError: need more than 3 values to unpack
Elezar Simeon Papo [EMAIL PROTECTED] wrote: SCHOOL, DEPART1, DEPART2, DEPART3 = line.split('\t') ValueError: need more than 3 values to unpack How do I solve this problem and change the program so it does not stop if a data record has less than three DEPART values. The problem is that when you unpack a sequence, you must have exactly the same number of variables as you have values. The idiom I use in a situation where I'm not sure how many values I've got in the sequence is: words = line.split('\t')+ 4 * [None] firstFourWords = words[0:3] SCHOOL, DEPART1, DEPART2, DEPART3 = firstFourWords The first line generates a list of words which is guaranteed to have at least 4 elements in it. The second line gets the first four of those words, and the last line unpacks them (in real life, I'd probably have combined the second and third lines, but I spread it out here for educational purposes). If line is HardKnocks\tFoo, you'll end up unpacking [HardKnocks, Foo, None, None]. Depending on your application, you may want to pad with empty strings instead of None. It would be convenient if string.split() took an optional 'minsplit' argument as well as a 'maxsplit'. Then you could have just done: school, dept1, dept2, dept3 = line.split ('\t', 4, 4) but, alas, it doesn't work that way. -- http://mail.python.org/mailman/listinfo/python-list
Re: Arithmetic sequences in Python
On Fri, 20 Jan 2006, it was written: [EMAIL PROTECTED] (Alex Martelli) writes: How would you make a one-element list, which we'd currently write as [3]? Would you have to say list((3,))? Yep. I don't particularly like the mandatory trailing comma in the tuple's display form, mind you, but, if it's good enough for tuples, and good enough for sets (how else would you make a one-element set?), If you really want to get rid of container literals, maybe the best way is with constructor functions whose interfaces are slightly different from the existing type-coercion functions: listx(1,2,3) = [1, 2, 3] listx(3) = [3] listx(listx(3)) = [[3]] dictx((a,b), (c,d)) = {a:b, c:d} setx(a,b,c) = Set((a,b,c)) listx/dictx/setx would be the display forms as well as the constructor forms. Could these even replace the current forms? If you want the equivalent of list(sometuple), write list(*sometuple). With a bit of cleverness down in the worky bits, this could be implemented to avoid the apparent overhead of unpacking and then repacking the tuple. In fact, in general, it would be nice if code like: def f(*args): fondle(args) foo = (1, 2, 3) f(*foo) Would avoid the unpack/repack. The problem is that you then can't easily do something like: mytable = ((1, 2, 3), (a, b, c), (Tone.do, Tone.re, Tone.mi)) mysecondtable = map(list, mytable) Although that's moderately easy to work around with possibly the most abstract higher-order-function i've ever written: def star(f): def starred_f(args): return f(*args) return starred_f Which lets us write: mysecondtable = map(star(list), mytable) While we're here, we should also have the natural complement of star, its evil mirror universe twin: def bearded_star(f): def bearded_starred_f(*args): return f(args) return bearded_starred_f Better names (eg unpacking and packing) would obviously be needed. tom -- I might feel irresponsible if you couldn't go almost anywhere and see naked, aggressive political maneuvers in iteration, marinating in your ideology of choice. That's simply not the case. -- Tycho Brahae -- http://mail.python.org/mailman/listinfo/python-list
Re: Numarray, numeric, NumPy, scpy_core ??!!
J wrote: Hi I hope the title of this message indicates my question. I am looking for basic array functionality in Python and it turns out that there are all these packages which are somehow related. Some are allegedly discontinued but still seem to get updated. Could we start a discussion about which package will or may or should survive ? I started to use numarray, but I have a bug that I just cannot find a solution for, so I started to look around again. Basically I want to provide scripting support to a graphics engine. All the matrices and vectors are in C++ and all I want to do is provide an interface to python. As a matter of fact, all of the matrix multiplication etc, could remain in the native C++ code, but I need a way to extend the python language with the array data type and somehow intercept operator calls such as *,+,- How is that done in the current libraries... Thx for any help. Cheers Jochen numarray was intended to replace Numeric. numarray is stable and performs reaonably well. If you have a specific problem, you might post a problem report to: [EMAIL PROTECTED] You can also subscribe to the list. numpy is intended to perform better and is close to a production release. Colin W, -- http://mail.python.org/mailman/listinfo/python-list
Re: PyXML: SAX vs. DOM
Ivan Herman wrote: I know this is not the ideal answer, but maybe it helps... It does, thanks Ivan. Regards, Matthias -- http://mail.python.org/mailman/listinfo/python-list
[Python for .NET] Any plans for supporting CLR2.0?
I'm on .NET/CLR2.0 and would like to use some stuff from w/i Python. The Python for .NET file name suggests that CLR1.1 is needed. Is that right? Any known plans to change this? Kind regards Franz GEIGER -- http://mail.python.org/mailman/listinfo/python-list
Re: Decimal vs float
[Kay Schluehr] I concur and I wonder why CAS like e.g. Maple that represent floating point numbers using two integers [1] are neither awkward to use nor inefficient. My guess is that it's because you never timed the difference in Maple -- or, perhaps, that you did, but misinterpreted the results. You don't give any data, so it's hard to guess which. BTW, why do you think Maple's developers added the UseHardwareFloats option? According to the Python numeric experts one has to pay a high tradeoff between speed and accuracy. But as it seems it just compares two Python implementations ( float / decimal ) and does not compare those to approaches in other scientific computing systems. It's easy to find papers comparing the speed of HW and SW floating point in Maple. Have you done that, Kay? For example, read: Symbolic and Numeric Scientific Computation in Maple K.O. Geddes, H.Q. Le http://www.scg.uwaterloo.ca/~kogeddes/papers/ICAAA02.ps Keith Geddes is a key figure in Maple's history and development, and can hardly be accused of being a Python apologist ;-) Note that Example 1.5 there shows a _factor_ of 47 speed gain from using HW instead of SW floats in Maple, when solving a reasonably large system of linear equations. So I'll ask again ;-): why do you think Maple's developers added the UseHardwareFloats option? While that paper mentions the facility only briefly, Geddes and Zheng give detailed analyses of the tradeoffs in Maple here: Exploiting Fast Hardware Floating Point in High Precision Computation http://www.scg.uwaterloo.ca/~kogeddes/papers/TR200241.ps If you're uncomfortable reading technical papers, one bottom line is that they show that the time required by Maple to do a floating-point multiplication in software is at least 1000 times larger than doing the same with UseHardwareFloats set to true (and Digits:=15 in both cases). By the way one can also learn from Maple how accuracy can be adjusted practically. I never heard users complaining about that. It's easy to change the number of digits of precision in Python's decimal module. ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Simultaneous connections
datbenik schrieb: How can i write a program that supports simultaneous multipart download. So i want to open multiple connections to download one file. Is this possible. If so, how? In case of HTTP, the needed header is Range. So I guess its all a matter of making n connections, and specifying total_size/n consecutive ranges in each request. But be aware that the range is possibly nor supported - no idea how that is communicated. Googling reveals this: http://linux.duke.edu/projects/urlgrabber/ Use that, or look at it and reprogram it accordingly. Diez -- http://mail.python.org/mailman/listinfo/python-list
Dynamic website content
Basically I have written a cgi script to automatically download TIFF images of patents from the US patent office. What I want is that the user can see what is happening when the images are being downloaded, because it takes a while to download them and there can be anything up to 30 individual files for each image. Is there a way of using Python or any other means, that I could it could print on the webpage: Downloading image 1 Downloading image 2 ... Downloading image X as the individual pictures are being downloaded so the user doesn't think the program is hanging? -- http://mail.python.org/mailman/listinfo/python-list
Re: Dynamic website content
sophie_newbie schrieb: Basically I have written a cgi script to automatically download TIFF images of patents from the US patent office. What I want is that the user can see what is happening when the images are being downloaded, because it takes a while to download them and there can be anything up to 30 individual files for each image. Is there a way of using Python or any other means, that I could it could print on the webpage: Downloading image 1 Downloading image 2 ... Downloading image X as the individual pictures are being downloaded so the user doesn't think the program is hanging? Why? In my browser, if I download a file, the browser itself shows a nice progress-bar. I guess what you are after is a way to trigger a download while the current page is displayed in the browser. Looking at sf, one can see that the header of the site explaining to you that your download now starts contains this: meta http-equiv=refresh content=5; URL=http://peterhost.dl.sourceforge.net/sourceforge/winavr/WinAVR-20050214-install.exe; / That means that 5 seconds later, the URL is fetched. As the type is neither image nor HTML, the browser will download it. In conclusion, it should even suffice to just let the user click that link itself. Then the browser should start downloading that image of yours. Regards, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Numarray, numeric, NumPy, scpy_core ??!!
Ok, I will look at NumPy ... I have another question about performance. Are the array operations such as matrix multiplication implemented in python or in C ? I was under the impression that the function calls in numarray are only wrappers to C code, but now I suspect that matrix multiplicaiton is implemented in python and executed in the interpreter. Is that true ? Can someone also please point me to examples of how I could make my own array classes. Basically all I need is vectors and 3x3 matrices. I already have all of the multiplication code in my C++ classes and only need wrappers. But how can I create an array class and intercept operators calls like * + -. This is not neccessarily a solution that I want to follow, but it may be what I have to do for now. BTW, here is also the problem I have with a numarray. I have created a vector like so... mPyObject = PyArray_FromDimsAndData(GeoVec4f::sD,GeoVec4f::sDim, PyArray_FLOAT,(char*)mValue.mValues); Py_INCREF(mPyObject); The PyObject is then used as a member called gradient in another embedded class. When I execute the following script x.gradient*3 my app just crashes. But when I execute print (x.gradient) x.gradient*3 everything works fine... I assum there must be some kind of reference count problem... Cheers Jochen -- http://mail.python.org/mailman/listinfo/python-list
Re: Numarray, numeric, NumPy, scpy_core ??!!
J wrote: Ok, I will look at NumPy ... I have another question about performance. Are the array operations such as matrix multiplication implemented in python or in C ? I was under the impression that the function calls in numarray are only wrappers to C code, but now I suspect that matrix multiplicaiton is implemented in python and executed in the interpreter. Is that true ? No, not at all. In fact, if an optimized BLAS is available on your system, you can make numpy (or numarray or Numeric) use that to do your matrix multiplications much faster. Can someone also please point me to examples of how I could make my own array classes. Basically all I need is vectors and 3x3 matrices. I already have all of the multiplication code in my C++ classes and only need wrappers. But how can I create an array class and intercept operators calls like * + -. This is not neccessarily a solution that I want to follow, but it may be what I have to do for now. It's a difficult problem, since you have to overload nearly every operation in order to return arrays of your subclass, not the basic array class. numpy has a new mechanism to try to alleviate this. You should look at the matrix subclass in numpy/core/defmatrix.py . -- Robert Kern [EMAIL PROTECTED] In the fields of hell where the grass grows high Are the graves of dreams allowed to die. -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list
Error in Python documentation
I found a minor error in the Python documentation for 2.4 which I thought I would report. But after a while I gave up. I wonder if this sort of reporting which is less than a bug could be made easier? The error was that the index entry to 'print statement' sent me to http://www.python.org/doc/2.4.2/lib/types.html#l2h-90. From the point of view of making Python accessible this sort of typo should be easily reportable. -- http://mail.python.org/mailman/listinfo/python-list
Re: Error in Python documentation
peter I found a minor error in the Python documentation for 2.4 which I peter thought I would report. But after a while I gave up. I wonder if peter this sort of reporting which is less than a bug could be made peter easier? The error was that the index entry to 'print statement' peter sent me to http://www.python.org/doc/2.4.2/lib/types.html#l2h-90. peter From the point of view of making Python accessible this sort of peter typo should be easily reportable. You can always report documentation problems to [EMAIL PROTECTED] I'll submit a bug report. A quick glance didn't locate the source of the problem. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Dynamic website content
To give you a better explaination of what I want, you could visit www.pat2pdf.org. Type in 123456 as the patent number, you see what it does? It tells the user that it is requesting the various TIFF images and then displays the link to the PDF file that it has created. This is exactly what I want to do, so if anyone has any idea how it is done I would be greatful. I'm not asking how to get the TIFF files of create the PDF etc, that is grand, just how it updates the screen with its progress like that... -- http://mail.python.org/mailman/listinfo/python-list
Re: Numarray, numeric, NumPy, scpy_core ??!!
I will just jump in an use NumPy. I hope this one will stick and evolve into the mother of array packages. How stable is it ? For now I really just need basic linear algebra. i.e. matrix multiplication, dot, cross etc Cheers -- http://mail.python.org/mailman/listinfo/python-list
Re: Error in Python documentation
From http://www.python.org/doc/2.4.2/ go to the Library reference http://www.python.org/doc/2.4.2/lib/lib.html from there to the index (i) at http://www.python.org/doc/2.4.2/lib/genindex.html. In the index select 'p' and click to reach http://www.python.org/doc/2.4.2/lib/types.html#l2h-90 . At the foot of this page is a link: See About this document... for information on suggesting changes. which if you follow takes you to http://www.python.org/doc/2.4.2/lib/about.html where there is: If you find specific errors in this document, either in the content or the presentation, please report the bug at the Python Bug Tracker at SourceForge. So you need to add a bug to the Python bug tracker -- at least so it seems. Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: excellent book on information theory
Anton Vredegoor [EMAIL PROTECTED] writes: And so the cycle repeats itself. We teach our students the world is all about money, and sure enough, the world is all about money. If we would continue to keep the interesting things away from most of the people, by hiding it behind mathematical jargon we end up believing that functional programming is connected to having a math degree and more such self serving and self fullfilling prophecies. I don't think a math degree is needed to read that book, but you do need to know some basic calculus and probability. Maybe also some abstract algebra since error correcting codes generally involve finite field arithmetic. The book doesn't cover those subjects starting from scratch. I don't think it can reasonably be expected to do so. But it's less math-intensive than most books I've looked at about digital signal processing, for example. Perhaps it could be improved by being more explicit about what the reader needs to know, and giving references to other books where the prerequisites can be found. I also don't think presenting the math in Python would make things any easier conceptually. The math in Sussman and Wisdom's Structure and Interpretation of Classical Mechanics is all presented in Scheme, but it's still the same math that's normally presented as equations, and you have to think just as hard to understand it. Math is a beautiful subject, and is not at all secret or inaccessible. Try to broaden your horizons a bit ;-). -- http://mail.python.org/mailman/listinfo/python-list
Re: Arithmetic sequences in Python
Tom Anderson [EMAIL PROTECTED] writes: listx/dictx/setx would be the display forms as well as the constructor forms. Could these even replace the current forms? If you want the equivalent of list(sometuple), write list(*sometuple). The current list function is supposed to be something like a typecast: list() = [] xlist() = [] # ok list(list()) = [] # casting a list to a list does nothing xlist(xlist()) = [[]] # make a new list, not the same list(xrange(4)) = [0,1,2,3] xlist(xrange(4)) = [xrange(4)] # not the same list((1,2)) = [1,2] xlist((1,2)) = [(1,2)] etc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Numarray, numeric, NumPy, scpy_core ??!!
J wrote: I will just jump in an use NumPy. I hope this one will stick and evolve into the mother of array packages. How stable is it ? For now I really just need basic linear algebra. i.e. matrix multiplication, dot, cross etc That stuff isn't going to change on you. -- Robert Kern [EMAIL PROTECTED] In the fields of hell where the grass grows high Are the graves of dreams allowed to die. -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list
Re: Numarray, numeric, NumPy, scpy_core ??!!
J wrote: I will just jump in an use NumPy. I hope this one will stick and evolve into the mother of array packages. How stable is it ? For now I really just need basic linear algebra. i.e. matrix multiplication, dot, cross etc There is a new release coming out this weekend. It's closer to 1.0 and so should be more stable.It also has some speed improvements in matrix-vector operations (if you have ATLAS BLAS --- or if you download a binary version with ATLAS BLAS compiled in). I would wait for it. -Travis -- http://mail.python.org/mailman/listinfo/python-list
Re: Arithmetic sequences in Python
On Sat, 21 Jan 2006, it was written: Tom Anderson [EMAIL PROTECTED] writes: listx/dictx/setx would be the display forms as well as the constructor forms. Could these even replace the current forms? If you want the equivalent of list(sometuple), write list(*sometuple). The current list function is supposed to be something like a typecast: A what? ;-| list() = [] xlist() = [] # ok list(list()) = [] # casting a list to a list does nothing xlist(xlist()) = [[]] # make a new list, not the same list(xrange(4)) = [0,1,2,3] xlist(xrange(4)) = [xrange(4)] # not the same list((1,2)) = [1,2] xlist((1,2)) = [(1,2)] True, but so what? Is it that it has to be that way, or is it just that it happens to be that way now? tom -- It's the 21st century, man - we rue _minutes_. -- Benjamin Rosenbaum -- http://mail.python.org/mailman/listinfo/python-list
Re: Dynamic website content
sophie_newbie schrieb: To give you a better explaination of what I want, you could visit www.pat2pdf.org. Type in 123456 as the patent number, you see what it does? It tells the user that it is requesting the various TIFF images and then displays the link to the PDF file that it has created. This is exactly what I want to do, so if anyone has any idea how it is done I would be greatful. I'm not asking how to get the TIFF files of create the PDF etc, that is grand, just how it updates the screen with its progress like that... It seems that they just fetch the tiff and then write Fetched %ibr/\n into the page. The important thing then is to flush the stdout, so that the data is actually transmitted over the network. And I guess you have to provide a header that accounts for the number of bytes you want to write (the total bytes of the html-page that is), by specifying something equals or maybe greater than the overall page. Regards, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Numarray, numeric, NumPy, scpy_core ??!!
On Sat, 21 Jan 2006, Travis E. Oliphant wrote: J wrote: I will just jump in an use NumPy. I hope this one will stick and evolve into the mother of array packages. How stable is it ? For now I really just need basic linear algebra. i.e. matrix multiplication, dot, cross etc There is a new release coming out this weekend. It's closer to 1.0 and so should be more stable. It also has some speed improvements in matrix-vector operations (if you have ATLAS BLAS --- or if you download a binary version with ATLAS BLAS compiled in). I would wait for it. Pardon my failure to RTFM, but does NumPy pick up the vecLib BLAS on Macs? tom -- It's the 21st century, man - we rue _minutes_. -- Benjamin Rosenbaum -- http://mail.python.org/mailman/listinfo/python-list
Re: Dynamic website content
On Saturday 21 January 2006 20:42, sophie_newbie wrote: To give you a better explaination of what I want, you could visit www.pat2pdf.org. Type in 123456 as the patent number, you see what it does? It tells the user that it is requesting the various TIFF images and then displays the link to the PDF file that it has created. Ah, so you are trying to get the page displayed while your CGI is still running? Try flushing stdout after you print something. Otherwise the output will only be sent when the CGI ends or the buffer is full. Kindly Christoph -- Never trust a system administrator who wears a tie and suit. -- http://mail.python.org/mailman/listinfo/python-list
The real name
I'm playing with a sudoku GUI...just to learn more about python. I've made 81 'cells'...actually small canvases Part of my scheme to write the cells (all 81 of them in the gui) to a file (using the the SAVE callback/button), then restore the gui cells from the contents of the saved file, which depends on knowing the name of the cell with the focus, or one (or more) which have a number. The print shows .9919624.9990312, but this nunber (name?) does not work in: cell-name of cell-.create_text(18,18, text = somevar, fill = 'blue' , font = ('arial', 18, 'bold')) Also, how can I declare a variable outside of the mainloop/callback scheme which would be 'known' to the callbacks? Thanks, Norm -- http://mail.python.org/mailman/listinfo/python-list
Regular expressions: recursive patterns and callouts
Hi! I think two extensions to re could be really powerful in aiding to match non regular strings -for example those containing parens nested up to an arbitrary depth- but without a significative performance loss, although I'm not at all sure at this last point. One of these features is re nesting; I don't mean nesting some strings and then compiling the composed re, but to include -possibly recursive- references to other re's. The second feature is the ability to add callout points in a re, so external functions would be called when the matcher reaches those points to validate the current matched prefix or even to do some arbitrary further matching of its own, advancing the pattern position. pcre implements similar features with its (?CN) callout and (?N) recursive patterns mechanisms. Are the above or equivalent features planned for future python releases? Do you know of some extension package which provide them or at least pcre compatible res? Thank you in advance, Carlos -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: excellent book on information theory
Slow and to the pointless, but ... On Wed, 18 Jan 2006, Terry Hancock wrote: On Mon, 16 Jan 2006 12:15:25 -0500 Tim Peters [EMAIL PROTECTED] wrote: More Britishisms are surviving in the Scholastic editions as the series goes on, but as the list for Half-Blood Prince shows the editors still make an amazing number of seemingly pointless changes: like: UK:Harry smiled vaguely back US:Harry smiled back vaguely I know you are pointing out the triviality of this, since both US and UK English allow either placement -- but is it really preferred style in the UK to put the adverb right before the verb? For the meaning which i assume is meant here, no, i wouldn't have said so. In US English, the end of the clause (or the beginning) is probably more common. Same in British English (or at least, English English). As Dave Hansen pointed out, Harry smiled vaguely back, means that the direction Harry was smiling was vaguely back - might have been a bit to the side or something. This actually gets back on topic ( ;-) ), because it might affect the localization of a Python interactive fiction module I'm working on -- it's a GUI to generate sentences that are comprehensible to the IF engine. My guess would be that you're going to need something far more powerful than a localisation engine for this. en_US: Sally, gently put flower in basket vs en_UK: Sally, put flower in basket gently That example isn't as bad as the Rowling one (although the lack of articles is a bit odd); i think i'd only use the latter form if i wanted to put particular emphasis on the 'gently', particularly if it was as a modified repetition of a previous sentence: Instructor: Sally, put a flower in the basket. [Sally roughly puts the flower in the basket, crushing it] Instructor: Sally, put a flower in the basket *gently*. Your second construction isn't the equivalent of the Rowling sentence, though, where the adverb goes right after the verb; that would make it Sally, put gently the flower in the basket, which would be completely awful. Or maybe it would be Sally, put the flower gently in the basket, which would be fine, although a bit dated - has an admittedly euphonious 1950s BBC English feel to it. tom -- It's the 21st century, man - we rue _minutes_. -- Benjamin Rosenbaum -- http://mail.python.org/mailman/listinfo/python-list
Re: Numarray, numeric, NumPy, scpy_core ??!!
Tom Anderson wrote: Pardon my failure to RTFM, but does NumPy pick up the vecLib BLAS on Macs? Yes. -- Robert Kern [EMAIL PROTECTED] In the fields of hell where the grass grows high Are the graves of dreams allowed to die. -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list
Re: Dynamic website content
Christoph Haas [EMAIL PROTECTED] wrote: On Saturday 21 January 2006 20:42, sophie_newbie wrote: To give you a better explaination of what I want, you could visit www.pat2pdf.org. Type in 123456 as the patent number, you see what it does? It tells the user that it is requesting the various TIFF images and then displays the link to the PDF file that it has created. Ah, so you are trying to get the page displayed while your CGI is still running? Try flushing stdout after you print something. Otherwise the output will only be sent when the CGI ends or the buffer is full. ...unless you run Python with the -u option, which makes output unbuffered (and, if on Windows where it matters, binary). However, it's not sufficient to ensure the user's browser will show the messages you want when you want. A much more reliable way to achieve that is to use timed redirects, or an AJAX (Javascript-based) solution. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: The real name
Part of my scheme to write the cells (all 81 of them in the gui) to a file (using the the SAVE callback/button), then restore the gui cells from the contents of the saved file, which depends on knowing the name of the cell with the focus, or one (or more) which have a number. The print shows .9919624.9990312, but this nunber (name?) does not work in: cell-name of cell-.create_text(18,18, text = somevar, fill = 'blue' , font = ('arial', 18, 'bold')) I'm not entirely sure what you are after here. To me it sounds better to create names like cell%i % row * column just for the sake of having different names, but store the cell in a 2-dimensional list called e.g. cells Then accessing the cell at x, y is simply cells[x][y].create_text(...) Does that make sense to you? Also, how can I declare a variable outside of the mainloop/callback scheme which would be 'known' to the callbacks? You can of course go for globals. Beside that, a callback can be anything callable. That means that you can go for something like this: class StatefulCallable(obkect): def __init__(self, some_state): self.state = some_state def __call__(self, *args): # I'm not sure what comes with the callback print called with args %r and state %r % (args, self.state) Then pass an instance of StatefulCallable as callback. Regards, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Error in Python documentation
... [much page traversal deleted] ... peter So you need to add a bug to the Python bug tracker -- at least so peter it seems. If you go to the top of the doc tree: http://docs.python.org/ and look in the left-hand sidebar you'll see [EMAIL PROTECTED] under the heading Email Us. -- http://mail.python.org/mailman/listinfo/python-list
Re: The real name
[EMAIL PROTECTED] wrote: I'm playing with a sudoku GUI...just to learn more about python. I've made 81 'cells'...actually small canvases Part of my scheme to write the cells (all 81 of them in the gui) to a file (using the the SAVE callback/button), then restore the gui cells from the contents of the saved file, which depends on knowing the name of the cell with the focus, or one (or more) which have a number. The print shows .9919624.9990312, but this nunber (name?) does not work in: cell-name of cell-.create_text(18,18, text = somevar, fill = 'blue' , font = ('arial', 18, 'bold')) Also, how can I declare a variable outside of the mainloop/callback scheme which would be 'known' to the callbacks? Thanks, Norm How about using a dict, something like (untested): cells = {} for row in range(1, 10): . for column in range(1, 10): . cells[(row, column)] = canvas() # or whatever you use to create a canvas Then, to put a value in a given cell, you simply to cell[(row, column)].create_text(...) André -- http://mail.python.org/mailman/listinfo/python-list
Compiling cx_Oracle and LD_LIBRARY_PATH
I can compile and install cx_Oracle fine by following the manta: export ORACLE_HOME=... python setup.py install export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH python import cx_Oracle My issue is the LD_LIBRARY_PATH. Is there a way to compile cx_Oracle, or any Python extension for that matter so that it's not required to set LD_LIBRARY_PATH? Is there a way I can make distutils do this for me? Thanks, Brian Cole -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiling cx_Oracle and LD_LIBRARY_PATH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Brian Cole wrote: I can compile and install cx_Oracle fine by following the manta: export ORACLE_HOME=... python setup.py install export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH python import cx_Oracle My issue is the LD_LIBRARY_PATH. Is there a way to compile cx_Oracle, or any Python extension for that matter so that it's not required to set LD_LIBRARY_PATH? Is there a way I can make distutils do this for me? Set runtime_library_dirs to a list of library directories you want to search at runtime in your setup.py. Check http://cvs.sourceforge.net/viewcvs.py/pypgsql/pypgsql/setup.py?rev=1.25view=auto for an example. HTH, - -- Gerhard -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFD0rQ5dIO4ozGCH14RAguJAJ9KW7g9pTP/co63Jn5DNF+GN4IMvgCeOYic a3yQm+oOdsiepvICBLQFt2A= =KeLY -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: The real name
[EMAIL PROTECTED] wrote: I'm playing with a sudoku GUI...just to learn more about python. I've made 81 'cells'...actually small canvases Part of my scheme to write the cells (all 81 of them in the gui) to a file (using the the SAVE callback/button), then restore the gui cells from the contents of the saved file, which depends on knowing the name of the cell with the focus, or one (or more) which have a number. The print shows .9919624.9990312, but this nunber (name?) does not work in: cell-name of cell-.create_text(18,18, text = somevar, fill = 'blue' , font = ('arial', 18, 'bold')) Also, how can I declare a variable outside of the mainloop/callback scheme which would be 'known' to the callbacks? Thanks, Norm I guess you are using tkinter. .9919624.9990312 in tkinter is just a string representation of the underlying object, in this case a Canvas(). It is not up to a python programmer to understand exactly what these numbers are. They are used by Tcl/Tk internally. Tk objects are not pickleable. Better is to create a datastructure that can be pickled from info gleaned specifically with the itemcget() method. Example code is below. See the Pickle/cPickle documentation. They are very easy to use. Since you haven't posted any code, I can only guess what you are doing. But you may want to try variations on the following (read the comments): from Tkinter import * # This is how you may want to make a bunch of canvases in a grid. def make_canvases(parent, rows=9, cols=9, **options): Pass in rows, cols, and any options the canvases should require. cells = [] for i in xrange(rows): arow = [] for j in xrange(cols): c = Canvas(parent, **options) c.grid(row=i, column=j) arow.append(c) cells.append(arow) return cells def demo(): Tests out our make_canvases() function. # tkinter stuff--setting up tk = Tk() f = Frame(tk) f.pack(expand=YES, fill=BOTH) # make the canvases the gui-programmer way canvases = make_canvases(f, height=25, width=25) # individual access to canvases (remember that indices start at 0) canvases[0][0].configure(background='orange') canvases[7][8].create_text(14, 8, text='Bob', fill='blue', font=('arial', 14, 'bold')) canvases[8][8].create_text(14, 8, text='9,9', fill='blue', font=('arial', 14, 'bold')) # accessing inside loops for i in xrange(9): canvases[i][8-i].configure(background='red') # fun with bindings (see your last question) # you should study this one! for i in xrange(9): for j in xrange(9): c = canvases[i][j] c.bind(Button-1, lambda e=None, c=c: c.configure(background='green')) # getting out info texts = [] for i in xrange(9): for j in xrange(9): c = canvases[i][j] for t in c.find_all(): try: text = c.itemcget(t, 'text') texts.append((i,j,text)) except: pass # reporting the got-out info Label(tk, text=Texts are: %s % texts).pack(expand=YES, fill=X) tk.mainloop() demo() -- http://mail.python.org/mailman/listinfo/python-list
Embedding matplotlib into page GUI builder
After a successful but problematic experience with the QT Designer + python combo, I decided that I needed something simpler (read completely in python) for my lab applications with python linux-gpib bindings. I am looking at PAGE, which while not pretty, seems simple and fast to work with. How do I embed a realtime graphic o/p from matplotlib into this GUI builder ? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Read from Serial Port
On 2006-01-21, Diez B. Roggisch [EMAIL PROTECTED] wrote: appropriate platform-specific code. I'll be happy to answer questions about the Posix parts of it, but I had the portion of my brain containing Win32 knowledge cauterized. I'm working on that. Last time I checked there was even some AMIGA pre-AGA-stuff in there. Which I actually think is cute, but could be filled with other more useful stuff. Any suggestions for a good cauterization service? Yea, um, hmm. Don't remember that either. Sloppy work then, eh? Just as well. -- Grant Edwards grante Yow! ... A housewife at is wearing a polypyrene visi.comjumpsuit!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables and none?
Steve Holden [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Ivan Shevanski wrote: python way to detect if a variable exsists? Say I had a program that needed a certain variable to be set to run and the variable was not found when it came time to use it. . .Would I just have to catch the error, or could I have python look for the variable beforehand? The usual way to do this is to catch the error. If you can access the namespace of interest (say it's an instance of some class) then you can use hasattr() to answer the question, but catching the exception is the generic way to do it. According to what I recently read, hasattr is purely syntactic sugar. It answers that question by invoking gettattr in the C equivalent of a try clause. def hasattr(ob, name): # this and below untested try: getattr(ob,name) return True except AttributeError: return False So if the attribute exists, it is retrieved twice -- the first time to tell the caller that it is okay to get it again the second time. Perhaps we should have hasgetattr(ob, name): def hasgetattr(ob, name): try: return True, getattr(ob, name) except AttributeError: return False, None This could be used like so: has,val = hasgetattr(ob, attr) if has: code using val Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python for .NET] Any plans for supporting CLR2.0?
F. GEIGER [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm on .NET/CLR2.0 and would like to use some stuff from w/i Python. The Python for .NET file name suggests that CLR1.1 is needed. Is that right? Any known plans to change this? Most responders here use CPython. The IronPython users mailing list, mirrored as gmane.comp.python.ironpython.users (see gmane.org) would more likely give you an authoritative answer. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: excellent book on information theory
On Sat, 21 Jan 2006 21:01:53 +, Tom Anderson wrote: As Dave Hansen pointed out, Harry smiled vaguely back, means that the direction Harry was smiling was vaguely back - might have been a bit to the side or something. That's an extremely artificial interpretation of the sentence, even if it is grammatically possible. Who talks about smiling in a physical direction? Does anyone ever say He smiled forward or She smiled north-by-north-east or She smiled to the side? The only thing even close to what you're talking about is He smiled out of the corner (or side) of his mouth -- not the same thing at all. Smiled vaguely back is a clumsy construction, and any decent editor should change it to smiled back vaguely regardless of whether they are from the US or UK. But clumsy or not, you're really pushing the envelope to get the interpretation that he smiled in a direction which was vaguely back. Yes, the sentence He smiled vaguely back is grammatically ambiguous, but semantically can have only one meaning: he returned a smile, but his smile was vague. He vaguely smiled back suffers the same fate. It too can imply that the smile was vague, or that the smile was only vaguely in return. Both interpretations are grammatically possible, but the second is semantically dubious. A good editor from any country is supposed to weed out clumsy, confusing sentences like that, and replace them with the grammatically unambiguous equivalent he smiled back vaguely. This isn't a localisation issue, it is a command of language issue. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: The real name
On Sat, 21 Jan 2006 14:23:49 -0800, James Stroud [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I'm playing with a sudoku GUI...just to learn more about python. I've made 81 'cells'...actually small canvases Part of my scheme to write the cells (all 81 of them in the gui) to a file (using the the SAVE callback/button), then restore the gui cells from the contents of the saved file, which depends on knowing the name of the cell with the focus, or one (or more) which have a number. The print shows .9919624.9990312, but this nunber (name?) does not work in: cell-name of cell-.create_text(18,18, text = somevar, fill = 'blue' , font = ('arial', 18, 'bold')) Also, how can I declare a variable outside of the mainloop/callback scheme which would be 'known' to the callbacks? Thanks, Norm I guess you are using tkinter. .9919624.9990312 in tkinter is just a string representation of the underlying object, in this case a Canvas(). It is not up to a python programmer to understand exactly what these numbers are. They are used by Tcl/Tk internally. Tk objects are not pickleable. Better is to create a datastructure that can be pickled from info gleaned specifically with the itemcget() method. Example code is below. See the Pickle/cPickle documentation. They are very easy to use. Since you haven't posted any code, I can only guess what you are doing. But you may want to try variations on the following (read the comments): from Tkinter import * # This is how you may want to make a bunch of canvases in a grid. def make_canvases(parent, rows=9, cols=9, **options): Pass in rows, cols, and any options the canvases should require. cells = [] for i in xrange(rows): arow = [] for j in xrange(cols): c = Canvas(parent, **options) c.grid(row=i, column=j) arow.append(c) cells.append(arow) return cells def demo(): Tests out our make_canvases() function. # tkinter stuff--setting up tk = Tk() f = Frame(tk) f.pack(expand=YES, fill=BOTH) # make the canvases the gui-programmer way canvases = make_canvases(f, height=25, width=25) # individual access to canvases (remember that indices start at 0) canvases[0][0].configure(background='orange') canvases[7][8].create_text(14, 8, text='Bob', fill='blue', font=('arial', 14, 'bold')) canvases[8][8].create_text(14, 8, text='9,9', fill='blue', font=('arial', 14, 'bold')) # accessing inside loops for i in xrange(9): canvases[i][8-i].configure(background='red') # fun with bindings (see your last question) # you should study this one! for i in xrange(9): for j in xrange(9): c = canvases[i][j] c.bind(Button-1, lambda e=None, c=c: c.configure(background='green')) # getting out info texts = [] for i in xrange(9): for j in xrange(9): c = canvases[i][j] for t in c.find_all(): try: text = c.itemcget(t, 'text') texts.append((i,j,text)) except: pass # reporting the got-out info Label(tk, text=Texts are: %s % texts).pack(expand=YES, fill=X) tk.mainloop() demo() Thanks for your reply, and those of others...all are helpful. As to the code I wrote (so far), her it is, complete with some expressions that didn't work too well...:) ThanksNorm # Start GUI CODE == from Tkinter import * import tkFileDialog fred = Tk()# Notice I have a bias against 'top', 'master', 'root', etc fred.title('SUDOKU SCREEN') #fred.geometry('400x400') #fred.resizable(0,0) #-- Declare 9 frames plus one for the buttons fr1 = Frame(fred); fr2 = Frame(fred); fr3 = Frame(fred) fr4 = Frame(fred); fr5 = Frame(fred); fr6 = Frame(fred) fr7 = Frame(fred); fr8 = Frame(fred); fr9 = Frame(fred) bfr = Frame(fred, relief = 'raised', borderwidth = 1, pady = 10) #-- Set some vars ind = [3,4,5,12,13,14,21,22,23,27,28,29,33,34,35,36,37,38,42,43,44,45,46,47,51,52,53,57,58,59,66,67,68,75,76,77] fr_list = [fr1,fr2,fr3,fr4,fr5,fr6,fr7,fr8,fr9] can_list = ['can1','can2','can3','can4','can5','can6','can7','can8','can9'] cell = [] myvar = '' mykey = 'K' myadd = 'one' iy = 0 #-- Create 9 frames with 9 canvases in each for fitem in fr_list: for item in can_list: item = Canvas(fitem, width = 30, height = 30, borderwidth = 1, relief = 'solid') item.pack(side = LEFT, fill = BOTH) cell.append([item, iy, '-']) # List of [IDs, 0 to 80, key text] iy += 1 #-- Create some supporting (callback) functions def clr_scrn(): for iz in range(81): cell[iz][0].delete(ALL) def hint(): print 'Hint not implemented yet' def solve(): print 'Solve not implemented yet'
Re: New Python.org website ?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Steve Holden wrote: Tim Golden wrote: [Steve Holden] | https://svn.python.org/www/trunk/beta.python.org | but I don't know whether anonymous access is enabled. Maybe you can let |me know ... Doesn't look like it. Asking me for authentication. I've finally gotten to install pyramid and build the very small and outdated subset of the beta pydotorg site. Obviously, I'd like to have access to the real data in the python.org SVN. Rats, thanks for letting me know. As a first step I'd like to open up anonymous access to both the content and the site generation software, so that people can experiment with local content generation. Then once someone knows how to use the system they can get a login for the SVN system and start editing site content. I'll get back to the list with instructions ASAP. It may take a while due to inter-continental time differences and general overwork. Are you still on it? I'd be happy enough with any kind of readonly access for myself for now. Thanks, - -- Gerhard -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFD0skhdIO4ozGCH14RArdeAKCvolij/RdlCR+2f95usNaMAU5GKgCeOW2U 2OuazmveIIuaTpgJNSh4xOc= =IgFW -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: The real name
[EMAIL PROTECTED] wrote: On Sat, 21 Jan 2006 14:23:49 -0800, James Stroud [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I'm playing with a sudoku GUI...just to learn more about python. I've made 81 'cells'...actually small canvases Part of my scheme to write the cells (all 81 of them in the gui) to a file (using the the SAVE callback/button), then restore the gui cells from the contents of the saved file, which depends on knowing the name of the cell with the focus, or one (or more) which have a number. The print shows .9919624.9990312, but this nunber (name?) does not work in: cell-name of cell-.create_text(18,18, text = somevar, fill = 'blue' , font = ('arial', 18, 'bold')) Also, how can I declare a variable outside of the mainloop/callback scheme which would be 'known' to the callbacks? Thanks, Norm I guess you are using tkinter. .9919624.9990312 in tkinter is just a string representation of the underlying object, in this case a Canvas(). It is not up to a python programmer to understand exactly what these numbers are. They are used by Tcl/Tk internally. Tk objects are not pickleable. Better is to create a datastructure that can be pickled from info gleaned specifically with the itemcget() method. Example code is below. See the Pickle/cPickle documentation. They are very easy to use. Since you haven't posted any code, I can only guess what you are doing. But you may want to try variations on the following (read the comments): from Tkinter import * # This is how you may want to make a bunch of canvases in a grid. def make_canvases(parent, rows=9, cols=9, **options): Pass in rows, cols, and any options the canvases should require. cells = [] for i in xrange(rows): arow = [] for j in xrange(cols): c = Canvas(parent, **options) c.grid(row=i, column=j) arow.append(c) cells.append(arow) return cells def demo(): Tests out our make_canvases() function. # tkinter stuff--setting up tk = Tk() f = Frame(tk) f.pack(expand=YES, fill=BOTH) # make the canvases the gui-programmer way canvases = make_canvases(f, height=25, width=25) # individual access to canvases (remember that indices start at 0) canvases[0][0].configure(background='orange') canvases[7][8].create_text(14, 8, text='Bob', fill='blue', font=('arial', 14, 'bold')) canvases[8][8].create_text(14, 8, text='9,9', fill='blue', font=('arial', 14, 'bold')) # accessing inside loops for i in xrange(9): canvases[i][8-i].configure(background='red') # fun with bindings (see your last question) # you should study this one! for i in xrange(9): for j in xrange(9): c = canvases[i][j] c.bind(Button-1, lambda e=None, c=c: c.configure(background='green')) # getting out info texts = [] for i in xrange(9): for j in xrange(9): c = canvases[i][j] for t in c.find_all(): try: text = c.itemcget(t, 'text') texts.append((i,j,text)) except: pass # reporting the got-out info Label(tk, text=Texts are: %s % texts).pack(expand=YES, fill=X) tk.mainloop() demo() Thanks for your reply, and those of others...all are helpful. As to the code I wrote (so far), her it is, complete with some expressions that didn't work too well...:) ThanksNorm # Start GUI CODE == from Tkinter import * import tkFileDialog fred = Tk()# Notice I have a bias against 'top', 'master', 'root', etc fred.title('SUDOKU SCREEN') #fred.geometry('400x400') #fred.resizable(0,0) #-- Declare 9 frames plus one for the buttons fr1 = Frame(fred); fr2 = Frame(fred); fr3 = Frame(fred) fr4 = Frame(fred); fr5 = Frame(fred); fr6 = Frame(fred) fr7 = Frame(fred); fr8 = Frame(fred); fr9 = Frame(fred) Named references are useleless here, especially since you are putting these frames into a list later. In fact, you really don't need to create these frames because you can just use grid() to place your canvases...except if you want resize behavior. bfr = Frame(fred, relief = 'raised', borderwidth = 1, pady = 10) This frame you WILL want a named reference for, because you do adress it by name later. #-- Set some vars ind = [3,4,5,12,13,14,21,22,23,27,28,29,33,34,35,36,37,38,42,43,44,45,46,47,51,52,53,57,58,59,66,67,68,75,76,77] fr_list = [fr1,fr2,fr3,fr4,fr5,fr6,fr7,fr8,fr9] Better is to eliminate the fr# = Frame(fred) code above and replace this latter line with: fr_list = [Frame(fred) for i in xrange(9)] can_list = ['can1','can2','can3','can4','can5','can6','can7','can8','can9'] This list is largely unecessary. Can do the same thing with xrange below. cell = [] myvar = '' mykey = 'K' myadd = 'one' iy = 0
Re: Firefox bug in webbrowser module on Ubuntu?!
This seems ok... import webbrowser webbrowser._iscommand(firefox) True webbrowser.register(firefox,None,webbrowser.Netscape(firefox)) webbrowser._browsers {'galeon': [None, webbrowser.Galeon instance at 0xb7d471cc], 'firefox': [None, webbrowser.Netscape instance at 0xb7d43bcc], 'mozilla': [None, webbrowser.Netscape instance at 0xb7d4708c], 'mozilla-firefox': [None, webbrowser.Netscape instance at 0xb7d4712c], 'w3m': [None, webbrowser.GenericBrowser instance at 0xb7d43fec]} But it is still not working... webbrowser.open(http://www.python.org;) ...doesn't do anything However... import os os.path.exists('/usr/bin/firefox') True I also have Ubuntu on a VMware Player and there it works out of the box, although firefox is not registered there. (mozilla-firefox is.) It is strange as I just installed Ubuntu on this system and can't imagine something is screwed up already. -- http://mail.python.org/mailman/listinfo/python-list
how to run python scripts on a website
i have a website which runs apache on linux. it supports python (i think via cginot sure how else). anyway how can I go to a web page and run a python script or something like that? for example say i make a script which prints out all the links on another URLhow can i run that? thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: how to run python scripts on a website
py wrote: i have a website which runs apache on linux. it supports python (i think via cginot sure how else). anyway how can I go to a web page and run a python script or something like that? for example say i make a script which prints out all the links on another URLhow can i run that? thanks! Here is a start. Put the following in your cgi-bin folder or equivalent. Name it test.cgi #!/usr/bin/python print Content-Type: text/plain\n\n print Hello, World!\n Now just browse it. E.g.: http://www.doe-mbi.ucla.edu/cgi/jstroud/ex-1.1.cgi James -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expressions: recursive patterns and callouts
Carlos [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi! I think two extensions to re could be really powerful in aiding to match non regular strings -for example those containing parens nested up to an arbitrary depth- but without a significative performance loss, although I'm not at all sure at this last point. One of these features is re nesting; I don't mean nesting some strings and then compiling the composed re, but to include -possibly recursive- references to other re's. The second feature is the ability to add callout points in a re, so external functions would be called when the matcher reaches those points to validate the current matched prefix or even to do some arbitrary further matching of its own, advancing the pattern position. pcre implements similar features with its (?CN) callout and (?N) recursive patterns mechanisms. Are the above or equivalent features planned for future python releases? Do you know of some extension package which provide them or at least pcre compatible res? Thank you in advance, Carlos Pyparsing supports both parse-time callouts (called parse actions) and recursive grammar definitions. Download pyparsing at http://pyparsing.sourceforge.net. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
new.instancemethod as a form of partial()
I came across this while searching for a way to DIY partial(), until it is available in 2.5 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/229472 However, when trying for the following, it doesn't work and is wondering if it is a bug or intended : import operator import new new.instancemethod(operator.is_,None,object)(None) Traceback (most recent call last): File pyshell#5, line 1, in -toplevel- new.instancemethod(operator.is_,None,object)(None) TypeError: is_ expected 2 arguments, got 1 new.instancemethod(operator.is_,False,object)(False) True So it seems that instancemethod() don't like None as the instance. -- http://mail.python.org/mailman/listinfo/python-list
Re: new.instancemethod as a form of partial()
[EMAIL PROTECTED] wrote: ... So it seems that instancemethod() don't like None as the instance. bound methods and unbound methods are instance of the same type, distinguished by one thing: the im_self of an unbound method is None, the im_self of a bound method is anything else. So, when you pass None as the instance, instancemethod likes it just fine... and returns an unbound method as the result, so you haven't actually achieved your goal (you must still pass the first parameter explicitly -- all you've gained by wrapping a function into an unbound method is an implicit typecheck on the first argument, and if, as the class, you're using 'object' as in your example, that's not much use [even in other cases, it's no great shakes;-)]). Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: new.instancemethod as a form of partial()
Alex Martelli wrote: [EMAIL PROTECTED] wrote: ... So it seems that instancemethod() don't like None as the instance. bound methods and unbound methods are instance of the same type, distinguished by one thing: the im_self of an unbound method is None, the im_self of a bound method is anything else. So, when you pass None as the instance, instancemethod likes it just fine... and returns an unbound method as the result, so you haven't actually achieved your goal (you must still pass the first parameter explicitly -- all you've gained by wrapping a function into an unbound method is an implicit typecheck on the first argument, and if, as the class, you're using 'object' as in your example, that's not much use [even in other cases, it's no great shakes;-)]). thanks. So in this special case, None is being treated as a flag rather than just an instance(I just read the doc) like any other instance and the behaviour is intended. Is there any reason why it is designed this way ? -- http://mail.python.org/mailman/listinfo/python-list
Some thougts on cartesian products
In Python, it is possible to multiply a string with a number: hello*3 'hellohellohello' However, you can't multiply a string with another string: 'hello'*'world' Traceback (most recent call last): File interactive input, line 1, in ? TypeError: can't multiply sequence by non-int Sometimes I was missing such a feature. What I expect as the result is the cartesian product of the strings. Here is a simple implementation of new list and string objects that explains what I mean. It also implements powers of lists and strings: class plist(list): list with cartesian product list def __mul__(self, other): if isinstance(other, pstr): return plist([s+o for s in self for o in other]) if hasattr(other, '__getitem__'): return plist([[s, o] for s in self for o in other]) else: return list(self)*other def __pow__(self, other): if isinstance(other, int) and other 0: if other == 1: return self return self * self**(other-1) class pstr(str): str with cartesian product list def __mul__(self, other): if hasattr(other, '__getitem__'): return plist([s+o for s in self for o in other]) else: return str(self)*other def __pow__(self, other): if isinstance(other, int) and other 0: if other == 1: return self return self * self**(other-1) With these new strings you can do the following: pstr(ab)*pstr(cd)*pstr(ef) ['ace', 'acf', 'ade', 'adf', 'bce', 'bcf', 'bde', 'bdf'] print pstr(abcdefgh)*pstr(12345678) ['a1', 'a2', ..., 'a8', 'b1', 'b2', ..., 'b8', ..., ..., ..., 'h1', 'h2', ..., 'h8'] print pstr(ACGU)**3 ['AAA', 'AAC', 'AAG', 'AAU', 'ACA', 'ACC', 'ACG', ..., ..., 'UGC', 'UGG', 'UGU', 'UUA', 'UUC', 'UUG', 'UUU'] I think this can be quite handy at times and save some typing. If Python strings had this ability, you could even outdo the 117 byte solution in the recent shortest Python coding contest (http://www.pycontest.net), as follows: j=''.join;seven_seg=lambda x:j(j(\ (' |'*'_ '*' |')[ord('|[EMAIL PROTECTED](ÀD°'[int(d)])%e]\ for d in x)+'\n'for e in(4,9,7)) This has only 110 bytes. Or you could write a simple password cracker like that: def crack(crypted, alphabet): for passwd in alphabet**4: if crypt(passwd, crypted[:2]) == crypted: return passwd And call it with alphabet = string.lowercase, for example. Cartesian products may be generally interesting for iterables: def imul(iterable1, iterable2): cartesian product of two iterables for object1 in iterable1: for object2 in iterable2: if isinstance(object1, basestring) and \ isinstance(object2, basestring): yield object1 + object2 else: yield (object1, object2) def ipow(iterable, number): cartesian product power of an iterable if number == 1: for object in iterable: yield object elif number 1: for object1 in iterable: for object2 in ipow(iterable, number-1): yield object1 + object2 class istr(str): str with iterable cartesian product def __mul__(self, other): if isinstance(other, str): return imul(self, other) else: return str(self)*other def __pow__(self, other): return ipow(self, other) I was wondering if similar functionality could be added in some way to Python. I noticed that Python has a lot of aggregate functions that can reduce given collection objects (like reduce, filter, min, max, sum, hash) and functions that keep the same size (like map, sort or zip), but few functions that can inflate the given objects (like range and enumerate). I know, such functions are dangerous because they also inflate time and memory consumed by the program. Still, sometimes they can make sense, whenever you for some reason simply *have* to walk through all the combinations. -- http://mail.python.org/mailman/listinfo/python-list
Re: Returning a tuple-struct
[EMAIL PROTECTED] wrote: I've noticed that there's a few functions that return what appears to be a tuple, but that also has attributes for each item in the tuple. For example, time.localtime() returns a time.time_struct, which looks like a tuple but also like a struct. That is, I can do: time.localtime() (2006, 1, 18, 21, 15, 11, 2, 18, 0) time.localtime()[3] 21 time.localtime().tm_hour 21 Ah, but it ISN'T really a tuple: import time t = time.localtime() type(t) type 'time.struct_time' str(t) '(2006, 1, 21, 22, 49, 32, 5, 21, 0)' It's a class object. The __repr__ method returns a string that LOOKS the same as a tuple. -- - Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Help needed with Weave and XP and MSVC 6.0
Hi, I'm having some problems getting weave to work correctly. For now, I'm just testing how to access Numeric arrays under weave. My test code is: from Numeric import * import weave a = zeros((5,5,5,5,5),typecode=Int16) a[4,3,2,2,1] = 55.0 code = a[0,0,3,0,0] = 3.0; printf(%d,a[4,3,2,2,1]); weave.inline(code,['a'] ,type_converters= weave.converters.blitz, compiler='msvc') The interperter is currently spitting out errors which ends in: AttributeError: array_info instance has no attribute 'msvc_msg' If I leave off the compiler keyword, the interperter then starts having problems with the type_converter. If l leave both keywords off, the code just doesn't work. On the other hand, I have had success saving Numeric arrays to file using fwrite and opening them again with fread. I have a feeling that my weave/python install is messed up, but I'm not sure what's wrong. I first installed MSVC 6, then the Enthought package of python/weave. Has anybody ever experienced this problem? -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's Edu Corner: IT Industry Predicament
Ulrich Hobelmann [EMAIL PROTECTED] wrote: [ snip bait ] I know, don't feed the troll. Sorry 'bout that. To quote Space Balls: Don't be sorry, be *quiet*! :) Cheers, Tim Hammerquist -- http://mail.python.org/mailman/listinfo/python-list
Re: How to generate graphics dynamically on the web using Python CGI script?
Luiz Geron wrote: I don't have experience on this, but I think that you can make the script return the image contents directly to the img tag, without passing it to a img file, so you can use something like this: img src=script_that_return_image_contents wich saves some processing and I/O. I like this method. You have 2 cgi scripts: one that creates your html with that img tag in it, and a 2nd one to generate the image file on the fly when the browser asks for it. For generating the plot, I tried pychart http://home.gna.org/pychart/ and it was pretty nice. If using pychart, your script that emits image contents might look like this: code #!/usr/bin/python # Not using cgi module at this point, since this script # isn't very smart yet. :) import sys sys.argv.append( '--format=png' ) print Content-type: image/png print from pychart import * theme.get_options() theme.scale_factor = 3 theme.reinitialize() import random data = [] for i in range(10): data.append( (i, random.random()* 3.0) ) xaxis = axis.X( format=/hL%d, label=time ) yaxis = axis.Y( label=synaptic activity ) ar = area.T( x_axis=xaxis, y_axis=yaxis, y_range=(0,None), size=(120,110) ) plot = line_plot.T( label=cortex data, data=data, ycol=1, tick_mark=tick_mark.star ) ar.add_plot( plot ) ar.draw() - /code Try the script out -- it'll work as-is once you've installed pychart. You can add logic to it to generate your plot depending on what you pass in, encoded in the URL request. Just import the cgi module for getting those parameters. ---J -- (remove zeez if demunging email address) -- http://mail.python.org/mailman/listinfo/python-list
[ python-Bugs-1338995 ] CVS webbrowser.py (1.40) bugs
Bugs item #1338995, was opened at 2005-10-26 18:08 Message generated for change (Comment added) made by montanaro You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1338995group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.5 Status: Closed Resolution: Fixed Priority: 5 Submitted By: Greg Couch (gregcouch) Assigned to: Nobody/Anonymous (nobody) Summary: CVS webbrowser.py (1.40) bugs Initial Comment: There are two calls to _safequote that are only made on darwin, aka, Mac OS X. That function is missing. And the UnixBrowser is missing an in the simpler command and thus causes python to hang until the browser is exited (if it wasn't running already). -- Comment By: Skip Montanaro (montanaro) Date: 2006-01-21 09:06 Message: Logged In: YES user_id=44345 Skip, can you test? Yes, it works, thanks. I can understand special casing local URLs, but why also OSX? Was that the only platform on which local URLs failed? -- Comment By: Georg Brandl (birkenfeld) Date: 2006-01-20 15:05 Message: Logged In: YES user_id=1188172 Another try to fix it in 42121. I added a special case for OSX browsers wrt local URLs. Skip, can you test? -- Comment By: Greg Couch (gregcouch) Date: 2005-12-06 18:13 Message: Logged In: YES user_id=131838 And I agree it is desirable, but it didn't work reliably in 2.4 nor any earlier version, and it isn't documented to work. The urllib.urlopen example you gave fails miserably with Windows files names, i.e., given C:\WINDOWS\system.ini it tries to interpret the C as a scheme. You need to use urllib's pathname2url function and pass the result to urlopen. If webbrowser.open is fixed, then maybe there will be some pressure to fix urlopen as well. You just have been lucky or unlucky depending on how you view it. -- Comment By: Skip Montanaro (montanaro) Date: 2005-12-06 17:38 Message: Logged In: YES user_id=44345 All I'm saying is that if this form webbrowser.open(/tmp/foo.html) was supported in Python 2.4, possibly by recognizing the bare path and silently pretending the programmer wrote webbrowser.open(file://localhost/tmp/foo.html) then it ought to do the same in 2.5 unless you intend to break existing applications. How hard can it be to recognize that the first character of the url is / and prepend file://localhost/ before passing it along to the user's chosen browser? I suggest compatibility with urllib.urlopen is desirable: f = urllib.urlopen(/etc/hosts) f.read() ##\n# Host Database\n# \n# Note that this file is consulted when the system is running in single-user\n# mode. At other times this information is handled by lookupd. By default,\n# lookupd gets information from NetInfo, so this file will not be consulted\n# unless you have changed lookupd's configuration.\n#\n# localhost is used to configure the loopback interface\n# when the system is booting. Do not change this entry.\n##\n127.0.0.1\tlocalhost montanaro.dyndns.org\n255.255.255.255\tbroadcasthost\n Skip -- Comment By: Greg Couch (gregcouch) Date: 2005-12-06 16:27 Message: Logged In: YES user_id=131838 And you seem to have scanned my previous post and missed where I discussed all of the problems with webbrowser.open(path). I should have been more explicit that those were problems with the all versions of the webbrowser module. It is browser-dependent whether or not opening a path works at all. I have had to work around that problem for years (starting with grail in 1997 and carried over to the webbroswer module in 2001). Any cross-platform developer, that tests their code, already has a workaround in place. If the webbrowser documentation agreed with you, then I would agree with you as well. Although I feel we are already violently agreeing. Fix the documentation and I'll fix the code. -- Comment By: Skip Montanaro (montanaro) Date: 2005-12-06 15:57 Message: Logged In: YES user_id=44345 You're missing the point. It works in Python 2.4 and doesn't on CVS HEAD. I've already had to modify one application. Maybe the old webbrowser module used to prepend a file://localhost/ to filenames that were missing schemes. All I know is it used to work and now it doesn't As is, 2.5 is likely to break some applications that rely on the behavior in 2.4. -- Comment By: Greg Couch (gregcouch) Date:
[ python-Bugs-1338995 ] CVS webbrowser.py (1.40) bugs
Bugs item #1338995, was opened at 2005-10-27 01:08 Message generated for change (Comment added) made by birkenfeld You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1338995group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.5 Status: Closed Resolution: Fixed Priority: 5 Submitted By: Greg Couch (gregcouch) Assigned to: Nobody/Anonymous (nobody) Summary: CVS webbrowser.py (1.40) bugs Initial Comment: There are two calls to _safequote that are only made on darwin, aka, Mac OS X. That function is missing. And the UnixBrowser is missing an in the simpler command and thus causes python to hang until the browser is exited (if it wasn't running already). -- Comment By: Georg Brandl (birkenfeld) Date: 2006-01-21 20:04 Message: Logged In: YES user_id=1188172 Well, all of the Unix browsers I tried accept filenames without a problem, the os.startfile function on Windows does it in any case. That left OSX and Safari. -- Comment By: Skip Montanaro (montanaro) Date: 2006-01-21 16:06 Message: Logged In: YES user_id=44345 Skip, can you test? Yes, it works, thanks. I can understand special casing local URLs, but why also OSX? Was that the only platform on which local URLs failed? -- Comment By: Georg Brandl (birkenfeld) Date: 2006-01-20 22:05 Message: Logged In: YES user_id=1188172 Another try to fix it in 42121. I added a special case for OSX browsers wrt local URLs. Skip, can you test? -- Comment By: Greg Couch (gregcouch) Date: 2005-12-07 01:13 Message: Logged In: YES user_id=131838 And I agree it is desirable, but it didn't work reliably in 2.4 nor any earlier version, and it isn't documented to work. The urllib.urlopen example you gave fails miserably with Windows files names, i.e., given C:\WINDOWS\system.ini it tries to interpret the C as a scheme. You need to use urllib's pathname2url function and pass the result to urlopen. If webbrowser.open is fixed, then maybe there will be some pressure to fix urlopen as well. You just have been lucky or unlucky depending on how you view it. -- Comment By: Skip Montanaro (montanaro) Date: 2005-12-07 00:38 Message: Logged In: YES user_id=44345 All I'm saying is that if this form webbrowser.open(/tmp/foo.html) was supported in Python 2.4, possibly by recognizing the bare path and silently pretending the programmer wrote webbrowser.open(file://localhost/tmp/foo.html) then it ought to do the same in 2.5 unless you intend to break existing applications. How hard can it be to recognize that the first character of the url is / and prepend file://localhost/ before passing it along to the user's chosen browser? I suggest compatibility with urllib.urlopen is desirable: f = urllib.urlopen(/etc/hosts) f.read() ##\n# Host Database\n# \n# Note that this file is consulted when the system is running in single-user\n# mode. At other times this information is handled by lookupd. By default,\n# lookupd gets information from NetInfo, so this file will not be consulted\n# unless you have changed lookupd's configuration.\n#\n# localhost is used to configure the loopback interface\n# when the system is booting. Do not change this entry.\n##\n127.0.0.1\tlocalhost montanaro.dyndns.org\n255.255.255.255\tbroadcasthost\n Skip -- Comment By: Greg Couch (gregcouch) Date: 2005-12-06 23:27 Message: Logged In: YES user_id=131838 And you seem to have scanned my previous post and missed where I discussed all of the problems with webbrowser.open(path). I should have been more explicit that those were problems with the all versions of the webbrowser module. It is browser-dependent whether or not opening a path works at all. I have had to work around that problem for years (starting with grail in 1997 and carried over to the webbroswer module in 2001). Any cross-platform developer, that tests their code, already has a workaround in place. If the webbrowser documentation agreed with you, then I would agree with you as well. Although I feel we are already violently agreeing. Fix the documentation and I'll fix the code. -- Comment By: Skip Montanaro (montanaro) Date: 2005-12-06 22:57 Message: Logged In: YES user_id=44345 You're missing the point. It works in Python 2.4 and doesn't on CVS HEAD. I've already had to modify one application. Maybe the old
[ python-Bugs-1411674 ] print statement in libref index broken
Bugs item #1411674, was opened at 2006-01-21 13:50 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1411674group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Documentation Group: Python 2.5 Status: Open Resolution: None Priority: 5 Submitted By: Skip Montanaro (montanaro) Assigned to: Nobody/Anonymous (nobody) Summary: print statement in libref index broken Initial Comment: The print statement entry in the libref index refers the user to http://www.python.org/dev/doc/devel/lib/types.html#l2h-92 The source (libstdtypes.tex): \ulink{\keyword{print} statement}{../ref/print.html} suggests that the link should be to the reference manual. Something's fishy. This was reported on comp.lang.python by [EMAIL PROTECTED] His report was against the current doc, but the problem still exists in the development version. Just passing it along... -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1411674group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1411674 ] print statement in libref index broken
Bugs item #1411674, was opened at 2006-01-21 20:50 Message generated for change (Comment added) made by birkenfeld You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1411674group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Documentation Group: Python 2.5 Status: Open Resolution: None Priority: 5 Submitted By: Skip Montanaro (montanaro) Assigned to: Fred L. Drake, Jr. (fdrake) Summary: print statement in libref index broken Initial Comment: The print statement entry in the libref index refers the user to http://www.python.org/dev/doc/devel/lib/types.html#l2h-92 The source (libstdtypes.tex): \ulink{\keyword{print} statement}{../ref/print.html} suggests that the link should be to the reference manual. Something's fishy. This was reported on comp.lang.python by [EMAIL PROTECTED] His report was against the current doc, but the problem still exists in the development version. Just passing it along... -- Comment By: Georg Brandl (birkenfeld) Date: 2006-01-21 20:59 Message: Logged In: YES user_id=1188172 The output is okay. The \ulink you state does not add the index entry, it's the \stindex one line above it. But it's questionable whether this mention of print merits an index entry. Fred? -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1411674group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1411695 ] XML.sax.saxutils.escape -- always escapes , , ,
Bugs item #1411695, was opened at 2006-01-21 15:17 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1411695group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: XML Group: Python 2.4 Status: Open Resolution: None Priority: 5 Submitted By: Mark Sandler (msandler) Assigned to: Nobody/Anonymous (nobody) Summary: XML.sax.saxutils.escape -- always escapes , , , Initial Comment: sax.saxutils.escape -- always escapes , , , even if entities are provided. E.g. escape(abcd, {'a':'\a'}) would produce lt;\abcd%rt; instead of \abcd While it might be expected behaviour, the documentation states You can escape other strings of data by passing a dictionary as the optional entities parameter. The keys and values must all be strings; each key will be replaced with its corresponding value. and it is not at all obvious that entities specify _additional_ (to , , ) escape strings. It is also impossible to do custom escapes of ,, using saxutils.escape. (while custom escapes of and might be never necessary for XML, the escape function is general enough to be of interest in other circumstances). -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1411695group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1411097 ] urllib2.urlopen() hangs due to use of socket._fileobject?
Bugs item #1411097, was opened at 2006-01-20 20:26 Message generated for change (Comment added) made by jjlee You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1411097group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: None Status: Open Resolution: None Priority: 5 Submitted By: John J Lee (jjlee) Assigned to: Nobody/Anonymous (nobody) Summary: urllib2.urlopen() hangs due to use of socket._fileobject? Initial Comment: To reproduce: import urllib2 print urllib2.urlopen(http://66.117.37.13/;).read() The attached patch fixes the hang, but that patch is not acceptable because it also removes the .readline() and .readlines() methods on the response object returned by urllib2.urlopen(). The patch seems to demonstrate that the problem is caused by the (ab)use of socket._fileobject in urllib2.AbstractHTTPHandler (I believe this hack was introduced when urllib2 switched to using httplib.HTTPConnection). Not sure yet what the actual problem is... -- Comment By: John J Lee (jjlee) Date: 2006-01-21 22:10 Message: Logged In: YES user_id=261020 In fact the commit message for rev 36871 states the real reason _fileobject is used (handling chunked encoding), showing my workaround is even more harmful than I thought. Moreover, doing a urlopen on 66.117.37.13 shows the response *is* chunked. The problem seems to be caused by httplib failing to find a CRLF at the end of the chunked response, so the loop at the end of _read_chunked() never terminates. Haven't looked in detail yet, but I'm guessing a) it's the server's fault and b) httplib should work around it. Here's the commit message from 36871: Fix urllib2.urlopen() handling of chunked content encoding. The change to use the newer httplib interface admitted the possibility that we'd get an HTTP/1.1 chunked response, but the code didn't handle it correctly. The raw socket object can't be pass to addinfourl(), because it would read the undecoded response. Instead, addinfourl() must call HTTPResponse.read(), which will handle the decoding. One extra wrinkle is that the HTTPReponse object can't be passed to addinfourl() either, because it doesn't implement readline() or readlines(). As a quick hack, use socket._fileobject(), which implements those methods on top of a read buffer. (suggested by mwh) Finally, add some tests based on test_urllibnet. Thanks to Andrew Sawyers for originally reporting the chunked problem. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1411097group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com