Re: How do I make Windows Application with Python ?
There are several GUI toolkits for python. Tkinter comes with python, but wxPython, a binding to wxWindows is popular, as is pyQT, and pyGTK. You can also build native win32 GUIs using PythonWin, part of win32all. A more complete list of options is available here: http://www.python.org/cgi-bin/moinmoin/GuiProgramming . I have heard a couple good things about Boa Constructor (http://boa-constructor.sourceforge.net/) as an IDE. It includes a GUI designer. I have not used it though. Stand alone GUI designers such as wxGlade (http://wxglade.sourceforge.net/) are available as well. As far as packaging the application for use on computers where python is not installed. If you are distributing to windows computers you can use py2exe to make a windows executable from a python program. It will include dlls you need to distribute with your program. cx_Freeze and Gordon McMillan's Installer also can create windows executable files. Good luck... and be sure to read through the online tutorials and wikis, there is a wealth of information out there. A book isn't a bad investment either, I always feel better with a good reference book around. Python in a nutshell is a good reference book, while Learning Python gives you a good introduction to the language. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I make Windows Application with Python ?
I should learn to type faster. You beat me to the response. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: distutils linux script installation broken?
I just installed python2.4 and used it to install a set of scripts I had previously been using distutils with. It worked fine, and replaced the first line with: #!/usr/local/bin/python2.4 distutils should replace that first line with the location of the binary used to run setup.py. Are you running setup with the following command line? python setup.py install -- http://mail.python.org/mailman/listinfo/python-list
Re: distutils linux script installation broken?
I've got python 2.3.3, 2.4, and 1.5.2 (which came preinstalled) on my linux box. It's redhat 7.2 (I know... I would upgrade, but it would void my service contract, so I just install things in /usr/local). You can check if PYTHONHOME or PYTHONPATH are set, which may somehow be interfering. I don't have those variables set. If they are set, you could try running: python -E setup.py install The -E option should make python ignore those environment variables. Good luck, I hope this helps. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Integration with java
It is possible, though possibly painful, to call java modules from CPython using JNI. This is more difficult than Jython integration, but probably required if you want to keep using your extension modules. The JNI tutorial is available at http://java.sun.com/docs/books/tutorial/native1.1/index.html . I probably would not take this approach unless java offered some incredibly substantial benefit or I was integrating a complex python system with a complex java sytem. I would also probably start by creating a good C API to access the required java modules via JNI and then use SWIG (http://www.swig.org/) to generate the python wrapper. Of course if you can drop the extension modules you have already written, accessing Java from Jython is just an import statement away. Good luck, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: make install with python
On Sat, Jan 22, 2005 at 01:54:17AM +0100, Uwe Mayer wrote: > Any suggestions how I handle uninstallation? This was provided by automake > rather mechanically. I didn't find a section on that in the distutils > documentation... :( I've been using distutils for a couple of projects I've written for work. Overall I love it as I rarely have to consult documentation (I always need to look at documentation to use autoconf, though I must admit I have only used autoconf/automake on two projects). On the distutils2.0 Wiki page (http://www.python.org/moin/DistUtils20) I found the quote: "Uninstallation is solved as soon as we have an installation database, which is part of what we're trying to do here." -- BobIppolito So it looks like they are working on it. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: how to find number of processors in python
"/usr/sbin/psrinfo -p" will print the number of physical processors on the system, though it does not indocate if they are on- or off-line. You could also write an extension which gets processor information using the sys/processor library. Example code is available in the "p_online" man page. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Microsoft Visual C++ and pyton
On Sun, Jan 30, 2005 at 03:12:06PM -0800, mike wrote: > I am new with python. Is it possible to have an MFC application and > develop some module using python? what are the steps in doing this? can > anybody give me a url or some documentation for this.. thanks.. It is possible to embed python in a C or C++ application, enabling you to call python functions from C. I would recommend reading "Extending and Embedding the Python Interpreter" at http://docs.python.org/ext/ext.html for more information. If you are currently using Visual C++ 6.0, either stick with Python 2.3 or read this: http://www.vrplumber.com/programming/mstoolkit/ to learn how to build extensions for python 2.4 with the free VC++ toolkit compiler. If you are already using version 7 of the Microsoft C++ compiler then you should have no problems with Python 2.4. I usually do not embed the interpreter, but I have written some extension modules... well, I should say I have used SWIG (http://www.swig.org/) to create wrappers around some C libraries. For information (read: rants) on extending versus embedding see http://twistedmatrix.com/users/glyph/rant/extendit.html and http://c2.com/cgi/wiki?EmbedVsExtend . You can also use win32 python extensions to make your module available through COM, but I don't know anything about that. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Microsoft Visual C++ and pyton
On Mon, Jan 31, 2005 at 02:42:11PM -0800, mike wrote: > I was also advised to build the python core (pythoncore.vcproj) with my > C++ program. By that way I would not have to load the python core > anymore during runtime. Is this a good approach? > I am currently using VC++ 7 and python 2.4. I'm not sure... I'm not very familiar with PC builds. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: New to unix/python. How to install
On Sun, Feb 06, 2005 at 01:42:22PM -0800, Bobby Owens wrote: > I've muddled through the python code and figured out parts of it. I've > now installed Sun Solaris 10 on a VM ware installation successfully > and can muddle thorough the basics of the o/s. I cant figure out how > to install python. From looking online I've found what I think I need: > > - python-2.3.3-sol9-intel-local > - libgcc-3.3-sol10-intel-local I wouldn't worry about these binary packages. Usually under solaris compiling the source works fine. Download the source from this page: http://www.python.org/download/ It comes as a gzipped tar file. You can unpack it by issuing the command: gunzip -c Python-2.4.tgz | tar xvf - Change into the Python-2.4 directory and run the commands: ./configure make as "root" run the command: make install Python should install into /usr/local. The python interpreter should be /usr/local/bin/python. Since python is written in C, you do not need to use the Gnu C compiler to compile it, ./configure should find an appropriate C compiler, and everything should work fine. Feel free to reply if this series of steps does not work. Good luck, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: python code with indention
On Mon, Feb 07, 2005 at 03:43:15PM -0500, Dan Perl wrote: > > "Xah Lee" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > is it possible to write python code without any indentation? > > I read just today in a tutorial that "Python on the other hand, does not > even allow changes in code's indentation". Maybe the author of that > tutorial can help? And to think he posted both on the same day. It'd be funny if it weren't so sad... actually it's just funny. Anyway, in response to the question see http://docs.python.org/ref/indentation.html#l2h-9 A sequence of statements without any looping or function or class definitions can probably be done without any indenting. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Synchronizing methods of a class
On Mon, Feb 07, 2005 at 11:57:02AM -0800, Keith Veleba wrote: > Background: > I'm working on a project where I have to do some serious > multithreading. I've worked up a decorator in Python 2.3.4 to implement > the lock semantics required for specific functions I want to > synchronize: I found Chris Liechti's example very helpful when working on a similar project. See http://groups-beta.google.com/group/comp.lang.python/msg/d647a830de39d1db . Also, I strongly suggest using threading.RLock() objects instead of primitive locks. With Rlocks one thread can acquire the same lock multiple times without blocking. This is useful if one synchronized method calls another synchronized method. > Obviously, my classes have to instantiate the _lock in __init__ in > order for this to work. The great thing about Chris's example is that the first time a synchronized method is called a lock is instantiated, so you don't have to worry about this step. > Problem: > > When iterating through klass.__dict__.items() in the convenience > method, I only get the instance variables of the class. No functions. > I've found a way to get the function list, by iterating through > klass.__class__.__dict__ . I'm not sure why klass.__dict__.items() isn't working for you. I tried a simple example: class simple(object): def hello(self): print "Hello World" def methods(cls): for name,value in cls.__dict__.items(): if callable(value): print name >>> methods(simple) hello Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: SCons build tool speed
On Sat, Feb 12, 2005 at 07:16:02PM +, ted wrote: > How does the speed of the Scons build tool compare with Ant? I would recommend asking this question on [EMAIL PROTECTED] , but my impressions is that most of the time is probably spent in the compiler. If you are working on a java project you could try switching from javac to jikes and that might improve your time, though it has been a while since I used jikes. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Q: Portable Way to Make Files Read Only
On Sun, Feb 13, 2005 at 01:25:02PM -0600, Efrat Regev wrote: > I would like to recurse through a directory and make files (which match > a specific criteria) read only. From searching the Internet, I found > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303343 > which shows how to change file attributes to read only using the > win32api module. That's great, but I was hoping there's a more portable way > to do so. Is there a more portable API call to make files read only? assuming the variable "path" is set to a string indicating the file in question, try the following: import os import stat # get the current file mode mode = os.stat(path)[stat.ST_MODE] # set it so it is not user, group, or other writable os.chmod(path, mode & ~stat.S_IWUSR & ~stat.S_IWGRP & ~stat.S_IWOTH) #or os.chmod(path,mode & ~0222) Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Modules for Various Internet Protocols?
On Thu, Feb 24, 2005 at 11:11:07AM -0600, Efrat Regev wrote: > I was wondering whether there are any Python modules for various > Internet protocols, ... Twisted (http://twistedmatrix.com/products/twisted) is an event driven framework for writing network applications. It includes many internet protocols including ftp, irc, imap4, pop, etc... Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Canonical way of dealing with null-separated lines?
On Wed, Feb 23, 2005 at 10:54:50PM -0500, Douglas Alan wrote: > Is there a canonical way of iterating over the lines of a file that > are null-separated rather than newline-separated? I'm not sure if there is a canonical method, but I would recommending using a generator to get something like this, where 'f' is a file object: def readnullsep(f): # Need a place to put potential pieces of a null separated string # across buffer boundaries retain = [] while True: instr = f.read(2048) if len(instr)==0: # End of file break # Split over nulls splitstr = instr.split('\0') # Combine with anything left over from previous read retain.append(splitstr[0]) splitstr[0] = ''.join(retain) # Keep last piece for next loop and yield the rest retain = [splitstr[-1]] for element in splitstr[:-1]: yield element # yield anything left over yield retain[0] Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Canonical way of dealing with null-separated lines?
On Thu, Feb 24, 2005 at 02:03:52PM -0500, Douglas Alan wrote: > Thanks for the generator. It returns an extra blank line at the end > when used with "find -print0", which is probably not ideal, and is > also not how the normal file line iterator behaves. But don't worry > -- I can fix it. Sorry... I forgot to try it with a null terminated string. I guess it further illustrates the power of writing good test cases. Something like this would help: # yield anything left over if retain[0]: yield retain[0] The other modification would be an option to ignore multiple nulls in a row, rather than returning empty strings, which could be done in a similar way. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Canonical way of dealing with null-separated lines?
On Fri, Feb 25, 2005 at 07:56:49AM +1100, John Machin wrote: > Try this: > !def readweird(f, line_end='\0', bufsiz=8192): > !retain = '' > !while True: > !instr = f.read(bufsiz) > !if not instr: > !# End of file > !break > !splitstr = instr.split(line_end) > !if splitstr[-1]: > !# last piece not terminated > !if retain: > !splitstr[0] = retain + splitstr[0] > !retain = splitstr.pop() > !else: > !if retain: > !splitstr[0] = retain + splitstr[0] > !retain = '' > !del splitstr[-1] > !for element in splitstr: > !yield element > !if retain: > !yield retain > I think this is a definite improvement... especially putting the buffer size and line terminators as optional arguments, and handling empty files. I think, however that the if splitstr[-1]: ... else: ... clauses aren't necessary, so I would probably reduce it to this: !def readweird(f, line_end='\0', bufsiz=8192): !retain = '' !while True: !instr = f.read(bufsiz) !if not instr: !# End of file !break !splitstr = instr.split(line_end) !if retain: !splitstr[0] = retain + splitstr[0] !retain = splitstr.pop() !for element in splitstr: !yield element !if retain: !yield retain Popping off that last member and then iterating over the rest of the list as you suggested is so much more efficient, and it looks a lot better. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: bsddb for k, v in db.items(): do order the numbers ?
On Mon, Feb 28, 2005 at 08:30:59AM -0800, [EMAIL PROTECTED] wrote: > WHen I use the code below and printing all the results i get this: > -- > 0 1 10 > 11 2 3 > 4 5 6 > 7 8 9 > -- > But I want > -- > 0 1 2 > 3 4 5 > 6 7 8 > 9 10 11 > -- If you want your key, value pairs in a certain order you have to sort them yourself. Dictionaries and bsddb keys are unsorted. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: bsddb for k, v in db.items(): do order the numbers ?
On Wed, Mar 02, 2005 at 01:31:04PM +0300, Denis S. Otkidach wrote: > You are not right, records in BTree (btopen) are certainly sorted. For > positive integers you can pack keys with struct.pack('>I', value). You're right... I missed the btopen (rather a key thing to miss I know, but when you have a toddler in your lap it sometimes happens). Sorry about that. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Email filters in python
I use fetchmail in daemon mode and have procmail set up to filter my email through bogofilter (http://bogofilter.sourceforge.net/). As for outgoing mail postfix, exim, and sendmail are popular. From my laptop I do use a python script to cache mail my mail when I'm not connected. I then use a script which sends my email over ssh to my work computer which uses sendmail to send it all out. I discuss those scripts at http://miyu.idolstarastronomer.com:8080/cgi-bin/cgiwrap/devries/blosxom.cgi/2004/04/27#laptop-mail and they are written in python. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python vs. Perl
Roy Smith already touched on regular expressions, but as far as features go, I would say that the real difference between python and perl is not in the features, but in the philosophy. It seems to me that any program you can write in python could also be written in perl. What it comes down to for me was which language most fit the way I tend to think. I decided python was that language, and I found everything very intuitive. I have a good friend who thinks in perl and is very productive using it. Other people might disagree, but when I was looking at perl and python I borrowed recent copies of "Learning Perl" and "Learning Python" from the O'Reilly series and after reading each, decided I preferred python. You can find out about most of the features in those books. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: List limits
It is possible to store 70,000 items in a list (try "l = range(7)"), but the best way to check if you can store all the items you need to store is to try it. After all if they are all very large you might potentially run out of memory. Chris -- http://mail.python.org/mailman/listinfo/python-list