Re: How I learned Tkinter
In message [EMAIL PROTECTED], peter [EMAIL PROTECTED] writes I've been trying to teach myself Tkinter programming over the last few months (in a strictly amateur way), and have made a number of requests for help in this newsgroup and elsewhere. I've now (sort of) got there - in that I have used Tkinter for some programs for personal use - and I've written up my experiences at http://www.aqzj33.dsl.pipex.com/how_i_learned_tkinter/contents.htm In general I found that while Frederik Lundh's tutorial is comprehensive and well written, there is little else around to help the newcomer working without the benefit of more experienced colleagues, and that in places the documentation is too sparse to be of much help. Any thoughts? Is my experience typical? Peter Recently I decided to use tkinter because it was included with Python and like you I suffered through a few weeks of puzzling out tkinter. I wish I'd read your notes before I started! Regards Ian -- Ian Parker -- http://mail.python.org/mailman/listinfo/python-list
Re: Generate a sequence of random numbers that sum up to 1?
fumanchu [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm surprised noone has pursued a course of subtraction rather than division. I believe someone did mention the subtraction method in one of the initial responses. But the problem is this. If you independently sample n numbers from a given distribution and then rescale, then the scaled numbers still all have the same distribution (and are uniform in that sense). In the subtraction method, each comes from a differnt distribution, as others explained, with the nth being radically different from the first. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
MinGW and Python
Is there any specific reason for not using MinGW to build the official distribution of Python for Win32? A quick Google search did not reveal the answer to my question. If a link is available, please post it. Best Regards, Srijit -- http://mail.python.org/mailman/listinfo/python-list
cmd module busy waiter ?
Hi all, Just wondering if the cmd module in python uses busy waiting for polling user command input as this is inefficient. Cheers -- http://mail.python.org/mailman/listinfo/python-list
Read and extract text from pdf
Hi, Thanks I use that and is all right :) import commands txt = commands.getoutput('ps2ascii tmp.pdf') print txt -- http://mail.python.org/mailman/listinfo/python-list
Re: MS VC++ Toolkit 2003, where?
Alex Martelli wrote: Can anybody suggest where to get a Framework SDK 1.1., or any other legal way to get the core msvcrt.lib for msvcr71.dll against which to link your extensions. This is critically important...??? From http://www.microsoft.com/downloads/details.aspx?familyid=9b3a2ca6-3647-4070-9f41-a333c6b9181ddisplaylang=en I'm sure my Windows-loving colleagues in the PSF (who got several free copies of VS 2003 from Microsoft, I believe -- at the time, I had zero Windows installations and zero interest in Windows, so I didn't sign up for one) have fully considered this recurring drama, and come to the decision of sticking with VS 2003 (avoiding any free-as-in-beer compilers such as VS 2005 or mingw) with thorough and wise deliberation. Not sure whether this mark was meant to be sarcastic: but why you don't want to use mingw to build extensions on Windows, I cannot understand. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: MS VC++ Toolkit 2003, where?
Alex Martelli wrote: As suggested to me by David Rushby 10 hours ago, http://www.microsoft.com/downloads/details.aspx?FamilyId=272BE09D-40BB-4 9FD-9CB0-4BFA122FA91Bdisplaylang=en does work. Can you please try this again: I'm also getting the error message that AIM is getting. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: MinGW and Python
Srijit Kumar Bhadra wrote: Is there any specific reason for not using MinGW to build the official distribution of Python for Win32? What could be the reasons to use MinGW? As for reasons not to do that: - there is no build process available to do that - people building extensions to Python must be able to do so with Microsoft C++, since some of these extensions are written using MFC. - developing Python itself in Visual Studio is quite convenient; in particular, the debugger works better than gdb. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: i18n hell
fyleow wrote: I just spent hours trying to figure out why even after I set my SQL table attributes to UTF-8 only garbage kept adding into the database. Apparently you need to execute SET NAMES 'utf8' before inserting into the tables. Does anyone have experience working with other languages using Django or Turbogears? I just need to be able to retrieve and enter text to the database from my page without it being mangled. I know these frameworks employ ORM so you don't need to write SQL and that worries me because I tried this on Rails and it wouldn't work. Frequently asked question to people who are burning in i18n hell: are you using unicode strings or byte strings? Unicode string means that type(your_string) is unicode, it does not mean you keep utf-8 encoded text in python byte strings. AFAIK Ruby has only byte strings that have the same set of issues/problems/traps as Python byte strings. -- http://mail.python.org/mailman/listinfo/python-list
Re: bug in modulus?
[EMAIL PROTECTED] wrote: But maybe I'm reading it wrong. In any case what I wanted was simply a way to extract the angle from a complex number where the angle is between 0 and 2*pi. I think I'll just take the modulus twice. def angle(complex): Returns angle where 2*pi angle =0 angle(1+1j) - atan(1) 1e-3 True angle(-1+1j) - (atan(-1) + 3*pi) % (2*pi) 1e-3 True angle(0+1j) == pi/2 True angle(0-1j) == 1.5*pi True angle(1+0j) == 0 True angle(0+0j) == 0 True angle(1-1e-100*1j) == 0 True if complex.real == 0: if complex.imag == 0: return 0 if complex.imag 0: return 1.5*pi return pi/2 theta = (atan2(complex.imag, complex.real) % (2*pi)) % (2*pi) assert 2*pi theta =0, (theta, complex) return theta from math import atan2, pi def cangle(z): ret = atan2(z.imag, z.real) if ret 0: ret += 2*pi return ret assert cangle(1+1j) * 180 / pi == 45.0 assert cangle(-1+1j) * 180 / pi == 135.0 assert cangle(-1-1j) * 180 / pi == 225.0 assert cangle(1-1j) * 180 / pi == 315.0 assert cangle(1+0j) * 180 / pi == 0.0 assert cangle(-1+0j) * 180 / pi == 180.0 assert cangle(1j) * 180 / pi == 90.0 assert cangle(-1j) * 180 / pi == 270.0 Gerard -- http://mail.python.org/mailman/listinfo/python-list
thread support help
I installed Python 2.4.2 windows installer from python.org, but when I compiled a python related project on mingw, I got a error message. error: python must be compiled with thread support Thank you for any help you can provide. -- http://mail.python.org/mailman/listinfo/python-list
Re: need a thread to keep a socket connection alive?
[EMAIL PROTECTED] wrote: i have a script that waits for message packets from a data server over a socket. If you're using TCP, bear in mind that you do not receive packets - you receive a stream of data, which may usually come in the same quantities as it was sent, but not always. If you don't take that into account, you may end up missing a valid message because it arrived in several parts. it works fine for a while, but the server requires that i send a heartbeat ping every 600 seconds or it will terminate the connection. It is probably worth just reconnecting if necessary. After all, you could be disconnected for other reasons too. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: what has python added to programming languages? (lets be esoteric, shall we ;)
Wildemar Wildenburger wrote: Over the time I've seen lots of remarks about python that read like a lot like lists in lisp or like the hashtable in java or any other form of like feature in language. Are there any concepts that python has not borrowed, Esoterically speaking, you should better distinguish between historic and individual time. Python's foo is like Java's foo speaks of the individual's exoteric order of experience with Python and Java, that may reverse esoteric historical chronology (and in fact, does so). -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing data attributes as method parameters
Panos Laganakos [EMAIL PROTECTED] (PL) wrote: PL Thanks Ben. PL What does it mean that they're statically bound? It means that the default values are evaluated at definition time. At that time there isn't a variable 'self' defined. It would only work if the defaults would be evaluated at the time the method is called, but that's not how Python works. PL It seems weird that I'm not able to access variables in the class PL namespace even though these attributes come into existance after class PL instantiation. What do you mean 'variables in the class namespace'? Which variable is in the class namespace? Please note that you can access variables in the class namespace: class MyClass: a = 10 b = 20 def my_method(self, param1=a, param2=b): print param1, param2 -- Piet van Oostrum [EMAIL PROTECTED] URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: getattr from local scope
[EMAIL PROTECTED] wrote: I know I can use eval, but I've always been told that if you're using eval, you're doing it wrong. Also not using eval limits the scope damage that can be caused by any errors in my application which could cause the database to be poisoned. a more robust approach is to explicitly add public entry points to a dictionary, and dispatch via that dictionary: a simple decorator can be handy for this purpose: registry = {} def public(func): registry[func.__name__] = func @public def func1(): print func1 @public def func2(): print func2 def func3(): print internal func3 registry[func1]() registry[func3]() # this will fail in pre-decorator versions of python, this can be implemented either by explicitly registering the entry points: def func2(): print func2 public(func2) or def func2(): print func2 registry[func2] = func2 or by using a prefix to make accidental publishing less likely: def public_func2(): print func2 globals()[public_ + funcname]() and/or by making all the callbacks methods of a class, and use getattr on an instance of that class. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: MySql -Python question
Dennis Lee Bieber wrote: On 23 Apr 2006 21:25:48 -0700, [EMAIL PROTECTED] declaimed the following in comp.lang.python: Hey all, I'm running a query within some python code, and I'm having difficulties doing something that seems to be really simple . I'm running a query in the following form: query01 = 'select max(DirectorID) +1 from Director;' cursor.execute(query01) table = cursor.fetchall() the resulting table , is a 1 row , 1 column table,showing 1 number and I just need that number inside that table,and save it for a different query, but I can't get it , can anybody tell me the best way to do this? thanks What does table[0]#first element of list table return to you? Or, since fetchall() might be assuming multiple rows even for a single row data set... table[0][0] #first element of first sublist of list table There is no method for work with data who are presented only in one column. This method would raise speed of work with such data as it is not necessary to make allocation one-item tuple object. Therefore I have a some expanded the module py-sqlplug_mysql (http://sourceforge.net/projects/py-sqlplg-mysql) where such API it is delivered through methods of the cursor: fetchcol0, fetchallcol0, fetchmanycol0. Now on a site of the project the documentation is inaccessible. The basic methods correspond to the specification described in PEP-249. P.S. The project while was tested only on FreeBSD and Linux though can work and on other platforms. P.P.S. For drawing up of the documentation the translator from Russian is required. -- http://mail.python.org/mailman/listinfo/python-list
Re: Can you create an instance of a subclass with an existing instance of the base class?
Lawrence D'Oliveiro wrote: (snip) I think you're taking Python's OO-ness too seriously. One of the strengths of Python is that it can _look_ like an OO language without actually being OO. According to which definition of OO ? -- 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: Looking for resources for making the jump from Java to Python easier and more productive
Lawrence D'Oliveiro wrote: In article [EMAIL PROTECTED], ToddLMorgan [EMAIL PROTECTED] wrote: I'm looking for the common types of mistakes that say a Java/C# or even C++ developer may commonly make. Using subclassing when you don't have to. For instance, you might have a Java method which takes an argument of type java.io.OutputStream to which it writes. You might translate this to a Python method to which you are careful to only pass instances of subclasses of file objects. But in fact there is no necessity for this: you are free to pass any object which has appropriate members. I suppose this is an instance of the more general rule: using OO when you don't have to. Lawrence, I'm afraid you're confusing OO with statically-typed class-based. FWIW, dynamic typing is part of OO since Smalltalk. -- 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: Missing interfaces in Python...
bruno at modulix wrote: Neal Becker wrote: (snip) I see various answers that Python doesn't need interfaces. OTOH, there are responses that some large Python apps have implemented them (e.g., zope). Does anyone have an explanation of why these large systems felt they needed to implement interfaces? This might help: http://dirtsimple.org/2004/12/python-interfaces-are-not-java.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
YOUR MESSAGE HAS BEEN BLOCKED
Message Delivery BLOCKED Reason: Virus found in message. Our Virus scanner found a virus in the message that you sent. Virus scanning report - 24 April 2006 @ 14:17 F-PROT ANTIVIRUS Program version: 4.3.2 Engine version: 3.14.7 VIRUS SIGNATURE FILES SIGN.DEF created 21 April 2006 SIGN2.DEF created 21 April 2006 MACRO.DEF created 21 April 2006 Search: /var/tmp/emailscan2388/attachment Action: Automatic deletion Files: Dumb scan of all files Switches: -ARCHIVE -PACKED -LIST /var/tmp/emailscan2388/attachment/1-MChVEs5 /var/tmp/emailscan2388/attachment/body.zip-body.scr Infection: W32/[EMAIL PROTECTED] Virus-infected files in archives cannot be deleted. Results of virus scanning: Files: 2 MBRs: 0 Boot sectors: 0 Objects scanned: 3 Infected: 1 Suspicious: 0 Disinfected: 0 Deleted: 0 Renamed: 0 Time: 0:00 -- http://mail.python.org/mailman/listinfo/python-list
Re: need a thread to keep a socket connection alive?
[EMAIL PROTECTED] wrote: hey there, i have a script that waits for message packets from a data server over a socket. it goes a little like this: while 1: x+=1 databack = sockobj.recv(158) if databack: print 'caught a message %s bytes ' % len(databack) if len(databack) 120: message = databack[3:-3] #strip stx and enx print '\n\n%s' % message else: break print 'end data ack' You need to go review how TCP works. All that it guarantees is that you will receive bytes in the same order they were sent. It says nothing about maintaining record boundaries. Just because you did a send(n) at one end, it doesn't mean that you can expect to read n bytes in a single recv() call at this end. Multiple send() calls could have their contents accumlated into a single recv() call, or a single send() could get broken up into several recv() calls. If you want to read fixed-length messages (as you appear to be trying to do with your recv(158)), you need to build a buffering layer which reads from the socket into a buffer and then doles out messages to a higher layer from that buffer. it works fine for a while, but the server requires that i send a heartbeat ping every 600 seconds or it will terminate the connection. so i also need something like while 1: sockobj.send(ping) ping_acknowlage = sockobj.recv(48) time.sleep(550) This needs to be burried in a lower layer as well. You want to build some kind of bufferedConnection class which hides all this gunk from your application. You probably will want sendMessage() and recvMessage() methods for your class. You probably want to have this class create a thread to handle the low-level I/O asyncronously, and put the heatbeat processing in there. This is not a trivial problem. By the time you're done with it, you will have learned a lot about how to communicate over a network. -- http://mail.python.org/mailman/listinfo/python-list
Re: need a thread to keep a socket connection alive?
Roy Smith wrote: If you want to read fixed-length messages (as you appear to be trying to do with your recv(158)), you need to build a buffering layer which reads from the socket into a buffer and then doles out messages to a higher layer from that buffer. This is not a trivial problem. By the time you're done with it, you will have learned a lot about how to communicate over a network. however, creating a buffered layer for reading is a trivial problem: just call makefile on the socket object, and use the resulting object as a file handle: s = socket.socket() s.connect((www.python.org, 80)) s.send(GET / HTTP/1.0\n\n) 16 f = s.makefile() f.readline() 'HTTP/1.1 200 OK\r\n' f.readline() 'Date: Mon, 24 Apr 2006 12:37:46 GMT\r\n' f.read(10) 'Server: Ap' f.read(10) 'ache/2.0.5' f.readline() '4 (Debian GNU/Linux) DAV/2 SVN/1.1.4 mod_python/3.1.3 ... f.readline() 'Last-Modified: Mon, 24 Apr 2006 04:52:53 GMT\r\n' etc. /F -- http://mail.python.org/mailman/listinfo/python-list
Subclass str: where is the problem?
Hello, can anybody explain/help me: Python 2.4.2 (#2, Sep 30 2005, 21:19:01) [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2 class Upper(str): def __new__(cls, value): return str.__new__(cls, value.upper()) u = Upper('test') u 'TEST' type(u) class '__main__.Upper' u = Upper('') u '' type(u) class '__main__.Upper' All seems to be ok... class MyObject(object): def __init__(self, dictionary = {}): self.id = dictionary.get('id', '') def __setattr__(self, attribute, value): value = type(value) is type('') and Upper(value) or value object.__setattr__(self, attribute, value) m = MyObject({'id': 'test'}) m.id 'TEST' type(m.id) class '__main__.Upper' m = MyObject() m.id '' type(m.id) type 'str' Why is m.id a str ? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
GRIB to images
Hi, I am interesseted on reading some GRIB files using python and then converting the fields to gif images. Does anyone know if this is possible or have a program that does this? /Sheldon -- http://mail.python.org/mailman/listinfo/python-list
Re: MS VC++ Toolkit 2003, where?
On Sun, 23 Apr 2006 21:15:23 -0700, Alex Martelli wrote: As suggested to me by David Rushby 10 hours ago, ... huge URL snipped ... Alas, somehow this URL was split in two, and all the kings horses and all the kings men can't seem to put it back together again (at least in my browser). Could someone post a tinyurl? And, as an aside...: [Those] not willing to shell out mucho $$$ to MS for a pro VS 2003) must go through such gyrations as these in order to be able to build Python extensions on Windows. I'm sure my Windows-loving colleagues in the PSF (who got several free copies of VS 2003 from Microsoft, I believe -- at the time, I had zero Windows installations and zero interest in Windows, so I didn't sign up for one) have fully considered this recurring drama, and come to the decision of sticking with VS 2003 (avoiding any free-as-in-beer compilers such as VS 2005 or mingw) with thorough and wise deliberation. Well, so long as there's a way to get the requisite tools. I'm sure these Windows-loving colleagues confirmed these free tools worked under WINE, else how would us cheap programmers with Windows-less boxes avoid sending $$$ to the Great Satan? Jim Wilson Gainesville, FL -- http://mail.python.org/mailman/listinfo/python-list
Re: need a thread to keep a socket connection alive?
Fredrik Lundh [EMAIL PROTECTED] wrote: however, creating a buffered layer for reading is a trivial problem: just call makefile on the socket object, and use the resulting object as a file handle: The problem with that is that makefile() requires the socket to be in blocking mode. If you're going to be implementing heartbeat, that's probably not what you want. -- http://mail.python.org/mailman/listinfo/python-list
Re: GRIB to images
Sheldon wrote: Hi, I am interesseted on reading some GRIB files using python and then converting the fields to gif images. Does anyone know if this is possible or have a program that does this? Yes of course with PIL. http://www.pythonware.com/products/pil/ http://effbot.org/imagingbook/format-grib.htm /Sheldon Michele -- http://mail.python.org/mailman/listinfo/python-list
Re: Subclass str: where is the problem?
[EMAIL PROTECTED] schrieb: Hello, can anybody explain/help me: Python 2.4.2 (#2, Sep 30 2005, 21:19:01) [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2 class Upper(str): def __new__(cls, value): return str.__new__(cls, value.upper()) u = Upper('test') u 'TEST' type(u) class '__main__.Upper' u = Upper('') u '' type(u) class '__main__.Upper' All seems to be ok... class MyObject(object): def __init__(self, dictionary = {}): self.id = dictionary.get('id', '') def __setattr__(self, attribute, value): value = type(value) is type('') and Upper(value) or value object.__setattr__(self, attribute, value) m = MyObject({'id': 'test'}) m.id 'TEST' type(m.id) class '__main__.Upper' m = MyObject() m.id '' type(m.id) type 'str' Why is m.id a str ? Because Upper(value) will be False in the line value = type(value) is type('') and Upper(value) or value and thus, you assign value itself to value again. rewrite it for exmaple in this way: def __setattr__(self, attribute, value): if type(value) is type('') : value = Upper(value) object.__setattr__(self, attribute, value) -- http://mail.python.org/mailman/listinfo/python-list
Re: Writing backwards compatible code - when?
Scott David Daniels a écrit : Bob Greschke wrote: Is there a list of all of the Python commands and modules that tell when (what version) they were added to Python? I was hoping the new Essential Reference would have it, but it doesn't. Here's a reference that stops at 2.3: http://rgruet.free.fr/PQR2.3.html Remove the 2.3, and you get the 2.4 :-) http://rgruet.free.fr/ A+ Laurent. -- http://mail.python.org/mailman/listinfo/python-list
Re: MinGW and Python
Is there any specific reason for not using MinGW to build the official distribution of Python for Win32? A quick Google search did not reveal the answer to my question. If a link is available, please post it. You may look at this thread: * E02 - Support for MinGW Open Source Compiler http://tinyurl.com/lxfsz There was a big polemic and it is really long, but there are some useful posts there. Regards, Josef -- http://mail.python.org/mailman/listinfo/python-list
Re: need a thread to keep a socket connection alive?
[EMAIL PROTECTED] wrote: hey there, i have a script that waits for message packets from a data server over a socket. it goes a little like this: while 1: x+=1 databack = sockobj.recv(158) if databack: print 'caught a message %s bytes ' % len(databack) if len(databack) 120: message = databack[3:-3] #strip stx and enx print '\n\n%s' % message else: break print 'end data ack' it works fine for a while, but the server requires that i send a heartbeat ping every 600 seconds or it will terminate the connection. so i also need something like while 1: sockobj.send(ping) ping_acknowlage = sockobj.recv(48) time.sleep(550) should i do this with threads? i dont want to interrupt the listening cycle to send a ping. appreciate any tips on how would be the best way to pull this off. sockobj.settimeout(550) before the loop and later in the loop: try: databack = sockobj.recv(158) except socket.timeout: ping_server(sockobj) continue Also, as other people pointed out, you'd better make buffered socket with .makefile() socket method. -- http://mail.python.org/mailman/listinfo/python-list
Re: what has python added to programming languages? (lets be esoteric, shall we ; )
Michael Tobis wrote: Although somewhat more elegant, Python slices follow Matlab's slice notation. In simpler cases they are identical. mt I think in Matlab, as in Fortran 90, i:j refers to the elements from i up to and including j, unlike Python, where j is excluded. Another language with slicing is S, implemented in S-Plus and R. It follows the same convention as Fortran. The languages treat negative subscripts of lists and arrays differently. In Fortran, since lower bounds of arrays can be negative, a negative subscript has no special meaning. In S, where arrays start with element 1, a negative subscript means that the absolute value of the subscript is excluded, so that if array x has three elements, x[-2] refers to (x[1],x[3]). In Python, negative indices wraparound. -- http://mail.python.org/mailman/listinfo/python-list
Update Demo/ and Tools/ directories
Hi! I'd like to help with updating the Demo/ and Tools/ directories as it is suggested in the Python Wiki http://wiki.python.org/moin/SimpleTodo. How exactly should the directories be updated? Should it just be made sure that the demos and examples are working or should they be updated to use the newest applicable Python features (e.g. the new any/all functions)? Dennis -- http://mail.python.org/mailman/listinfo/python-list
Python Evangelism
Python On WinXP: 7 Minutes To Hello World! Call it Python for the Complete XP Idiot if you must, but it's getting dugg on digg.com http://digg.com/programming rpd -- http://mail.python.org/mailman/listinfo/python-list
Re: how to append to a list twice?
Fredrik Lundh wrote: Alex Martelli wrote: But of course that only does it once, and I don't want to have to copy and paste the append line. Perhaps there's a better way than this. def makeseries(N): series = [N] append = series.append for tailer in xrange(N-1, -1, -1): append(tailer) append(tailer) But Now You've Violated The DRY Principle!!! Do you mean the three times -1 in the xrange arguments? :-) pepr -- http://mail.python.org/mailman/listinfo/python-list
Re: Subclass str: where is the problem?
This is good... try this: value = 'test' value 'test' type(value) type 'str' value = type(value) is type('') and Upper(value) or value value 'TEST' type(value) class '__main__.Upper' value = 1 value 1 type(value) type 'int' value = type(value) is type('') and Upper(value) or value value 1 type(value) type 'int' -- http://mail.python.org/mailman/listinfo/python-list
Re: what has python added to programming languages? (lets be esoteric, shall we ; )
Aahz wrote: In article [EMAIL PROTECTED], Carl Banks [EMAIL PROTECTED] wrote: Cameron Laird wrote: In article [EMAIL PROTECTED], Carl Banks [EMAIL PROTECTED] wrote: Wildemar Wildenburger wrote: Are there any concepts that python has not borrowed, concepts that were not even inspired by other languages? I'm just interested if it is merely a best-of collection of language features or if there are actually inventions that have not - or hardly - existed in programming before python? Nesting by indentation You *do* realize this was present in ABC, among others, right? Yes. I took the question to mean what has Python made a commercial success out of that wasn't popular before, which I guess was taking quite a bit of liberty with it. But he did give us the out of hardly. I think it would be fair to say nesting by indentation hardly existed before Python. Yup. I started following up to your post exactly as Cameron did before I realized the rejoinder you were almost certain to make. So I kept my mouth shut. ;-) That's a refreshing change ;-) Long time no see! regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: Can you create an instance of a subclass with an existing instance of the base class?
Lawrence D'Oliveiro wrote: All you want is a dictionary, then. That's basically what Python objects are. Yes, that's it exactly. I made a lazy wrapper for it, and I was really happy with what I was able to accomplish, it turned out to be very easy. Thanks, -Sandra -- http://mail.python.org/mailman/listinfo/python-list
error
Anyone know what this error means? C:/Python24/pythonw.exe -u C:/Python24/MyProjects/HeadsUp/cls_Bot.py File C:/Python24/MyProjects/HeadsUp/cls_Bot.py, line 10246 elif handname == 'straightflush': SystemError: com_backpatch: offset too large thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: proposed Python logo
Michael Tobis wrote: Is this the right room for an argument? http://geosci.uchicago.edu/~tobis/snake.png Is that a gun in its pocket, or is it just glad to see me? (with apologies to Mae West). regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: MySql -Python question
both of your suggestions don't work, that's kind of what I was trying the whole time -- http://mail.python.org/mailman/listinfo/python-list
Re: Subclass str: where is the problem?
[EMAIL PROTECTED] wrote: This is good... try this: value = 'test' value 'test' type(value) type 'str' value = type(value) is type('') and Upper(value) or value value 'TEST' type(value) class '__main__.Upper' Try again with value = This makes Upper(value) a False value in a boolean context: class Upper(str): ... pass ... Upper() '' type(Upper()) class '__main__.Upper' type(Upper() or ) type 'str' versus type(Upper(x) or x) class '__main__.Upper' Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: proposed Python logo
Michael Tobis wrote: Not that I'm disagreeing, but how to you rate resonance with the product? Hmm, I'm not a marketing professional, but this is would I would do with my focus groups: Ask people familar with the product to name what they like about the image, and what they like about the product, and look for analogies between them. Ask them what they dislike about the image and the product, and minimize overlap. (The main thing I dislike about Python is that the documentation is too sketchy. It's very unclear what the official logo represents. So another strike against it; it reminds me of the confusion I often face on making use of an unfamiliar module.) As opposed to, for example, Apache's feater, which immediately says ... er, er, ... ? Anyway, none of this is intended to discourage you, I think it's good that people are still interested in improving Python's image (as am I: see http://squidoo.com/pythonology). regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: error
[EMAIL PROTECTED] wrote: Anyone know what this error means? C:/Python24/pythonw.exe -u C:/Python24/MyProjects/HeadsUp/cls_Bot.py File C:/Python24/MyProjects/HeadsUp/cls_Bot.py, line 10246 elif handname == 'straightflush': SystemError: com_backpatch: offset too large Google dead today? http://mail.python.org/pipermail/python-list/2004-November/249799.html Given the linenumber is over 1, I presume that is your problem. I guess you'd have to read upon modules... :) Diez -- http://mail.python.org/mailman/listinfo/python-list
freebsd thread problem
Hi there, I have installed python(2.4.3) trac(0.9.4) on freebsd(4.8) from the ports collection and I seem to have an underlying problem with the thread module. Pysqlite is calling 'import thread' which is failing with no such module and causing it not to load. I thought that 'thread' was one of the core sys.modules and when I install python via ports I can see in the makefile that threading is turned on. Salling 'import thread' from the python prompt yields the same result. I have a 'threading.py' and a 'dummy_thread.py' in my /usr/local/lib/python2.4 folder and I only have one version of python installed. Can anyone help me with this? I've googled it and can't find any mention of a similar problem anywhere else. I've also been through the trac mailing-list, but it doesn't seem like a trac-specific problem. All/any help greatly appreciated dorian -- http://mail.python.org/mailman/listinfo/python-list
Re: proposed Python logo
Michael Tobis wrote: A more Monty sort of Python logo would be fine with me. A flying sheep perhaps? An exploding penguin? A giant hedgehog? A dog license with the word dog crossed out and cat written in crayon? A great big book on how to put your budgie down? This http://www.informatik.uni-trier.de/~roth/bilder/mpfc/GUMBY3.JPG chap? I'm not sure that conveys the intended gravitas to the corporate community, though. mt How about a big P with the serif at the bottom being the foot that stamps on things? regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: Subclass str: where is the problem?
Effectively. Thanks a lot Peter and Harold. -- http://mail.python.org/mailman/listinfo/python-list
Re: Subclass str: where is the problem?
Hi Pascal, Indeed, the example you show work corrctly. But in the code you posted before, you wonder about the behavior of these lines: m = MyObject() m.id '' type(m.id) type 'str' So what happens when you provide the empty string '' to your and-or construct? value = '' value = type(value) is type('') and Upper(value) or value As you can easily check, bool('') resolves to False. Thus, your line becomes: value = False and False or value Python first evaluates the and expression, which resolves to False. The or expression evaluates the second argument and returns that one as the result if and only if the first one evaluates to False, which is the case here. So the result of False or value is value. You can check that value is (False or value) True so, in you code, the empty string gets indeed assign as value again. Be carefull with the condition/and/or chain! You must be 110% sure, that the desired return value in case of condition==True can never evaluate to False! - harold - -- http://mail.python.org/mailman/listinfo/python-list
Re: need a thread to keep a socket connection alive?
Serge Orlov [EMAIL PROTECTED] wrote: sockobj.settimeout(550) [...] Also, as other people pointed out, you'd better make buffered socket with .makefile() socket method. If I understand the docs for the socket module correctly, these two suggestions are mutually incompatable. -- http://mail.python.org/mailman/listinfo/python-list
Twisted/wxPython Problem...
Hi, I am relatively new to Python, and am learning it as part of a university module... Im currently undertaking a project to create an IM server and IM gui client. I have a very basic server, and a basic gui client. I can get my client to connect to my server, but cant get it to disconnect or send messages to the server. I am getting the following error when I click on the 'Disconnect' button - AttributeError: 'NoneType' object has no attribute 'loseConnection' I have attached the code for both the server and the client below this. I am using the Twisted and wxPython packages, and as previously stated am fairly new to Python so would appreciate any help anyone can offer. Thanks, Peter server.py from twisted.internet import reactor from twisted.internet.protocol import Factory from twisted.protocols.basic import LineReceiver factory = Factory() #this is a list factory.transports = [] #this is a dictionary userNicknames = {} class SimpleLogger(LineReceiver): def connectionMade(self): self.factory.transports.append(self.transport) userNicknames[self.transport.client] = '' #write to the client self.transport.write(Welcome to Chris Pete's chat server!\r\n) self.transport.write(Please enter your nickname:\r\n) #prints on the server screen print 'got connection from', self.transport.client def connectionLost(self, reason): who = str(userNicknames.get(self.transport.client)) + ' Disconnected' + '\r\n' print who userNicknames[self.transport.client] = '' for transport in self.factory.transports: transport.write(who) def lineReceived(self, line): #if the users nickname in the dictionary (userNicknames) is blank, create a #value in the dictionary with the line just received. #if the user already has a nickname then it must be a message they are writing. #So instead print out the message if userNicknames.get(self.transport.client) == '': #if the username is already in the dictionary someone is #already using it so ask for another one. if line in userNicknames.values(): self.transport.write('That nickname is already in use, please use another:') else: userNicknames[self.transport.client] = line #print userNicknames.items() message = userNicknames.get(self.transport.client) + ' has joined\r\n' for transport in self.factory.transports: transport.write(message) else: message = userNicknames.get(self.transport.client) + ': ' + line + '\r\n' for transport in self.factory.transports: transport.write(message) factory.protocol = SimpleLogger reactor.listenTCP(1234, factory) reactor.run() client.py -- from wxPython.wx import * import wx from twisted.internet import wxreactor wxreactor.install() from twisted.internet import reactor from twisted.internet.protocol import Protocol, ClientCreator class imApp(wxApp, Protocol): def buildMe(self): frame = wx.Frame(None, title=IM Client, size=(800, 550)) bkg = wx.Panel(frame) global ipAdd global portNo global messages global newMsg ipAddLab = wx.StaticText(bkg, -1, 'IP Address: ') ipAdd = wx.TextCtrl(bkg) ipAdd.SetToolTipString('Please enter the server IP address here.') spacer1 = wx.StaticText(bkg, -1, ' ') portNoLab = wx.StaticText(bkg, -1, 'Port No: ') portNo = wx.TextCtrl(bkg) portNo.SetToolTipString('Please enter the port number the server is using here.') spacer2 = wx.StaticText(bkg, -1, ' ') connectButton = wx.Button(bkg, label='Connect') connectButton.SetToolTipString('Click this button to connect to the server.') connectButton.Bind(wx.EVT_BUTTON, self.connectMe) disconnectButton = wx.Button(bkg, label='Disconnect') disconnectButton.SetToolTipString('Click this button to disconnect from the server.') disconnectButton.Bind(wx.EVT_BUTTON, self.disconnectMe) messages = wx.TextCtrl(bkg, style=(wx.TE_MULTILINE | wx.HSCROLL)) newMsg = wx.TextCtrl(bkg) sendButton = wx.Button(bkg, label='Send') sendButton.SetToolTipString('Click this button to send a message to the server.') sendButton.Bind(wx.EVT_BUTTON, self.sendMe) hbox1 = wx.BoxSizer() hbox1.Add(ipAddLab, proportion=0, flag=wx.EXPAND) hbox1.Add(ipAdd, proportion=0, flag=wx.EXPAND) hbox1.Add(spacer1, proportion=0, flag=wx.EXPAND) hbox1.Add(portNoLab, proportion=0, flag=wx.EXPAND) hbox1.Add(portNo, proportion=0, flag=wx.EXPAND) hbox1.Add(spacer2, proportion=0, flag=wx.EXPAND) hbox1.Add(connectButton, proportion=0, flag=wx.LEFT, border=5)
Re: MySql -Python question
[EMAIL PROTECTED] wrote: both of your suggestions don't work, that's kind of what I was trying the whole time I am sure you have read this before somewhere, but - 1. Tell us what you have tried so far 2. Tell us what you expected (or hoped) would happen 3. Tell us what actually happened, including any traceback Then there is a possibility that someone might be able to help you. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list
Re: How I learned Tkinter
peter wrote: I've been trying to teach myself Tkinter programming over the last few months (in a strictly amateur way), and have made a number of requests for help in this newsgroup and elsewhere. I've now (sort of) got there - in that I have used Tkinter for some programs for personal use - and I've written up my experiences at http://www.aqzj33.dsl.pipex.com/how_i_learned_tkinter/contents.htm In general I found that while Frederik Lundh's tutorial is comprehensive and well written, there is little else around to help the newcomer working without the benefit of more experienced colleagues, and that in places the documentation is too sparse to be of much help. Any thoughts? Is my experience typical? Peter Programming Python by Mark Lutz has several chapters on Tkinter (O'Reilly). Thanks for your notes as I am still behind you. Ken D. -- http://mail.python.org/mailman/listinfo/python-list
Re: Twisted/wxPython Problem...
PeterG wrote: Hi, I am relatively new to Python, and am learning it as part of a university module... Im currently undertaking a project to create an IM server and IM gui client. I have a very basic server, and a basic gui client. I can get my client to connect to my server, but cant get it to disconnect or send messages to the server. I am getting the following error when I click on the 'Disconnect' button - AttributeError: 'NoneType' object has no attribute 'loseConnection' It seems that your client inherits from two classes, but doesn't invoke their respective constructors. That makes python only call the first classes constructor, as this simple experiment shows: class A(object): def __init__(self): print I'm A class B(object): def __init__(self): print I'm B class C(A,B): pass C() - I'm A so - create a constructor, invoke both constructors of your super-classes either explicitly or using super (make sure you understand super!) Regards, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: debugging in emacs
Gary Wessle wrote: Gary Wessle [EMAIL PROTECTED] writes: Hi python users I am using emacs and python-mode.el under dabian testing. is there a way to debug python code where I can step over each line and watch the value of all the variables and be able to change any during debugging. say you have a loop structure and want to see what the values of your variables are during debugging when your code is running as you step line by line. thanks what is the most used the older python-mode.el or the newer python.el? I am using eamcs 21.4.1 under dabian testing. I use python-mode.el v. 4.63 with Emacs 21.3 (I haven't made the switch to 21.4 yet). When I'm running an interactive *Python* buffer inside of Emacs and get a stack trace, I then use pdb.pm() and I get the familiar GDB-in-Emacs style interface. Good luck. -- Steve Juranich Tucson, AZ USA -- http://mail.python.org/mailman/listinfo/python-list
Re: MS VC++ Toolkit 2003, where?
JW [EMAIL PROTECTED] wrote: ... As suggested to me by David Rushby 10 hours ago, ... huge URL snipped ... Alas, somehow this URL was split in two, and all the kings horses and all the kings men can't seem to put it back together again (at least in my browser). Could someone post a tinyurl? http://tinyurl.com/gv8wr Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: MS VC++ Toolkit 2003, where?
Martin v. Löwis [EMAIL PROTECTED] wrote: Alex Martelli wrote: Can anybody suggest where to get a Framework SDK 1.1., or any other legal way to get the core msvcrt.lib for msvcr71.dll against which to link your extensions. This is critically important...??? From http://www.microsoft.com/downloads/details.aspx?familyid=9b3a2ca6-3647- 4070-9f41-a333c6b9181ddisplaylang=en Thanks! For the convenience of tinyurl-preferrers: http://tinyurl.com/5flob I'm sure my Windows-loving colleagues in the PSF (who got several free copies of VS 2003 from Microsoft, I believe -- at the time, I had zero Windows installations and zero interest in Windows, so I didn't sign up for one) have fully considered this recurring drama, and come to the decision of sticking with VS 2003 (avoiding any free-as-in-beer compilers such as VS 2005 or mingw) with thorough and wise deliberation. Not sure whether this mark was meant to be sarcastic: but why you don't want to use mingw to build extensions on Windows, I cannot understand. Jocular, but not sarcastic. I have no problems using mingw if that's what it takes -- the later instructions I saw were those suggesting the Toolkit instead, so those are the ones I'm trying to follow. What's the updated URL for the instructions about using mingw instead? Thanks, Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: MS VC++ Toolkit 2003, where?
Martin v. Löwis [EMAIL PROTECTED] wrote: Alex Martelli wrote: As suggested to me by David Rushby 10 hours ago, http://www.microsoft.com/downloads/details.aspx?FamilyId=272BE09D-40BB-4 9FD-9CB0-4BFA122FA91Bdisplaylang=en does work. Can you please try this again: I'm also getting the error message that AIM is getting. Try tinyurl http://tinyurl.com/gv8wr please. I've also tinyurl'd your URL for the 1.1 SDK, to http://tinyurl.com/5flob . ((I suspect the problem has to do with a limitation of 80 characters/line in NNTP messages, which my favorite newsreader enforces unconditionally)). Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: MS VC++ Toolkit 2003, where?
Robert Kern [EMAIL PROTECTED] wrote: Edward Elliott wrote: I think Apple switched to the Intel compiler for x86 macs, was python built with that or with gcc? I'm pretty sure MacTel OS X still uses gcc 4 (although I think there is a beta version of the Intel compiler available). All of the Python builds floating around for it certainly use gcc. Apple's XCode still uses gcc. The intel compilers are out of beta, and cost many hundreds of dollars per developer, besides NOT supporting ObjectiveC, while XCode is still free (as in beer for the GUI parts etc, as in speech for the underlying commandline tools, though I'm not quite sure where I'd start looking for the latters' sources if I wanted them;-). Edward's request on this thread is eminently reasonable, but I don't really have time to get and post all the detailed results of pybench right now - I'll try to get to it this evening. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: need a thread to keep a socket connection alive?
Roy Smith wrote: Serge Orlov [EMAIL PROTECTED] wrote: sockobj.settimeout(550) [...] Also, as other people pointed out, you'd better make buffered socket with .makefile() socket method. If I understand the docs for the socket module correctly, these two suggestions are mutually incompatable. Perhaps this restriction was lifted? s = socket.socket() s.settimeout(15) s.connect((www.python.org, 80)) f = s.makefile() f.readline() Traceback (most recent call last): File pyshell#21, line 1, in -toplevel- f.readline() File C:\Python24\lib\socket.py, line 340, in readline data = self._sock.recv(self._rbufsize) timeout: timed out -- http://mail.python.org/mailman/listinfo/python-list
Python C API question
Hi, I'm a newbie in python extension development, and I'd like to ask you a simple question. I have to implement a simple estension that parses a source file and returns an xml.dom.minidom.Document instance. I'd like to know how can I import and then manage xml.dom.minidom.* objects using Python C API. thanks, Gabriele -- http://mail.python.org/mailman/listinfo/python-list
Re: freebsd thread problem
Dorian Mcfarland wrote: Hi there, I have installed python(2.4.3) trac(0.9.4) on freebsd(4.8) from the ports collection and I seem to have an underlying problem with the thread module. Salling 'import thread' from the python prompt yields the same result. I have a 'threading.py' and a 'dummy_thread.py' in my /usr/local/lib/python2.4 folder and I only have one version of python installed. How did you install python? By default, if built from ports, it should pop up a configuration dialog in which one of the options is to enable thread support. If you have a bad configuration record, you can do a make config in /usr/ports/lang/python to re-create it. (if there's no such option, then maybe using threads with python is disabled in 4.x) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python C API question
Gabriele *darkbard* Farina wrote: Hi, I'm a newbie in python extension development, and I'd like to ask you a simple question. I have to implement a simple estension that parses a source file and returns an xml.dom.minidom.Document instance. I'd like to know how can I import and then manage xml.dom.minidom.* objects using Python C API. thanks, Gabriele Have you looked at the PyImport_* functions? -- Steve Juranich Tucson, AZ USA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python C API question
It seems to be what I need. Thank you! -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple DAV server?
Ivan Voras wrote: robert wrote: maybe thats a good idea to put it on sf.net to boil out all bugs. Yet I like it in that simple default manner, maybe switch on those additional creation functions with commandline switches (or config class instance passed to run..(config=None) ) I'm thinking of making a small separation between the actual WebDAV server (server.py) and the library/libraries that do the actual protocol (davserver.py fsdav.py). This way, we can still have a simple server (server.py), libraries with new features, and possibly an advanced server (possibly called server_advanced.py or something like that) that can use all those new features. I'll submit a project request, and will post here when it's processed, so stay tuned :) Hello, what is the current status of Pandav? KL wrote, he added some more capabs. I'd need MOVE and saw PUT has bugs to also not respect URL-quoted folders/elements (with spaces, utf-8 etc.) Wanted to ask to not double things? -robert -- http://mail.python.org/mailman/listinfo/python-list
Dr. Dobb's Python-URL! - weekly Python news and links (Apr 24)
QOTW: Going from Python to Java (as it's in my case) is real pain I wish nobody to feel... Even with multi-million support for Java from giants like Sun, IBM or Oracle, I find it much easier to gain full control over my project when using Python than Java. - Jarek Zgoda while 1: life.side.bright.look() - Robin Becker When debugging your code, would you have to dedent the block inside a for loop to run it just once? Of course not: http://groups.google.com/group/comp.lang.python/msg/256b4b45ba784910 You can query the Python package index or Cheese Shop through XML-RPC. http://groups.google.com/group/comp.lang.python/msg/261807863aa38fd7?hl=en; http://www.inkdroid.org/journal/2005/08/11/pypi-over-xmlrpc/ http://wiki.python.org/moin/PyPiXmlRpc Peter Mosley gives a thorough report of how he learned Tkinter. http://www.aqzj33.dsl.pipex.com/how_i_learned_tkinter/contents.htm Python seeks mentors and students for Google's Summer of Code. http://www.artima.com/weblogs/viewpost.jsp?thread=156971 Guido van Rossum gives a brief overview of his plans concerning Python 3000. http://www.python.org/doc/essays/ppt/accu2006/Py3kACCU.ppt Irmen de Jong's wiki is one of the resources that turn up in Todd L. Morgan's hunt for information to ease the transition from Java to Python. http://groups.google.com/group/comp.lang.python/browse_frm/thread/d49659bd73482967/b37f2c287858?tvc=1 http://www.razorvine.net/python/PythonComparedToJava Michael P. Soulier proposes a sly shell one-liner: python -c 'help(time.sleep)' John J. Lee has a few tricks up his sleeve to make dealing with cookies easier. http://groups.google.com/group/comp.lang.python/msg/4a1dea64710643a5 Many PyCon 2006 presentations are now available online, announces conference chair Andrew Kuchling. http://pyfound.blogspot.com/2006/04/pycon-2006-presentations-online.html 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 Python411 indexes podcasts ... to help people learn Python ... Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous tradition early borne by Andrew Kuchling, Michael Hudson and Brett Cannon of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems.
ANN: PyScript 0.6.0 released
Overview: PyScript is a python module for producing high quality postscript graphics. Rather than use a GUI to draw a picture, the picture is programmed using python and the PyScript objects. Some of the key features are: * All scripting is done in python, which is a high level, easy to learn, well developed scripting language. * All the objects can be translated, scaled, rotated, ... in fact any affine transformation. * Plain text is automatically kerned. * You can place arbitrary LaTeX expressions on your figures. * You can create your own figure objects, and develop a library of figure primitives. * Output is publication quality. License: Released under the GPL Changes: The major change in this release is a complete rewrite of the Talk and Poster classes of the presentation library. There have also been many bug fixes and minor other improvements. For details see the PyScript web page: a href=http://pyscript.sourceforge.net;pyscript.sourceforge.net/a. Getting the software: One can download the latest version (0.6) from: a href=http://pyscript.sourceforge.net;PyScript/a Requirements: * Python 2.2 and above * An up-to-date LaTeX distribution Authors: * Alexei Gilchrist [EMAIL PROTECTED] * Paul Cochrane [EMAIL PROTECTED] If you use this software, have any suggestions, or bug reports, please let us know! -- [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: i18n hell
On 24 Apr 2006 00:38:42 -0700, Serge Orlov [EMAIL PROTECTED] wrote: fyleow wrote: I just spent hours trying to figure out why even after I set my SQL table attributes to UTF-8 only garbage kept adding into the database. Apparently you need to execute SET NAMES 'utf8' before inserting into the tables. Does anyone have experience working with other languages using Django or Turbogears? I just need to be able to retrieve and enter text to the database from my page without it being mangled. I know these frameworks employ ORM so you don't need to write SQL and that worries me because I tried this on Rails and it wouldn't work. Frequently asked question to people who are burning in i18n hell: are you using unicode strings or byte strings? Unicode string means that type(your_string) is unicode, it does not mean you keep utf-8 encoded text in python byte strings. I used to live i18n hell, a while ago, until I understood this: everytime you keep a reference to some kind of string object, ALWAYS ALWAYS ALWAYS be AWARE of whether it is not encoded (a unicode object) or an encoding string (a str object), and if so, which encoding it is in. Then deal with the conversion between the two domains EXPLICITLY (e.g. encode(), decode()). If you hold onto a str or unicode object and you don't know which it is, you are inevitably bound to face unicode hell at some point. You can use a prefix convention if that makes it easier for you, but the point is that you CANNOT just wing it. Python makes it too easy to just wing it and that creates a lot of surprises, especially since some methods hide the conversions, e.g. str.join. w.r.t. to DB storage, that depends on the specific database you're using and the DBAPI module you're using, read up on it, write a few tests on your corresponding DBAPI (simple tests, easy peasy), know what kinds of strings you're sending in and reading back. I'm using PostgreSQL often and my configuration always stores strings in UTF-8 in the database. I have a lightweight mapping module that disambiguiates and does the encoding/decoding automatically in a consistent way (that decision belongs in the client code for now, unfortunately, but is centralized using my table declaration that lists the desired conversions for each column). See http://furius.ca/antiorm/ for something simple that works well. cheers, -- Martin Furius Python Training -- http://furius.ca/training/ -- http://mail.python.org/mailman/listinfo/python-list
Re: MS VC++ Toolkit 2003, where?
Alex Martelli wrote: Jocular, but not sarcastic. I have no problems using mingw if that's what it takes -- the later instructions I saw were those suggesting the Toolkit instead, so those are the ones I'm trying to follow. What's the updated URL for the instructions about using mingw instead? Install mingw (an large task in and of itself that I'm not going to go into here, but look at http://www.mingw.org/) and make sure the bin/ directory is on your PATH. You will have to edit the gcc specs file to replace -lmsvcrt with -lmsvcr71. Its filename is lib/mingw32/3.4.2/specs . After that, use the --compiler=mingw32 option on build_ext when using distutils. -- Robert Kern [EMAIL PROTECTED] I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: error
thanks for the heads up. I read other posts on this error, but it's unclear to me whether the following will be a problem as well. Suppose I break up my very long module into smaller modules and import them into another module 'main'. Will I get the same error running main if the total number of lines in the smaller modules is 10k? thanks. -- http://mail.python.org/mailman/listinfo/python-list
Packing a list of lists with struct.pack()
Hello, I have a list that includes lists of integers, in the form of: li = [[0, 1, 2], [3, 4, 5], ...] packed = struct.pack(str(len(li)*3)+'i', li) The frmt part is right, as I'm multiplying by 3, 'cause each inner list has 3 elements. What can I do to get li as a single list of integers? I tried list comprehension in the form of: [([j for j in i]) for i in li] But that doesn't seem to work, any ideas? -- http://mail.python.org/mailman/listinfo/python-list
Re: MS VC++ Toolkit 2003, where?
Alex Martelli wrote: Jocular, but not sarcastic. I have no problems using mingw if that's what it takes -- the later instructions I saw were those suggesting the Toolkit instead, so those are the ones I'm trying to follow. What's the updated URL for the instructions about using mingw instead? Oh, that's right, you need an import library for Python24.dll . If you build numpy first, it will automatically build the import library for you. The implementation is fairly simple if you would rather bodge a script together. The driver is the function build_import_library() here: http://svn.scipy.org/svn/numpy/trunk/numpy/distutils/mingw32ccompiler.py This uses the following module: http://svn.scipy.org/svn/numpy/trunk/numpy/distutils/lib2def.py -- Robert Kern [EMAIL PROTECTED] I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: Packing a list of lists with struct.pack()
Just came up with this: litemp = [] [litemp.extend(i) for i in li] Seems to give me a list with all the inner elements of li, not sure if struct.pack will accept it now, but I'll give it a try. -- http://mail.python.org/mailman/listinfo/python-list
Re: MinGW and Python
Martin v. Löwis wrote: Srijit Kumar Bhadra wrote: Is there any specific reason for not using MinGW to build the official distribution of Python for Win32? What could be the reasons to use MinGW? As for reasons not to do that: - there is no build process available to do that - people building extensions to Python must be able to do so with Microsoft C++, since some of these extensions are written using MFC. - developing Python itself in Visual Studio is quite convenient; in particular, the debugger works better than gdb. - gcc does not optimize particularly well. -- Robert Kern [EMAIL PROTECTED] I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: error
[EMAIL PROTECTED] wrote: thanks for the heads up. I read other posts on this error, but it's unclear to me whether the following will be a problem as well. Suppose I break up my very long module into smaller modules and import them into another module 'main'. Will I get the same error running main if the total number of lines in the smaller modules is 10k? No. There exist quite a few projects out there with several 10K lines of code. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for resources for making the jump from Java to Python easier and more productive
Ant wrote: Take a look at the newgroup archives over the last week or two - there seem to have been a glut of people coming from Java to Python and asking the same sort of questions. There were some links to a bunch of Python 'gotcha' pages which will be useful. Here's a few gotchas which i would like to drop into the python wiki, but I couldn't find an appropriate place. Maybe the Intermediate Conundrums page? Anyway, if OP take the time to flip through these, it'll speed the learning, I hope. http://www.ferg.org/projects/python_gotchas.html http://zephyrfalcon.org/labs/python_pitfalls.html http://zephyrfalcon.org/labs/beginners_mistakes.html http://www.python.org/doc/faq/ http://wiki.python.org/moin/Intermediate_Conundrums http://diveintopython.org/appendix/abstracts.html http://diveintopython.org/appendix/tips.html http://blog.ianbicking.org/my-python-4k.html http://www.onlamp.com/pub/a/python/2004/02/05/learn_python.html http://www.norvig.com/python-iaq.html http://www.faqts.com/knowledge_base/index.phtml/fid/245 http://amk.ca/python/writing/warts http://c2.com/cgi/wiki?PythonProblems -- http://mail.python.org/mailman/listinfo/python-list
Re: Packing a list of lists with struct.pack()
Panos Laganakos wrote: I have a list that includes lists of integers, in the form of: li = [[0, 1, 2], [3, 4, 5], ...] What can I do to get li as a single list of integers? I tried list comprehension in the form of: [([j for j in i]) for i in li] But that doesn't seem to work, any ideas? you have it backwards: a nested list expression is like a nested for loop, but with the innermost expression at the beginning. a for-loop would look like: for i in li: for j in i: ... do something with j ... so the corresponding comprehension is [j for i in li for j in i] which gives you the expected result. when you pass this to pack, you can use a generator expression instead: data = struct.pack(%di % (len(li)*3), *(j for i in li for j in i)) /F -- http://mail.python.org/mailman/listinfo/python-list
Pydev and Pydev Extensions 1.0.6 release
Hi All, Pydev and Pydev Extensions 1.0.6 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: - - New Feature: Show hierarchy (F4) -- Still in a beta state (currently only looks for subclasses on the same project). - Analysis happens in a Thread, so, you should now always have the latest parse without any halts (this happened only when the option was set to analyze only on save). - Class variable marked as error when self ommitted - when an undefined import is found within a try..except ImportError, it will not be reported. - Allow changing the keybinding for activating the Interactive Console (Ctrl+Enter) - Added a simple text-search that looks for in all .py and .pyw files (will be improved in the future to make a real python-like search). - The keywords that match the 'simple' keywords completion do not show up. Release Highlights in Pydev: -- - Assign variables to attributes (Ctrl+2+a): Contributed by Joel Hedlund (this is the first contribution using the new jython scripting engine). - 3 minor 'quirks' were fixed in the indentation engine - The debugger had some changes (so, if you had halts with it, please try it again). - Allow changing the keybinding for activating the Find next problem (Ctrl+.) - The debugger step-return had its behaviour changed. - Additional scripts location added to pythonpath in the jython scripting engine - Transversal of nested references improved - Fixed problems with compiled modules when they had 'nested' module structures (e.g.: wx.glcanvas) 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
threads and sys.exit()
calling sys.exit() from a thread does nothing... the thread dies, but the interpreter remains. i guess the interpreter just catches and ignore the SystemExit exception... does anybody know of a way to overcome this limitation? -tomer -- http://mail.python.org/mailman/listinfo/python-list
Re: error
Will I get the same error running main if the total number of lines in the smaller modules is 10k? Not sure if this would solve your problem, but I noticed the 10K filesize. I don't know about other programmers, but I find it much easier to keep track of stuff if I keep the individual file sizes less than 10K in size. Another thought would be to create a module with several submodules of grouped functionality (similar to the xml module where submodules dom/parsers/sax are) - this way it's easier to keep track of the differences/problems. -- http://mail.python.org/mailman/listinfo/python-list
Re: threads and sys.exit()
gangesmaster wrote: calling sys.exit() from a thread does nothing... the thread dies, but the interpreter remains. i guess the interpreter just catches and ignore the SystemExit exception... does anybody know of a way to overcome this limitation? Use Thread.setDaemon(True) on your threads. diez -- http://mail.python.org/mailman/listinfo/python-list
Re: error
thanks for the help. cheers. -- http://mail.python.org/mailman/listinfo/python-list
Re: freebsd thread problem
That was the problem. thanks for the clarity - finally working. How did you install python? By default, if built from ports, it should pop up a configuration dialog in which one of the options is to enable thread support. If you have a bad configuration record, you can do a make config in /usr/ports/lang/python to re-create it. (if there's no such option, then maybe using threads with python is disabled in 4.x) -- http://mail.python.org/mailman/listinfo/python-list
Re: threads and sys.exit()
import threading t=threading.Thread(target=sys.exit) t.setDaemon(True) t.start() ? -- http://mail.python.org/mailman/listinfo/python-list
Re: threads and sys.exit()
(i forgot to say it didn't work) -- http://mail.python.org/mailman/listinfo/python-list
Re: threads and sys.exit()
gangesmaster: (i forgot to say it didn't work) It's the remaining threads that need to be daemon, when some thread performs sys.exit. When no non-daemon thread remains, the application terminates. -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list
Re: need a thread to keep a socket connection alive?
ok, thanks for all the suggestions, gents, i clearly have more to read on this. i have discovered that the server will send a request for the heartbeat ping if its almost timed out, so i use the length of the message to determine what to do with it. msg = sockobj.recv(1024) if len(msg) == 158: record the data elif len(msg) == (34): # length of request for ping ping the server else: yada yada. each real message ( according to their docs ) should be exactly 158 bytes. i know i need to look more into all of this.. but thanks for all of your help -shawn -- http://mail.python.org/mailman/listinfo/python-list
Re: need a thread to keep a socket connection alive?
[EMAIL PROTECTED] wrote: elif len(msg) == (34): # length of request for ping ping the server This seems really dangerous. You are obviously writing to some already defined (and hopefully, documented) protocol. What does the protocol spec say about ping request messages? I would be very surprised if the spec says that a ping request is defined as any message which is 34 bytes long. More likely, it says something like, A ping request is defined by the command code being set to 5 or something like that. That's what you should be testing, not the length of the message. -- http://mail.python.org/mailman/listinfo/python-list
get in reply to with nntplib
Hello, I am coding a small newsarchiv and have a question: When trying to read out the in reply to data with xhdr i always get a (none) as return. Example: s = nntplib.NNTP('freetext.usenetserver.com') resp, count, first, last, name = s.group('comp.lang.python') resp, subs = s.xhdr('In-Reply-To', first + '-' + last) for id, sub in subs[-20:]: print id, sub 529515 (none) 529516 (none) 529517 (none) 529518 (none) 529519 (none) 529520 (none) [.] What do I wrong? Many greetings Hanno -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for resources for making the jump from Java to Python easier and more productive
Lawrence D'Oliveiro [EMAIL PROTECTED] writes: In article [EMAIL PROTECTED], ToddLMorgan [EMAIL PROTECTED] wrote: Are there python specific equivalents to the common Patterns, Anti-Patterns and Refactoring books that are so prevalent as reccomended reading in C++ and Java? I don't think they exist. Such books are targeted more towards development in a corporate environment, where every proposal has to go through multiple layers of management, and nothing is ever done by individuals working alone, always by teams working on separate parts of the project. And also where the end-users don't really get much say in how things are supposed to work. It's only in such a high-overhead, top-down, cover-your-ass environment that such books are looked on as being at all useful. Possibly on the grounds that nobody ever got fired for buying them. I'd say languages like Python and Perl are the absolute antithesis of this sort of development culture. On antithesis comment: Python can be used for Agile Programming, with the end user there at the monitor. But it can also be used for heavy duty development regimens with data models, specifications, development teams working multiple shifts or working worldwide, separate test-and-release teams, etc. On response to the OP: The most important thing you bring to the table is knowledge of data formats, algorithms, OO programming, and test-driven design. E.g., XML, HTML, LDAP, SQL, pipes, stacks, queues, threads, dictionaries, lexers, parsers, regular expressions, matrix transformations, GUI dialogs, etc. Many of us consider Python a secret weapon in learning new paradigms and technologies The most important things you need to leave behind: 1. Intuition about what is already available vs what you have to write. Java tries to reinvent the whole compsci world. Python just says Nice C/C++/FORTRAN library; I think I'll use it via a binding. If it is codable, it is probably scriptable in Python. 2. Temptation to reinvent entire stacks of libraries to replicate the Java module import structure. This is a real problem in migrating existing code. You have to take deep breath and ask What is the fundamental task, and how would a programmer do that in Python? Entire library trees melt away when you do this. 3. Fear you are missing something when you get done. Python takes c. 1/3 as many LOC as Java for the same task. At first I kept saying: This wee bit of code couldn't posssibly do the whole job, could it? If you have a good regression test suite, you are done when it works. If you need help getting on board unittests, see mkpythonproj: http://www.seanet.com/~hgg9140/comp/index.html#L006 -- Harry George PLM Engineering Architecture -- http://mail.python.org/mailman/listinfo/python-list
Re: i18n hell
Martin Blais napisał(a): See http://furius.ca/antiorm/ for something simple that works well. I'd like to know what is this module/library good for *before* I start downloading it. Almost like ORM but not exactly is rather vague term and can denote anything. Is it dishwasher? Or microwave oven? BTW, I don't have any problems without character encodings since I started using unicode objects internally in my programs. Database is the same kind of data source, as regular files, sockets or ttys -- you have to know client encoding before you start receiving data. Then decode it to unicode and you are fine. -- Jarek Zgoda http://jpa.berlios.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: need a thread to keep a socket connection alive?
[EMAIL PROTECTED]: i have discovered that the server will send a request for the heartbeat ping if its almost timed out, so i use the length of the message to determine what to do with it. msg = sockobj.recv(1024) if len(msg) == 158: record the data elif len(msg) == (34): # length of request for ping ping the server Incorrect. There are no 'messages' with TCP, only bytes. -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list
Re: MS VC++ Toolkit 2003, where?
Alex Martelli wrote: Martin v. Löwis [EMAIL PROTECTED] wrote: Alex Martelli wrote: As suggested to me by David Rushby 10 hours ago, http://www.microsoft.com/downloads/details.aspx?FamilyId=272BE09D-40BB-4 9FD-9CB0-4BFA122FA91Bdisplaylang=en does work. Can you please try this again: I'm also getting the error message that AIM is getting. Try tinyurl http://tinyurl.com/gv8wr please. I still get the following with the tinyurl link: ~~~ The download you requested is unavailable. If you continue to see this message when trying to access this download, go to the Search for a Download area on the Download Center home page. ~~~ Pasting the above tinyurl into firefox results in the following link. http://www.microsoft.com/downloads/details.aspx?familyid=272BE09D-40BB-4displaylang=en Which appears to still be truncated. :-/ I've also tinyurl'd your URL for the 1.1 SDK, to http://tinyurl.com/5flob . This one works. ((I suspect the problem has to do with a limitation of 80 characters/line in NNTP messages, which my favorite newsreader enforces unconditionally)). Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Recommended IDE for creating GUI?
Always nice to recommend myself: http://farpy.holev.com Free WYSIWYG GUI editor for wxPython (and wxRuby!). Have fun... -- http://mail.python.org/mailman/listinfo/python-list
Re: Recommended IDE for creating GUI?
Marty Christion napisał(a): What are some good free or inexpensive ($50) IDE's for learning how to program and create GUI's for Python? I'm pretty good with the simple programming aspect of the language, but I'm a little mystified by the world of GUI's, and the options available in python. Glade is a GUI builder for GTK and PyGTK. Free, cost free, OpenSource, multiplatform. Not as easy as Delphi, but with Python can do wonders. -- Jarek Zgoda http://jpa.berlios.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: threads and sys.exit()
gangesmaster wrote: calling sys.exit() from a thread does nothing... the thread dies, but the interpreter remains. i guess the interpreter just catches and ignore the SystemExit exception... does anybody know of a way to overcome this limitation? call thread.interrupt_main() on *NIX: os.kill(os.getpid(),signal.) or best design your threading correctly with resonable/flexible communication channels, e.g. CallQueue: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/491281 (infact that latter (example2) uses sys.exit/SystemExit the other way correctly: to terminate a thread cleanly in functional style. in the same style reverse the mainthread could be terminated cleanly.) I'd -robert -- http://mail.python.org/mailman/listinfo/python-list
Re: test assignmet problem
2006/4/23, Paul McGuire [EMAIL PROTECTED]: Paolo Pantaleo [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] So I tried this if(not (attr=global_re.match(line)) ): break it says invalid syntax [on the =] ... because this syntax is not valid ... so it is not possible to do test and assignment in C style? ... no it's not, see http://www.python.org/doc/faq/general/#why-can-t-i-use-an-assignment-in-an-expression how can I write this otherwise? ... is this so bad?... attr=global_re.match(line) if not attr: break ... or, since you don't seem to be doing much with attr, you could just do if not global_re.match(line): break ... and get rid of all those distracting ()'s! -- http://mail.python.org/mailman/listinfo/python-list Thnx for the help, actually the problme is not solved i have [well I want to do...] something like: if a=b(): do stuff with a else if a=c(): do stuff with b else: do other stuff well, two solutions are a1=b() a2=c() if a1: do stuff with a1 else if a2: do stuff with a2 else: do other stuff the other is if b(): a=b() do stuff with a else if c(): a=c() do stuff with b else: do other stuff Even if none is exactly the same about: * the number of times the b() and c() functions are executed * the final value of a I think the right one is: a=b() if a: do stuff with a else: a=c() if a=c(): do stuff with b else: do other stuff PAolo -- if you have a minute to spend please visit my photogrphy site: http://mypic.co.nr -- http://mail.python.org/mailman/listinfo/python-list
Re: MySql -Python question
[EMAIL PROTECTED] wrote: both of your suggestions don't work, that's kind of what I was trying the whole time Well it seems firly obvious that your universe is somehow broken. Please send it back to God in a plain wrapper and it will be replaced with a new universe in which all programming is done in assembly language :-) regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: threads and sys.exit()
i can't make the main thread daemonic. the situation is this: * the main thread starts a thread * the new thread does sys.exit() * the new thread dies, but the process remains i can do os.kill(os.getpid()), or TerminateProcess(-1) but that's not what i want -tomer -- http://mail.python.org/mailman/listinfo/python-list
Re: threads and sys.exit()
that's not a question of design. i just want a child-thread to kill the process. in a platform agnostic way. -- http://mail.python.org/mailman/listinfo/python-list
SOAP server with WSDL?
Does anyone know of a Python SOAP package that will publish a SOAP service /and/ generate a corresponding WSDL file? Looking at SOAPpy and ZSI, it seems that their WSDL support is limited to client-side stuff. -- http://mail.python.org/mailman/listinfo/python-list