ANNOUNCE: wxPython 2.6.3.2
Announcing -- The 2.6.3.2 release of wxPython is now available for download at http://wxpython.org/download.php. This is a mostly bug fix release and takes care of several unfortunate features discovered in the 2.6.3.0 release made last week. A summary of changes is listed below and at http://wxpython.org/recentchanges.php. What is wxPython? - wxPython is a GUI toolkit for the Python programming language. It allows Python programmers to create programs with a robust, highly functional graphical user interface, simply and easily. It is implemented as a Python extension module that wraps the GUI components of the popular wxWidgets cross platform library, which is written in C++. wxPython is a cross-platform toolkit. This means that the same program will usually run on multiple platforms without modifications. Currently supported platforms are 32-bit Microsoft Windows, most Linux or other Unix-like systems using GTK2, and Mac OS X 10.2+, in most cases the native widgets are used on each platform. Changes in 2.6.3.2 -- Fixed reference leak in wx.gizmos.TreeListCtrl.GetSelections. wxMSW: Fixed sizing issue with wx.Choice and wx.ComboBox. This change was implemented by reverting a prior fix for a different problem (continuous painting/resizing when a combobox is used as a widget in a wx.html.HtmlWindow) so a method to fix both problems is still being investigated. wxGTK: Fixed potential buffer overrun when pasting from the clipboard. Fixed problem in wx.lib.splitter when used on 64-bit platforms. Used the current length of the list for specifying an append instead of sys.maxint. wxMSW: Support added for XP themed owner drawn buttons and bitmap buttons. For example, if you change the foreground color of a button it will now be drawn with the XP themed style rather than an ugly generic button style. XRCed: Fix for Copy/Paste objects with international characters. Fixed the equality and inequality operators for some of the basic data types (wx.Point, wx.Size, wx.Colour, etc.) to no longer raise a TypeError if the compared object is not compatible, but to just return a boolean as expected. For example:: wx.Colour(64,0,64) == 123 == False wxMSW: Fixed (again) sizing/positioning issues of calling Realize on a wx.ToolBar that is not manaaged directly by a frame and that is already shown. wxMSW: Fixed wx.Choice/wx.ComboBox so they send events when a new item is selected only with the keyboard. -- Robin Dunn Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython! -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ANN: CherryPy-2.2.0 released
(sorry for the double-post, the title of the previous one was wrong) Hello everyone, After six months of hard work and 300 changesets since the last stable release I'm happy to announce that CherryPy-2.2.0-final is out. The biggest changes are: - switch to a lowercase api (although the old camelCase API is still supported for backward compatibility) - support for multiple applications (new cherrypy.tree object) - better error handling - lots of bug fixes (especially in file-based sessions) - better test suite. Check out http://www.cherrypy.org/wiki/UpgradeTo2.2 for more details. *** About CherryPy: CherryPy is a simple (no dependencies), pythonic (doesn't get in your way) web development framework. Here is a sample Hello, World in CherryPy: # import cherrypy # class HelloWorld: # @cherrypy.expose # def index(self): # yield htmlbody # yield Hello world! # yield /body/html # cherrypy.root = HelloWorld() # cherrypy.server.start() The project has been growing strongly lately: cherrypy.org averaged 3000 visitors/day in March, up from 2000 visitors/day in January and February; and the cherrypy-users list just passed 700 users. Details and downloads are available from: http://www.cherrypy.org Remi. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
RELEASED Python 2.5 (alpha 1)
On behalf of the Python development team and the Python community, I'm happy to announce the first alpha release of Python 2.5. This is an *alpha* release of Python 2.5, and is the *first* alpha release. As such, it is not suitable for a production environment. It is being released to solicit feedback and hopefully discover bugs, as well as allowing you to determine how changes in 2.5 might impact you. If you find things broken or incorrect, please log a bug on Sourceforge. In particular, note that changes to improve Python's support of 64 bit systems might require authors of C extensions to change their code. More information (as well as source distributions and Windows installers) are available from the 2.5 website: http://www.python.org/2.5/ The plan from here is for a number of additional alpha releases, followed by one or more beta releases and moving to a 2.5 final release around August. PEP 356 includes the schedule and will be updated as the schedule evolves. The new features in Python 2.5 are described in Andrew Kuchling's What's New In Python 2.5. It's available from the 2.5 web page. Amongst the language features added include conditional expressions, the with statement, the merge of try/except and try/finally into try/except/finally, enhancements to generators to produce a coroutine kind of functionality, and a brand new AST-based compiler implementation. New major modules added include hashlib, ElementTree, sqlite3 and ctypes. In addition, a new profiling module cProfile was added. A large number of bugs, regressions and reference leaks have been fixed since Python 2.4. See the release notes for more. Enjoy this new (alpha!) release, Anthony Anthony Baxter [EMAIL PROTECTED] Python Release Manager (on behalf of the entire python-dev team) pgpj12FUUt0aK.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ANN: uuid-0.2 released
Happy to announce the release of uuid-0.2 What is uuid? uuid is a python module to create RFC 4122 compatible UUIDs The module supports generation off RFC 4122 compatible time based, random, sha1 and md5 based UUIDs Whats new? x. new function get_mac_address() x. get_variant() now returns VARIANT_UNKNOWN if the variant of a UUID is not recognized x. output decoration around UUIDs is no longer included if the module is used from commandline x. bugfixes For download and documentation see http://home.arcor.de/jurner/python/ -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
specialized GUI
I am new to python. I got a new project where I have to create a GUI and attch my code to it. The GUI should look like vsTASKER www.virtualsim.com I mean GUI lets user create diagram, and my code should read that diagram and run the algorithm. Do you know any other tool like this where I can integrate my code with. Every help is appreciated -- http://mail.python.org/mailman/listinfo/python-list
Re: Standalone Python functions in UML?
In [EMAIL PROTECTED], Roman Susi wrote: Out of curiosity, how do I draw functions outside classes with UML? How module could be drawn in this case? I just create a (UML) class for modules. After all a Python module can be seen as a class definition for a singleton which is instantiated at import time. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
IMPORTANT 2.5 API changes for C Extension Modules
If you don't write or otherwise maintain Python Extension Modules written in C (or C++), you can stop reading. Python 2.5 alpha 1 is in the process of being released later today. There are important changes that are in 2.5 to support 64-bit systems. These changes can cause Python to crash if your module is not upgraded to support the changes. Python was changed internally to use 64-bit values on 64-bit machines for indices. If you've got a machine with more than 16 GB of RAM, it would be great if you can test Python with large ( 2GB) strings and other sequences. For more details about the Python 2.5 schedule: http://www.python.org/dev/peps/pep-0356/ For more details about the 64-bit change: http://www.python.org/dev/peps/pep-0353/ How to fix your module: http://www.python.org/dev/peps/pep-0353/#conversion-guidelines The effbot wrote a program to check your code and find potential problems. http://svn.effbot.python-hosting.com/stuff/sandbox/python/ssizecheck.py Please test and upgrade your extension modules! Cheers, n -- http://mail.python.org/mailman/listinfo/python-list
Re: Difference in Python and Ruby interactive shells
Lou Pecora enlightened us with: Impressive, but YIKES, there ought to be a simpler way to do this. I think during the development phase editing and reloading would be very common and you'd want everything updated. I hardly ever reload stuff manually during development. I write a script, and execute it. The few times I use reload() it's no big deal to do x = B(). So why is it done the other way, the reference stays the same? Is that useful? It's predictable. Variables point to one and the same thing, unless you manipulate them directly. Maybe time for a 'switch' to set in Python to choose which behavior you want. That wouldn't be pythonic. People would start using that switch in their programs too, causing a single command to act differently in each program. Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself? Frank Zappa -- http://mail.python.org/mailman/listinfo/python-list
Re: CD Burning
Albert Leibbrandt wrote: Hi Can anybody tell me which windows API or python module they are using for writing cd's / dvd's with python? Other people have offered sound suggestions about using cdrecord etc. under Cygwin. Just to make the point, though, XP (and above, presumably) does have an inbuilt interface for burning CDs. I've never used it, and I don't know how feasible it would be to access it from Python. (Helpful, eh?) The interface is ICDBurn and it should be possible to wrap it with ctypes / ctypes.com but I haven't the time at the moment to try it out. (And I haven't a CD writer in this machine either!) Ultimately, it might still be easier to install Cygwin and use the cdrecord approach. I just wanted to make the point that there *was* an in-built mechanism. ICDBurn: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/ifaces/icdburn/icdburn.asp ctypes.com: http://starship.python.net/crew/theller/ctypes/com.html TJG -- http://mail.python.org/mailman/listinfo/python-list
save file as utf-8 format
hi, what should i do to save file as utf-8 encoding. thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: The World's Most Maintainable Programming Language
John Salerno wrote: There is an article on oreilly.net's OnLamp site called The World's Most Maintainable Programming Language (http://www.oreillynet.com/onlamp/blog/2006/03/the_worlds_most_maintainable_p.html). There is one really interessting (imho) point in the last part that struck me down: blockquote Aside from a formal specification, which I hope to produce in the near future, the language needs a name. Here is where many modern languages have done well. Perl, named after Pearl Biggar (Larry Wall’s fiancée), Ruby (named after Ruby Kusanagi Matsumoto, Yukihiro Matsumoto’s youngest daughter), Ada (named after Charles Babbage’s first programming student, Ada Lovelace), and COBOL (named after Colleen Bolero, the heroine of a Ravel operetta) have set a high standard for naming techniques. /blockquote OMG! Did you people know that already ;-) Regards M. -- http://mail.python.org/mailman/listinfo/python-list
Re: save file as utf-8 format
On Wednesday 05 April 2006 10:53, [EMAIL PROTECTED] wrote: hi, what should i do to save file as utf-8 encoding. thanks. from http://evanjones.ca/python-utf8.html The Byte-Order Marker (BOM) section did the trick. -- http://mail.python.org/mailman/listinfo/python-list
Re: Convertion of Unicode to ASCII NIGHTMARE
Fredrik Lundh [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Roger Binns wrote: SQLite only accepts Unicode so a Unicode string has to be supplied. fact or FUD? let's see: Note I said SQLite. For APIs that take/give strings, you can either supply/get a UTF-8 encoded sequence of bytes, or two bytes per character host byte order sequence. Any wrapper of SQLite that doesn't do Unicode in/out is seriously breaking things. I ended up using the UTF-8 versions of the API as Python can't quite make its mind up how to represent Unicode strings at the C api level. You can have two bytes per char or four, and the handling/production of byte order markers isn't that clear either. import pysqlite2.dbapi2 as DB pysqlite had several unicode problems in the past. It has since been cleaned up as you saw. Roger -- http://mail.python.org/mailman/listinfo/python-list
Re: using range() in for loops
John Salerno wrote: The reason for this distinction comes from the fact that I read a lot how using range and for is somewhat discouraged, because it doesn't really use a for loop for it's true purpose. So my question is, is this just a Python-oriented opinion about for loops, or is it a general idea? The use of range in for loops is not discouraged, just the unnecessary use of it. In many languages, you were forced to use range - or size, or length, or count, etc - because the only practical method of iteration was to use successive indices into the array or other collection, stopping when the indexes run out. Most loops operate on some sort of structure in this way. In Python, you can iterate directly over the structure instead, so you no longer have to worry about keeping track of the current index, comparing it to the maximum index, or collecting the right object from the structure according to its index. Python just gives you the next object until there are none left. As a result, for most looping tasks, you have no need to use range or an equivalent. Also, what if you *do* need to just do something a set number of times. Is this okay, or does it mean you are approaching the problem incorrectly? Do you really need to do something a number of times? If so, range (or xrange) is perfect for the job. More often though, you need to do something once for every whatever, so put your 'whatevers' in a list and iterate over that. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Doc suggestions
On 4 Apr 2006 15:18:27 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote in message Here is a 3' view. I posted about a clear (admittedly very minor) doc problem 8 days ago. Since then there have been 30+ postings in this thread. Insults and bad feelings have flown. Two people setup wikis and uploaded the tutorial. I don't know how many people have visited or made changes. After all that I look at the current 2.5 docs, and what do I see? The same, trivial, problem is still there. I agree with you generally on the something needs to be done. I'm all for a system that allows people to make trivial changes themselves, and has a team (or Czar) overseeing it to keep things in order. I disagree with some of the details of your suggestion as I tend to be more in favour of a Wild West Wiki approach that gives everyone equal power, except the editors who have final say. However I'm broadly in agreement. Ironically, I think that if you and Fredric played nicely, you'd find that he also broadly agrees with the need for change (hence the creation of the wiki). I think (but am not at all sure) that getting the people in change of Python to change the way things are done is quite difficult. I think, just like with the standard library, that there tends to be a system of seeing what gets created in the wild, and then once something is fairly well proven, make it official. I'm not at all sure that this is a bad way of going about things. DIY certainly seems to be a large, but unspoken, part of the community. If you want your changes to take place, you'll need to set it up yourself, make it work, and if it did, it would very likely replace the current system. If it doesn't work, that would seem to suggest that it wasn't sufficiently better. I know it can be very frustrating making suggestions and comments on the list and people at best ignoring them, but that seems to be how things work around here. I think it's a zen thing. [snipped...a proposal that would hopefully improve the documentation and process.] No comments on this either. I wonder why? ...It is a lousy or unworkable idea. ...Fredrik doesn't like it. ...It did not come from an insider. ...The docs for introducing people to Python and getting them to an intermediate level are already ok. Any further improvement would erode the status of the existing experts and is thus undersireable. ...Same as above but would reduce the ability of experts to make money writing commercial books. Probably none of the above. It's just not exciting enough for people to go away and do it for you. If you really believe in the idea, do it, prove it and then people will accept it (and you'll probably be in charge of the docs). Ed -- http://mail.python.org/mailman/listinfo/python-list
Re: The World's Most Maintainable Programming Language
John Salerno wrote: There is an article on oreilly.net's OnLamp site called The World's Most Maintainable Programming Language (http://www.oreillynet.com/onlamp/blog/2006/03/the_worlds_most_maintainable_p.html). It's not about a specific language, but about the qualities that would make up the title language (learnability, consistency, simplicity, power, enforcing good programming practices). I thought this might be of interest to some of you, and I thought I'd point out the two places where Python was mentioned: It's interesting to see a slightly different take on type checking.. In the real world it is an error to put five pounds of potatoes in a ten pound sack The same might be true of computer games, where a type checker so careful that it might refuse to allow an operation where a 180-pound character can carry 10,000 gold pieces might actually remove the aspect of fun from the game. Isn't this data validation and if it is, should the compiler be checking this? Tim Parkin -- http://mail.python.org/mailman/listinfo/python-list
Problem connecting Python with PostgreSQL
Hello.I have a problem connecting to a PostgreSQL database and I don't know where the problem lays. A bit of background: I installed the psycopg module yesterday (it was a bit of a pain to do it since I installed the wrong version and it didn't work). I got to install it in the end anyway. I have a database hosted in a server (let's call it xxx.yy.com). I need to access that database from another computer. I have configured the PostgreSQL server right (except something I'll explain later), and added the right line tothe pg_hba.conf file. After trying to connect to the server using the connect() function in the psycopg module, I get the following error message after a few seconds: psycopg.OperationalError: could not connect to server: Connection timed out Is the server running on host xxx.yy.com and accepting TCP/IP connections on port 5432? Following the error's suggestion, I went to check the Postgresql.conf file, and realized the tcpip_socket = true line was commented. I uncommented the line, and after restarting the server, it crashed, so I commented the line again. I thought that was the source of the problem, but when I checked my netstat, realized that the postgresql server was listening on port 5432... Don't ask me why, since the line tcpip_socket = true was commented. But why does the server crash when I try to set tcpip_socket to true? Anyway, I'm now out of possible solutions. Maybe the source of the error lays in a different place. I really need help on this. Has anyone ever gotten the same error message before, or is familiar with it? If you need more information about the error, I'll be glad to share it with you. Thank you very much for your attention. Jose Carlos. -- http://mail.python.org/mailman/listinfo/python-list
Re: using range() in for loops
It's not just a Python thing, Java for example generally uses the idiom: for (Iterator it = list.iterator(); it.hasNext(); ) { Object next = it.next(); //Do stuff to next } Horrible compared to the python idiom of course (though the latest version supports for (x : list){}) Ruby has something similar in: list.each do |item| print item end Again, not as nice as the python idiom IMHO (Though there may be better ways - I don't know Ruby very well). So really, all modern programming languages seem to prefer the loop-over-iterator idiom in preference to looping over a numerical range. -- http://mail.python.org/mailman/listinfo/python-list
Re: Standalone Python functions in UML?
Ravi Teja wrote: (snip) And probably Python is too dynamic for UML. That is another reason rountrip tools aren't there. As you probably already know, UML diagrams are structural and behavioural (plus interactional with 2.0). Round trip tools only model structural diagrams. Python is dynamic but only once the program starts executing :-). Even though Python classes can change, they do so only at runtime Well, you can have a lot of things happening during the import stage. Is this 'runtime' or not ?-) And you can actually *create* (not 'change') classes at runtime too. So dynamism of Python should not be as much of an issue. Not so sure about this. -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Standalone Python functions in UML?
Philippe Martin wrote: meta please don't top-post - corrected/meta bruno at modulix wrote: Philippe Martin wrote: Roman Susi wrote: (snip) More theoretical question is if I create classes on the fly, how UML can reflect that? You mean objects I think: Yes : class objects !-) Python's classes *are* objects. And you can create new classes at runtime. (snip) But not in UML: a class diagram will represent classes while a sequence diagram objects. Yes, there's in UML a fundamental distinction between classes and objects - distinction that does not exist in a lot of OO languages. This greatly limits UML's usability for some common idioms in dynamic OOPL's. Seems like UML has been designed to express only the restricted subset of OO supported by rigid static languages like C++, Java and ADA. My 2 cents -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Dice probability problem
Op 2006-04-04, Tomi Lindberg schreef [EMAIL PROTECTED]: First, thanks to Antoon and Alexander for replying. Antoon Pardon wrote: It would be better to construct distributions for one die and make a function that can 'add' two distributions together. As both replies pointed to this direction, I tried to take that route. Here's the unpolished code I came up with. Does it look even remotely sane way to accomplish my goal? -- code begins -- # A die with n faces D = lambda n: [x+1 for x in range(n)] # A new die with 6 faces d6 = D(6) # Adds another die to results. def add_dice(sums, die): # If first die, all values appear once if not sums: for face in die: sums[face] = 1 # Calculating the number of appearances for additional # dice else: new_sums = {} for k in sums.keys(): for f in die: if new_sums.has_key(k+f): new_sums[k+f] += sums[k] else: new_sums[k+f] = sums[k] sums = new_sums return sums sums = add_dice({}, d6) sums = add_dice(sums, d6) sums = add_dice(sums, d6) -- code ends -- IMO you are making things too complicated and not general enough. Here is my proposal. - import operator class Distribution(dict): '''A distribution is a dictionary where the keys are dice totals and the values are the number of possible ways this total can come up ''' def __add__(self, term): '''Take two distributions and combine them into one.''' result = Distribution() for k1, v1 in self.iteritems(): for k2, v2 in term.iteritems(): k3 = k1 + k2 v3 = v1 * v2 try: result[k3] += v3 except KeyError: result[k3] = v3 return result def __rmul__(self, num): tp = num * [self] return reduce(operator.add, tp) def D(n): ''' One die has a distribution where each result has one possible way of coming up ''' return Distribution((i,1) for i in xrange(1,n+1)) sum3d6 = 3 * D(6) sum2d6p2d4 = 2 * D(6) + 2 * D(4) - -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
socket.socket.settimeout implementation
When using socket.socket.settimeout we normally only guard against socket.timeout exception.Now the implementation of settimeout in Python-2.4.3/Modules/socketmodule.c sets the socket fd to nonblocking and uses select() to timeout as seen below in line 1487 and 1386 : static PyObject * 1470 sock_settimeout(PySocketSockObject *s, PyObject *arg) 1471 { 1472 double timeout; .. 1485 1486 s-sock_timeout = timeout; 1487 internal_setblocking(s, timeout 0.0); 1488 1489 Py_INCREF(Py_None); 1490 return Py_None; 1491 } 1492 1362 sock_accept(PySocketSockObject *s) 1363 { ... 1385 Py_BEGIN_ALLOW_THREADS 1386 timeout = internal_select(s, 0); 1387 if (!timeout) 1388 newfd = accept(s-sock_fd, (struct sockaddr *)addrbuf, 1389 addrlen); 1390 Py_END_ALLOW_THREADS 1391 Now internal_select() returns 1 on timemout else 0 as seen below : 673n = select(s-sock_fd+1, fds, NULL, NULL,tv); 674 if (n == 0) 675return 1; 676 return 0; back to the sock_accept() fuction on line 1387 1387 if (!timeout) 1388 newfd = accept(s-sock_fd, (struct sockaddr *) addrbuf, 1389addrlen) if select() returned before timeout we call accept() Now my observation on FC4 ( kernel version 2.6.11-1.1369_FC4) select() can return before timeout with a Interrupted system call (EINTR) error, my question is , is it possible that our internal_select() fuction as seen on line 676 above returns 0 and we go on to do a accept() call which returns with a Resource temporarily unavailable error if the sockfd is not readable. So user expects only socket.timeout but gets Resource temporarily unavailable which stops the program from proceeding. Our Case : We are using CherryPy , which sets a timeout on socket using settimeout and whenever our code uses os.seteuid cherrpy dies giving out the Resource temporarily unavailable. I did write a C program using pthreads , one thread doing non blocking accept() and select() and other thread doing a seteuid() . select() did bail out giving Interrupted system call Error. Thanks Jitendra Nair -- http://mail.python.org/mailman/listinfo/python-list
Re: The World's Most Maintainable Programming Language
Mirco Wahab [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] John Salerno wrote: There is an article on oreilly.net's OnLamp site called The World's Most Maintainable Programming Language (http://www.oreillynet.com/onlamp/blog/2006/03/the_worlds_most_maintainable_ p.html). There is one really interessting (imho) point in the last part that struck me down: blockquote Aside from a formal specification, which I hope to produce in the near future, the language needs a name. Here is where many modern languages have done well. Perl, named after Pearl Biggar (Larry Walls fiancée), Ruby (named after Ruby Kusanagi Matsumoto, Yukihiro Matsumotos youngest daughter), Ada (named after Charles Babbages first programming student, Ada Lovelace), and COBOL (named after Colleen Bolero, the heroine of a Ravel operetta) have set a high standard for naming techniques. /blockquote OMG! Did you people know that already ;-) Regards M. COBOL = COmmon Business-Oriented Language I think the author was just testing to see who was reading. Also, is there any significance to the publication date of the Conclusion (or the name selected for the ultimate language)? Seems like a lot of work for an Avril Fool's prank... -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: The World's Most Maintainable Programming Language
John Salerno wrote: There is an article on oreilly.net's OnLamp site called The World's Most Maintainable Programming Language (http://www.oreillynet.com/onlamp/blog/2006/03/the_worlds_most_maintainable_p.html). It's not about a specific language, but about the qualities that would make up the title language (learnability, consistency, simplicity, power, enforcing good programming practices). I thought this might be of interest to some of you, and I thought I'd point out the two places where Python was mentioned: from Part 4, Power: Of course (second point), a language that requires users to extend it to be productive has already failed, unless it can enforce that there is one obvious solution to any problem and autonomously subsume the first working solution into the core language or library. Python is a good example of this practice. There is a strong polycultural subcommunity in the world of free and open source, and the members of this group consider the lack of competing projects in Python (one XML parser, one logging library, one networking toolkit) to be counterintuitive and even counter to the goal of language progress. They’re wrong; this is actually a strong force for cohesion in the language and community, where the correct answer to a novice’s question of “How can I parse XML?”, “How can I publish a database-driven web site?”, or even “How can I integrate the legacy system of an acquired company from a different industry with our existing legacy system?” (to prove that this principle does not only apply to small or toy problems) is usually “Someone else has already implemented the correct solution to that problem — it is part of the standard library.” xml templates ? ORM ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Standalone Python functions in UML?
Well, you can have a lot of things happening during the import stage. Is this 'runtime' or not ?-) Runtime. And you can actually *create* (not 'change') classes at runtime too. Yes sir! By now I am quite well aware what 'dynamic typing' means. Once again, round trip tools today model program structure/code/text, not runtime magic - all the stuff a dynamically typed language such as Python does differently from statically typed languages like Java. So this does not affect them much. Languages like Python with metaclasses and other dynamic aspects do present an interesting case for modelling but what I am talking about is round trip tools, not the full scope of modelling and UML. Round trip implementations today get at class and package diagrams (structural), not object diagrams and collaboration diagrams. Class and Package diagrams are concerned with the layout, not intricate runtime behaviour, mutations and mutilations of classes and packages. That would be the domain of behavioural diagrams of which I made no assertions. There isn't much magical about Python as far as code layout is concerned. Metaclasses can for example change the very behaviour of the class construct but modelling that is not the purpose of a class or package diagram. Rather than going hypothetical and us miscommunicating in the abstract plane, could you just tell me why you could not draw a class or package diagram for your last project? That will probably make me see what I am missing from your points. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Decompilers?
Peter Hansen wrote: flamesrock wrote: Hi, Are there any good decompilers for python? Decompyle can manage any version from 1.5 up to 2.3.3. I was disappointed when I started to play with decompyle for python 2.3 to observe that it failed on non-trivial list comprehensions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Decompilers?
flamesrock wrote: Are there any good decompilers for python? I've had some success with decompyle, which seems to be principally available as a Debian package, for which the sources can be obtained here: http://packages.debian.org/stable/source/decompyle Paul -- http://mail.python.org/mailman/listinfo/python-list
FREE WEBSITE plus 10EMAIL ADDRESSES
FREE WEBSITE plus 10EMAIL ADDRESSES Please visit: http://website.ws/daisypool/show -- http://mail.python.org/mailman/listinfo/python-list
Dr. Dobb's Python-URL! - weekly Python news and links (Apr 4)
QOTW: Don't be too sure that it's compatible for the indefinite future. XML is just as future-proof as any other format. - Sybren Stuvel Submitting a proposed change or fix [of the Python docs] is easier and quicker than arguing about it on c.l.py and it seems to get pretty quickly to the actual document maintainers. - Kent Johnson Still struggling with recursion? comp.lang.python is newbie-friendly: http://groups.google.com/group/comp.lang.python/browse_frm/thread/2ca81c529b485f89/cf531016b54d0ca1?tvc=1 An interview with Michael Foord, author of MovablePython, is the latest entry in the Python411 series intended to help you learn Python and learn about Python: http://www.awaretek.com/python/index.html PyInstaller advances Gordon McMillan's earlier and widely-used work on Python installation: http://pyinstaller.hpcf.upr.edu/cgi-bin/trac.cgi If PL/SQL is your only programming language, your Oracle work may suffer. In her introductory article Catherine Devlin demonstrates the power of Python from the perspective of a database user: http://www.oracle.com/technology/pub/articles/devlin-python-oracle.html http://catherinedevlin.blogspot.com/2006/03/otn-article-addendum.html Getting hold of subclasses is easy with new-style classes: http://groups.google.com/group/comp.lang.python/msg/8fbe567f4ff121f9 Once you learn about the secret of iter()'s second parameter, many use cases of a while-loop in C can be better expressed with a for-loop in Python: http://groups.google.com/group/comp.lang.python/browse_frm/thread/b3ab8141c492bb21/df51ed3d13dd4975?tvc=1 The Python 2.4.3 bugfix release is available: http://groups.google.com/group/comp.lang.python/browse_frm/thread/93a2ad5d99db34ec Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. For far, FAR more Python reading than any one mind should absorb, much of it quite interesting, several pages index much of the universe of Pybloggers. http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog http://www.planetpython.org/ http://mechanicalcat.net/pyblagg.html comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous tradition early borne by Andrew Kuchling, Michael Hudson and Brett Cannon of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://aspn.activestate.com/ASPN/Cookbook/Python Among several Python-oriented RSS/RDF feeds available are
Re: tuple syntax ',' (ending in comma?)
In article [EMAIL PROTECTED], Michael Yanowitz [EMAIL PROTECTED] wrote: I am confused by the syntax for tuples. ... The way I fixed this error was I added an extra , (comma) to the tuple: thread.start_new_thread(read_data_thread, (strDataFilename,)) I am just confused by the syntax. I am used to a comma meaning that there should be another parameter after the comma and if no additional parameter the comma would not be necessary. http://python.org/doc/2.4.2/ref/parenthesized.html -- http://mail.python.org/mailman/listinfo/python-list
HTMLParser fragility
I've been using HTMLParser to scrape Web sites. The trouble with this is, there's a lot of malformed HTML out there. Real browsers have to be written to cope gracefully with this, but HTMLParser does not. Not only does it raise an exception, but the parser object then gets into a confused state after that so you cannot continue using it. The way I'm currently working around this is to do a dummy pre-parsing run with a dummy (non-subclassed) HTMLParser object. Every time I hit HTMLParseError, I note the line number in a set of lines to skip, then create a new HTMLParser object and restart the scan from the beginning, skipping all the lines I've noted so far. Only when I get to the end without further errors do I do the proper parse with all my appropriate actions. -- http://mail.python.org/mailman/listinfo/python-list
A Lambda Logo Tour
A Lambda Logo Tour (and why LISP languages using λ as logo should not be looked upon kindly) Xah Lee, 2002-02 Dear lispers, The lambda character λ, always struck a awe in me, as with other mathematical symbols. In my mind, i imagine that those obscure math symbolism are etched in stone by god. A salient example is the book cover Concrete Mathematics by Ronald Graham et al. (See it here: http://xahlee.org/UnixResource_dir/bcb/concrete-math.jpg.) Here we see the summation sign ∑ etched in stone. The summation sign happens to be my favorite math symbol. (chosen as my website signet: http://xahlee.org/Icons_dir/icon_sum.gif XahLee.org signet) These symbols are not to be trifled with. If anyone puffs in as much half a snicker, i wish god strikes a thunder upon their impudence. The Greek lambda symbol is used in a branch of logic called lambda calculus. The theories of lambda calculus is what functional languages are based on, thus many functional languages's logo feature the lambda. Here is a sampling: MIT Scheme logo MIT Scheme's logo features a recursive shield with lambda http://www.swiss.ai.mit.edu/projects/scheme/ Schemer.org's logo Schemer.org's logo has a modernized look. It is a simple lambda inside a O figuration. http://www.schemers.org/ (the O figure is supposed to be a pair of parenthesis) PLT Scheme logo PLT Scheme logo, notable is the red/white/blue coloring scheme. http://www.plt-scheme.org/ MzScheme MzScheme logo features a lambda besides a Chinese character 文 (wen2). The character means written language. http://www.cs.rice.edu/CS/PLT/packages/mzscheme/ Common Lisp HTTP server logo the Common Lisp HTTP server logo. http://www.ai.mit.edu/projects/iiip/doc/cl-http/home-page.html Scheme Shell logo Scheme shell scsh logo is a lamba inside a bivalve, perhaps most artistic of the bunch: http://www.scsh.net/ Haskell logo Haskell language logo is a plain lambda: http://haskell.org/ Hugs98 logo The Haskell interpreter Hugs98 features a 3D lambda with projected shadow http://www.haskell.org/hugs/ Yale Haskell logo Yale Haskell bullfrog Yale Haskell project used a logo that features symbols in lambda calculus including the lambda, and also a bullfrog head. Quite funny and beautiful. (the bullfrog logo origin is explained at the bottom. i.e. that of parody to Yale's bulldog logo) http://web.archive.org/web/2301023909/http://www.cs.yale.edu/haskell/yale-fp.html The book cover Structure Interpretation of Computer Programs by Abelson Sussman, features a wizard and witch talking with prominent lambda, and a monster foot of the table showing: see: http://xahlee.org/UnixResource_dir/sicp-cover.jpg I love these lambda-featuring logos. However, i have a complaint. As most of you know, lisp languages are not purely functional languages. Subroutines in lisps easily have side-effects, and sometimes non-functional programing methodologies such as OOP are actually encouraged in lisp. As most of you know, the lambda symbol chosen by functional languages is to signify no side-effects. In this respect, i find the lisp languages not totally deserving the use of lambda in their logo. As i have expressed before, mathematical symbols are not to be trifled with, and the Schemers have tainted my mathematics, strickly speaking. Although i have these minor objections with lispers using the lambda symbol, but overall i think the lispers and i share a more important common goal. That is, to kill all imperative programing ignoramuses of the world. Once the unix and c and perl and otherwise idiots are all dead, then i'll formally raise my objection about Lisper's unfit borrowing of the math symbol and term lambda. (PS In America, imperative language programers are such not because they prefer such methodology, but because they know shit.) -- Addendum, 2003-05, 2006-04. Haskell logo above: Haskell language's new logo, inargurated in 2003-05. Superb! Haskell logo Haskell logo above: Two Web logos for Haskell. Someone has written a C++ library for functional programing, called FC++. (by Brian McNamara and Yannis Smaragdakis, 2003) Their website is http://www.cc.gatech.edu/~yannis/fc++/index.html. They have unsettled logos. Here's one of them: FC++ logo There's a Scheme-to-C compiler called Chicken (by Felix L Winkelmann, at http://www.call-with-current-continuation.org/chicken.html). Scheme Chicken logo This is getting silly and disrespectful. This post is archived at: http://xahlee.org/UnixResource_dir/lambda_logo.html PS if you know any new lambda logo, please let me know. Thanks. Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: HTMLParser fragility
Lawrence D'Oliveiro: I've been using HTMLParser to scrape Web sites. The trouble with this is, there's a lot of malformed HTML out there. Real browsers have to be written to cope gracefully with this, but HTMLParser does not. There are two solutions to this: 1. Tidy the source before parsing it. http://www.egenix.com/files/python/mxTidy.html 2. Use something more foregiving, like BeautifulSoup. http://www.crummy.com/software/BeautifulSoup/ -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list
Re: problems with looping, i suppose
In article [EMAIL PROTECTED], John Salerno [EMAIL PROTECTED] wrote: ... and now when I run it, the DOS prompt flashes real quick and disappears. Does your DOS OS not have the equivalent of xterm, or KDE Konsole, or such? Something that lets you execute more than just one command, so you can see the results of the previous command before the window disappears? -- http://mail.python.org/mailman/listinfo/python-list
Re: String pattern matching
Thanks to all for the various good approaches. Kent's plain RE approach seems the most straightforward - did not know that RE can handle this situation - good to know! -- http://mail.python.org/mailman/listinfo/python-list
Re: HTMLParser fragility
Lawrence D'Oliveiro wrote: I've been using HTMLParser to scrape Web sites. The trouble with this is, there's a lot of malformed HTML out there. Real browsers have to be written to cope gracefully with this, but HTMLParser does not. Not only does it raise an exception, but the parser object then gets into a confused state after that so you cannot continue using it. The way I'm currently working around this is to do a dummy pre-parsing run with a dummy (non-subclassed) HTMLParser object. Every time I hit HTMLParseError, I note the line number in a set of lines to skip, then create a new HTMLParser object and restart the scan from the beginning, skipping all the lines I've noted so far. Only when I get to the end without further errors do I do the proper parse with all my appropriate actions. You could try HTMLTidy (http://www.egenix.com/files/python/mxTidy.html) as a first step to get well formed HTML. Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: HIRING: PHP Developer
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: We are hiring a PHP developer! http://groups.google.com/[EMAIL PROTECTED] .co.nz -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: unix newbie questions
In article [EMAIL PROTECTED], Gerard Flanagan [EMAIL PROTECTED] wrote: * To create an empty __init__.py file I do 'vim __init__.py' then immediately exit vim, is there a shell or vim command which will create an empty file without opening the editor? man touch * If I want to do : mv mypackage-1.0.2.tar.gz subdir/mypackage-1.0.2.tar.gz then tab-completion gives me the first occurrence of the file, but I have to type the second occurrence - is there a way of not having to type it? This is not how bash works. bash lists all the possible completions. * cd ~ brings me to my home directory, is there a means by which I can set up a similar alias for, say, /usr/local/www, so I can do: eg. cd ^ to get to that directory? You could set up a variable, e.g. in bash export w=/usr/local/www then cd $w * I'm using the tcsh shell and have no problems with it, but bash seems more popular - any reason to change? (I don't intend writing many shell scripts) Last time I used tcsh, its autocorrection facility kept making wrong suggestions. I just don't think it's worth using any more. Stick to bash for all your shell needs, both interactive and scripting, and leave it at that. * Any other unix/vim tips for a 'nix newb?! Try emacs. -- http://mail.python.org/mailman/listinfo/python-list
Distribution of Python apps
Hi,I was wondering if there is anything similar to py2exe for OS X and Linux distributions so that I wouldn't have to pre-install Python and required modules for my application.Thanks.-- Sebastjanhttp://www.trepca.si/blog -- http://mail.python.org/mailman/listinfo/python-list
Re: Standalone Python functions in UML?
Ravi Teja wrote: What I mean is utility is the formal notation for a class in which global functions are aggregated. It's not a hack. Python is not alone here. Most OO languages aside Java and Smalltalk have functions outside classes and UML accomodates though not encourages free functions. It doesn't seem to sit well with the common Python idiom of having several free functions packaged in a module, sadly. Python is dynamic but only once the program starts executing :-). Even though Python classes can change, they do so only at runtime ( wouldn't it be scary if they decided to change as code when you are not looking :-) ). So dynamism of Python should not be as much of an issue. But on a similar note, I was wondering about classes such as BaseHTTPServer where the function to be called is looked up by name, and may or may not exist, or the situation where multiple function calls with similar signatures can be redirected to one using some getattr trickery - these don't seem to play well with the static nature of UML. (Or editor auto-completion, or cross-referencing code in an IDE...) I tend to shy away from such constructs for these reasons. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: HIRING: PHP Developer
-- http://urlkick.com/ Free URL redirection service. Turns a long URL into a much shorter one. Lawrence D'Oliveiro [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: We are hiring a PHP developer! http://groups.google.com/[EMAIL PROTECTED] .co.nz Or http://urlkick.com/51 :) Simon -- http://mail.python.org/mailman/listinfo/python-list
Filters like old skool Jive, Fudd, Valspeak... Text transformation in Python
I would like to learn how to roll my own filter ala early 90's filters like Jive, Fudd, Kraut, Moron, etc, that take text as an input, and re-writes the text adding general hilarity of various linguistic flavor (depending on the filter). I always loved running my philosophy papers, or anything that sounded too dang serious through filters. Gave me a new perspective on my own writing. Running the screenplay of the Empire Strikes Back through the Kraut filter, particularly the scene where Vader reveals Skywalker's true lineage, is amusing. No offense to good Germans everywhere. I'm sure someone could write a good American filter than would be a gag on American obsession with success and work, being happy 100% of the time, etc. Anyway, I'd like to see an old skool filter written in Python so I can write my own filters. There's an old prof of mine so, erm, linguistically unique, that I absolutely must write a Prof X filter to share with old college buds. I need to encapsulate / generate a model of the Prof's speech patterns for posterity and educational purposes only - ok, for entertainment. A fun way to learn more about Python and text processing. Any good generators written in Python? I'd like to roll me one of these as well; e.g. execute the program and it will create a few paragraphs of text in the jargon of a discipline, subdiscipline, subculture, etc. Anyone know what I'm talking about? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
[pyqt] How to copy the content of a QPopupMenu ?
Dear all, For a particuliar case, I need to copy all the items of an existing menu (including the separators and sub-menus) in a new empty one ... Does someone knows how to do that ? I've tried : item = menu_orig.findItem(item_id) menu_new.insertItem(item, item_id) but it fails with : TypeError: argument 1 of QMenuData.insertItem() has an invalid type Thanks in advance, Cheers, K. -- http://mail.python.org/mailman/listinfo/python-list
Re: A Lambda Logo Tour
Scripsit Xah Lee [EMAIL PROTECTED] Subroutines in lisps easily have side-effects, and sometimes non-functional programing methodologies such as OOP are actually encouraged in lisp. As most of you know, the lambda symbol chosen by functional languages is to signify no side-effects. What are you smoking? You're sure you could stop anytime you wanted, right? -- Henning MakholmWhat a hideous colour khaki is. -- http://mail.python.org/mailman/listinfo/python-list
wxPython and SuSE 10.0
Hello, I was wondering if there is a wxPython RPM for SuSE 10.0 available. I Googled for it with no luck, but I'm hopeful that there is one out there. Thanks-in-Advance Steve -- http://mail.python.org/mailman/listinfo/python-list
Re: A Lambda Logo Tour
I bet the ∑-book also has some λ-stuff in it. If it doesn't, it probably uses some other greek letters that aren't mentioned on the cover. It's such a shame, really ... :( -- Lars Rune Nøstdal http://lars.nostdal.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Filters like old skool Jive, Fudd, Valspeak... Text transformation in Python
[EMAIL PROTECTED] wrote: (snip part about filters) Any good generators written in Python? I'd like to roll me one of these as well; e.g. execute the program and it will create a few paragraphs of text in the jargon of a discipline, subdiscipline, subculture, etc. Anyone know what I'm talking about? There's a Kant generator example in Dive Into Python: http://diveintopython.org/xml_processing/index.html -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: String pattern matching
[EMAIL PROTECTED] wrote: Thanks to all for the various good approaches. Kent's plain RE approach seems the most straightforward - did not know that RE can handle this situation - good to know! Thanks to Eddie Corns also who showed how to express the problem as a parsing problem. I am also trying a pyparsing solution but I don't see a way to repeat a previous element in pyparsing. Paul McGuire, are you listening? Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: Convertion of Unicode to ASCII NIGHTMARE
Roger Binns wrote: fact or FUD? let's see: Note I said SQLite. For APIs that take/give strings, you can either supply/get a UTF-8 encoded sequence of bytes, or two bytes per character host byte order sequence. Any wrapper of SQLite that doesn't do Unicode in/out is seriously breaking things. I ended up using the UTF-8 versions of the API as Python can't quite make its mind up how to represent Unicode strings at the C api level. You can have two bytes per char or four, and the handling/production of byte order markers isn't that clear either. sounds like your understanding of Unicode and Python's Unicode system is a bit unclear. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange problem when running python code
ishtar2020 wrote: It's quite puzzling. And if I change some lousy thing, like inserting a newline between the sentences, the interpreter will find another error somewhere else, even when that part of the code was working flaw- lessly in previous runs what Python version are you using ? (I've already provided an explanation in another post, but it seems that neither you nor the it's your fault crowd read that...). /F -- http://mail.python.org/mailman/listinfo/python-list
Re: using range() in for loops
John Salerno schreef: I'm reading Text Processing in Python right now and I came across a comment that is helping me to see for loops in a new light. I think because I'm used to the C-style for loop where you create a counter within the loop declaration, for loops have always seemed to me to be about doing something a certain number of times, and not about iterating over an object. The reason for this distinction comes from the fact that I read a lot how using range and for is somewhat discouraged, because it doesn't really use a for loop for it's true purpose. So my question is, is this just a Python-oriented opinion about for loops, or is it a general idea? Also, what if you *do* need to just do something a set number of times. Is this okay, or does it mean you are approaching the problem incorrectly? Using for and range together seems to be a common idiom, yet at the same time discouraged, so I'm wondering what is a good balance. I felt more or less the same when I first learned Python; I was also used to C-style loops, coming from a C/C++ background. In the end though, it turned out to be a non-issue for me. In many cases loops really are for iterating over sequences; more so than I realized when using for loops in C or C++. In these cases, Python's for statement works better than C-style loops. And if you really need to do something a certain number of times, there's still range() or xrange() to do it. It's quite simple, I think: - You have a sequence or iterator to loop over? Use for x in sequence. - You want something done a set number of times? Use for i in range(). - You want to loop over a sequence and also need the index? Use for i, x in enumerate(sequence). -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list
Re: Dice probability problem
Antoon Pardon wrote: IMO you are making things too complicated and not general enough. I believe that the above is very likely more than just your opinion :) Programming is just an occasional hobby to me, and I lack both experience and deeper (possibly a good chunk of shallow as well) knowledge on the subject. I'll study the code you posted, and make further questions if something remains unclear afterwards. Thanks, Tomi Lindberg -- http://mail.python.org/mailman/listinfo/python-list
Re: [pyqt] How to copy the content of a QPopupMenu ?
[EMAIL PROTECTED] wrote: Dear all, For a particuliar case, I need to copy all the items of an existing menu (including the separators and sub-menus) in a new empty one ... Does someone knows how to do that ? I've tried : item = menu_orig.findItem(item_id) menu_new.insertItem(item, item_id) but it fails with : TypeError: argument 1 of QMenuData.insertItem() has an invalid type From the docs: QMenuItem * QMenuData::findItem ( int id ) const Returns the menu item with identifier id, or 0 if there is no item with this identifier. Note that QMenuItem is an internal class, and that you should not need to call this function. Use the higher level functions like text(), pixmap() and changeItem() to get and modify menu item attributes instead. See also indexOf(). Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Standalone Python functions in UML?
Roman Susi wrote: [...] Also, my argument that Python is quite good at communicating design ideas is supported by the fact that Python developers do not use UML (or other modelling tools/languages) as often as say Java programmers, nor feel the need to. And probably Python is too dynamic for UML. That is another reason rountrip tools aren't there. Another reason is probably the problem you started this thread with; UML class diagrams are very much centered around Java style object orientation. Other paradigms, like the procedural and the generic ones, do not fit well. Nor is it well suited to represent the shift to a meta level that is involved when you start creating types at execution time. Cheers, Nicola Musatti -- http://mail.python.org/mailman/listinfo/python-list
Re: How to copy the content of a QPopupMenu ?
Dear Diez, Thanks ... I've already read the doc :) In my case, I would like to copy an item from a popup menu to another popup menu ... Of course, I can create a new item with same name, same pixmap and so on but I don't know how to execute the same code when my new item is activated ... And I don't know how to treat the separators (Is there a way to distinguish a real item from a separator ?) And what about the sub-menus ... In fact, all items (usual items, separators and sub-menus) are ... items. So I was wondering if it is a way to copy an item (more precisely to get an item then to insert it in another menu) Cheers, E.A. -- http://mail.python.org/mailman/listinfo/python-list
Re: Standalone Python functions in UML?
bruno at modulix wrote: [...] Yes, there's in UML a fundamental distinction between classes and objects - distinction that does not exist in a lot of OO languages. This greatly limits UML's usability for some common idioms in dynamic OOPL's. Seems like UML has been designed to express only the restricted subset of OO supported by rigid static languages like C++, Java and ADA. Moreover, it also seems like UML has been designed to express the restricted OO subset of the paradigms supported by languages like C++ and ADA. And I suspect UML design tools are not that popular within the C and Lisp programming communities... Cheers, Nicola Musatti -- http://mail.python.org/mailman/listinfo/python-list
Re: Dice probability problem
Tomi Lindberg [EMAIL PROTECTED] writes: # Adds another die to results. def add_dice(sums, die): # If first die, all values appear once I'd add something like sums = sums or {} because otherwise your function will sometimes mutate sums and sometimes return a fresh object, which usually is a very bad thing as it can easily lead to quite nasty bugs. if not sums: for face in die: sums[face] = 1 # Calculating the number of appearances for additional # dice else: new_sums = {} for k in sums.keys(): for f in die: if new_sums.has_key(k+f): new_sums[k+f] += sums[k] else: new_sums[k+f] = sums[k] sums = new_sums return sums 'as -- http://mail.python.org/mailman/listinfo/python-list
Re: HTMLParser fragility
[Daniel] You could try HTMLTidy (http://www.egenix.com/files/python/mxTidy.html) as a first step to get well formed HTML. But Tidy fails on huge numbers of real-world HTML pages. Simple things like misspelled tags make it fail: from mx.Tidy import tidy results = tidy(htmlbodypreeHello world!/pre/body/html) print results[3] line 1 column 7 - Warning: inserting missing 'title' element line 1 column 13 - Error: pree is not recognized! line 1 column 13 - Warning: discarding unexpected pree line 1 column 31 - Warning: discarding unexpected /pre This document has errors that must be fixed before using HTML Tidy to generate a tidied up version. Is there a Python HTML tidier which will do as good a job as a browser? -- Richie -- http://mail.python.org/mailman/listinfo/python-list
RELEASED Python 2.5 (alpha 1)
On behalf of the Python development team and the Python community, I'm happy to announce the first alpha release of Python 2.5. This is an *alpha* release of Python 2.5, and is the *first* alpha release. As such, it is not suitable for a production environment. It is being released to solicit feedback and hopefully discover bugs, as well as allowing you to determine how changes in 2.5 might impact you. If you find things broken or incorrect, please log a bug on Sourceforge. In particular, note that changes to improve Python's support of 64 bit systems might require authors of C extensions to change their code. More information (as well as source distributions and Windows installers) are available from the 2.5 website: http://www.python.org/2.5/ The plan from here is for a number of additional alpha releases, followed by one or more beta releases and moving to a 2.5 final release around August. PEP 356 includes the schedule and will be updated as the schedule evolves. The new features in Python 2.5 are described in Andrew Kuchling's What's New In Python 2.5. It's available from the 2.5 web page. Amongst the language features added include conditional expressions, the with statement, the merge of try/except and try/finally into try/except/finally, enhancements to generators to produce a coroutine kind of functionality, and a brand new AST-based compiler implementation. New major modules added include hashlib, ElementTree, sqlite3 and ctypes. In addition, a new profiling module cProfile was added. A large number of bugs, regressions and reference leaks have been fixed since Python 2.4. See the release notes for more. Enjoy this new (alpha!) release, Anthony Anthony Baxter [EMAIL PROTECTED] Python Release Manager (on behalf of the entire python-dev team) pgpeD3UBh10yc.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: How to copy the content of a QPopupMenu ?
[EMAIL PROTECTED] wrote: Dear Diez, Thanks ... I've already read the doc :) In my case, I would like to copy an item from a popup menu to another popup menu ... Of course, I can create a new item with same name, same pixmap and so on but I don't know how to execute the same code when my new item is activated ... And I don't know how to treat the separators (Is there a way to distinguish a real item from a separator ?) And what about the sub-menus ... In fact, all items (usual items, separators and sub-menus) are ... items. So I was wondering if it is a way to copy an item (more precisely to get an item then to insert it in another menu) Your approach at whole must be changed. You can't just insert the old items somewhere else - they have a 1:n parent-relation that would be changed - either crashing, or simply removing your item from your old menu. What you need is a different means to create the items - some factory/function that gets passed a QPopupMenu and adds all the items, together with the connectrions and so on. You then invoke that on the other menu. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: RELEASED Python 2.5 (alpha 1)
After reading AMK's survey of what's new in Python 2.5, I am suitably impressed. As usual, I can't wait to start using the cool new features... extended generators? (mind is currently swimming with the question of can I implement Scheme's call-with-current-continuation using extended generators.) Anyway, the more important question that came to mind: I see that 2.5 will include the excellent ElementTree. Will cElementTree be included where available? or is it only the pure-Python version that will be in the standard library? - Michael -- mouse, n: a device for pointing at the xterm in which you want to type. -- Fortune Visit me on the Web: http://www.elehack.net -- http://mail.python.org/mailman/listinfo/python-list
Re: RELEASED Python 2.5 (alpha 1)
Michael Ekstrand wrote: [...] Anyway, the more important question that came to mind: I see that 2.5 will include the excellent ElementTree. Will cElementTree be included where available? or is it only the pure-Python version that will be in the standard library? Both elementtree as (xml.etree) and cElementTree (as _elementtree) are included. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: RELEASED Python 2.5 (alpha 1)
Michael Ekstrand wrote: After reading AMK's survey of what's new in Python 2.5, I am suitably impressed. As usual, I can't wait to start using the cool new features... extended generators? (mind is currently swimming with the question of can I implement Scheme's call-with-current-continuation using extended generators.) No. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to copy the content of a QPopupMenu ?
[EMAIL PROTECTED] wrote: In my case, I would like to copy an item from a popup menu to another popup menu ... Of course, I can create a new item with same name, same pixmap and so on but I don't know how to execute the same code when my new item is activated ... And I don't know how to treat the separators (Is there a way to distinguish a real item from a separator ?) And what about the sub-menus ... You might want to use QAction to define individual items that can be activated. That way you can just reuse the same actions in both menus or move them from one to another. Submenus will probably take more effort to move. In some ways, it might be useful to keep some sort of data structure around that you can use as a template for the menu, and regenerate the menu from that. In fact, all items (usual items, separators and sub-menus) are ... items. So I was wondering if it is a way to copy an item (more precisely to get an item then to insert it in another menu) Not with one single operation as far as I can see, unless you're using QAction, and even then it will only work for normal menu items. Aside: The Qt 4 action system probably makes it a lot easier to do what you're trying to do, though that's not a lot of help if your project is based on Qt 3. :-/ David -- http://mail.python.org/mailman/listinfo/python-list
Re: How to copy the content of a QPopupMenu ?
Well, the Google web interface didn't quite work as expected there. Here's a version of the previous message containing just my advice. You might want to use QAction to define individual items that can be activated. That way you can just reuse the same actions in both menus or move them from one to another. Submenus will probably take more effort to move. In some ways, it might be useful to keep some sort of data structure around that you can use as a template for the menu, and regenerate the menu from that. Aside: The Qt 4 action system probably makes it a lot easier to do what you're trying to do, though that's not a lot of help if your project is based on Qt 3. :-/ -- http://mail.python.org/mailman/listinfo/python-list
small challenge : limit((x+1)**0.5 for x in itially(2))
generators challenge define limit and itially so that limit(foo(x) for x in itially(bar)) works out the same as limit2(foo,bar) with def limit2(foo,bar) : bar1 = foo(bar) while bar != bar1 : bar1,bar = foo(bar),bar1 return bar Note : be careful with your choice of foo and bar, to prevent infinite loops when the iterated value won't converge. To think of it, perhaps abs(bar-bar1)epsilon would be more appropriate than bar != bar1 in the above loop - I can imagine roundoff errors leading to tiny oscillations in the least significant bits of an otherwise convergent computation. Best, az -- http://mail.python.org/mailman/listinfo/python-list
Re: Dice probability problem
Antoon Pardon wrote: def __rmul__(self, num): tp = num * [self] return reduce(operator.add, tp) sum3d6 = 3 * D(6) One basic question: is there any particular reason not to use __mul__ instead (that would allow me to use both 3 * D(6) and D(6) * 3, while __rmul__ raises an AttributeError with the latter)? Difference between the two methods is slightly unclear to me. Thanks, Tomi Lindberg -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange problem when running python code
On Tue, 04 Apr 2006 12:01:12 -0700, ishtar2020 wrote: I must add, when the python interpreter displays the traceback, with the line that is producing the error, it doesn't look like the one I got in the code. I sometimes get that problem when I'm running code, I make a change in the source file, use reload() to update my module, but forget to reinitialise my objects still in memory. So I end up with (buggy) instances in memory, but when I hit a traceback, the source code displayed has nothing to do with the actual error because the source file has been edited. If you are getting these weird errors when you do nothing but change comments, there is a good chance that's what is happening. Here is an example of that behaviour. Is this the sort of thing which is happening to you? # === File tester.py === class Parrot(object): def speak(self): print I'm pining for the fjords. def species(self, colour=None): return Norwegian + colour Now import the file: import tester p = tester.Parrot() p.speak() I'm pining for the fjords. p.species() Traceback (most recent call last): File stdin, line 1, in ? File tester.py, line 9, in species return Norwegian + colour TypeError: cannot concatenate 'str' and 'NoneType' objects Now I edit the file, just adding comments and nothing else: # === File tester.py === class Parrot(object): # Add some comments here. # Line two. def speak(self): print I'm pining for the fjords. def species(self, colour=None): return Norwegian + colour But if I execute the old existing object, I get a nonsensical error: p.species() Traceback (most recent call last): File stdin, line 1, in ? File tester.py, line 9, in species print I'm pining for the fjords. TypeError: cannot concatenate 'str' and 'NoneType' objects Even doing a reload() doesn't help. I have to delete the old instance, and create a new one. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: using range() in for loops
Roel Schroeven wrote: In many cases loops really are for iterating over sequences; more so than I realized when using for loops in C or C++. In these cases, Python's for statement works better than C-style loops. And if you really need to do something a certain number of times, there's still range() or xrange() to do it. Yeah, I'm starting to see the distinction now. I think one thing that confused me was that C# had two separate loops for these functionalities, the for loop and the foreach loop (which is equivalent to Python's for). But even when just doing something a number of times (C#'s for, Python's for), it looks much cleaner in Python because you don't have the long, messy three-part for statement. -- http://mail.python.org/mailman/listinfo/python-list
Re: using range() in for loops
Paul Rubin wrote: Normally you'd use range or xrange. range builds a complete list in memory so can be expensive if the number is large. xrange just counts up to that number. so when range would be used instead of xrange. if xrange is more efficient, why range was not reimplemented? -- http://mail.python.org/mailman/listinfo/python-list
Re: small challenge : limit((x+1)**0.5 for x in itially(2))
Azolex wrote: generators challenge define limit and itially so that limit(foo(x) for x in itially(bar)) works out the same as limit2(foo,bar) with def limit2(foo,bar) : bar1 = foo(bar) while bar != bar1 : bar1,bar = foo(bar),bar1 oops, this should read bar1,bar = foo(bar1),bar1 sorry return bar Note : be careful with your choice of foo and bar, to prevent infinite loops when the iterated value won't converge. To think of it, perhaps abs(bar-bar1)epsilon would be more appropriate than bar != bar1 in the above loop - I can imagine roundoff errors leading to tiny oscillations in the least significant bits of an otherwise convergent computation. Best, az -- http://mail.python.org/mailman/listinfo/python-list
Re: using range() in for loops
[EMAIL PROTECTED] wrote: hi John, Python doesn't provide for loop like C / C++ but using Range() or Xrange() you can achive all the functionalities of the C for loop. Not quite. Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: using range() in for loops
AndyL wrote: Paul Rubin wrote: Normally you'd use range or xrange. range builds a complete list in memory so can be expensive if the number is large. xrange just counts up to that number. so when range would be used instead of xrange. if xrange is more efficient, why range was not reimplemented? Because of backwards compatibility. range() returns a list, xrange() an iterator: list(xrange(...)) will give the same results as range(...). In for loops, using xrange instead of range makes no difference since the loop only iterates over the range. But it's a problem when someone just does l = range(100) and assumes that he's got a list, probably doing l.remove(5) and so on. In Python 3000, plans are that range() will be the same as xrange() is now, and anyone needing a list can call list(range(...)). Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: using range() in for loops
On Tue, 2006-04-04 at 21:54 -0400, John Salerno wrote: I'm reading Text Processing in Python right now and I came across a comment that is helping me to see for loops in a new light. I think because I'm used to the C-style for loop where you create a counter within the loop declaration, for loops have always seemed to me to be about doing something a certain number of times, and not about iterating over an object. This is a normal reaction. Try to keep in mind that when you use any higher level language your code will closer reflect what you want rather than how to accomplish what you want. When you are creating a loop over numbers, is your goal really to count, or to use the integer that you are counting to do something else, like perhaps dereference elements of a string. Also, part of the problem is a preconceived restriction that you hold on the use of forloops. They arn't just for counting, there are all sorts of interesting things that can go in there. Remember, a for loop is basically a while loop with a little bit of syntactic sugar. Look at this: for( a, b, c ) { d; e; } is the same as a; while (b) { d; e; c; } C for and while are the same creature. Python's while loop is Python's version of for/while. If you wanted to mimick C you could write i = 0 while( i10 ): print i i+=1 but this is clumbsy and slower. for(i=0;i10;i++) is a common enough programing pattern, you arn't really interested in setting i, incrementing, doing all of that housekeeping. You really want to repeat 10 times with with i set to 0, 1 ... for ... xrange does this well and is somewhat the motivation for the creation of xrange. The reason for this distinction comes from the fact that I read a lot how using range and for is somewhat discouraged, because it doesn't really use a for loop for it's true purpose. So my question is, is this Nothing in a well defined language has a true purpose. The true purpose of an int in C isn't to be for loop fodder. One of the hallmarks of a well designed language is orthogonality; most anything works with anything else. A feature that has one specific use doesn't provide much utility to justify the effort used to create it. just a Python-oriented opinion about for loops, or is it a general idea? Programming languages borrow from heavily from natural languages; yes, for is a loaned word from English that exists in C, python ... lots of languages. But just as when one human language borrows from another, the resulting semantics are not always the same. Each as a formal semantic. C and Python are somewhat different, and yes, you could describe the philosophical difference as a matter of opinions. Also, what if you *do* need to just do something a set number of times. Is this okay, or does it mean you are approaching the problem incorrectly? Using for and range together seems to be a common idiom, yet at the same time discouraged, so I'm wondering what is a good balance. The correct idiom is for( xrange( foo )). This is preferred over range for efficiency. Historically there were no iters. If you wanted to do loop you would say for x in range( 10 ): foo bar range created a list of 10 items and x marched over them. Creating this list in advance doesn't need to take any more time; you have to create the number objects anyway to assign to x at some point, so you might as well get that done with upfront. The problem was memory consumption. The memory requirements of the list put a bound on large your iteration could be. xrange was created, and soon followed general iters. Now, the range object generates the numbers on the fly as the loop runs .. the loop says hey, whats next and the next item is returned. When people say don't say for x in range they are really saying use xrange instead of range. -- http://mail.python.org/mailman/listinfo/python-list
Re: using range() in for loops
AndyL [EMAIL PROTECTED] wrote: Paul Rubin wrote: Normally you'd use range or xrange. range builds a complete list in memory so can be expensive if the number is large. xrange just counts up to that number. so when range would be used instead of xrange. if xrange is more efficient, why range was not reimplemented? If you actually want the list for some reason: $ python2.4 -mtimeit 'list(xrange(100))' 10 loops, best of 3: 4.54 usec per loop $ python2.4 -mtimeit 'range(100)' 10 loops, best of 3: 2.61 usec per loop -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | Frankly I have no feelings towards penguins one way or the other \X/ |-- Arthur C. Clarke her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange problem when running python code
Dennis Lee Bieber wrote: As an occassional dabbler in the Tarot, I can assure you that cards are NOT used for mind-reading; they merely offer up a possible future which must be interpreted in light of the querant's situation... (or, since I typically read for myself -- the allow my subconscious to reveal my inclinations based upon the cards' meanings) Who said anything about tarot? I'm talking about the old Pick a card, any card... bit. Cheers. -- Steve Juranich Tucson, AZ USA -- http://mail.python.org/mailman/listinfo/python-list
Re: Registration Code
On Tue, 04 Apr 2006 12:02:24 -0700, Ross Ridge wrote: Steven D'Aprano wrote: Look at Microsoft. Their first version of Word (for Macintosh, as it turned out) was copy-protected. Their second version of Word, and every version since, as well as Excel and Powerpoint, have not included copy protection, time-limitations, product activation, or any other barrier to keep users away. On the contrary -- Microsoft have turned a blind eye to piracy until fairly recently. Same with Windows -- although, a few years back when Microsoft felt secure in owning the desktop, they introduced product activation. Microsoft has been using product activation in it's office software for a while now, before Windows XP in fact. You're right, Office has Product Activation as well as Windows, that was my error. However, consider how easy Microsoft make it to avoid Product Activation: if you purchase volume licences, and by volume I mean five licences or more, you don't have to use PA. I know plenty of people who have activated their version of Windows; I don't know anyone, home user or corporate, who has needed to activate their version of Office. It is so easy to legally avoid PA on Office that I wasn't even aware you needed to do so -- and let's not even talk about illegal installations. Presumably there are a few SMEs and home users who have had to do PA on their Office installs, but as a percentage, I'd be very surprised if it was more than a tiny minority. What are the odds that Vista will have it? About 100%. Considering that you can hardly walk into a university, school or corporation without finding Windows or Office supplied without PA, would you care to revise that number? (That's a rhetorical question, by the way.) -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: RELEASED Python 2.5 (alpha 1)
Michael Ekstrand wrote: Anyway, the more important question that came to mind: I see that 2.5 will include the excellent ElementTree. Will cElementTree be included where available? or is it only the pure-Python version that will be in the standard library? they're both available, via the xml.etree namespace: import xml.etree.ElementTree import xml.etree.cElementTree we've also modified things so that cElementTree uses the expat instance provided by pyexpat (via runtime linking), rather than it's own copy. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: tuple syntax ',' (ending in comma?)
On Wed, 05 Apr 2006 08:17:07 +1000, Ben Finney wrote: Michael Yanowitz [EMAIL PROTECTED] writes: I am still relatively new to Python. I am confused by the syntax for tuples. Well, it's reassuring to know that this is still as confusing for newcomers now as it was when I started. With the introduction of generator expressions, I'm sure the next generation of newcomers will have a brand new source of confusion whenever they see a pair of parentheses, ensuring plenty of work for those writing tutorials and books. And they say that language designers don't think of the future. *wink* -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: using range() in for loops
On Wed, 05 Apr 2006 09:16:37 -0400, AndyL wrote: Paul Rubin wrote: Normally you'd use range or xrange. range builds a complete list in memory so can be expensive if the number is large. xrange just counts up to that number. so when range would be used instead of xrange. if xrange is more efficient, why range was not reimplemented? For historical reasons. Don't worry, in Python3000, range() will be an iterator, and xrange() will disappear. Until then, I use range() for small loops (by small I mean anything up to a few tens of thousands), and xrange() only when I absolutely have to optimize my code to save a piddling few tens of kilobytes of memory. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: using range() in for loops
On Wed, 05 Apr 2006 16:15:12 +0200, Georg Brandl wrote: [EMAIL PROTECTED] wrote: hi John, Python doesn't provide for loop like C / C++ but using Range() or Xrange() you can achive all the functionalities of the C for loop. Not quite. Care to explain what the differences are, or shall we guess? -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: using range() in for loops
On Wed, 05 Apr 2006 16:21:02 +0200, Georg Brandl wrote: Because of backwards compatibility. range() returns a list, xrange() an iterator: list(xrange(...)) will give the same results as range(...). Georg is pretty much correct in his explanation, but just to dot all the I's and cross all the T's, we should explain that xrange() doesn't return an iterator, it returns a special xrange object: x = xrange(1000) type(x) type 'xrange' xrange existed as a special bit of magic before Python supported iterators. While xrange objects behave (sort of) like iterators, they aren't quite the same. For instance, they don't have a next attribute: x.next Traceback (most recent call last): File stdin, line 1, in ? AttributeError: 'xrange' object has no attribute 'next' whereas iterators do: i = iter(range(1000)) i.next method-wrapper object at 0xf7054d2c Likewise, you can get random access to the items in an xrange object: x[500] 500 but not in iterators: i[500] Traceback (most recent call last): File stdin, line 1, in ? TypeError: unsubscriptable object -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: using range() in for loops
Steven D'Aprano wrote: On Wed, 05 Apr 2006 16:21:02 +0200, Georg Brandl wrote: Because of backwards compatibility. range() returns a list, xrange() an iterator: list(xrange(...)) will give the same results as range(...). Georg is pretty much correct in his explanation, but just to dot all the I's and cross all the T's, we should explain that xrange() doesn't return an iterator, it returns a special xrange object: Ah yes, the old iterator - iterable problem ;) Georg -- http://mail.python.org/mailman/listinfo/python-list
ceval.c no such file or dir and SIGSEGV
Hi, I'm running 2.4 Python. I have an extension program that calls C funcs. Actually I have a C prog that calls python that calls C. In a python to C function call I get a SIGSEGV and this stack trace. I have print statements that show it made it into the C extension function, and within there its crashing with this trace. gdb also puts up a popup that says Python/ceval.c No such file or directory. Thanks. Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 1024 (LWP 7873)] PyEval_EvalFrame (f=0x8472c8c) at ../Python-2.4/Python/ceval.c:899 in ../Python-2.4/Python/ceval.c (gdb) where #0 PyEval_EvalFrame (f=0x8472c8c) at ../Python-2.4/Python/ceval.c:899 #1 0x081f4611 in fast_function (func=0x0, pp_stack=0xbfffe304, n=4, na=1, nk=0) at ../Python-2.4/Python/ceval.c:3629 #2 0x081f4174 in call_function (pp_stack=0xbfffe304, oparg=1) at ../Python-2.4/Python/ceval.c:3568 #3 0x081f26ba in PyEval_EvalFrame (f=0x847741c) at ../Python-2.4/Python/ceval.c:2163 #4 0x081f4611 in fast_function (func=0x0, pp_stack=0xbfffe434, n=4, na=1, nk=0) at ../Python-2.4/Python/ceval.c:3629 #5 0x081f4174 in call_function (pp_stack=0xbfffe434, oparg=1) at ../Python-2.4/Python/ceval.c:3568 #6 0x081f26ba in PyEval_EvalFrame (f=0x8476b6c) at ../Python-2.4/Python/ceval.c:2163 #7 0x081f4611 in fast_function (func=0x0, pp_stack=0xbfffe564, n=4, na=1, nk=0) at ../Python-2.4/Python/ceval.c:3629 #8 0x081f4174 in call_function (pp_stack=0xbfffe564, oparg=1) at ../Python-2.4/Python/ceval.c:3568 #9 0x081f26ba in PyEval_EvalFrame (f=0x84724bc) at ../Python-2.4/Python/ceval.c:2163 #10 0x081f4611 in fast_function (func=0x0, pp_stack=0xbfffe694, n=4, na=1, nk=0) at ../Python-2.4/Python/ceval.c:3629 #11 0x081f4174 in call_function (pp_stack=0xbfffe694, oparg=1) at ../Python-2.4/Python/ceval.c:3568 #12 0x081f26ba in PyEval_EvalFrame (f=0x848f65c) at ../Python-2.4/Python/ceval.c:2163 #13 0x081f4611 in fast_function (func=0x0, pp_stack=0xbfffe7c4, n=4, na=1, nk=0) at ../Python-2.4/Python/ceval.c:3629 #14 0x081f4174 in call_function (pp_stack=0xbfffe7c4, oparg=1) at ../Python-2.4/Python/ceval.c:3568 #15 0x081f26ba in PyEval_EvalFrame (f=0x846b5fc) at ../Python-2.4/Python/ceval.c:2163 #16 0x081f4611 in fast_function (func=0x0, pp_stack=0xbfffe8f4, n=4, na=1, nk=0) at ../Python-2.4/Python/ceval.c:3629 #17 0x081f4174 in call_function (pp_stack=0xbfffe8f4, oparg=1) at ../Python-2.4/Python/ceval.c:3568 #18 0x081f26ba in PyEval_EvalFrame (f=0x848ea1c) at ../Python-2.4/Python/ceval.c:2163 #19 0x081f4611 in fast_function (func=0x0, pp_stack=0xbfffea24, n=4, na=1, nk=0) at ../Python-2.4/Python/ceval.c:3629 #20 0x081f4174 in call_function (pp_stack=0xbfffea24, oparg=1) at ../Python-2.4/Python/ceval.c:3568 #21 0x081f26ba in PyEval_EvalFrame (f=0x848dddc) at ../Python-2.4/Python/ceval.c:2163 #22 0x081f4611 in fast_function (func=0x0, pp_stack=0xbfffeb54, n=4, na=1, nk=0) at ../Python-2.4/Python/ceval.c:3629 #23 0x081f4174 in call_function (pp_stack=0xbfffeb54, oparg=1) at ../Python-2.4/Python/ceval.c:3568 #24 0x081f26ba in PyEval_EvalFrame (f=0x847959c) at ../Python-2.4/Python/ceval.c:2163 #25 0x081f30fe in PyEval_EvalCodeEx (co=0x402dcca0, globals=0x1, locals=0x0, args=0x4032e970, argcount=3, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at ../Python-2.4/Python/ceval.c:2730 #26 0x0824c8e9 in function_call (func=0x4031ee2c, arg=0x4032e964, kw=0x0) at ../Python-2.4/Objects/funcobject.c:550 #27 0x081a86c9 in PyObject_Call (func=0x8472c8c, arg=0x1, kw=0x1) at ../Python-2.4/Objects/abstract.c:1746 #28 0x081f4005 in PyEval_CallObjectWithKeywords (func=0x1, arg=0x4032e964, kw=0x0) at ../Python-2.4/Python/ceval.c:3419 #29 0x081a8690 in PyObject_CallObject (o=0x1, a=0x1) at ../Python-2.4/Objects/abstract.c:1737 #30 0x080ce555 in pyGraphResolvePoint (funcIndex=1, sim=0, field_name=0x825c17c signal, x=2.2002, y=7.2002, point=0xbfffed38) at pygraph.c:94 #31 0x080c1058 in graphNodeResolvePoint (sim=0, fieldName=0x825c17c signal, x=2.2002, y=7.2002) at graph.c:57 #32 0x0807a7a6 in fibs_pointEval (sim=0, pointname=0x825c17c signal, pos={x = 2.2002, y = 7.2002}) at libfibs.c:386 #33 0x0807b03f in libfibsTest (xmdlpath=0x825bd58 xmdl.test, x=2.2002, y=7.2002) at libfibs.c:716 #34 0x08079c01 in main () at libfibsTest.c:8 #35 0x40186507 in __libc_start_main (main=0x8079bc8 main, argc=1, ubp_av=0xbfffeeb4, init=0x80789cc _init, fini=0x825bd20 _fini, rtld_fini=0x4000dc14 _dl_fini, stack_end=0xbfffeeac) at ../sysdeps/generic/libc-start.c:129 (gdb) Quit (gdb) -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython and SuSE 10.0
On 2006-04-05, Steve [EMAIL PROTECTED] wrote: Hello, I was wondering if there is a wxPython RPM for SuSE 10.0 available. I Googled for it with no luck, but I'm hopeful that there is one out there. http://www.novell.com/products/linuxpackages/professional/python-wxgtk.html is the package you want I suppose, it's called python-wxGTK-2.6.1.0-4.i586.rpm. You get it with SUSE 10.0 pro but not in openSUSE. Don't know why not as it's GPL. So it exists, I can tell you that much... not sure where you can get it though. Googling the exact name throws up a few things. Ah here we are: http://www.vislab.uq.edu.au/research/accessgrid/software/suse/wxWindows/RPMS/python-wxGTK-2.6.1.0-4.i586.rpm -- http://mail.python.org/mailman/listinfo/python-list
Re: small challenge : limit((x+1)**0.5 for x in itially(2))
Azolex [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] generators challenge define limit and itially so that limit(foo(x) for x in itially(bar)) works out the same as limit2(foo,bar) with def limit2(foo,bar) : bar1 = foo(bar) while bar != bar1 : bar1,bar = foo(bar),bar1 return bar Howzis? -- Paul class Bag: pass data = Bag() data.x = None def itially(bar): if data.x is None: data.x = bar while 1: yield data.x def limit(z): eps = 1e-10 done = False z2 = z.next() z1 = z2 + 1 while abs(z2-z1) eps: data.x = z2 z2, z1 = z.next(),z2 print dbg,z1,z2 return z1 print limit( x**0.5 for x in itially(2) ) Prints out: dbg 1.41421356237 1.189207115 dbg 1.189207115 1.09050773267 dbg 1.09050773267 1.04427378243 dbg 1.04427378243 1.02189714865 dbg 1.02189714865 1.01088928605 dbg 1.01088928605 1.00542990111 dbg 1.00542990111 1.00271127505 dbg 1.00271127505 1.00135471989 dbg 1.00135471989 1.00067713069 dbg 1.00067713069 1.00033850805 dbg 1.00033850805 1.00016923971 dbg 1.00016923971 1.8461627 dbg 1.8461627 1.4230724 dbg 1.4230724 1.211534 dbg 1.211534 1.1057664 dbg 1.1057664 1.0528831 dbg 1.0528831 1.0264415 dbg 1.0264415 1.0132207 dbg 1.0132207 1.0066104 dbg 1.0066104 1.0033052 dbg 1.0033052 1.0016526 dbg 1.0016526 1.0008263 dbg 1.0008263 1.0004131 dbg 1.0004131 1.0002066 dbg 1.0002066 1.0001033 dbg 1.0001033 1.516 dbg 1.516 1.258 dbg 1.258 1.129 dbg 1.129 1.065 dbg 1.065 1.032 dbg 1.032 1.016 dbg 1.016 1.008 1.016 -- http://mail.python.org/mailman/listinfo/python-list
is there any bug in this multi-thread script?
I wrote a script to do work with multi-thread in a queue reference others code. Is there any bug in this script? another question is : when we call start to run one thread extends from threading, it will call a join() by itself? I want to monitor the qsize() to ensure all work are finished. but when I commented the #code start while q.qsize()0: time.sleep(0.1) #code end it works well too. any response is welcome. Thanks a lot. #code start #!/usr/bin/env python import Queue import threading import time import random q=Queue.Queue(0) NUM_WORKERS = 3 class MyThread(threading.Thread): A worker thread. def __init__(self, input, worktype): self._jobq = input self._work_type = worktype threading.Thread.__init__(self) def run(self): Get a job and process it. Stop when there's no more jobs while True: if self._jobq.qsize()0: job = self._jobq.get() worktype=self._work_type self._process_job(job,worktype) else: break def _process_job(self, job,worktype): Do useful work here. worktype: let this thread do different work 1,do list 2,do item 3,,, doJob(job) def doJob(job): do work function 1 time.sleep(random.random()*3) print doing ,job if __name__=='__main__': print begin... #put some work to q for i in range(NUM_WORKERS*2): q.put(i) #print total job q's size print job q'size,q.qsize() #start threads to work for x in range(NUM_WORKERS): MyThread(q,x).start() #if q is not empty, wait #while q.qsize()0: #time.sleep(0.1) -- http://mail.python.org/mailman/listinfo/python-list
Re: using range() in for loops
Steven D'Aprano wrote: On Wed, 05 Apr 2006 16:15:12 +0200, Georg Brandl wrote: [EMAIL PROTECTED] wrote: hi John, Python doesn't provide for loop like C / C++ but using Range() or Xrange() you can achive all the functionalities of the C for loop. Not quite. Care to explain what the differences are, or shall we guess? C's for is much more powerful. for(a; b; c) { d } translates to a while b d c which can't be replaced by a simple for i in range(...) Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: Mouse event - binding
Dear John, Thanks for your help. I don't know how to bind the ball only into a program. Would you mind help me on this? I added the changeColour function, here is a complete program. --- from Tkinter import * import string class Pong(Frame): def createWidgets(self): self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=LEFT, fill=BOTH) ## The playing field self.draw = Canvas(self, width=5i, height=5i) ## The speed control for the ball self.speed = Scale(self, orient=HORIZONTAL, label=ball speed, from_=-100, to=100) self.speed.pack(side=BOTTOM, fill=X) # The ball self.ball = self.draw.create_oval(0i, 0i, 0.10i, 0.10i, fill=red) self.theBall() self.x = 0.05 self.y = 0.05 self.velocity_x = 0.3 self.velocity_y = 0.5 self.draw.pack(side=LEFT) def changeColour(self, event): x = self.draw.canvasx(event.x) y = self.draw.canvasy(event.y) item = self.draw.find_closest(x,y) currentColour = self.draw.itemcget(item, 'fill') if currentColour == 'red': self.draw.itemconfigure(item, fill='blue') else: self.draw.itemconfigure(item, fill='red') def moveBall(self, *args): if (self.x 5.0) or (self.x 0.0): self.velocity_x = -1.0 * self.velocity_x if (self.y 5.0) or (self.y 0.0): self.velocity_y = -1.0 * self.velocity_y deltax = (self.velocity_x * self.speed.get() / 100.0) deltay = (self.velocity_y * self.speed.get() / 100.0) self.x = self.x + deltax self.y = self.y + deltay self.draw.move(self.ball, %ri % deltax, %ri % deltay) self.after(10, self.moveBall) def __init__(self, master=None): Frame.__init__(self, master) Pack.config(self) self.createWidgets() self.after(10, self.moveBall) game = Pong() game.mainloop() Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: RELEASED Python 2.5 (alpha 1)
That is cool and that will be a great addition to the libraries. Robert -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to have a for-loop index?
Sometimes C++ is the right tool/style for the job, but I don't need the speed or efficiency of C++. -- http://mail.python.org/mailman/listinfo/python-list
Re: Convertion of Unicode to ASCII NIGHTMARE
Fredrik Lundh [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] sounds like your understanding of Unicode and Python's Unicode system is a bit unclear. Err, no. Relaying unicode data between two disparate C APIs requires being careful and thorough. That means paying attention to when conversions happen, byte ordering (compile time) and boms (run time) and when the API documentation isn't thorough, verifying the behaviour yourself. That requires a very clear understanding of Unicode in order to do the requisite test cases, as well as reading what the code does. Roger -- http://mail.python.org/mailman/listinfo/python-list
Re: CD Burning
Nero has a commandline utility called NeroCMD.exe (not sure if you needed a free solution or not) Here's some sample code and write-up using NeroCMD.exe with Python: http://www.answermysearches.com/index.php/nerocmdexe-and-python-automating-the-burning-process/10/ -Greg On 5 Apr 2006 00:46:16 -0700, Tim Golden [EMAIL PROTECTED] wrote: Albert Leibbrandt wrote: Hi Can anybody tell me which windows API or python module they are using for writing cd's / dvd's with python? Other people have offered sound suggestions about using cdrecord etc. under Cygwin. Just to make the point, though, XP (and above, presumably) does have an inbuilt interface for burning CDs. I've never used it, and I don't know how feasible it would be to access it from Python. (Helpful, eh?) The interface is ICDBurn and it should be possible to wrap it with ctypes / ctypes.com but I haven't the time at the moment to try it out. (And I haven't a CD writer in this machine either!) Ultimately, it might still be easier to install Cygwin and use the cdrecord approach. I just wanted to make the point that there *was* an in-built mechanism. ICDBurn: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/ifaces/icdburn/icdburn.asp ctypes.com: http://starship.python.net/crew/theller/ctypes/com.html TJG -- http://mail.python.org/mailman/listinfo/python-list -- Gregory Piñero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Decompilers?
Thanks, guys! Sorry if my question confused anyone :/ I was hoping to find something better then decompyle, since I've had limited success with it.. -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: unix newbie questions
Another option is zsh, which is very much like bash, but better ;) -- http://mail.python.org/mailman/listinfo/python-list
Pydev and Pydev Extensions 1.0.5 release
Hi All, Pydev and Pydev Extensions 1.0.5 have been released Check http://www.fabioz.com/pydev for details on Pydev Extensions and http://pydev.sf.net for details on Pydev Release Highlights in Pydev Extensions: - - The pop-up does not pop as much for unlicensed versions Release Highlights in Pydev: -- - Another batch of things to improve indentation: * Indent does not try to make auto-indentation when pasting * When smart-indent is not selected, it will still add an indentation level after ':' * It will keep the indent of the previous line on new-lines if the current line is empty * Other little things - Added a place to specify vm arguments (for jython or python) -- thanks to Rudi de Andrade for this patch - Added a way to kill the underlying python/jython shells (Ctrl+2+kill) What is PyDev? --- PyDev is a plugin that enables users to use Eclipse for Python and Jython development -- making Eclipse a first class Python IDE -- It comes with many goodies such as code completion, syntax highlighting, syntax analysis, refactor, debug and many others. Cheers, -- Fabio Zadrozny -- Software Developer ESSS - Engineering Simulation and Scientific Software http://www.esss.com.br Pydev Extensions http://www.fabioz.com/pydev Pydev - Python Development Enviroment for Eclipse http://pydev.sf.net http://pydev.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
how to convert string
I want to print number 0 to 9 in one line like this 0 1 2 3 4 5 6 7 8 9 if I do like this, it prints in different lines for i in xrange(10): print i so i tried like this str = for i in xrange(10): str = i + print str but i want to know how convert int i to string. Every help is appreciate. -- http://mail.python.org/mailman/listinfo/python-list
Re: Registration Code
Steven D'Aprano wrote: What are the odds that Vista will have it? Ross Ridge wrote; About 100%. Steven D'Aprano wrote: Considering that you can hardly walk into a university, school or corporation without finding Windows or Office supplied without PA, would you care to revise that number? No. Windows Vista is certain have product activation, just like Windows XP does. The fact that volume licence users of Vista won't be required to use product activatation, just like volume licence users of XP, doesn't make it any less certain. Ross Ridge -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython and SuSE 10.0
Ben C wrote: On 2006-04-05, Steve [EMAIL PROTECTED] wrote: Hello, I was wondering if there is a wxPython RPM for SuSE 10.0 available. I Googled for it with no luck, but I'm hopeful that there is one out there. http://www.novell.com/products/linuxpackages/professional/python-wxgtk.html is the package you want I suppose, it's called python-wxGTK-2.6.1.0-4.i586.rpm. You get it with SUSE 10.0 pro but not in openSUSE. Don't know why not as it's GPL. So it exists, I can tell you that much... not sure where you can get it though. Googling the exact name throws up a few things. Ah here we are: http://www.vislab.uq.edu.au/research/accessgrid/software/suse/wxWindows/RPMS/python-wxGTK-2.6.1.0-4.i586.rpm Thanks Ben, I appreciate the information. Steve -- http://mail.python.org/mailman/listinfo/python-list
Re: how to convert string
[EMAIL PROTECTED] wrote: I want to print number 0 to 9 in one line like this 0 1 2 3 4 5 6 7 8 9 if I do like this, it prints in different lines for i in xrange(10): print i for i in xrange(10): print i, so i tried like this str = for i in xrange(10): str = i + print str but i want to know how convert int i to string. s = # Don't shadow the str builtin. for i in xrange(10): s += str(i) + print s -- http://mail.python.org/mailman/listinfo/python-list