ANN: ShowMeDo commercial series: 'Python 101 - easygui and csv'
Summary: 1 hour 20 minutes of lessons in how to build a complete and tested Python application from scratch. The series is aimed at beginners, all necessary material is provided, viewers can ask me (the author) questions as they go. Commercial series: 'Python 101 - easygui and csv': http://showmedo.com/videos/series?name=IwrOgqPc9 Detail: The 17 episodes walk a new Python programmer through all necessary steps to build a working and unit-tested Python program. In this series I use Wingware's Wing IDE but any Python development environment can be used. The program reads in a csv data file (e.g. from Excel) using a file-open dialog (easygui), the data is processed, a mathematical average generated and a modified csv file is written out. easygui's messagebox and yes/no dialog are also used. I show how to document the code, refactor the early script using functions and test functions using nosetests. Several exercises are set which extend the viewer's knowledge of easygui. They also provide practice for writing code, refactoring and applying test-driven development. The viewer is encouraged to ask questions using the Comments section, I'll answer all questions and everyone is encouraged to help each other. Full source is provided and the viewer can download the videos for off-line viewing. Further details are available here: http://blog.showmedo.com/2007/06/13/learn-gui-and-file-handling-techniques/ -- http://ShowMeDo.com http://ShowMeDo.com/about (our pictures) http://blog.ShowMeDo.com http://forums.ShowMeDo.com [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: HTMLParser.HTMLParseError: EOF in middle of construct
Sergio Monteiro Basto wrote: Can someone explain me, what is wrong with this site ? python linkExtractor3.py http://www.noticiasdeaveiro.pt test HTMLParser.HTMLParseError: EOF in middle of construct, at line 1173, column 1 at line 1173 of test file is perfectly normal . I like to know what I have to clean up before parse the html page I send in attach the python code . You don't want to do these things with HTMLParser. lxml is much easier to use and supports broken HTML (as in the page you're parsing). Note that there is a SVN branch of lxml that comes with an html package (lxml.html) that provides a clean() function. Just parse the page with the HTML parser provided by the package (a few lines), then call the clean() function on it with the parameters you want to get rid of scripts and the like. The docs: http://codespeak.net/lxml/dev/ The SVN branch: http://codespeak.net/svn/lxml/branch/html/ You seem to be on Linux, so compiling lxml should be simple enough: http://codespeak.net/lxml/dev/build.html#subversion Have fun, Stefan -- http://mail.python.org/mailman/listinfo/python-list
How do I trap errors in win32com.client?
How do I trap errors from win32com.client. I have tried the com_error classes from pywintypes and pythoncom sub modules. It is not catching for all cases. Is there any docs available? -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows XMLRPC Service
On Jun 18, 2:16 am, Gabriel Genellina [EMAIL PROTECTED] wrote: En Mon, 18 Jun 2007 00:25:25 -0300, [EMAIL PROTECTED] escribió: I'm trying to serve up a simple XMLRPC server as a windows service. I got it to run properly, I'm just not sure how to stop it properly. Most of the documentation/examples I found for this was from forums, so I'd love some links to relevant info also. Here's what I have...taken from the cookbook with the xmlrpc server added: def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) # Create an event which we will use to wait on. # The service stop request will set this event. self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) def SvcStop(self): # Before we do anything, tell the SCM we are starting the stop process. self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) # quit the xmlrpc sever self.server.quit() What is quit()? As the server may be processing a request I'd move any finalization code below, after exiting the while loop. # And set my event. win32event.SetEvent(self.hWaitStop) def SvcDoRun(self): # Serve up the XMLRPC forever self.server = SimpleXMLRPCServer.SimpleXMLRPCServer((10.0.1.6, 8000)) self.server.register_instance(MyClass()) self.server.serve_forever() win32event.WaitForSingleObject(self.hWaitStop) The simplest solution is to replace serve_forever with a loop waiting on hWaitStop: while WaitForSingleObject(self.hWaitStop, 0)==WAIT_TIMEOUT: self.server.handle_request() Set the socket timeout to a reasonable value (you'll have to wait that time before exiting). Also, a ThreadingTCPServer may be better if you expect more than a request at a time. If you search past messages you may find other ways. -- Gabriel Genellina- Hide quoted text - - Show quoted text - I can't quite figure out where to set the socket timeout. I tried setting win32event.WAIT_TIMEOUT, but I'm pretty sure that's not the variable you were talking about. I did manage to make it multi- threaded by incorporating a different recipe, and I'm beginning to understand the control flow a bit better, but it doesn't seem to be doing what I expect. When SvcStop() is executed and calls win32event.SetEvent(self.hWaitStop), the while loop should break as win32event.WaitForSingleObject(self.hWaitStop, 0) returns zero at this point. But it doesn't do that. What am I missing? import win32serviceutil import win32service import win32event import SocketServer from SimpleXMLRPCServer import SimpleXMLRPCServer,SimpleXMLRPCRequestHandler # Threaded mix-in class AsyncXMLRPCServer(SocketServer.ThreadingMixIn,SimpleXMLRPCServer): pass class MyClass(object): def hello(self): return Hello World class SmallestPythonService(win32serviceutil.ServiceFramework): _svc_name_ = PythonXMLRPC _svc_display_name_ = PythonXMLRPC def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) # Create an event which we will use to wait on. self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) import socket localhost = socket.gethostbyname(socket.gethostname()) self.server = AsyncXMLRPCServer((localhost, 8000), SimpleXMLRPCRequestHandler) def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) win32event.SetEvent(self.hWaitStop) #print EVENT:, win32event.WaitForSingleObject(self.hWaitStop, 0) # returns 0 here def SvcDoRun(self): self.server.register_instance(MyClass()) #win32event.WAIT_TIMEOUT = 2 --- This just makes the loop never execute because # the WaitFor... part always returns 258 while win32event.WaitForSingleObject(self.hWaitStop, 0) == win32event.WAIT_TIMEOUT: self.server.handle_request() if __name__ == '__main__': win32serviceutil.HandleCommandLine(SmallestPythonService) Thanks for any help! ~Sean -- http://mail.python.org/mailman/listinfo/python-list
Re: GUI apps in Windows with native widgets?
Gilles Ganault [EMAIL PROTECTED] wrote: I'd like to write a GUI app in Python exclusively for Windows. Apparently, development of PythonWin has stopped a long time ago. I'm not sure why you would think so. The latest pywin32 release came out in September, and supports Python 2.2 through 2.6. However, PythonWin isn't really a framework for writing GUI Python apps. It's more of an IDE for Python. Is there another thin wrapper to write apps in Windows? I'd rather not have to ship eg. WxWidgets, GTK+, or QT. If you are comfortable with the Win32 API and MFC, pywin32 includes a relatively thin wrapper around MFC. It's quite possible to write GUI apps using it, and there are several good examples. I'm not sure that I'd prefer it to wxPython, however. -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and (n)curses
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: The obvious choice, I thought, was ncurses. But as far as I can tell, it is not available for Python on Windows? More precisely, curses doesn't work natively on Windows, regardless of whether Python is involved. As with many how do I get Unix feature foo on Windows?, one answer is to download and install Cygwin URL:http://www.cygwin.com/. This gives you a Unix-like environment where you can run a great many applications, including ones that depend on curses. For working with curses in Python you might find the Urwid library helpful. URL:http://excess.org/urwid/ -- \ I was in a bar the other night, hopping from barstool to | `\ barstool, trying to get lucky, but there wasn't any gum under | _o__)any of them. -- Emo Philips | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Permutation over a list with selected elements
Hi, I have been working at this problem, and I think I need a permutation algorithm that does the following: Given a list of elements that are either a character or a character follows by a number, e.g. ['a', 'b', 'c1', 'd', 'e1', 'f', 'c2', 'x', 'e2'] find all the permutations that are given by switching the positions of the elements that: (1) begins with the same letter, and (2) follows by a number. With the above list, some possible permutations are: ['a', 'b', 'c2', 'd', 'e1', 'f', 'c1', 'x', 'e2'] ['a', 'b', 'c1', 'd', 'e2', 'f', 'c2', 'x', 'e1'] ['a', 'b', 'c2', 'd', 'e2', 'f', 'c1', 'x', 'e1'] Can anyone help me out? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Rotating a picture
Hi, I'm trying to build a small spaceship battle game as an exercise, using pygame. How can I rotate the gif file of my ship by X degrees ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Rotating a picture
In [EMAIL PROTECTED], Tom Gur wrote: I'm trying to build a small spaceship battle game as an exercise, using pygame. How can I rotate the gif file of my ship by X degrees ? You shouldn't do this with the PyGame functions, the quality is poor. Either use a paint program to pre-generate rotated images or the python imaging library (PIL) to create them in the game. Either way you should use an RGB format instead of a format with a palette to have better anti aliasing, and always rotate from the original image as each rotation introduces some loss of quality and detail. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: sizeof() in python
Thanks for the reply, yes you're right I just realized it sooner. -- http://mail.python.org/mailman/listinfo/python-list
poplib.retr doens't flag message as read
Hi there, I am trying to use the poplib library to get emails using the retr method. The small program bellow works but the message aren't flagged as read which puzzles me. I believe the pop server is qmail 1.0.6 / vpopmail 5.2.1 and I am running the following script on Windows using Pyhton 2.5. import poplib import email pop = poplib.POP3('mail.server.com') pop.user('[EMAIL PROTECTED]') pop.pass_('password') status, msg_list, octets = pop.list() for msg_number in [msg.split(' ')[0] for msg in msg_list]: status, lines, octets = pop.retr(msg_number) msg = email.message_from_string('\n'.join(lines)) if not msg.is_multipart() and msg.get_content_type() == 'text/plain': print msg.get('Subject') print msg.get_payload() pop.quit() Why aren't the message flagged as read? Is there a way to manually mark them read? Thanks, EuGeNe -- http://www.3kwa.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Matrix Multiplication
sturlamolden wrote: That's what I wrote: NumPy has a matrix type. It is called called numpy.matrix. I did not suggest using the array type numpy.array. Reading carefully is indeed important... I know what you wrote and you are strictly correct. I was just clarifying it for a reader who may not have instantly realised that there were multiple array types in numpy (I didn't for a while), and could have wasted many hours and been discouraged. Explaining clearly is indeed important. -- Jeremy Sanders http://www.jeremysanders.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs
Long count = 12.19.14.7.8; tzolkin = 7 Lamat; haab = 16 Zotz. I get words from the Allmighty Great Gnus that GB == Galen Boyer [EMAIL PROTECTED] writes: GB Most other environments will be for those just trying to perform GB their tasks and staying even with the average proficiency chart. Alleluja, brother! (just unleashed the power of the True One Editor surprising the rest of the workgroup) -- /\ ___ /___/\_|_|\_|__|___Gian Uberto Lauri_ //--\| | \| | Integralista GNUslamico \/ e coltivatore diretto di Software A Cesare avrei detto di scrivermi a [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Does altering a private member decouple the property's value?
Ethan Kennerly [EMAIL PROTECTED] writes: I really like properties for readonly attributes, Python doesn't have readonly attributes, and to attempt to use properties for that purpose will only lead to confusion. and their ability to make the interface more elegant, by hiding uninteresting methods (like dumb get/set accessors). The best solution to this is not to create get/set accessors at all. Just define a simple data attribute, name the attribute logically, and use it normally. When the interface demands something other than a plain attribute, *then* consider changing it to a property; but prefer a plain data attribute in the usual case. class a_class: Define your classes as inheriting from 'object', or some other type in the Python type hierarchy, and properties will work as expected. class a_class(object): # foo -- \ When I get real bored, I like to drive downtown and get a | `\ great parking spot, then sit in my car and count how many | _o__) people ask me if I'm leaving. -- Steven Wright | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: avoid script running twice
Nick Craig-Wood wrote: Tim Williams [EMAIL PROTECTED] wrote: On 18/06/07, Nick Craig-Wood [EMAIL PROTECTED] wrote: On Windows the open-a-file-for-writing method works well, but as *nix doesn't work the same way then maybe the socket solution is the best cross-platform option. Actually you could combine your solution and Jeff McNeil's solution to make something which should work on both windows and unix and is 100% guaranteed to release the lock on process exit. import sys try: # use fcntl lock if we can from fcntl import lockf, LOCK_EX, LOCK_NB from errno import EAGAIN locking = True except ImportError: # otherwise platform mustn't open a file twice for write if sys.platform != win32: raise AssertionError(Unsupported platform for locking) locking = False try: fhandle = file(ourlockfile.txt, w) if locking: lockf(fhandle.fileno(), LOCK_EX|LOCK_NB) except IOError, e: if locking and e.errno != EAGAIN: raise print sys.stderr, exiting, another copy currently running import time time.sleep(2) (I tested it on linux only!) many interesting suggestions, unfortunately I'm not exactly sure about the filesystem to be used. I think it might be some kind of NFS which might impact some of these solutions. -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and (n)curses
I've said it before and I'll say it again. Why does Python have no platform neutral commands for simple screen manipulation? yabasic (a 'hobby' type language - http://www.yabasic.de/) has commands clear screen, inkey$ and putscreen$ which perform the basic functions of clearing the screen, reading a key press and printing a string at an arbitrary xy position in either Windows or Linux, leaving all the messy implementation away from the user. For me, introducing similar commands in Python would be by far the biggest single improvement that could be made to the language. Yes, I know the argument that it's up to me to contribute such a module. But I'm afraid my knowledge and skill are way below the threshold needed for such work. Which is why I need it as an addition to the core language! Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL cutting off letters
On 16 Jun, 17:20, Pierre Hanser [EMAIL PROTECTED] wrote: Matt Haggard a écrit : I'm using PIL (Python Imaging Library) to generate button images. They consist of a left end image, a middle, repeating image and a right side image anyway, that's not important I'm using a TTF font for the text of the button (Verdana.TTF) and it keeps cutting the bottom part of the the g's q's and y's off. hello may be the problem is in your code, but it is also possibly in PIL which clips caracters at the top and bottom line; that's not the typographic names, but these are *font* values, not characters ones. There are fonts with caracters far higher than these conventionnal lines (try Liorah.ttf or any swashed font for exemple)! I don't remember for sure but may be there is the same problem horizontally. -- Pierre I've had this problem horizontally, and solved it by the high tech method of adding a leading and trailing space!!! Peter -- http://mail.python.org/mailman/listinfo/python-list
help in rnopen in bsddb?
How ca i create a databse file using rnopen? How to set the key for this file? i am tried but i got error.. please can any one tell... -- http://mail.python.org/mailman/listinfo/python-list
is it possible to write python scripts in mainframe like REXX ??
hai folks , i am extremely new to this list can anybody tell me where can i find docs that are related to sripting in mainframe using python or how can we use python instered of REXX in mainframe how can i run python scripts in mainframe any help will be appreciated. thanks in advance regards, abhilash -- http://mail.python.org/mailman/listinfo/python-list
Python IDE
Hi, which IDE would you recommend for a python ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
On 19 Cze, 12:39, Tom Gur [EMAIL PROTECTED] wrote: Hi, which IDE would you recommend for a python ? I prefer Eclipse with PyDev extension, link - http://wiki.python.org/moin/EclipsePythonIntegration -- http://mail.python.org/mailman/listinfo/python-list
determine 32 or 64 bit architecture with python 2.2
Hello, how can I determine the architecture (32 or 64bit) with python 2.2 on Windows or Unix (AIX, Solaris) OS, without the modul platform? Thanks for your hints, Kai -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and (n)curses
On Jun 19, 2:17 am, Josiah Carlson [EMAIL PROTECTED] wrote: This link offers a series of links for console IO...http://mail.python.org/pipermail/python-list/2005-January/303984.html Thanks. Among them is a link to the 'wcurses' module that has been relocated here:http://adamv.com/dev/python/curses/ It doesn't actually work in the console, but it seems as though you can program towards one API. Yep. There is always cygwin + Python + ncurses. Of course, but I want to be able to distribute the resulting application easily. Can I do that with this solution? /David -- http://mail.python.org/mailman/listinfo/python-list
very simple shared dll with ctypes
I have created a simple windows small_dll.dll exporting a function that does a computation using C and C++ classes which i wish to call from Python. I have read lots of ctypes documentation but I still dont quite understand how to call the function. As a test, I have written a much simpler mathematical function below to try to get it to work from Python. I am trying to call this from python by: from ctypes import * print cdll.small_dll.adder(c_double(5.343534),c_double(3.4432)) 2223968 Can someone give me a few tips to get going! The DLL declaration is below. #includewindows.h #if defined(_MSC_VER) #define DLL extern C __declspec(dllexport) #else #define DLL #endif DLL double adder(double a, double b){ double c; c=a+b; return c; } -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and (n)curses
On Jun 19, 9:04 am, Ben Finney [EMAIL PROTECTED] wrote: More precisely, curses doesn't work natively on Windows, regardless of whether Python is involved. True. But then: are there other multi-platform console libraries out there? I want to code to a single API. As with many how do I get Unix feature foo on Windows?, one answer is to download and install Cygwin URL:http://www.cygwin.com/. This gives you a Unix-like environment where you can run a great many applications, including ones that depend on curses. Yes, but will I be able to easily distribute my finished application? For working with curses in Python you might find the Urwid library helpful. URL:http://excess.org/urwid/ Thanks. Just to be more precise: curses is not a requirement, a multi-platform console library with a single API is. So are there alternatives to curses? Python-only or not. And as peter mentions, Python _could_ have such a library, abstracting away the implementation details of the particular platform. Can't see why that would be hard at all. /David -- http://mail.python.org/mailman/listinfo/python-list
static python classes ?
Hi, I'm new to python, and I can't seem to find in the docs how to create the python equivalent of what's called in most OOP languages static classes, can you give me a hint ? -- http://mail.python.org/mailman/listinfo/python-list
Urgent Onsite opportunity for Python Developers
Hi, This is in Reference to the position for the direct client of Consus iTechnologies ( www.consusitechnologies.com) for Python Developer. We have reviewed your resume on one of the portal and a client of ours has a position available that we thought you might be interested in. Job Title: Python Developer Relevant Experience: 2+ yrs Location : Gurgaon / US Company : Navisite If you are interested in the position, please feel free to e-mail us at the address given below or call us at 9910353107 along with a word formatted resume of yours giving details of the projects you have done and the number of years of experience you have in the above mentioned skill sets and information about the following: 1. Updated word formatted resume. 2. Portfolio of works done 3. Current salary expected salary 4. Availability status If you are not in the market at this time feel free to forward this information to a friend or associate that has identical skills and might be interested in this position. GIVE US THE BEST NUMBERS TO REACH YOU (TELEPHONE/ MOBILE NUMBERS) SO THAT WE CAN PROCEED IN RECRUITING PROCESS Thanks Regards, Shikha Tomar Resourcing Specialist Consus iTechnologies Ltd. [EMAIL PROTECTED] Mob.9910353107 -- http://mail.python.org/mailman/listinfo/python-list
File processing - is Python suitable?
I have not used Python before, but believe it may be what I need. I have large text files containing text, numbers, and junk. I want to delete large chunks process other bits, etc, much like I'd do in an editor, but want to do it automatically. I have a set of generic rules that my fingers follow to process these files, which all follow a similar template. Question: can I translate these types of rules into programmatical constructs that Python can use to process these files? Can Python do the trick? ferrad -- http://mail.python.org/mailman/listinfo/python-list
Re: static python classes ?
On Jun 19, 10:00 pm, Tom Gur [EMAIL PROTECTED] wrote: Hi, I'm new to python, and I can't seem to find in the docs how to create the python equivalent of what's called in most OOP languages static classes, can you give me a hint ? Look for @staticmethod in http://docs.python.org/lib/built-in-funcs.html Example: class C: @staticmethod def f(arg1, arg2, ...): ... -- Gerald Kaszuba http://geraldkaszuba.com -- http://mail.python.org/mailman/listinfo/python-list
Re: static python classes ?
the python equivalent of what's called in most OOP languages static classes, can you give me a hint ? Look for @staticmethod inhttp://docs.python.org/lib/built-in-funcs.html Woops... I misread... -- Gerald Kaszuba http://geraldkaszuba.com -- http://mail.python.org/mailman/listinfo/python-list
Re: static python classes ?
On Tue, 2007-06-19 at 12:00 +, Tom Gur wrote: Hi, I'm new to python, and I can't seem to find in the docs how to create the python equivalent of what's called in most OOP languages static classes, can you give me a hint ? If I had to guess, which apparently I have to because you're not telling us what *you* think a static class is, I'd say you want a class where all methods are static. In Python, there is no point in making such a thing. Just make a module that defines the functions you need. If this doesn't help, please explain to us what you're actually trying to achieve. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
textmate and execute line
Hi, I have the latest bundle for python (upgraded from svn) but I don't understand how execute line works.. It only works if I play with arithmetic operations, something like this works: 2*2 4 but for example trying to execute this line gives me this error, any help? x = 1; x + 1 Traceback (most recent call last): File /tmp/temp_textmate.31Kc2h, line 19, in ? stdout.write(exc) TypeError: argument 1 must be string or read-only character buffer, not list Thanks a lot -- http://mail.python.org/mailman/listinfo/python-list
Re: determine 32 or 64 bit architecture with python 2.2
On Jun 19, 9:17 pm, Kai Rosenthal [EMAIL PROTECTED] wrote: Hello, how can I determine the architecture (32 or 64bit) with python 2.2 on Windows or Unix (AIX, Solaris) OS, without the modul platform? Thanks for your hints, Kai What happens when you fire up a 64-bit Python and type import sys; sys.maxint at it? -- http://mail.python.org/mailman/listinfo/python-list
Re: static python classes ?
It's not clear what you mean here. If you mean something like static inner classes in Java, then you can simply nest classes in Python: class A(object): ... class B(object): ... def aaa(self): ... print AA ... z = A.B() z.aaa() AA (In contrast the equivalent of Java's ordinary inner class: class A(object): ... def __init__(self): ... class B(object): ... def aa(self): ... print ... self.B = B ... A().B().aa() ) If you mean static class as in an class which only has static methods and variables, then the python equivalent is a module. I'm new to python, and I can't seem to find in the docs how to create the python equivalent of what's called in most OOP languages static classes, can you give me a hint ? Hope the above was what you are looking for. -- Ant... http://antroy.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: very simple shared dll with ctypes
mclaugb schrieb: I have created a simple windows small_dll.dll exporting a function that does a computation using C and C++ classes which i wish to call from Python. I have read lots of ctypes documentation but I still dont quite understand how to call the function. As a test, I have written a much simpler mathematical function below to try to get it to work from Python. I am trying to call this from python by: from ctypes import * print cdll.small_dll.adder(c_double(5.343534),c_double(3.4432)) 2223968 Can someone give me a few tips to get going! You should assign the .restype and the .argtypes attributes to your function. That gives the the proper result, and you don't have to pack the arguments into c_double yourself. The DLL declaration is below. #includewindows.h #if defined(_MSC_VER) #define DLL extern C __declspec(dllexport) #else #define DLL #endif DLL double adder(double a, double b){ double c; c=a+b; return c; } from ctypes import * adder = cdll.small_dll.adder adder.restype = c_double adder.argtypes = c_double, c_double print adder(5.343534, 3.4432) Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: static python classes ?
Look for @staticmethod inhttp://docs.python.org/lib/built-in-funcs.html Example: class C: @staticmethod def f(arg1, arg2, ...): ... Oops, sorry for the confusion - I've actually meant a static method, and Gerald's answer works fine. Thanks alot -- http://mail.python.org/mailman/listinfo/python-list
Re: File processing - is Python suitable?
ferrad wrote: I have not used Python before, but believe it may be what I need. I have large text files containing text, numbers, and junk. I want to delete large chunks process other bits, etc, much like I'd do in an editor, but want to do it automatically. I have a set of generic rules that my fingers follow to process these files, which all follow a similar template. Question: can I translate these types of rules into programmatical constructs that Python can use to process these files? Can Python do the trick? I think that's one of the great strength of Python. Just some pointers http://gnosis.cx/TPiP/ http://www.egenix.com/products/python/mxBase/mxTextTools/ -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list
Re: Trivial string substitution/parser
Duncan Booth wote: If you must insist on using backslash escapes (which introduces the question of how you get backslashes into the output: do they have to be escaped as well?) then use string.Template with a custom pattern. If anybody wants this, I worked out the following regular expression which seems to work: (?Pescaped\\)\$ | #backslash escape pattern \$(?: (?Pnamed[_a-z][_a-z0-9]*)| # delimiter and Python identifier {(?Pbraced[_a-z][_a-z0-9]*)} | # delimiter and braced identifier (?Pinvalid) # Other ill-formed delimiter exprs ) The clue is string.Template.pattern.pattern So you compile that with verbose and case-insensitive flags and set it to pattern in a string.Template subclass. (In fact you don't have to compile it, but that behaviour's undocumented.) Something like regexp = ... (?Pescaped)\\$ | # backslash escape pattern ... \$(?: ... (?Pnamed[_a-z][_a-z0-9]*)| # delimiter and identifier ... {(?Pbraced[_a-z][_a-z0-9]*)} | # ... and braced identifier ... (?Pinvalid) # Other ill-formed delimiter exprs ... ) ... class BackslashEscape(Template): ... pattern = re.compile(regexp, re.I | re.X) ... Graham -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
On Jun 19, 5:39 am, Tom Gur [EMAIL PROTECTED] wrote: Hi, which IDE would you recommend for a python ? VIM But if you crave distraction. http://wiki.python.org/moin/PythonEditors rd -- http://mail.python.org/mailman/listinfo/python-list
Re: very simple shared dll with ctypes
Assigining restype and argtypes works! Thomas Heller [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] mclaugb schrieb: I have created a simple windows small_dll.dll exporting a function that does a computation using C and C++ classes which i wish to call from Python. I have read lots of ctypes documentation but I still dont quite understand how to call the function. As a test, I have written a much simpler mathematical function below to try to get it to work from Python. I am trying to call this from python by: from ctypes import * print cdll.small_dll.adder(c_double(5.343534),c_double(3.4432)) 2223968 Can someone give me a few tips to get going! You should assign the .restype and the .argtypes attributes to your function. That gives the the proper result, and you don't have to pack the arguments into c_double yourself. The DLL declaration is below. #includewindows.h #if defined(_MSC_VER) #define DLL extern C __declspec(dllexport) #else #define DLL #endif DLL double adder(double a, double b){ double c; c=a+b; return c; } from ctypes import * adder = cdll.small_dll.adder adder.restype = c_double adder.argtypes = c_double, c_double print adder(5.343534, 3.4432) Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
BartlebyScrivener wrote: VIM *clap-clap* BTW, are there tutorials on the more arcane vim functions that come in handy with Python? Regards, Björn -- BOFH excuse #168: le0: no carrier: transceiver cable problem? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and (n)curses
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: Just to be more precise: curses is not a requirement, a multi-platform console library with a single API is. So are there alternatives to curses? Python-only or not. And as peter mentions, Python _could_ have such a library, abstracting away the implementation details of the particular platform. Can't see why that would be hard at all. And as peter mentions, it awaits only someone doing that work and contributing it to Python. Those who can't see why it would be hard are welcome to do so. -- \ The most common way people give up their power is by thinking | `\they don't have any. -- Alice Walker | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
Tom Gur [EMAIL PROTECTED] writes: which IDE would you recommend for a python ? GNU screen, Emacs or Vim, and Bash. The right tool for each job, and tools that work well together, rather than a single tool trying to do everything in its own isolated world. -- \ Killing the creator was the traditional method of patent | `\ protection -- Terry Pratchett, _Small Gods_ | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: static python classes ?
Tom Gur [EMAIL PROTECTED] writes: I'm new to python, and I can't seem to find in the docs how to create the python equivalent of what's called in most OOP languages static classes, can you give me a hint ? Can you give us a hint of what a static class would do? That is, what features do you require that you can't find how to implement? -- \ I've always wanted to be somebody, but I see now that I should | `\have been more specific. -- Jane Wagner, via Lily Tomlin | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and (n)curses
On Tue, 19 Jun 2007 02:43:09 -0700, peter [EMAIL PROTECTED] wrote: I've said it before and I'll say it again. Why does Python have no platform neutral commands for simple screen manipulation? yabasic (a 'hobby' type language - http://www.yabasic.de/) has commands clear screen, inkey$ and putscreen$ which perform the basic functions of clearing the screen, reading a key press and printing a string at an arbitrary xy position in either Windows or Linux, leaving all the messy implementation away from the user. Curses is much more than that, though. One cool feature is its redraw optimizations -- do a lot of changes, and call a commit-type method, and curses chooses the most optimal (for your terminal) way of changing the display according to your wishes. For me, introducing similar commands in Python would be by far the biggest single improvement that could be made to the language. If it should be done, it should be done as a compatible subset of curses, IMHO. It has such a long history as the standard GUI toolkit for text terminals. try: import curses except ImportError: import inferior_curses as curses /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: File processing - is Python suitable?
ferrad wrote: I have large text files containing text, numbers, and junk. I want to delete large chunks process other bits, etc, much like I'd do in an editor, but want to do it automatically. Question: can I translate these types of rules into programmatical constructs that Python can use to process these files? Someone can. ;-) However if the file is structured, awk may be faster, since this sounds like the kind of report generation it was designed for. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: GUI apps in Windows with native widgets?
From: Gilles Ganault [EMAIL PROTECTED] Subj: GUI apps in Windows with native widgets? Date: 19.6.2007 04:15:55 Hello I'd like to write a GUI app in Python exclusively for Windows. Apparently, development of PythonWin has stopped a long time ago. Is there another thin wrapper to write apps in Windows? I'd rather not have to ship eg. WxWidgets, GTK+, or QT. Thank you. -- http://mail.python.org/mailman/listinfo/python-list Hello, I haven't tried it myself in a real application (while using wxpython), but Venster seems to be much more lightweight than some other more popular GUI toolkits; it also supports only Windows. You may check it here: http://venster.sourceforge.net/htdocs/index.html The most important thing would be to determine, if it suits your needs (e.g. the supported widgets, methods etc.) Greetings, Vlastimil Brom -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs
Galen Boyer [EMAIL PROTECTED] writes: On Mon, 18 Jun 2007, [EMAIL PROTECTED] wrote: The problem with this line of thinking is that it aims to make Emacs appeal to people -- I think it is rather the other way around. Certain people appeal to Emacs: certain kinds of people like Emacs and the way it is set up, and they change it to suit their needs. Emacs will always be for people who like to be able to constantly fiddle with their environments which continues to increase the efficiency with which they perform their tasks, increasing the # of tasks they can perform and therefore increasing the # of peers it would take to equal the amount of work they alone perform. Most other environments will be for those just trying to perform their tasks and staying even with the average proficiency chart. -- Galen Boyer constantly fiddle I've used emacs since the 1980's. I've used it for text, xml, html markups, programming in many languages, and natural languages. In a few cases I've fiddled with the environment. I've even written a mode. But it has never been constantly. One does the setup, and then uses it day after day, year after year... until you have a new need, in which case you re-tune your settings and then go back to work. trying to perform their tasks...average proficiency Aye, there's the rub. As Fred Brooks and others repeatedly point out, there is little room in programming for average proficiency. I don't mind folks using any editor they want, as long as they are proficient. In those cases, I have no problem doing Extreme Programming with them -- code a bit, save, the other guy codes a bit. But when someone uses vi and then forgets how to do block moves, or uses eclipse and bogs down the session, or uses MS Notepad and can't enforce language-specific indents, I get frustrated. -- Harry George PLM Engineering Architecture -- http://mail.python.org/mailman/listinfo/python-list
Re: static python classes ?
Tom Gur wrote: Hi, I'm new to python, and I can't seem to find in the docs how to create the python equivalent of what's called in most OOP languages static classes, can you give me a hint ? With other OOP languages you mean Java. Which does have static methods because they lack the notion of a function by its own, so the shoehorned them into their everything is inside a class-paradigm. Forget about that. As well as getters and setters, interfaces and the like. Just use a module-level function. diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and (n)curses
On Jun 19, 3:27 pm, Ben Finney [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] [EMAIL PROTECTED] writes: Just to be more precise: curses is not a requirement, a multi-platform console library with a single API is. So are there alternatives to curses? Python-only or not. You wouldn't happen to have an answer to this question? And as peter mentions, Python _could_ have such a library, abstracting away the implementation details of the particular platform. Can't see why that would be hard at all. And as peter mentions, it awaits only someone doing that work and contributing it to Python. Those who can't see why it would be hard are welcome to do so. The classic answer. /David -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs
Harry George [EMAIL PROTECTED] writes: I don't mind folks using any editor they want, as long as they are proficient. In those cases, I have no problem doing Extreme Programming with them -- code a bit, save, the other guy codes a bit. But when someone uses vi and then forgets how to do block moves, or uses eclipse and bogs down the session, or uses MS Notepad and can't enforce language-specific indents, I get frustrated. My favorite killing offence is /* vi:set ts=4: */. -- David Kastrup -- http://mail.python.org/mailman/listinfo/python-list
Re: File processing - is Python suitable?
ferrad wrote: I have not used Python before, but believe it may be what I need. I have large text files containing text, numbers, and junk. I want to delete large chunks process other bits, etc, much like I'd do in an editor, but want to do it automatically. I have a set of generic rules that my fingers follow to process these files, which all follow a similar template. Question: can I translate these types of rules into programmatical constructs that Python can use to process these files? Can Python do the trick? Yes, and if you are a non-programmer, the entry barrier for Python is as low as it can get. However, what a programming language treats as a rule is much stricter than what a human being might expect. For example, appending an 's' to the first word in a sentence is easy in Python, changing the subject's numerus to plural is hard. Both are doable, but the less technical your rules are the harder they become to translate. You often have to compromise either by proofreading the results of any automated processing, or by having your program ask a human operator in the cases it can't decide upon. I recommend that you play around a bit in the interactive interpreter to get a feel for the kind of operations that are easily available on strings. Then write the processing rules into a script, and always start your conversion from the original data (of which you you have a backup in some locker), not some intermediate output. That way you can try processing without losing information in the data or about the process -- until you find the results acceptable. Make backups of your script, too, before you are trying something new. Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Does altering a private member decouple the property's value?
On Tue, 19 Jun 2007 18:54:41 +1000, Ben Finney wrote: Ethan Kennerly [EMAIL PROTECTED] writes: I really like properties for readonly attributes, Python doesn't have readonly attributes, and to attempt to use properties for that purpose will only lead to confusion. class Parrot(object): def _plumage(self): return Beautiful red plumage plumage = property(_plumage) parrot = Parrot() parrot.plumage 'Beautiful red plumage' parrot.plumage = Ragged grey feathers Traceback (most recent call last): File stdin, line 1, in module AttributeError: can't set attribute It walks like a read-only attribute, it squawks like a read-only attribute, but since Python doesn't have read-only attributes, Ben must be right: using properties to implement read-only attributes will only lead to confusion. *wink* -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: Does altering a private member decouple the property's value?
Ben Finney [EMAIL PROTECTED] wrote: Ethan Kennerly [EMAIL PROTECTED] writes: I really like properties for readonly attributes, Python doesn't have readonly attributes, Many Python types do, e.g.: def f(): pass ... def g(): pass ... f.func_name = 'zap' f.func_code = g.func_code f function zap at 0x66070 f.func_code code object g at 0x55458, file stdin, line 1 f.func_closure = g.func_closure Traceback (most recent call last): File stdin, line 1, in module TypeError: readonly attribute i.e., you can reassign some of f's attributes (such as its name and code) but others (such as its closure) are readonly (as the TypeError's message says) so you cannot reassign those. It makes just as much sense for user-coded types (aka classes) to have some r/w attributes and others that are readonly, as it does for builtin types -- and properties are often the simplest way to accomplish that. and to attempt to use properties for that purpose will only lead to confusion. I disagree -- a property is a great way to implement readonly attributes, as long as you're using a new-style class of course. class Rectangle(object): def __init__(self, w, h): self.w = w self.h = h area = property(lambda self: self.w * self.h) No confusion here -- given a Rectangle instance r, you can both read and write (reassign) r.w and r.h, but r.area is readonly (can't be set): r = Rectangle(12, 34) r.area 408 r.h = 10 r.area 120 r.area = 144 Traceback (most recent call last): File stdin, line 1, in module AttributeError: can't set attribute Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs
David Kastrup wrote: My favorite killing offence is /* vi:set ts=4: */. This is apparently the default setting in many of the so-called IDEs today.. I think it's another unwelcome poison gift from the ignorant M$FT world (I suspect some primitive Windoze IDE which couldn't differentiate between TAB and indent probably offered the programmer changing the tabwidth as the only method for changing indentation, and then this method got stuck...) F'up to comp.emacs. -- http://mail.python.org/mailman/listinfo/python-list
Re: determine 32 or 64 bit architecture with python 2.2
On Jun 19, 4:28 pm, John Machin [EMAIL PROTECTED] wrote: On Jun 19, 9:17 pm, Kai Rosenthal [EMAIL PROTECTED] wrote: Hello, how can I determine the architecture (32 or 64bit) with python 2.2 on Windows or Unix (AIX, Solaris) OS, without the modul platform? Thanks for your hints, Kai What happens when you fire up a 64-bit Python and type import sys; sys.maxint at it? That's not suitable, because of the differences between LP64 and LLP64 (http://en.wikipedia.org/wiki/64-bit#64-bit_data_models ). Try python -c import struct; print struct.calcsize('P') instead. That calculates the size of a pointer. -- http://mail.python.org/mailman/listinfo/python-list
Re: Convert to C/C++?
On Thu, 14 Jun 2007 13:16:42 -0700, SpreadTooThin [EMAIL PROTECTED] wrote: I am wondering if someone who knows the implemention of python's time could help converting this to c/c++ nanoseconds = int(time.time() * 1e9) [straightforward non-time arithmetic snipped] vs unix gettimeofday int gettimeofday(struct timeval *tp, struct timezone *tzp); struct timeval { long tv_sec; /* seconds since Jan. 1, 1970 */ long tv_usec;/* and microseconds */ }; Quite simply, time.time() corresponds to tv_sec + tv_usec/1e6, modulo any rounding and numerical errors introduced by the floating-point format used. struct timezone { int tz_minuteswest; /* of Greenwich */ int tz_dsttime; /* type of dst correction to apply */ }; The struct timezone is not set by Linux/glibc gettimeofday(), so you can happily ignore it. You only want UTC time anyway. /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
On 2007-06-19, Bjoern Schliessmann [EMAIL PROTECTED] wrote: BartlebyScrivener wrote: VIM *clap-clap* BTW, are there tutorials on the more arcane vim functions that come in handy with Python? One thing to do is to look in your vim ftplugin directory and read python.vim. Unfortunately, the current version contains no documention, so it's harder to figure out what you get than it ought to be. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
missing modules help
Dear list, I am attempting to build a python based project off SourceForge, iTorrent ( http://sourceforge.net/project/showfiles.php?group_id=163841package_id=185388release_id=415006). The project is built with py2exe, includes bittorrent 4.4 and appears to require a number of dependent modules. This is the error message that I receive when I build: The following modules appear to be missing ['FCNTL', 'Foundation', 'OpenSSL', '_curses', 'entropy', 'gdk', 'kqsyscall', 'ltihooks', 'mxDateTime.__version__', 'resource', ' win32com.gen_py'] I have installed the following modules: py2exe-0.6.6.win32-py2.4 pywin32-210.win32-py2.4 ctypes-1.0.2.win32-py2.4 pygtk-2.10.2.win32-py2.4 pyobject-2.12.3-1.win32-py2.4 pycairo-1.2.6.1.win32-py2.4 egenix-mx-base.3.0.0..win32-py2.4 gtk+2.10.11 wxPython2.8-win32-unicode-2.8.4-py24 winshell02 Can anyone help me get bootstrapped? What is the best way of hunting down these modules? Thank you, and I hope that your help will in turn allow me to contribute to the community. -Chris Judd -- http://mail.python.org/mailman/listinfo/python-list
Re: HTMLParser.HTMLParseError: EOF in middle of construct
Gabriel Genellina wrote: En Mon, 18 Jun 2007 16:38:18 -0300, Sergio Monteiro Basto [EMAIL PROTECTED] escribió: Can someone explain me, what is wrong with this site ? python linkExtractor3.py http://www.noticiasdeaveiro.pt test HTMLParser.HTMLParseError: EOF in middle of construct, at line 1173, column 1 at line 1173 of test file is perfectly normal . That page is not valid HTML - http://validator.w3.org/ finds 726 errors in it. ok but my problem is not understand what is the specific problem at line 1173 HTMLParser expects valid HTML - try a different tool, like BeautifulSoup, which is specially designed to handle malformed pages. --Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: HTMLParser.HTMLParseError: EOF in middle of construct
Gabriel Genellina wrote: En Mon, 18 Jun 2007 16:38:18 -0300, Sergio Monteiro Basto [EMAIL PROTECTED] escribió: Can someone explain me, what is wrong with this site ? python linkExtractor3.py http://www.noticiasdeaveiro.pt test HTMLParser.HTMLParseError: EOF in middle of construct, at line 1173, column 1 at line 1173 of test file is perfectly normal . That page is not valid HTML - http://validator.w3.org/ finds 726 errors in it. ok but my problem is not understand what is the specific problem at line 1173 HTMLParser expects valid HTML - try a different tool, like BeautifulSoup, which is specially designed to handle malformed pages. --Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Thunderbird access to this newsgroup
On Jun 18, 1:23 pm, Steve Holden [EMAIL PROTECTED] wrote: You might find, as many others do, that it's convenient to read this group using the Gmane service - it's group gmane.comp.python.general on server news.gmane.org. I tried news.gmane.org in Thunderbird and I keep on getting a error saying it can not find the server. Your friend, Scott -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
Tom Gur [EMAIL PROTECTED] wrote: which IDE would you recommend for a python ? It depends on that python's tastes and preferences. Like many others who have already responded, I prefer an editor (VIM) and a separate commandline/terminal; I know of many others who share another responder's preference for Eclipse+PythonDev; other options that should be mentioned include IDLE, Wing, eric4, Microsoft Visual Studio (Windows-only), Apple's XCode (Mac-only), ... Alex -- http://mail.python.org/mailman/listinfo/python-list
[ANN] pysqlite 2.3.4 released
pysqlite 2.3.4 released === I'm pleased to announce the availability of pysqlite 2.3.4. This is a bugfix release. Go to http://pysqlite.org/ for downloads, online documentation and reporting bugs. What is pysqlite? pysqlite is a DB-API 2.0-compliant database interface for SQLite. SQLite is a relational database management system contained in a relatively small C library. It is a public domain project created by D. Richard Hipp. Unlike the usual client-server paradigm, the SQLite engine is not a standalone process with which the program communicates, but is linked in and thus becomes an integral part of the program. The library implements most of SQL-92 standard, including transactions, triggers and most of complex queries. pysqlite makes this powerful embedded SQL engine available to Python programmers. It stays compatible with the Python database API specification 2.0 as much as possible, but also exposes most of SQLite's native API, so that it is for example possible to create user-defined SQL functions and aggregates in Python. If you need a relational database for your applications, or even small tools or helper scripts, pysqlite is often a good fit. It's easy to use, easy to deploy, and does not depend on any other Python libraries or platform libraries, except SQLite. SQLite itself is ported to most platforms you'd ever care about. It's often a good alternative to MySQL, the Microsoft JET engine or the MSDE, without having any of their license and deployment issues. pysqlite can be downloaded from http://pysqlite.org/ - Sources and Windows binaries for Python 2.5, 2.4 and Python 2.3 are available. === CHANGES === - pysqlite is now easy_install-able. - Under some circumstances it's was not possible to close the connection object. This happened if you still had cursor objects around with statements that were no longer in the cached statements pool. This was fixed by finalizing all statements that were created from the connection instead of only those that are still found in the connection pool. - SQLite often does not report useful error messages when the stepped-on statement was not reset first. Now we make sure that's always the case. - From Python core version: Patch by Tim Delany (missing DECREF). SF #1731330. - Merged missing corrections for sample code from Python core version. - Allow the size parameter for fetchmany() for better DB-API compliance. - Allow a static build of pysqlite using the SQLite amalgamation. Copy sqlite3.c and sqlite3.h into the pysqlite directory, then use $ python extended_setup.py build_static to build pysqlite. setuptools must be installed in order to use the extended_setup.py script. - Applied patch from #184. This defers the implicit BEGINs/COMMITs and thus improves concurrency. - Print a warning if somebody tries to run the pysqlite test suite from the pysqlite root directory and exit. In earlier versions, the user would get a hard to understand error message about a missing extension module instead. -- http://mail.python.org/mailman/listinfo/python-list
Re: HTMLParser.HTMLParseError: EOF in middle of construct
Gabriel Genellina wrote: En Mon, 18 Jun 2007 16:38:18 -0300, Sergio Monteiro Basto [EMAIL PROTECTED] escribió: Can someone explain me, what is wrong with this site ? python linkExtractor3.py http://www.noticiasdeaveiro.pt test HTMLParser.HTMLParseError: EOF in middle of construct, at line 1173, column 1 at line 1173 of test file is perfectly normal . That page is not valid HTML - http://validator.w3.org/ finds 726 errors in it. ok but my problem is not understand what is the specific problem at line 1173 HTMLParser expects valid HTML - try a different tool, like BeautifulSoup, which is specially designed to handle malformed pages. --Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
ctypes pointer
I have a simple function void adder(double a, double b, double *c){ *c = a+b; } i have created a shared dll -- small_dll4.dll of it using visual studio. now i wish to call it from python. to do so, i have done the following: libx = cdll(small_dll4.dll, RTLD_GLOBAL) libx.adder.argtypes = [c_double, c_double, POINTER(c_double)] libx.adder.restype = None size=c_double() zz=libd.adder(3.342, 4, byref(size)) and the result is an access violation! File console, line 0, in __main__ WindowsError: exception: access violation reading 0x7EF9DB23 I cant figure out what is causing this. thanks in advance, Bryan -- http://mail.python.org/mailman/listinfo/python-list
Re: HTMLParser.HTMLParseError: EOF in middle of construct
In [EMAIL PROTECTED], none wrote: Gabriel Genellina wrote: En Mon, 18 Jun 2007 16:38:18 -0300, Sergio Monteiro Basto [EMAIL PROTECTED] escribió: Can someone explain me, what is wrong with this site ? python linkExtractor3.py http://www.noticiasdeaveiro.pt test HTMLParser.HTMLParseError: EOF in middle of construct, at line 1173, column 1 at line 1173 of test file is perfectly normal . That page is not valid HTML - http://validator.w3.org/ finds 726 errors in it. ok but my problem is not understand what is the specific problem at line 1173 You can't just look at that line and ignore the rest. There are 604 (!) errors, some about table rows, before this line. So the parser may be confused at this point and be already in an internal state that sees that line in a completely different light than you do. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
jedit - auto code completetion
Hi Does it have a plug-in for python code completetion ? thks -- http://mail.python.org/mailman/listinfo/python-list
Re: Output of HTML parsing
On 6 15 , 2 01 , Stefan Behnel [EMAIL PROTECTED] wrote: Jackie wrote: import lxml.etree as et url = http://www.economics.utoronto.ca/index.php/index/person/faculty/; tree = et.parse(url) Stefan- - - - Thank you. But when I tried to run the above part, the following message showed up: Traceback (most recent call last): File D:\TS\Python\workspace\eco_department\lxml_ver.py, line 3, in module tree = et.parse(url) File etree.pyx, line 1845, in etree.parse File parser.pxi, line 928, in etree._parseDocument File parser.pxi, line 932, in etree._parseDocumentFromURL File parser.pxi, line 849, in etree._parseDocFromFile File parser.pxi, line 557, in etree._BaseParser._parseDocFromFile File parser.pxi, line 631, in etree._handleParseResult File parser.pxi, line 602, in etree._raiseParseError etree.XMLSyntaxError: line 2845: Premature end of data in tag html line 8 Could you please tell me where went wrong? Thank you Jackie -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
Bjoern Schliessmann wrote: BartlebyScrivener wrote: VIM *clap-clap* BTW, are there tutorials on the more arcane vim functions that come in handy with Python? Regards, Björn Not a tutorial, but I found this little snippet: http://www.ibiblio.org/obp/pyBiblio/tips/elkner/vim4python.php I thought the last line was especially neat. Will -- http://mail.python.org/mailman/listinfo/python-list
Re: Output of HTML parsing
Jackie schrieb: On 6 15 , 2 01 , Stefan Behnel [EMAIL PROTECTED] wrote: Jackie wrote: import lxml.etree as et url = http://www.economics.utoronto.ca/index.php/index/person/faculty/; tree = et.parse(url) Stefan- - - - Thank you. But when I tried to run the above part, the following message showed up: Traceback (most recent call last): File D:\TS\Python\workspace\eco_department\lxml_ver.py, line 3, in module tree = et.parse(url) File etree.pyx, line 1845, in etree.parse File parser.pxi, line 928, in etree._parseDocument File parser.pxi, line 932, in etree._parseDocumentFromURL File parser.pxi, line 849, in etree._parseDocFromFile File parser.pxi, line 557, in etree._BaseParser._parseDocFromFile File parser.pxi, line 631, in etree._handleParseResult File parser.pxi, line 602, in etree._raiseParseError etree.XMLSyntaxError: line 2845: Premature end of data in tag html line 8 Could you please tell me where went wrong? Ah, ok, then the page is not actually XHTML, but broken HTML. Use this idiom instead: parser = et.HTMLParser() tree = et.parse(url, parser) Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
Douglas Alan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | Terry Reedy [EMAIL PROTECTED] writes: | | |oug writes: | | Scheme has a powerful syntax extension mechanism | | I did not and do not see this as relevant to the main points of my | summary above. The main point of my original post was that the quoted slam at Python was based on a misquote of Tim Peters and a mischaracterization of Python and that it was out-of-place in the quoted discussion of physics methods and that it added nothing to that discussion and should better have been omitted. *All of this has nothing to do with Scheme.* At the end, I added as a *side note* the irony that the purported author was the co-developer of Scheme, another 'minimalist algorithm language (Wikipedia's characterization) with more uniform syntax than Python and like Python, also with one preferred way to scan sequences (based on my memory of Scheme use in the original SICP, co-authored by the same purported quote author, and also confirmed by Wikipedia). I do not consider it a slam at Scheme to compare it with Python and see some similarities. Nor is it a slam at Scheme to suggest that it could just as well have been the subject of an unfair slam, if only the slammer were not its co-developer ;-) | [Steele quote deleted] | Do you now see how Scheme's syntax extension mechanism is relevant? No. This just partly explains why Scheme gets away with being minimalist. I explicitly referred to the core language as delivered and as used in SICP. tjr -- http://mail.python.org/mailman/listinfo/python-list
Re: ctypes pointer
I answered this one already. from ctypes import * libx = CDLL(small_dll5.dll, RTLD_GLOBAL) libx = cdll.small_dll4 libx.adder.restype = None libx.adder.argtypes = [c_double, c_double, POINTER(c_double)] real=c_double(0) imag=c_double(0) zz=libx.adder(3.342,4,byref(size)) print size mclaugb [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have a simple function void adder(double a, double b, double *c){ *c = a+b; } i have created a shared dll -- small_dll4.dll of it using visual studio. now i wish to call it from python. to do so, i have done the following: libx = cdll(small_dll4.dll, RTLD_GLOBAL) libx.adder.argtypes = [c_double, c_double, POINTER(c_double)] libx.adder.restype = None size=c_double() zz=libd.adder(3.342, 4, byref(size)) and the result is an access violation! File console, line 0, in __main__ WindowsError: exception: access violation reading 0x7EF9DB23 I cant figure out what is causing this. thanks in advance, Bryan -- http://mail.python.org/mailman/listinfo/python-list
Re: Set timeout and kill external windows
At Saturday 16/06/2007 02:24, you wrote: Thanks for your reply. I am new to Python and I cannot seem to figure this out. I searched for examples based on your recommendation below but couldn't do it. I am not familiar with subprocess and WaitForSingleObject. And I want to do this in Windows. Could you please write me the few lines I need to do this? (Please keep posting on the list - other people may help too, and I don't read this email too often). Try this. (I had to use a private Popen attribute, _handle). import subprocess from win32event import WaitForSingleObject, WAIT_TIMEOUT from win32api import TerminateProcess def execute_and_wait(args, timeout=None): Execute a command and wait until termination. If timeout elapses and still not finished, kill it. args: list containing program and arguments, or a single string. timeout: maximum time to wait, in ms, or None. p = subprocess.Popen(args) if timeout: ret = WaitForSingleObject(p._handle, timeout) if ret==WAIT_TIMEOUT: TerminateProcess(p._handle, 1) return None return p.wait() ret = execute_and_wait([notepad, c:\\python\\LICENSE.txt], 5000) print ret=,ret -- Gabriel Genellina __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
pydev help
My first post! Greetings all, I am trying to get pydev up and running in linux. I have it up and running in windows but for some strange reason not here. I did install pydev a few months ago on my windows machine so that may be the reason why.. I followed this guide: http://www.fabioz.com/pydev/manual_101_install.html When I get to about the middle of the page where it seemingly loading everything and I get this: Pydev Mylar Integration (0.2.0) requires plug-in org.eclipse.mylar (2.0.0.v20070403-1300), or later version. Where do I get that module from? Thanks, Danyelle -- http://mail.python.org/mailman/listinfo/python-list
Re: ctypes pointer
mclaugb schrieb: I have a simple function void adder(double a, double b, double *c){ *c = a+b; } i have created a shared dll -- small_dll4.dll of it using visual studio. now i wish to call it from python. to do so, i have done the following: libx = cdll(small_dll4.dll, RTLD_GLOBAL) libx.adder.argtypes = [c_double, c_double, POINTER(c_double)] libx.adder.restype = None size=c_double() zz=libd.adder(3.342, 4, byref(size)) and the result is an access violation! File console, line 0, in __main__ WindowsError: exception: access violation reading 0x7EF9DB23 I cant figure out what is causing this. That should work (and works for me, of course). Do you have a typo in the above code? libd instead of libx? Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: pydev help
Its called mylyn now. You can get it from here: http://www.eclipse.org/mylyn/dl.php Best, Chris On 6/19/07, Danyelle Gragsone [EMAIL PROTECTED] wrote: My first post! Greetings all, I am trying to get pydev up and running in linux. I have it up and running in windows but for some strange reason not here. I did install pydev a few months ago on my windows machine so that may be the reason why.. I followed this guide: http://www.fabioz.com/pydev/manual_101_install.html When I get to about the middle of the page where it seemingly loading everything and I get this: Pydev Mylar Integration (0.2.0) requires plug-in org.eclipse.mylar (2.0.0.v20070403-1300), or later version. Where do I get that module from? Thanks, Danyelle -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Python-URL! - weekly Python news and links (Jun 19)
QOTW: Regarding a Java programmer moving to Python, a lot of the mindset change is about the abundant use of built in data types of Python. So a Java programmer, when confronted with a problem, should think 'how can I solve this using lists, dicts and tuples?' (and perhaps also my new favourite, sets). Class-based solution should be chosen only after seeing that the problem can't be trivially solved with built-in types. - Ville Vainio The remainder of the unittest docs are somewhat obtuse and uninspiring. - Raymond Hettinger How to generate HTML page thumbnails: John J Lee enumerates several alternatives, using MSIE, Firefox, Konqueror and others. http://groups.google.com/group/comp.lang.python/browse_thread/thread/2185ad4e31c9320b/ Concatenating strings may be painfully slow in some circumstances if not done the right way: http://groups.google.com/group/comp.lang.python/browse_thread/thread/3999b83838787fa1/ Initializing class members only when needed, using a LazyClassAttribute decorator: http://groups.google.com/group/comp.lang.python/browse_thread/thread/18f8b54cb15f922f/ Postpone attribute creation: similar to thread above, but more from a design perspective: http://groups.google.com/group/comp.lang.python/browse_thread/thread/393d2ac620716d90/ Simple Programs: the search for small, complete, useful examples of Python code still continues: http://groups.google.com/group/comp.lang.python/browse_thread/thread/ec8184ca4ed7e3e6/ See the resulting programs at http://wiki.python.org/moin/SimplePrograms A simple question: How many list items comply with this condition?, and many answers: http://groups.google.com/group/comp.lang.python/browse_thread/thread/6d488fb624fbb6a7/ Continuing from last week: only one way to do it, now discussing tail call optimization, generic programming, Scheme and macros... http://groups.google.com/group/comp.lang.python/browse_thread/thread/e587471d08dbfcbb/ 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. The Python Papers aims to publish the efforts of Python enthusiats. http://pythonpapers.org/ Readers have recommended the Planet sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djqas_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 continues the marvelous tradition early borne by Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim Lesher 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
Re: sqlite3 bug??
Hyuga wrote: On Jun 17, 9:16 am, mark carter [EMAIL PROTECTED] wrote: Should I also explicitly close the cursor and connection, or is that taken care of automagically? Somebody correct me if I'm wrong, but I'm pretty sure that the Cursor and Connection objects properly clean themselves up when deallocated (when their reference count reaches 0), so not explicitly closing them isn't a terrible thing. [...] That's correct for pysqlite, and probably for all other DB-API modules too. If you have a client-server database, it's nicer to close the database connection if you don't need it any longer in order to free up resources on the server, of course. In fact, I have code in which references to a db connection are passed around, so I have to be careful about explicitly closing the connection, lest it be in use by some other method somewhere. Maybe people will frown on this, but it's not uncommon. I don't think I've ever explicitly closed a cursor object when programming to the DB-API myself. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
easy_install from svn
Hi all, I currently use easy_install to install packages from a custom, locally hosted package_index. The index consists of a single html doc with a list of package names and urls. All works well. I would like to get a little more sophisticated and install a package from subversion. My package is structured as described in the setuptools docs. Simply pointing the url in my package index to svn://my/repo/package/trunk works, but I would like - and I get the impression it is possible - to be able to specify a revision number, or a tag and have that version installed. Is it simply a case of appending a fragment to the url? Would anyone be so kind as to provide a working example? cheers, Rob Cowie -- http://mail.python.org/mailman/listinfo/python-list
Re: pydev help
ty! Danyelle -- http://mail.python.org/mailman/listinfo/python-list
Phraserate
I have found the Phraserate algorithm to extract keyphrases from html pages and I tried it and it works like a charm. However the algorithm is integrated in the much bigger iVia library, but I need something smaller and more practical, so I was wondering if someone knows of a python implementation of the Phraserate algorithm. Thanks for the replies. -- http://mail.python.org/mailman/listinfo/python-list
ni pci-6010 Analog Input Multifunction DAQ
Hello there is someone that have experience with the ni-pci-6010 Analog Input Multifunction DAQ and python? -- http://mail.python.org/mailman/listinfo/python-list
Re: ctypes pointer
Yes, i double defined one of the terms when copying it. This now works by value and by reference. Thanks alot, Bryan Thomas Heller [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] mclaugb schrieb: I have a simple function void adder(double a, double b, double *c){ *c = a+b; } i have created a shared dll -- small_dll4.dll of it using visual studio. now i wish to call it from python. to do so, i have done the following: libx = cdll(small_dll4.dll, RTLD_GLOBAL) libx.adder.argtypes = [c_double, c_double, POINTER(c_double)] libx.adder.restype = None size=c_double() zz=libd.adder(3.342, 4, byref(size)) and the result is an access violation! File console, line 0, in __main__ WindowsError: exception: access violation reading 0x7EF9DB23 I cant figure out what is causing this. That should work (and works for me, of course). Do you have a typo in the above code? libd instead of libx? Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs: terminology buffer and keybinding
Here are some Frequently Asked Questions about The Modernization of Emacs. They are slightly lengthy, so i've separated each item per post. The whole article can be found at http://xahlee.org/emacs/modernization.html Q: The Terminology “buffer” and “keybinding” is good as they are. A: The terminology “buffer” or “keybinding”, are technical terms having to do with software programing. The term “keybinding” refers to the association of a keystroke with a command in a technical, software application programing context. That is to say, a programer “bind” a keystroke to a command in a software application. The term “buffer” refers to a abstract, temporary area for storing data, in the context of programing or computer science. These terms are irrelevant to the users of a software application. As a user of a text editor, he works with files. The terms “opened file” or “untitled file” are more appropriate than “buffer”. Since emacs is also used for many things beside reading files or writing to files, for example, file management, ftp/sftp, shell, email, irc etc., the proper term can be “panel”, “window”, or “work area”. And, the term “keyboard shortcut” refers to typing of a key- combination to activate a command. It is also more appropriate than “binding” or “keybinding”. Although concepts like “buffer” and “keybinding” are seemingly interchangeable with “panel” or “keyboard shortcut”, but their contexts set them apart. This is why in all modern software application's user documentations, terms like “buffer” or “keybinding” are not to be seen but “windows, panes, and keyboard shortcuts”. The reason emacs uses the technical terminologies throughout is because when emacs started in the 1970s, there really isn't any other text editors or even software applications. And, Emacs users consists of solely computer scientists and programers, and there are not many. Changes in society are always resisted by old timers, but it is also a main element behind progress. This terminology issue may seem trivial, but its importance lies in making emacs palpable to the vast number of people who ever need to use a computer to write. Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs: not dumb down
Here are some Frequently Asked Questions about The Modernization of Emacs. They are slightly lengthy, so i've separated each item per post. The whole article can be found at http://xahlee.org/emacs/modernization.html Q: Why should emacs want to be popular and why should emacs change to conform the majority? We don't want emacs to be popular. We want people to adopt emacs, not emacs adopting people. A: This attitude has plagued unix and computer geekers for decades. In the early 1990s (DOS and unix), tech geekers would sneer at graphical menus and mouse, with hordes of reasons how pure text interface, the command line, and or keyboard operations are sufficient and superior than graphical user interface or using a mouse. This seems ridiculous today, but such online forum messages are common. The reason for these type of attitude, is almost never a sensible alternative view about the topic in discussion, but a show of machismo and superiority complex. (perhaps more than 95% of online computing forum users are males, and majority of them are aged under 25.) The person who utters such opinion, made sure in the way he writes that he is a expert in the “more difficult to use” method or tools and would prefer things not to be “dumbed down”. It is silly to retort “Why should emacs want to be popular?”. It is like asking “why do you want to live longer?” when someone is picky about healthy food, or “why should you want to look beautiful?” when someone dresses up. We want to improve software, not taking the attitude of “we are more complex and unique and superior and we want to keep dummies out”. In software design, occasionally we are tied down with a design decision, such that it has a popular vs elegant aspect. For example, suppose we are designing a set of keyboard shortcuts for emacs and we are faced the question of whether to keep the copy/paste/undo/open etc with the conventional C/V/Z/O etc keystrokes. Or, we can choose to sacrifice user's familiarity of conventions but obtain a keyboard shortcut set that is in some way more consistent, extensible, or otherwise technically better. If a design decision comes down to a pure popularity vs elegance and everything else equal, then the decision might be based on our philosophical dispositions or the software creator's ultimate goal. However, it is not proper to pigeon-hole design issues into popularity vs elegance. Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs: technically superior
Here are some Frequently Asked Questions about The Modernization of Emacs. They are slightly lengthy, so i've separated each item per post. The whole article can be found at http://xahlee.org/emacs/modernization.html Q: Emacs's ways are technically superior. It should not change. A: Emac's user interface, when compared to modern software application's user interface, is complex and unusual, however, there's no basis whatsoever of it being actually a superior design with regards to any sensible metrics. (in fact, much of emacs's user interface are due to historical reasons. That is, how computers are in 1980s.) For example, let's consider emacs's system of keyboard shortcuts. For a keyboard shortcut system, we might judge its quality based on several aspects. Here are some examples of consideration: * Is it easy to learn? (is it familiar to most people?) * Is it easy to type? (is most frequently used commands easy to type?) * Is it easy to remember? * Are more frequently used commands have the easier-to-type shortcuts that less frequently used commands? * Are most frequently used commands all have a keyboard shortcut? * Can the shortcut system somehow be consistent and extensible to cover other user defined shortcuts? Emacs's keyboard shortcuts system, somewhat satisfies the last aspect, but do very bad with respect to all the others. Emacs keyboard shortcuts are perhaps one of the most difficult to learn among software, and is also one of the most difficult to remember. The worst aspect of emacs's keyboard shortcuts, is that it is ergonomically painful. (Many emacs-using programer celebrities have injured their hands with emacs. (e.g. Richard Stallman, Jamie Zawinski), and emacs's Cntl-x keyboard and Meta-x combinations are most cited as the major turn-off to potential users among programers) Computer keyboard is a hardware interface, and the mapping of commands to the key press combinations can be considered from a Operation Research point of view. The keyboard hardware itself can be designed with consideration of ergonomics (that's why we have split and curved keyboards), but consideration of what functions to map to what key presses is also non-trivial if the software has large number of functions or if the software is mission critical. Think of it this way, consider a airplane cockpit, filled with knobs, dials, buttons, and switches. Now, if your job is to map the airplane control functions to these switches, what are the things to consider for a optimal map? If we take careful consideration on creating a keyboard shortcut system for emacs, it is actually easy to create a system that are purely superior in some technical sense than the ad-hoc Emacs's ways. Aside from keyboard shortcuts system, Emacs's other user interfaces are also questionable. For example, one major aspect of emacs operation is that it uses a single window for multiple purposes and files. Emacs is this way not because of a design decision, but rather due to historical reasons. Computer resources in the 1980s are very limited. When emacs is around, graphical system of showing “windows” is not practically available, and the emacs's method of using the screen (the textual-based-monitor) for presenting multiple tasks (“buffers”) is actually a very advanced user interface design not available in software of that era. When graphical systems becomes practical in the 1990s, drawing a window takes a lot memory, and opening multiple windows is slow and inpractical. Modern software interface (say, post 2000) usually uses one window per file (or task), and or show a tab if multiple task is to be represented in a single window. However, in general, emacs doesn't provide the tabs visual clue and still remained its old way of using a single window for all files and tasks as its standard operation. As far as user interface design is considered per se with respect to today's computing standards, the emacs's way is inferior because it is less intuitive. Arguably, emacs's operation methods may be more efficient for expert users. 20 years ago, efficiency for expert users may out weight the ease of use for majority of average users. But in today computing era, computers are standard tools in every household, efficiency and ease of use for general users is as important for professional users. Even for professional users, it is openly questionable that emacs's ways of operation induced by its default user interface allows faster or more efficient operation than a user interface based on modern software conventions. Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs: exists already
Here are some Frequently Asked Questions about The Modernization of Emacs. They are slightly lengthy, so i've separated each item per post. The whole article can be found at http://xahlee.org/emacs/modernization.html Q: Aquamacs already does what you want. A: Aquamacs is a emacs variant based on emacs, for Apple's Macintosh computers, created in about 2004 by David Reitter. Aquamacs modifies emacs so that its user interface follows modern (Mac OS X) conventions. For example, copy, paste, undo shortcuts are cmd-c, cmd- v, cmd-z. Open file is cmd-o, saving is cmd-s. Close window is cmd-w. There is a redo command by default, with shortcut cmd-shift-z. By following a modern user interface, almost all points mentioned in this article are fixed in Aquamacs. For more info, see: Wikipedia Aquamacs↗ and Aquamac's home page at: Aquamacs.org ↗ As a emacs variant, it does help in spreading the idea that emacs user interface should be modernized. However, a third-party variant software is irrelevant to the modernization issue. For example, suppose Microsoft Word remained with its DOS era command line interface, for example, file is opened with [Esc] (to open the menus), [T] (for Transfer), [L] (for Load). Suppose Microsoft hired a third party to release a variant called MS AquaWord. This would not help Microsoft Word the software itself, and is likely to complicate the issue around Microsoft Word. Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list
metaclasses and performance
Hi all I'm playing around with metaclasses and noticed, that there is small but mesurable a performance difference in the code shown below. With a more complex example I get a 5 percent performance penalty for using a metaclass. Until today I assumed, that a metaclass has no performance impact at all after class creation. Can someone explain me the performance difference between the two classes test1 and test2 Thank's in advance Mirko cut here - class meta(type): pass class test1(object): __metaclass__ = meta# using type via meta here def __init__(self): self.foo = 42 def get_foo(self): return self.foo class test2(object): __metaclass__ = type# using type directly def __init__(self): self.foo = 42 def get_foo(self): return self.foo # and here the performance test code ... it's only 2% on my machine import time for c in [test1, test2] * 10: t = c() start = time.time() for i in xrange(10 * 1000 * 1000): t.get_foo() print c.__name__, time.time() - start cut here - -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs: terminology buffer and keybinding
Xah Lee [EMAIL PROTECTED] writes: Here are some Frequently Asked Questions about The Modernization of Emacs. They are slightly lengthy, so i've separated each item per post. The whole article can be found at http://xahlee.org/emacs/modernization.html Q: The Terminology “buffer” and “keybinding” is good as they are. A: The terminology “buffer” or “keybinding”, are technical terms having to do with software programing. The term “keybinding” refers to the association of a keystroke with a command in a technical, software application programing context. That is to say, a programer “bind” a keystroke to a command in a software application. The term “buffer” refers to a abstract, temporary area for storing data, in the context of programing or computer science. These terms are irrelevant to the users of a software application. Bologna. Every computer user should see himself as a programmer. Changes in society are always resisted by old timers, but it is also a main element behind progress. This terminology issue may seem trivial, but its importance lies in making emacs palpable to the vast number of people who ever need to use a computer to write. I'm a young-timer. Joel -- Joel J. Adamson Biostatistician Pediatric Psychopharmacology Research Unit Massachusetts General Hospital Boston, MA 02114 (617) 643-1432 (303) 880-3109 A webpage of interest: http://www.gnu.org/philosophy/sylvester-response.html -- http://mail.python.org/mailman/listinfo/python-list
Re: jedit - auto code completetion
Libertarian wrote: Does it have a plug-in for python code completetion ? Yes. /W -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows XMLRPC Service
En Tue, 19 Jun 2007 03:45:19 -0300, [EMAIL PROTECTED] escribió: I can't quite figure out where to set the socket timeout. I tried setting win32event.WAIT_TIMEOUT, but I'm pretty sure that's not the variable you were talking about. I did manage to make it multi- threaded by incorporating a different recipe, and I'm beginning to understand the control flow a bit better, but it doesn't seem to be doing what I expect. When SvcStop() is executed and calls win32event.SetEvent(self.hWaitStop), the while loop should break as win32event.WaitForSingleObject(self.hWaitStop, 0) returns zero at this point. But it doesn't do that. What am I missing? May be because you didn't set correctly the socket timeout. See the comments below. def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) win32event.SetEvent(self.hWaitStop) #print EVENT:, win32event.WaitForSingleObject(self.hWaitStop, 0) # returns 0 here That's OK, since you have set the event. def SvcDoRun(self): self.server.register_instance(MyClass()) #win32event.WAIT_TIMEOUT = 2 --- This just makes the loop never execute because # the WaitFor... part always returns 258 WAIT_TIMEOUT is 258. How do you see it is 2? For example, see http://msdn2.microsoft.com/en-us/library/ms681382.aspx. Python 2.5.1 + pywin32 210 prints this on my PC: py import win32event py win32event.WAIT_TIMEOUT 258 while win32event.WaitForSingleObject(self.hWaitStop, 0) == win32event.WAIT_TIMEOUT: self.server.handle_request() The loop above should keep running until hWaitStop is set, with a maximum wait time (inside handle_request) corresponding to the socket timeout value. You can either: - use socket.setdefaulttimeout() (in __init__, by example) before anything else. This will set a global timeout for all sockets. - modify the socket instance. Just add this method to your AsyncServer: def server_activate(self): SimpleXMLRPCServer.server_activate(self) self.socket.settimeout(15) # for 15 secs -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Python/C API bug (multithreading)
Hi, I think I've found a bug in Python/C API and multithreading. I'm currently creating an intrusion detection system based on mobile agents. I have an AgentPlatform (C/C++) and 2 agents on it (2 Python scripts: Snort and Anomaly) These 2 agents are each running its own Python interpreter (both by Py_Run*** stuff). Of course I do have Threading on (I mean there is: PyGILStateEnsure stuff as well). I also have an interface that is used by both agents (Python scripts) to access my Agent Platform (C/C++ program). That interface have one method: AgentPlatform.getPacket() - when I call it in Python - appropriate method AgentPlatform.getPacket() is called in C/C++ AgentPlatform. Between these two moments somthing bad happens. This happens when Snort calls Python's AgentPlatform.getPacket() and just before C/C++'s AgentPlatform.getPacket() is called - another agent - Anomaly Agent calls its Python's AgentPlatform.getPacket(). In this particular moment everything hangs:( Let me show it on an image: http://www.mobiltek.pl/~mrbpl/tmp/PythonBug.JPG Is there any simple way to fix this damned bug?? best regards -- Krzysztof Włodarczyk Centrum Technologii Mobilnych Mobiltek S.A. e-mail: [EMAIL PROTECTED] mobile: 502-525-035 This email is confidential and is intended for receipt solely by the individual or entity to which it is addressed. Any review, use, retention, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender by reply email and delete all copies of this message. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
serial readline thread IO Error (9, 'Bad file descriptor')
Hi, How can I close a thread that is waiting on a file/port down gracefully, and not have an IO error pop up? I am having trouble closing a thread that is listening to the serial port. I have a thread that calls uses a pySerial serial port and calls readline() without a timeout, which is blocking. When I am shutting down the application I close the serial port, which causes the IO error: (9, 'Bad file descriptor'). It makes sense that we would get this error, because it is trying to read off of a closed 'file'. Is there a better way to close this thread and port down? Thanks, Nik -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
Terry Reedy [EMAIL PROTECTED] writes: The main point of my original post was that the quoted slam at Python was based on a misquote of Tim Peters But it wasn't based on a misquote of Tim Peters; it was based on an *exact* quotation of Tim Peters. and a mischaracterization of Python I find Sussman's criticism not to be a mischaracterization at all: I and others have previous mentioned in this very forum our desire to have (in an ideal world) a good syntax extension facility for Python, and when we've done so, we've been thoroughly pounced upon by prominent members of the Python community as just not understanding the true Weltanschauung of Python. This despite the fact that I have been happily and productively programming in Python for more than a decade, and the fact that Guido himself has at times mentioned that he's been idly considering the idea of a syntax extension facility. The reason given for why macros wouldn't gel with Python's Weltanschauung has typically been the only one obvious way koan, or some variant of it. and that it was out-of-place in the quoted discussion of physics methods and that it added nothing to that discussion and should better have been omitted. *All of this has nothing to do with Scheme.* I'm not sure what you're getting at. Gerry Sussman has a philosophy of language design that is different from Python's (at least as it is commonly expressed around here), and he was using an analogy to help illuminate what his differences are. His analogy is completely clear to me, and, I in fact agree with it. I love Python, but I think the only one obvious way philosophy may do more harm than good. It is certainly used, in my experience, at times, to attempt to squelch intelligent debate. At the end, I added as a *side note* the irony that the purported author was the co-developer of Scheme, another 'minimalist algorithm language Sussman's statements are not ironic because Scheme is a language that is designed to be extended by the end-user (even syntactically), while keeping the core language minimal. This is a rather different design philosophy from that of Python. (Wikipedia's characterization) with more uniform syntax than Python and like Python, also with one preferred way to scan sequences (based on my memory of Scheme use in the original SICP, co-authored by the same purported quote author, and also confirmed by Wikipedia). There is no one preferred way to scan sequences in Scheme. In fact, if you were to take SICP at MIT, as I did when I was a freshman, you would find that many of the problem sets would require you to solve a problem in several different ways, so you would learn that there are typically a number of different reasonable ways to approach a problem. E.g., one of the first problem sets would have you implement something both iteratively and recursively. I recall another problem set where we had to find the way out of a maze first using a depth-first search and then using a breadth-first search. | [Steele quote deleted] | Do you now see how Scheme's syntax extension mechanism is relevant? No. This just partly explains why Scheme gets away with being minimalist. I explicitly referred to the core language as delivered and as used in SICP. I suggest that you haven't yet grokked the Weltanschauung of Scheme. Scheme aficionados would not typically insist that a proposed language feature is not good because it violates anything like an only one obvious way rule. Rather they would argue that if it can be implemented as fuctions and/or macros, then it *should* be implemented that way, rather than polluting the core language. The new facility should then be included in a library. |oug -- http://mail.python.org/mailman/listinfo/python-list
ARM cross compile - one last problem
Hello all, I've been trying to get Python to cross compile to linux running on an ARM. I've been fiddling with the cross compile patches here: http://sourceforge.net/tracker/index.php?func=detailaid=1597850group_id=5470atid=305470 and I've had some success. Python compiles and now all of the extensions do too, but when I try to import some of them (time, socket, etc.), they have trouble finding certain symbols. Py_Exc_IOError and _Py_NoneStruct are the two I remember seeing. It would appear that they are exported by libpython, which I believe is statically linked into the python executable? That's where I start to get confused. What part of python is breaking? Where should I be looking for problems? Thanks a lot! Justin -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows XMLRPC Service
On Jun 19, 10:21 am, Gabriel Genellina [EMAIL PROTECTED] wrote: En Tue, 19 Jun 2007 03:45:19 -0300, [EMAIL PROTECTED] escribió: I can't quite figure out where to set the socket timeout. I tried setting win32event.WAIT_TIMEOUT, but I'm pretty sure that's not the variable you were talking about. I did manage to make it multi- threaded by incorporating a different recipe, and I'm beginning to understand the control flow a bit better, but it doesn't seem to be doing what I expect. When SvcStop() is executed and calls win32event.SetEvent(self.hWaitStop), the while loop should break as win32event.WaitForSingleObject(self.hWaitStop, 0) returns zero at this point. But it doesn't do that. What am I missing? May be because you didn't set correctly the socket timeout. See the comments below. def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) win32event.SetEvent(self.hWaitStop) #print EVENT:, win32event.WaitForSingleObject(self.hWaitStop, 0) # returns 0 here That's OK, since you have set the event. def SvcDoRun(self): self.server.register_instance(MyClass()) #win32event.WAIT_TIMEOUT = 2 --- This just makes the loop never execute because # the WaitFor... part always returns 258 WAIT_TIMEOUT is 258. How do you see it is 2? For example, see http://msdn2.microsoft.com/en-us/library/ms681382.aspx. Python 2.5.1 + pywin32 210 prints this on my PC: py import win32event py win32event.WAIT_TIMEOUT 258 while win32event.WaitForSingleObject(self.hWaitStop, 0) == win32event.WAIT_TIMEOUT: self.server.handle_request() The loop above should keep running until hWaitStop is set, with a maximum wait time (inside handle_request) corresponding to the socket timeout value. You can either: - use socket.setdefaulttimeout() (in __init__, by example) before anything else. This will set a global timeout for all sockets. - modify the socket instance. Just add this method to your AsyncServer: def server_activate(self): SimpleXMLRPCServer.server_activate(self) self.socket.settimeout(15) # for 15 secs -- Gabriel Genellina def SvcDoRun(self): self.server.register_instance(MyClass()) #win32event.WAIT_TIMEOUT = 2 --- This just makes the loop never execute because # the WaitFor... part always returns 258 WAIT_TIMEOUT is 258. How do you see it is 2? For example, see http://msdn2.microsoft.com/en-us/library/ms681382.aspx. Python 2.5.1 + pywin32 210 prints this on my PC: py import win32event py win32event.WAIT_TIMEOUT 258 I meant here that *if* I set the WAIT_TIMEOUT to 2, then I see that behavior. - use socket.setdefaulttimeout() (in __init__, by example) before anything else. This will set a global timeout for all sockets. That was the one that did it. Thank you again Gabriel. I'll post back with something complete. ~Sean -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
On 2007-06-19, Douglas Alan [EMAIL PROTECTED] wrote: Terry Reedy [EMAIL PROTECTED] writes: At the end, I added as a *side note* the irony that the purported author was the co-developer of Scheme, another 'minimalist algorithm language Sussman's statements are not ironic because Scheme is a language that is designed to be extended by the end-user (even syntactically), while keeping the core language minimal. This is a rather different design philosophy from that of Python. Which version Scheme, though? Scheme has only formally had macros since R4RS, and then only as an extension. Macros are an extension to Scheme, rather than a founder. Python could conceivably end up in the same position 15 years from now, with macros a well-established late-comer, as generators have become. I suggest that you haven't yet grokked the Weltanschauung of Scheme. Scheme aficionados would not typically insist that a proposed language feature is not good because it violates anything like an only one obvious way rule. Rather they would argue that if it can be implemented as fuctions and/or macros, then it *should* be implemented that way, rather than polluting the core language. The new facility should then be included in a library. The SRFIs are cool. The last time I dipped my toe into the Scheme newsgroup, I was overwhelmed by the many impractical discussions of Scheme's dark corners. Python is either much more free of dark corners, or else simply doesn't attract that kind of aficionado. -- Neil Cerutti Let us join David and Lisa in the celebration of their wedding and bring their happiness to a conclusion. --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs
Gian Uberto Lauri wrote: GB == Galen Boyer [EMAIL PROTECTED] writes: GB Most other environments will be for those just trying to perform GB their tasks and staying even with the average proficiency chart. Oh, please. The I'm so l33t thing. I used EMACS back in the LISP era, but really, that approach is mostly of historical interest at this late date. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
caseless dictionary howto ?
hello, I need to search a piece of text and make all words that are equal (except their case) also equal in their case, based on the first occurrence. So I'm using a dictionary to store names and attributes of objects. As as I need to search on the caseless name (so I've choosen lowercase), My dictionairy looks like this: self.procs [ serial_hw_read ] = ( Serial_HW_Read, F, ++, T) Is this really a good solution, or are there better ways ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list