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. -- ht

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'

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 tex

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 outcom

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 "", line 2, in ? >ValueError: need more than 1 value tyo unpack > >maybe this might help to

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

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 constr

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: begging for a tree implementation

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

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: 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

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 d

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

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 inst

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: 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 s

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: 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: 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é Pijlm

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 foldin

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 a

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 -- Re

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 -- http://mail.python.o

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: 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 BTr

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 -- http://mail.python.org/mai

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 wi

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: 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 >straig

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

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

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 safet

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: 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 (some

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

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

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 f

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 s

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: 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 -- http://mail.pytho

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: 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: 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 parsin

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 on

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: 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 = email.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

<    1   2