Re: instancemethod
In <[EMAIL PROTECTED]>, Gert Cuykens wrote: >> > >gert.excecute('select * from person') >> > >for x in range(0,gert.rowcount): >> > >print gert.fetchone() >> > >gert.close() >> > > > […] > > python always seems to amaze me how other languages make a mess of > things that suppose to be simple It gets even simpler: cursor objects are iterable after the `execute()` call. So you don't need the number of rows:: gert.excecute('select * from person') for row in gert: print row gert.close() Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: class explorer for automating IE
The problem is that this does not run javascript code it seems. I got started with pamie, which seems to work till now. Thanks, --j On Jan 22, 2:42 am, Peter Otten <[EMAIL PROTECTED]> wrote: > John wrote: > > Is there an analogue of IE Mechanize in > > python?http://www.google.com/search?q=python%20mechanize&btnI=I%27m+Feeling+... -- http://mail.python.org/mailman/listinfo/python-list
Re: Win GUI application: avoiding DOS console
"Jarek Zgoda" wrote: > Siggi napisa³(a): > >> how do I avoid the DOS console show-up when starting a WinXP GUI >> application >> with mouseclick on the respective Python file? >> >> I had this with my previous Python installation; it is very simple, >> something with a "-i" somewhere in the open command of the MS Windows >> data >> types "PY" and "PYW". But after a new Python installation, this was lost, >> and I cannot find the instruction what to do. > > Run it using pythonw.exe instead of python.exe (check in file types > properties window). > > -- > Jarek Zgoda > http://jpa.berlios.de/ Thanks! siggi -- http://mail.python.org/mailman/listinfo/python-list
Re: Code reformater?
In <[EMAIL PROTECTED]>, Vincent Delporte wrote: > On Sun, 21 Jan 2007 14:15:46 +1100, Steven D'Aprano > <[EMAIL PROTECTED]> wrote: >>Still, it is better not to lose the indentation in the first place. > > Thanks for the tips. But it does happen when copy/pasting code from > either a web page or an e-mail that TABs are messed up, which is not a > problem with other languages, but is a problem with Python. Too bad. Well then don't use code from people using TABs. If it's indented by four spaces per level, like suggested by the style guide, there's no problem with TABs. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
newbie question
Hi, i wrote a simple script (which follows) to insert a table in the database.i could execute this query and get the result in python shell.but when i open "my sql enterprise manager" i couldnt find the table"animals".it would be so kind of you if someone could help me,,, import dbi import odbc conn=odbc.odbc("DSN=mydatabase;UID=xxx;PWD=yyy") cursor=conn.cursor() cursor.execute("Create table animals(parent char(50),child char(50))") cursor.execute("insert into animals values('lion','cub')") cursor.execute("insert into animals values('goat','lamb')") cursor.execute("select * from animals") print cursor.fetchall() Rgds Kavitha - Heres a new way to find what you're looking for - Yahoo! Answers -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Windows Editors
gonzlobo wrote: > I prefer PyScripter too, but would like to know if I can have > 'indentation guides' enabled like PythonWin allows. If you mean, typing a for-statement, then when placing the final ":"+Enter, the indentation auto increases, then the answer is yes, otherwise I don't kno what you mean. cheers, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: html + javascript automations = [mechanize + ?? ] or somethingelse?
"John" <[EMAIL PROTECTED]> wrote: > I tried it, didnt work with the python25 distribution msi file that is > on python.org > But activestate python worked. Now I can open IE using COM. What I am > trying > to figure out is how to click an x,y coordinate on a page in IE > automatically > using COM. How about typing something automatically...Any ideas? Don't think about clicking a coordinate or typing something; think about the actions on the page. e.g. to fill in a field on a form you'll want something like: ie.document.forms[formname][fieldname].value = 'whatever' to click a button call its click method e.g. submit = ie.document.forms[0]['submit'] submit.focus() submit.click() Check out the documentation at msdn.microsoft.com for the application, document, form etc. objects. Generally speaking anything you could have done through javascript you should be able to do through automation, plus a few of other things that javascript might have blocked for security reasons. -- http://mail.python.org/mailman/listinfo/python-list
Re: PyMeld for html templates?
[Sean] > The pymeld docs show examples only for the Python command line > interpreter and show using the print statement to output stuff. But > using mod_python.apache, I think you need to use req.write(something) > format. And of course, this fails when you feed it output from Meld. req.write(str(meld)) ? -- Richie Hindle [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: mmap caching
Martin v. Löwis <[EMAIL PROTECTED]> wrote: > In fact, memory that is read in because of mmap should *never* cause > a MemoryError. Python calls MapViewOfFile when mmap.mmap is invoked, > at which point the operating commits to providing that much address > space to the application, along with backing storage on disk > (typically, from the file being mapped, unless it is an anonymous > map). Later access to the mapped range cannot fail (except for > hardware errors), and if it would, you wouldn't see a MemoryError. So presumably it is python generating a MemoryError. It is asking for a new bit of memory and it is failing so it throws a MemoryError. Could memory allocation under windows be affected by a large chunk of mmap()ed file which is physically swapped in at the time of the allocation? -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: mmap caching
George Sakkis <[EMAIL PROTECTED]> wrote: > The file is written once and then opened as read-only, there's no > flushing. So if caching is completely up to the OS, I take it that my > options are either (1) modify my algorithms so that they work in > fixed-size batches instead of arbitrarily long sequences or (2) > implement my own memory-mapping scheme to fit my algorithms. I guess > (1) would be the less trouble overall, or is there a way to give a hint > to the OS on how large cache can it use ? The above behaviour isn't as expected. So either there is something going on in your program that we don't know about or there is a bug somewhere, either in the OS or in python. Can you make a short program to replicate the problem? That will help narrow down the problem. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: PQueue and Python 2.5
Gabriel Genellina wrote: > Python got in 2.3 a heapq module in its standard library; I think it is what > Ah! then I bet: > - There is some C code involved. > - It carelessly mixes PyMem_Malloc with PyObject_Free or similar as > described in > http://docs.python.org/whatsnew/ports.html > > So do yourself a favor and forget about such old piece of code... I would be happy to do so, but it does suit my needs quite well. :) But everybody thanks for pointing out the probable cause, I never did anything with C-extentions before, so I wasn't aware of the 2.5 changes. But I'll look into the code. Berteun -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie question
kavitha thankaian wrote: > Hi, > > i wrote a simple script (which follows) to insert a table in the > database.i could execute this query and get the result in python > shell.but when i open "my sql enterprise manager" i couldnt find the > table"animals".it would be so kind of you if someone could help me,,, > > > import dbi > import odbc > conn=odbc.odbc("DSN=mydatabase;UID=xxx;PWD=yyy") > cursor=conn.cursor() > cursor.execute("Create table animals(parent char(50),child char(50))") > cursor.execute("insert into animals values('lion','cub')") > cursor.execute("insert into animals values('goat','lamb')") > cursor.execute("select * from animals") > print cursor.fetchall() > > > Rgds > Kavitha > > You've probably missed cursor.commit() ;) -- Sincerely, Eugene Antimirov PortaOne, Inc., SIP Support Engineer [EMAIL PROTECTED] * For further Billing and Technical information: => Please visit our website http://www.portaone.com => Please visit our forum http://forum.portaone.com * Meet us at Internet Telephony Conference & Expo * Ft. Lauderdale, FL - January 24-26, 2007 - Booth 1322 * http://www.tmcnet.com/voip/conference/ -- http://mail.python.org/mailman/listinfo/python-list
Linking in a Linux environment
Bonjour, We have implemented Python as an "embedded script language" in our NLP application, XIP which a grammar rule engine written in C++ and available as a library. We have also developped a GUI in Java, which is linked to this XIP library, to simplify the development of NL grammars. JAVA GUI IDE Library: XIP (C++) Python Modules can be called from grammar rules Now we have the following problem, when we try to execute a Python script from a grammar in a Linux environment, the system fails when this Python module tries to import basic modules like "math" for instance. The system returns a "PyExc_OverflowException undefined variable" error. This problem only occurs on Linux platforms, we do not have any problems on Mac OS and on Windows. We have linked our NLP library with Python 2.4.4, and we have tried many different manipulations to solve this problem. We have tried to link with the static and the dynamic Python library, without any success. Searching the WEB, we have discovered similar problems, but none of the proposed solutions actually worked. For instance, some people wrote that the problem was to due to the compiling options of our Python library; we checked the Makefile for these options, which we found to be already there. We also tried to modify the dlopen options, as suggested, through the specific dlopen operations in the Python corresponding library. NOP... However, the use the Python 2.5 dynamic library seems to solve most of these problems, which would be ok, if people would accept to switch to a version that is quite new. Halas, this is not that simple... I still do not have any clear answer about what is going on. If someone could help me on this one, I'll be really grateful... :-) Merci d'avance, Claude -- http://mail.python.org/mailman/listinfo/python-list
Re: Py 2.5 on Language Shootout
Ramon Diaz-Uriarte wrote: >> In England the corresponding expression is "Counting Angels on a >> Pinhead" >> http://dannyayers.com/2001/misc/angels.htm >> > > Thanks, that is neat. I find the discussion on the sex of the angels, > well, sexier. But we are probably a few hundred years late to start a > catholic-protestant religious war here :-). > NOBODY expects the Spanish Inquisition! Our chief weapon is surprise...surprise and fear...fear and surprise. -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie question
Eugene Antimirov wrote: > You've probably missed cursor.commit() ;) Sorry, my bad: conn.commit() is correct one AFAIR. -- Sincerely, Eugene Antimirov PortaOne, Inc., SIP Support Engineer [EMAIL PROTECTED] * For further Billing and Technical information: => Please visit our website http://www.portaone.com => Please visit our forum http://forum.portaone.com * Meet us at Internet Telephony Conference & Expo * Ft. Lauderdale, FL - January 24-26, 2007 - Booth 1322 * http://www.tmcnet.com/voip/conference/ -- http://mail.python.org/mailman/listinfo/python-list
python grammar
Hello. In 'augop' non-terminal : http://docs.python.org/ref/augassign.html the delimiter '//=' was skipped. Why? In 'Boolean operations': http://docs.python.org/ref/Booleans.html In 'expression' rule - what does 'if', 'else' mean? I guess 'if' and 'else' must be keywords, not non-terminals. -- http://mail.python.org/mailman/listinfo/python-list
Getting to an SSH account over a HTTP proxy
I want to use Python to connect to a SSH account over a HTTP proxy to automate some operations. I thought paramiko would be able to do that, but it can not (it seems). Is there some other Python module that can do what I want? -- mvh Björn -- http://mail.python.org/mailman/listinfo/python-list
Re: pylab, matplotlib ... roots function question
Hi, [...] > No, that's actually wrong. What version of numpy are you using? With a recent > SVN checkout of numpy, I get the correct answer: > > In [3]: roots([1,0,0]) > Out[3]: array([ 0., 0.]) In [17]: import sys, numpy In [18]: sys.version Out[18]: '2.5 (r25:51908, Sep 23 2006, 01:23:14) \n[GCC 4.1.1]' In [19]: numpy.version.version Out[19]: '1.0rc1' moon:/pool/PROG/python # uname -a Linux moon 2.6.16.13-4-smp #1 SMP Wed May 3 04:53:23 UTC 2006 x86_64 x86_64 x86_64 GNU/Linux I think I will get and compile newer version of source BTW, I also look for good (more or less complete and/or interessting) tutoruals on signal processing with python something like low/high-pass filtering/ploting of wave files etc I would appreciate pointers very much. I am learning this at the moment, when it all starts to make sense to me, I will write such a tutorial on my own later Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: Frequency spectrum with fft of a real valued array...?
Hello Robert! Thank you for your tips. They were very useful. Bye Holger Am 11.01.2007, 19:08 Uhr, schrieb Robert Kern <[EMAIL PROTECTED]>: > Holger wrote: > >> What does it mean to me? How do I get to the wanted frequenca >> spectrum??? > > It's packed in the conventional FFT format. Here is a function in numpy > (the > successor to Numeric, which I assume that you are using) that generates > the > corresponding frequencies in the same packed format: > > In [324]: import numpy > > In [325]: numpy.fft.fftfreq? > Type: function > Base Class: > Namespace: Interactive > File: > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/numpy-1.0.2.dev3507-py2.5-macosx-10.4-i386.egg/numpy/fft/helper.py > Definition: numpy.fft.fftfreq(n, d=1.0) > Docstring: > fftfreq(n, d=1.0) -> f > > DFT sample frequencies > > The returned float array contains the frequency bins in > cycles/unit (with zero at the start) given a window length n and a > sample spacing d: > > f = [0,1,...,n/2-1,-n/2,...,-1]/(d*n) if n is even > f = [0,1,...,(n-1)/2,-(n-1)/2,...,-1]/(d*n) if n is odd > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting to an SSH account over a HTTP proxy
BJörn Lindqvist wrote: > I want to use Python to connect to a SSH account over a HTTP proxy to > automate some operations. I thought paramiko would be able to do that, > but it can not (it seems). > > Is there some other Python module that can do what I want? Is there anything that can do what you want? Last time I checked there is no such thing as SSH-over-HTTP. Are you sure that is possible? Diez -- http://mail.python.org/mailman/listinfo/python-list
Program eating memory, but only on one machine?
Hi Everybody: I'm having a difficult time figuring out a a memory use problem. I have a python program that makes use of numpy and also calls a small C module I wrote because part of the simulation needed to loop and I got a massive speedup by putting that loop in C. I'm basically manipulating a bunch of matrices, so nothing too fancy. That aside, when the simulation runs, it typically uses a relatively small amount of memory (about 1.5% of my 4GB of RAM on my linux desktop) and this never increases. It can run for days without increasing beyond this, running many many parameter set iterations. This is what happens both on my Ubuntu Linux machine with the following Python specs: Python 2.4.4c1 (#2, Oct 11 2006, 20:00:03) [GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy >>> numpy.version.version '1.0rc1' and also on my Apple MacBook with the following Python specs: Python 2.4.3 (#1, Apr 7 2006, 10:54:33) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import numpy >>> numpy.version.version '1.0.1.dev3435' >>> Well, that is the case on two of my test machines, but not on the one machine that I really wish would work, my lab's cluster, which would give me 20-fold increase in the number of processes I could run. On that machine, each process is using 2GB of RAM after about 1 hour (and the cluster MOM eventually kills them). I can watch the process eat RAM at each iteration and never relinquish it. Here's the Python spec of the cluster: Python 2.4.4 (#1, Jan 21 2007, 12:09:48) [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-49)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy >>> numpy.version.version '1.0.1' It also showed the same issue with the April 2006 2.4.3 release of python. I have tried using the gc module to force garbage collection after each iteration, but no change. I've done many newsgroup/google searches looking for known issues, but none found. The only major difference I can see is that our cluster is stuck on a really old version of gcc with the RedHat Enterprise that's on there, but I found no suggestions of memory issues online. So, does anyone have any suggestions for how I can debug this problem? If my program ate up memory on all machines, then I would know where to start and would blame some horrible programming on my end. This just seems like a less straightforward problem. Thanks for any help, Per -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting to an SSH account over a HTTP proxy
Diez B. Roggisch wrote: > BJörn Lindqvist wrote: > >> I want to use Python to connect to a SSH account over a HTTP proxy to >> automate some operations. I thought paramiko would be able to do that, >> but it can not (it seems). >> >> Is there some other Python module that can do what I want? > > Is there anything that can do what you want? Last time I checked there is no > such thing as SSH-over-HTTP. Are you sure that is possible? He's referring to the HTTP CONNECT method, which can tunnel arbitrary TCP connections, not just HTTP. The IETF draft for this is titled "Tunneling TCP based protocols through Web proxy servers". AFAIK, there are no Python modules which support that. The protocol itself is fairly simply though, so it shouldn't be too hard to write your own wrapper or proxy for the client side. Things get a little more complicated if you have to authenticate with the proxy first. -- http://mail.python.org/mailman/listinfo/python-list
GetBoundingMetrics
Hi, I have been moving from Windows XP to Debian Etch. Most of my Python scripts work fine with minor modifications. However, I have a script that launches a browser and goes to various sites using the Python module webbrowser.open ("url-goes-here") On Debian Etch, Firefox (or IceWeasel, I guess) opens the sites, but back in the commandline window I get repeated messages that say: GetBoundingMetrics (char *) Anybody know what's causing that? I don't get it if I just launch firefox from the commandline. Only when I use the Python module. Thank you, rd -- http://mail.python.org/mailman/listinfo/python-list
module check
Can anybody suggest a correct way of checking in python module exists and correctly installed from python program. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it possible to fasten the import of cgi?
On Thu, 18 Jan 2007 14:15:44 -0300, Gabriel Genellina <[EMAIL PROTECTED]> wrote: ... > I'll try to explain better: the cgi *protocol* (I'm not talking about the > cgi *module*) requires a *new* python process to be created on *each* > request. Try to measure the time it takes to launch Python, that is, the > time from when you type `python ENTER` on your shell and the interpreter > prompt appears. On my Mac Mini with all of Python on local disk: tuva:~> time python time python < /dev/null 0.028u 0.004s 0:00.02 100.0%0+0k 0+0io 0pf+0w tuva:~> I.e. about 200--300ms. I assume startup time >> shutdown time. If Python was at the other end of a NFS file system, much worse figures. /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: module check
I'm at work so I can't test this, but I do beleive the inspect module can help you out. If it can't you can always try import the module in a try-catch statement, catching ImportError, however ImportError may be raised if the module you imported has trouble loading another module, but it shouln't be to hard to track down where the ImportError came from, a traceback object can give a lot more information than you would beleive. Victor Polukcht wrote: > Can anybody suggest a correct way of checking in python module exists > and correctly installed from python program. -- http://mail.python.org/mailman/listinfo/python-list
Re: module check
I'm at work so I can't test this, but I do beleive the inspect module can help you out. If it can't you can always try import the module in a try-catch statement, catching ImportError, however ImportError may be raised if the module you imported has trouble loading another module, but it shouln't be to hard to track down where the ImportError came from, a traceback object can give a lot more information than you would believe. Victor Polukcht wrote: > Can anybody suggest a correct way of checking in python module exists > and correctly installed from python program. -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenOffice 2.0 UNO update Links; need help
Sells, Fred a écrit : > I've got a ~100 page document I assemble from ~30 OOo .odt files with some > search and replace functions. I then produce a PDF. So far so good. > > Now I need to get a barcode from our internal website and insert that. The > barcode will vary based on some parameters. Our internal site provides a > .jpg image (or .gif) based on those parameters. > > Can anyone provide a snippet or some pointers on how to do this. I've > googled it to death and checked the OOo DevGuide to no avail. > > Either python or java solution is acceptable. > > you can use urllib2 python module: # TestGoogle.py # import urllib2 # f = urllib2.urlopen('http://www.google.fr/images/nav_logo.png') data = f.read() f = file('nav_logo.png', 'w') f.write(data) f.close() in your case, may be parameters are passed thru url to get a particular barcode image (http://myserver/myapplication/barcode?format=xxx&id=yyy etc. ...). for authentication, if any, it needs a little more sophisticated coding. -- http://mail.python.org/mailman/listinfo/python-list
Re: Program eating memory, but only on one machine?
Per B. Sederberg wrote: > Python 2.4.4c1 (#2, Oct 11 2006, 20:00:03) > [GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on > [linux2 Type "help", "copyright", "credits" or "license" for > more information. Doesn't eat up. > Python 2.4.3 (#1, Apr 7 2006, 10:54:33) > [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin > Type "help", "copyright", "credits" or "license" for more > information. Doesn't eat up. > Python 2.4.4 (#1, Jan 21 2007, 12:09:48) > [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-49)] on linux2 > Type "help", "copyright", "credits" or "license" for more > information. Eats up memory > So, does anyone have any suggestions for how I can debug this > problem? Have a look at the version numbers of the GCC used. Probably something in your C code fails if it interacts with GCC 3.x.x. It's hardly Python eating memory, this is probably your C module. GC won't help here, since then you must add this into your C module. > If my program ate up memory on all machines, then I would know > where to start and would blame some horrible programming on my > end. This just seems like a less straightforward problem. GCC 3.x.x brings other runtime libs, than GCC 4.x.x, I would check into that direction. Wolfgang Draxinger -- E-Mail address works, Jabber: [EMAIL PROTECTED], ICQ: 134682867 -- http://mail.python.org/mailman/listinfo/python-list
Re: GetBoundingMetrics
BartlebyScrivener wrote: > I don't get it if I just launch > firefox from the commandline. Only when I use the Python module. I spoke too soon. I do get it from the command line if firefox is not already running. Same is true with the Python script. Must be a Gnome or Debian thing. Sorry for the distraction. rd -- http://mail.python.org/mailman/listinfo/python-list
Is there a better way to implement this:
Hello: I wrote the code below (much irrelevant code removed). This doesn't quite work. What I wanted it to do was a) Execute function ftimed, which takes a function and a timeout in seconds. b) This will also execute function abort() as a thread. This function just runs for the specified number of seconds and returns. However, before it returns, throws an exception. c) If test() is still running when abort() is finished, ftimed() should catch the exception and return. It is catching the exception, however it continues running the function. Why does it continue and not return? What am I missing, or is there a better way to implement this (having ftimed() return when the abort-timer time is exceeded? import time, thread, sys thread_finished = "MAX RUN TIME EXCEEDED!" def abort (seconds): start_time = time.time() while ((time.time() - start_time) < seconds): time.sleep(0.01) print "script run time exceeded max_run_time of", seconds, "seconds." raise thread_finished return def test(): i = 0 while (True): time.sleep(1) print "HELLO", i i+=1 def ftimed (func, seconds): thread.start_new_thread (abort, (seconds,)) try: func() except thread_finished: print "Timeout" return ftimed (test, 30) print "Script finished" It presently generates the following output: $ python ./testthread.py HELLO 0 HELLO 1 HELLO 2 HELLO 3 HELLO 4 HELLO 5 HELLO 6 HELLO 7 HELLO 8 HELLO 9 HELLO 10 HELLO 11 HELLO 12 HELLO 13 HELLO 14 HELLO 15 HELLO 16 HELLO 17 HELLO 18 HELLO 19 HELLO 20 HELLO 21 HELLO 22 HELLO 23 HELLO 24 HELLO 25 HELLO 26 HELLO 27 HELLO 28 HELLO 29 script run time exceeded max_run_time of 30 seconds. Unhandled exception in thread started by Traceback (most recent call last): File "./testthread.py", line 10, in abort raise thread_finished MAX RUN TIME EXCEEDED! HELLO 30 HELLO 31 HELLO 32 Thanks in advance: Michael Yanowitz -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenOffice 2.0 UNO update Links; need help
Sells, Fred wrote: > I've got a ~100 page document I assemble from ~30 OOo .odt files with some > search and replace functions. I then produce a PDF. So far so good. > > Now I need to get a barcode from our internal website and insert that. The > barcode will vary based on some parameters. Our internal site provides a > .jpg image (or .gif) based on those parameters. You can use pdftk to insert the barcode into the pdf. (No python and OOo involved) I think it is a very bad idea to use a jpg for the barcode. There are many libaries which provide EPS. If you need an image format, please use PNG. Jpeg is for images from a digital camera. Thomas -- Thomas Güttler, http://www.thomas-guettler.de/ http://www.tbz-pariv.de/ E-Mail: guettli (*) thomas-guettler + de Spam Catcher: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Program eating memory, but only on one machine?
Wolfgang Draxinger darkstargames.de> writes: > > > So, does anyone have any suggestions for how I can debug this > > problem? > > Have a look at the version numbers of the GCC used. Probably > something in your C code fails if it interacts with GCC 3.x.x. > It's hardly Python eating memory, this is probably your C > module. GC won't help here, since then you must add this into > your C module. > > > If my program ate up memory on all machines, then I would know > > where to start and would blame some horrible programming on my > > end. This just seems like a less straightforward problem. > > GCC 3.x.x brings other runtime libs, than GCC 4.x.x, I would > check into that direction. > Thank you for the suggestions. Since my C module is such a small part of the simulations, I can just comment out the call to that module completely (though I am still loading it) and fill in what the results would have been with random values. Sadly, the program still eats up memory on our cluster. Still, it could be something related to compiling Python with the older GCC. I'll see if I can make a really small example program that eats up memory on our cluster. That way we'll have something easy to work with. Thanks, Per -- http://mail.python.org/mailman/listinfo/python-list
Re: closing a "forever" Server Socket
thanks infact the server_forever() method is only a serve() method inside an infinite loop. many thanks again, Alessandro Matimus ha scritto: > > I want to ask if someone knows a better way for closing a "forever > > server" or if there is a lack in my design. > > Generally you don't create a 'forever server'. You create an 'until I > say stop' server. I would do this by looking at the 'serve_forever' > method, and implementing my own 'serve_until_?' method that is similar, > but will stop if a flag is set. Then you have to create a method for > setting that flag. It could be as simple as a keypress, or you could > add a quit method to your dispatcher that sets the flag when a certain > address is visited. That second method probably needs some added > security, otherwise anybody can just visit 'your.server.com/quit' and > shut it down. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a better way to implement this:
Michael Yanowitz wrote: > Hello: > >I wrote the code below (much irrelevant code removed). > This doesn't quite work. What I wanted it to do was > a) Execute function ftimed, which takes a function and a timeout > in seconds. > b) This will also execute function abort() as a thread. > This function just runs for the specified > number of seconds and returns. > However, before it returns, throws an exception. > c) If test() is still running when abort() is > finished, ftimed() should catch the exception and > return. > > It is catching the exception, however it continues running the function. > Why does it continue and not return? The exception is raised in the thread that executes the abort() function. The exception does not get caught and terminates this thread. The other (main) thread is unaffected - exceptions are local to a thread and there is currently no (portable) way to raise an exception in another thread. > What am I missing, or is there a better way to > implement this (having ftimed() return when the > abort-timer time is exceeded? You may use the signal.alarm() function, if you are on a UNIXoid system and you have only a signle time-out at a time (e.g. not nested). > import time, thread, sys > > thread_finished = "MAX RUN TIME EXCEEDED!" > > def abort (seconds): > start_time = time.time() > while ((time.time() - start_time) < seconds): > time.sleep(0.01) any reason for not using time.sleep(seconds) here? > print "script run time exceeded max_run_time of", seconds, "seconds." > raise thread_finished > return > > > def test(): > i = 0 > while (True): >time.sleep(1) >print "HELLO", i >i+=1 > > > def ftimed (func, seconds): > thread.start_new_thread (abort, (seconds,)) > > try: > func() > except thread_finished: > print "Timeout" > return > > ftimed (test, 30) > print "Script finished" -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://pink.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list
RE: Is there a better way to implement this:
Thanks. I suppose I could have used time.sleep(seconds) here. I did it in 0.01 because in an earlier verion, I did something else between the sleeps. I guess I am looking for something portable (both Windows and Linux) where I can abort a function after a certain time limit expires. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Benjamin Niemann Sent: Monday, January 22, 2007 11:19 AM To: python-list@python.org Subject: Re: Is there a better way to implement this: Michael Yanowitz wrote: > Hello: > >I wrote the code below (much irrelevant code removed). > This doesn't quite work. What I wanted it to do was > a) Execute function ftimed, which takes a function and a timeout > in seconds. > b) This will also execute function abort() as a thread. > This function just runs for the specified > number of seconds and returns. > However, before it returns, throws an exception. > c) If test() is still running when abort() is > finished, ftimed() should catch the exception and > return. > > It is catching the exception, however it continues running the function. > Why does it continue and not return? The exception is raised in the thread that executes the abort() function. The exception does not get caught and terminates this thread. The other (main) thread is unaffected - exceptions are local to a thread and there is currently no (portable) way to raise an exception in another thread. > What am I missing, or is there a better way to > implement this (having ftimed() return when the > abort-timer time is exceeded? You may use the signal.alarm() function, if you are on a UNIXoid system and you have only a signle time-out at a time (e.g. not nested). > import time, thread, sys > > thread_finished = "MAX RUN TIME EXCEEDED!" > > def abort (seconds): > start_time = time.time() > while ((time.time() - start_time) < seconds): > time.sleep(0.01) any reason for not using time.sleep(seconds) here? I suppose I could have, but in earlier versions > print "script run time exceeded max_run_time of", seconds, "seconds." > raise thread_finished > return > > > def test(): > i = 0 > while (True): >time.sleep(1) >print "HELLO", i >i+=1 > > > def ftimed (func, seconds): > thread.start_new_thread (abort, (seconds,)) > > try: > func() > except thread_finished: > print "Timeout" > return > > ftimed (test, 30) > print "Script finished" -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://pink.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: closing a "forever" Server Socket
alessandro írta: > thanks > > infact the server_forever() method is only a serve() method inside an > infinite loop. > > many thanks again, > Here is a snipped that show a "software terminateable threading TCP socker server". The "server" object is a SocketServer instance, server_stopped is a threading.Event instance. You should also import the "select" module. srvfd = server.fileno() while not server_stopped.isSet(): ready = select.select([srvfd], [], [], 1) # Give one second for incoming connection so we can stop the server in seconds if srvfd in ready[0]: server.handle_request() else: pass # log('No incoming connection, retrying') -- http://mail.python.org/mailman/listinfo/python-list
Re: closing a "forever" Server Socket
Oh my God! it's really so complicated? 3 modules (threading, SocketServer, select) only for design a way to shutdown a TCP server ...but they told me that python was easy... :) I'm working on a simulator and I have a monitor server that collects information. I can shutdown it using Ctrl-C from the keyboard but for my purpose could be very nice if I introduce a timer. So I could launch my monitor like this: ./monitor 100 and my monitor will run for 100 seconds. For this I'm using the Timer class provided by threading module, I have implemented a function like this: def shutdown(): sys.exit() but it doesen't work because the server remain alive...maybe SocketServer create immortal server... I need only to close my application, there is a way to force the server thread to close? thanks! Alessandro Laszlo Nagy ha scritto: > alessandro írta: > > thanks > > > > infact the server_forever() method is only a serve() method inside an > > infinite loop. > > > > many thanks again, > > > Here is a snipped that show a "software terminateable threading TCP > socker server". The "server" object is a SocketServer instance, > server_stopped is a threading.Event instance. You should also import the > "select" module. > > srvfd = server.fileno() > while not server_stopped.isSet(): > ready = select.select([srvfd], [], [], 1) # Give one second > for incoming connection so we can stop the server in seconds > if srvfd in ready[0]: > server.handle_request() > else: > pass # log('No incoming connection, retrying') -- http://mail.python.org/mailman/listinfo/python-list
Re: Program eating memory, but only on one machine?
I had a similar problem with an extension module on Solaris years ago. My problem at that time: I requested memory and released it and requested more memory in the next step and so on. The reason that the memory was eaten up: An answer out of this group was that the operating system doesn't release the memory space because it assumes you will need it soon again. The memory will only be released with the end of the process. The solution was always to request memory for the largest array the process will demand and it worked for me. Regards Wolfgang Per B.Sederberg wrote: > Wolfgang Draxinger darkstargames.de> writes: >>> So, does anyone have any suggestions for how I can debug this >>> problem? >> Have a look at the version numbers of the GCC used. Probably >> something in your C code fails if it interacts with GCC 3.x.x. >> It's hardly Python eating memory, this is probably your C >> module. GC won't help here, since then you must add this into >> your C module. >> >>> If my program ate up memory on all machines, then I would know >>> where to start and would blame some horrible programming on my >>> end. This just seems like a less straightforward problem. >> GCC 3.x.x brings other runtime libs, than GCC 4.x.x, I would >> check into that direction. >> > > Thank you for the suggestions. Since my C module is such a small part of the > simulations, I can just comment out the call to that module completely > (though I > am still loading it) and fill in what the results would have been with random > values. Sadly, the program still eats up memory on our cluster. > > Still, it could be something related to compiling Python with the older GCC. > > I'll see if I can make a really small example program that eats up memory on > our > cluster. That way we'll have something easy to work with. > > Thanks, > Per > > > -- http://mail.python.org/mailman/listinfo/python-list
SQLObject 0.7.3b1
Hello! I'm pleased to announce the 0.7.3b1 release of SQLObject. What is SQLObject = SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, and Firebird. It also has newly added support for Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject == Site: http://sqlobject.org Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://cheeseshop.python.org/pypi/SQLObject/0.7.3b1 News and changes: http://sqlobject.org/docs/News.html What's New == Bug Fixes - * Allow multiple MSSQL connections. * Psycopg1 requires port to be a string; psycopg2 requires port to be an int. * Fixed a bug in MSSQLConnection caused by column names being unicode. * Fixed a bug in FirebirdConnection caused by column names having trailing spaces. * Fixed a missed import in firebirdconnection.py. * Remove a leading slash in FirebirdConnection. For a more complete list, please see the news: http://sqlobject.org/docs/News.html Oleg. -- Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED] Programmers don't die, they just GOSUB without RETURN. -- http://mail.python.org/mailman/listinfo/python-list
SQLObject 0.8.0b2
Hello! I'm pleased to announce the 0.8.0b2 release of SQLObject. What is SQLObject = SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, and Firebird. It also has newly added support for Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject == Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://cheeseshop.python.org/pypi/SQLObject/0.8.0b2 News and changes: http://sqlobject.org/devel/News.html What's New == News since 0.8.0b1 -- * Another round of bugfixes for MySQL errors 2006 and 2013 (SERVER_GONE, SERVER_LOST). * Fixed a bug in MSSQLConnection caused by column names being unicode. * Fixed a bug in FirebirdConnection caused by column names having trailing spaces. * Remove a leading slash in FirebirdConnection. For a more complete list, please see the news: http://sqlobject.org/devel/News.html Oleg. -- Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED] Programmers don't die, they just GOSUB without RETURN. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a better way to implement this:
Michael Yanowitz wrote: > >I guess I am looking for something portable (both > Windows and Linux) where I can abort a function after > a certain time limit expires. Doing a search for "timeout function Python" on Google reveals a number of approaches. Using signals: * http://nick.vargish.org/clues/python-tricks.html * http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/307871 Using threads: * http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/473878 Using processes: * http://lfw.org/python/delegate.html Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Is any python like linux shell?
In article <[EMAIL PROTECTED]>, James Stroud <[EMAIL PROTECTED]> wrote: ... > Paddy wrote:' > > Frank, > > IPython is great, but it is not a replacement for a shell like bash. If > > you have a Linux system then you still need to know the rudiments of > > bash > > Or better yet, csh. ;) Careful, someone will think you're serious. -- http://mail.python.org/mailman/listinfo/python-list
Re: closing a "forever" Server Socket
alessandro írta: > Oh my God! it's really so complicated? > > 3 modules (threading, SocketServer, select) only for design a way to > shutdown a TCP server > ...but they told me that python was easy... :) > I believe that SockerServer was created for testing purposes, although there are some programs using it in production. Yes, Python is easy. The language is very clear, and you do not need to install third party modules in order to create a server. :-) Of course the easiest way is to call serve_forever. Isn't it easy? The other way is to implement your own message handling loop. The SocketServer is flexible enough to do this; and I don't think it is complicated. 7 lines of code will allow you to stop the server safely from anywhere, even from other threads. Try to implement the same in C or Delphi... > but it doesen't work because the server remain alive...maybe > SocketServer create immortal server... > I need only to close my application, there is a way to force the server > thread to close? > In pure Python, no. Python threads are "cooperative". In other words, they cannot be terminated from outside. A thread will stop after the execution exits its "run" method. (You can, of course terminate the tread with an operating system function, but it is not recommended.) Here is a class that can be stopped with an event: import threading stop_requested = threading.Event() class SoftWaitThread(threading.Thread): """SoftWaitThread can wait for a given time except if the thread was asked to terminate itself.""" def waitsome(self,amount=10): """Wait the specified amount of time. This can be terminated by stop_requested within 0.1 seconds.""" for idx in range(int(10*amount)): time.sleep(0.1) if stop_requested.isSet(): break Then you can do this: class MyServerThread(SoftWaitThread): def run(self): server = MySocketServerClass() srvfd = server.fileno() while not stop_requested.isSet(): ready = select.select([srvfd], [], [], 1) if srvfd in ready[0]: server.handle_request() else: pass And then: import time def main(): sth = MyServerThread() # Create your thread sth.start() # Start handling requests in another thread try: time.sleep(TIMEOUT_IN_SECONDS) # Wait... finally: stop_requested.set() # Request the server thread to stop itself sth.join() # Wait until the server thread stops print "Stopped." You could start several threads and request them to stop with the same event. I hope this helps. Laszlo p.s.: Not all of the above was tested, be careful. -- http://mail.python.org/mailman/listinfo/python-list
(newbie) new version install (winXP) ?
I've been started with Python on winXP, by installing the "Enthought" edition (about half a year old). This works like a charm. As a regular windows user, I'm not used to install partial packages. Now I find interesting application, that require higher versions of certain packages. Can I install only the higher version of a certain package ? Is that done by simply copying them ? Should I make a backup (of what) ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Best way to document Python code...
I am working on a Python module and I would like to prepare some API documentaiton. I managed to find epydoc after some searching online. Is there a standard way to document the API for Python modules? Is epydoc the best way to go if there is no standard? Are there other ways to document a Python API? Thanks, Scott Huey -- http://mail.python.org/mailman/listinfo/python-list
Re: (newbie) new version install (winXP) ?
At Monday 22/1/2007 15:58, you wrote: Can I install only the higher version of a certain package ? Is that done by simply copying them ? You should read the install instructions given in the package, but usually it's as easy as: - extract the .zip into a temporary directory - open a command line window, go to that directory, and run: - python setup.py install Should I make a backup (of what) ? Perhaps... -- Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: closing a "forever" Server Socket
At Monday 22/1/2007 14:49, alessandro wrote: Oh my God! it's really so complicated? 3 modules (threading, SocketServer, select) only for design a way to shutdown a TCP server ...but they told me that python was easy... :) You already have the answer: replace serve_forever with your own loop. I'm working on a simulator and I have a monitor server that collects information. I can shutdown it using Ctrl-C from the keyboard but for my purpose could be very nice if I introduce a timer. So I could launch my monitor like this: ./monitor 100 and my monitor will run for 100 seconds. For this I'm using the Timer This is simple enough, I presume: try: stopt = time.time()+100 while time.time()The drawback is that it won't leave the loop until a request arrives, but this may not be a problem for you. (Other suggestions are more complicated because of this issue.) -- Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: instancemethod
Gert Cuykens a écrit : > import MySQLdb > > class Db: (snip) >def excecute(self,cmd): >self._cursor.execute(cmd) >self._db.commit() > What about autocommit and automagic delegation ? import MySQLdb class Db(object): def __init__(self,server, user, password, database): self._db = MySQLdb.connect(server , user , password , database) self._db.autocommit(True) self._cursor = self._db.cursor() def close(self): self._cursor.close() self._db.close() def __del__(self): try: self.close() except: pass def __getattr__(self, name): attr = getattr( self._cursor, name, getattr(self._db, name, None) ) if attr is None: raise AttributeError( "object %s has no attribute %s" \ % (self.__class__.__name__, name) ) return attr (NB :not tested...) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Windows Editors
W. Watson napisał(a): > I downloaded python-2.5.msi and installed it. I believe its editor is > IDE. I understand there's a Win editor called pythonwin. I believe it's > in the download pywin32-210.win32-py2.5.exe, but I'm not sure if this > exe file has just the editor or all of Python. Comments? If not how do I > get the PythonWin editor by itself? No, there's no "single official Python editor or IDE". You can edit Python code in any editor you want. When I was on Windows, I used to use jEdit (http://www.jedit.org/) or Vim (http://www.vim.org/), but others will give you other advices. Any text editor is only as good as the programmer who uses it. ;) -- Jarek Zgoda http://jpa.berlios.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Program eating memory, but only on one machine? (Solved, sort of)
Per B.Sederberg princeton.edu> writes: > I'll see if I can make a really small example program that eats up memory on > our cluster. That way we'll have something easy to work with. Now this is weird. I figured out the bug and it turned out that every time you call numpy.setmember1d in the latest stable release of numpy it was using up a ton of memory and never releasing it. I replaced every instance of setmember1d with my own method below and I have zero increase in memory. It's not the most efficient of code, but it gets the job done... def ismember(a,b): ainb = zeros(len(a),dtype=bool) for item in b: ainb = ainb | (a==item) return ainb I'll now go post this problem on the numpy forums. Best, Per -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Windows Editors
Any text editor is only as good as the > programmer who uses it. ;) > Yes but an IDE is different ;-) cheers, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLObject 0.8.0b2
Where is Oracle support? -- http://mail.python.org/mailman/listinfo/python-list
Are there sprintf in Python???
Are there any sprintf in Python? I know you can print to files(or redefine sys.stout) and later open the file content. Are there similar function to sprintf in C? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Are there sprintf in Python???
"questions?" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Are there any sprintf in Python? > I know you can print to files(or redefine sys.stout) and later > open the file content. > > Are there similar function to sprintf in C? Something like this? x = 9 vbl = "One digit: %d, four digits: %04d" % (x,x) print vbl -- http://mail.python.org/mailman/listinfo/python-list
Re: mmap caching
Dennis Lee Bieber wrote: > On 21 Jan 2007 13:32:19 -0800, "George Sakkis" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > > > The file is written once and then opened as read-only, there's no > > flushing. So if caching is completely up to the OS, I take it that my > > How large is said file? While the OS should handle swapping pages as > needed, you do have to recall that those pages are /mapped/ into the > process virtual address space. Trying to mmap a 2GB file into a process > that is already using 1GB of memory may not work (what is the default > Windows split? 2GB process and 2GB shared OS?) It's around 400MB. As I said, I cannot reproduce the MemoryError locally since I have 1GB physical space but IIRC the user who reported it had less. Actually I am less concerned about whether a MemoryError is raised or not in this case and more about the fact that even if there's no exception, the program may suffer from severe thrashing due to constant swapping. That's an issue with the specific program/algorithm rather with Python or the OS. George -- http://mail.python.org/mailman/listinfo/python-list
Re: Does eval has the same features as Perl's?
The python editor won't "get exit." It will raise an exception. With or without an eval, you can catch the exception. try: x = 1/0 except ZeroDivisionError: x = "infinity" Jm lists wrote: > Hello members, > > I want to know does the "eval" in python have the same features as in > Perl (capture errors)? > > For example,in perl I can wrote: > > $re = eval { 1 / 0 }; > > Though 1/0 is a fatal error but since it's in "eval" block so the perl > interpreter doesn't get exit. > > Thanks again. -- http://mail.python.org/mailman/listinfo/python-list
Re: Program eating memory, but only on one machine? (Solved, sort of)
Per B.Sederberg wrote: > Per B.Sederberg princeton.edu> writes: > >> I'll see if I can make a really small example program that eats up memory on >> our cluster. That way we'll have something easy to work with. > > Now this is weird. I figured out the bug and it turned out that every time > you > call numpy.setmember1d in the latest stable release of numpy it was using up a > ton of memory and never releasing it. Hmm. With a recent checkout from SVN, I don't see any memory increase. In [15]: from numpy import * In [16]: ar1 = arange(100) In [17]: ar2 = arange(3, 7) In [18]: import itertools In [19]: for i in itertools.count(1): :if not i % 1000: :print i :x = setmember1d(ar1, ar2) -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: mmap caching
> In fact, memory that is read in because of mmap should *never* cause > a MemoryError. This is certainly not true. You can run out of virtual address space by reading data from a memory mapped file. > Python calls MapViewOfFile when mmap.mmap is invoked, > at which point the operating commits to providing that much address > space to the application, along with backing storage on disk > (typically, from the file being mapped, unless it is an anonymous > map). Later access to the mapped range cannot fail (except for > hardware errors), and if it would, you wouldn't see a MemoryError. > Hmm, maybe I'm wrong. Are you sure that Windows allocates the size of the whole file in terms of memory address space? I also wrote a program before (in Delphi). That program was playing a memory mapped wave file. From the task manager, I have seen that "used memory" was growing as the program was playing the wave file. For me, this indicates that Windows extends the mapped address space in chunks. Regards, Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: mmap caching
> It's around 400MB. As I said, I cannot reproduce the MemoryError > locally since I have 1GB physical space but IIRC the user who reported > it had less. Actually I am less concerned about whether a MemoryError > is raised or not in this case and more about the fact that even if > there's no exception, the program may suffer from severe thrashing due > to constant swapping. That's an issue with the specific > program/algorithm rather with Python or the OS. > Well, if the same program runs when you have 1GB physical memory then probably the problem is not that you ran out of virtual address space. It would help to provide the related code from your program. Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLObject 0.8.0b2
Robert Hicks said the following on 22.1.2007 21:02: > Where is Oracle support? > What about DB2 UDB and DB2/400 >:o -- Dejan Rodiger - PGP ID 0xAC8722DC Delete wirus from e-mail address -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to document Python code...
Scott Huey wrote: > I am working on a Python module and I would like to prepare some API > documentaiton. I managed to find epydoc after some searching online. > > Is there a standard way to document the API for Python modules? Is > epydoc the best way to go if there is no standard? Are there other ways > to document a Python API? > > Thanks, > > Scott Huey > The "standard" is to use docstrings i.e., class MyModule: """ This module does something """ def someMethod(self): """ This method does something, accepts args/returns value etc. """ Then one way to view the docstrings is to start a python shell, import your module, and do help(MyModule) i.e., module: mymodule.py class: MyModule do in the shell: import mymodule help(mymodule.MyModule) Then Python will generate a quick help interface for your module. I suspect epydoc uses docstrings but I *may* be wrong, since I have never used epydoc. But a quick look at pydoc (not to be confused with epydoc) which is part of the standard library allows you to generate documentation in HTML format, and/or serve it over web with its built-in HTTP server. pydoc: http://docs.python.org/lib/module-pydoc.html Hope this helps. Adonis -- http://mail.python.org/mailman/listinfo/python-list
AES and Credit card number encryption
I browsed this subject and thought I might use the 'AES' cypher scheme to do this. Would this be a good choice? I came across a "Python Cryptography Toolkit" http://www.amk.ca/python/code/crypto which has a nice AES implementation, but in the example, a simple string is passed as the key: obj=AES.new('abcdefgh', AES.ECB) So my real question is, how do I go about generating the best key. Isn't the length supposed to be a 2^n bits, and soforth? Thanks, Tobiah -- Posted via a free Usenet account from http://www.teranews.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to document Python code...
Adonis Vargas wrote: > Then Python will generate a quick help interface for your module. I Hi Does Python has API just like in Java, for example http://java.sun.com/j2se/1.5.0/docs/api/allclasses-noframe.html ctrl-f and than click on class you are searching for, and finally you get clean list of all fields and methods. Where can I find similar in Python, for example, if I would like to see which methods list/dictionary has. -- "kad imaš 7 godina glup si ko kurac, sve je predobro: autići i bageri u kvartu.. to je život" Drito Konj -- http://mail.python.org/mailman/listinfo/python-list
Re: Is any python like linux shell?
On Sun, 21 Jan 2007 22:10:17 -0800, James Stroud <[EMAIL PROTECTED]> wrote: > Frank Potter wrote: >> I learned some python in windows. >> And now I've turned to linux. >> I read a book and it teaches how to write shell script with bash, >> but I don't feel like the grammar of bash. ... > My strongest advice would be to let go of the idea of "shell scripting" > altogether and begin to write programs built from libraries to solve > your problems. Shell scripting is "building from libraries". In this case, other executables are the libraries. > The mere act of beginning to write a shell script (in, > say, bash) will tie you to that "language", In what way is shell scripting different from Python scripting here? > even when you realize your > task was much more complex than you had originally imagined. It has > happened to me time and time again. Opinions differ, of course. Me, I don't hesitate to write Bourne shell scripts when that seems like the straightforward idea. Then it's my responsibility to move to something else -- usually Python -- if the problem grows out of its language. (And I have to admit, I don't let it grow very complex before I make that choice, because I don't known Bourne shell that well.) /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: instancemethod
Reading all of the above this is the most simple i can come too. import MySQLdb class Db: def __init__(self,server,user,password,database): self._db=MySQLdb.connect(server , user , password , database) self._db.autocommit(True) self.cursor=self._db.cursor() def excecute(self,cmd): self.cursor.execute(cmd) self.rowcount=int(self.cursor.rowcount) def close(self): self.cursor.close() self._db.close() def __del__(self): try: self.close() except: pass if __name__ == '__main__': gert=Db('localhost','root','**','gert') gert.excecute('select * from person') for row in gert.cursor: print row This must be the most simple it can get right ? PS i didn't understand the __getattr__ quit well but i thought it was just to overload the privies class -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting to an SSH account over a HTTP proxy
On Mon, 22 Jan 2007 14:40:49 +0100, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > BJörn Lindqvist wrote: > >> I want to use Python to connect to a SSH account over a HTTP proxy to >> automate some operations. I thought paramiko would be able to do that, >> but it can not (it seems). >> >> Is there some other Python module that can do what I want? > > Is there anything that can do what you want? Last time I checked there is no > such thing as SSH-over-HTTP. Are you sure that is possible? I am pretty sure there is. Or at least TCP-over-HTTP, or IP-over-HTTP. An acquaintance of mine used it to tonnel home through a corporate firewall. I think -- I didn't want to know the details. If you implement in the same way as ssh tunnels, the application doesn't need to know anything about it -- you just talk to a TCP port on localhost. Good for everyone involved. /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to document Python code...
Boris Ozegovic: > Does Python has API just like in Java, for example > http://java.sun.com/j2se/1.5.0/docs/api/allclasses-noframe.html ctrl-f and > than click on class you are searching for, and finally you get clean list > of all fields and methods. Where can I find similar in Python, for > example, if I would like to see which methods list/dictionary has. You can do that from the shell, with help(name) or dir(name), where name can be a class, object, most things. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to document Python code...
At Monday 22/1/2007 17:48, Boris Ozegovic wrote: Does Python has API just like in Java, for example http://java.sun.com/j2se/1.5.0/docs/api/allclasses-noframe.html ctrl-f and than click on class you are searching for, and finally you get clean list of all fields and methods. Where can I find similar in Python, for example, if I would like to see which methods list/dictionary has. Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. py> help(dict) Help on class dict in module __builtin__: class dict(object) | dict() -> new empty dictionary. | dict(mapping) -> new dictionary initialized from a mapping object's | (key, value) pairs. | dict(seq) -> new dictionary initialized as if via: | d = {} | for k, v in seq: | d[k] = v | dict(**kwargs) -> new dictionary initialized with the name=value pairs | in the keyword argument list. For example: dict(one=1, two=2) | | Methods defined here: | | __cmp__(...) | x.__cmp__(y) <==> cmp(x,y) | | __contains__(...) You should skip at first magic __methods__. You can use help() with any object, or language keyword: help("if") py> import math py> help(math) Help on built-in module math: NAME math FILE (built-in) DESCRIPTION This module is always available. It provides access to the mathematical functions defined by the C standard. FUNCTIONS acos(...) acos(x) Return the arc cosine (measured in radians) of x. [...] -- Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Building extensions with vc8
Has there been any progress on being able to build extensions with MSVC8 (aka Visual Studio 2005)? Since the "free" compiler from Microsoft is now VC8, I *assume* this will be the new method. 2.5 itself rebuilds using PCbuild8, as do tkinter (but using Tcl 8.4.14 and Tk 8.4.14) however none of the distutils-generated extensions will build. -- http://mail.python.org/mailman/listinfo/python-list
Re: mmap caching
Laszlo Nagy schrieb: > >> In fact, memory that is read in because of mmap should *never* cause >> a MemoryError. > This is certainly not true. You can run out of virtual address space by > reading data from a memory mapped file. That is true, but not what I said. I said you cannot run out of memory *while reading it*. You can only run out of virtual address space when you invoke mmap.mmap itself (and when the application later tries to allocate more virtual address space through VirtualAlloc). >> Python calls MapViewOfFile when mmap.mmap is invoked, >> at which point the operating commits to providing that much address >> space to the application, along with backing storage on disk >> (typically, from the file being mapped, unless it is an anonymous >> map). Later access to the mapped range cannot fail (except for >> hardware errors), and if it would, you wouldn't see a MemoryError. >> > Hmm, maybe I'm wrong. Are you sure that Windows allocates the size of > the whole file in terms of memory address space? Yes, I am. See MapViewOfFile, at http://msdn2.microsoft.com/en-us/library/aa366761.aspx "Mapping a file makes the specified portion of a file visible in the address space of the calling process." Notice allocating address space doesn't consume much memory (it consumes a little memory for the page tables). > I also wrote a program > before (in Delphi). That program was playing a memory mapped wave file. > From the task manager, I have seen that "used memory" was growing as the > program was playing the wave file. For me, this indicates that Windows > extends the mapped address space in chunks. You are misinterpreting the data. I'm not sure what precisely "used memory" is, most likely it is the working set of the process, i.e. the amount the number of physical pages that are allocated for the process. That is typically much smaller than the address space, since many pages will be paged out (or not yet read in at all). You need to display the virtual address space in the task manager to determine how much address space the application is using. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: AES and Credit card number encryption
Tobiah <[EMAIL PROTECTED]> writes: > I browsed this subject and thought I might use the 'AES' cypher > scheme to do this. Would this be a good choice? There's more to it than that, but yes, AES is a good underlying algorithm. > So my real question is, how do I go about generating the best key. > Isn't the length supposed to be a 2^n bits, and soforth? AES key length is your choice of 128, 192, or 256 bits. In practice 128 bits (16 bytes) is fine and is what most people use. You should use 16 completely random bytes. Get these by reading them from os.urandom(16), which is provided for basically this purpose. -- http://mail.python.org/mailman/listinfo/python-list
Re: mmap caching
Nick Craig-Wood schrieb: > So presumably it is python generating a MemoryError. It is asking for > a new bit of memory and it is failing so it throws a MemoryError. > > Could memory allocation under windows be affected by a large chunk of > mmap()ed file which is physically swapped in at the time of the > allocation? To my knowledge, no. There might be virtual memory quotas, but I don't think Windows supports such a concept. More likely, this is entirely unrelated to the mmap issue. I would guess that the machine on which the problem occurs is close to exhausting its swap file (because of other activities in the system), so Python occasionally manages to exhaust the swap file, through regular allocations (memory-mapped files don't contribute to swap file usage, as they have their own disk-backing, namely in the file being mapped). Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
How to convert a string into an integer
Can you please tell me why the following code does not work in python? My guess is I need to convert 'count' from a string to an integer. How can I do that? And my understanding is python is a dynamic type language, should python convert it for me automatically? count = sys.argv[2] for i in range(count): #do some stuff Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to convert a string into an integer
> count = sys.argv[2] > for i in range(count): > #do some stuff for i in range(int(count)): -- Posted via a free Usenet account from http://www.teranews.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Building extensions with vc8
Howard Lightstone schrieb: > Has there been any progress on being able to build extensions with MSVC8 > (aka Visual Studio 2005)? No. No progress will happen throughout the release of Python 2.5. To get the facts straight: it *might* be possible to build an extension with msvc8 (thus linking with msvcr8.dll); this should work as long as the extension doesn't use any API that is forbidden for the mixed-CRT case. Only a source inspection of the extension module can tell whether there is any risky code. > Since the "free" compiler from Microsoft is now VC8, I *assume* this will > be the new method. Your assumption is wrong; this isn't officially supported. > 2.5 itself rebuilds using PCbuild8, as do tkinter (but using Tcl 8.4.14 and > Tk 8.4.14) however none of the distutils-generated extensions will build. If you built Python 2.5 yourself with VS 2005, you should be able to build extension modules as well with distutils, by setting MSSdk and DISTUTILS_USE_SDK appropriately. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Windows Editors
Stef Mientki napisał(a): > Any text editor is only as good as the >> programmer who uses it. ;) >> > Yes but an IDE is different ;-) Would it make me better Fortran programmer? ;) -- Jarek Zgoda http://jpa.berlios.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: mmap caching
George Sakkis wrote: > It's around 400MB. On Windows you may not be able to map a file of this size into memory because of virtual address space fragmentation. A Win32 process has only 2G of virtual address space, and DLLs tend to get scattered through out that address space. > As I said, I cannot reproduce the MemoryError > locally since I have 1GB physical space but IIRC the user who reported > it had less. Virtual address space fragmentation isn't affected by the amount of physical memory in your system. A system with 64MB of RAM might be able to map a 400MB file while system with 3G of RAM might not be able to map it because of how DLLs got loaded in to the process. > Actually I am less concerned about whether a MemoryError > is raised or not in this case and more about the fact that even if > there's no exception, the program may suffer from severe thrashing due > to constant swapping. Well, that's what you're asking for when you use mmap. The same mechanism that creates virtual memory using a swap file is used to create a virtual memory mapping of your file. When you read from the mmap file pages from the file a swapped into memory and stay in memory until they need to be swapped out to make room for something else. If you don't want this behaviour, don't use mmap. Ross Ridge -- http://mail.python.org/mailman/listinfo/python-list
Re: How to convert a string into an integer
[EMAIL PROTECTED] wrote: > Can you please tell me why the following code does not work in python? > My guess is I need to convert 'count' from a string to an integer. How > can I do that? > And my understanding is python is a dynamic type language, should > python convert it for me automatically? > > count = sys.argv[2] > for i in range(count): > #do some stuff > > Thank you. You are confusing dynamic typing with weak typing. Weakly typed languages (such as BASIC perform) such implicit conversions. However, Python is dynamically and strongly typed. With dynamic typing, the type information resides with the actual object and not with the name referring to it. That simply means that the type cannot be determined till the object is actually created (i.e till runtime). But once created, the object does have a type. So you will need to explicitly convert yourself. In this case with int_value = int(string_value) Ravi Teja. -- http://mail.python.org/mailman/listinfo/python-list
How to use time.clock() function in python
Hi, I am following this python example trying to time how long does an operation takes, like this: My question is why the content of the file (dataFile) is just '0.0'? I have tried "print >>dataFile, timeTaken" or "print >>dataFile,str( timeTaken)", but gives me 0.0. Please tell me what am I missing? t1 = time.clock() os.system(cmd) outputFile = str(i) + ".png" t2 = time.clock() timeTaken = t2 - t1 allTimeTaken += timeTaken print >>dataFile, timeTaken -- http://mail.python.org/mailman/listinfo/python-list
beep or sound playing under linux
Hi, Is there a way to do that ? Regards, hg -- http://mail.python.org/mailman/listinfo/python-list
Re: How to use time.clock() function in python
At Monday 22/1/2007 19:05, [EMAIL PROTECTED] wrote: I am following this python example trying to time how long does an operation takes, like this: My question is why the content of the file (dataFile) is just '0.0'? I have tried "print >>dataFile, timeTaken" or "print >>dataFile,str( timeTaken)", but gives me 0.0. Please tell me what am I missing? t1 = time.clock() os.system(cmd) outputFile = str(i) + ".png" t2 = time.clock() timeTaken = t2 - t1 allTimeTaken += timeTaken print >>dataFile, timeTaken time.clock() may not give you enough precision; see this recent post http://mail.python.org/pipermail/python-list/2007-January/422676.html Use the timeit module instead. -- Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: How to use time.clock() function in python
On Mon, 22 Jan 2007 14:05:16 -0800, [EMAIL PROTECTED] wrote: > Hi, > > I am following this python example trying to time how long does an > operation takes, like this: > > My question is why the content of the file (dataFile) is just '0.0'? > I have tried "print >>dataFile, timeTaken" or "print >>dataFile,str( > timeTaken)", but gives me 0.0. > Please tell me what am I missing? > > > t1 = time.clock() > os.system(cmd) > > outputFile = str(i) + ".png" > > t2 = time.clock() > > timeTaken = t2 - t1 > allTimeTaken += timeTaken > print >>dataFile, timeTaken For the correct way to time operations, see the timeit module. For your specific problem, it is hard to tell what you are doing wrong when you don't tell us what "datafile" is. What's "outfile" for? It gets created *after* the command runs, but doesn't get used. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to document Python code...
On Mon, 22 Jan 2007 20:40:57 +, Adonis Vargas wrote: > But a quick look at pydoc (not to be confused with epydoc) > which is part of the standard library allows you to generate > documentation in HTML format, and/or serve it over web with its built-in > HTTP server. > > pydoc: http://docs.python.org/lib/module-pydoc.html > > Hope this helps. > > Adonis The HTML generated by pydoc doesn't link to standard modules properly. They are generated as relative links. So it can't be used without modification for generating docs for a web page about a python package. I'm struggling with the same issue. Coding Python is so much easier than Java. However documenting Java is so much easier than Python. Just include doc comments, run javadoc, and voila! -- Stuart D. Gathman <[EMAIL PROTECTED]> Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flamis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Windows Editors
Jarek Zgoda wrote: > Stef Mientki napisał(a): > >> Any text editor is only as good as the >>> programmer who uses it. ;) >>> >> Yes but an IDE is different ;-) > > Would it make me better Fortran programmer? ;) > I can't judge for you, ... ... maybe you are already at the top ;-) I can only speak for myself ... ... for beginners an IDE is certainly much much more than an editor. cheers, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: beep or sound playing under linux
hg wrote: > Hi, > > Is there a way to do that ? > > Regards, > > hg PS: I'm actually under wpPython -- http://mail.python.org/mailman/listinfo/python-list
Re: module check
Victor Polukcht wrote: > Can anybody suggest a correct way of checking in python module exists > and correctly installed from python program. > Not sure I understand the question, but I'll try: try: import yourmodule except: print "Can't import yourmodule" -Larry -- http://mail.python.org/mailman/listinfo/python-list
arrow keys don't work
I've noticed that in Python 2.5, the interactive prompt does not support intelligent use of arrow keys like 2.4 did (up/down for previous/next statement, left/right for moving the cursor). What exactly is the reason for this and is there an easier fix than downgradinig to 2.4? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: beep or sound playing under linux
hg wrote this on Mon, Jan 22, 2007 at 04:12:50PM +0100. My reply is below. > Is there a way to do that? (Make noise.) In Gnome there is: gtk.gdk.beep() -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 28° — Wind WSW 10 mph — Sky overcast. -- http://mail.python.org/mailman/listinfo/python-list
Re: arrow keys don't work
tac-tics wrote: > I've noticed that in Python 2.5, the interactive prompt does not > support intelligent use of arrow keys like 2.4 did (up/down for > previous/next statement, left/right for moving the cursor). What > exactly is the reason for this and is there an easier fix than > downgradinig to 2.4? Thanks. Your installation of 2.4 probably had the readline module installed while your installation of 2.5 doesn't. What platform are you on? -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: beep or sound playing under linux
In <[EMAIL PROTECTED]>, hg wrote: > Is there a way to do that ? Maybe this helps: http://paste.pocoo.org/show/316/ Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
How to get self reference from within a module?
Hi, i would like to now how to get a self reference from within a module. The goal is to be able to generate a list of all declared function within the module. Thanks, Erick -- http://mail.python.org/mailman/listinfo/python-list
Re: How to use time.clock() function in python
Thanks. I have a fuction called 'func1'. def func1: # logic of the function When my script just call 'func1()' it works. func1() But when put it under timerit.Timer, like this: t = timeit.Timer("func1()","") t.repeat(1, 10) # want to time how long it takes to run 'func1' 10 times, I get an error like this: File "/usr/lib/python2.4/timeit.py", line 188, in repeat t = self.timeit(number) File "/usr/lib/python2.4/timeit.py", line 161, in timeit timing = self.inner(it, self.timer) File "", line 6, in inner NameError: global name 'func1' is not defined I don't understand why i can't find 'func1', when I call the function 'func1' directly, it works. but why when I call it within 'timeit', it can't find it? Thank you. Gabriel Genellina wrote: > At Monday 22/1/2007 19:05, [EMAIL PROTECTED] wrote: > > >I am following this python example trying to time how long does an > >operation takes, like this: > > > >My question is why the content of the file (dataFile) is just '0.0'? > >I have tried "print >>dataFile, timeTaken" or "print >>dataFile,str( > >timeTaken)", but gives me 0.0. > >Please tell me what am I missing? > > > > > > t1 = time.clock() > > os.system(cmd) > > > > outputFile = str(i) + ".png" > > > > t2 = time.clock() > > > > timeTaken = t2 - t1 > > allTimeTaken += timeTaken > > print >>dataFile, timeTaken > > time.clock() may not give you enough precision; see this recent post > http://mail.python.org/pipermail/python-list/2007-January/422676.html > Use the timeit module instead. > > > -- > Gabriel Genellina > Softlab SRL > > > > > > > __ > Preguntá. Respondé. Descubrí. > Todo lo que querías saber, y lo que ni imaginabas, > está en Yahoo! Respuestas (Beta). > ¡Probalo ya! > http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLObject 0.8.0b2
Oleg Broytmann wrote: > Hello! > > I'm pleased to announce the 0.8.0b2 release of SQLObject. > > > What is SQLObject > = > > SQLObject is an object-relational mapper. Your database tables are described > as classes, and rows are instances of those classes. SQLObject is meant to be > easy to use and quick to get started with. > > SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, and > Firebird. It also has newly added support for Sybase, MSSQL and MaxDB (also > known as SAPDB). > > > Where is SQLObject > == > > Site: > http://sqlobject.org > > Development: > http://sqlobject.org/devel/ > > Mailing list: > https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss > > Archives: > http://news.gmane.org/gmane.comp.python.sqlobject > > Download: > http://cheeseshop.python.org/pypi/SQLObject/0.8.0b2 > > News and changes: > http://sqlobject.org/devel/News.html > > > What's New > == > > News since 0.8.0b1 > -- > > * Another round of bugfixes for MySQL errors 2006 and 2013 (SERVER_GONE, > SERVER_LOST). > > * Fixed a bug in MSSQLConnection caused by column names being unicode. > > * Fixed a bug in FirebirdConnection caused by column names having trailing > spaces. > > * Remove a leading slash in FirebirdConnection. > > For a more complete list, please see the news: > http://sqlobject.org/devel/News.html > > Oleg. This project has an amazingly impressive pace of development: 10:20 AM : "SQLObject 0.7.3b1" 10:22 AM : "SQLObject 0.8.0b2" But I'm wondering, why is it taking so long for SQLObject 0.8.7b3? James -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get self reference from within a module?
Lavoie Érick wrote: > Hi, > > i would like to now how to get a self reference from within a > module. The goal is to be able to generate a list of all declared > function within the module. > > Thanks, > > Erick I think this is what you're asking for: If you import a module, say import sys then sys is an object you can refer to. Like man objects in Python, you can do some ,so called, introspection. For instance you can ask for the list of all the attributes (function, classes, and such) with the vars builtin print vars(sys) That yields a dictionary of all objects in the module, from which you can access and iterate through the names (keys) and values. If you want more capabilities, you should also look at the inspect module. Gary Herron -- Gary Herron, PhD. Department of Computer Science DigiPen Institute of Technology (425) 895-4418 -- http://mail.python.org/mailman/listinfo/python-list
Re: arrow keys don't work
Robert Kern wrote: > tac-tics wrote: > > I've noticed that in Python 2.5, the interactive prompt does not > > support intelligent use of arrow keys like 2.4 did (up/down for > > previous/next statement, left/right for moving the cursor). What > > exactly is the reason for this and is there an easier fix than > > downgradinig to 2.4? Thanks. > > Your installation of 2.4 probably had the readline module installed while your > installation of 2.5 doesn't. What platform are you on? Actually, I should have posted this a while ago. I've noticed it on Ubuntu Linux, Mac OSX, and earlier today on Sun Solaris. What do I need to do to install / configure readline? -- http://mail.python.org/mailman/listinfo/python-list
Re: arrow keys don't work
On Mon, 22 Jan 2007 14:53:01 -0800, tac-tics wrote: > I've noticed that in Python 2.5, the interactive prompt does not > support intelligent use of arrow keys like 2.4 did (up/down for > previous/next statement, left/right for moving the cursor). It works perfectly for me. > What > exactly is the reason for this and is there an easier fix than > downgradinig to 2.4? Thanks. Have you changed your terminal (either the program itself or its config) so that it is no longer sending the correct codes? When you hit the arrow key, what happens? Do you just get nothing at all, or do you get control characters appearing? e.g. ^Z or similar. -- Steven D'Aprano -- http://mail.python.org/mailman/listinfo/python-list
Re: How to use time.clock() function in python
On Mon, 22 Jan 2007 15:32:58 -0800, samuel.y.l.cheung wrote: > File "/usr/lib/python2.4/timeit.py", line 188, in repeat > t = self.timeit(number) > File "/usr/lib/python2.4/timeit.py", line 161, in timeit > timing = self.inner(it, self.timer) > File "", line 6, in inner > NameError: global name 'func1' is not defined > > I don't understand why i can't find 'func1', when I call the function > 'func1' directly, it works. > but why when I call it within 'timeit', it can't find it? Because the code in timeit is running in a different namespace. You have to import your function first. That's what the setup parameter is used for. Here's the hard way: t = timeit.Timer("func1()", """def func1(): #do something here return result """) Here's the easy way: t = timeit.Timer("func1()", "from __main__ import func1") -- Steven D'Aprano -- http://mail.python.org/mailman/listinfo/python-list
Re: arrow keys don't work
> Have you changed your terminal (either the program itself or its config) > so that it is no longer sending the correct codes? I doubt this is the case. Everything works for the bash shell and common lisp. It's just python acting up. > When you hit the arrow key, what happens? Do you just get nothing at all, > or do you get control characters appearing? e.g. ^Z or similar. udlr yields ^[[A^[[B^[[C^[[D in the interactive python interpreter, but like I said, works like it should outside the Python interpreter. -- http://mail.python.org/mailman/listinfo/python-list
Re: arrow keys don't work
It looks like I got readline working. Thanks for the help! -- http://mail.python.org/mailman/listinfo/python-list