Re: yet another noob question

2006-08-13 Thread Rene Pijlman
mike_wilson1333: I would like to generate every unique combination of numbers 1-5 in a 5 digit number [...] What would be the best way to do this? Ask the Java newsgroup to design a clever algorithm and post it here for pythonification. Ask for the pseudocode, not the Java code. -- René

Re: yet another noob question

2006-08-13 Thread Rene Pijlman
Stargaming: Generally, it is range(1, 5) Minus all numbers whose decimal string representation matches [0-9]*[06-9][0-9]* Briljant! -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib (in thread) never returns

2006-07-17 Thread Rene Pijlman
Kingsley: it just sits in either the urlopen() or read() forever. [...] I would have thought that some urllib-internal timeout would fix this?! Yes, but you'll need to enable it. See socket.setdefaulttimeout() : http://docs.python.org/lib/module-socket.html -- René Pijlman --

Re: classes and interfaces

2006-07-02 Thread Rene Pijlman
[EMAIL PROTECTED]: In python , how to implement interface like the above? Interfaces are lacking in Python, but an even more generic proposal is on its way: http://www.artima.com/weblogs/viewpost.jsp?thread=155123 In the mean time, interfaces have already been implemented in Zope 3:

Re: classes and interfaces

2006-07-02 Thread Rene Pijlman
Bruno Desthuilliers: Java interfaces are a workaround Troll alert. -- http://mail.python.org/mailman/listinfo/python-list

Re: Program slowing down with greater memory use

2006-06-23 Thread Rene Pijlman
Dan Stromberg: What's the deal here? The sketchy information in your post doesn't rule out any possibility. -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: An error ?

2006-06-12 Thread Rene Pijlman
Bo Yang: [Fri Jun 16 14:06:45 2006] [error] [client 10.10.110.17] malformed header from script. Bad header=Hello World!: a.py The output of a CGI script should consist of two sections, separated by a blank line. The first section contains a number of headers, telling the client what kind of data

Re: Using PHP in Python

2006-06-12 Thread Rene Pijlman
Tgone: I have some custom PHP functions that I didn't want to re-write in Python. But maybe I should just rewrite them :) Absolutely. The alternative is one of many IPC mechanisms that are available in both Python and PHP (such as XML-RPC). But that may require more effort than rewriting the

Re: CENSORSHIP - Django Project (Schema Evolution Support)

2006-06-07 Thread Rene Pijlman
Ilias Lazaridis: What is the credibility and value of the provided wikipedia entry? Wikipedia always tells the Absolute Truth, because if it doesn't, we can edit it and fix it right away. -- http://mail.python.org/mailman/listinfo/python-list

Re: Writing to a certain line?

2006-06-06 Thread Rene Pijlman
Tommy B: I was wondering if there was a way to take a txt file and, while keeping most of it, replace only one line. You'd need to read the file and parse it, to find the start position of the line you want to change. Then seek output to that position and write and flush the changes. You must

Re: Writing to a certain line?

2006-06-06 Thread Rene Pijlman
bruno at modulix: You can't do this in place with a text file (would be possible with a fixed-length binary format). More precise: it's possible with any fixed-length change, in both binary and text files, with both fixed and variable formats. -- René Pijlman --

Re: 10GB XML Blows out Memory, Suggestions?

2006-06-06 Thread Rene Pijlman
[EMAIL PROTECTED]: I wrote a program that takes an XML file into memory using Minidom. I found out that the XML document is 10gb. I clearly need SAX or something else? Any suggestions on what that something else is? PullDOM. http://www-128.ibm.com/developerworks/xml/library/x-tipulldom.html

Re: Python to C converter

2006-06-05 Thread Rene Pijlman
[EMAIL PROTECTED]: I have an application return in python. I want this to be converted to C. http://www.python.org/doc/faq/general/#can-python-be-compiled-to-machine-code-c-or-some-other-language -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: beginner code problem

2006-06-02 Thread Rene Pijlman
RJ: import random flip = random.randrange(2) heads = 0 tails = 0 count = 0 while count 100: if flip == 0: heads += 1 else: tails += 1 count += 1 Since flip isn't changed in the loop, this is going to report 100 heads or 100 tails, depending on

