Re: Calling Python from Matlab
> "AgenteSegreto" == AgenteSegreto <[EMAIL PROTECTED]> writes: AgenteSegreto> I've been a Matlab user for years and have recently AgenteSegreto> started using Python with matplotlib and NumPy for AgenteSegreto> most of my work. The only thing I found that is AgenteSegreto> still lacking is a 3D capability in matplotlib. I There is some progress being made on this front -- in svn are a collection of classes for basic 3d plots (plot3, mesh, surf) but the interface to these is still under development. We hope they will be included in the next major release 0.88. You can see some examples here: http://www.scipy.org/Wiki/Cookbook/Matplotlib/mplot3D Also, there is a master's student who will be working on extending mpl 3d capabilities as part of her master's project, so expect some basic functionality in the near future. We certainly don't aim to compete with VTK or other full-blown 3D solutions like Mayavi http://mayavi.sourceforge.net/ http://www.enthought.com/enthought/wiki/MayaVi http://www.scipy.org/ArndBaecker/MayaVi2 but most agree it would be nice to have some support for basic 3D plotting in matplotlib. JDH -- http://mail.python.org/mailman/listinfo/python-list
Re: filling today's date in a form
Lawrence D'Oliveiro wrote: > In article <[EMAIL PROTECTED]>, Kun <[EMAIL PROTECTED]> > wrote: > > >>... but i am >>wondering if there is a way to create a button which would automatically >>insert today's date in the date form field if the user chooses to use >>today's date. > > > If you're going to have a button to do it, then the button might as well > invoke a JavaScript sequence to fill in the field. No sense bothering > the server with something this simple. If JavaScript is enabled, the following example will do what the OP wants: function getDate() { alert("getting date..."); var d = new Date(); var s = d.toLocaleString(); alert(s); return s; } function setDate() { alert("Setting date"); document.getElementById("myDate").value = getDate(); } Date: However, if JS is not enabled (as I often surf, given how requisite JS is for many attack vectors and popups...thank goodness for the NoScript plugin for FireFox which allows me to whitelist sites allowed to use JS), your only hope is to round-trip the server where your CGI/mod_python/whatever script is sitting generating the page. Or populate the field by default (using 'value="1/2/03"' attribute on your textbox) when creating the field and let the user change it if needed. The ideal is to prepopulate the field to the most frequently used value so that the user has as little work to do as possible. You'll find some great tools on JavaScript over at the http://www.w3schools.com site where you can experiment with their TryIt editor. That will at least allow you to tinker with the JS. You haven't provided enough details regarding your web-scripting environment (Django, CGI, TG, mod_python...) -tkc -- http://mail.python.org/mailman/listinfo/python-list
Queue can result in nested monitor deadlock
I think there's a slight design flaw in the Queue class that makes it hard to avoid nested monitor deadlock. The problem is that the mutex used by the Queue is not easy to change. You can then easily get yourself into the following situation (nested monitor deadlock): Say we have a class that contains a Queue and some other things. The class's internals are protected by a mutex M. Initially the Queue is empty. The only access to the queue is through this class. Thread 1 locks M, then calls Queue.get(). It blocks. At this point the Queue's mutex is released, but M is still held. Thread 2 tries to put something in the Queue by calling the enclosing class's methods, but it blocks on M. Deadlock. The solution would be to expose the Queue's mutex via a constructor argument and/or method, so that, to take the above example, one could create M and give it to the Queue as its mutex. Of course this is doable now, as the code below demonstrates. But it should be documented and exposed. As I'm new to the Python community, I'm not sure that this is the right forum for this suggestion. Is it the sort of thing one would put on the SourceForge bug list? Advice appreciated. "Fixed" Queue class: class LQueue(Queue.Queue): """ Fixes a problem with the standard Queue implementation: you can't use your own mutex, so you are subject to nested monitor deadlock. This version lets you pass in your own lock. """ def __init__(self, maxsize=0, lock=None): "Optionally takes a lock (threading.Lock or threading.RLock) to use for the queue's lock." Queue.Queue.__init__(self, maxsize) if lock: self.mutex = lock # Re-create the condition objects with the new mutex. self.not_empty = threading.Condition(self.mutex) self.not_full = threading.Condition(self.mutex) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python certification/training
aum wrote: > > Makes me wonder, just out of curiosity - are there any universities > actually teaching python (in anything bigger than a small elective > module), or are they all still owned by Java, C++, C# and Visual Basic? > like NLTK, maybe? http://www.ldc.upenn.edu/sb/home/papers/nltk.pdf -- http://mail.python.org/mailman/listinfo/python-list
Re: any update to this?
Hi Mickle. A quick search on the www.python.org site leads to: http://wiki.python.org/moin/LanguageComparisons The thing about language comparisons are that they are all subjective/biased. Best to read other things by the author to know 'where they are coming from'. Oh, and check the dates of the articles. Its also good to go to Perl/Ruby/TCL/C++... sites and see what they have for comparisons to Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: any update to this?
[EMAIL PROTECTED] wrote: > hi > i was looking at this : > http://www.python.org/doc/essays/comparisons.html > on comparisons of python and other languages? are there any updates to > this doc? or is there > other reliable source for such comparison elsewhere? thanks lots of blogs out there, check artima, C2.com, http://reddit.com/search?q=python+lisp http://del.icio.us/tag/python+lisp -- http://mail.python.org/mailman/listinfo/python-list
Re: Queue can result in nested monitor deadlock
Jonathan Amsterdam <[EMAIL PROTECTED]> wrote: ... > As I'm new to the Python community, I'm not sure that this is the right > forum for this suggestion. Is it the sort of thing one would put on the > SourceForge bug list? Advice appreciated. Posting a patch and/or bug to Sourceforge is probably the best approach. Alex -- http://mail.python.org/mailman/listinfo/python-list
SSL client authentication
Hi everybody, I'm developing a distributed application in Python and I intend to use SOAP over a SSL connection. I looked at the SOAPpy package and it seems to have all I need but client authentication; in other words I want my client certificate be sent to the server during the SSL handshake. SOPApy.SOPAServer has ssl_context to use the private key and certificate of the server but the client side SOAPProxy doesn't seem to take such context. I was wondering if this is due to httplib.HTTPS (used by SOAPProxy) not performing any certificate verification, according to the httplib.py sources. Any hints? -- http://mail.python.org/mailman/listinfo/python-list
Java Developer Exploring Python
I've traditionally been a Java developer, although I play around with LISP. I recently migrated to Linux and I was exploring Mono as an option for development on Linux. However, I've had some problems with the maturity and support when working with Mono. So I was considering Python as an alternative development language. Is Python actively developed and supported on Linux? Would it be a viable option for cross-platform application development? Can anyone recommend an open source IDE for Python that runs on Linux? Thanks, Scott Huey -- http://mail.python.org/mailman/listinfo/python-list
Re: Queue can result in nested monitor deadlock
"Jonathan Amsterdam" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I think there's a slight design flaw in the Queue class that makes it > hard to avoid nested monitor deadlock. The problem is that the mutex > used by the Queue is not easy to change. You can then easily get > yourself into the following situation (nested monitor deadlock): > > Say we have a class that contains a Queue and some other things. The > class's internals are protected by a mutex M. Initially the Queue is > empty. The only access to the queue is through this class. > > Thread 1 locks M, then calls Queue.get(). It blocks. At this point the > Queue's mutex is released, but M is still held. > > Thread 2 tries to put something in the Queue by calling the enclosing > class's methods, but it blocks on M. Deadlock. > This isn't really a deadlock, it is just a blocking condition, until Thread 1 releases M. There are 3 requirements for deadlock: 1. Multiple resources/locks 2. Multiple threads 3. Out-of-order access You have definitely created the first two conditions, but the deadlock only occurs if Thread 2 first acquires the Queue lock, then needs to get M before continuing. By forcing all access to the Queue through the class's methods, which presumably lock and unlock M as part of their implementation, then you have successfully prevented 3. No deadlocks, just proper blocking/synchronization. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Queue can result in nested monitor deadlock
If you don't want to call it deadlock, fine, but the program execution I describe will make no progress to the end of time. Thread 2 can never put anything in the queue, because Thread 1 holds M, and Thread 1 will never release M because that can only happen if someone puts something on the queue. -- http://mail.python.org/mailman/listinfo/python-list
MySql -python 1.2.1_p2 and visual c++ toolkit
Hi. I'm trying to use Python 2.4 with MySql 5.0, but I'm having installation problems. I've tried to follow the following articles to install mysql-python with the free visual c++ toolkit http://mail.python.org/pipermail/python-list/2004-December/255184.html http://www.vrplumber.com/programming/mstoolkit/ but when I'm trying to install mysql-python, I get the following errors : C:\Python24\Lib\site-packages\MySQL-python-1.2.1_p2>python setup.py install running install running build running build_py copying MySQLdb\release.py -> build\lib.win32-2.4\MySQLdb running build_ext building '_mysql' extension C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -Ic:\python24\include -Ic:\python24\PC /Tc_mysql.c /Fobuild\te mp.win32-2.4\Release\_mysql.obj -Dversion_info="(1,2,1,'final',2)" -D__version__ ="1.2.1_p2" _mysql.c c:\Python24\include\structmember.h(73) : warning C4005: 'WRITE_RESTRICTED' : mac ro redefinition C:\Program Files\Microsoft Platform SDK for Windows XP SP2\Include\WinNT .h(4727) : see previous definition of 'WRITE_RESTRICTED' _mysql.c(1350) : warning C4018: '<' : signed/unsigned mismatch _mysql.c(2804) : error C2015: too many characters in constant _mysql.c(2804) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int' _mysql.c(2808) : error C2059: syntax error : 'bad suffix on number' _mysql.c(2808) : error C2440: 'function' : cannot convert from 'double' to 'cons t char *' _mysql.c(2808) : warning C4024: 'PyString_FromString' : different types for form al and actual parameter 1 _mysql.c(2808) : error C2143: syntax error : missing ')' before 'constant' error: command '"C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin\cl.exe"' failed with exit status 2 It failes on the second line here : if (PyDict_SetItemString(dict, "version_info", PyRun_String(version_info, Py_eval_input, dict, dict))) As I'm new to python, I cant really figure out what the error is. The C2015 error states that I'm trying to pass a char* where a char is needed. version_info is, as far as I can see, defined in metadata.cfg as version_info: (1,2,1,'final',2) Still this doeasnt tell me much.. I hope that someone can help me with this problem. -- http://mail.python.org/mailman/listinfo/python-list
Re: Java Developer Exploring Python
>> I've traditionally been a Java developer, although I play around with LISP. For most java developers, understanding dynamic typing is a big step. Your Lisp background however would mean that you will pick up Python very quickly. >> I recently migrated to Linux and I was exploring Mono as an option for development on Linux. However, I've had some problems with the maturity and support when working with Mono. IronPython (still a beta) BTW, runs on Mono as well and you can use Mono through Python when you deem it ready. There is also Jython, which runs on the Java platform if you feel married to Java platform or class libraries. >> Is Python actively developed and supported on Linux? Yes and very well so. Many Linux distributions come with Python pre-installed and Python has quite a bit of following in the Linux crowd. Red Hat / Fedora installer - Anaconda, for example uses Python. >> Would it be a viable option for cross-platform application development? Python is a very good candidate for open source development. But then again, most open source languages these days are. The culture is a bit different though. Although Python is byte code compiled just like Java, Python programmers are not averse to using native extensions (which in most cases can be compiled painlessly on all popular platforms thanks to Python's distutils). Java programmers on the other hand generally extol 'Pure Java'. Both approaches have their own advantages and disadvantages (Swing vs SWT) and you can use either with Python. >> Can anyone recommend an open source IDE for Python that runs on Linux? Most Python IDEs are open source along with a few commercial ones. http://wiki.python.org/moin/IntegratedDevelopmentEnvironments Everyone has their favorites and you should pick your own. Since you have a Java background, PyDev is probably the best choice for you. JEdit also has a Python plugin. I just use SciTE (just an editor) most of the time. -- http://mail.python.org/mailman/listinfo/python-list
Re: Fixing Python instalation in win2000 by hand
BartlebyScrivener wrote: > > You may want to try disabling any anti-virus software you have running > as they > frequently cause software installation failures. NONE!! > > MSI Installers have a known issue with mapped network drives; please > copy the > installer to the c:\ root drive and try running the installation again. > > If you are using the NTFS file system, please make sure that the SYSTEM > account has full rights over the target installation directory, the > directory > containing the installer file, AND the Windows Installer directory, > located at > either c:\WINNT\Installer\ (WINNT 4 / Windows 2000) or > c:\Windows\Installer\ > (Windows XP). Since I have not formated this drive (C:) it happens to be NTFS. SYSTEM account??? what's that, where do I manage that? When I was trying to share these drives in the past with linux, I would often run into a message similar to "cannot share drive as main-c drive already shared for system 'something' (C$)" > > This may be the result of an altered Windows Scripting Host > installation. The > best workaround is to reinstall this Windows component. > > Windows Scripting Host can be downloaded from: > http://www.microsoft.com/downloads/details.aspx?FamilyID=c717d943-7e4b-4622-86eb-95a22b832caa&DisplayLang=en > > ( for Windows 200 / XP ) > > or Genuine validation? lol this should be interesting. > > http://www.microsoft.com/downloads/details.aspx?FamilyID=0a8a18f6-249c-4a72-bfcf-fc6af26dc390&DisplayLang=en > > ( for Windows 9x / Me / NT4 ) > > You will need to be logged in as an administrator of the target > computer. You > will also need to ensure that you have full permissions to install on > the > drive you have chosen. > > You must have Microsoft Windows Installer version 2.0 or greater to run > the > MSI package. There is a link to download the correct Windows Installer > for > your platform on the System Requirements page: > > http://activestate.com/Products/ActivePerl/system_requirements.plex > > The MSI file may be corrupt. You may also want to try re-downloading > the > installation package and trying the installation again. If you have > trouble > downloading the file, you may want to try getting it via FTP: > > ftp://ftp.activestate.com or http://downloads.activestate.com > > If you are still seeing errors after the re-installation attempt, it > would be > helpful if you could send us a log of the installation process. You can > perform Microsoft Installer logging using the msiexec command: > > C:\> msiexec /I installer_file_name.msi /L*v install.log > > Send us the resultant install.log file and we will investigate further. > I believe the most recent code I have tried to install was V3 InstMsiW.exe 1822848 Cre Aug. 13 2005 But if I am not mistaken it always came up with ERROR box "The specified service already exists." May have been installed by some auto update, looking at the log seams like I have installer V3. c:\temp1>msiexec /I c:\temp1\python-2.4c1.msi /L*v install.log /L*v ok here it is... before downloading and installin the VB scripting crap.( in case it starts closing apps trying to reboot and clear all this typing I've done hehe. install.log === Verbose logging started: 17/04/2006 12:28:52 Build type: SHIP UNICODE 3.01.4000.2435 Calling process: C:\WINNT\system32\msiexec.exe === MSI (c) (84:10) [12:28:52:609]: Resetting cached policy values MSI (c) (84:10) [12:28:52:609]: Machine policy value 'Debug' is 0 MSI (c) (84:10) [12:28:52:609]: *** RunEngine: *** Product: c:\temp1\python-2.4c1.msi *** Action: *** CommandLine: ** MSI (c) (84:10) [12:28:52:609]: Machine policy value 'DisableUserInstalls' is 0 MSI (c) (84:10) [12:29:23:156]: Failed to connect to server. Error: 0x80080005 MSI (c) (84:10) [12:29:23:156]: MainEngineThread is returning 1601 === Verbose logging stopped: 17/04/2006 12:29:23 === -- http://mail.python.org/mailman/listinfo/python-list
Re: Queue can result in nested monitor deadlock
On Mon, Apr 17, 2006 at 09:41:37AM -0700, Jonathan Amsterdam wrote: > If you don't want to call it deadlock, fine, but the program execution > I describe will make no progress to the end of time. Thread 2 can never > put anything in the queue, because Thread 1 holds M, and Thread 1 will > never release M because that can only happen if someone puts something > on the queue. > Right, the problem isn't with Queue it is with your global lock M. Here is the pseudo code for your program: acquire_lock("No_one_else_can_do_anything") wait_for_someone_else_to_do_something() # waits forever -Jack -- http://mail.python.org/mailman/listinfo/python-list
How protect proprietary Python code? (bytecode obfuscation?, what better?)
How can a proprietary software developer protect their Python code? People often ask me about obfuscating Python bytecode. They don't want people to easily decompile their proprietary Python app. I suppose another idea is to rewrite entire Python app in C if compiled C code is harder to decompile. Any ideas? -- http://mail.python.org/mailman/listinfo/python-list
Re: List operation: Removing an item
Steven D'Aprano wrote: > On Sat, 15 Apr 2006 22:39:37 -0600, Miguel E. wrote: > > >>I am trying to create a function that removes an item as specified by >>the user. Apparently, the list operation "del list[:]" deletes the >>entire list. Below is the sample function. > > > If you know the value of the item, and not its position: > > somelist.remove("value") > > This will raise an exception if "value" is not in somelist. > Thank you. That fixed it. Regards, -M -- http://mail.python.org/mailman/listinfo/python-list
Re: Fixing Python instalation in win2000 by hand
> > c:\temp1>msiexec /I c:\temp1\python-2.4c1.msi /L*v install.log > /L*v ok here it is... before downloading and installin the VB > scripting crap.( in case it starts closing apps > trying to reboot and clear all this typing I've done hehe. > install.log > === Verbose logging started: 17/04/2006 12:28:52 Build type: SHIP > UNICODE 3.01.4000.2435 Calling process: C:\WINNT\system32\msiexec.exe === > MSI (c) (84:10) [12:28:52:609]: Resetting cached policy values > MSI (c) (84:10) [12:28:52:609]: Machine policy value 'Debug' is 0 > MSI (c) (84:10) [12:28:52:609]: *** RunEngine: > *** Product: c:\temp1\python-2.4c1.msi > *** Action: *** CommandLine: ** > MSI (c) (84:10) [12:28:52:609]: Machine policy value > 'DisableUserInstalls' is 0 > MSI (c) (84:10) [12:29:23:156]: Failed to connect to server. Error: > 0x80080005 > > MSI (c) (84:10) [12:29:23:156]: MainEngineThread is returning 1601 > === Verbose logging stopped: 17/04/2006 12:29:23 === Well, I installed the scripten.exe but to no avail. same log , same behavior. install1.log === Verbose logging started: 17/04/2006 13:20:01 Build type: SHIP UNICODE 3.01.4000.2435 Calling process: C:\WINNT\system32\msiexec.exe === MSI (c) (4C:10) [13:20:01:781]: Resetting cached policy values MSI (c) (4C:10) [13:20:01:781]: Machine policy value 'Debug' is 0 MSI (c) (4C:10) [13:20:01:781]: *** RunEngine: *** Product: python-2.4c1.msi *** Action: *** CommandLine: ** MSI (c) (4C:10) [13:20:01:890]: Machine policy value 'DisableUserInstalls' is 0 MSI (c) (4C:10) [13:20:33:296]: Failed to connect to server. Error: 0x80080005 MSI (c) (4C:10) [13:20:33:312]: MainEngineThread is returning 1601 === Verbose logging stopped: 17/04/2006 13:20:33 === Windows Installer (box) The windows Installer Service could not be accessed. this can occur in safe mode, or if Installer is not correctly installed. Contact for assistance. So I guess no way to retrieve the contents/instructions of python.msi SCRYPT to find out what should go where? Cheers. -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I use Code Context under Options in IDLE?
Phoe6 wrote: > Hi all, >I have this Code Context feature under Options in the IDLE. > How should I use it? Are there folks here who use it regularly and find > it useful. > Please guide me. Well, you could start by looking at the Help: Options Menu: Configure IDLE -- Open a configuration dialog. Fonts, indentation, keybindings, and color themes may be altered. Startup Preferences may be set, and Additional Help Souces can be specified. --- Code Context -- Open a pane at the top of the edit window which shows the block context of the section of code which is scrolling off the top or the window. But what does that actually mean? Take this code fragment example (with line numbers added for reference) 1 import collatz_functions as cf 2 3 def makepath(dstart,cstart,pattern,reps): 4print pattern 5 alphabet = ' 123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' 6 # fopen('pathmade.lst', WRITE,TEXT) 7 coeff= dstart 8 oldcoeff = coeff/3 9 const= cstart 10 print 'coeff %d const %d oldcoeff %d' % (coeff,const,oldcoeff) 11 for i in xrange(1,reps+1): 12 print 'i',i 13 for j in xrange(1,len(pattern)): 14 print 'j',j 15currstep = alphabet.index(pattern[j]) 16 print 'currstep',currstep 17while currstep>2: 18 coeff= 4 * coeff 19 const= 4 * const 20 currstep = currstep - 2 21 print 'coeff %d const %d currstep %d' % (coeff,const,currstep) 22 if currstep==1: The moment line 3 scrolls off the top of the edit window, it appears in the code context window. This tells you that the current line at the top of the screen is in line 3's scope. When line 11 scrolls off, it appears in the code context window showing you that the current lines are now in the scope of the for loop. By the time you reach line 18, your code context window looks like (line 3 has scrolled off the code context window): 11 for i in xrange(1,reps+1): 13 for j in xrange(1,len(pattern)): 17while currstep>2: Allowing you to see where line 18 is in the big picture. The moment I scroll past line 21, line 17 drops off the code context window showing me that my scope is now back to that of line 13. And no, I don't use it regulary because I wasn't even aware of it until you asked. > > Thanks! > Senthil -- http://mail.python.org/mailman/listinfo/python-list
Re: Queue can result in nested monitor deadlock
Jonathan Amsterdam wrote: > If you don't want to call it deadlock, fine, but the program execution > I describe will make no progress to the end of time. Thread 2 can never > put anything in the queue, because Thread 1 holds M, and Thread 1 will > never release M because that can only happen if someone puts something > on the queue. > If your class is using a queue to handle the inter-thread communication why is it also using a semaphore? If your methods are already locked so only one thread runs at a time why are you then using a queue to provide another layer of locking: a simple list should suffice? -- http://mail.python.org/mailman/listinfo/python-list
Re: Fixing Python instalation in win2000 by hand
>> the reason I can't move to brand new installation is because I am missing >> sound drivers. If I were you, I'd download the latest ActiveState version of Python from: http://www.activestate.com/Products/ActivePython/ I would install it from c:\ Who cares about sound drivers if all you want to do is get Python up and running? rd -- http://mail.python.org/mailman/listinfo/python-list
Re: How protect proprietary Python code? (bytecode obfuscation?, what better?)
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > How can a proprietary software developer protect their Python code? > People often ask me about obfuscating Python bytecode. They don't want > people to easily decompile their proprietary Python app. > > I suppose another idea is to rewrite entire Python app in C if compiled > C code > is harder to decompile. > > Any ideas? Go to Google's newsgroup archives for c.l.p (accessible via google.com) and search for some of the numerous past threads on this issue, which give several ideas and viewpoints. There may or may not also be something in the Python FAQ or Wiki at python.com. -- http://mail.python.org/mailman/listinfo/python-list
C FFI: easy conversion from list to argv?
Hi, I'm trying to update the fuse python bindings to my app and I was curious if there were any C utility functions that would turn a sys.argv into a C style argv array, or am I going to have to write those myself? Thanks. -- burton samograd kruhft .at. gmail kruhft.blogspot.com www.myspace.com/kruhft metashell.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Queue can result in nested monitor deadlock
"Jonathan Amsterdam" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > If you don't want to call it deadlock, fine, but the program execution > I describe will make no progress to the end of time. Thread 2 can never > put anything in the queue, because Thread 1 holds M, and Thread 1 will > never release M because that can only happen if someone puts something > on the queue. > Ah, I get it now, and yes as you describe it, this is a deadlock. But why do you need both mutex M and a Queue, then? You should release M before calling Queue.get(). Then if you need to, you should reacquire it afterward. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Queue can result in nested monitor deadlock
"Jonathan Amsterdam" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > As I'm new to the Python community, I'm not sure that this is the right > forum for this suggestion. Is it the sort of thing one would put on the > SourceForge bug list? Advice appreciated. As a sometimes bug reviewer who has noticed that a substantial fraction of 'bug' reports do not actually report CPython bugs, I wish more people would do as you did and post here first and get opinions from the wider variety of readers here. A CPython bug is a discrepancy between a reasonable interpretation of the doc and the behavior of the CPython implementation. Your post did not even claim such a discrepancy that I could see. A request for a design change can be put on the RFE (request for enhancement) list. Patches, whether to fix bugs or implement enhancements, usually go on the patch list. Note that you do not necessarily need to convince people that the current design is 'flawed' to demonstrate that a change would be good. Perhaps your recipe should be added to the oreilly online python cookbook. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Decode html, or is it unicode, how?
On 2006-04-17, <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote: > Hi All, > I've done a bunch of searching in google and in python's help, but, > I haven't found any function to decode a string like: > Refresh! (ihenvyr) > In to plain english. > [...] I needed to do that the other day, and did it like this: def decode(line): pat = re.compile(r'(\d+);') def sub(mo): return unichr(int(mo.group(1))) return pat.sub(sub, unicode(line)) there may well be a better way though. -- http://mail.python.org/mailman/listinfo/python-list
socket timeout error?
Hi, Running Fedora Core 4: Python 2.4.3 and Python 2.4.1. I'm getting: IOError: [Errno socket error] (2, 'No such file or directory') all the time. Trying to track down this problem: Python 2.4.1 (#1, May 16 2005, 15:19:29) [GCC 4.0.0 20050512 (Red Hat 4.0.0-5)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import socket >>> socket.getdefaulttimeout() >>> import urllib >>> urllib.urlopen('http://www.python.org') Traceback (most recent call last): File "", line 1, in ? File "urllib.py", line 77, in urlopen return opener.open(url) File "urllib.py", line 180, in open return getattr(self, name)(url) File "urllib.py", line 296, in open_http h.endheaders() File "/usr/lib/python2.4/httplib.py", line 794, in endheaders self._send_output() File "/usr/lib/python2.4/httplib.py", line 675, in _send_output self.send(msg) File "/usr/lib/python2.4/httplib.py", line 642, in send self.connect() File "/usr/lib/python2.4/httplib.py", line 610, in connect socket.SOCK_STREAM): IOError: [Errno socket error] (2, 'No such file or directory') >>> socket.setdefaulttimeout(0.1) >>> socket.getdefaulttimeout() 0.10001 >>> urllib.urlopen('http://www.python.org') socket.setdefaulttimeout(0.01) >>> urllib.urlopen('http://www.python.org') Traceback (most recent call last): File "", line 1, in ? File "urllib.py", line 77, in urlopen return opener.open(url) File "urllib.py", line 180, in open return getattr(self, name)(url) File "urllib.py", line 296, in open_http h.endheaders() File "/usr/lib/python2.4/httplib.py", line 794, in endheaders self._send_output() File "/usr/lib/python2.4/httplib.py", line 675, in _send_output self.send(msg) File "/usr/lib/python2.4/httplib.py", line 642, in send self.connect() File "/usr/lib/python2.4/httplib.py", line 626, in connect raise socket.error, msg IOError: [Errno socket error] timed out >>> socket.setdefaulttimeout(0.05) >>> urllib.urlopen('http://www.python.org') Seems a timeout of 0.01 is to small and a timeout >= 0.05 is working. What is the real problem here? Jaap -- http://mail.python.org/mailman/listinfo/python-list
Re: Queue can result in nested monitor deadlock
In article <[EMAIL PROTECTED]>, Jonathan Amsterdam <[EMAIL PROTECTED]> wrote: >If you don't want to call it deadlock, fine, but the program execution >I describe will make no progress to the end of time. Thread 2 can never >put anything in the queue, because Thread 1 holds M, and Thread 1 will >never release M because that can only happen if someone puts something >on the queue. That's not a problem in the design of the queue class, it is a problem in how you are using it. Two possible solutions are: 1. Don't have the global lock on the object (or, at the very least, don't have that global lock taken when you read from the queue). 2. Don't use a syncronized queue. If the only access to the queue is through the object and the object is protected then you don't need a synchronized queue. Alan -- Defendit numerus -- http://mail.python.org/mailman/listinfo/python-list
Re: MySql -python 1.2.1_p2 and visual c++ toolkit
I'm pretty new myself. But if you don't get anywhere using mysql-python, I can recommend mxODBC. I have connected to both MS Access DB and MySQL DB. You get it from: http://www.egenix.com/files/python/mxODBC.html But read the instructions carefully as I think there are two things to install. If you search on python-msql and compare to mxODBC in this forum it seems people have an easier time with mxODBC. rpd -- http://mail.python.org/mailman/listinfo/python-list
piping question
I have been working on a little frontend for newspost. It runs newspost just fine and gets it's output. The problem is that i want it to get the stdout as the program runs, not hold it all till it's finished. I've tried a few variations of popen , and others with no luck. Here is the subroutine that executes newspost: def on_BT_go_clicked(self,obj): self.notebook.set_current_page(3) newspost = "newspost -i " + self.newsserver.get_text() + " " newspost += "-z " + self.port.get_text() + " " if self.username.get_text() != "": newspost += "-u " + self.username.get_text() + " " if self.password.get_text() != "": newspost += "-p " + self.password.get_text() + " " newspost += "-f " + self.email.get_text() + " " newspost += "-n " + self.newsgroup.get_text() + " " newspost += "-s \"" + self.subject.get_text() + "\" " if self.include_file_x_of_y.get_active(): newspost += "-q " if self.yenc.get_active(): newspost += "-y " for row in self.listmodel: newspost += "\"" + row[0] + "\" " pipe = os.popen(newspost) while 1: output = pipe.read() if not(output): break textiter = self.textbuffer.get_end_iter() self.textbuffer.insert(textiter, output) pipe.close() -- http://mail.python.org/mailman/listinfo/python-list
Re: C FFI: easy conversion from list to argv?
Burton Samograd <[EMAIL PROTECTED]> writes: > I'm trying to update the fuse python bindings to my app and I was > curious if there were any C utility functions that would turn a > sys.argv into a C style argv array, or am I going to have to write > those myself? Following up to myself again...found the solution: -- PyObject *argv; /* value from PyArg_ParseTupleAndKeywords elsewhere */ int _argc = PySequence_Length(argv); char **_argv = malloc(_argc*sizeof(char**)); int i; for(i=0;i<_argc;i++) _argv[i] = PyString_AsString(PyList_GetItem(argv, i)); -- Could probabaly use some error checking but it works... -- burton samograd kruhft .at. gmail kruhft.blogspot.com www.myspace.com/kruhft metashell.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Threading problem
Hi all, I have a problem with threading. The following part should be running in a main programm all the time, but so that the main programm also works (like 2 seperate programms, but in one) How to integrate the Code-part in the main programm, so that the mainprogramm works? Code: import win32com.clientimport timeimport osimport threading Document = win32com.client.Dispatch('MaxIm.Document')Application = win32com.client.Dispatch('MaxIm.Application')p = win32com.client.dynamic.Dispatch('PinPoint.Plate') class TestThread ( threading.Thread ): path_to_watch = "F:/Images/VRT/" before = dict ([(f, None) for f in os.listdir (path_to_watch)]) while 1: time.sleep(2) after2 = dict ([(f, None) for f in os.listdir (path_to_watch)]) added = [f for f in after2 if not f in before] if added: name= ' ,'.join (added) if str(name[-3:])=='fit': Document.OpenFile('F:/Images/VRT/'+name) Document.SaveFile('F:/Images/VRT/'+ str(name[0:-4])+'.jpg', 6, 1024,2) Application.CloseAll() try: p.AttachFITS('F:/Images/VRT/'+name) p.ArcsecPerPixelHoriz = -1.7 p.ArcsecPerPixelVert = -1.7 p.MaxMatchResidual = 1.0 p.FitOrder = 3 p.CentroidAlgorithm = 0 p.RightAscension = p.TargetRightAscension p.Declination = p.TargetDeclination p.Catalog = 0 # GSC p.CatalogPath = 'F:/' p.ProjectionType = 1 # p.Solve() p.DetachFITS() pRA = p.RightAscension pDec = p.Declination print pRA print pDec except: p.DetachFITS() print 'Error' before = after2 TestThread().start() For your prompt reply, I say thank you in advance.Best regards,Aleksandar -- http://mail.python.org/mailman/listinfo/python-list
Threating problem
Hi all, I have a problem with threading. The following part should be running in a main programm all the time, but so that the main programm also works (like 2 seperate programms, but in one) How to integrate the part in the main programm? Code: import win32com.client import time import os import threading Document = win32com.client.Dispatch('MaxIm.Document') Application = win32com.client.Dispatch('MaxIm.Application') p = win32com.client.dynamic.Dispatch('PinPoint.Plate') class TestThread ( threading.Thread ): path_to_watch = "F:/Images/VRT/" before = dict ([(f, None) for f in os.listdir (path_to_watch)]) while 1: time.sleep(2) after2 = dict ([(f, None) for f in os.listdir (path_to_watch)]) added = [f for f in after2 if not f in before] if added: name= ' ,'.join (added) if str(name[-3:])=='fit': Document.OpenFile('F:/Images/VRT/'+name) Document.SaveFile('F:/Images/VRT/'+ str(name[0:-4])+'.jpg', 6, 1024,2) Application.CloseAll() try: p.AttachFITS('F:/Images/VRT/'+name) p.ArcsecPerPixelHoriz = -1.7 p.ArcsecPerPixelVert = -1.7 p.MaxMatchResidual = 1.0 p.FitOrder = 3 p.CentroidAlgorithm = 0 p.RightAscension = p.TargetRightAscension p.Declination = p.TargetDeclination p.Catalog = 0 # GSC p.CatalogPath = 'F:/' p.ProjectionType = 1 # p.Solve() p.DetachFITS() pRA = p.RightAscension pDec = p.Declination print pRA print pDec except: p.DetachFITS() print 'Error' before = after2 TestThread().start() For your prompt reply, I say thank you in advance. Best regards, Aleksandar -- http://mail.python.org/mailman/listinfo/python-list
Re: How protect proprietary Python code? (bytecode obfuscation?, what better?)
well, you can do something silly: create a c file into which you embed your code, ie., #include char code[] = "print 'hello moshe'"; void main(...) { Py_ExecString(code); } then you can compile the C file into an object file, and use regular obfuscators/anti-debuggers. of course people who really want to get the source will be able to do so, but it will take more time. and isn't that the big idea of using obfuscation? but anyway, it's stupid. why be a dick? those who *really* want to get to the source will be able to, no matter what you use. after all, the code is executing on their CPU, and if the CPU can execute it, so can really enthused men. and those who don't want to use your product, don't care anyway if you provide the source or not. so share. -tomer -- http://mail.python.org/mailman/listinfo/python-list
piping question
I forgot to add that i'm running ubuntu with python 2.4, and the imports are: import os import pygtk pygtk.require('2.0') import gtk import gtk.glade -- http://mail.python.org/mailman/listinfo/python-list
Dr. Dobb's Python-URL! - weekly Python news and links (Apr 17)
QOTW: "Discussion about Python 3000 is heating up. What I haven't seen so far is a list of things that will be dropped from the language to make room for new ideas." - Greg Wilson "The longer I work at writing software, the more I come to appreciate that people are the hardest thing to figure out." - Ned Batchelder An extra generator makes skipping items in a sequence painless, as Diez B. Roggisch shows: http://groups.google.com/group/comp.lang.python/browse_thread/thread/39e384173b6bdb97?tvc=1 Paul Moore has set up a wiki page to help you build Python from source on Windows with tools available free of charge. http://wiki.python.org/moin/Building_Python_with_the_free_MS_C_Toolkit Steven Bethard proposes a new 'make' statement as a generalization of the class-declaration syntax. http://groups.google.com/group/comp.lang.python/browse_frm/thread/cdacc75d99f56612/7237a512fecd741b?tvc=1 Are you abusing them, too? Tuples are not just constant lists. http://jtauber.com/blog/2006/04/15/python_tuples_are_not_just_constant_lists Python's random integers are not limited by the underlying hardware's long. Expect your web browser to explode when Google discovers this capability for generating their usenet group URLs. http://groups.google.com/group/comp.lang.python/browse_frm/thread/2e10b56da6ae823a/ Michele Simionato's little script lets you search for a name in Python scripts, avoiding false positives that a standard tool like grep would yield. http://groups.google.com/group/comp.lang.python/msg/e84e36ad10d78303 Brian Hayes brings Python to the classroom of an eighteenth century school in the german province, and finds that the resident math genius may lose his competitive advantage. http://bit-player.org/2006/summing-up Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. For far, FAR more Python reading than any one mind should absorb, much of it quite interesting, several pages index much of the universe of Pybloggers. http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog http://www.planetpython.org/ http://mechanicalcat.net/pyblagg.html comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Python411 indexes "podcasts ... to help people learn Python ..." Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous tradition early borne by Andrew Kuchling, Michael Hudson and Brett Cannon of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative e
Re: How protect proprietary Python code? (bytecode obfuscation?, what better?)
[EMAIL PROTECTED] wrote: > How can a proprietary software developer protect their Python code? > People often ask me about obfuscating Python bytecode. They don't want > people to easily decompile their proprietary Python app. > > I suppose another idea is to rewrite entire Python app in C if compiled > C code > is harder to decompile. > > Any ideas? Shuffle opcode values in random order, recompile Python, recompile stdlib, recompile py2exe (or whatever you use for bundling). It will keep attacker busy for several hours -- http://mail.python.org/mailman/listinfo/python-list
Re: Why new Python 2.5 feature "class C()" return old-style class ?
In article <[EMAIL PROTECTED]>, Alex Martelli <[EMAIL PROTECTED]> wrote: >Aahz <[EMAIL PROTECTED]> wrote: >> >> Method resolution order is the primary up-front difference, but >> introspective code can also have problems. > >The crucial difference between the old-style classes and the new ones >is about how Python lookups special methods. Right. Thanks! I don't actually use new-style classes much myself, so I forgot about that one. (And I needed it for the draft that's due today...) -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "LL YR VWL R BLNG T S" -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I use Code Context under Options in IDLE?
[EMAIL PROTECTED] wrote: > --- > Code Context -- Open a pane at the top of the edit window which > shows the block context of the section of code > which is scrolling off the top or the window. > > But what does that actually mean? > > Take this code fragment example (with line numbers added > for reference) That explaination was very helpful and cleared my doubts. Thanks a lot. Regards, Senthil -- http://mail.python.org/mailman/listinfo/python-list
Re: Java Developer Exploring Python
Ravi Teja wrote: > >> I've traditionally been a Java developer, although I play around with LISP. > > For most java developers, understanding dynamic typing is a big step. > Your Lisp background however would mean that you will pick up Python > very quickly. > > >> I recently migrated to Linux and I was exploring Mono as an > option for development on Linux. However, I've had some problems with > the maturity and support when working with Mono. > > IronPython (still a beta) BTW, runs on Mono as well and you can use > Mono through Python when you deem it ready. There is also Jython, which > runs on the Java platform if you feel married to Java platform or class > libraries. > > >> Is Python actively developed and supported on Linux? > > Yes and very well so. Many Linux distributions come with Python > pre-installed and Python has quite a bit of following in the Linux > crowd. Red Hat / Fedora installer - Anaconda, for example uses Python. > > >> Would it be a viable option for cross-platform application development? > > Python is a very good candidate for open source development. But then > again, most open source languages these days are. The culture is a bit > different though. Although Python is byte code compiled just like Java, > Python programmers are not averse to using native extensions (which in > most cases can be compiled painlessly on all popular platforms thanks > to Python's distutils). Java programmers on the other hand generally > extol 'Pure Java'. Both approaches have their own advantages and > disadvantages (Swing vs SWT) and you can use either with Python. > > >> Can anyone recommend an open source IDE for Python that runs on Linux? > > Most Python IDEs are open source along with a few commercial ones. > http://wiki.python.org/moin/IntegratedDevelopmentEnvironments > Everyone has their favorites and you should pick your own. > > Since you have a Java background, PyDev is probably the best choice for > you. JEdit also has a Python plugin. I just use SciTE (just an editor) > most of the time. Ravi, Thank you for taking the time to answer my questions. It sounds like Python may be the solution I am searching for. I took a look at lists of the IDEs on the wiki. Looks like I might be sticking with the IDLE editor for now. :] Perhaps I will have to write a simple IDE for Python that integrates Glade and supports pyGTK when I have some more programming experience... Scott Huey -- http://mail.python.org/mailman/listinfo/python-list
Re: MySql -python 1.2.1_p2 and visual c++ toolkit
I tried mxODBC now, and it worked out of the box. Thanks for the tip! -- http://mail.python.org/mailman/listinfo/python-list
Re: Queue can result in nested monitor deadlock
This is a reply to Alan Morgan, Paul McGuire and Duncan Booth. I need mutex M because I have other fields in my class that need to be thread-safe. The reason I want to use a Queue and not a list is that a Queue has additional synchronization besides the mutex. For instance, Queue.get() will block the caller until the queue is non-empty. Of course I could build this behavior on top of a list, but then I'm reinventing the wheel: Queue.Queue is the perfect thing, except for the problem I describe. I can't release my mutex M and then call Queue.get(). That could be a race condition: between the time M is released and Queue's mutex is acquired, another thread could get into my object and mess things up. (We'd need a specific example to see this, and there may be many cases where I could safely release M before calling Queue.get(), but in general it won't work.) -- http://mail.python.org/mailman/listinfo/python-list
Re: XPath/Screen Scraping Gurus..
Peter Hansen wrote: > bruce wrote: >> I'm not that familiar with Pythin, but I wasn wondering if there are any >> XPath/Python Gurus that I might be able to talk to regarding screen >> scraping >> applications... > > Since you mention XPath, it seems likely you are really interested in > *web-scraping*. > > Screen-scraping refers, I believe, to the process of identifying what is > onscreen in GUI programs, possibly even at the pixel level, and trying > to translate that back into a higher level model (e.g. text in fields) > of what is going on. > > Web-scraping, on the other hand, generally doesn't need to involve the > graphic representation of anything, and can work at the level of HTML, > XML, and ... XPath. > > (Disclaimer: I know these terms are not really standardized, but I think > the defacto standard definitions match what I've described fairly closely.) > > -Peter > Back in the days of DOS when I first came across the term screen scraping, it meant a program that emulated a terminal like a VT100, sending keystrokes and reading from an internal screen buffer. This was very much text and character oriented. Steve -- http://mail.python.org/mailman/listinfo/python-list
Missing interfaces in Python...
I'm coming from a Java background, so please don't stone me... I see that Python is missing "interfaces". The concept of an interface is a key to good programming design in Java, but I've read that they aren't really necessary in Python. I am wondering what technique I can use in Python to get the same benefits to a program design that I would get with interfaces in Java. For example, if I want to have a program with a Car object, and a Bus object. I want both of these objects to present a common group of methods that can be used by Mechanic objects, but slightly different methods that can be used by Driver objects. In Java I would accomplish this by defining an IFixable interface that would be implemented by both the Car and Bus objects. Mechanic objects would work with any object implementing this interface. How would I approach this problem in Python? I think I would use an abstract class instead of an interface for IFixable, since Python supports multiple inheritance, but I'm not sure this is correct. Thanks for any suggestions. Scott Huey -- http://mail.python.org/mailman/listinfo/python-list
Re: Socket Error: Connection Refused
[EMAIL PROTECTED] wrote: > Dear c.l.p, > > I have recently been doing the tutorial of Python and everything is > well, i'm upto the pass section. Anyway, when I try to launch idle now > I get the error message: Socket Error: Connection Refused. I do not > have a firewall, so I don't know what is going on. Also, this comes up > after it: > > IDLE's subprocess didn't make the connection. Either IDLE can't start a > subprocess or personal firewall software is blocking the connection. > > [OK] > > > Any help would be appreciate. > > Yamas > If it's not your personal firewall, then perhaps the machine you are trying to connect to is refusing the call. Are you sure it's listening on the port that you are trying to connect to? Steve -- http://mail.python.org/mailman/listinfo/python-list
Re: Queue can result in nested monitor deadlock
"Jonathan Amsterdam" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > This is a reply to Alan Morgan, Paul McGuire and Duncan Booth. > > I need mutex M because I have other fields in my class that need to be > thread-safe. > > The reason I want to use a Queue and not a list is that a Queue has > additional synchronization besides the mutex. For instance, Queue.get() > will block the caller until the queue is non-empty. Of course I could > build this behavior on top of a list, but then I'm reinventing the > wheel: Queue.Queue is the perfect thing, except for the problem I > describe. > > I can't release my mutex M and then call Queue.get(). That could be a > race condition: between the time M is released and Queue's mutex is > acquired, another thread could get into my object and mess things up. > (We'd need a specific example to see this, and there may be many cases > where I could safely release M before calling Queue.get(), but in > general it won't work.) > What if you expose an unguarded method on your class, that allows external put()'s to the Queue without first locking M? -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
[EMAIL PROTECTED] enlightened us with: > I see that Python is missing "interfaces". No it isn't. It just hasn't got them. > The concept of an interface is a key to good programming design in > Java, but I've read that they aren't really necessary in Python. > In Java I would accomplish this by defining an IFixable interface > that would be implemented by both the Car and Bus objects. Mechanic > objects would work with any object implementing this interface. In Python, you would simply call the functions you need. No need to make things that rigidly defined. Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself? Frank Zappa -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
# In Python, you would simply call the functions you need. No need to # make things that rigidly defined. Except when you need to handle exceptions when those methods don't exist. I think interfaces can definitely be useful. -- Jonathan Daugherty http://www.parsed.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
Jonathan Daugherty wrote_ > # In Python, you would simply call the functions you need. No need to > # make things that rigidly defined. > > Except when you need to handle exceptions when those methods don't > exist. I think interfaces can definitely be useful. so with interfaces, missing methods will suddenly appear out of thin air ? -- http://mail.python.org/mailman/listinfo/python-list
scanning through page and replacing all instances of 00:00:00.00
I have a python-cgi file that pulls data from an sql database, i am wondering what is the easiest way to remove all instances of '00:00:00.00' in my date column. how would i write a python script to scan the entire page and delete all instances of '00:00:00.00', would i use regular expressions? -- http://mail.python.org/mailman/listinfo/python-list
Re: piping question
Have you tried running python with '-u'? That turns off most buffering within python at least. I'm not familiar with newspost, so I've no idea what to do about any output buffering it might be doing. -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
# so with interfaces, missing methods will suddenly appear out of thin # air ? With interfaces, the idea is that they're enforced; so, they'll appear because someone implements them. -- Jonathan Daugherty http://www.parsed.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
Jonathan Daugherty wrote: > # so with interfaces, missing methods will suddenly appear out of thin > # air ? > > With interfaces, the idea is that they're enforced; so, they'll appear > because someone implements them. enforced by whom, at what point ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
Thanks for the responses...Looks like I might have opened Pandora's box here. Could I accomplish the above with an abstract class? If the mechanic class had a "fixIt()" method defined, could I pass it any object I wanted, and then just call the method that I expect to find there, or do I need to strictly define the type, or class, of an object that is passed to a method. Scott Huey -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
# enforced by whom, at what point ? In the case of Java, I think the JVM enforces interface implementation (probably at the parser level). -- Jonathan Daugherty http://www.parsed.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
# Thanks for the responses...Looks like I might have opened Pandora's # box here. Could I accomplish the above with an abstract class? Zope 3 has an interface system which is good. I recommend you look at that. -- Jonathan Daugherty http://www.parsed.org -- http://mail.python.org/mailman/listinfo/python-list
Re: scanning through page and replacing all instances of 00:00:00.00
> I have a python-cgi file that pulls data from an sql > database, i am wondering what is the easiest way to > remove all instances of '00:00:00.00' in my date column. > > how would i write a python script to scan the entire page > and delete all instances of '00:00:00.00', would i use > regular expressions? No need for a regexp: someString = someString.replace("00:00:00.00", "") I'd recommend doing it before you print the values out, rather than try and "scan the entire page" after you've printed them. Easy 'nuff. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Threading problem
Aleksandar Cikota wrote: > How to integrate the Code-part in the main programm, so that the > mainprogramm works? > > Code: > > import win32com.client > import time > import os > import threading > > Document = win32com.client.Dispatch('MaxIm.Document') > Application = win32com.client.Dispatch('MaxIm.Application') > p = win32com.client.dynamic.Dispatch('PinPoint.Plate') > > class TestThread ( threading.Thread ): > path_to_watch = "F:/Images/VRT/" def run(self): # Put the following code in the run method > before = dict ([(f, None) for f in os.listdir (path_to_watch)]) > while 1: [cut] > TestThread().start() This should work -- Faber http://faberbox.com/ http://smarking.com/ The man who trades freedom for security does not deserve nor will he ever receive either. -- Benjamin Franklin -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
[EMAIL PROTECTED] wrote: > If the mechanic class had a "fixIt()" method defined, could I pass it > any object I wanted absolutely. > and then just call the method that I expect to find there yes. > or do I need to strictly define the type, or class, of an object that is > passed to a method. no. this is Python. no need to negotiate with the compiler; just do what you want, and the interpreter will tell you when that doesn't work. also see: http://en.wikipedia.org/wiki/Duck_typing -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
Jonathan Daugherty wrote: > # Thanks for the responses...Looks like I might have opened Pandora's > # box here. Could I accomplish the above with an abstract class? > > Zope 3 has an interface system which is good. I recommend you look at > that. Zope 3's interface system is quite good, but it's also quite different from what he's probably expecting. On the up side, it's probably much better than what he's expecting too. :) -- Benji York -- http://mail.python.org/mailman/listinfo/python-list
Re: scanning through page and replacing all instances of 00:00:00.00
Kun wrote: > I have a python-cgi file that pulls data from an sql database, i am > wondering what is the easiest way to remove all instances of > '00:00:00.00' in my date column. > > how would i write a python script to scan the entire page and delete all > instances of '00:00:00.00', would i use regular expressions? You could use regular expressions or you might want to take a look at Beautiful Soup http://www.crummy.com/software/BeautifulSoup to parse the page and replace the offending text. -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Have a look at Zope 3. (http://www.zope.org/DevHome/Wikis/DevSite/Projects/ComponentArchitecture/FrontPage). It has an interface implementation. You can use this implementation with the apllication server Zope 3 or alone. Regards, Egon [EMAIL PROTECTED] schrieb am 17.04.2006 22:39: > I'm coming from a Java background, so please don't stone me... > > I see that Python is missing "interfaces". The concept of an interface > is a key to good programming design in Java, but I've read that they > aren't really necessary in Python. I am wondering what technique I can > use in Python to get the same benefits to a program design that I would > get with interfaces in Java. > > For example, if I want to have a program with a Car object, and a Bus > object. I want both of these objects to present a common group of > methods that can be used by Mechanic objects, but slightly different > methods that can be used by Driver objects. > > In Java I would accomplish this by defining an IFixable interface that > would be implemented by both the Car and Bus objects. Mechanic objects > would work with any object implementing this interface. > > How would I approach this problem in Python? I think I would use an > abstract class instead of an interface for IFixable, since Python > supports multiple inheritance, but I'm not sure this is correct. > > Thanks for any suggestions. > > Scott Huey > - -- Egon Frerich, Freudenbergstr. 16, 28213 Bremen E-Mail: [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (MingW32) Comment: GnuPT 2.7.2 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFERAsZuTzybIiyjvURAn4wAJ4qCaqAZu4BmnZzrltVAneyWwmh+wCeI8DV DwNlvYJed/22Ls8Jct4fKV4= =8eTo -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: scanning through page and replacing all instances of 00:00:00.00
"Kun" wrote: > I have a python-cgi file that pulls data from an sql database, i am > wondering what is the easiest way to remove all instances of > '00:00:00.00' in my date column. > > how would i write a python script to scan the entire page and delete all > instances of '00:00:00.00', would i use regular expressions? umm. if you're using a database, why not filter out uninteresting dates either in the SQL statement, or when you're building the page ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
[EMAIL PROTECTED] wrote: > I see that Python is missing "interfaces". The concept of an interface > is a key to good programming design in Java, but I've read that they > aren't really necessary in Python. I am wondering what technique I can > use in Python to get the same benefits to a program design that I would > get with interfaces in Java. To use interfaces in python, just what you would do in Java, except don't use interfaces. To expand on that slightly Zen answer, think about why you use interfaces in Java. The interface declaration tells the compiler that your object implements a specific set of functions, or that your function expects an object that implements these functions. Then, at run time, the actual type of the object is used to decide what function to call. However, python doesn't to any type checking at compile time, so it just uses the dynamic type of the object to decide what function to call. > How would I approach this problem in Python? I think I would use an > abstract class instead of an interface for IFixable, since Python > supports multiple inheritance, but I'm not sure this is correct. Concretely: class Car: def fix(self): print "Your car is ready, sir" class Bus: def fix(self): print "Your bus is ready, sir" class Mechanic: def repair(self, customer, vehicle): vehicle.fix() customer.bill() class Customer: def bill(self): print "Ouch, that was expensive" me = Customer() my_bus = Bus() my_car = Car() m = Mechanic() m.repair(me, my_bus) m.repair(me, my_car) Which gives the output: Your bus is ready, sir Ouch, that was expensive Your car is ready, sir Ouch, that was expensive If you try and repair something that can't be fixed: m.repair(me, me) you get: Traceback (most recent call last): File "test.py", line 30, in ? m.repair(me, me) File "test.py", line 14, in repair vehicle.fix() AttributeError: Customer instance has no attribute 'fix' Obviously, you don't want this to happen when people use your program. Java would check this at compile time, but as python doesn't, you can write a unit test to check that the object's you want to implement the relevant functions really do. def is_fixable(obj): try: obj.fix except AttributeError: return False return True assert is_fixable(Car()) assert is_fixable(Bus()) assert not is_fixable(Customer()) assert not is_fixable(Mechanic()) -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
[EMAIL PROTECTED] wrote: > I'm coming from a Java background, so please don't stone me... > > I see that Python is missing "interfaces". The concept of an interface > is a key to good programming design in Java, but I've read that they > aren't really necessary in Python. I am wondering what technique I can > use in Python to get the same benefits to a program design that I would > get with interfaces in Java. > > For example, if I want to have a program with a Car object, and a Bus > object. I want both of these objects to present a common group of > methods that can be used by Mechanic objects, but slightly different > methods that can be used by Driver objects. > > In Java I would accomplish this by defining an IFixable interface that > would be implemented by both the Car and Bus objects. Mechanic objects > would work with any object implementing this interface. > > How would I approach this problem in Python? I think I would use an > abstract class instead of an interface for IFixable, since Python > supports multiple inheritance, but I'm not sure this is correct. > > Thanks for any suggestions. > > Scott Huey > Just thought I'd put in my 2 cents. You may want to take a look at Zope 3 (www.zope.com). If I understand what you ware looking for, I think they have already solved the problem (at least in one way). It is at least worth a quick review. You will find that most Python programmers bristle at words like "missing", "enforcement" and "strictly defined the type". Python programmers just don't work that way. The fact that programmers in other languages must, is their loss. -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list
Re: scanning through page and replacing all instances of 00:00:00.00
Fredrik Lundh wrote: > "Kun" wrote: > >> I have a python-cgi file that pulls data from an sql database, i am >> wondering what is the easiest way to remove all instances of >> '00:00:00.00' in my date column. >> >> how would i write a python script to scan the entire page and delete all >> instances of '00:00:00.00', would i use regular expressions? > > umm. if you're using a database, why not filter out uninteresting dates > either > in the SQL statement, or when you're building the page ? > > > > > because in my sql database, the date is only 'date' (as in -mm-dd), only when i extract it with my python-cgi does the date turn into (-mm-dd 00:00:00.00), thus i figured the best way to fix this problem is to parse it after the matter. side note: the 'date' column is not formatted as datetime in the mysql database. -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
Jonathan Daugherty wrote: > Except when you need to handle exceptions when those methods don't > exist. I think interfaces can definitely be useful. I think I see what you mean, but that's an odd way to put it. Typically, you aren't going to handle the exceptions produced by type errors. Of course, you want some way to test that your code doesn't have type errors. Static type checking is one way of doing the requisite testing, unit tests are another, but it's the tests that are useful, not the interfaces per se. Adding interfaces to python, which doesn't support static type checking, would be useless IMO. -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
<[EMAIL PROTECTED]> wrote: > I see that Python is missing "interfaces". The concept of an interface > is a key to good programming design in Java, but I've read that they > aren't really necessary in Python. I am wondering what technique I can > use in Python to get the same benefits to a program design that I would > get with interfaces in Java. Python is a very dynamic language. Java is a very static language. What that means is that in Java (like C++), you do a lot of error checking at compile time. That's what interfaces are all about. In Python, you do almost no error checking (beyond basic language syntax) at compile time, and do everything at run time. For the most part, this means wrapping things in try blocks and catching exceptions. >For example, if I want to have a program with a Car object, and a Bus >object. I want both of these objects to present a common group of >methods that can be used by Mechanic objects, but slightly different >methods that can be used by Driver objects. > >In Java I would accomplish this by defining an IFixable interface that >would be implemented by both the Car and Bus objects. Mechanic objects >would work with any object implementing this interface. > >How would I approach this problem in Python? I think I would use an >abstract class instead of an interface for IFixable, since Python >supports multiple inheritance, but I'm not sure this is correct. Well, let's say your IFixable interface in Java would have included changeTire(), rechargeBattery(), and adjustBrakes() methods. In Python, I'd just go ahead and implement those methods for both Car and Bus classes. All Java's interface mechanism does for you is provide some compile-time checking that those methods are implemented. In Python, you would just call those methods when appropriate, and catch any NameError exception that would happen if it turns out there is no such method. Consider that in Python, an object can have methods added to it after it is created. It's entirely possible that the Car class has no changeTire() method, but one would be added to each Car instance sometime before the first place it might be called. Consider something like: if self.owner.hasRoadsideAssistance(): self.changeTire = callForHelp elif self.owner.canFixThings: self.changeTire = getHandsDirty Now, calling myCar.changeTire() could end up calling callForHelp(), or calling getHandsDirty(), or throwing NameError is no way exists to get the tire fixed. Maybe that's what makes sense in your application. -- http://mail.python.org/mailman/listinfo/python-list
ANN: the experimental python faq wiki
encouraged by the great response to the python tutorial wiki, I've set up another semi-open wiki for the Python FAQ: http://pyfaq.infogami.com/ the immediate goal is to get the FAQ ready for the 2.5 release, by using the wiki to collect comments. for more on future plans, see this page: http://pyfaq.infogami.com/process anyway, if you have some time to spare, why not drop by, pick some random article, and let us know how it can be improved. -- http://mail.python.org/mailman/listinfo/python-list
Re: scanning through page and replacing all instances of 00:00:00.00
"Kun" wrote: > because in my sql database, the date is only 'date' (as in -mm-dd), > only when i extract it with my python-cgi does the date turn into > (-mm-dd 00:00:00.00), thus i figured the best way to fix this > problem is to parse it after the matter. you still make no sense. why not fix this in your python cgi script ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
Jonathan Daugherty wrote: > # so with interfaces, missing methods will suddenly appear out of thin > # air ? > > With interfaces, the idea is that they're enforced; so, they'll appear > because someone implements them. But if you're writing tests you will check method signatures anyway, so why bother? Besides how java-like interfaces will help you if one of interface methods is supposed to accept one parameter that can be list or dict and not accept None? -- http://mail.python.org/mailman/listinfo/python-list
Re: python to c API, passing a tuple array
Thanks for the solution! Farshid Lashkari wrote: > [EMAIL PROTECTED] wrote: > > Hi, > > I want to pass something like this to a C function via the Python C > > API. > > mytuple = (("string_one", 1.2, 1.3), ("string_two", 1.4, 1.5), .., > > ., ) > > This tuple is dynamic in size, it needs to be 3 X N dimensions. each > > tuple in the > > tuple array is of the form (string, float, float) as described above > > > > so from python: > > > > mytuple = (("string_one", 1.2, 1.3), ("string_two", 1.4, 1.5)) > > api.myCFunction(mytuple) > > > > The C api: > > static PyObject *myCFunction(PyObject *self, PyObject *args) > > { > > > > if (!PyArg_ParseTuple(args, "O", . ?) { > > printf(" error in PyArg_ParseTuple!\n"); > > return Py_None; > > } > > > > Thanks. > > > > > Just loop through each item in the arguments and parse the sub-tuple. > Here is some sample code that doesn't do any error checking: > > static PyObject *myCFunction(PyObject *self, PyObject *args) > { > int numItems, i; > PyObject *tuple; > > numItems = PyTuple_Size(args); > > for(i = 0; i < numItems; ++i) > { > tuple = PyTuple_GetItem(args,i); > if(!PyArg_ParseTuple(tuple,"sff",...) { > //handle error > Py_RETURN_NONE; > } > } > } > > Also, you need to INCREF Py_None before you return it. Or you can use > the macro used in the sample code above. > > -Farshid -- http://mail.python.org/mailman/listinfo/python-list
Re: Threading problem
Thank You, but now it cannot open a file, but it should work... Here the error message: >>> Exception in thread Thread-1: Traceback (most recent call last): File "C:\Program Files\Python\lib\threading.py", line 442, in __bootstrap self.run() File "G:\Robot teleskop\VRT\test\test2.py", line 25, in run Document.OpenFile('F:/Images/VRT/'+name) File "C:\Program Files\Python\Lib\site-packages\win32com\client\dynamic.py", line 496, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: MaxIm.Document.OpenFile And here the Code: import win32com.client import time import os import threading Document = win32com.client.Dispatch('MaxIm.Document') Application = win32com.client.Dispatch('MaxIm.Application') p = win32com.client.dynamic.Dispatch('PinPoint.Plate') class TestThread (threading.Thread): def run (self): path_to_watch = "F:/Images/VRT/" before = dict ([(f, None) for f in os.listdir (path_to_watch)]) while 1: time.sleep(2) after2 = dict ([(f, None) for f in os.listdir (path_to_watch)]) added = [f for f in after2 if not f in before] if added: name= ' ,'.join (added) if str(name[-3:])=='fit': Document.OpenFile('F:/Images/VRT/'+name) Document.SaveFile('F:/Images/VRT/'+ str(name[0:-4])+'.jpg', 6, 1024,2) Application.CloseAll() try: p.AttachFITS('F:/Images/VRT/'+name) p.ArcsecPerPixelHoriz = -1.7 p.ArcsecPerPixelVert = -1.7 p.MaxMatchResidual = 1.0 p.FitOrder = 3 p.CentroidAlgorithm = 0 p.RightAscension = p.TargetRightAscension p.Declination = p.TargetDeclination p.Catalog = 0 # GSC p.CatalogPath = 'F:/' p.ProjectionType = 1 # p.Solve() p.DetachFITS() pRA = p.RightAscension pDec = p.Declination print pRA print pDec except: p.DetachFITS() print 'Error' before = after2 TestThread().start() "raise AttributeError, "%s.%s" % (self._username_, attr)", what does it mean? For your prompt reply, I say thank you in advance. Best regards, Aleksandar "Faber" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Aleksandar Cikota wrote: > >> How to integrate the Code-part in the main programm, so that the >> mainprogramm works? >> >> Code: >> >> import win32com.client >> import time >> import os >> import threading >> >> Document = win32com.client.Dispatch('MaxIm.Document') >> Application = win32com.client.Dispatch('MaxIm.Application') >> p = win32com.client.dynamic.Dispatch('PinPoint.Plate') >> >> class TestThread ( threading.Thread ): >> path_to_watch = "F:/Images/VRT/" > >def run(self): ># Put the following code in the run method > >> before = dict ([(f, None) for f in os.listdir (path_to_watch)]) >> while 1: > > [cut] > >> TestThread().start() > > This should work > > -- > Faber > http://faberbox.com/ > http://smarking.com/ > > The man who trades freedom for security does not deserve nor will he ever > receive either. -- Benjamin Franklin -- http://mail.python.org/mailman/listinfo/python-list
Re: scanning through page and replacing all instances of 00:00:00.00
Fredrik Lundh wrote: > "Kun" wrote: > >> because in my sql database, the date is only 'date' (as in -mm-dd), >> only when i extract it with my python-cgi does the date turn into >> (-mm-dd 00:00:00.00), thus i figured the best way to fix this >> problem is to parse it after the matter. > > you still make no sense. why not fix this in your python cgi script ? > > > > > i have the following python-cgi which extracts data from a mysql table, how do i parse the date so that it doesn't display the time '00:00:00.00'? print 'Query Results' try: db = MySQLdb.connect(host="localhost", user="xxx", passwd="", db="") cursor = db.cursor() sqlstring = (select + " FROM dir" + where + order_by + limit) print sqlstring cursor.execute(sqlstring) numrows = cursor.rowcount numcols = len(cursor.description) #print sqlstring #print "SQL statement used:" + sqlstring print "" print "" for col in range(0, numcols): print "", cursor.description[col][0], "" print "" for row in range(0,numrows): record = cursor.fetchone() print "" for col in range(0, numcols): print "", record[col], "" print "" except MySQLdb.OperationalError, message: print "Error %d:%s" % (message[0], message[1]) print "SQL statement used:" + sqlstring print "" -- http://mail.python.org/mailman/listinfo/python-list
Re: scanning through page and replacing all instances of 00:00:00.00
Kun> i have the following python-cgi which extracts data from a mysql Kun> table, how do i parse the date so that it doesn't display the time Kun> '00:00:00.00'? I have no idea which column in your table is a datetime object, but just convert it to a date. For example: >>> import datetime >>> dt = datetime.datetime.now() >>> print dt 2006-04-17 18:19:38.698925 >>> print dt.date() 2006-04-17 Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: scanning through page and replacing all instances of 00:00:00.00
> for col in range(0, numcols): > print "", record[col], "" This is the point at which you want to intercept the column data and make your change: print "", str(record[col]).replace("00:00:00.0", ""), "%s" % foo or alternatively DATECOLUMNS = [3, 14] for col in range(0, numcols): foo = record[col] if col in DATECOLUMNS: foo = foo.replace("00:00:00.00", "") print "%s" % foo I don't know off the top of my head if your MySQL cursor object supports metadata...something like the following pseudocode: for col in range(0, numcols): foo = record[col] if cursor.fieldtypes[col] == MYSQL_DATE: foo = foo.replace("00:00:00.00", "") print "%s" % foo Adjust accordingly. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: scanning through page and replacing all instances of 00:00:00.00
[EMAIL PROTECTED] wrote: > Kun> i have the following python-cgi which extracts data from a mysql > Kun> table, how do i parse the date so that it doesn't display the time > Kun> '00:00:00.00'? > > I have no idea which column in your table is a datetime object, but just > convert it to a date. For example: > > >>> import datetime > >>> dt = datetime.datetime.now() > >>> print dt > 2006-04-17 18:19:38.698925 > >>> print dt.date() > 2006-04-17 > > Skip assuming that my date column is 2, how would i parse out the date? the example you gave is of you parsing out the current time, but how do you parse out a pre-specified time that is extracted via sql? i don't think something like dt.date() works because it doesn't work with a string? correct me if i'm wrong. -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm coming from a Java background, so please don't stone me... Most of us came to Python from some other language background ;-) > I see that Python is missing "interfaces". As someone else noted, Python objectively does not have 'interfaces' (or 'protocols') as an object type in the language. (But 'missing' is somewhat subjective.) On the other hand, the concepts are very much part of the language. See the article on duck typing, which could be called duck interfacing, that someone gave a link for. For example, an iterator (newer definition) is an object with an __iter__() method returning self and a next() method that returns objects until it raises StopIteration. An iterable is an object with an __iter__() method that return an iterator. (Hence, iterators are conveniently iterables also.) Instead of declaring that a class implements IterableInterface, you just implement it (and the corresponding iterator class if needed) and use it anywhere an iterable is expected, which is lots places in the builtins and standard library. > How would I approach this problem in Python? I think I would use an > abstract class instead of an interface for IFixable, since Python > supports multiple inheritance, but I'm not sure this is correct. I believe this >>> NotImplementedError was added so that people could go the route of abstract base classes with stub functions. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
a flattening operator?
as we all know, * (asterisk) can be used to "inline" or "flatten" a tuple into an argument list, i.e.: def f(a, b, c): ... x = (1,2,3) f(*x) so... mainly for symmetry's sake, why not make a "flattening" operator that also works outside the context of function calls? for example: a = (1,2,3) b = (4,5) c = (*a, *b) # ==> (1,2,3,4,5) yeah, a + b would also give you the same result, but it could be used like format-strings, for "templating" tuples, i.e. c = (*a, 7, 8, *b) i used to have a concrete use-case for this feature some time ago, but i can't recall it now. sorry. still, the main argument is symmetry: it's a syntactic sugar, but it can be useful sometimes, so why limit it to function calls only? allowing it to be a generic operator would make things like this possible: f(*args, 7) # an implied last argument, 7, is always passed to the function today you have to do f(*(args + (7,))) which is quite ugly. and if you have to sequences, one being a list and the other being a tuple, e.g. x = [1,2] y = (3,4) you can't just x+y them. in order to concat them you'd have to use "casting" like f(*(tuple(x) + y)) instead of f(*x, *y) isn't the latter more elegant? just an idea. i'm sure people could come up with more creative use-cases of a standard "flattening operator". but even without the creative use cases -- isn't symmetry strong enough an argument? why are function calls more important than regular expressions? and the zen proves my point: (*) Beautiful is better than ugly --> f(*(args + (7,))) is ugly (*) Flat is better than nested --> less parenthesis (*) Sparse is better than dense --> less noise (*) Readability counts --> again, less noise (*) Special cases aren't special enough to break the rules --> then why are function calls so special? the flattening operator would work on any sequence (having __iter__ or __next__), not just tuples and lists. one very useful feature i can thik of is "expanding" generators, i.e.: print xrange(10) # ==> xrange(10) print *xrange(10) # ==> (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) i mean, python already supports this half-way: >>> def f(*args): ... print args ... >>> f(*xrange(10)) (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) so... why can't i just do "print *xrange(10)" directly? defining a function just to expand a generator? well, i could use "list(xrange(10))" to expand it, but it's less intuitive. the other way is list-comprehension, [x for x in xrange(10)], but isn't *xrange(10) more to-the-point? also, "There should be one-- and preferably only one --obvious way to do it"... so which one? (*) list(xrange(10)) (*) [x for x in xrange(10)] (*) [].extend(xrange(10)) (*) f(*xrange(10)) they all expand generators, but which is the preferable way? and imagine this: f(*xrange(10), 7) this time you can't do *(xrange(10) + (7,)) as generators do not support addition... you'd have to do *(tuple(xrange(10)) + (7,)) which is getting quite long already. so as you can see, there are many inconsistencies between function-call expressions and regular expressions, that impose artificial limitations on the language. after all, the code is already in there to support function-call expressions. all it takes is adding support for regular exoressions. what do you think? should i bring it up to python-dev? -tomer -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 359: The "make" Statement
> I think this PEP is going off the rails. It's primary virtue was that it was a simpler, clearer way to write: class Foo(args): __metaclass__ = some_metaclass #... And it doesn't even do that. What's wrong with "class Foo: __metaclass__ = blah"? Two lines of code, and the double underscores indicate something special is happening. What I would most like to see is 'type' become the default metaclass without having to type wait for Python 3000 or clutter the code with a soon-to-be-redundant "(object)" base class. That would obviate my main use of __metaclass__. How about "from __future__ import classic_classes" for those few programs that really need old-style classes? -- http://mail.python.org/mailman/listinfo/python-list
Freeze without a binary
I want to use freeze to create the .o's to then include in a library that will be distributed. When I use freeze it creates a binary and a main, and the main calls some frozenmain func. Obviously I dont want a main() in this code. Do I need to extract the code that was generated by freeze in main like Py_FrozenMain() and call this from somewhere else? This was created in the main() function: extern int Py_FrozenMain(int, char **); PyImport_FrozenModules = _PyImport_FrozenModules; return Py_FrozenMain(argc, argv); In my code i have C funcs that call py file functions which call C funcs. I dont want to ship the py files, but include it in a library with the other .o's Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: scanning through page and replacing all instances of 00:00:00.00
Tim Chase wrote: >> for col in range(0, numcols): >> print "", record[col], "" > > This is the point at which you want to intercept the column data and > make your change: > > print "", str(record[col]).replace("00:00:00.0", ""), " > If it's possible/plausible that other fields might have such a value > reasonably, then you'd want to do a check, something like > > > THEDATECOL = 42 > for col in range(0, numcols): > foo = record[col] > if col == THEDATECOL: > foo = foo.replace("00:00:00.00", "") > print "%s" % foo > > or alternatively > > DATECOLUMNS = [3, 14] > for col in range(0, numcols): > foo = record[col] > if col in DATECOLUMNS: > foo = foo.replace("00:00:00.00", "") > print "%s" % foo > > I don't know off the top of my head if your MySQL cursor object supports > metadata...something like the following pseudocode: > > for col in range(0, numcols): > foo = record[col] > if cursor.fieldtypes[col] == MYSQL_DATE: > foo = foo.replace("00:00:00.00", "") > print "%s" % foo > > Adjust accordingly. > > -tkc > much thanks! > > > > mu -- http://mail.python.org/mailman/listinfo/python-list
Schedule
I want to create a work schedule; I will have to input some names (in alphabetical order) and the days they can't be working because they have a license, are in vacation or are doing special services. Then, using that information, the program would assign, from a Monday specified onwards, from two weeks to two weeks for a period of 3 months (12 weeks), one person to the morning and two to the afternoon, following the order.However, if the person is not available in any day of that two weeks (input given earlier); it is not allocated to that two weeks of work. Instead, it is still the first of the list (it will be assigned in the future to the next two weeks when there's nothing to impede the work). Then the program will output the schedule to a file or the screen (preferrably a file). I've included an example of only one period. The impediment list is optional, but highly recommended if you can do it.If anyone would want to program it for me, I'd be pleased. However, if you just want to help me, I'll post the code and the problem:day = int(raw_input("day: ")) month = int(raw_input("month: "))year = int(raw_input("year: "))for week in range(5): if day in calendar.monthcalendar(ano, mes)[week]: startweek = weekdef definsemana(): monthcalendar = calendar.monthcalendar(year, month) t1s = monthcalendar[startweek] if t1s[-1] == 0: startweek = 0 if month < 12: month += 1 for i in range(7): if t1s[i] == 0: t1s[i] = calendar.monthcalendar(year, month)[startweek][i] startweek = 1 else: month = 2 year += 1 for day in t1s: print day, '\t',This SHOULD get the day specified and output the week following it, however it seems that it's outputting the first week of the month, regardless of the input date (try 26 December 2005 as an example). Where's the problem? -- http://mail.python.org/mailman/listinfo/python-list
A 'Box' Function
Hey guys. I should warn you, first off, that I'm relatively new to Python. Basically, what I'm trying to do is create a word-wrapping function with the added complication that it add a character at the beginning and end of each line, so that it encloses the text in a sort of 'box': | Like this | The word-wrapping function I'm working with is similar to the one given here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/148061 def wrap(text, width): return reduce(lambda line, word, width=width: '%s%s%s' % (line, ' \n'[(len(line)-line.rfind('\n')-1 + len(word.split('\n',1)[0] ) >= width)], word), text.split(' ') ) Does anyone have any ideas on how it could be modified? Am I approaching it the right way? Thanks a bunch! Mike -- http://mail.python.org/mailman/listinfo/python-list
Re-creating a Tkinter mainloop()
Hi, I am trying to run a Tkinter application in a thread and it works pretty well to an extent. However, when I try to recreate the application after the thread exits, the new application never shows up. The code below the message explains what I am trying. On running this, you should see a simple two-button frame pop-up, while a sting will keep being printed on the console. Please press the "QUIT" button before the counter counts down to 0. You should see "done with main()" on the console. When the counter hits 0, I see opening new thread on the console, so main() is being called, but no window appears. I am quite new to Tkinter, so I hope I am being clear about my intentions... Thanks, Srinath from Tkinter import * import thread import time class Application(Frame): def say_hi(self): print 'hello world' def createWidgets(self): self.QUIT = Button(self) self.QUIT["text"] = "QUIT" self.QUIT["fg"] = "red" self.QUIT["command"] = self.quit self.QUIT.pack({"side": "left"}) self.hi_there = Button(self) self.hi_there["text"] = "Hello", self.hi_there["command"] = self.say_hi self.hi_there.pack({"side": "left"}) def __init__(self, master=None): Frame.__init__(self, master) self.pack() self.createWidgets() def main(): app = Application() app.mainloop() print 'done with main()' app.destroy() t = thread.start_new_thread(main, ()) n = 20 while 1: print 'in main thread, n = %d' % n time.sleep(0.5) n -= 1 if n == 0: print 'opening new thread' t2 = thread.start_new_thread(main, ()) -- http://mail.python.org/mailman/listinfo/python-list
Re: scanning through page and replacing all instances of 00:00:00.00
Kun> assuming that my date column is 2, how would i parse out the date? No parsing required. Just get its date: d = record[2].date() The str() of a datetime.date object is a string in -MM-DD form. Kun> the example you gave is of you parsing out the current time, but Kun> how do you parse out a pre-specified time that is extracted via Kun> sql? i don't think something like dt.date() works because it Kun> doesn't work with a string? correct me if i'm wrong. I think MySQLdb automatically returns datetime objects when the column data type is date. Skip -- http://mail.python.org/mailman/listinfo/python-list
freakin out over C++ module in python
lo there all ! i have a huge delima, i have to be able to connect to a data server and recieve info from it. The servers software guys release some visual C++ modules that one can incorporate into a visual C++ project. Which is great, but i am developing in linux, and only am very familliar with python. i have tried to use swig to make a python module out of it, and it wouldn't work. Tried to just compile them with gcc and that would not work either. So, i have to go thru and try to re-create them in python. So here is the trick, i don't know anything about C++, but this has got to work. and so, i guess the main question i have is is there a module or program that will parse these classes and duplicate them for a python module ? Some kind of code translator ? Or is that just way out there? i would go thru it line by line, but i just dont know enough about C++, how it pulls off a socket connection, etc.. and some of the things i dont know how to do in python. like how to make an unsigned long init. whew. so, i guess i could google each line... but if someone has an easier alternative, i am all ears.. its about 400 lines total. thanks. sk -- http://mail.python.org/mailman/listinfo/python-list
Re: A 'Box' Function
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The word-wrapping function I'm working with is I have never used this, but it might help you >>> import textwrap >>> dir(textwrap) ['TextWrapper', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__revision__', '_whitespace', 'dedent', 'fill', 're', 'string', 'wrap'] tjr -- http://mail.python.org/mailman/listinfo/python-list
Slicing matrix
I am using numarray. Suppose I have >>> p = array(range(25), shape=(5,5)) >>> p array([[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]]) How do I easily slice out [0,1,2] or [1,2,3] or [2,7,12] or [7,12,17] and put it in a list? I checked the documentation at http://www.esrf.fr/computing/bliss/python2/NumArray/html/node26.html , but could not get it. Thanks. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Why new Python 2.5 feature "class C()" return old-style class ?
Aahz <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Alex Martelli <[EMAIL PROTECTED]> wrote: > >Aahz <[EMAIL PROTECTED]> wrote: > >> > >> Method resolution order is the primary up-front difference, but > >> introspective code can also have problems. > > > >The crucial difference between the old-style classes and the new ones > >is about how Python lookups special methods. > > Right. Thanks! I don't actually use new-style classes much myself, so > I forgot about that one. (And I needed it for the draft that's due > today...) Glad to have been of help, then! BTW, I use new-style classes almost exclusively (except when maintaining legacy code, or, up to 2.4, for exceptions)... Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Java Developer Exploring Python
Ravi Teja <[EMAIL PROTECTED]> wrote: > >> I've traditionally been a Java developer, although I play around with LISP. > > For most java developers, understanding dynamic typing is a big step. > Your Lisp background however would mean that you will pick up Python > very quickly. Very good point. > >> I recently migrated to Linux and I was exploring Mono as an > option for development on Linux. However, I've had some problems with > the maturity and support when working with Mono. > > IronPython (still a beta) BTW, runs on Mono as well and you can use > Mono through Python when you deem it ready. There is also Jython, which > runs on the Java platform if you feel married to Java platform or class > libraries. Both are important options, of course; mostly, they offer assurances that the effort spent today in mastering Python is never going to be "wasted" even if different deployment platforms are needed for some future projects (Python is good at invading niches of all kinds;-). > >> Is Python actively developed and supported on Linux? > > Yes and very well so. Many Linux distributions come with Python > pre-installed and Python has quite a bit of following in the Linux > crowd. Red Hat / Fedora installer - Anaconda, for example uses Python. Maybe the best example is Ubuntu, since its principal proponent, Mark Shuttleworth, is such a fan of Python -- his foundation offers bounties for Python projects, for example. > >> Would it be a viable option for cross-platform application development? > > Python is a very good candidate for open source development. But then > again, most open source languages these days are. The culture is a bit > different though. Although Python is byte code compiled just like Java, > Python programmers are not averse to using native extensions (which in > most cases can be compiled painlessly on all popular platforms thanks > to Python's distutils). Java programmers on the other hand generally > extol 'Pure Java'. Both approaches have their own advantages and > disadvantages (Swing vs SWT) and you can use either with Python. A rather good summary! Yes, part of Python's ability to infiltrate niches is the willingness to exploit whatever's around, without getting into a "language purist" mood. Consider for example that one of the additions to Python 2.5 (currently in alpha stage) is the inclusion in the Python standard library of ctypes, an extension (which is and will also remain available for download for previous Python releases) that lets Python code dynamically load any available .DLL/.so/.dylib (roughly same thing but different file extensions depending on platform;-) and call C-level functions therein. > >> Can anyone recommend an open source IDE for Python that runs on Linux? > > Most Python IDEs are open source along with a few commercial ones. > http://wiki.python.org/moin/IntegratedDevelopmentEnvironments > Everyone has their favorites and you should pick your own. > > Since you have a Java background, PyDev is probably the best choice for > you. JEdit also has a Python plugin. I just use SciTE (just an editor) > most of the time. My vote would go to eric3, but then, I _am_ a Qt fan;-). As you say, the wiki is a better choice, to get an idea of the available options, than any individual's suggestions... Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
Jonathan Daugherty <[EMAIL PROTECTED]> wrote: > # enforced by whom, at what point ? > > In the case of Java, I think the JVM enforces interface implementation > (probably at the parser level). "parser"...?! If you have an 'Object o', say one just received as an argument, and cast it to IBlahble, a la IBlahble blah = (IBlahble) o; ...what can the parser ever say about it? It's clearly up to the runtime system to "enforce" whatever -- raising the appropriate exception if the "actual" (leafmost) class of o does not in fact implement IBlahble (Java doesn't _really_ do compile-time static typing: it just forces you to violate the "Don't Repeat Yourself" cardinal rule by redundantly repeating types, as above, but then in general it checks things at runtime anyway!). Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: How protect proprietary Python code? (bytecode obfuscation?, what better?)
gangesmaster <[EMAIL PROTECTED]> wrote: ... > but anyway, it's stupid. why be a dick? those who *really* want to get > to the source will be able to, no matter what you use. after all, the > code is executing on their CPU, and if the CPU can execute it, so > can really enthused men. and those who don't want to use your product, > don't care anyway if you provide the source or not. so share. Alternatively, if you have secrets that are REALLY worth protecting, keep a tiny part of your app, embedding all worthwhile secrets, on YOUR well-secured server -- expose it as a webservice, or whatever, so the "fat client" (most of the app) can get at it. This truly gives you complete control: you don't care any more if anybody decompiles the part you distribute (which may be 90% or 99% of the app), indeed you can publish the webservice's specs or some API to encourage more and more people to write to it, and make your money by whatever business model you prefer (subscription, one-off sale, pay-per-use, your choice!). If you keep your client thin rather than fat, the advantages increase (your app can be used much more widely, etc), but you may need substantial amounts of servers and other resources to support widespread use. When I started proposing this approach, years and years ago, the fact that your app can work only when connected to the net might be considered a real problem for many cases: but today, connectivity is SO pervasive, that all sort of apps require such connectivity anyway -- e.g, look at Google Earth for a "fat client", Google Maps for a "thin" one accessing a subset of roughly the same data but running (the client side) inside a browser (with more limited functionality, to be sure). Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Java Developer Exploring Python
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Alex Martelli) wrote: > Consider for example that one of the additions to Python 2.5 (currently > in alpha stage) is the inclusion in the Python standard library of > ctypes Indeed, I think the inclusion of ctypes is far and away the most exciting thing in 2.5. -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 359: The "make" Statement
Mike Orr wrote: > > I think this PEP is going off the rails. It's primary virtue was that it > was a simpler, clearer way to write: > > class Foo(args): > __metaclass__ = some_metaclass > #... > > And it doesn't even do that. What's wrong with "class Foo: > __metaclass__ = blah"? Two lines of code, and the double underscores > indicate something special is happening. I think you're missing the point somewhat. The real point isn't to make using metaclasses easier; it's to let the useful semantics of the class statement be used for things that aren't classes. Example: I can define the following "metaclass": def PropertyMaker(name,bases,pdict): fget = pdict.get("get",None) fset = pdict.get("set",None) fdel = pdict.get("delete",None) doc = pdict.get("__doc__",None) return property(fget,fset,fdel,doc) Then, I could define a property inside some class definition like this: class some_attribute: __metaclass__ = PropertyMaker def get(self): whatever def set(self,value): whatever But the thing is, if I did that, I'd be lying bastard. I'd be using the class statement and the __metaclass__ property; however, the object I'm creating is not a class (it's a property), and the thing I'm assigning to __metaclass__ is not a metaclass (it's a factory function). With the make statement, I could instead write: make property some_attribute: def get(self): # etc. Then I'm not lying about it, and I'm using a more straightforward syntax. If this proposal were just about metaclasses, I agree that wouldn't be important enough to justify a new statement. Metaclasses aren't too common, and are generally used by experts who don't need the straightforwardness the make statement would provide. But, properties, dicts, and other things could benefit from some of the semantics the class statement, and with the make statement, the average user could take advantage of that without having to worry about all this circumlocative metaclass hackiness. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Slicing matrix
Anthony Liu wrote: > I am using numarray. I will be using numpy for this post, and if you are new to numarray, then you should probably skip it and use numpy instead. All new development is going towards numpy. http://numeric.scipy.org/ > Suppose I have > p = array(range(25), shape=(5,5)) p > > array([[ 0, 1, 2, 3, 4], >[ 5, 6, 7, 8, 9], >[10, 11, 12, 13, 14], >[15, 16, 17, 18, 19], >[20, 21, 22, 23, 24]]) In [4]: from numpy import * In [5]: p = arange(25).reshape((5,5)) In [6]: p Out[6]: array([[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]]) > How do I easily slice out [0,1,2] In [7]: p[0, :3] Out[7]: array([0, 1, 2]) > or [1,2,3] In [9]: p[0, 1:4] Out[9]: array([1, 2, 3]) > or [2,7,12] In [10]: p[:3, 2] Out[10]: array([ 2, 7, 12]) > or [7,12,17] and put it in a list? In [11]: p[1:4, 2] Out[11]: array([ 7, 12, 17]) -- Robert Kern [EMAIL PROTECTED] "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: Missing interfaces in Python...
# "parser"...?! If you have an 'Object o', say one just received as an # argument, and cast it to IBlahble, a la # # IBlahble blah = (IBlahble) o; # # ...what can the parser ever say about it? Maybe you didn't read the "I think" in my OP. Anyway, you clearly know more about (or have more recent experience with) Java than I do. -- Jonathan Daugherty http://www.parsed.org -- http://mail.python.org/mailman/listinfo/python-list
Reducing memory overhead for dictionaries by removing precomputed hash
Forgive me if this has already been discussed, but it seems to me that one could reduce the memory usage of dictionaries by 2/3 by removing the precomputed hash in each bucket. Since Dictionaries only allow immutable objects as keys, one could move the precomputed hash into the keys. * Strings are probably the most popular keys for dictionaries and they already cache the hash (hmm that almost rhymes). * Numbers are trivial to hash. * For Tuples one could add a member to cache the hash. So why store the hash? I imagine it makes rebuilding the dictionary a bit quicker, since I guess you can avoid some comparisions since you know there are no duplicates. haven't looked at the code to see if it does that tho. and collision chains are possibly a bit quicker to traverse, tho I think python uses a mask instead of a mod by prime, so hash keys with the same low bits will collide, so collisions might be more common, but that's possibly fixable by using a congruential hash, but that's all black magic to me. -Kirat -- http://mail.python.org/mailman/listinfo/python-list
Re: Slicing matrix
Hi, Robert, Thanks a lot. I figure it out, too. NumArray is so flexible, it's like cutting the cheese. You can cut it anyway you want. I really like NumArray. --- Robert Kern <[EMAIL PROTECTED]> wrote: > Anthony Liu wrote: > > I am using numarray. > > I will be using numpy for this post, and if you are > new to numarray, then you > should probably skip it and use numpy instead. All > new development is going > towards numpy. > > http://numeric.scipy.org/ > > > Suppose I have > > > p = array(range(25), shape=(5,5)) > p > > > > array([[ 0, 1, 2, 3, 4], > >[ 5, 6, 7, 8, 9], > >[10, 11, 12, 13, 14], > >[15, 16, 17, 18, 19], > >[20, 21, 22, 23, 24]]) > > In [4]: from numpy import * > > In [5]: p = arange(25).reshape((5,5)) > > In [6]: p > Out[6]: > array([[ 0, 1, 2, 3, 4], >[ 5, 6, 7, 8, 9], >[10, 11, 12, 13, 14], >[15, 16, 17, 18, 19], >[20, 21, 22, 23, 24]]) > > > How do I easily slice out [0,1,2] > > In [7]: p[0, :3] > Out[7]: array([0, 1, 2]) > > > or [1,2,3] > > In [9]: p[0, 1:4] > Out[9]: array([1, 2, 3]) > > > or [2,7,12] > > In [10]: p[:3, 2] > Out[10]: array([ 2, 7, 12]) > > > or [7,12,17] and put it in a list? > > In [11]: p[1:4, 2] > Out[11]: array([ 7, 12, 17]) > > -- > Robert Kern > [EMAIL PROTECTED] > > "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 > __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Ironpython book?
Anyone know if there is a book for Ironpython in the works? A good knowledge of .NET and Python is enough to get started but just poking around Ironpython homepage it seems like there are some new language features added to handle some quirks with working within the CLR. Although I could be wrong. Thanks -Jake -- http://mail.python.org/mailman/listinfo/python-list