Seattle Python Interest Group meeting 14 June 2007
Thursday, June 14th, 2007 at 7 PM See details at www.seapig.org -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Version 1.2 of MMA is now available
Version 1.2 of MMA - Musical MIDI Accompaniment - is now available for downloading. Included in this release: A new command set which lets MMA create and play MIDI files on-the- fly, Some additional synchronization options, Smoother volume changes with (De)Crescendos, Minor bug fixes/improvements. See the entire change log in the included CHANGES-1.1 file. MMA is a accompaniment generator -- it creates midi tracks for a soloist to perform with. User supplied files contain pattern selections, chords, and MMA directives. For full details please visit: http://www.mellowood.ca/mma/ If you have any questions or comments, please send them to: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: VIM editor question
In your vim configuration file enter: colorscheme name Example: colorscheme elflord Restart vim. On 6/8/07, David [EMAIL PROTECTED] wrote: Is anyone in the group familiar with the VIM editor? I rather like it but any time I right click on a file and select Edit with Vim It opens the file in a rather ugly default color scheme. I'd love to know how to make it automatically open files I select in my favorite color scheme rather than having to go into the EDIT pull down menu and select my preferred Color Scheme every time I open a file. thanks for any wisdom you can share DavidKG2LI -- http://mail.python.org/mailman/listinfo/python-list -- Jesus is coming!Rev. 1:7 The Bottom LineJohn 3:3-7 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
En Sat, 09 Jun 2007 02:49:03 -0300, WaterWalk [EMAIL PROTECTED] escribió: I've just read an article Building Robust System by Gerald Jay Sussman. The article is here: http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf In it there is a footprint which says: Indeed, one often hears arguments against building exibility into an engineered sys- tem. For example, in the philosophy of the computer language Python it is claimed: \There should be one|and preferably only one|obvious way to do it.[25] Science does not usually proceed this way: In classical mechanics, for example, one can construct equa- tions of motion using Newtonian vectoral mechanics, or using a Lagrangian or Hamiltonian variational formulation.[30] In the cases where all three approaches are applicable they are equivalent, but each has its advantages in particular contexts. I'm not sure how reasonable this statement is and personally I like Python's simplicity, power and elegance. So I put it here and hope to see some inspiring comments. I think the key is the word you ommited in the subject: obvious. There should be one obvious way to do it. For what I can remember of my first love (Physics): if you have a small ball moving inside a spherical cup, it would be almost crazy to use cartesian orthogonal coordinates and Newton's laws to solve it - the obvious way would be to use spherical coordinates and the Lagrangian formulation (or at least I hope so - surely knowledgeable people will find more obviously which is the right way). All classical mechanics formulations may be equivalent, but in certain cases one is much more suited that the others. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Case-Insensitive Sorting of Multi-Dimensional Lists
Joe [EMAIL PROTECTED] wrote: I am new to lambda and have searched for a few hours this morning, coming up empty handed. Is this possible? Seeing as it has happened, it must be. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonS?
On Jun 9, 3:51 am, Michel Claveau [EMAIL PROTECTED] wrote: Hi! Python, Iron-Python, Jython, StackLess-Python, Monty-Python, Movable-Python, etc. Shouldn't add a S to the end of Python? See:http://www.jfwilliam.com/Sites/1473/Python.jpg The fact of adding a S could constitute a PEP. for classification, I propose: PEP'S -- @-salutations Michel Claveau I'd vote for a more serpentine Python :-) - Paddy. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
WaterWalk [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | I've just read an article Building Robust System by Gerald Jay | Sussman. The article is here: | http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf | | In it there is a footprint which says: | Indeed, one often hears arguments against building exibility into an | engineered sys- | tem. For example, in the philosophy of the computer language Python it | is claimed: For him to imply that Python is anti-flexibility is wrong. Very wrong.. He should look in a mirror. See below. | \There should be one|and preferably only one|obvious way to do | it.[25] Science does | not usually proceed this way: In classical mechanics, for example, one | can construct equa- | tions of motion using Newtonian vectoral mechanics, or using a | Lagrangian or Hamiltonian | variational formulation.[30] In the cases where all three approaches | are applicable they are | equivalent, but each has its advantages in particular contexts. And in those contexts, one would hope that the method with advantages is somehow the obvious way to do it. Otherwise beginners might become like Buriden's ass. So I dispute that science is as different as he claims. And I do not see any real value in the statement in that I do not see it saying anything useful to the reader, at least not in this snippet. | I'm not sure how reasonable this statement is and personally I like | Python's simplicity, power and elegance. So I put it here and hope to | see some inspiring comments. How much has Mr. Sussman actually programmed in Python and what actual problems did he find with the *implementation* of the philosophy? Without something concrete, the complaint is rather bogus. But here is what I find funny (and a bit maddening): G. J. Sussman is one of the inventers of the Lisp dialect Scheme, a minimalist language that for some things has only one way to do it, let alone one obvious way. Scheme would be like physics with only one of the three ways. After all, if they are equivalent, only one is needed. For example, consider scanning the items in a collection. In Python, you have a choice of recursion (normal or tail), while loops, and for statements. For statements are usually the obvious way, but the other two are available for personal taste and for specially situations such as walking a tree (where one might use recursion to write the generator that can then be used by for loops. In scheme, I believe you just have recursion. Since iteration and recursion are equivalent, why have both? Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: interating over single element array
Basilisk96 [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | On Jun 8, 11:54 am, T. Crane [EMAIL PROTECTED] wrote: | You can also do this (if tuples are okay in your case): | | a = 1, | | The comma turns 'a' into a tuple (1,) which is both iterable and has a | length of 1. | | I have run into this issue before with a function that took a list of | filenames (strings), and needed to iterate over the list to operate on | the input files. For the case when the input would be a single file, I | needed to turn the input string into an iterable such that the 'for' | loop would not iterate on the filename characters (a rather | undesirable gotcha, you understand :-) ). So I solved my problem like | this: | | def loadfiles(filelist): |if not isinstance(filelist, list): | filelist = filelist, Any what if 'filelist' is any iterable other than a string or list? Your code is broken, and unnecessarily so. So I would call the parameter 'files' and test for isinstance(files, str) #or basestring. And wrap if it is. |for filename in filelist: | f = open(filename,'r') | #do interesting stuff with file, etc... | | ..and it's been working very well. | | Cheers, | -Basilisk96 | | -- | http://mail.python.org/mailman/listinfo/python-list | -- http://mail.python.org/mailman/listinfo/python-list
Re: Working with fixed format text db's
On Jun 8, 5:50 pm, Neil Cerutti [EMAIL PROTECTED] wrote: Many of the file formats I have to work with are so-called fixed-format records, where every line in the file is a record, and every field in a record takes up a specific amount of space. For example, one of my older Python programs contains the following to create a fixed-format text record for a batch of new students: new = file(new.dat, w) if not new: print Error. Could not open file new.dat for writing. raw_input(Press Return To Exit.) sys.exit(1) for s in freshmen: new.write(s.ssn.ljust(9)) new.write(s.id.ljust(10)) new.write(s.last[:16].ljust(16)) new.write(s.first[:11].ljust(11)) new.write(' '.ljust(10)) # Phone Number new.write(' '.ljust(1254)) # Empty 'filler' space. new.write('2813 ') new.write(s.major.ljust(5)) I have to do this occasionally, and also find it cumbersome. I toyed with the idea of posting a feature request for a new 'fixed length' string formatting operator, with optional parameters for left/ right-justified and space/zero-filled. We already have '%-12s' to space fill for a length of 12, but it is not truly fixed-length, as if the value has a length greater than 12 you need it to be truncated, and this construction will not do that. Assume we have a new flag '!n', which defaults to left-justified and space-filled, but allows an optional 'r' and '0' to override the defaults. Then the above example could be written as format = '%!9s%!10s%!16s%!11s%!10s%!1254s%!6s%!5s' for s in freshmen: new.write (format % (s.ssn,s.id,s.last,s.first, ' ',' ','2813',s.major)) I never felt strongly enough about it to propose it, but I thought I would mention it. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list
Re: Working with fixed format text db's
On Jun 9, 5:48 am, Mark Carter [EMAIL PROTECTED] wrote: Neil Cerutti wrote: The underlying problem, of course, is the archaic flat-file format with fixed-width data fields. Even the Department of Education has moved on to XML for most of it's data files, :( I'm writing a small app, and was wondering the best way to store data. Currently the fields are separated by spaces. I was toying with the idea of using sqlite, yaml or json, but I think I've settled on CSV. Dull, but it's easy to parse for humans and computers. Yup, humans find that parsing stuff like the following is quite easy: Jack The Ripper Jones,Eltsac Ruo, 123 Smith St,,Paris TX 12345 Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Re: Case-Insensitive Sorting of Multi-Dimensional Lists
Ben Finney wrote: mosscliffe [EMAIL PROTECTED] writes: I have tried the following, for a one dimensional list and it works, but I can not get my head around this lambda. How would this be written, without the lamda ? mylist = ['Fred','bill','PAUL','albert'] mylist.sort(key=lambda el: el.lower()) Here's a hint: FoO.lower() 'foo' str.lower(FoO) 'foo' But be aware that you lose both the ability to override and duck-typing: print r # derived from str Upper East Side print s # unicode München r.lower(), str.lower(r) ('Lower East Side', 'upper east side') s.lower(), str.lower(s) Traceback (most recent call last): File stdin, line 1, in module TypeError: descriptor 'lower' requires a 'str' object but received a 'unicode' Peter -- http://mail.python.org/mailman/listinfo/python-list
Ang roskilde billet
Hej Jeg er interesseret i at købe din billet, jeg bor selv på amager, så vi kan gøre en hurtig handel. Mvh André -- http://mail.python.org/mailman/listinfo/python-list
Re: python-ldap for Python 2.5 on Windows?
Waldemar Osuch wrote: On Jun 8, 6:36 am, Benedict Verheyen [EMAIL PROTECTED] wrote: Hi, i found python-ldap for version Python 2.4. Is there i place i can find a version for 2.5? If not, how can i build it myself for Windows? I have managed to build it for myself using MinGW: http://www.osuch.org-a.googlepages.com/python-ldap-2.3.win32-py2.5.exe I'd appreciate if someone would provide Win32 builds of python-ldap on a regular basis. Or at least a description what to do. I could add it to python-ldap's web site. Ciao, Michael. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
Terry Reedy wrote: In Python, you have a choice of recursion (normal or tail) Please explain this. I remember reading on this newsgroup that an advantage of ruby (wrt python) is that ruby has tail recursion, implying that python does not. Does python have fully optimized tail recursion as described in the tail recursion Wikipedia entry? Under what circumstances can one count on the python interpreter recognizing the possibility for optimized tail recursion? James = Disclaimer: Mention of more than one programming language in post does not imply author's desire to begin language v. language holy battle. The author does not program in [some or all of the other languages mentioned aside from the language topical to the newsgroup] and has no opinions on the merits or shortcomings of said language or languages. = -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
In scheme, I believe you just have recursion. Cousin TJR I'm a total scheme rookie starting only about 3 days ago and one of the mechanisms I went looking for was a technique for iteration Found in the scheme docs about iteration supplied via the reduce package Iterate and reduce are extensions of named-let for writing loops that walk down one or more sequences such as the elements of a list or vector, the characters read from a port, or arithmetic series The following scheme session illustrates a trivial example , open reduce ( define ( list_loop this_list ) ( iterate loop ( ( list* this_item this_list ) ) ; iterate expression ( ( new_list '( ) ) ) ; state expression ( loop ( cons ( * 2 this_item ) new_list ) ) ; bodyexpression ( reverse new_list ) ) ) ; final expression ; no values returned ( define L '( 1 2 3 4 5 ) ) ; no values returned ( define result_i ( list_loop L ) ) ; no values returned result_i '(2 4 6 8 10) However, just as in Python the map function might be both easier to code and more readable in many cases ( define ( x2 n ) ( * 2 n ) ) ; no values returned ( define result_m ( map x2 L ) ) ; no values returned result_m '(2 4 6 8 10) Note No lambdas in my scheme code either ;-) -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
Gabriel Genellina wrote: For what I can remember of my first love (Physics): if you have a small ball moving inside a spherical cup, it would be almost crazy to use cartesian orthogonal coordinates and Newton's laws to solve it - the obvious way would be to use spherical coordinates and the Lagrangian formulation (or at least I hope so Yep, that's right. - surely knowledgeable people will find more obviously which is the right way). No, this case is IMHO almost classical. Movement with planar constraints can be solved quite easy using Lagrange. All classical mechanics formulations may be equivalent, but in certain cases one is much more suited that the others. Or: Lagrange is the only obvious way to describe movement with constraints. Regards, Björn -- BOFH excuse #80: That's a great computer you have there; have you considered how it would work as a BSD machine? -- http://mail.python.org/mailman/listinfo/python-list
Re: Working with fixed format text db's
Frank Millman [EMAIL PROTECTED] writes: On Jun 8, 5:50 pm, Neil Cerutti [EMAIL PROTECTED] wrote: Many of the file formats I have to work with are so-called fixed-format records, where every line in the file is a record, and every field in a record takes up a specific amount of space. [ ... ] We already have '%-12s' to space fill for a length of 12, but it is not truly fixed-length, as if the value has a length greater than 12 you need it to be truncated, and this construction will not do that. In this case, we can use '%-12.12s'. -- Lloyd Zusman [EMAIL PROTECTED] God bless you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
On Jun 9, 12:16 pm, James Stroud [EMAIL PROTECTED] wrote: Terry Reedy wrote: In Python, you have a choice of recursion (normal or tail) Please explain this. I remember reading on this newsgroup that an advantage of ruby (wrt python) is that ruby has tail recursion, implying that python does not. Proof by rumour? You can use first class continuations in Ruby to eliminate tail calls in and define higher order function wrappers ( like Python decorators ). But I wouldn't call this fully optimized. Does python have fully optimized tail recursion as described in the tail recursion Wikipedia entry? No. -- http://mail.python.org/mailman/listinfo/python-list
Re: The Concepts and Confusions of Prefix, Infix, Postfix and Fully Functional Notations
Twisted wrote: On Jun 8, 7:30 pm, Jürgen Exner [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: [nothing relevant to Perl] Perl?? Perl is even less relevant to Java than the original post, which admittedly has some connection to pretty much all programming languages. (Perl, on the other hand, has no connection to any known programming language. ;) In particular, Perl code looks more like line noise than like code from any known programming language. ;)) Hmm - I know of APL and SNOBOL. -- Lew -- http://mail.python.org/mailman/listinfo/python-list
Re: how to convert a bitmap file to an array ?
stef wrote: Stefan Sonnenberg-Carstens wrote: stef schrieb: hello I can find all kind of procedures to convert an array to a bitmap (wxPython, PIL), but I can't find the reverse, either - convert a bitmap to an array or - read a bitmap file to an array thanks, Stef Mientki Take a look at the struct module. There you fill find pack/unpack, which can do what you need. thanks Stefan, but using struct, I need to know how a bitmap file is build, I don't know that (and I rather don't want to know that ;-) Any better solutions (I'm a spoiled Delphi user ;-) I can offer the code below, but I can't guarantee you won't need to play with it. You can almost certainly ignire the fonty bits! def _setupContext(memory, font=None, color=None): if font: memory.SetFont(font) else: memory.SetFont(wx.NullFont) if color: memory.SetTextForeground(wx.Colour(*color)) def write( text, bitmap, pos=(0,0), font=None, color=None): Simple write into a bitmap doesn't do any checking. memory = wx.MemoryDC() _setupContext(memory, font, color) memory.SelectObject(bitmap) width, height = memory.GetTextExtent(text) try: memory.DrawText(text, pos[0],pos[1],) finally: memory.SelectObject(wx.NullBitmap) return width def bitmapToPil(bitmap): return imageToPil(bitmapToImage(bitmap)) def bitmapToImage(bitmap): return wx.ImageFromBitmap(bitmap) def pilToBitmap(pil): return imageToBitmap(pilToImage(pil)) def pilToImage(pil): image = wx.EmptyImage(pil.size[0], pil.size[1]) image.SetData(pil.convert('RGB').tostring()) return image def imageToPil(image): pil = Image.new('RGB', (image.GetWidth(), image.GetHeight())) pil.fromstring(image.GetData()) return pil def imageToBitmap(image): return image.ConvertToBitmap() regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: interating over single element array
Terry Reedy [EMAIL PROTECTED] wrote: Any what if 'filelist' is any iterable other than a string or list? Your code is broken, and unnecessarily so. So I would call the parameter 'files' and test for isinstance(files, str) #or basestring. And wrap if it is. Can you give an example of such an iterable (other than a tuple)? I'd certainly like to fix my 'fix' to work for a more general case. Regards, -Basilisk96 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python for embedded systems with memory constraints
Hi, Thanks Cameron for your suggestions. In fact I am using custom memory sub-allocator where I preallocate a pool of memory during initialization of my application and ensure that Python doesn't make any system mallocs later . With this arrangement, python seems to run out of preallocated memory (of 10MB) after running few simple scripts due to huge external fragmentation. My memory sub-allocator got a good design which uses the best-fit algorithm and coaelescing the adjacent blocks during each free call. If anybody out there used their own memory manager and ran Python without fragmentation , could provide some inputs on this. Thanks in advance. On 6/7/07, Cameron Laird [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], vishnu [EMAIL PROTECTED] wrote: Hi there, I am embedding python 2.5 on embedded system running on RTOS where I had strict memory constraints. As python is a huge malloc intensive application, I observed huge memory fragmentation in my system which is leading to out of memory after running few scripts. So I decided to re-initialise the python with out restarting the whole python. I tried to use Py_Finalise() after completion of each script , then call Py_Initialise as is done in below link. http://mail.python.org/pipermail/python-list/2001-November/114253.html Which in every loop it causes a leak of 10K and after some iterations it leaks of 200K etc. After few more runs this crashes. I read some where this leak was solved in 2.5, but with 2.5 also I am having problems And also I found Py_Finalise does not completely cleanup the memory, So how do I re-initialise my memory pool? Does anybody faced this problem earlier and got any solution hack to run the python for a embedded system within own managed memory pool of say 10MB? Any help/ideas are greatly appreciated!. Thanks in advance. Your report is interesting and important--and surprising! I thought Python memory allocation is cleaner than you seem to be observing. I hope one of the core Python maintainers can address this. I haven't worked at this level recently enough to speculate on why it's happen- ing, nor will I soon be in a position to volunteer to research it on my own (although I'd eagerly contract to do so on a modestly paid basis). Depending on your schedule and technology, there are lots of technical fixes that might apply: A. quick-starting Python variations that encourage you to manage memory on a whole-process level; B. use of one of the many Python variants (even PyPy?) that might give you a more favorable memory profile; C. switch to Lua or Tcl as more easily embeddable alternative languages; D. custom memory allocator; ... -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: VIM editor question
On Jun 9, 1:14 am, Jerry VanBrimmer [EMAIL PROTECTED] wrote: In your vim configuration file enter: colorscheme name Example: colorscheme elflord Restart vim. No! That's completely wrong. It should be: colorscheme moria set bg=dark http://www.vim.org/scripts/script.php?script_id=1464 -- http://mail.python.org/mailman/listinfo/python-list
Re: interating over single element array
In [EMAIL PROTECTED], Basilisk96 wrote: Terry Reedy [EMAIL PROTECTED] wrote: Any what if 'filelist' is any iterable other than a string or list? Your code is broken, and unnecessarily so. So I would call the parameter 'files' and test for isinstance(files, str) #or basestring. And wrap if it is. Can you give an example of such an iterable (other than a tuple)? I'd certainly like to fix my 'fix' to work for a more general case. def iter_filenames(filename): lines = open(filename, 'r') for line in lines: yield line.rstrip() lines.close() filenames = iter_filenames('files.txt') Now `filenames` is an iterable over strings representing file names but it's not a `list`. And it's easy to come up with iterables over strings that produce the data themselves, for example by attaching a counter to a basename, or extracting the names from XML files, fetching them from a database etc. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
running python scripts via crontab
Hello all, I wrote a simple python script to send mail via smtp to my gmail acc.I can run it as python /home/phil/Desktop/smtp.py but when I add the same to my crontab as * * * * * /usr/bin/python2.5 /home/phil/Desktop/smtp.py ,it doesn't run.I checked the process by using top command and python did start a thread but died soon. I need some help here. The python script uses tls-lite lib to use tls over smtp. life isn#39;t heavy enough,it flies away and floats far above action - How would you spend $50,000 to create a more sustainable environment in Australia? Go to Yahoo!7 Answers and share your idea.-- http://mail.python.org/mailman/listinfo/python-list
piping data stream through GPG
I played around trying to encrypt/decrypt data through GPG on the fly (or worse - by using a file) (on Windows first - later to try on Linux too) Using os.popen3 like i,o,e=os.popen3('gpg -e -r Robert') # i.write('y\n') i.write('wefwef') i.close() # e.read(1) o.read(1) hangs on o.read or e.read. So its quite dark. Just a totally non-existing userid (-r) will result significantly different like i.write('wefwef') Traceback (most recent call last): File interactive input, line 1, in ? IOError: [Errno 22] Invalid argument GPG asks confirmation stuff (and pwd upon -d or -c) on the command line. How to get all this the right way? Robert -- http://mail.python.org/mailman/listinfo/python-list
Re: piping data stream through GPG
robert wrote: I played around trying to encrypt/decrypt data through GPG on the fly (or worse - by using a file) (on Windows first - later to try on Linux too) Using os.popen3 like i,o,e=os.popen3('gpg -e -r Robert') # i.write('y\n') i.write('wefwef') i.close() # e.read(1) o.read(1) hangs on o.read or e.read. So its quite dark. Just a totally non-existing userid (-r) will result significantly different like i.write('wefwef') Traceback (most recent call last): File interactive input, line 1, in ? IOError: [Errno 22] Invalid argument GPG asks confirmation stuff (and pwd upon -d or -c) on the command line. How to get all this the right way? now tryed around like i,o,e=os.popen3('gpg --status-fd 2 --passphrase-fd 0 -e -r Robert','b') i.write('y\r') i.write('wefwef') i.close() # e.read(1) o.read(1) still just hanging... never any output (status or honey) Robert -- http://mail.python.org/mailman/listinfo/python-list
Re: Where can I suggest an enchantment for Python Zip lib?
In article [EMAIL PROTECTED], durumdara [EMAIL PROTECTED] wrote: [...] Click your heels together three times and say, Abracadabra! (Sorry, couldn't resist.) -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ as long as we like the same operating system, things are cool. --piranha -- http://mail.python.org/mailman/listinfo/python-list
Tackling setup.py - A bug??
Hi, I've successfully compiled p4python with modified setup.py the key to success was to split extra_compile_args's argument '-arch' into 2 args. below is fixed part: [code] ext_modules=[Extension(P4Client, [ P4Clientmodule.cc ], include_dirs=[ os.path.join( p4_api_dir, include, p4 ) ], library_dirs=[ os.path.join( p4_api_dir, lib ) ], libraries=[client, rpc, supp],# P4API libs extra_compile_args=[-DCASE_INSENSITIVE, -fpascal-strings, -isysroot, /Developer/SDKs/MacOSX10.4u.sdk, -DOS_MACOSX, -DOS_MACOSX104 , -arch, ppc ,-D%s % p4_api_ver], extra_link_args=[ -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk , -arch, ppc , -framework, System , -framework, CoreFoundation , -framework, Carbon ], )] [/code] hope it will help --- Original Message: --- And this followed by an setup.py install seemed to work just fine. Ok so now I need to backport these options into setup.py. Here is what I came up with.. elif os.name == posix: setup(name=NAME, version=VERSION, description=DESCRIPTION, author=AUTHOR, author_email=AUTHOR_EMAIL, maintainer=MAINTAINER, maintainer_email=MAINTAINER_EMAIL, license=LICENSE, url=URL, keywords=KEYWORDS, classifiers = filter(None, classifiers.split(\n)), long_description = \n.join(doclines[2:]), py_modules=PY_MODULES, ext_modules=[Extension(P4Client, [P4Clientmodule.cc], include_dirs=[p4_api_dir], library_dirs=[p4_api_dir], libraries=[client, rpc, supp],# P4API libs extra_compile_args=[-DCASE_INSENSITIVE, -fpascal-strings, -isysroot/Developer/ SDKs/MacOSX10.4u.sdk, -DOS_MACOSX, - DOS_MACOSX104, -DOS_MACOSXPPC, - DOS_MACOSX104PPC ,-D%s % p4_api_ver], extra_link_args=[ -Wl,-syslibroot,/ Developer/SDKs/MacOSX10.4u.sdk, -arch ppc, -framework Carbon ], )]) But low and behold it didn't work... In the course of debugging I found that the compile works. The linking appears to be a problem. In the link stage I see the command which is being run looks very similar to my command g++ -bundle -undefined dynamic_lookup build/temp.macosx-10.3-ppc-2.5/ P4Clientmodule.o \ -Lp4api6.1 -lclient -lrpc -lsupp -o build/lib.macosx-10.3-ppc-2.5/ P4Client.so \ -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch ppc -framework Carbon Not quite the same but close enough. HERE is where the bug shows up If I rerun this same EXACT command at the command line - followed by a setup.py install it works. Can someone with a larger python brain than mine please help me figure this out? It's bugging the crap out fo me... -- BR. Alexander 'zowers' Petrov.jabber:[EMAIL PROTECTED]icq:69694782 http://zowers.googlepages.com/mailto:[EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: VIM editor question
I use vim on both Windows and UNIX/Linux, and found this vimrc file. http://darksmile.net/software/.vimrc.html It's pretty good and has good comments. You might want to take a look at that and customize it. Plus this is great: http://www.usf.uni-osnabrueck.de/infoservice/doc/localhtml/vim/if_python.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter custom drawing
Thank you this is nice code. I never thought of using the move_pending method.. Still it doesn't answer my question (which I ensure is very unclear). But do not worry, I found some way to get throught my dilemma and I can live easily with it. Thanks for your help. -- http://mail.python.org/mailman/listinfo/python-list
Re: VIM editor question
On Jun 9, 9:56 am, Joe Riopel [EMAIL PROTECTED] wrote: I use vim on both Windows and UNIX/Linux, and found this vimrc file.http://darksmile.net/software/.vimrc.html It's pretty good and has good comments. You might want to take a look at that and customize it. Plus this is great:http://www.usf.uni-osnabrueck.de/infoservice/doc/localhtml/vim/if_pyt... This one also good, especially for those of us who sometimes wrap text: http://www.cs.cornell.edu/~djm/ubuntu/vimrc.txt -- http://mail.python.org/mailman/listinfo/python-list
Re: Repository - file scanner
On Jun 8, 2:33 pm, HMS Surprise [EMAIL PROTECTED] wrote: Greetings, Could someone point my muddled head at a/the python repository. I know that one exists but cannot find it again. In particular I am looking for a standalone search tool that given a path searches files for a text string. Thanks, jvh Are you looking for A.) a Python script to search for file names that match a given text string? B.) a script to search for a given text string within a text file? C.) a Python repository, as in the SVN/CVS area? Here's a couple scripts for finding files given a path: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52224 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/189973 And here's an interesting article on creating a Python Find utility: http://www.python.org/search/hypermail/python-1994q2/0116.html This link has a chapter from Learning Python by O'Reilly that talks about looking for words within files: http://www.oreilly.com/catalog/lpython/chapter/ch09.html The repository is here: http://svn.python.org/ Enjoy! Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Repository - file scanner
On Jun 8, 2:33 pm, HMS Surprise [EMAIL PROTECTED] wrote: Greetings, Could someone point my muddled head at a/the python repository. I know that one exists but cannot find it again. In particular I am looking for a standalone search tool that given a path searches files for a text string. Thanks, jvh Search for text in a file, from O'Reilly's Learning Python book: http://www.oreilly.com/catalog/lpython/chapter/ch09.html Search for files given a path (or paths) and some text to search for: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52224 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/189973 http://www.python.org/search/hypermail/python-1994q2/0116.html The Python repository (I think): http://svn.python.org/ Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: How Can I Increase the Speed of a Large Number of Date Conversions
Many thanks for the lucid and helpful suggestions. Since my date range was only a few years, I used Some Other Guy's suggestion above, which the forum is saying will be deleted in five days, to make a dictionary of the whole range of dates when the script starts. It was so fast it wasn't even worth saving in a file. Made the script a LOT faster. I guess two thousand function calls must be faster than 200 million? Like maybe a hundred thousand times faster? I also benefitted from studying the other suggestons. I had actually implemented an on the fly dictionary caching scheme for one of my other calculations. I don't know why it didn't occur to me to do it with the dates, except I think I must be assuming, as a newbie Pythonista, that the less I do and the more I let the libraries do the better off I will be. Thanks for putting me straight. As someone I know said to me when I told him I wanted to learn Python, the power of Python is in the dictionaries. Funny how long it's taking me to learn that. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
James Stroud [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | Terry Reedy wrote: | In Python, you have a choice of recursion (normal or tail) | | Please explain this. I am working on a paper for Python Papers that will. It was inspired by the question 'why doesn't Python do tail-recursion optimization'. tjr -- http://mail.python.org/mailman/listinfo/python-list
Hooking exceptions outside of call stack
Here is what I would like to do: # a = Tr3() # implements domain specific language a.b = 1# this works, Tr3 overrides __getattr__ a.__dict__['b'] = 2# just so you know that b is local a[b] = 3 # I want to resolve locally, but get: Traceback (most recent call last): ... exec cmd in globals, locals ... NameError: global name 'b' is not defined # So far, I've tried capturing exceptions in __getattr__, __setitem__, and __setattr__, with no luck. I do NOT want to put `a[b]=3` inside a try...except block because I want to enable a command line `a[b]=3` Is there a way to hook a NameError exception outside of the call stack? Perhaps, inside Tr3.__init__ ? Is there a way of putting back unhandled NameError exceptions, so that they unwind the stack normally? This is intended for production code. Many thanks! Warren -- http://mail.python.org/mailman/listinfo/python-list
Re: piping data stream through GPG
robert wrote: I played around trying to encrypt/decrypt data through GPG on the fly (or worse - by using a file) (on Windows first - later to try on Linux too) Using os.popen3 like i,o,e=os.popen3('gpg -e -r Robert') # i.write('y\n') i.write('wefwef') i.close() # e.read(1) o.read(1) hangs on o.read or e.read. So its quite dark. Just a totally non-existing userid (-r) will result significantly different like i.write('wefwef') Traceback (most recent call last): File interactive input, line 1, in ? IOError: [Errno 22] Invalid argument GPG asks confirmation stuff (and pwd upon -d or -c) on the command line. How to get all this the right way? I basically can handle it now by a os.popen3 cmd like 'gpg -e -r Robert --batch --always-trust', 'gpg -d -r Robert --batch --always-trust --passphrase-fd 0' and by using a thread for feeding the child_stdin stream (necessary for files of significant length / more than buffers) Robert -- http://mail.python.org/mailman/listinfo/python-list
Re: DAO and Access97 WHERE clause fails
Hello all. Thanks for the help! John pointed out to me the flaw in my code: Change: sSQL3 = 'SELECT * FROM T_Index2DirName WHERE iIndex = hsDB' to: sSQL3 = 'SELECT * FROM T_Index2DirName WHERE iIndex = %ld' % hsDB That did the trick. I had looked at the statement so often that it was *obviously* correct. John also pointed me to the DAO help file that I had not been able to find. Dennis also pointed out the correction, but went on to educate me much more on what I was trying to do. BTW, I had searched extensivly on line for the answer before posting, but was missing the obvious, stupid coding error. Thanks to all for getting me back on track! --Vic v.davis2 [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi all, I am attempting to use Access97 as the database to hold the results of a python script. I seem to be able to make simple SELECT clauses work (like SELECT * FROM TableName), but have not been able to figure out how to add a WHERE clause to that (e.g., SELECT * FROM TableName WHERE myFieldName = 34) This fails complaining that the wrong number of parameters are present. I haved tried DAO36 and I have tried the ADO version with the same results. Therefore I have to conclude it is my screwup! Help in the forum or via email would sure be appreciated! ([EMAIL PROTECTED]) Here is the skeleton code: import win32com.client daoEngine = win32com.client.Dispatch('DAO.DBEngine.35') sDBname = 'vpyAnalyzeDirectorySize.mdb' sDB = 'c:\\documents and settings\\vic\\my documents\\tools\\python25\\_myscripts\\'+sDBname daoDB = daoEngine.OpenDatabase(sDB) sSQL1 = 'SELECT * FROM T_Index2DirName' daoRS = daoDB.OpenRecordset(sSQL1) # this works FINE and I can play with the record set #snip hsDB = hash(sDB) sSQL3 = 'SELECT * FROM T_Index2DirName WHERE iIndex = hsDB' # names are all correct in mdb file daoRStest = daoDB.OpenRecordset(sSQL3) # this FAILS, even though the record is there daoRS.Close() Traceback (most recent call last): File C:\Documents and Settings\Vic\My Documents\Tools\python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py, line 310, in RunScript exec codeObject in __main__.__dict__ File C:\Documents and Settings\Vic\My Documents\Tools\python25\_MyScripts\TestForPosting01.py, line 14, in module daoRStest = daoDB.OpenRecordset(sSQL3) # this FAILS, even though record is there File C:\Documents and Settings\Vic\My Documents\Tools\python25\lib\site-packages\win32com\gen_py\00025E01---C000-0046x0x5x0.py, line 523, in OpenRecordset , Type, Options, LockEdit) com_error: (-2147352567, 'Exception occurred.', (0, 'DAO.Database', 'Too few parameters. Expected 1.', 'jeterr35.hlp', 5003061, -2146825227), None) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
Cousin Stanley [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | In scheme, I believe you just have recursion. I was referring to the original mimimalist core language developed by Guy and Sussman and as I remember it being used in the original edition of SICP (see Wikipedia). I also remember statements explaining (truthfully) that builtin iteration is not needed because it can be defined in terms of tail recursion, which in Scheme is required to be optimized to be just as space efficient. I see in Wikipedia that Scheme has do loops (all versions?), but I do not know if that was original or added. If the former, it was de-emphasized. Hence my belief, even if mistaken. | Cousin TJR | | I'm a total scheme rookie starting only about 3 days ago | and one of the mechanisms I went looking for was a technique | for iteration | | Found in the scheme docs about iteration supplied | via the reduce package Right. An add-on library package, not part of the core;-) In Python, modules can add functions (and classes, etc), but not statement syntax, so adding while statements defined in terms of recursion is not possible. Scheme is quite elegant and worth learning at least the basics of. My only point was that Sussman is an odd person to be criticizing (somewhat mistakingly) Python for being minimalist. tjr -- http://mail.python.org/mailman/listinfo/python-list
Re: launching default browser
Laurent Pointal wrote: Via webbrowser module http://docs.python.org/lib/module-webbrowser.html thx a lot. Just again Python positively surprises me. (note: its in top five in google search for Python + launch + browser...) so now it will be in top four :-). -- http://mail.python.org/mailman/listinfo/python-list
Re: How Can I Increase the Speed of a Large Number of Date Conversions
vdicarlo [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | Many thanks for the lucid and helpful suggestions. Since my date range | was only a few years, I used Some Other Guy's suggestion above, which | the forum is saying will be deleted in five days, to make a dictionary | of the whole range of dates when the script starts. It was so fast it | wasn't even worth saving in a file. Made the script a LOT faster. I | guess two thousand function calls must be faster than 200 million? | Like maybe a hundred thousand times faster? Any function called repeatedly with the same input is a candidate for a lookup table. This is a fairly extreme example. || I also benefitted from studying the other suggestons. I had actually | implemented an on the fly dictionary caching scheme for one of my | other calculations. I don't know why it didn't occur to me to do it | with the dates, except I think I must be assuming, as a newbie | Pythonista, that the less I do and the more I let the libraries do the | better off I will be. | | Thanks for putting me straight. As someone I know said to me when I | told him I wanted to learn Python, the power of Python is in the | dictionaries. | | Funny how long it's taking me to learn that. Well, look at how many of us also did not quite see the now obvious answer. Even Python's list.sort() only fairly recently gained the optional 'key' parameter, which implements the decorate-sort-undecorate pattern and which often obsoletes the original compare-function parameter because it saves time by calculating (and saving) the key only once per item instead of once each comparison. import this The Zen of Python, by Tim Peters [snip] Namespaces are one honking great idea -- let's do more of those! I include lookup dictionaries in this admonition. tjr -- http://mail.python.org/mailman/listinfo/python-list
Re: Repository - file scanner
En Sat, 09 Jun 2007 12:30:49 -0300, [EMAIL PROTECTED] escribió: On Jun 8, 2:33 pm, HMS Surprise [EMAIL PROTECTED] wrote: Could someone point my muddled head at a/the python repository. I know that one exists but cannot find it again. In particular I am looking for a standalone search tool that given a path searches files for a text string. Are you looking for A.) a Python script to search for file names that match a given text string? B.) a script to search for a given text string within a text file? C.) a Python repository, as in the SVN/CVS area? D.) The Python Package Index perhaps? http://www.python.org/pypi -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: read xml file from compressed file using gzip
flebber wrote: I was working at creating a simple program that would read the content of a playlist file( in this case *.k3b) and write it out . the compressed *.k3b file has two file and the one I was trying to read was maindata.xml The k3b format is a ZIP archive. Use the zipfile library: file:///usr/share/doc/python2.5-doc/html/lib/module-zipfile.html Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Gzip - gunzip using zlib
flebber wrote: Hi Can anyone show me a working example of how to use gzip to decompress a file. I have read the docs at python.org and had many goes at it but just can't get it to work. According to your other post, you are trying to open a ZIP archive using gzip. Use the zipfile module instead. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
Bjoern Schliessmann wrote: Gabriel Genellina wrote: For what I can remember of my first love (Physics): if you have a small ball moving inside a spherical cup, it would be almost crazy to use cartesian orthogonal coordinates and Newton's laws to solve it - the obvious way would be to use spherical coordinates and the Lagrangian formulation (or at least I hope so Having actually solved that problem in simulation, I can report that it's easier in Cartesian coordinates. I used to use this as a test of Falling Bodies, one of the first physics engines that really worked on the hard cases. Spherical coordinates seem attractive until you have to deal with friction between the ball and cup. The ball is rotating, too, and may be slipping with respect to the cup. Then the simple Physics 101 approach isn't so simple any more. John Nagle Animats -- http://mail.python.org/mailman/listinfo/python-list
Re: VIM editor question
On 6/9/07, BartlebyScrivener [EMAIL PROTECTED] wrote: On Jun 9, 1:14 am, Jerry VanBrimmer [EMAIL PROTECTED] wrote: In your vim configuration file enter: colorscheme name Example: colorscheme elflord Restart vim. No! That's completely wrong. No, it's not *completely* wrong. Yes, I should have mentioned the bg=dark entry, but that doesn't make it *completely* wrong. you're just showing your preference for the moria colorscheme, which is fine, but don't say my suggestion is *completely* wrong. Cheers Good Day. -- http://mail.python.org/mailman/listinfo/python-list
Re: Where can I suggest an enchantment for Python Zip lib?
Hogwarts. Sorry, I couldn't resist either. I'm sure you meant to say enhancement - an enchantment is a magic spell, often used to lull an unsuspecting victim into some sort of compliance or trance. Actually, if you have an *enchantment* for Python, I'm sure several people on this list would be interested. :) But yes, *enhancement* requests can be posted on the SF feature request list. You may need to more clearly define what kind of data these zlib callbacks would receive, and under what conditions they would be called. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: The Concepts and Confusions of Prefix, Infix, Postfix and Fully Functional Notations
On Jun 9, 6:49 am, Lew [EMAIL PROTECTED] wrote: In particular, Perl code looks more like line noise than like code from any known programming language. ;)) Hmm - I know of APL and SNOBOL. -- Lew TECO editor commands. I don't have direct experience with TECO, but I've heard that a common diversion was to type random characters on the command line, and see what the editor would do. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: running python scripts via crontab
On Jun 9, 2007, at 9:10 AM, Mr SZ wrote: Hello all, I wrote a simple python script to send mail via smtp to my gmail acc.I can run it as python /home/phil/Desktop/smtp.py but when I add the same to my crontab as * * * * * /usr/bin/python2.5 /home/phil/Desktop/smtp.py ,it doesn't run.I checked the process by using top command and python did start a thread but died soon. I need some help here. The python script uses tls-lite lib to use tls over smtp. One possible issue is that I believe the crontab entries to not run with the same environment that your normal user login does. If you set any environment variables in your .bashrc or .bash_profile file, try including those lines at the top of your crontab file. Here's the first line in my crontab file (this is on OS X, but the issue is likely the same on Linux). PATH=/opt/local/bin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/ usr/X11R6/bin:/Users/dreed/bin And are you really wanting to run the script every single minute (or is that just for testing)? Dave -- http://mail.python.org/mailman/listinfo/python-list
Multiple python interpreters within the same process
How do I use multiple Python interpreters within the same process? I know there's a function Py_NewInterpreter. However, how do I use functions like Py_RunString etc. with it? They don't take any arguments that would tell on which interpreter to run the string...? Marcin -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiple python interpreters within the same process
On Jun 9, 5:00 pm, Marcin Kalicinski [EMAIL PROTECTED] wrote: How do I use multiple Python interpreters within the same process? I know there's a function Py_NewInterpreter. However, how do I use functions like Py_RunString etc. with it? They don't take any arguments that would tell on which interpreter to run the string...? Marcin You may want to look at the code module http://docs.python.org/lib/module-code.html André -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
James Stroud wrote: Terry Reedy wrote: In Python, you have a choice of recursion (normal or tail) Please explain this. I remember reading on this newsgroup that an advantage of ruby (wrt python) is that ruby has tail recursion, implying that python does not. Does python have fully optimized tail recursion as described in the tail recursion Wikipedia entry? Under what circumstances can one count on the python interpreter recognizing the possibility for optimized tail recursion? Note that Terry said that you could do normal or tail recursion, he didn't claim that either were optimized. As for why tail calls are not optimized out, it was decided that being able to have the stack traces (with variable information, etc.) was more useful than offering tail call optimization (do what I say). - Josiah -- http://mail.python.org/mailman/listinfo/python-list
Re: Hooking exceptions outside of call stack
Warren Stringer wrote: Here is what I would like to do: # a = Tr3() # implements domain specific language a.b = 1# this works, Tr3 overrides __getattr__ a.__dict__['b'] = 2# just so you know that b is local a[b] = 3 # I want to resolve locally, but get: Traceback (most recent call last): ... exec cmd in globals, locals ... NameError: global name 'b' is not defined # Note that your a[b]=3 is the same as '__ = b;a[__]=3' You get that exception because b is not a bound name in the namespace you are currently using. In order to get what you want, you will either need to use a['b'] = 3, a.b = 3, or a method that I refuse to describe to you. This is intended for production code. The reason I refuse to describe to you the method that could 'solve' your particular problem is because it would be very difficult to differentiate between what you *want* to happen, and actual errors, which would make production code *very* difficult to get right. As an alternative to a['b'], you could use a[Z.b], for an object Z: class Z: def __getattr__(self, a): return a Z = Z() Which will have much less potential for destroying the maintainability and testability of your production code than hooking any trace function. - Josiah -- http://mail.python.org/mailman/listinfo/python-list
Re: Where can I suggest an enchantment for Python Zip lib?
durumdara wrote: Hi Larry! durumdara wrote: You can easily find out roughly how many bytes are in your .ZIP archive by using following: zipbytes=Zobj.fp.tell() The main problem is not this. I want to write a backup software, and I want to: - see the progress in the processing of the actual file - abort the progress if I need it If I compress small files, I don't have problems. But with larger files (10-20 MB) I get problems, because the zipfile's method is uninterruptable. Only one way I have to control this: if I modify the ZipFile module. dd On Jun 7, 8:26 pm, Larry Bates [EMAIL PROTECTED] wrote: On my 3 year old 3Ghz Pentium III it takes about 8 seconds to zip 20Mb file. So what is the problem? Not updating the process for 8-10 seconds should be just fine for most applications. -Larry -- http://mail.python.org/mailman/listinfo/python-list
RE: Hooking exceptions outside of call stack
Am still trying to hook a NameError exception and continue to run. After a few more hours of searching the web and pouring over Martelli's book, the closest I've come is: import sys def new_exit(arg=0): ... print 'new_exit called' ... #old_exit(arg) ... def hook(type, value, tb): ... print 'hook called with', type ... return ... sys.excepthook = hook old_exit = sys.exit sys.exit = new_exit a[b]=1 # would like to get new_exit called hook called with exceptions.NameError def test(): ... sys.exit() ... test() new_exit called The interactive session is different from running in the IDE (am using ActiveState's Visual Python) which exits just after the `a[b]=1` without calling hook. Am I missing something? Perhaps this is the wrong approach? I want Python to check a specific set of locals first, before checking globals. For instance: a.b[c] will call: a.__getattr__('b') but an exception is thrown before: a.b.__getitem__(c) Is there a way of intervening as `exec cmd in globals, locals` attempts to translate 'c' into an object? I thought that trapping a NameError might work. But now, I'm not so sure. Many thanks, \~/ Here is what I would like to do: # a = Tr3() # implements domain specific language a.b = 1# this works, Tr3 overrides __getattr__ a.__dict__['b'] = 2# just so you know that b is local a[b] = 3 # I want to resolve locally, but get: Traceback (most recent call last): ... exec cmd in globals, locals ... NameError: global name 'b' is not defined # So far, I've tried capturing exceptions in __getattr__, __setitem__, and __setattr__, with no luck. I do NOT want to put `a[b]=3` inside a try...except block because I want to enable a command line `a[b]=3` Is there a way to hook a NameError exception outside of the call stack? Perhaps, inside Tr3.__init__ ? Is there a way of putting back unhandled NameError exceptions, so that they unwind the stack normally? This is intended for production code. -- http://mail.python.org/mailman/listinfo/python-list
RE: Hooking exceptions outside of call stack
On Sat, 9 Jun 2007 13:52:19 -0700, Warren Stringer [EMAIL PROTECTED] wrote: Am still trying to hook a NameError exception and continue to run. After a few more hours of searching the web and pouring over Martelli's book, the closest I've come is: import sys def new_exit(arg=0): ... print 'new_exit called' ... #old_exit(arg) ... def hook(type, value, tb): ... print 'hook called with', type ... return ... sys.excepthook = hook old_exit = sys.exit sys.exit = new_exit a[b]=1 # would like to get new_exit called hook called with exceptions.NameError def test(): ... sys.exit() ... test() new_exit called The interactive session is different from running in the IDE (am using ActiveState's Visual Python) which exits just after the `a[b]=1` without calling hook. Am I missing something? Perhaps this is the wrong approach? I want Python to check a specific set of locals first, before checking globals. For instance: Yes. Python doesn't have restartable exceptions. Perhaps you would like to take a look at CL or Smalltalk? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
Josiah Carlson [EMAIL PROTECTED] writes: James Stroud wrote: Terry Reedy wrote: In Python, you have a choice of recursion (normal or tail) Please explain this. I remember reading on this newsgroup that an advantage of ruby (wrt python) is that ruby has tail recursion, implying that python does not. Does python have fully optimized tail recursion as described in the tail recursion Wikipedia entry? Under what circumstances can one count on the python interpreter recognizing the possibility for optimized tail recursion? Note that Terry said that you could do normal or tail recursion, he didn't claim that either were optimized. Well yeah, but without the implication how do the two words or tail add to the information content of the sentence? As for why tail calls are not optimized out, it was decided that being able to have the stack traces (with variable information, etc.) was more useful than offering tail call optimization I don't buy this. What's more important, making code not fail arbitrarily (and thus making approaches to certain problems feasible that otherwise wouldn't be) or making it a be a bit easier to debug code that will fail arbitrarily? Why not only do tail-call optimization in .pyo files and get the best of both worlds? (do what I say). Where did you say run out of memory and fail? More importantly how do you say don't run out of memory and fail? 'as -- http://mail.python.org/mailman/listinfo/python-list
urllib2 - iteration over non-sequence
im trying to get urllib2 to work on my server which runs python 2.2.1. When i run the following code: import urllib2 for line in urllib2.urlopen('www.google.com'): print line i will always get the error: Traceback (most recent call last): File stdin, line 1, in ? TypeError: iteration over non-sequence Anyone have any answers? -- http://mail.python.org/mailman/listinfo/python-list
RE: Hooking exceptions outside of call stack
Yes. Python doesn't have restartable exceptions. Perhaps you would like to take a look at CL or Smalltalk? Jean-Paul Hmmm, I wonder if anyone suggest to Philippe Petit, as stepped out 110 stories off the ground, that perhaps he would like to take a look at a different tightrope? Oddly enough, you suggestion regarding restartable exceptions turn up a solution: http://www.chneukirchen.org/blog/archive/2005/03/restartable-exceptions.html Oops, wrong language. \~/ -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 - iteration over non-sequence
[EMAIL PROTECTED] wrote: im trying to get urllib2 to work on my server which runs python 2.2.1. When i run the following code: import urllib2 for line in urllib2.urlopen('www.google.com'): print line i will always get the error: Traceback (most recent call last): File stdin, line 1, in ? TypeError: iteration over non-sequence Anyone have any answers? I ran your code: import urllib2 urllib2.urlopen('www.google.com') Traceback (most recent call last): File interactive input, line 1, in module File C:\Python25\lib\urllib2.py, line 121, in urlopen return _opener.open(url, data) File C:\Python25\lib\urllib2.py, line 366, in open protocol = req.get_type() File C:\Python25\lib\urllib2.py, line 241, in get_type raise ValueError, unknown url type: %s % self.__original ValueError: unknown url type: www.google.com Note the traceback. you need to call it with type in front of the url: import urllib2 urllib2.urlopen('http://www.google.com') addinfourl at 27659320 whose fp = socket._fileobject object at 0x01A51F48 Python's interactive mode is very useful for tracking down this type of problem. -Larry -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
Alexander Schmolck wrote: Josiah Carlson [EMAIL PROTECTED] writes: James Stroud wrote: Terry Reedy wrote: In Python, you have a choice of recursion (normal or tail) Please explain this. I remember reading on this newsgroup that an advantage of ruby (wrt python) is that ruby has tail recursion, implying that python does not. Does python have fully optimized tail recursion as described in the tail recursion Wikipedia entry? Under what circumstances can one count on the python interpreter recognizing the possibility for optimized tail recursion? Note that Terry said that you could do normal or tail recursion, he didn't claim that either were optimized. Well yeah, but without the implication how do the two words or tail add to the information content of the sentence? Normal and tail recursion are different, based upon whether or not one can technically considered to be done with the stack frame. def normal(arg): if arg == 1: return 1 return arg * normal(arg-1) def tail(arg, default=1): if arg == 1: return arg * default return tail(arg-1, default*arg) As for why tail calls are not optimized out, it was decided that being able to have the stack traces (with variable information, etc.) was more useful than offering tail call optimization I don't buy this. What's more important, making code not fail arbitrarily (and thus making approaches to certain problems feasible that otherwise wouldn't be) or making it a be a bit easier to debug code that will fail arbitrarily? Why not only do tail-call optimization in .pyo files and get the best of both worlds? I didn't make the decisions, I'm just reporting what was decided upon. Personally, I have never found the lack of tail call optimization an issue for two reasons. The first is because I typically write such programs in an iterative fashion. And generally for recursion for which tail call optimization doesn't work (the vast majority of recursive algorithms I use), I typically write the algorithm recursively first, verify its correctness, then convert it into an iterative version with explicit stack. I find it is good practice, and would be necessary regardless of whether Python did tail call optimization or not. (do what I say). Where did you say run out of memory and fail? More importantly how do you say don't run out of memory and fail? By virtue of Python's underlying implementation, Python does what I say, it doesn't do what I mean. While I may not have explicitly stated run out of stack space, the underlying implementation *has* limited stack space. You are stating that when you write a tail recursive program, you want Python to optimize it away by destroying the stack frames. And that's fine. There are tail-call optimization decorators available, and if you dig into sourceforge, there should even be a full patch to make such things available in a previous Python. However, Python is not Lisp and is not partially defined by infinite recursion (see sys.setrecursionlimit() ). Instead, it is limited by the C call stack (in CPython), and makes guarantees regarding what will always be available during debugging (the only thing that optimization currently does in Python at present is to discard docstrings). If you want to change what is available for debugging (to make things like tail call optimization possible), you are free to write and submit a PEP. In the mean time, you may need to do some source conversion. - Josiah -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 - iteration over non-sequence
Thanks for the reply Larry but I am still having trouble. If i understand you correctly, your are just suggesting that i add an http:// in front of the address? However when i run this: import urllib2 site = urllib2.urlopen('http://www.google.com') for line in site: print line I am still getting the message: TypeError: iteration over non-sequence File stdin, line 1 TypeError: iteration over non-sequence -- http://mail.python.org/mailman/listinfo/python-list
Re: Python for embedded systems with memory constraints
On Jun 9, 1:33 pm, vishnu [EMAIL PROTECTED] wrote: Hi, Thanks Cameron for your suggestions. In fact I am using custom memory sub-allocator where I preallocate a pool of memory during initialization of my application and ensure that Python doesn't make any system mallocs later . With this arrangement, python seems to run out of preallocated memory (of 10MB) after running few simple scripts due to huge external fragmentation. My memory sub-allocator got a good design which uses the best-fit algorithm and coaelescing the adjacent blocks during each free call. If anybody out there used their own memory manager and ran Python without fragmentation , could provide some inputs on this. From what I remember, the best-fit algorithm isn't a good idea because unless the free block was exactly the right size you'd tend to get left with lots of small fragments. (Suppose that the best fit was a free block only 4 bytes bigger than what you want; what can you do with a free block of 4 bytes?) A worst-fit algorithm would leave larger free blocks which are more useful subsequently, but I think that the recommendation was next-fit (ie use the first free block that's big enough, starting from where you found the last one). -- http://mail.python.org/mailman/listinfo/python-list
Re: interating over single element array
Thank you both for clearing that up. -Basilisk96 -- http://mail.python.org/mailman/listinfo/python-list
Re: Hooking exceptions outside of call stack
Warren Stringer wrote: Am still trying to hook a NameError exception and continue to run. After a few more hours of searching the web and pouring over Martelli's book, the closest I've come is: [snip] Is there a way of intervening as `exec cmd in globals, locals` attempts to translate 'c' into an object? I thought that trapping a NameError might work. But now, I'm not so sure. You can always muck around with the function's globals (if the operation is happening inside some function...) def foo(): ... print a ... d = {'a':1} foo = type(foo)(foo.func_code, d, foo.func_name, foo.func_defaults, foo.func_closure) a Traceback (most recent call last): File stdin, line 1, in ? NameError: name 'a' is not defined foo() 1 With a little work, you can 'merge' your namespace-like object with the module globals that normally exist for a function. However, I would say again, you shouldn't be doing this kind of thing in production code. - Josiah -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiple python interpreters within the same process
André wrote: On Jun 9, 5:00 pm, Marcin Kalicinski [EMAIL PROTECTED] wrote: How do I use multiple Python interpreters within the same process? I know there's a function Py_NewInterpreter. However, how do I use functions like Py_RunString etc. with it? They don't take any arguments that would tell on which interpreter to run the string...? Marcin You may want to look at the code module http://docs.python.org/lib/module-code.html That's completely unrelated. To answer Marcin's question, from what I understand, running multiple Python interpreters is not supported. There are various issues with object sharing and refcounts, etc., and are unlikely to be fixed soon if ever. - Josiah -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 - iteration over non-sequence
[EMAIL PROTECTED] wrote: Thanks for the reply Larry but I am still having trouble. If i understand you correctly, your are just suggesting that i add an http:// in front of the address? However when i run this: import urllib2 site = urllib2.urlopen('http://www.google.com') for line in site: print line I am still getting the message: TypeError: iteration over non-sequence File stdin, line 1 TypeError: iteration over non-sequence Newer version of Python are willing to implement an iterator that *reads* the contents of a file object and supplies the lines to you one-by-one in a loop. However, you explicitly said the version of Python you are using, and that predates generators/iterators. So... You must explicitly read the contents of the file-like object yourself, and loop through the lines you self. However, fear not -- it's easy. The socket._fileobject object provides a method readlines that reads the *entire* contents of the object, and returns a list of lines. And you can iterate through that list of lines. Like this: import urllib2 url = urllib2.urlopen('http://www.google.com') for line in url.readlines(): print line url.close() Gary Herron -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiple python interpreters within the same process
On Jun 10, 9:07 am, Josiah Carlson [EMAIL PROTECTED] wrote: André wrote: On Jun 9, 5:00 pm, Marcin Kalicinski [EMAIL PROTECTED] wrote: How do I use multiple Python interpreters within the same process? I know there's a function Py_NewInterpreter. However, how do I use functions like Py_RunString etc. with it? They don't take any arguments that would tell on which interpreter to run the string...? Marcin You may want to look at the code modulehttp://docs.python.org/lib/module-code.html That's completely unrelated. To answer Marcin's question, from what I understand, running multiple Python interpreters is not supported. There are various issues with object sharing and refcounts, etc., and are unlikely to be fixed soon if ever. I really don't know why people keep propagating this myth that you can't run multiple Python interpreters. :-( The Python C API has supported multiple Python interpreter instances within a single process for a long time. If you write your C program correctly there isn't a problem. The only real limitation is that different Python interpreter instances can't use different versions of a C extension module as they when loaded are shared across all Python interpreter instances. C extension modules can also cause other problems as well, but this isn't the fault of Python but of the module writers. Specifically, if a C extension module is written to only use the simplified API for GIL locking it can only be used with the first Python interpreter instance created. If they use the wider GIL locking API properly then there is no problem with using it in other Python interpreter instances. Another issue although one which you aren't likely to come across unless you are doing really tricky stuff, is where a C extension module was written so as to assume that once it is loaded into a Python interpreter instance, that that interpreter will not be destroyed. From what I have seen Pyrex generated C extension modules possibly have this latter problem and will cause a process to crash if a Python interpreter instance is destroyed and then a new one created in its place. As proof that all this stuff can work, have a look at mod_python and mod_wsgi. Both make use of multiple Python interpreter instances in a single process. The mod_wsgi documentation even points out the above problems with C extension modules in latter sections of: http://code.google.com/p/modwsgi/wiki/ApplicationIssues Graham -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
On Sat, 09 Jun 2007 22:42:17 +0100, Alexander Schmolck wrote: As for why tail calls are not optimized out, it was decided that being able to have the stack traces (with variable information, etc.) was more useful than offering tail call optimization I don't buy this. Do you mean you don't believe the decision was made, or you don't agree with the decision? What's more important, making code not fail arbitrarily (and thus making approaches to certain problems feasible that otherwise wouldn't be) or making it a be a bit easier to debug code that will fail arbitrarily? Why not only do tail-call optimization in .pyo files and get the best of both worlds? Are you volunteering? If you are, I'm sure your suggestion will be welcomed gratefully. (do what I say). Where did you say run out of memory and fail? More importantly how do you say don't run out of memory and fail? If we can live with a certain amount of arbitrary failures in simple arithmetic, then the world won't end if tail recursion isn't optimized away by the compiler. You can always hand-optimize it yourself. dont_run_out_of_memory_and_fail = 10**(10**100) # please? -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Ableton Live Python API is out!
I have been waiting for this ages and it's finally happened! Python meet Live, Live meet Python! There's now a wonderful (public) bridge between (arguably) the most exciting and innovative and easy-to-use realtime software sequencer and (arguably) the most exciting and innovative and easy-to-use computer programming language out there. I know the love will flow both ways (btw, they're having problems with the mac os x port, hint, hint... ) I rushed to update http://wiki.python.org/moin/PythonInMusic but lo and behold someone beat me to it. I love it when that happens especially since I kicked off the earliest version of that page back in the day ;-) Some important links: Ableton Live is at http://www.ableton.com The forum thread announcing the api is at : http://www.ableton.com/forum/viewtopic.php?t=66118postdays=0postorder=ascstart=0 And last but not least the Live python SDK sits at http://www.liveapi.org/ Enjoy! Alia K -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
On Sat, 09 Jun 2007 22:52:32 +, Josiah Carlson wrote: the only thing that optimization currently does in Python at present is to discard docstrings Python, or at least CPython, does more optimizations than that. Aside from run-time optimizations like interned strings etc., there are a small number of compiler-time optimizations done. Running Python with the -O (optimize) flag tells Python to ignore assert statements. Using -OO additionally removes docstrings. Regardless of the flag, in function (and class?) definitions like the following: def function(args): Doc string x = 1 s = this is a string constant and this string is treated as a comment return s*x The string-comment is ignored by the compiler just like real comments. (The same doesn't necessarily hold for other data types.) Some dead code is also optimized away: def function(): ... if 0: ... print dead code ... return 2 ... dis.dis(function) 4 0 LOAD_CONST 1 (2) 3 RETURN_VALUE Lastly, in recent versions (starting with 2.5 I believe) Python includes a peephole optimizer that implements simple constant folding: # Python 2.4.3 dis.dis(lambda: 1+2) 1 0 LOAD_CONST 1 (1) 3 LOAD_CONST 2 (2) 6 BINARY_ADD 7 RETURN_VALUE # Python 2.5 dis.dis(lambda: 1+2) 1 0 LOAD_CONST 2 (3) 3 RETURN_VALUE The above all holds for CPython. Other Pythons may implement other optimizations. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: The Concepts and Confusions of Prefix, Infix, Postfix and Fully Functional Notations
Paul McGuire [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Jun 9, 6:49 am, Lew [EMAIL PROTECTED] wrote: In particular, Perl code looks more like line noise than like code from any known programming language. ;)) Hmm - I know of APL and SNOBOL. -- Lew TECO editor commands. I don't have direct experience with TECO, but I've heard that a common diversion was to type random characters on the command line, and see what the editor would do. -- Paul J http://www.jsoftware.com/ -- http://mail.python.org/mailman/listinfo/python-list
RE: Ableton Live Python API is out!
Alia Khouri Write I have been waiting for this ages and it's finally happened! Python meet Live, Live meet Python! Wow. This is very cool; thanks for the announcement! I rushed to update http://wiki.python.org/moin/PythonInMusic but lo Thanks for this link, as well. Very useful. -- http://mail.python.org/mailman/listinfo/python-list
pyexe format
Hi, Is there a clean way to figure out that a .exe was actually generated by pyexe ? hg -- http://mail.python.org/mailman/listinfo/python-list
Re: pyexe format
hg wrote: Hi, Is there a clean way to figure out that a .exe was actually generated by pyexe ? hg I should gave writtent definite instead of clean hg -- http://mail.python.org/mailman/listinfo/python-list
How to get existing frames in non-current thread?
Hi, Is there some way to get all the frames for any given thread? -- in a way that does not require a compiled extension. Thanks, Fabio -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
Kay Schluehr wrote: On Jun 9, 12:16 pm, James Stroud [EMAIL PROTECTED] wrote: Terry Reedy wrote: In Python, you have a choice of recursion (normal or tail) Please explain this. I remember reading on this newsgroup that an advantage of ruby (wrt python) is that ruby has tail recursion, implying that python does not. Proof by rumour? Proof if you define proof by asking for clarification about a vague recollection of an even more vague posting. I think now I'll prove Fermat's Last Theorem by hailing a cab. -- http://mail.python.org/mailman/listinfo/python-list
RE: Hooking exceptions outside of call stack
Josiah Carlson wrote: foo = type(foo)(foo.func_code, d, foo.func_name, foo.func_defaults, foo.func_closure) Wow! I've never seen that, before. Is there documentation for `type(n)(...)` somewhere? I did find a very useful Decorator for Binding Constants, by Raymond Hettinger, that uses this technique. The calls are made from embedded classes that are constructed on the fly: class a(object): ... class b(object): ... class c(object): ... for `a.b[c]=1`, a.__getattr__('b') is called but 'c' need to be resolved as an object before a.b.__getitem__(c) is called. Could a.b.__init__ set globals so that 'c' gets resolved? Is this global namespace the same as the `globals()` namespace? Cheers, \~/ -- http://mail.python.org/mailman/listinfo/python-list
Re: pyexe format
On Jun 10, 10:38 am, hg [EMAIL PROTECTED] wrote: hg wrote: Hi, Is there a clean way to figure out that a .exe was actually generated by pyexe ? hg I should gave writtent definite instead of clean hg Reminds me of the story about a teacher trying to correct a student who was using rather dialectal English: You have went and putten putten when you should of putten put! :-) You should of looken at this: http://www.py2exe.org/index.cgi/WhereAmI HTH, John -- http://mail.python.org/mailman/listinfo/python-list
Re: pyexe format
On Jun 10, 11:25 am, John Machin [EMAIL PROTECTED] wrote: On Jun 10, 10:38 am, hg [EMAIL PROTECTED] wrote: hg wrote: Hi, Is there a clean way to figure out that a .exe was actually generated by pyexe ? hg I should gave writtent definite instead of clean hg Reminds me of the story about a teacher trying to correct a student who was using rather dialectal English: You have went and putten putten when you should of putten put! :-) You should of looken at this: http://www.py2exe.org/index.cgi/WhereAmI HTH, John I presumed that you were really asking: How can Python code tell whether it is being run in a py2exe-generated exe, or by the Python interpreter?. Alternatively, How can a human inspect an exe and determine whether it was generated by py2exe?: (1) I don't know (2) Why do you care? Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Re: VIM editor question
On Jun 9, 1:23 pm, Jerry Van Brimmer [EMAIL PROTECTED] wrote: On 6/9/07, BartlebyScrivener [EMAIL PROTECTED] wrote: No! That's completely wrong. No, it's not *completely* wrong. Yes, I should have mentioned the bg=dark entry, but that doesn't make it *completely* wrong. you're just showing your preference for the moria colorscheme, which is fine, but don't say my suggestion is *completely* wrong. Er, I was kidding. Point being, it's totally customizable. I guess I should have included a smiley face for your literal-minded self. rd -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 - iteration over non-sequence
Gary Herron wrote: So... You must explicitly read the contents of the file-like object yourself, and loop through the lines you self. However, fear not -- it's easy. The socket._fileobject object provides a method readlines that reads the *entire* contents of the object, and returns a list of lines. And you can iterate through that list of lines. Like this: import urllib2 url = urllib2.urlopen('http://www.google.com') for line in url.readlines(): print line url.close() This is really wasteful, as there's no point in reading in the whole file before iterating over it. To get the same effect as file iteration in later versions, use the .xreadlines method:: for line in aFile.xreadlines(): ... -- Erik Max Francis [EMAIL PROTECTED] http://www.alcyone.com/max/ San Jose, CA, USA 37 20 N 121 53 W AIM, Y!M erikmaxfrancis If you flee from terror, then terror continues to chase you. -- Benjamin Netanyahu -- http://mail.python.org/mailman/listinfo/python-list
Are there any python jobs worked at home from the internet?
Hi,all buddies. Are there any python jobs worked at home from the internet? I want to find a part time job. Please give a clue to this for me. Thanks a lot! -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 - iteration over non-sequence
Erik Max Francis [EMAIL PROTECTED] writes: This is really wasteful, as there's no point in reading in the whole file before iterating over it. To get the same effect as file iteration in later versions, use the .xreadlines method:: for line in aFile.xreadlines(): ... Ehhh, a heck of a lot of web pages don't have any newlines, so you end up getting the whole file anyway, with that method. Something like for line in iter(lambda: aFile.read(4096), ''): ... may be best. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get existing frames in non-current thread?
En Sat, 09 Jun 2007 21:40:40 -0300, Fabio Zadrozny [EMAIL PROTECTED] escribió: Is there some way to get all the frames for any given thread? -- in a way that does not require a compiled extension. For the current (calling) thread, you can use sys._getframe() For other threads, you can use sys._current_frames() Frames have a f_back attribute pointing to the previous one, that you can use to navigate them. Quoting http://docs.python.org/lib/module-sys.html sys._current_frames: Return a dictionary mapping each thread's identifier to the topmost stack frame currently active in that thread at the time the function is called. Note that functions in the traceback module can build the call stack given such a frame. This is most useful for debugging deadlock: this function does not require the deadlocked threads' cooperation, and such threads' call stacks are frozen for as long as they remain deadlocked. The frame returned for a non-deadlocked thread may bear no relationship to that thread's current activity by the time calling code examines the frame. This function should be used for internal and specialized purposes only. New in version 2.5. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Are there any python jobs worked at home from the internet?
En Sat, 09 Jun 2007 22:53:08 -0300, boyeestudio [EMAIL PROTECTED] escribió: Are there any python jobs worked at home from the internet? I want to find a part time job. Please give a clue to this for me. I know of http://www.rentacoder.com/ but I've never actually used it. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Third-party libs in version control
Good evening, I'm new to developing large subversion-controlled projects. This one will involve a few third-party libraries like wxWidgets, and perhaps Twisted. Ordinarily you could just install these into your system and they'll end up globally (in Python's Lib/site-packages directory). Is it proper practice to instead install the libraries into a separate [vendor branch] of the repository and reference that instead? I've read about vendor branches, and I'm under the impression that you're supposed to do that /instead/ of installing the libraries globally into Python's subdirectories... is that correct? Marcus -- http://mail.python.org/mailman/listinfo/python-list
Seattle Python Interest Group meeting 7 PM Thursday
Seattle Python Interest Group meeting 7 PM Thursday 14 June 2007. See http://www,seapig.org for location and directions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Seattle Python Interest Group meeting 7 PM Thursday
On Jun 9, 8:35 pm, James Thiele [EMAIL PROTECTED] wrote: Seattle Python Interest Group meeting 7 PM Thursday 14 June 2007. Seehttp://www,seapig.orgfor location and directions. Ooops! http://www.seapig.org -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 - iteration over non-sequence
Paul Rubin wrote: Erik Max Francis [EMAIL PROTECTED] writes: This is really wasteful, as there's no point in reading in the whole file before iterating over it. To get the same effect as file iteration in later versions, use the .xreadlines method:: for line in aFile.xreadlines(): ... Ehhh, a heck of a lot of web pages don't have any newlines, so you end up getting the whole file anyway, with that method. Something like for line in iter(lambda: aFile.read(4096), ''): ... may be best. Certainly there's are cases where xreadlines or read(bytecount) are reasonable, but only if the total pages size is *very* large. But for most web pages, you guys are just nit-picking (or showing off) to suggest that the full read implemented by readlines is wasteful. Moreover, the original problem was with sockets -- which don't have xreadlines. That seems to be a method on regular file objects. For simplicity, I'd still suggest my original use of readlines. If and when you find you are downloading web pages with sizes that are putting a serious strain on your memory footprint, then one of the other suggestions might be indicated. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list
Re: The Concepts and Confusions of Prefix, Infix, Postfix and Fully Functional Notations
On Jun 9, 8:21 pm, BCB [EMAIL PROTECTED] wrote: Paul McGuire [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Jun 9, 6:49 am, Lew [EMAIL PROTECTED] wrote: In particular, Perl code looks more like line noise than like code from any known programming language. ;)) Hmm - I know of APL and SNOBOL. -- Lew TECO editor commands. I don't have direct experience with TECO, but I've heard that a common diversion was to type random characters on the command line, and see what the editor would do. -- Paul J http://www.jsoftware.com/ Oh come on! Toy languages (such as any set of editor commands) and joke languages (ala Intercal) don't count, even if they are technically Turing-complete. ;) Nor does anything that was designed for the every-character-at-a- premium punch-card era, particularly if it is, or rhymes with, COBOL. Those have excuses, like it's a joke or it's a constrained environment. Perl, unfortunately, has no such excuses. If there were such a thing as embedded Perl, I'd have to hesitate here, but since there isn't... -- http://mail.python.org/mailman/listinfo/python-list
Re: MI5 Persecution: Goldfish and Piranha 29/9/95 (5104)
And this is here because ??? [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] |I just thought I'd let you know what I've been reading into the | Crusader spam. I don't want to post this to usenet because somebody | might try to tie that in to my posts in some way (someone already has, in | uk.misc). | | First of all, I'd like to ask you to believe that my phone line in my | apartment is bugged, and has been for many months. I have moved a couple | of times this year, but they have faithfully been on my trail. | | Anyway, let's suppose my phone line is bugged. Now, when I talk to my | internet service provider, it's over a SLIP (now PPP) connection. So if | you wanted to bug what was said, either you'd listen in over the line and | have to decode the transmission, or you could go to the service provider | (more difficult) and ask them to decode a particular user's connection. | | OK, so now they're listening to everything I do over my SLIP/PPP | connection. A couple of months ago I was messing around with faking | articles through nntp servers and through anonymous remailers. I chose a | nice inconspicuous newsgroup for my little tests, something no-one would | ever notice. Guess which newsgroup I chose??? Yes, _FISH_!!! or | rec.aquaria to be precise | | And guess what articles I tried to post? Goldfish, Koi carp and, you'll | never guess... PIRANHA!!! The goldfish article and the Koi went through, | but the piranha didn';t appear. | | by now you probably think this is too silly for words. But if you look in | the papers a few eeks ago you will find John Major, Tonny Blair and Paddy | Ashdown sharing a private joke about Major's sunburnt goldfish. We | haven't had anything about Koi yet (they must be too dull ). Now, sent by | someone who clearly knew what they were doing (they chose an Italian | backbone site for their launch point) we have many thousands of messages | to people all over the globe. All about piranha, and with the punchline | that gives you something to think about, doesn't it? | | The way it works is that they're trying to kill two birds with one stone | again. I don't knoiw why they should be against these national alliance | people, but my interpretation is that they simultaneously try to | discredit them, and stem the flow of Corley articles. | | = | | In article [EMAIL PROTECTED], | Mike Corley [EMAIL PROTECTED] wrote: | | John J Smith ([EMAIL PROTECTED]) wrote: | | : b) we do know who you are. Or are you someone else we don't know about? | : You are currently known as That bloody persistant net nutter, who's | : expanding from uk.misc to the rest of the world. | | I think the point I was trying to make is that I could tell you things | from my personal life, at home and at work, which would add credibility | to my story. But if I named people, then (a) they would object violently | to being included in this shenanigans, and (b) I would be revealing my | identity which would be bad for my personal life and my work life. Of | course some people in my personal life, and at work, do know who mike | corley is. But at least we're observing a studied silence for now. | | :People can always be called MR X, to save them being named. | : | :I'm completely perplexed as to what you mean by b). Revealing identity? | :To who? And why would this be bad for any part of your life when you | :already have a less than respectful reputation here? | | I'll just enumerate one or two things that I can still remember. Sometime | around August/Sept 1992 I was living in a house in Oxford, and coming out | of the house was physically attacked by someone - not punched, just grabbed | by the coat, with some verbals thrown in for good measure. That was something | the people at work shouldn't have known about... but soon after a couple of | people were talking right in front of me about, yeah, I heard he was | attacked. | | Again, one I went for a walk in some woods outside Oxford. The next day, | at work, someone said you know he went to the forest yesterday. | | I don't want to put details on usenet of what happened because to do so | would be to risk it happening again. If you put ideas in peoples' heads | then you can find them reflecting back at you, and I don't want that. | Also I can't remember that much from three years ago. From november 1992 | I started taking major tranquilizers and just blotted the whole thing | from my mind. | | This is a feature time and time again, that the security services | (presumed) get at you by manipulating other people around you to get at | you. If you have their contacts, manpower, resources and technology then | you can do that sort of thing. | | :But why? Are you a threat? | | They pretend they have to get at me. After the first few weeks they had | to find a reason to spy and abuse. You can't abuse someone unless they're | in
Re: read xml file from compressed file using gzip
On Jun 10, 3:45 am, Stefan Behnel [EMAIL PROTECTED] wrote: flebber wrote: I was working at creating a simple program that would read the content of a playlist file( in this case *.k3b) and write it out . the compressed *.k3b file has two file and the one I was trying to read was maindata.xml The k3b format is a ZIP archive. Use the zipfile library: file:///usr/share/doc/python2.5-doc/html/lib/module-zipfile.html Stefan Thanks for all the help, have been using the docs at python.org and the magnus t Hetland book. Is there any docs tha re a little more practical or expressive as most of the module documentation is very confusing for a beginner and doesn't provide much in the way of examples on how to use the modules. Not criticizing the docs as they are probably very good for experienced programmers. -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 - iteration over non-sequence
Gary Herron [EMAIL PROTECTED] writes: For simplicity, I'd still suggest my original use of readlines. If and when you find you are downloading web pages with sizes that are putting a serious strain on your memory footprint, then one of the other suggestions might be indicated. If you know in advance that the page you're retrieving will be reasonable in size, then using readlines is fine. If you don't know in advance what you're retrieving (e.g. you're working on a crawler) you have to assume that you'll hit some very large pages with difficult construction. -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug/Weak Implementation? popen* routines can't handle simultaneous read/write?
dmoore [EMAIL PROTECTED] wrote: On Jun 8, 12:30 pm, Nick Craig-Wood [EMAIL PROTECTED] wrote: Windows has a really strange idea of non-blocking IO - it uses something called overlapped io. You or in the FILE_FLAG_OVERLAPPED flag when you create the file/pipe. You then pass in overlap buffers for reading writing. the wx guys appear to do it differently (unless FILE_FLAG_OVERLAPPED is implicit in the calls they make) take a look at: http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/src/msw/utilsexc.cpp?rev=1.88content-type=text/vnd.viewcvs-markup a reasonably well-documented wxExecute function handles all the messy win32 api calls and wraps the process in a wxProcess object and the streams in wxInputStream / wxOutputStream (also see the wxExecuteDDE function) You are right, named pipes seem to have a non blocking mode. Here is the lowdown from http://msdn2.microsoft.com/en-US/library/aa365605.aspx Both pipe clients and pipe servers can change a pipe handle's wait mode by specifying either PIPE_WAIT or PIPE_NOWAIT in a call to the SetNamedPipeHandleState function. Note The nonblocking-wait mode is supported for compatibility with Microsoft® LAN Manager version 2.0. This mode should not be used to achieve overlapped input and output (I/O) with named pipes. Overlapped I/O should be used instead, because it enables time-consuming operations to run in the background after the function returns. For more information about overlapped I/O, see Synchronous and Overlapped Input and Output. So it has a nonblocking mode but you shouldn't use it! -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: 4 byte integer
Paul D Ainsworth [EMAIL PROTECTED] wrote: Greetings everyone. I'm a relative newcomer to python and I have a technical problem. I want to split a 32 bit / 4 byte unsigned integer into 4 separate byte variables according to the following logic: - bit numbers 0..7 byte 1 bit numbers 8..15 byte 2 bit numbers 16..23 byte 3 bit numbers 24..31 byte 4 Each of these byte variables to contain integer data from 0 to 255 (or 0 to FF in hex mode) I had thought that struct.unpack with an input message format of 'I' would be the way to do it, but its reporting an error that it doesn't want to accept an integer. Please can anyone advise? Would something like this work? def word2bytes(n): Given an positive integer n, return a tuple of 4 bytes from n's least significant 32-bits r = [] n = 0xL for i in range(4): r.append(n 0xFF) n = 8 r.reverse() return tuple(r) -- Jim Dennis, Starshine: Signed, Sealed, Delivered -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 - iteration over non-sequence
Gary Herron wrote: Certainly there's are cases where xreadlines or read(bytecount) are reasonable, but only if the total pages size is *very* large. But for most web pages, you guys are just nit-picking (or showing off) to suggest that the full read implemented by readlines is wasteful. Moreover, the original problem was with sockets -- which don't have xreadlines. That seems to be a method on regular file objects. For simplicity, I'd still suggest my original use of readlines. If and when you find you are downloading web pages with sizes that are putting a serious strain on your memory footprint, then one of the other suggestions might be indicated. It isn't nitpicking to point out that you're making something that will consume vastly more amounts of memory than it could possibly need. And insisting that pages aren't _always_ huge is just a silly cop-out; of course pages get very large. There is absolutely no reason to read the entire file into memory (which is what you're doing) before processing it. This is a good example of the principle of there is one obvious right way to do it -- and it isn't to read the whole thing in first for no reason whatsoever other than to avoid an `x`. -- Erik Max Francis [EMAIL PROTECTED] http://www.alcyone.com/max/ San Jose, CA, USA 37 20 N 121 53 W AIM, Y!M erikmaxfrancis The more violent the love, the more violent the anger. -- _Burmese Proverbs_ (tr. Hla Pe) -- http://mail.python.org/mailman/listinfo/python-list
[ python-Bugs-1732557 ] T_LONGLONG chokes on ints
Bugs item #1732557, was opened at 2007-06-06 23:23 Message generated for change (Comment added) made by rupole You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1732557group_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: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Roger Upole (rupole) Assigned to: Nobody/Anonymous (nobody) Summary: T_LONGLONG chokes on ints Initial Comment: Structmember attributes defined as T_LONGLONG or T_ULONGLONG won't accept a plain int, and give a misleading error msg: TypeError: bad argument type for built-in operation -- Comment By: Roger Upole (rupole) Date: 2007-06-09 01:52 Message: Logged In: YES user_id=771074 Originator: YES Submitted patch# 1733960 -- Comment By: Martin v. Löwis (loewis) Date: 2007-06-08 12:54 Message: Logged In: YES user_id=21627 Originator: NO Can you come up with a patch? -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1732557group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1729277 ] SVNVERSION redefined during compilation
Bugs item #1729277, was opened at 2007-06-01 04:28 Message generated for change (Settings changed) made by loewis You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1729277group_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: Build Group: Python 2.6 Status: Closed Resolution: Fixed Priority: 5 Private: No Submitted By: Brett Cannon (bcannon) Assigned to: Kristj�n Valur (krisvale) Summary: SVNVERSION redefined during compilation Initial Comment: I sometimes get the following warning during a build: ./Modules/getbuildinfo.c:23:1: warning: SVNVERSION redefined command line:1:1: warning: this is the location of the previous definition It looks like SVNVERSION is defined in getbuildinfo.c, but a value is also passed in on the command-line in the Makefile when the module is built (line 460). I have no clue why this is being done. -- Comment By: Kristj�n Valur (krisvale) Date: 2007-06-08 01:58 Message: Logged In: YES user_id=1262199 Originator: NO Applied the patch in change 55821, and backported to 25-maint in 55822 -- Comment By: Martin v. Löwis (loewis) Date: 2007-06-05 19:23 Message: Logged In: YES user_id=21627 Originator: NO Looks fine to me, please apply. -- Comment By: Kristj�n Valur (krisvale) Date: 2007-06-05 14:18 Message: Logged In: YES user_id=1262199 Originator: NO Here is a suggested patch. I don't have a linux setup to test with this, what do you think? Oh, and sorry for messing this up, I thought subwcrev was used on all platforms :( File Added: woo.patch -- Comment By: Martin v. Löwis (loewis) Date: 2007-06-05 09:50 Message: Logged In: YES user_id=21627 Originator: NO The define is indeed needed on Windows. On a Windows installation, there is typically no svnversion binary. However, TortoiseSVN ships with a similar tool, calls subwcrev.exe, which does string interpolation on a template file. So the define in getbuildinfo is the template, and the link process creates a second C file (getbuildinfo1.c) which is then compiled and linked into the interpreter. As subwcrev.exe might not be installed, the build process used to pass a define SUBWCREV on the command line, which was a condition to the definition of SVNVERSION. As Kristjan removed the condition, the Unix build broke. -- Comment By: Brett Cannon (bcannon) Date: 2007-06-04 23:30 Message: Logged In: YES user_id=357491 Originator: YES I figure that much from my experiment. What I am wondering is if the #define in getbuildinfo.c is needed. Does the Windows build need it? Or is it that just to guarantee that the file is self-supported and won't fail to compile if the compile-time define is not passed in? If the #define in the file is required then I vote for the #ifndef solution with an explanation. -- Comment By: Martin v. Löwis (loewis) Date: 2007-06-04 21:58 Message: Logged In: YES user_id=21627 Originator: NO SVNVERSION is passed on Unix. On Unix, there is no subwcrev program. Instead, there is an svnversion program which computes the same string as subwcrev, but prints it on stdout (rather than substituting it in some template file). Therefore, SVNVERSION needs to be passed on the command line. -- Comment By: Brett Cannon (bcannon) Date: 2007-06-04 21:41 Message: Logged In: YES user_id=357491 Originator: YES Well, when I remove the command-line def (the entire -D argument when building getbuildinfo.c) I get no subversion number out of sys.subversion. But when I comment out the SVNVERSION definition instead in getbuildinfo.c I do have the subversion number show up. And I just noticed that when both are defined I have no subversion number (as is the case in the trunk at the moment). I just wrapped the SVNVERSION definition in getbuildinfo.c in a #ifndef and that fixed the problem. but I don't know if doing that will just mask an issue where SVNVERSION should not be defined in getbuildinfo.c at all if it is being passed in during compilation. -- Comment By: Kristj�n Valur (krisvale) Date: 2007-06-04 11:46 Message: Logged In: YES user_id=1262199 Originator: NO The intent was to remove the reliance on the define SUBWCREV so to simplify the actions of make_buildinfo.c. It then only needs to either copy it or run it through subwcrev.exe. Now the code autodetects whether it was passed