Re: what is the reasonable (best?) Exception handling strategy?

2006-06-01 Thread Rene Pijlman
Petr Jakes: What about unexpected exceptions? :( I asked a similar question some time ago: http://groups.google.nl/group/comp.lang.python/browse_thread/thread/25963b99da4b2653 -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: Zope / Plone Groups

2006-06-01 Thread Rene Pijlman
[EMAIL PROTECTED]: are there any specific groups for zope / plone regarding questions? Try plone-users: http://plone.org/support -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: HTMLParser chokes on bad end tag in comment

2006-05-29 Thread Rene Pijlman
Fredrik Lundh: Rene Pijlman: [end tag in html comment in script element] The end tag it chokes on is in comment, isn't it? no. STYLE and SCRIPT elements contain character data, not parsed character data, so comments are treated as characters, and the first / ends the element. Ah, I see. I'll

Re: HTMLParser chokes on bad end tag in comment

2006-05-29 Thread Rene Pijlman
Miki: You can also check out BeautifulSoup (http://www.crummy.com/software/BeautifulSoup/) which is less strict than the regular HTML parser. Yes, thanks. Ik this case it was my sitechecker which checks for syntax and broken links, so it was supposed to find the syntax error. BeautifulSoup is not

HTMLParser chokes on bad end tag in comment

2006-05-28 Thread Rene Pijlman
The code below results in an exception (Python 2.4.2): HTMLParser.HTMLParseError: bad end tag: /foo' + 'bar, at line 4, column 6 Should it? The end tag it chokes on is in comment, isn't it? import HTMLParser HTMLParser.HTMLParser().feed( htmlheadtitle/title/headbodyscript !-- x = '/foo' + 'bar'

Re: why not in python 2.4.3

2006-05-28 Thread Rene Pijlman
Rocco: but does not work with 2.4.3. Define does not work. -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: Upgrading Class Instances Automatically on Reload

2006-05-09 Thread Rene Pijlman
malv: Did anybody get this recipe to work? Did you? -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: Upgrading Class Instances Automatically on Reload

2006-05-09 Thread Rene Pijlman
malv: At the statement b = Bar(), the following error occurs: The debugged program raised the exception unhandled AttributeError type object 'Bar' has no attribute '__instance_refs__' I haven't studied it at all, but the code on http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/160164 seems

Re: Can Python installation be as clean as PHP?

2006-05-09 Thread Rene Pijlman
Jack: I have to run the installer to install dozens of directories and hundreds of files, That's not unusual and not considered a problem by most people. and I don't really know if all of them are necessary. Don't let that bother you. Life's too short. Plus, lots of libraries are in .py,

Re: Getting HTTP responses - a python linkchecking script.

2006-05-08 Thread Rene Pijlman
[EMAIL PROTECTED]: with urllib2 it doesn't seem possible to get HTTP status codes. except urllib2.HTTPError, e: if e.code == 403: -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting HTTP responses - a python linkchecking script.

2006-05-08 Thread Rene Pijlman
[EMAIL PROTECTED]: Rene Pijlman wrote: [EMAIL PROTECTED]: with urllib2 it doesn't seem possible to get HTTP status codes. except urllib2.HTTPError, e: if e.code == 403: Thanks. Is there documentation for this available somewhere online, I can't see it to obviously

Re: PYTHONPATH vs PATH?

2006-05-08 Thread Rene Pijlman
Fredrik Lundh: PATH is used by the operating system to find executables, and PYTHONPATH is used by Python to find Python modules. Yes, but Python also finds modules in its own installation. So changing PATH may cause another installation of Python to be run, which may have some other set of

Re: ascii to latin1

2006-05-08 Thread Rene Pijlman
Luis P. Mendes: I'm developing a django based intranet web server that has a search page. Data contained in the database is mixed. Some of the words are accented, some are not but they should be. This is because the collection of data began a long time ago when ascii was the only way to go.

Re: data regex match

2006-05-02 Thread Rene Pijlman
Gary Wessle: tx = now 04/30/2006 then data = re.compile('(\d{2})/\1/\1\1', re.IGNORECASE) d = data.search(tx) print d Nono I was expecting 04/30/2006 You should expect: NameError: name 're' is not defined what went wrong? \1 matches the content of the first group, which is '04'. It doesn't

Re: setting file permissions on a web server

2006-04-30 Thread Rene Pijlman
John Salerno: I always read about how you need to set certain file permissions (for cgi files, for example), but it's never been clear to me *how* you do this. I know you can run the line chmod 755 scriptname.py but *where* do you run this? This is a Unix/Linux command. You run it in a shell

Re: Python member of function

2006-04-29 Thread Rene Pijlman
[EMAIL PROTECTED]: I was wondering if anyone knew of a built in Python function that will check if an item is a member of a list, i.e., if item i is a member of list l. 1 in [1,3,4] True 2 in [1,3,4] False -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: begging for a tree implementation

2006-04-27 Thread Rene Pijlman
Micah: I'd like a full-featured tree What features? -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: OOP / language design question

2006-04-25 Thread Rene Pijlman
[EMAIL PROTECTED]: I was wondering, why you always have to remember to call bases' constructors explicitly from the derived class constructor? Why hasn't this been enforced by the language? Probably because the language doesn't know whether the subclass wants to override its base class's

Re: OOP / language design question

2006-04-25 Thread Rene Pijlman
[EMAIL PROTECTED]: I think I'll need some shift in thinking after C++. +1 qotw -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: Zope 3

2006-04-25 Thread Rene Pijlman
Steve Juranich: is there some big master diff, along the lines of What's new in Python X.X that I could look at to get an idea of what z3 has that 2.9 (which I'm currently still cutting my teeth on) doesn't? It's a redesign. Z2: mixin base classes Z3: component architecture with interfaces

Re: threads and sys.exit()

2006-04-24 Thread Rene Pijlman
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?

2006-04-24 Thread Rene Pijlman
[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

Re: need a thread to keep a socket connection alive?

2006-04-22 Thread Rene Pijlman
[EMAIL PROTECTED]: i have a script that waits for message packets from a data server over a socket. Using what network protocol? 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. [...] should i do this with

Re: problems when unpacking tuple ...

2006-04-22 Thread Rene Pijlman
harold: The output (when given the data I want to parse) is: If you'd told us that data, and told us what version of Python you're using, we could have reproduced the problem to look into it. ValueError: need more than 3 values to unpack Why does python think that I want to unpack the outcome

Re: problems when unpacking tuple ...

2006-04-22 Thread Rene Pijlman
harold: A similar error happens in an interpreter session, when typing for line in [1 2 3 4] : ...for a,b,c,d in line.split() : ...pass ... Traceback (most recent call last): File stdin, line 2, in ? ValueError: need more than 1 value tyo unpack maybe this might help to track down

Re: Read and extract text from pdf

2006-04-21 Thread Rene Pijlman
Julien ARNOUX: I have a problem :), I just want to extract text from pdf file with python. There is differents libraries for that but it doesn't work... pyPdf and pdfTools, I don't know why but it doesn't works with some pdf... Text can be represented in different ways in PDF: as tagged text,

Re: Uniquifying a list?

2006-04-19 Thread Rene Pijlman
Tim Chase: Is there an obvious/pythonic way to remove duplicates from a list (resulting order doesn't matter, Use a set. http://www.python.org/doc/lib/types-set.html -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: Missing interfaces in Python...

2006-04-19 Thread Rene Pijlman
Kay Schluehr: You won't find many deep class hierarchies and extensive frameworks. Zope comes to mind. This has the advantage that a classification you have done once at the beginning of your project in the design phase is not considered to be carved in stone. Zope 3 comes to mind. --

Re: Missing interfaces in Python...

2006-04-19 Thread Rene Pijlman
Alex Martelli: PEAK is an interesting counterexample, particularly since Philip Eby tends to be ahead of the curve: I never noticed PEAK before. Is it well worth studying? -- http://mail.python.org/mailman/listinfo/python-list

Re: Missing interfaces in Python...

2006-04-19 Thread Rene Pijlman
Neal Becker: 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? A programming language doesn't

Re: Missing interfaces in Python...

2006-04-18 Thread Rene Pijlman
[EMAIL PROTECTED]: If it looks like a duck, and quacks like a duck, then for all practical purposes it supports the 'duck' interface. The problem with that of course, is that there's much more to being a duck than being called 'duck'. public interface JarFile { void explode(); } public

Re: sending email with charset utf-8 but subject is not coded properly

2006-04-14 Thread Rene Pijlman
Grzegorz ¦lusarek: I sending email using standard python modules smtplib, email, coding email in utf but subject of message is not coded properly. In subject i use my national characters (polish) and after send i get XX in place these characters. Here is the code Message =

Re: List of all syntactic sugar?

2006-04-14 Thread Rene Pijlman
Bas: just out of curiosity, is there a list of all the syntactic sugar that is used in python? http://docs.python.org/ref/specialnames.html -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: Characters contain themselves?

2006-04-07 Thread Rene Pijlman
WENDUM Denis 47.76.11 (agent): While testing recursive algoritms dealing with generic lists I stumbled on infinite loops which were triggered by the fact that (at least for my version of Pyton) characters contain themselves. No, strings contain characters. And 'a' is a string consisting of one

Re: FTP

2006-04-07 Thread Rene Pijlman
Arne: I want to connecto to a ftp server. There I woult like to read the directiroy and getting the filename, file owner and the file size. How can I do this in python http://docs.python.org/lib/module-ftplib.html -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: HTMLParser fragility

2006-04-05 Thread Rene Pijlman
Lawrence D'Oliveiro: I've been using HTMLParser to scrape Web sites. The trouble with this is, there's a lot of malformed HTML out there. Real browsers have to be written to cope gracefully with this, but HTMLParser does not. There are two solutions to this: 1. Tidy the source before parsing

Re: socket connetion to url with port 80

2006-04-04 Thread Rene Pijlman
Sakcee: how can i get page response from a site e.g. google.com port 80 [...] can i do at socket level? Yes, but you'll need to implement HTTP: http://www.ietf.org/rfc/rfc2616.txt -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: Pickle or Mysql

2006-03-31 Thread Rene Pijlman
[EMAIL PROTECTED]: Can I use Pickle to store about 500,000 key value pairs.. Performance would be horrible. Use a BTree in ZODB instead: http://www.zope.org/Wikis/ZODB/guide/node6.html#SECTION00063 or should I use mySql. You should use a relational database, such as PostgreSQL,

Re: instance and class-hierarchy ?

2006-03-29 Thread Rene Pijlman
Bror Johansson: I have a class-hierarchy (fairly deep and fairly wide). Is there a good and general way to test an instance-object obj for having a class belonging to a certain sub-tree of the hierarchy with a common parent class C? isinstance(obj,C) -- René Pijlman --

Re: trying to use popen2() to communicate with C program

2006-03-28 Thread Rene Pijlman
I. Myself: I can't get this to work With what versions of what software on what platform? -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between 'is' and '=='

2006-03-27 Thread Rene Pijlman
mwql: Hey guys, this maybe a stupid question, but I can't seem to find the result anywhere online. When is the right time to use 'is' and when should we use '=='? http://docs.python.org/ref/comparisons.html -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between 'is' and '=='

2006-03-27 Thread Rene Pijlman
Terry Reedy: The Python specification allows but does not require such behind-the-scenes implementation optimization hacks. As released, CPython 2.4 caches -5 to 99, I believe. In 2.5, the upper limit was increased to 256. The limits are in a pair of #define statements in the int object

Re: Module documentation

2006-03-26 Thread Rene Pijlman
Tony Burrows: With something like Java I can find the syntax of a method call with no problems, how do I do the same with Python? The basic syntax is just the name, with parameters in brakcets: object.method(par1, par2, ...) This is explained in the documentation, of course. how do I find

Re: Cookbook for beginners?

2006-03-26 Thread Rene Pijlman
Aahz: If you were going to name three or five essential recipes from the Python Cookbook suitable for beginners, what would you pick? Yes, this is for _Python for Dummies_, so idioms that aren't in the Cookbook are also fine. Constants Static methods / Class methods Bunch TaskQueue (Queue for

Re: OT: unix newbie questions

2006-03-25 Thread Rene Pijlman
Gerard Flanagan: * To create an empty __init__.py file I do 'vim __init__.py' then immediately exit vim, is there a shell or vim command which will create an empty file without opening the editor? touch __init__.py * cd ~ brings me to my home directory, is there a means by which I can set up a

Re: Good thread pool module

2006-03-23 Thread Rene Pijlman
Dennis Lee Bieber: Raymond Hettinger: Because of the GIL, thread pools are not as useful in Python as you might expect -- they execute one at a time and do not take advantage of hyper-threading or multiple processors. If that kind of efficiency is If the task is I/O bound (something

Re: Confused: appending to a list

2006-03-23 Thread Rene Pijlman
DataSmash: I'm confused. Why is it that when I say while len(list) 5:, I get 5 items in my list. Because the last time when len(list) was 5, the block of code following the while executed and did something to the list to give it a length = 5 (otherwise the block of code would be executed again

Re: COM Client / Server creation?

2006-03-22 Thread Rene Pijlman
Dan: New to python. Running under windows xp. Need help getting started writing COM server and client. Highly recommended: http://safari.oreilly.com/?XmlId=1-56592-621-8 -- http://mail.python.org/mailman/listinfo/python-list

Re: TaskQueue

2006-03-21 Thread Rene Pijlman
Raymond Hettinger: There are some competing approaches. One is to attach sentinel objects to the end of the line as a way for consumer threads to know that they should shut down. Then a regular t.join() can be used to block until the consumers threads have shut-down. This approach is

Re: TaskQueue

2006-03-21 Thread Rene Pijlman
Carl Banks: Rene Pijlman: for i in range(self.numberOfThreads): self.workQueue.put(None) Or, you could just put one sentinel in the Queue, and subclass the Queue's _get method not to take the sentinel out. Ah yes, clever trick. But you'd have to worry about thread-safety

Re: How can I compare if 2 files has duplicate entries in python?

2006-03-21 Thread Rene Pijlman
[EMAIL PROTECTED]: I am new to python. How can I compare if 2 files has duplicate entries in python? What is an 'entry'? -- René Pijlman Wat wil jij leren? http://www.leren.nl -- http://mail.python.org/mailman/listinfo/python-list

Re: Can XML-RPC performance be improved?

2006-03-21 Thread Rene Pijlman
Sion Arrowsmith: I've got an established client-server application here where there is now a need to shovel huge amounts of data (structured as lists of lists) between the two, and the performance bottleneck has become the amount of time spent parsing XML http://xmlsucks.org/ Anyone got any good

Re: TaskQueue

2006-03-21 Thread Rene Pijlman
Carl Banks: Rene Pijlman: Ah yes, clever trick. But you'd have to worry about thread-safety of your subclass though. Queue worries about this for you. The Queue class only calls _get when it has the queue's mutex, so you can assume thread safety when subclassing it. Ah yes, I overlooked

Re: Keeping a function from taking to long--threads?

2006-03-20 Thread Rene Pijlman
[EMAIL PROTECTED]: I'm using windows, and from what I've tried, the setdefaulttimeout function doesn't work on my machine. It should. It does on mine. -- René Pijlman Wat wil jij leren? http://www.leren.nl -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there such an idiom?

2006-03-19 Thread Rene Pijlman
Per: how to find whether there is/are common item(s) between two list in linear-time? To find items in common between two lists, make the first into a dictionary and then look for items in the second in it. -- René Pijlman Wat wil jij leren? http://www.leren.nl --

Re: Keeping a function from taking to long--threads?

2006-03-19 Thread Rene Pijlman
[EMAIL PROTECTED]: Just wondering if anyone knows of a way to keep a function, E.g. socket.gethostbyaddr(12.34.56.78), From taking to long-if it's run for more than 1 second, the function gethostbyaddr will be terminated? import socket socket.setdefaulttimeout(1) -- René Pijlman Wat wil jij

Re: Need design advice. What's my best approach for storing this data?

2006-03-17 Thread Rene Pijlman
Mudcat: My initial thought was to put the data in large dictionaries and shelve them (and possibly zipping them to save storage space until the data is needed). However, these are huge files. ZODB solves that problem for you. http://www.zope.org/Wikis/ZODB/FrontPage More in particular 5.3 BTrees

Re: Queue limitations?

2006-03-15 Thread Rene Pijlman
[EMAIL PROTECTED]: I'm using Queue to send images from one thread to another, and some of the images are not appearing in the consumer threadmaybe 1 in 3 arrive. I find that hard to believe. Could there be a bug in your program, somewhere, somehow? -- René Pijlman --

Re: Python compiler

2006-03-15 Thread Rene Pijlman
Rc: My question is where can I find a compiler for free. For Windows XP. http://www.python.org/download/ -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: calling another python file within python

2006-03-14 Thread Rene Pijlman
Kevin: #!/usr/bin/python import os import urllib os.system(python pyq.py ibm text1.txt) Check the return value of os.system. note: currently the text1.txt outputted is just blank, however if i run the command normally as 'python pyq.py ibm' in the command line, it works correctly and gives

Re: Python Debugger / IDE ??

2006-03-14 Thread Rene Pijlman
[EMAIL PROTECTED]: 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. Here's a recent thread about IDEs: http://groups.google.nl/group/comp.lang.python/browse_frm/thread/fd9604e225252ad4 -- René

Re: Python IDE: great headache....

2006-03-11 Thread Rene Pijlman
Sullivan WxPyQtKinter: I hope that an IDE should be featured with: I use WingIDE 2.1.0 (beta1) and I'm pleased with it. 1. Grammar Colored highlights. Yes, Wing does that. 2. Manage project in a tree view or something alike, ie, a project file navigator. Yes. 3. Code collapse and folding.

Re: urlerror, urllib2: no address ... why or debug tips?

2006-03-10 Thread Rene Pijlman
[EMAIL PROTECTED]: Help please with a URLError. Post your code (a small self-contained example, preferrably) and the URL. -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: how to validate a proxy is alive?

2006-03-10 Thread Rene Pijlman
JuHui: If a proxy is alive then return true, else return fals after 1 second. What kind of proxy? Design pattern? Protocol? Which one? -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: Use python to process XML file

2006-03-10 Thread Rene Pijlman
[EMAIL PROTECTED]: Can you please tell me how Use python to process XML file? The example I find is build a DOM, but I just need to do it in SAX based, how can I do that? http://docs.python.org/lib/module-xml.sax.html http://pyxml.sourceforge.net/topics/howto/section-SAX.html -- René Pijlman --

Re: accessors and lazy initialization

2006-03-10 Thread Rene Pijlman
Bill: In general I try to initialize the state of my objects as late as possible, in the accessor. [...] Is there a more Pythonic way of looking at this? http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/131495 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/363602 -- René Pijlman

Re: Confused by Method(function) of a module and method of a class/instance

2006-03-07 Thread Rene Pijlman
Sullivan WxPyQtKinter: Why do the three expression yield the same result abc? Because all three converted ABC to lowercase, as per your request. -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: linux clipboard?

2006-03-07 Thread Rene Pijlman
[EMAIL PROTECTED]: how can i copy text to the linux clipboard? Linux is an operating system. It doesn't have a clipboard. The clipboard is provided by desktop frameworks, such as KDE or Gnome. -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: automatic referencing for variables?

2006-03-06 Thread Rene Pijlman
[EMAIL PROTECTED]: can you do something like that in python? All you did is show us some string literals, but I guess you're looking for string substitution: http://docs.python.org/lib/typesseq-strings.html This can be simplified, they say:

Re: How to except the unexpected?

2006-03-05 Thread Rene Pijlman
Steven D'Aprano: The OP is doing it because catching all exceptions masks bugs. There are certain exceptions which should be allowed through, as they indicate a bug in the OP's code. Normally the tactic is to catch only the exceptions you are interested in, and let everything else through, but the

Re: dual CPU-mode in python

2006-03-05 Thread Rene Pijlman
Astan Chee: I was wondering if there is a way to maximize CPU usage Fork a Java app :-) -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: How to except the unexpected?

2006-03-04 Thread Rene Pijlman
Roy Smith: I like to create a top-level exception class to encompass all the possible errors in a given module, then subclass that. This way, if you want to catch anything to goes wrong in a call, you can catch the top-level exception class without having to enumerate them all. What do you

Re: How to except the unexpected?

2006-03-04 Thread Rene Pijlman
James Stroud: Which suggests that try: except HTTPException: will be specific enough as a catchall for this module. The following, then, should catch everything you mentioned except the socket timeout: Your conclusion may be (almost) right in this case. I just don't like this approach.

Re: How to except the unexpected?

2006-03-04 Thread Rene Pijlman
Peter Hansen: Good code should probably have a very small set of real exception handling cases, and one or two catchalls at a higher level to avoid barfing a traceback at the user. Good point. A catchall seems like a bad idea, since it also catches AttributeErrors and other bugs in the

Re: How to except the unexpected?

2006-03-04 Thread Rene Pijlman
Paul Rubin http://[EMAIL PROTECTED]: We have to get Knuth using Python. Perhaps a MIX emulator and running TeXDoctest on his books will convince him.. -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: How to except the unexpected?

2006-03-04 Thread Rene Pijlman
Steven D'Aprano: ExpectedErrors = (URLError, IOError) ErrorsThatCantHappen = try: process_things() except ExpectedErrors: recover_from_error_gracefully() except ErrorsThatCantHappen: print Congratulations! You have found a program bug! print For a $327.68 reward, please send the

Re: How to except the unexpected?

2006-03-04 Thread Rene Pijlman
Jorge Godoy: Rene Pijlman: my app was surprised by an httplib.InvalidURL since I hadn't noticed this could be raised by robotparser (this is undocumented). It isn't undocumented in my module. From 'pydoc httplib': That's cheating: pydoc is reading the source :-) What I meant was, I'm

Re: How to except the unexpected?

2006-03-04 Thread Rene Pijlman
Roy Smith: In theory, all exceptions which represent problems with the external environment (rather than programming mistakes) should derive from Exception, but not from StandardError. Are you sure? The class hierarchy for built-in exceptions is: Exception +-- StandardError |

Re: sockets, where can I find documentation?

2006-03-03 Thread Rene Pijlman
John Pote: I want to use python on a server to access incoming TCP port accesses. So I need to use the socket interface which is new to me. You may also want to look at Twisted: http://twistedmatrix.com/trac/ Where can I get the various papers mentioned in the manual? And as I like books

Re: socket freezes

2006-03-03 Thread Rene Pijlman
Luis P. Mendes: I've developed a program that uses a socket to receive information 24h a ~ day. The problem is that the socket seems to freeze. By that I mean the program stops getting information but doesn't raise any error. That's weird. There's probably a bug in your program. I tried to

How to except the unexpected?

2006-03-03 Thread Rene Pijlman
One of the things I dislike about Java is the need to declare exceptions as part of an interface or class definition. But perhaps Java got this right... I've writen an application that uses urllib2, urlparse, robotparser and some other modules in the battery pack. One day my app failed with an

Re: Threading - will threads run in parallel?

2006-02-28 Thread Rene Pijlman
SolaFide: (get() is a function which waits for a ping on a specific port, thus stopping the program for a while.) Will these run together, Thread 2 can run while thread 1 is blocked for I/O and v.v. Also, is it possible to split off a program for the terminal that started it? As in I type in

Re: ImportError in Unpickle

2006-02-26 Thread Rene Pijlman
[EMAIL PROTECTED]: I have a python script that pickles and unpickles a give object. It works without any problems on windows (the data was pickled on windows first). But when I try to run the script on Linux, I get the following error: [...] ImportError: No module named __main__ There are some

Re: ImportError in Unpickle

2006-02-26 Thread Rene Pijlman
Rene Pijlman: [EMAIL PROTECTED]: ImportError: No module named __main__ There are some posts in the Usenet archive Also: http://mail.python.org/pipermail/python-list/1999-April/000916.html -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: Exception-handling

2006-02-24 Thread Rene Pijlman
Odd-R.: I thought Exception would catch all exceptions. Try this: import sys try: pass # your code here except: e = sys.exc_value() Either to catch everything, or to get a hold on e. -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: A C-like if statement

2006-02-24 Thread Rene Pijlman
Roy Smith: How do you do any I/O in a functional language if side effects are verboten? The user is a function. Output is its parameter, input its return value. The user is not allowed to maintain state ;-) For that matter, how does a functional program ever stop running? By returning to the

  1   2   >