Re: recycling internationalized garbage
Martin v. Löwis wrote: The point is that you can tell UTF-8 reliably. If the data decodes as UTF-8, it *is* UTF-8, because no other encoding in the world produces the same byte sequences (except for ASCII, which is an UTF-8 subset). It should be obvious that any 8-bit single-byte character set can produce byte sequences that are valid in UTF-8. In fact I can't think of any multi-byte encoding that can't produce valid UTF-8 byte sequence. Ross Ridge -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Debugger / IDE ??
[EMAIL PROTECTED] wrote: I've always been happy with the debugger in PythonWin. You can even use: from pywin.debugger import set_trace;set_trace() to bring up the debugger directly from a script that wasn't originally run in the ide. I use that one also. There is also Boa (http://boa-constructor.sourceforge.net/), available both in Linux and Windows, and with the avantage of having a separate process for the debugging unit, which is great when you have to explore some unsane scripts. Regards jm -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Debugger / IDE ??
bruno at modulix wrote: FWIW, I've almost never used a debugger with Python. It's pourtant very simpa from time to time ! -- http://mail.python.org/mailman/listinfo/python-list
py2exe: abnormal program termination
Today, I found strange error while using py2exe: 1. I wrote simple program and save as 1.py: import win32ui import win32con win32ui.MessageBox('Test messageBox.' , 'Test', win32con.MB_OK | win32con.MB_TOPMOST ) 2. I create 1_setup.py file for py2exe: from distutils.core import setup import py2exe setup( version = 0.0, description = , name = '', options = {py2exe: {compressed: 1, optimize: 2, bundle_files: 1}}, console = [1.py], zipfile = None, ) 3. I run 1.exe and get error: [code:1:7ea8ce03ac] Runtime Error! Abnormal program termination. [/code:1:7ea8ce03ac] [URL=http://imageshack.us]http://img74.imageshack.us/img74/4212/abnormal5mv.png[/URL] Is there a way to fix it? Common way (python 1.py) works. Thank you! -- http://mail.python.org/mailman/listinfo/python-list
Re: SSL/TLS - am I doing it right?
Michael Ekstrand enlightened us with: clients aren't expected to have their own certificates. I think that the only time you really need the clients to have certificates is when the certificate *is* your authentication (e.g., in OpenVPN). Fact remains that a strong certificate is much more secure than letting people choose their own passwords. Likewise, SSH does not verify client certificates (unless you're using PKA, but that's different). PKA is the more secure one, IIRC. Since the password is your authentication, I don't see any reason why the client verifying the server's certificate against its known good fingerprint, and then providing username/password as its credentials, is any less secure than SSH with password/keyboard-interactive. Again, IIRC having properly used certificates is more secure than using passwords. For instance, even if the encryption is broken and the unencrypted text can be read, certificates still can't be misused for authentication, since the private key is never sent. Passwords on the other hand will be immediately useless. Sure, maybe not quite as secure as SSH w/ public key auth, but it's good enough for a lot of stuff. It's too weak for a lot of stuff either. 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: recycling internationalized garbage
Martin wrote: The point is that you can tell UTF-8 reliably. RFC 3629 says fairly reliably rather than reliably, but they mean the same thing... If the data decodes as UTF-8, it *is* UTF-8, because no other encoding in the world produces the same byte sequences (except for ASCII, which is an UTF-8 subset). or as the RFC puts it, the probability that a string of characters in any other encoding appears as valid UTF-8 is low, diminishing with increasing string length. ::: Ross Ridge wrote: It should be obvious that any 8-bit single-byte character set can produce byte sequences that are valid in UTF-8. it should be fairly obvious that you don't know much about UTF-8... /F -- http://mail.python.org/mailman/listinfo/python-list
MS word document generator
Hello guys, Is there any nice library to generate word documents using Python. As of today I am generating a HTML document and then open it with MS Word. But the problem is that I am not able to control the pages in the document and as a result of it the output looks terrible. I have been using reportlab's platypus to generate PDF documents. Its a nice application which allows controlling segments of the pages programatically. I was wondering if there was any library as reportlab to generate word documents. Thanks, /R -- http://mail.python.org/mailman/listinfo/python-list
Re: SSL/TLS - am I doing it right?
Sybren Stuvel wrote: Michael Ekstrand enlightened us with: clients aren't expected to have their own certificates. I think that the only time you really need the clients to have certificates is when the certificate *is* your authentication (e.g., in OpenVPN). Fact remains that a strong certificate is much more secure than letting people choose their own passwords. I suppose it depends on your degree of paranoia (not that I want to belittle paranoia - it is a healthy instinct in this context). I was recommended to read O'Reilly's Network Security with OpenSSL. The first chapter is available online - http://www.oreilly.com/catalog/openssl/chapter/ch01.pdf It is a 30 page introduction which explains the concepts fairly thoroughly. After describing how a server sends a certificate and a client validates it, it simply says Although rare, the server can also request a certficate from the client. Obviously there are many different scenarios, but for my particular one, user id and password is 'good enough'. Frank -- http://mail.python.org/mailman/listinfo/python-list
Re: SSL/TLS - am I doing it right?
Frank Millman [EMAIL PROTECTED] writes: You also want to generate a client certificate to install on the server. Both you and Sybren are insistent that this is a necessary step, but I confess I cannot see the need for it. The client is lightweight, and authenticates itself to the server using a user id and password. What is the worst that could go wrong? The client cert approach isn't strictly necessary but it means that the SSL stack takes care of stuff that your application would otherwise have to take care of at both the client and the server side. If you don't generate a certificate, you have to generate a username and password instead, and manage that. There's still secret authenticating info on the client, so you haven't really decreased the client's responsibility. Also, if you need to go to a heavier-duty approach sometime, there's an industry making hardware devices (e.g. smart cards) that encapsulate keys and certificates so that the keys are very difficult to get access to. That improves security considerably. -- http://mail.python.org/mailman/listinfo/python-list
details
Python: ActivePython 2.4.2 Build 10 (ActiveState Corp.) based on Python 2.4.2 (#67, Jan 17 2006, 15:36:03) [MSC v.1310 32 bit (Intel)] on win32 - win32ui: Dont know how to get version info. Little snippet [code:1:f18a50c332]import win32ui aa = sorted(dir(win32ui)) for i in aa: print '%s = %r' % (i, getattr(win32ui, i)) print [/code:1:f18a50c332] gives me only copyright = 'Copyright 1994-2004 Mark Hammond ([EMAIL PROTECTED])' - AFAIK, win32ui is part of pywin32 - Pythonwin.exe on about: pythonwin32 build 205 - OS: Windows 2000 SP4 Dualcore: NO -- http://mail.python.org/mailman/listinfo/python-list
installing numpy
Hi, I'm trying to install the numpy library (precisely numpy-0.9.6-py2.4-linux-i686) on Linux but I encounter several problems. After unpacking the file it creates the following folders: usr/lib/python2.4/site-packages/numpy/ The file setup.py and the whole library is located under the folder numpy. If, from the location where I unpacked the file, I run the command python usr/lib/python2.4/site-packages/numpy/setup.py install I receive the following error: Traceback (most recent call last): File usr/lib/python2.4/site-packages/numpy/setup.py, line 24, in ? sys.path.remove(os.getcwd()) ValueError: list.remove(x): x not in list If, instead, I do cd usr/lib/python2.4/site-packages/numpy/ and then python setup.py install I receive the following error Traceback (most recent call last): File setup.py, line 26, in ? from numpy.distutils.core import setup ImportError: No module named numpy.distutils.core Finally I tried to move the folder numpy to the location where all the third-party modules are installed, that in my case is /usr/lib/python2.4/site-packages/ and run the command from there like: python numpy/setup.py install but, once again, I receive the error: Traceback (most recent call last): File numpy/setup.py, line 26, in ? from numpy.distutils.core import setup ImportError: No module named numpy.distutils.core Does anyone know how this module should be installed? Thanks and regards Cesco -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Debugger / IDE ??
[EMAIL PROTECTED] schrieb: Is there any editor or IDE in Python (either Windows or Linux) which has very good debugging facilites like MS VisualStudio has or something like that. I like SPE but couldn't easily use winPDP. I need tips to debug my code easily. You can try out PyScripter, a relatively new Python IDE that is completely free and has nice debugging and unit testing facilities. The latest version is available here: http://mmm-experts.com/Downloads.aspx?ProductID=4ShowVersionInfo=yes -- Christoph -- http://mail.python.org/mailman/listinfo/python-list
Re: MS word document generator
Raja Raman Sundararajan wrote: I was wondering if there was any library as reportlab to generate word documents. If you are on Windows, why dont you use word for it? You can call it from Python. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science Phone: +45 66 11 84 94 Mobile: +45 29 93 42 96 -- http://mail.python.org/mailman/listinfo/python-list
global, globals(), _global ?
Using global variables in Python often raises chaos. Other languages use a clear prefix for globals. * you forget to declare a global * or you declare a global too much or in conflict * you have a local identical variable name and want to save/load it to/from the global with same name * while you add code, the definition of globals moves more and more apart from their use cases - weirdness; programmers thinking is fragmented * using globals()['xy'] is 'stringy non-program-code' Thus, since long time at the head of my bigger modules I often put... _global = sys.modules[__name__] ...and use global variables only/mainly like def f(y): v=x=_global.x _global.y=y ... for me this method is much more clear overall. And it is in line with the clear exposition of self as regular object in Python methods (in a much more self-similiar way compared to frozen @ $ m_... hacks in other languages) I know, this home created _global creates a circular ref, but usually this is not serious as modules are unload only at the end of a program. ( side question: does this maybe hinder global objects from being __del__'ed correctly; is at least gc() run when all modules are pulled off at exit() ) Somehow I miss a nice standard method for using globals in an unfragmented way everywhere. What do you think? Robert -- http://mail.python.org/mailman/listinfo/python-list
Re: global, globals(), _global ?
Hi Robert, I was using global variables some time ago, too. But with the time the program simply got unmaintainable, because it is very hard to trace, why a global variable has some special value and not the one, you thought it should have. So I redesigned the program and now I can do it without global variables. To me global variables are now in most cases a sign of bad design. Is there no other way to do it? Greets Xaver robert [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] Using global variables in Python often raises chaos. Other languages use a clear prefix for globals. * you forget to declare a global * or you declare a global too much or in conflict * you have a local identical variable name and want to save/load it to/from the global with same name * while you add code, the definition of globals moves more and more apart from their use cases - weirdness; programmers thinking is fragmented * using globals()['xy'] is 'stringy non-program-code' Thus, since long time at the head of my bigger modules I often put... _global = sys.modules[__name__] ...and use global variables only/mainly like def f(y): v=x=_global.x _global.y=y ... for me this method is much more clear overall. And it is in line with the clear exposition of self as regular object in Python methods (in a much more self-similiar way compared to frozen @ $ m_... hacks in other languages) I know, this home created _global creates a circular ref, but usually this is not serious as modules are unload only at the end of a program. ( side question: does this maybe hinder global objects from being __del__'ed correctly; is at least gc() run when all modules are pulled off at exit() ) Somehow I miss a nice standard method for using globals in an unfragmented way everywhere. What do you think? Robert -- http://mail.python.org/mailman/listinfo/python-list
WORKAROUND
I fixed problem using Atypes: import ctypes ctypes.windll.user32.MessageBoxA(0, 'test', 'Title', win32con.MB_ICONINFORMATION | win32con.MB_OK | win32con.MB_TOPMOST) It compiles and runs fine with py2exe. Dont remember buggy pywin32 :) -- http://mail.python.org/mailman/listinfo/python-list
Re: MS word document generator
Raja Raman Sundararajan wrote: Hello guys, Is there any nice library to generate word documents using Python. As of today I am generating a HTML document and then open it with MS Word. But the problem is that I am not able to control the pages in the document and as a result of it the output looks terrible. I have been using reportlab's platypus to generate PDF documents. Its a nice application which allows controlling segments of the pages programatically. I was wondering if there was any library as reportlab to generate word documents. How about PyRTF to generate Rich Text Format documents which MS-Word will lap up? Thanks to the efforts of Simon Cusack (hi Simon). See http://cheeseshop.python.org/pypi/PyRTF/0.45 Tim C -- http://mail.python.org/mailman/listinfo/python-list
Re: Playing with modules
Kent Johnson wrote: [EMAIL PROTECTED] wrote: But I was wondering whether I could fool or backend the normal import mechanism. Even in Java, I can write my own class loader which can quick compile Java snippets and load the anonymous byte code. See http://www.python.org/doc/2.3/whatsnew/section-pep302.html Kent Thanks. That one helped. Just to get me started looking at test_importhooks.py in the dist. -- http://mail.python.org/mailman/listinfo/python-list
Re: Memory visualization
In message [EMAIL PROTECTED], Tim Peters [EMAIL PROTECTED] writes [EMAIL PROTECTED] I'd like to know if for Python there is a similar program to dynamically see the memory in a similar way. If such tool doesn't exist yet, I'd like to know if it may be diffifult to create it. One already exists: Python Memory Validator. Software Verification provide software tools for Python on the Windows platform. Software Verification have two commercial products for coverage and performance profiling and three beta products for flow tracing, memory analysis and thread deadlock monitoring. http://www.softwareverify.com Software Verification run with Python 2.2 upwards - no need to modify the python source or binary. Stephen -- Stephen Kellett Object Media Limitedhttp://www.objmedia.demon.co.uk/software.html Computer Consultancy, Software Development Windows C++, Java, Assembler, Performance Analysis, Troubleshooting -- http://mail.python.org/mailman/listinfo/python-list
Re: recycling internationalized garbage
Ross Ridge wrote: It should be obvious that any 8-bit single-byte character set can produce byte sequences that are valid in UTF-8. Fredrik Lundh wrote: it should be fairly obvious that you don't know much about UTF-8... Despite this malicious and false accusation, your post only confirms what I wrote above is true and what Martin wrote was false. Even with the desperate and absurd semantic game you tried to play, like falsely equating fairly reliably with reliably, in a database as large as this a low probability of failure does not guarantee if the data decodes as UTF-8, it *is* UTF-8. Ross Ridge -- http://mail.python.org/mailman/listinfo/python-list
Re: elementtree and gbk encoding
Hi, good advice, but note that an envelope (e.g a HTTP request or response body) may override the encoding in the XML file itself. if this arrives in a MIME message with the proper charset information, it's perfectly okay to leave out the encoding from the file. It might be practical - still, a xml parser _should_ puke on you, ans certainly some will (elemnttree not being one of those, I know :)) So even if it goes over the wire headerless, you should be prepending it when dealing with teh data later. Regards, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: elementtree and gbk encoding
pyexpat has only limited support for non-standard encodings; the core expat library only supports UTF-8, UTF-16, US-ASCII, and ISO-8859-1, and the Python glue layer then adds support for all byte-to-byte en- codings support by Python on top of that. Interesting. Maybe 4suite is more complete? I'll give it a shot. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: elementtree and gbk encoding
Diez B. Roggisch wrote: good advice, but note that an envelope (e.g a HTTP request or response body) may override the encoding in the XML file itself. if this arrives in a MIME message with the proper charset information, it's perfectly okay to leave out the encoding from the file. It might be practical - still, a xml parser _should_ puke on you, ans certainly some will (elemnttree not being one of those, I know :)) no, the parser must not to choke on a file for which the encoding has been overridden. for example, the HTTP standard allows the transport layer to recode text/* re- sources as long as it updates the charset properly, so if you e.g send an XML document as text/xml and charset=iso-8859-1, the transport layer can recode that to charset=utf-8, *without* rewriting the XML header. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: recycling internationalized garbage
Ross Ridge wrote: Despite this malicious and false accusation, your post only confirms what I wrote above is true and what Martin wrote was false. Even with the desperate and absurd semantic game you tried to play, like falsely equating fairly reliably with reliably, in a database as large as this a low probability of failure does not guarantee if the data decodes as UTF-8, it *is* UTF-8. are you a complete idiot, or do you only play one on the internet ? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: WORKAROUND
Could you perhaps use basic netiquette stuff, such as sticking to the same sub- ject line for followup posts in the same thread, and including a least some trace of the post you're commenting on ? (this would be less of a problem if everyone was reading your posts in a news- reader, but this group is available in many different forms...) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: recycling internationalized garbage
Unless someone has any other ideas I'm giving up now. btw, have you looked at using http://musicbrainz.org/products/server/download.html instead? they appear to guarantee UTF-8 (to the extent that *they* have managed to autodecode the FreeDB junk, of course). not sure how complete it is, though... /F -- http://mail.python.org/mailman/listinfo/python-list
Re: SSL/TLS - am I doing it right?
Paul Rubin enlightened us with: The client cert approach isn't strictly necessary but it means that the SSL stack takes care of stuff that your application would otherwise have to take care of at both the client and the server side. Indeed. I always try to take the route of the least wheels I have to invent. If a group of security specialists have already looked at such a mechanism, why should I reinvent another? If you don't generate a certificate, you have to generate a username and password instead, and manage that. There's still secret authenticating info on the client, so you haven't really decreased the client's responsibility. And on top of that, using passwords the secret information is sent over the network. 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
Button and Key Event
Hi, how to enable EVT_CHAR or EVT_KEY_DOWN in a wxButton? Thank's, Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Tree and Graph structures in Python.
Istvan Albert wrote: See this: https://networkx.lanl.gov/ Or if you want to be able to handle large graphs efficiently, igraph might be a good choice: http://igraph.sourceforge.net/ It's written in pure C, but has a Python interface and according to my measurements, it's much faster than any other Python graph package. The Python interface really needs some documentation, though, because now the only way to figure things out is to call help(igraph.Graph) after importing the module. (Or read the documentation of the C interface and hope that the function arguments are the same :)) -- Tamas [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: global, globals(), _global ?
Xaver Hinterhuber wrote: Hi Robert, I was using global variables some time ago, too. But with the time the program simply got unmaintainable, because it is very hard to trace, why a global variable has some special value and not the one, you thought it should have. So I redesigned the program and now I can do it without global variables. To me global variables are now in most cases a sign of bad design. Is there no other way to do it? Yes, one should put common _application_ variables of importance to config instances or data-modules/classes etc. Yet globals variables in Python are anyway module commons. That is a frequent practical need. Grep e.g. the python standard modules for use of global variables and use of global There are many practical module globals, which control e.g. the mode of a module, store precomputed/cached stuff etc., and where you do not open an extra data structure (for now). Most variable read-s in Python anyway go to module globals - as there are no other kinds of namespaces except __builtins__ ( And that later scheme is fairly wonderful - compare for example the namespace fuzz in C/C++, Pascal, Ruby, ... where you never know which module file addeds what to which namespace; In Ruby they even scribble from anywhere to _any_ class _and_ any namespace without the barrier of a dot or subclassing or anything - using somehow by random the same name already joins!? A threat for good modularization of code. Not far from free flat memory programming :-) Don't know how they keep bigger projects managable in this language. ) Yet, python module globals are set with this strange fragmented global name ; name=... But the common storage object in question is an ordinary module anyway. Why not stay self-similiar and use it as such in dot-syntax for write-s (and often for read-s in places, where you want to express the use of a special global explicitly in order to not confuse things with locals, and want to maintain the code readable. Robert -- http://mail.python.org/mailman/listinfo/python-list
__slots__ in derived class
Hello, consider this code class A(object): ... def __init__(self): ... self.a = 1 ... self.b = 2 ... class B(A): ... __slots__ = [x,y] ... b=B() b.a 1 b.b 2 b.x = 100 b.y = 100 b.z = 100 no exception here does __slots__ nothing when used in derived classes? class Z(object): ... __slots__ = [x,y] ... z=Z() z.x = 100 z.y = 100 z.z = 100 Traceback (most recent call last): File stdin, line 1, in ? AttributeError: 'Z' object has no attribute 'z' here it works like expected Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: installing numpy
cesco wrote: Hi, I'm trying to install the numpy library (precisely numpy-0.9.6-py2.4-linux-i686) on Linux but I encounter several This is a dumb pre-built binary package (useful perhaps because it links against ATLAS already) built using distutils. You don't build it and install it using setup.py you just un-tar it in the / directory and start using it. You only run python setup.py install when you have a source file. You can download the sources if you want and build it yourself using: python setup.py install Finally I tried to move the folder numpy to the location where all the third-party modules are installed, that in my case is /usr/lib/python2.4/site-packages/ and run the command from there like: python numpy/setup.py install Presumably, you can copy the files directly there and then start using it (don't run setup.py though, there is no need). After copying the files over to your site-packages directory, just start python and do import numpy -Travis -- http://mail.python.org/mailman/listinfo/python-list
Re: global, globals(), _global ?
robert wrote: Most variable read-s in Python anyway go to module globals - as there are no other kinds of namespaces except __builtins__ your post made some sense until I got to this paragraph, which appears to completely ignore local variables, arguments, and variables in intermediate scopes ? maybe you could clarify ? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: elementtree and gbk encoding
no, the parser must not to choke on a file for which the encoding has been overridden. for example, the HTTP standard allows the transport layer to recode text/* re- sources as long as it updates the charset properly, so if you e.g send an XML document as text/xml and charset=iso-8859-1, the transport layer can recode that to charset=utf-8, *without* rewriting the XML header. I have to correct myself: I was under the impression that XML _has_ to contain an XMLDecl (which is the header, possibly with encoding) to be well-formed. Interestingly enough, that has not to be the case. A document can very well be well-formed without a header. The constraints for well-formedness are scattered throughout the spec, so I'm not sure what they say about the used encoding in absence of a header. I am certain though that I've met parsers which weren't able to digest xml without XMLDecl - which formed my impression. But then, that wasn't correct. Boy, that XML-stuff is always full of surprises - even after so many years dealing with it.. DIez -- http://mail.python.org/mailman/listinfo/python-list
Re: Very, Very Green Python User
Scott David Daniels wrote: [EMAIL PROTECTED] wrote: ... Is the Python debugger fairly stable? Yes, but it is not massively featured. The Pythonic way is to rarely use a debugger (test first and straightforward code should lead to shallow bugs). Often for most of us judiciously placed print statements suffice. The one you get with Perl stinks on ice. More than anything else, I would like to have a powerful OO environment where I do not have to worry about the debugger sucking Do watch your language on this newsgroup. Lots of people read this group and there is no good reason to offend them. In turn, you will be cut some slack. As one who avidly studies language, I have observed that the meaning of a word slip out of its original context through idiomatic usage. If I had included the implicit object of 'sucks', then you would have more grounds for complaint. However, 'sucks', used in the intransitive sense, is no worse than 'bites the bag'. Think about the word 'mogul'. Like 'oil mogul' or 'software mogul'. Well, the **Mughals**, whence comes the word, were mass-murderers: http://www.geocities.com/hindoo_humanist/mughal.html If you were a Hindu in those times, saying 'oil mogul', would be equivalent to saying 'oil Stalin' or 'oil Hitler' today. But this isn't about human rights so much as it is about semantics. (Nobody likes long-winded, abstract philosophical discussions on a technology NG.) 'Sucks' doesn't mean what it used to, at least how I used it there. Unless one is willing to investigate the etymology of every word he uses (like mogul, Christian, or juggernaut), there needs to be a more lenient attitude towards use of language. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tree and Graph structures in Python.
Thanks guys. The networkx and igraph packages look to have the sort of features I want. I'm surprised there's nothing in the standard module library really. -- Ant... -- http://mail.python.org/mailman/listinfo/python-list
Re: Very, Very Green Python User
Exactly...this is how most of my Perl modules are written and tested, actually. -- http://mail.python.org/mailman/listinfo/python-list
Re: elementtree and gbk encoding
Diez B. Roggisch wrote: Interestingly enough, that has not to be the case. A document can very well be well-formed without a header. The constraints for well-formedness are scattered throughout the spec, so I'm not sure what they say about the used encoding in absence of a header. if there's no header, and no external override, the document must use either UTF-8 or UTF-16, and for UTF-16, a leading byte order mark must be present (ASCII is of course a subset of UTF-8, but e.g. ISO-8859-1 isn't). reading http://www.w3.org/TR/2004/REC-xml-20040204/#sec-guessing may also help (at least if you read between the lines). Boy, that XML-stuff is always full of surprises - even after so many years dealing with it.. a specification written for humans would have saved the world a lot of con- fusion... /F -- http://mail.python.org/mailman/listinfo/python-list
libglade for python-2
I am having some fun running a program called pygps. This uses libglade and runs fine on my very old Redhat 7.? system running Python 1.5.2. I have not needed to make any changes to the import files (see below). The program uses a glade generated pygps.glade xml file for the gui. I like the way this works and the ability to edit the xml(?) with glade. Now on my Fedora system which has version 2 of just about everything it will not run and I cannot figure how to get the code to work. The site packages include a glade.so file but there is no libglade. Googling I have not found specifc support for libglade in anything other than ada and c, nothing for python 2.0. Is there a mechanism to invoke libglade operation (ie a separate xml file generated by glade-2 like I have with the old python 1 system? Note that I have discovered the older glade files are not compatible with glade-2. Is libglade dead now for python-2 or am I missing something? See: http://pygps.org/ Imports from pygps: import GDK from gtk import * import math import socket, string import libglade import GdkImlib import os from LatLongUTMconversion import LLtoUTM import NMEA (Ignore the last two, they are local but I have included them for completeness) Doug -- http://mail.python.org/mailman/listinfo/python-list
Re: Very, Very Green Python User
[EMAIL PROTECTED] wrote: Nobody likes long-winded, abstract philosophical discussions on a technology NG. not even on comp.lang.python ? ;-) /F -- http://mail.python.org/mailman/listinfo/python-list
Installing PySQLite on OS X 10.4
Hi all, I'm having difficulty installing pysqlite 2.1.3 on Mac OS X 10.4.4 There are some notes on the pysqlite wiki regarding modification of the setup.py script and I've followed them to no avail. Build and install appear to go smoothly but attempting to run the tests from the python interpreter fails. Likewise any attempt to utilise pysqlite2 in a python script fails. Has anyone here successfully installed it? If you have, do you have any pearls of wisdom that might help me out? Cheers, Rob C -- http://mail.python.org/mailman/listinfo/python-list
Re: Little Help with Exceptions and ConfigParser
mwt wrote: (Whoops, again.) def __init__(self, config_file): self.fahdata = fahdata.FAHData() self.INI = ConfigParser.ConfigParser() if os.path.exists(config_file): try: self.INI.read(config_file) except ConfigParser.Error, err: print Cannot parse configuration file. %s %err except IOError, err: print Problem opening configuration file. %s %err except Error, err: print Problem with with configuration file. %s %err I don't know what Error refers to here. If you want a blanket except clause then catch Exception, that would replace IOError and probably Error. Also you can specify more than one exception in a single except clause by putting them in a tuple: except (IOError, Error), err: print Problem opening configuration file. %s %err HTH Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: global, globals(), _global ?
In article [EMAIL PROTECTED], robert [EMAIL PROTECTED] wrote: Using global variables in Python often raises chaos. Other languages use a clear prefix for globals. Unsing globals raises chaos in any language. They should be shunned and avoided. -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing PySQLite on OS X 10.4
Rob Cowie wrote: There are some notes on the pysqlite wiki regarding modification of the setup.py script and I've followed them to no avail. Build and install appear to go smoothly but attempting to run the tests from the python interpreter fails. Likewise any attempt to utilise pysqlite2 in a python script fails. it's might be a bit easier to help if you what you did when attempting to use the library, and how things failed. (if you get an ImportError, are you importing the right thing? where did the setup.py install step put the modules ? is that directory on the Python path ?) /F -- http://mail.python.org/mailman/listinfo/python-list
Feedparser and dates
I'm using FeedParser.org to import feeds into our MySQL database. Our problem is that we haven't found a solution to translate the date of a post item into GMT. Any ideas? Thanks, Jacob -- http://mail.python.org/mailman/listinfo/python-list
Re: __slots__ in derived class
Schüle Daniel wrote: Hello, consider this code class A(object): ... def __init__(self): ... self.a = 1 ... self.b = 2 ... class B(A): ... __slots__ = [x,y] ... b=B() b.a 1 b.b 2 b.x = 100 b.y = 100 b.z = 100 no exception here does __slots__ nothing when used in derived classes? class Z(object): ... __slots__ = [x,y] ... z=Z() z.x = 100 z.y = 100 z.z = 100 Traceback (most recent call last): File stdin, line 1, in ? AttributeError: 'Z' object has no attribute 'z' here it works like expected Regards, Daniel I would expect that A has to define its own __slots__ too. The following code should work as expected and makes also sense with the memory optimization considerations that motivated introduction of the __slots__ variable. class A(object): __slots__ = [a,b] def __init__(self): self.a = 1 self.b = 2 class B(A): __slots__ = [x,y] Kay -- http://mail.python.org/mailman/listinfo/python-list
Re: WORKAROUND
Fredrik Lundhwrote: Could you perhaps use basic netiquette stuff, such as sticking to the same sub- ject line for followup posts in the same thread, and including a least some trace of the post you're commenting on ? (this would be less of a problem if everyone was reading your posts in a news- reader, but this group is available in many different forms...) /F Excuse me, please. I mean, that 1. When I post new message to WEBFORUM (not a Mailing List nor News Group) not to include even part of message. 2. About subject line: if this forum huge depends from subject line, this field must be disabled or set to RE: % + (orig_msg.subject) by forum admins. Forum using some webforum engine, and easiest way to format messages - tune it up accurately instead of messaging about netiquette. 3. I receive message about topic posts without host name, so could go in Browser History to find it. I mean, misplaced 'netiquette' eclipsed by this bug: Hello, You are receiving this email because you are watching the topic, Re: WORKAROUND at niXforums. This topic has received a reply since your last visit. You can use the following link to view the replies made, no more notifications will be sent until you visit the topic. http:///files/forum/viewtopic.php?p=730860#730860 If you no longer wish to watch this topic you can either click the Stop watching this topic link found at the bottom of the topic above, or by clicking the following link: http:///files/forum/viewtopic.php?t=136721unwatch=topic -- Thanks, The Management Please, sorry for my english. -- http://mail.python.org/mailman/listinfo/python-list
Re: WORKAROUND
Fredrik Lundhwrote: Could you perhaps use basic netiquette stuff, such as sticking to the same sub- ject line for followup posts in the same thread, and including a least some trace of the post you're commenting on ? (this would be less of a problem if everyone was reading your posts in a news- reader, but this group is available in many different forms...) /F Excuse me, please. I mean, that 1. When I post new message to WEBFORUM (not a Mailing List nor News Group) not to include even part of message. 2. About subject line: if this forum huge depends from subject line, this field must be disabled or set to RE: % + (orig_msg.subject) by forum admins. Forum using some webforum engine, and easiest way to format messages - tune it up accurately instead of messaging about netiquette. 3. I receive message about topic posts without host name, so could go in Browser History to find it. I mean, misplaced 'netiquette' eclipsed by this bug: Hello, You are receiving this email because you are watching the topic, Re: WORKAROUND at niXforums. This topic has received a reply since your last visit. You can use the following link to view the replies made, no more notifications will be sent until you visit the topic. http:///files/forum/viewtopic.php?p=730860#730860 If you no longer wish to watch this topic you can either click the Stop watching this topic link found at the bottom of the topic above, or by clicking the following link: http:///files/forum/viewtopic.php?t=136721unwatch=topic -- Thanks, The Management Please, sorry for my english. -- http://mail.python.org/mailman/listinfo/python-list
Re: WORKAROUND
Fredrik Lundhwrote: Could you perhaps use basic netiquette stuff, such as sticking to the same sub- ject line for followup posts in the same thread, and including a least some trace of the post you're commenting on ? (this would be less of a problem if everyone was reading your posts in a news- reader, but this group is available in many different forms...) /F Excuse me, please. I mean, that 1. When I post new message to WEBFORUM (not a Mailing List nor News Group) not to include even part of message. 2. About subject line: if this forum huge depends from subject line, this field must be disabled or set to RE: % + (orig_msg.subject) by forum admins. Forum using some webforum engine, and easiest way to format messages - tune it up accurately instead of messaging about netiquette. 3. I receive message about topic posts without host name, so could go in Browser History to find it. I mean, misplaced 'netiquette' eclipsed by this bug: Hello, You are receiving this email because you are watching the topic, Re: WORKAROUND at niXforums. This topic has received a reply since your last visit. You can use the following link to view the replies made, no more notifications will be sent until you visit the topic. http:///files/forum/viewtopic.php?p=730860#730860 If you no longer wish to watch this topic you can either click the Stop watching this topic link found at the bottom of the topic above, or by clicking the following link: http:///files/forum/viewtopic.php?t=136721unwatch=topic -- Thanks, The Management Please, sorry for my english. -- http://mail.python.org/mailman/listinfo/python-list
Re: Very, Very Green Python User
Fredrik Lundh wrote: [EMAIL PROTECTED] wrote: Nobody likes long-winded, abstract philosophical discussions on a technology NG. not even on comp.lang.python ? ;-) I wish :-) regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd www.holdenweb.com Love me, love my blog holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
FIR filtering
Hi all, i'm looking for a module to implement a digital FIR filter! Can anyone help me? Thanks, Vincent -- http://mail.python.org/mailman/listinfo/python-list
Re: WORKAROUND
PyDenis wrote: 1. When I post new message to WEBFORUM (not a Mailing List nor News Group) not to include even part of message. comp.lang.python is a newsgroup and the python-list mailing list is a mailing list. your messages appear in both places. /F -- http://mail.python.org/mailman/listinfo/python-list
Server applications - avoiding sleep
I have written a small server application (for Windows) which handles sending and receiving information from an instant messaging client and a database. This server needs to run 24/7, however it stops when the computer screen is locked. I assume there is a way to make it run in the background 24/7 but how do I go about doing this? At present the application runs from within a wxPython GUI, however this is only used to start and stop it. It could be entire faceless and the GUI only used to execute it. Best, rod -- http://mail.python.org/mailman/listinfo/python-list
Re: global, globals(), _global ?
Roy Smith wrote: In article [EMAIL PROTECTED], robert [EMAIL PROTECTED] wrote: Using global variables in Python often raises chaos. Other languages use a clear prefix for globals. Unsing globals raises chaos in any language. They should be shunned and avoided. Solution: replace globals with Singletons ;-) Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: Feedparser and dates
friis wrote: I'm using FeedParser.org to import feeds into our MySQL database. Our problem is that we haven't found a solution to translate the date of a post item into GMT. from what I can tell, feedparser returns a 9-item UTC time tuple (which is the same thing as GMT, at least for all practical purposes). if it's a standard timestamp you want, you can use calendar.timegm: t = (2004, 1, 1, 19, 48, 21, 3, 1, 0) import calendar calendar.timegm(t) 1072986501 import time, datetime time.asctime(time.gmtime(calendar.timegm(t))) 'Thu Jan 01 19:48:21 2004' datetime.datetime.utcfromtimestamp(calendar.timegm(t)) datetime.datetime(2004, 1, 1, 19, 48, 21) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Server applications - avoiding sleep
You can create a Windows Service which will run as long as Windows are up, well, except if you stop it. You can find more info here: http://www.python.org/windows/win32/ Sebastjan On 15 Mar 2006 05:26:45 -0800, rodmc [EMAIL PROTECTED] wrote: I have written a small server application (for Windows) which handles sending and receiving information from an instant messaging client and a database. This server needs to run 24/7, however it stops when the computer screen is locked. I assume there is a way to make it run in the background 24/7 but how do I go about doing this? At present the application runs from within a wxPython GUI, however this is only used to start and stop it. It could be entire faceless and the GUI only used to execute it. Best, rod -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Server applications - avoiding sleep
rodmc wrote: I have written a small server application (for Windows) which handles sending and receiving information from an instant messaging client and a database. This server needs to run 24/7, however it stops when the computer screen is locked. I assume there is a way to make it run in the background 24/7 but how do I go about doing this? At present the application runs from within a wxPython GUI, however this is only used to start and stop it. It could be entire faceless and the GUI only used to execute it. http://www.python.org/windows/win32/ google is your friend - when you know what to search !-) -- 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: __slots__ in derived class
Schüle Daniel wrote: consider this code class A(object): ... def __init__(self): ... self.a = 1 ... self.b = 2 ... class B(A): ... __slots__ = [x,y] ... b=B() b.a 1 b.b 2 b.x = 100 b.y = 100 b.z = 100 no exception here does __slots__ nothing when used in derived classes? __slots__ is intended as a way to reduce memory consumption. It was never intended as a protection mechanism. The slots which are available in a class only add to the attributes available in the base class. You can hide base class slots by defining a slot of the same name, but you cannot remove them. Your base class has a __dict__ attribute and therefore all instances of the base class or any derived classes also have a __dict__ attribute. -- http://mail.python.org/mailman/listinfo/python-list
Install Universal Encoding Detector
How do I install Universal Encoding Detector (http://chardet.feedparser.org/)? Thanks, Jacob -- http://mail.python.org/mailman/listinfo/python-list
Re: Threads: does Thread.start() atomically set Thread.__started ?
Enigma Curry wrote: Can some kind person please further my education on Threads? When I create a thread called t and I do a t.start() am I guaranteed that t.isAlive() will return True as long as the thread hasn't already completed? Put another way, does t.start() ever return before t.__started is set to True? Did you check the source? It's fairly straightforward, as I recall. (threading.py in the python library) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Install Universal Encoding Detector
Jacob wrote: How do I install Universal Encoding Detector (http://chardet.feedparser.org/)? it comes with a setup.py file, so I suppose the answer is in the usual way: 1. download 2. unpack 3. cd to the distribution directory 4. run python setup.py install more here: http://docs.python.org/inst/inst.html /F -- http://mail.python.org/mailman/listinfo/python-list
Re: FIR filtering
LabWINC wrote: i'm looking for a module to implement a digital FIR filter! Can anyone help me? Is this for homework, for academic interest, for a control system problem, or what? Some context would be useful in helping us answer. (The first thing that occurs to me, for example, is why don't you just write it yourself? ...it's not like they're a complicated equation and if you have the coefficients, you practically have the code already. But that might not be the best approach if this is a real-world situation.) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: FIR filtering
It's for research work. I'm implementing an algorithm from a matlab one. It could be very difficult to find the fir coefficients because i have lot of fileters to implement. Vincent -- http://mail.python.org/mailman/listinfo/python-list
Re: MS word document generator
Hi Tim, Thanks for your PyRTF suggestion. I am checking it out now :-) /R -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing PySQLite on OS X 10.4
Fredrik Lundh wrote: Rob Cowie wrote: There are some notes on the pysqlite wiki regarding modification of the setup.py script and I've followed them to no avail. Build and install appear to go smoothly but attempting to run the tests from the python interpreter fails. Likewise any attempt to utilise pysqlite2 in a python script fails. it's might be a bit easier to help if you what you did when attempting to use the library, and how things failed. (if you get an ImportError, are you importing the right thing? where did the setup.py install step put the modules ? is that directory on the Python path ?) /F True... I should have included this stuff. the output from setup.py install indicates that an egg is constructed and copied to /Library/Python/2.3/site-packages/pysqlite-2.1.3-py2.3-macosx-10.4-ppc.egg. At the python prompt, I can import pysqlite2 with no problems. However, if I do from pysqlite2 import test as suggested after installation, I get the following traceback... Traceback (most recent call last): File stdin, line 1, in ? File pysqlite2/test/__init__.py, line 25, in ? from pysqlite2.test import dbapi, types, userfunctions, factory, transactions File pysqlite2/test/dbapi.py, line 26, in ? import pysqlite2.dbapi2 as sqlite File pysqlite2/dbapi2.py, line 32, in ? from pysqlite2._sqlite import * ImportError: No module named _sqlite If I view my site-packages dir in the Finder, the .egg file appears as a document, instead of a directory as is usually the case with .eggs. Perhaps this is an indication that the .egg file is not being built correctly? -- http://mail.python.org/mailman/listinfo/python-list
Re: FIR filtering
LabWINC wrote: Hi all, i'm looking for a module to implement a digital FIR filter! Can anyone help me? Thanks, Vincent gnuradio? Hans Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: Install Universal Encoding Detector
Thanks :) -- http://mail.python.org/mailman/listinfo/python-list
Re: WORKAROUND the Python GUI-lib situation ...
PyDenis wrote: I fixed problem using Atypes: import ctypes ctypes.windll.user32.MessageBoxA(0, 'test', 'Title', win32con.MB_ICONINFORMATION | win32con.MB_OK | win32con.MB_TOPMOST) It compiles and runs fine with py2exe. Dont remember buggy pywin32 :) better use win32api.MessageBox win32api/gui/... are flat modules unlikely to have errors. I tested your 2-liner with build207/py2.4.2 and build205/py2.3.5 with py2exe and cx_Freeze in each combination and could not reproduce the bug on XP, W2K and 98. ( The DestroyWindow bug appears only for more complex apps explicitly using .DestroyWindow from certain Notification Handlers; the dual core bug does not apply here ) I'm curious what it is? If you could post a bug - if reproduceable - with all your detailed context data to pywin32 project/bugs on sf.net, that would be fine. --- Python GUI situation: win32ui most probably is responsible for this bug; its a complex beast with lot of descriptional status (MFC). win32ui wants a mainframe, a document-template, an all that like until you can do any simple thing :-( :-) But once settled and maybe hiding its added complexity in a custom wrapper you can program quite fluid apps with official Windows lookfeel with it. Yet in my recent tests with wxPython (I tried now 4x over years to get something stable with wx :-( ), Boa, Kommodo, ... I had so much more freezes and damages, and fat memory consumption and slowness and fatigue, and funny appearance, that I'd say, for Windows its better to live with win32ui for non-trivial GUI's (especially distributable ones), which appear and behave like real Windows apps - and not like something copyied from a Donald Duck magazine. Testing the latest wx and Boa last week (for py2.3) it hit the high-score: All other old win32api/ui apps - just by starting them - press magically buttons themslef, raise this and that. Never saw such behaviour. wx modified something in the libraries. There were new Windows ctrl-libs in the main Python folder after wx-install (which I never requested/allowed). But even removing them did not heal the ghostly behavor of normal win32 apps not having anything to do with wx. Only after uninstalling wx boa win32 was stable again... There are some other (open) things like PyFltk and worse ... In my opinion the overall situation of Python GUI's (platform independent) is not in line with and not up to the level of the wonderful language itself and to its stability. There is always a fragile TCL or XY-C++ or MFC or this and that in the middle - and I can't believe, that it is necessary. Python is a best OO language for GUI programming also and it should glue soon to OS-libs (win32api/gui../ctypes , gtk, ...) . I'd believe there is still room for a relly good, platform independent speedy, flat, python-only OO GUI library - which loads modules with discipline into memory, allows building distributables below 2MB, raises only Python exceptions and would even attack Delphi in terms of stability, endurance, VHL language typing speed - first by Pythons qualities, and quickly by features (for which people would contribute very quickly if a good plan is raised). ( But maybe I'm only dreaming ... ? ) Anygui was an academical test. Some want to see wx as standard Python GUI lib. In my opinion thats compromising cheaply with a C++ monster for producing clumsy test in-door apps by carefully avoiding too much stepping with broken builds .. It is strange, that each of the big python IDE's uses another GUI toolkit: In an urge they use everything from Tk and to even the 20MB MozillaWindowing-Toolkit (Komodo; I dropped 3.5 yesterday from my HD after it core-dumped on second start and stepped 20x slower in the debugger than PythonWin, no consistent Interactive Win/history, 100MB in memory, .. ). Python first should maybe have a real Python GUI toolkit and unite the OS'es directly - as good as it does for the os module ? Robert -- http://mail.python.org/mailman/listinfo/python-list
Re: sizeof(struct timeval)
Nick Kew wrote: Tony Houghton wrote: ... But regardless of whether it's 'safe' amongst current devices, you're setting yourself up for a Y2K-family bug. Except it'll be a real one, not a storm-inna-teacup. Hey, hey, don't go spouting off like one of those ignorant journalists! I and a lot of other programmers wasted years debugging code ahead of 2000 to make darn sure the tempest stayed in the teacup. The code I worked on sure as heck would have screwed over a bunch of Texans on Medicaid, and I would have far preferred to be at my previous job monitoring Space Shuttle data. And in that Nick is correct, don't paint yourself into a corner. Curtis -- http://mail.python.org/mailman/listinfo/python-list
Re: Tried Ruby (or, what Python *really* needs or perldoc!)
While epydoc is nice, I'll point out that one thing that Unix people like myself really like is to be able to check docs on a remote server that we're logged into via a terminal session. The help() function in the interpreter is great for this, although it seems that python eggs broke it. :( Please don't leave the terminal behind. Perl provides docs in all formats, since if you can write POD (plain old documentation), you can run perldoc, or run pod2html, or pod2man, etc. I'll also point out that a lot of these complex solutions are ignoring the KISS principle. POD takes about 5 minutes to learn, tops. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tried Ruby (or, what Python *really* needs or perldoc!)
I'd love to have a unified documentation system where *all* the documentation for *all* installed modules was available to pydoc *and* the web browser and *all* this documentation was in .py files. Seconded! Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Install Universal Encoding Detector
Jacob wrote: How do I install Universal Encoding Detector (http://chardet.feedparser.org/)? The usual process: download unpack with your favorite tool - tar or WinZip, maybe cd chardet-1.0 python setup.py install Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: Tried Ruby (or, what Python *really* needs or perldoc!)
I have found the Python sidebar VERY helpful: Personally, I can't use local docs on my desktop as they may not be the same version of the docs for the Python distro running on the server that I'm deploying on. I usually go to python.org and use the wayback machine to look at the old docs for the release that I'm on. But, if Python would match Perl for docs available on the command-line, then I'd have it all at my fingertips. I simply don't understand why this is not being done. When I'm coding in C, I use the manpages on the remote host so that I know the docs are correct for my target. Why can't I do that in Python? It's yet another thing that my Perl-using coworkers point out as a Python weakness. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: WORKAROUND the Python GUI-lib situation ...
On 3/15/06, robert [EMAIL PROTECTED] wrote: PyDenis wrote: I fixed problem using Atypes: import ctypes ctypes.windll.user32.MessageBoxA(0, 'test', 'Title', win32con.MB_ICONINFORMATION | win32con.MB_OK | win32con.MB_TOPMOST) It compiles and runs fine with py2exe. Dont remember buggy pywin32 :) better use win32api.MessageBox win32api/gui/... are flat modules unlikely to have errors. I tested your 2-liner with build207/py2.4.2 and build205/py2.3.5 with py2exe and cx_Freeze in each combination and could not reproduce the bug on XP, W2K and 98. ( The DestroyWindow bug appears only for more complex apps explicitly using .DestroyWindow from certain Notification Handlers; the dual core bug does not apply here ) I'm curious what it is? If you could post a bug - if reproduceable - with all your detailed context data to pywin32 project/bugs on sf.net, that would be fine. --- Python GUI situation: win32ui most probably is responsible for this bug; its a complex beast with lot of descriptional status (MFC). win32ui wants a mainframe, a document-template, an all that like until you can do any simple thing :-( :-) But once settled and maybe hiding its added complexity in a custom wrapper you can program quite fluid apps with official Windows lookfeel with it. Yet in my recent tests with wxPython (I tried now 4x over years to get something stable with wx :-( ), Boa, Kommodo, ... I had so much more freezes and damages, and fat memory consumption and slowness and fatigue, and funny appearance, that I'd say, for Windows its better to live with win32ui for non-trivial GUI's (especially distributable ones), which appear and behave like real Windows apps - and not like something copyied from a Donald Duck magazine. win32gui and wxPython use *exactly* the same controls in almost all cases. If you're seeing something donald duck then you're either doing something wrong, or you're using a custom control. wx is also in a far better position for most non-trivial UIs, becuase it has infrastructure that win32 (pretty much alone among modern UI toolkits) lacks, like layout algorithms and i18ln support. Testing the latest wx and Boa last week (for py2.3) it hit the high-score: All other old win32api/ui apps - just by starting them - press magically buttons themslef, raise this and that. Never saw such behaviour. wx modified something in the libraries. There were new Windows ctrl-libs in the main Python folder after wx-install (which I never requested/allowed). But even removing them did not heal the ghostly behavor of normal win32 apps not having anything to do with wx. Only after uninstalling wx boa win32 was stable again... I dont know where you get your wx libs from, or what press magically buttons themself means, but the official wx installer doesn't do any of this. Whatever you saw had nothing to do with wx. There are some other (open) things like PyFltk and worse ... In my opinion the overall situation of Python GUI's (platform independent) is not in line with and not up to the level of the wonderful language itself and to its stability. There is always a fragile TCL or XY-C++ or MFC or this and that in the middle - and I can't believe, that it is necessary. Python is a best OO language for GUI programming also and it should glue soon to OS-libs (win32api/gui../ctypes , gtk, ...) . I'd believe there is still room for a relly good, platform independent speedy, flat, python-only OO GUI library - which loads modules with discipline into memory, allows building distributables below 2MB, Python all by itself is bigger than this unless you totally gut the standard library, and even then it's just barely under 2MB. raises only Python exceptions and would even attack Delphi in terms of stability, endurance, VHL language typing speed - first by Pythons qualities, and quickly by features (for which people would contribute very quickly if a good plan is raised). ( But maybe I'm only dreaming ... ? ) Anygui was an academical test. Some want to see wx as standard Python GUI lib. In my opinion thats compromising cheaply with a C++ monster for producing clumsy test in-door apps by carefully avoiding too much stepping with broken builds .. It is strange, that each of the big python IDE's uses another GUI toolkit: In an urge they use everything from Tk and to even the 20MB MozillaWindowing-Toolkit (Komodo; I dropped 3.5 yesterday from my HD after it core-dumped on second start and stepped 20x slower in the debugger than PythonWin, no consistent Interactive Win/history, 100MB in memory, .. ). Python first should maybe have a real Python GUI toolkit and unite the OS'es directly - as good as it does for the os module ? Even a minimal GUI toolkit is an order of magnitude more complicated than the os module. Robert -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Tried Ruby (or, what Python *really* needs or perldoc!)
msoulier wrote: But, if Python would match Perl for docs available on the command-line, then I'd have it all at my fingertips. I simply don't understand why this is not being done. When I'm coding in C, I use the manpages on the remote host so that I know the docs are correct for my target. Why can't I do that in Python? What about pydoc? % pydoc os [Clear screen] Help on module os: NAME os - OS routines for Mac, DOS, NT, or Posix depending on what system we're on. FILE /usr/lib/python2.4/os.py MODULE DOCS http://www.python.org/doc/current/lib/module-os.html DESCRIPTION [...] It's yet another thing that my Perl-using coworkers point out as a Python weakness. In my experience, Perl-using coworkers tend to dredge up all sorts of weaknesses, although many of them are no more than cheap shots: the name, whitespace, and so on. Sure, Python's documentation system could be better, but let's consider the tools we already have first. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Server applications - avoiding sleep
Hi, Thanks to both of you for your help. cheers, rod -- http://mail.python.org/mailman/listinfo/python-list
Re: global, globals(), _global ?
Fredrik Lundh wrote: robert wrote: Most variable read-s in Python anyway go to module globals - as there are no other kinds of namespaces except __builtins__ your post made some sense until I got to this paragraph, which appears to completely ignore local variables, arguments, and variables in intermediate scopes ? maybe you could clarify ? Of course the local namespaces on the stack are the unmentioned default (the intermediate frames are half way on the stack ..). The discussion focused on off-stack, common name spaces. Python has done the right magic in order to let modularize code well. Just self-similiar self-inspection is not (yet) done to the best in some places: this _global own module, self inspection in functions/classes/methods (nameless recursion), stack handling/callcc Robert -- http://mail.python.org/mailman/listinfo/python-list
Re: FIR filtering
What's gnuradio? -- http://mail.python.org/mailman/listinfo/python-list
Re: MS word document generator
On 2006-03-15, Raja Raman Sundararajan [EMAIL PROTECTED] wrote: Is there any nice library to generate word documents using Python. I find the following works well for me: f = open(file.doc) f.write(Hello there.\n) f.write(How are you?\n) f.close() As of today I am generating a HTML document and then open it with MS Word. But the problem is that I am not able to control the pages in the document and as a result of it the output looks terrible. If you want fancier formatting that available in my example code, I'd look for a library to generate RTF. Something like this perhaps (I haven't tried it yet): http://pyrtf.sourceforge.net/ RTF is far more portable that whatever .doc format-du-jour happens to be in vogue in Redmond. I have been using reportlab's platypus to generate PDF documents. Its a nice application which allows controlling segments of the pages programatically. I was wondering if there was any library as reportlab to generate word documents. -- Grant Edwards grante Yow! ... I have read the at INSTRUCTIONS... visi.com -- http://mail.python.org/mailman/listinfo/python-list
Don't use __slots__ (was Re: __slots__ in derived class)
In article [EMAIL PROTECTED], =?ISO-8859-1?Q?Sch=FCle_Daniel?= [EMAIL PROTECTED] wrote: does __slots__ nothing when used in derived classes? Short answer: don't use __slots__ until you're comfortable writing metaclasses and decorators. __slots__ are a performance hack strictly for advanced users, and if you think you need them, you probably don't. -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ 19. A language that doesn't affect the way you think about programming, is not worth knowing. --Alan Perlis -- http://mail.python.org/mailman/listinfo/python-list
Re: FIR filtering
LabWINC wrote: What's gnuradio? http://www.gnu.org/software/gnuradio/ It's a c++ lib with a python wrapper. BTW, thats the first hit in google ... Hans Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing PySQLite on OS X 10.4
Rob Cowie wrote: [...] However, if I do from pysqlite2 import test as suggested after installation, I get the following traceback... Traceback (most recent call last): File stdin, line 1, in ? File pysqlite2/test/__init__.py, line 25, in ? from pysqlite2.test import dbapi, types, userfunctions, factory, transactions File pysqlite2/test/dbapi.py, line 26, in ? import pysqlite2.dbapi2 as sqlite File pysqlite2/dbapi2.py, line 32, in ? from pysqlite2._sqlite import * ImportError: No module named _sqlite [...] Apparently, you're doing this from the pysqlite sources root directory. So the pysqlite2 directory is tried, which does ont include the compiled C extension module. Execuring from any other working directory on your system should work fine. I'll have to check that this is all properly documented before I do the next pysqlite release. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: WORKAROUND the Python GUI-lib situation ...
wx is also in a far better position for most non-trivial UIs, becuase it has infrastructure that win32 (pretty much alone among modern UI toolkits) lacks, like layout algorithms and i18ln support. Qt has all of this. On all platforms. Just for the record. And layout algorithms - that was something I discovered in tk (using it from tcl, btw) 10 years ago - but my VB experience some years later didn't include that. Maybe that has changed - but the straight VB 6.0 GUI builder certainly encouraged you to use windows UI-units or however these thingies were called. Regards, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: FIR filtering
LabWINC wrote: What's gnuradio? Google dead again? Boy, must be one of these days... Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: FIR filtering
I can't understand how gnuradio can help me... I find scipy is the only way to implement a good FIR. Thanks, Vincent -- http://mail.python.org/mailman/listinfo/python-list
Re: FIR filtering
LabWINC == LabWINC [EMAIL PROTECTED] writes: LabWINC Hi all, i'm looking for a module to implement a digital LabWINC FIR filter! Can anyone help me? scipy.org Between scipy and matplotlib, you'll feel quite comfortable with python as a former matlab user help scipy.filter (see FIR filter design below) DESCRIPTION Signal Processing Tools === Convolution: convolve -- N-dimensional convolution. correlate -- N-dimensional correlation. fftconvolve -- N-dimensional convolution using the FFT. convolve2d-- 2-dimensional convolution (more options). correlate2d -- 2-dimensional correlation (more options). sepfir2d -- Convolve with a 2-D separable FIR filter. B-splines: bspline -- B-spline basis function of order n. gauss_spline -- Gaussian approximation to the B-spline basis function. cspline1d -- Coefficients for 1-D cubic (3rd order) B-spline. qspline1d -- Coefficients for 1-D quadratic (2nd order) B-spline. cspline2d -- Coefficients for 2-D cubic (3rd order) B-spline. qspline2d -- Coefficients for 2-D quadratic (2nd order) B-spline. Filtering: order_filter -- N-dimensional order filter. medfilt -- N-dimensional median filter. medfilt2 -- 2-dimensional median filter (faster). wiener-- N-dimensional wiener filter. symiirorder1 -- 2nd-order IIR filter (cascade of first-order systems). symiirorder2 -- 4th-order IIR filter (cascade of second-order systems). lfilter -- 1-dimensional FIR and IIR digital linear filtering. deconvolve-- 1-d deconvolution using lfilter. hilbert --- Compute the analytic signal of a 1-d signal. get_window--- Create FIR window. detrend --- Remove linear and/or constant trends from data. Filter design: remez -- Optimal FIR filter design. firwin--- Windowed FIR filter design. iirdesign --- IIR filter design given bands and gains iirfilter --- IIR filter design given order and critical frequencies freqs --- Analog filter frequency response freqz --- Digital filter frequency response Matlab-style IIR filter design: butter (buttord) -- Butterworth cheby1 (cheb1ord) -- Chebyshev Type I cheby2 (cheb2ord) -- Chebyshev Type II ellip (ellipord) -- Elliptic (Cauer) bessel-- Bessel (no order selection available -- try butterod) Linear Systems: lti -- linear time invariant system object. lsim -- continuous-time simulation of output to linear system. impulse -- impulse response of linear, time-invariant (LTI) system. step -- step response of continous-time LTI system. LTI Reresentations: tf2zpk -- transfer function to zero-pole-gain. zpk2tf -- zero-pole-gain to transfer function. tf2ss -- transfer function to state-space. ss2tf -- state-pace to transfer function. zpk2ss -- zero-pole-gain to state-space. ss2zpk -- state-space to pole-zero-gain. Waveforms: sawtooth -- Periodic sawtooth square -- Square wave gausspulse -- Gaussian modulated sinusoid chirp -- Frequency swept cosine signal Wavelets: daub -- return low-pass filter for daubechies wavelets qmf -- return quadrature mirror filter from low-pass cascade -- compute scaling function and wavelet from coefficients -- http://mail.python.org/mailman/listinfo/python-list
Re: FIR filtering
LabWINC wrote: I can't understand how gnuradio can help me... I find scipy is the only way to implement a good FIR. Well, then do it with scipy... gnuradio has a module for FIR. I never used it. I just wanted to share that information. Hans Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: WORKAROUND the Python GUI-lib situation ...
On 3/15/06, Diez B. Roggisch [EMAIL PROTECTED] wrote: wx is also in a far better position for most non-trivial UIs, becuase it has infrastructure that win32 (pretty much alone among modern UI toolkits) lacks, like layout algorithms and i18ln support. Qt has all of this. On all platforms. Just for the record. I know - so do almost all other toolkits, but not the win32 API, which is what I was comparing it to. And layout algorithms - that was something I discovered in tk (using it from tcl, btw) 10 years ago - but my VB experience some years later didn't include that. Maybe that has changed - but the straight VB 6.0 GUI builder certainly encouraged you to use windows UI-units or however these thingies were called. Dialog units. But thats a mapping mechanism for scaling dialogs to screen resolution, not a layout mechanism. The traditional mechanism on win32 (VB and otherwise) is to place your controls in absolute (dialog unit) coordinates. If you want to scale with window resizes, you need to do it manually. Even Delphi has better layout support than that! Regards, Diez -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
newbie questions
Hi, I'm just starting out with Python, and so far I am thoroughly impressed with what you can do very easily with the language. I'm coming from a C++ background here. A couple of questions came up as I was thinking about dynamically typed languages: 1. If someone releases an interface in Python, how does the user know what parameters the function takes/returns? 2. If documentation is the answer to 1, then are there any Python documentation standards? 3. Are there any tools out there that can extract the interface information from Python files and release it as documentation like header (.h) files? I know there are tools like this for languages like C#. 4. Really basic question, and I'm sure I will learn this very quickly with more reading, but I'm confused by the lack of an entry point in a Python app, i.e. int main(). Btw, I was turned on to Python from Bruce Eckel's article Strong Typing vs Strong Testing. Thanks, John -- http://mail.python.org/mailman/listinfo/python-list
Re: FIR filtering
Thank you too Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: FIR filtering
LabWINC wrote: It's for research work. I'm implementing an algorithm from a matlab one. It could be very difficult to find the fir coefficients because i have lot of fileters to implement. Oh, you mean you need to find the coefficients, not just implement the FIR filter itself. (Perhaps to some these describe the same thing, but I would call the former designing the filter.) I see John Hunter's post shows scipy probably has what you need. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Printable string for 'self'
Fredrik Lundh wrote: objects don't have names in Python, and the source is not part of the running program. have you read this ? http://effbot.org/zone/python-objects.htm I have now. Thank you very much. objects don't have names in Python: It appears from the code that Michael posted that objects can discover the names that are bound to themselves. Is this true in general? If so, then I guess it does not matter which name I use as long as it is bound to the object. the source is not part of the running program : Ok, but in my case I would have the source that corresponds to the running program available to me and the inspect module does appear to provide enough information for me to find the corresponding piece of the source code. Is there something wrong with using the inspect module for this sort of work? My overall intent is to try to build something that can record interactions against an object so that they can be replayed later for testing and debugging. I had in mind to generate the recording as a sequence of Python statements. I would like to do this without modifying the source of the target class. At the moment this is just a project to help me learn Python, although it would nice if it did yield something useful. Is there anything around that already does this sort of thing? Cheers, Don. -- http://mail.python.org/mailman/listinfo/python-list
Re: Very, Very Green Python User
[EMAIL PROTECTED] wrote: Scott David Daniels wrote: [EMAIL PROTECTED] wrote: ... Is the Python debugger fairly stable? Yes, but it is not massively featured. The Pythonic way is to rarely use a debugger (test first and straightforward code should lead to shallow bugs). Often for most of us judiciously placed print statements suffice. The one you get with Perl stinks on ice. More than anything else, I would like to have a powerful OO environment where I do not have to worry about the debugger sucking Do watch your language on this newsgroup. Lots of people read this group and there is no good reason to offend them. In turn, you will be cut some slack. As one who avidly studies language, I have observed that the meaning of a word slip out of its original context through idiomatic usage. If I had included the implicit object of 'sucks', In fact I elided the ass from your original sucks ass in my original quote, and now you carefully forget it in order to bolster your case. then you would have more grounds for complaint. However, 'sucks', used in the intransitive sense, is no worse than 'bites the bag'. Comp.lang.python is an unusually well-mannered group. If you look at the messages over the past year (and exclude any chain with Xah Lee), I think you will find your language, while not obscene, was well below the standard for the newsgroup. Some of us value that, and are happy enough to leave it to other groups to express themselves more fervently. Here you'll find even strong disagreement is usually expressed with a careful consideration that the other person may well get offended. By the by, you will notice I did not simply chide you about your use of language, but rather answered your questions as best I understood them. Don't worry, this is the last I have to say on the subject. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: FIR filtering
I'm interested in finding coefficient and implementig the filter as well. John's post is what i need. John Hunter wrote: help scipy.filter (see FIR filter design below) How can i get the help like yours? If i type help scipy.filter it give me an error help scipy.filter File input, line 1 help scipy.filter ^ SyntaxError: invalid syntax I'm sorry but i'm new of python, Vincent -- http://mail.python.org/mailman/listinfo/python-list
Re: WORKAROUND the Python GUI-lib situation ...
a far better position for most non-trivial UIs, becuase it has infrastructure that win32 (pretty much alone among modern UI toolkits) lacks, like layout algorithms and i18ln support. Qt has all of this. On all platforms. Just for the record. I know - so do almost all other toolkits, but not the win32 API, which is what I was comparing it to. Ah, I misread your statement as win32 _having_ layout algorithms. Dialog units. But thats a mapping mechanism for scaling dialogs to screen resolution, not a layout mechanism. The traditional mechanism on win32 (VB and otherwise) is to place your controls in absolute (dialog unit) coordinates. If you want to scale with window resizes, you need to do it manually. Even Delphi has better layout support than that! Yes - and as I knew tk when first seing win32, I thought of it being archaic. Sorry for the confusion, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing PySQLite on OS X 10.4
Gerhard Häring wrote: Rob Cowie wrote: [...] However, if I do from pysqlite2 import test as suggested after installation, I get the following traceback... Traceback (most recent call last): File stdin, line 1, in ? File pysqlite2/test/__init__.py, line 25, in ? from pysqlite2.test import dbapi, types, userfunctions, factory, transactions File pysqlite2/test/dbapi.py, line 26, in ? import pysqlite2.dbapi2 as sqlite File pysqlite2/dbapi2.py, line 32, in ? from pysqlite2._sqlite import * ImportError: No module named _sqlite [...] Apparently, you're doing this from the pysqlite sources root directory. So the pysqlite2 directory is tried, which does ont include the compiled C extension module. Execuring from any other working directory on your system should work fine. I'll have to check that this is all properly documented before I do the next pysqlite release. -- Gerhard Thanks however, now when I try from pysqlite2 import test it results in: Traceback (most recent call last): File stdin, line 1, in ? File build/bdist.darwin-8.5.0-Power_Macintosh/egg/pysqlite2/test/__init__.py, line 25, in ? File build/bdist.darwin-8.5.0-Power_Macintosh/egg/pysqlite2/test/dbapi.py, line 26, in ? File build/bdist.darwin-8.5.0-Power_Macintosh/egg/pysqlite2/dbapi2.py, line 32, in ? File build/bdist.darwin-8.5.0-Power_Macintosh/egg/pysqlite2/_sqlite.py, line 7, in ? File build/bdist.darwin-8.5.0-Power_Macintosh/egg/pysqlite2/_sqlite.py, line 6, in __bootstrap__ ImportError: dlopen(/Users/rob/.python-eggs/pysqlite-2.1.3-py2.3-macosx-10.4-ppc.egg-tmp/pysqlite2/_sqlite.so, 2): Symbol not found: _sqlite3_transfer_bindings Referenced from: /Users/rob/.python-eggs/pysqlite-2.1.3-py2.3-macosx-10.4-ppc.egg-tmp/pysqlite2/_sqlite.so Expected in: dynamic lookup I now suspect that this may all be down to the version of sqlite3 installed as part of OS X 10.4. Some people report success when using this version with pysqlite, others report failure. -- http://mail.python.org/mailman/listinfo/python-list
Re: WORKAROUND the Python GUI-lib situation ...
Chris Mellon wrote: win32gui and wxPython use *exactly* the same controls in almost all (win32ui or win32gui? the later is almost only a better ctypes replacement ) cases. If you're seeing something donald duck then you're either doing something wrong, or you're using a custom control. wx is also in a far better position for most non-trivial UIs, becuase it has infrastructure that win32 (pretty much alone among modern UI toolkits) lacks, like layout algorithms and i18ln support. Yes, wx is of course fat. But I guess things like a layout algorithm ? is done very quickly in a clean Python only lib. I can just imagine ... Testing the latest wx and Boa last week (for py2.3) it hit the high-score: All other old win32api/ui apps - just by starting them - press magically buttons themslef, raise this and that. Never saw such behaviour. wx modified something in the libraries. There were new Windows ctrl-libs in the main Python folder after wx-install (which I never requested/allowed). But even removing them did not heal the ghostly behavor of normal win32 apps not having anything to do with wx. Only after uninstalling wx boa win32 was stable again... I dont know where you get your wx libs from, or what press magically buttons themself means, but the official wx installer doesn't do any of this. Whatever you saw had nothing to do with wx. that last test was with py2.3.5 / pywin32 205 / wxPython2.6-win32-ansi-2.6.2.1-py23.exe then run a few dialog examples of win32 and the dance begins. There are some other (open) things like PyFltk and worse ... In my opinion the overall situation of Python GUI's (platform independent) is not in line with and not up to the level of the wonderful language itself and to its stability. There is always a fragile TCL or XY-C++ or MFC or this and that in the middle - and I can't believe, that it is necessary. Python is a best OO language for GUI programming also and it should glue soon to OS-libs (win32api/gui../ctypes , gtk, ...) . I'd believe there is still room for a relly good, platform independent speedy, flat, python-only OO GUI library - which loads modules with discipline into memory, allows building distributables below 2MB, Python all by itself is bigger than this unless you totally gut the standard library, and even then it's just barely under 2MB. ??? This 2-liner hello world 1.py with win32ui(=MFC) of this thread with py2exe / cx_freeze / py2.3 / win32ui 205 is all compressed 869kB , or even 700 kB with upx7zip. A quite big app (upx'ed) with win32ui, ssl, enc., unicode and all .. app.zip 683 kB app.exe 8 kB _socket.pyd 16 kB _sre.pyd 18 kB _ssl.pyd 192 kB _winreg.pyd 11 kB datetime.pyd 17 kB pywintypes23.dll 39 kB unicodedata.pyd 167 kB w9xpopen.exe 3 kB win32api.pyd 21 kB win32clipboard.pyd 6 kB win32gui.pyd 25 kB win32help.pyd 11 kB win32task.dll 21 kB win32ui.pyd 156 kB zlib.pyd 23 kB AES.pyd 13 kB Blowfish.pyd 11 kB DES3.pyd 9 kB select.pyd 5 kB python23.dll 361 kB .. is not more than 1700kB. That competes with Delphi. A real Python OO GUI lib would be similar in size, maybe even smaller. you'd hardly get more than 2MB (without docs) after all compressions. Python first should maybe have a real Python GUI toolkit and unite the OS'es directly - as good as it does for the os module ? Even a minimal GUI toolkit is an order of magnitude more complicated than the os module. Of course its some effort, but with Python you code very very fast. Once a basic OO message handling system is wired and the first commctrls of Windows are covered and resembled on the other systems, things would go very fast. Resembling indispensable things of MFC/wx like tool/statusbars, docking windows, ... can also be coded quickly with a clean python GUI system. And soon first professional apps could be built ... the more I think about it Most effort would be to have a mature, compatible event system. wx learned it anyway from Windows (WM_ - EVT_ ) and resembled it more on Linux, etc. That would be principally ok here too, as Windows is quite good in this (despite the rest of the OS). One could steal a few principles, abstract algs. and even names in less time than gluing the fragile C++. Robert -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie questions
meeper34 wrote: Hi, I'm just starting out with Python, and so far I am thoroughly impressed with what you can do very easily with the language. I'm coming from a C++ background here. A couple of questions came up as I was thinking about dynamically typed languages: 1. If someone releases an interface in Python, how does the user know what parameters the function takes/returns? 2. If documentation is the answer to 1, then are there any Python documentation standards? 3. Are there any tools out there that can extract the interface information from Python files and release it as documentation like header (.h) files? I know there are tools like this for languages like C#. epydoc: http://epydoc.sourceforge.net/ is used by a bunch of people - including me. The documentation it produces is far from a header file, typically it is in HTML (although other output formats are available) but I find it does. 4. Really basic question, and I'm sure I will learn this very quickly with more reading, but I'm confused by the lack of an entry point in a Python app, i.e. int main(). There is some idiom for this. def main(*args, **kw): # do stuff pass if __name__ == '__main__': # call main, perhaps with sys.argv main() You put this at the bottom of the file you want to run. The __name__ property will be '__main__' iff you have executed the file from the command line. In particular the code in the if __name__... block won't be run if you just import the file. All the best, Keir. Btw, I was turned on to Python from Bruce Eckel's article Strong Typing vs Strong Testing. Thanks, John -- http://mail.python.org/mailman/listinfo/python-list
Re: global, globals(), _global ?
robert [EMAIL PROTECTED] wrote: ... ( And that later scheme is fairly wonderful - compare for example the namespace fuzz in C/C++, Pascal, Ruby, ... where you never know which module file addeds what to which namespace; Pascal (per se) doesn't really have much by the way of namespaces (alas). C++ (per se) does, with zap::zop=23 being rather unambiguous (C compatibility and using namespace zap can muddy it up, but that's like saying, e.g., that from zap import * muddies things up in Python: true, but the obvious solution in both cases is just don't do it;-). Sure, any C++ or Ruby soure file can reopen a namespace or class, respectifely -- but how's that different from Python's anothermodule.zop=23? It's much of a muchness. In Ruby they even scribble from anywhere to _any_ class _and_ any namespace without the barrier of a dot or subclassing or anything - using somehow by random the same name already joins!? A threat for good modularization of code. Not far from free flat memory programming :-) Don't know how they keep bigger projects managable in this language. Uh? I don't see what you mean -- in Ruby, an assignment can be clearly situated regarding what namespace it affects. The only example of using somehow by random the same name I can think of is within a block, where (e.g.) 'a=2' sets a new block-local name _unless_ 'a' was previously used within the lexically enclosing method, in which case it resets said method's 'a', but while unpleasant that's a fairly localized problem. Maybe you can give some examples? Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: global, globals(), _global ?
robert [EMAIL PROTECTED] wrote: Using global variables in Python often raises chaos. Other languages use a clear prefix for globals. Ruby does ($ means global), but, what other languages? Perl, C, C++, Java (taking a class's statics as Java's equivalent of other languages' globals), etc, etc, all use the same lexical form for identifiers whether local or global, disambiguating in other ways, not by a clear prefix ('my' in Perl to declare locals, sort of like 'global' in Python to declare globals, just with the default the other way 'round, etc). Can you please explain what you mean here? Anyway, I'd LOVE expunging the hated 'global' in favour of an explicit namespace (and another one for free variables in containing functions for closures), but while this gets often proposed in python-dev, Guido is apparently never going to approve such a change (even in Py3k where backwards compatibility could be broken), so I've given up on it. Alex -- http://mail.python.org/mailman/listinfo/python-list