Re: Interfaces.

2007-11-16 Thread Steven D'Aprano
On Fri, 16 Nov 2007 21:13:17 -0800, Chris M wrote: >> > Status:Rejected >> >> Thank you for pointing out the obvious. But *truly* helpful would be >> insight into "While at some point I expect that Python will have >> interfaces." Look for that sentence under the "rejected" part. >> >> James >

Re: What is python?????

2007-11-16 Thread [EMAIL PROTECTED]
On Nov 16, 3:10�pm, Alan <[EMAIL PROTECTED]> wrote: > On Nov 16, 8:29 pm, [EMAIL PROTECTED] wrote: > > > I still don't get it and I've been haunting this group for months... > > > Mike > > Go on then �... > > What ? > > The punchline, do the punchline Punchline? I don't think there's a punchline s

Re: What is python?????

2007-11-16 Thread Hendrik van Rooyen
(Mike) wrote: > On Nov 16, 1:16 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > On Nov 16, 8:14 am, Thorsten Kampe <[EMAIL PROTECTED]> wrote: > > > > > * Cope (Fri, 16 Nov 2007 06:09:31 -0800 (PST)) > > > > > > please tell me what is python.This group is so crowded. > > > > > A Python is da

Re: Resolving declaring class of a method at runtime

2007-11-16 Thread Janne Härkönen
On Nov 16, 2007 10:51 PM, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Fri, 16 Nov 2007 19:02:25 +0200, Janne Härkönen > wrote: > > >> X is an "old style" class. Most people probably shouldn't use old style > >> classes, for various reasons. To use new style classes, you inherit > >> from object

newbie Q: sequence membership

2007-11-16 Thread saccade
>>> a, b = [], [] >>> a.append(b) >>> b.append(a) >>> b in a True >>> a in a Traceback (most recent call last): File "", line 1, in RuntimeError: maximum recursion depth exceeded in cmp >>> >>> a is a[0] False >>> a == a[0] Traceback (most recent call last): File "", line 1, in RuntimeError:

Re: What is python?????

2007-11-16 Thread Hendrik van Rooyen
: "Thorsten Kampe" wrote: > * Cope (Fri, 16 Nov 2007 06:09:31 -0800 (PST)) > > please tell me what is python.This group is so crowded. > > A Python is dangerous snake[1]. This group here mainly consists of > misguided snake worshippers. You'd better run before they come to your > place... >

Re: Interfaces.

2007-11-16 Thread George Sakkis
On Nov 15, 8:55 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Does anyone know what the state of progress with interfaces for python > (last I can see ishttp://www.python.org/dev/peps/pep-0245/) No progress AFAIK for Python 2.x but Abstract Base Classes (ABCs) are pretty close to interface

OT: good code snippet manager

2007-11-16 Thread Wensui Liu
Might anyone recommend a good code snippet manager to me? Thank you so much! -- === WenSui Liu (http://spaces.msn.com/statcompute/blog) === -- http://mail.python.org/mailman/listinfo/python-list

Re: Interfaces.

2007-11-16 Thread Chris M
On Nov 16, 12:26 am, James Stroud <[EMAIL PROTECTED]> wrote: > Chris M wrote: > > On Nov 15, 8:55 pm, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > >> Hi, > > >> Does anyone know what the state of progress with interfaces for python > >> (last I can see ishttp://www.python.org/dev/peps/pep-0

Re: overriding methods - two questions

2007-11-16 Thread Donn Ingle
> I am curious as to why you want to go through such contortions.  What > do you gain. for obj in list: if obj has a foo() method: a = something b = figureitout ( ) object.foo ( a, b ) I am accepting objects of any class on a stack. Depending on their nature I want to call certain methods

Re: Global variables within classes.

2007-11-16 Thread Donn Ingle
Very interesting reply. I must ask a few questions, interleaved: > If you mean that all instances of Class Canvas and Thing will share > the *same* Stack, I think we can do it kind of like this: What's the difference between "same Stack" and "same instance of Stack"? I thought I knew what an insta

Re: overriding methods - two questions

2007-11-16 Thread Donn Ingle
>> While technically possible (using inspect.getargspec), trying to make >> your code idiot-proof is a lost fight and a pure waste of time. > Worse: it's actually counter-productive! > The whole idea of being able to subclass a class means that the user > should be able to override foo() *includi

Re: Interfaces.

2007-11-16 Thread Benjamin
On Nov 15, 7:55 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, > > Does anyone know what the state of progress with interfaces for python > (last I can see ishttp://www.python.org/dev/peps/pep-0245/) > > I would argue that interfaces/(similar feature) are necessary in any > modern languag

Re: implement random selection in Python

2007-11-16 Thread Jordan
How about this variation on your intial attempt? # Untested! def randomPick(n, items): def pickOne(): index = random.randint(0, 99) currentP = 0 for (obj, p) in items: currentP += p if currentP > index: return obj selection = set() while len(selection) < n:

Re: implement random selection in Python

2007-11-16 Thread Steven D'Aprano
On Fri, 16 Nov 2007 16:47:16 -0800, Bruza wrote: > I think I need to explain on the probability part: the "prob" is a > relative likelihood that the object will be included in the output list. > So, in my example input of > > items = [('Mary',30), ('John', 10), ('Tom', 45), ('Jane', 15)] > > S

Re: implement random selection in Python

2007-11-16 Thread duncan smith
Bruza wrote: > On Nov 16, 4:47 pm, Bruza <[EMAIL PROTECTED]> wrote: >> On Nov 16, 6:58 am, duncan smith <[EMAIL PROTECTED]> >> wrote: >> >> >> >>> Bruza wrote: I need to implement a "random selection" algorithm which takes a list of [(obj, prob),...] as input. Each of the (obj, prob) repr

Re: overriding methods - two questions

2007-11-16 Thread George Sakkis
On Nov 16, 5:03 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 16 Nov 2007 18:28:59 +0100, Bruno Desthuilliers wrote: > >> Question 1: > > >> Given that the user of the API can choose to override foo() or not, how > >> can I control the signature that they use? > > > W

Re: implement random selection in Python

2007-11-16 Thread Jordan
Maybe it would help to make your problem statement a litte rigorous so we can get a clearer idea of whats required. One possible formulation: Given a list L of pairs of values, weightings: [ (v_0, w_0), (v_1, w_1), ], and some N between 1 and length(L) you would like to randomly select a set

Getting file timestamp from url

2007-11-16 Thread mhearne808[insert-at-sign-here]gmail[insert-dot-here]com
Is is possible to get the timestamp of a file on a web server if it has a URL? For example, let's say that I want to know when the following file was created: http://www.w3schools.com/xml/note.xml I can get an HTTPMessage object using urllib2, like this:

Re: Namespace troubles

2007-11-16 Thread barronmo
Mike and Alan, thanks very much, working fine now. I'll review the classes references too. Mike -- http://mail.python.org/mailman/listinfo/python-list

Re: implement random selection in Python

2007-11-16 Thread Bruza
On Nov 16, 4:47 pm, Bruza <[EMAIL PROTECTED]> wrote: > On Nov 16, 6:58 am, duncan smith <[EMAIL PROTECTED]> > wrote: > > > > > Bruza wrote: > > > I need to implement a "random selection" algorithm which takes a list > > > of [(obj, prob),...] as input. Each of the (obj, prob) represents how > > > l

Re: implement random selection in Python

2007-11-16 Thread Bruza
On Nov 16, 6:58 am, duncan smith <[EMAIL PROTECTED]> wrote: > Bruza wrote: > > I need to implement a "random selection" algorithm which takes a list > > of [(obj, prob),...] as input. Each of the (obj, prob) represents how > > likely an object, "obj", should be selected based on its probability > >

Re: Fwd: Sorting Countries by Region

2007-11-16 Thread Sergio Correia
About the sort: Check this (also on http://pastebin.com/f12b5b6ca ) def make_regions(): # Values you provided EU = ["Austria","Belgium", "Cyprus","Czech Republic", "Denmark","Estonia", "Finland"] NA = ["Canada", "United States"] AP = ["Australia", "China", "Hong Kong", "India

Symposium "Image Processing and Analysis" within the ICCES'08 USA - Announce & Call for Papers

2007-11-16 Thread [EMAIL PROTECTED]
-- Symposium "Image Processing and Analysis" International Conference on Computational and Experimental Engineering & Sciences 2008 (ICCES'08) USA, 17-22 March 2008 http://icces.org/cgi-bin/ices08/pages

Re: PyCheck for a classes defined in python and user data in PyObject_HEAD

2007-11-16 Thread sndive
On Nov 15, 10:00 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Fri, 16 Nov 2007 00:27:42 -0300, <[EMAIL PROTECTED]> escribió: > > > > > On Nov 1, 11:04 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > > wrote: > >> En Thu, 01 Nov 2007 22:13:35 -0300, <[EMAIL PROTECTED]> escribió: > >> >> I'm

Re: Embedded Python - Blocking Python Function

2007-11-16 Thread andy
On Nov 15, 5:03 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Thu, 15 Nov 2007 16:18:45 -0300, <[EMAIL PROTECTED]> escribió: > > > On Nov 15, 9:43 am, [EMAIL PROTECTED] wrote: > >> On Nov 14, 4:20 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > >> wrote: > > >> > Not forcibly - you need som

Re: Populating a dictionary, fast [SOLVED SOLVED]

2007-11-16 Thread Steven D'Aprano
On Fri, 16 Nov 2007 11:24:24 +0100, Hrvoje Niksic wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: > >>> Can you post minimal code that exhibits this behavior on Python 2.5.1? >>> The OP posted a lot of different versions, most of which worked just >>> fine for most people. >> >> Who were tes

Re: Fwd: Sorting Countries by Region

2007-11-16 Thread patrick . waldo
Great, this is very helpful. I'm new to Python, so hence the inefficient or nonsensical code! > > 2) I would suggest using countries.sort(...) or sorted(countries,...), > specifying cmp or key options too sort by region instead. > I don't understand how to do this. The countries.sort() lists al

Re: overriding methods - two questions

2007-11-16 Thread Steven D'Aprano
On Fri, 16 Nov 2007 18:28:59 +0100, Bruno Desthuilliers wrote: >> Question 1: >> >> Given that the user of the API can choose to override foo() or not, how >> can I control the signature that they use? > > While technically possible (using inspect.getargspec), trying to make > your code idiot-pr

Re: What is python?????

2007-11-16 Thread Shawn Milochik
On Nov 16, 2007 2:16 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > On Nov 16, 8:14 am, Thorsten Kampe <[EMAIL PROTECTED]> wrote: > > * Cope (Fri, 16 Nov 2007 06:09:31 -0800 (PST)) > > > > > please tell me what is python.This group is so crowded. > > > > A Python is dangerous snake[1]. This gr

Re: tracking/ordering log files

2007-11-16 Thread nik
OK, that's it, so to do what I want I am using: self.logger = logging.getLogger('debuglog') hdlr = logging.handlers.RotatingFileHandler(debugfilename, 'a', 0, 5) hdlr.doRollover() formatter = logging.Formatter('%(asctime)s % (levelname)s:%(message

Re: Python beginner!

2007-11-16 Thread Shawn Milochik
I completely support Wildemar. Lazy questions like that deserve absolutely nothing. I agree that cushioning the reply with a brief explanation of why that question sucks would have helped the original poster, but he doesn't deserve any effort from any of us until he has shown evidence of his own e

Re: Resolving declaring class of a method at runtime

2007-11-16 Thread Chris Mellon
On Nov 16, 2007 2:51 PM, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Fri, 16 Nov 2007 19:02:25 +0200, Janne Härkönen > wrote: > > >> X is an "old style" class. Most people probably shouldn't use old style > >> classes, for various reasons. To use new style classes, you inherit > >> from object:

Re: Insert image to a List box

2007-11-16 Thread Matt McCredie
> Thanks a lot for your patience. > I put the gif file to a folder called fig in my desktop. > dirpath = './fig' > still got error: > > Traceback (most recent call last): > File "11.py", line 238, in > img.config(image=gifsdict[imgname]) > NameError: name 'imgname' is not defined > You shou

Re: Namespace troubles

2007-11-16 Thread kyosohma
On Nov 16, 2:51 pm, barronmo <[EMAIL PROTECTED]> wrote: > I'm new to programming and new to Python; namespace issues are getting > the best of me. Can someone help me with the following: > > import wx > import sys > sys.path.append('~/PyPrograms/EMRGUI') > import Selectable > > class MyApp(wx.App)

Re: Sorting Countries by Region

2007-11-16 Thread Alan
On Nov 16, 8:28 pm, martyw <[EMAIL PROTECTED]> wrote: > > i would create a class to capture country information, e.g. What is the advantage of this: > def __cmp__(self, other): > if self.name < other.name: > return -1 > elif self.name > other.name: >

Re: What is python?????

2007-11-16 Thread Alan
On Nov 16, 8:29 pm, [EMAIL PROTECTED] wrote: > I still don't get it and I've been haunting this group for months... > > Mike Go on then ... What ? The punchline, do the punchline -- Alan -- http://mail.python.org/mailman/listinfo/python-list

Re: PIL question

2007-11-16 Thread Thomas Heller
Thomas Heller schrieb: > I'm trying to read an image with PIL, crop several subimages out of it, > and try to combine the subimages again into a combined new one. This is > a test script, later I want to only several single images into a combined one. [...] > Here is the code; I'm using Python 2.4

Re: Resolving declaring class of a method at runtime

2007-11-16 Thread Alan
On Nov 16, 8:51 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > There should be a term for "optimization" techniques that actually slow > things down instead of speeding them up. > I belive those are the ones known as "premature optimizations", which sit at the root of all evil

Re: Namespace troubles

2007-11-16 Thread Alan
> class MyFrame(wx.Frame): > def __init__(self, parent, id, title): > wx.Frame.__init__(self, parent, id, title, size=(600,500)) > > nb = wx.Notebook(self) > self.page1 = Form1(nb, -1) > nb.AddPage(self.page1, "Choose Patient") > self.page1.SetFocus() >

Namespace troubles

2007-11-16 Thread barronmo
I'm new to programming and new to Python; namespace issues are getting the best of me. Can someone help me with the following: import wx import sys sys.path.append('~/PyPrograms/EMRGUI') import Selectable class MyApp(wx.App): def __init__(self): wx.App.__init__(self) frame =

PIL question

2007-11-16 Thread Thomas Heller
I'm trying to read an image with PIL, crop several subimages out of it, and try to combine the subimages again into a combined new one. This is a test script, later I want to only several single images into a combined one. I have to work with 16-bit color windows bitmaps in BMP format. My input

Re: Resolving declaring class of a method at runtime

2007-11-16 Thread Steven D'Aprano
On Fri, 16 Nov 2007 19:02:25 +0200, Janne Härkönen wrote: >> X is an "old style" class. Most people probably shouldn't use old style >> classes, for various reasons. To use new style classes, you inherit >> from object: > > I am also aware of old and new style classes, this was the fastest way >

Re: Populating a dictionary, fast [SOLVED SOLVED]

2007-11-16 Thread Jeffrey Froman
Steven D'Aprano wrote: > Can you try it running in 64-bit mode? Here are my results using the following test.py: $ cat test.py #!/usr/bin/python import time print "Starting: %s" % time.ctime() v = {} for line in open('keys.txt'): v[long(line.strip())] = True print "Finished: %s" % time.ctime(

Re: Sorting Countries by Region

2007-11-16 Thread martyw
[EMAIL PROTECTED] wrote: > Hi all, > > I'm analyzing some data that has a lot of country data. What I need > to do is sort through this data and output it into an excel doc with > summary information. The countries, though, need to be sorted by > region, but the way I thought I could do it isn't

Re: timing puzzle

2007-11-16 Thread Neil Cerutti
On 2007-11-16, Robin Becker <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: > ... > > > see why. >> >> You are no longer making m copies of active_nodes. > > my profiling indicated that the main problem was the removes. Yeah, I should've added, "for one thing." I'm glad Chris correctly poi

Re: overriding methods - two questions

2007-11-16 Thread [EMAIL PROTECTED]
On Nov 16, 11:35 am, Donn Ingle <[EMAIL PROTECTED]> wrote: > >This may help (on an old Python version): > class Sam: pass > class Judy: > > ...def foo(self): pass > > ... > children = [Sam(), Judy(), Sam()] > for child in children: hasattr(child, "foo") > > ... > > False > >

Re: What is python?????

2007-11-16 Thread kyosohma
On Nov 16, 1:16 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Nov 16, 8:14 am, Thorsten Kampe <[EMAIL PROTECTED]> wrote: > > > * Cope (Fri, 16 Nov 2007 06:09:31 -0800 (PST)) > > > > please tell me what is python.This group is so crowded. > > > A Python is dangerous snake[1]. This group he

Fwd: Sorting Countries by Region

2007-11-16 Thread Sergio Correia
Just a few notes: 1) get_countries_list What is the purpose of that function? Besides a few errors (an argument named list, no value returned), it seems you just want to remove duplicates from a list called countries. You can do that transforming the list to a 'set'. new_countries = list( set(c

Re: timing puzzle

2007-11-16 Thread Robin Becker
Neil Cerutti wrote: ... see why. > > You are no longer making m copies of active_nodes. my profiling indicated that the main problem was the removes. > > > When you have to make many deletions from the middle of a > sequence, you would normally choose a linked list. Python doe

Re: timing puzzle

2007-11-16 Thread Robin Becker
Chris Mellon wrote: > > remove() does a linear search to find the item to remove, so it's O(n) > + the actual deletion. Append() is amortized O(1) (overcommit). If you > delete by index instead: > for idx, node in active_nodes: > if cond: > del active_nodes[idx] > > that's what I

Re: timing puzzle

2007-11-16 Thread Neil Cerutti
On 2007-11-16, Neil Cerutti <[EMAIL PROTECTED]> wrote: > Instead, filter your list. It looks like you can't use filter > directly, so just do it manually. > >for i in xrange(m): >... >saved_nodes = [] >for A in active_nodes[:]: I meant to remove the slice. That line

Re: timing puzzle

2007-11-16 Thread Neil Cerutti
On 2007-11-16, Robin Becker <[EMAIL PROTECTED]> wrote: > I'm trying to get my head round a timing puzzle I find whilst > optimizing A Kuchling's version of the Knuth line splitting > algorithm from the oedipus project. The puzzle is as follows in > highly abstract form (here active_nodes is a list

Re: What is python?????

2007-11-16 Thread [EMAIL PROTECTED]
On Nov 16, 8:14 am, Thorsten Kampe <[EMAIL PROTECTED]> wrote: > * Cope (Fri, 16 Nov 2007 06:09:31 -0800 (PST)) > > > please tell me what is python.This group is so crowded. > > A Python is dangerous snake[1]. This group here mainly consists of > misguided snake worshippers. You'd better run before

Sorting Countries by Region

2007-11-16 Thread patrick . waldo
Hi all, I'm analyzing some data that has a lot of country data. What I need to do is sort through this data and output it into an excel doc with summary information. The countries, though, need to be sorted by region, but the way I thought I could do it isn't quite working out. So far I can only

Re: timing puzzle

2007-11-16 Thread Chris Mellon
On Nov 16, 2007 12:42 PM, Robin Becker <[EMAIL PROTECTED]> wrote: > I'm trying to get my head round a timing puzzle I find whilst optimizing A > Kuchling's version of the Knuth line splitting algorithm from the oedipus > project. The puzzle is as follows in highly abstract form (here > active_nod

Re: Trouble building pywin32 with Visual Studio 2005

2007-11-16 Thread danfike
> > If you know what you are doing, you can override the logic of distutils. > > Set up an SDK environment (with LIBRARY, INCLUDE and everything), then > > also set the MSSdk environment variable (which should get set if you > > use the standard environment batch file from the SDK), and then also >

Re: Populating a dictionary, fast [SOLVED SOLVED]

2007-11-16 Thread Istvan Albert
On Nov 16, 1:18 pm, "Michael Bacarella" <[EMAIL PROTECTED]> wrote: > You're right, it is completely inappropriate for us to be showing our > dirty laundry to the public. you are misinterpreting my words on many levels, (and I of course could have refrained from the "chair-monitor" jab as well)

timing puzzle

2007-11-16 Thread Robin Becker
I'm trying to get my head round a timing puzzle I find whilst optimizing A Kuchling's version of the Knuth line splitting algorithm from the oedipus project. The puzzle is as follows in highly abstract form (here active_nodes is a list of objects kept in a sorted order, but there are no specia

Re: insert comments into elementtree

2007-11-16 Thread Stefan Behnel
Tim Arnold wrote: > Hi, I'm using the TidyHTMLTreeBuilder to generate some elementtrees from > html. One by-product is that I'm losing comments embedded in the html. That's how the parser in ET works. Use lxml instead, which keeps documents intact while parsing. http://codespeak.net/lxml/dev/ ht

Re: overriding methods - two questions

2007-11-16 Thread Bruno Desthuilliers
Donn Ingle a écrit : >> for child in self.childrens: >> if 'foo' in child.__class__.__dict__: >> child.foo() > Bruno, you're the man! I really must take the time to look into all those > under-under score things! Knowing Python's object model can help, indeed !-) Now while this kind of stuff is

Re: Using python as primary language

2007-11-16 Thread Jean-Paul Calderone
On Wed, 14 Nov 2007 09:25:04 -0800, sturlamolden <[EMAIL PROTECTED]> wrote: > [snip] >I think the need for these "eventloop unifications" stems from Visual >Basic. VB programmers never learned to use more than one thread, and >they are still struggling to unlearn the bad habits they aquired. > +1

Re: build a hierarchical tree, without using DOM,schema, and sax using expat parser and c

2007-11-16 Thread Stefan Behnel
Wildemar Wildenburger wrote: > sharan wrote: >> I've been experimenting with the jclark's expat parser. I compiled it >> on >> linux, and it works just great. However, finding tags and data by >> implementing the callback functions in c language is cumbersome. >> Has anybody written code that use

insert comments into elementtree

2007-11-16 Thread Tim Arnold
Hi, I'm using the TidyHTMLTreeBuilder to generate some elementtrees from html. One by-product is that I'm losing comments embedded in the html. So I'm trying to put them back in, but I'm doing something wrong: here's the code snippet of how I generate the Trees: from elementtree import ElementT

RE: Populating a dictionary, fast [SOLVED SOLVED]

2007-11-16 Thread Michael Bacarella
> Do you really believe that you cannot create or delete a large > dictionary with python versions less than 2.5 (on a 64 bit or multi- > cpu system)? That a bug of this magnitude has not been noticed until > someone posted on clp? You're right, it is completely inappropriate for us to be showing

Re: Python Design Patterns - composition vs. inheritance

2007-11-16 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : (snip) > It's hard to apply some of the available > material's examples to Python since a lot of the documentation I find > is specific to implementations in lower-level languages and don't > apply to Python. Fact is that quite a few design patterns are mostly workarou

Re: overriding methods - two questions

2007-11-16 Thread Donn Ingle
> for child in self.childrens: > if 'foo' in child.__class__.__dict__: > child.foo() Bruno, you're the man! I really must take the time to look into all those under-under score things! Thanks. /d -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Design Patterns - composition vs. inheritance

2007-11-16 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > In learning about design patterns, I've seen discussion about using > inheritance when an object's relationship to another object is 'is-a' > and composition when the relationship is 'has-a'. wrt/ inheritance, it only makes sens with declarative static type systems w

Re: Insert image to a List box

2007-11-16 Thread Matt McCredie
On Nov 15, 2007 2:15 PM, linda. s <[EMAIL PROTECTED]> wrote: > > On 11/15/07, Matimus <[EMAIL PROTECTED]> wrote: > > On Nov 15, 12:45 pm, linda.s <[EMAIL PROTECTED]> wrote: > > > I run the following code and got the error (I put a .gif file on the > > > desktop) > > > Traceback (most recent call l

Re: overriding methods - two questions

2007-11-16 Thread Donn Ingle
>This may help (on an old Python version): class Sam: pass class Judy: > ...def foo(self): pass > ... children = [Sam(), Judy(), Sam()] for child in children: hasattr(child, "foo") > ... > False > True > False That's not what my tests are showing. While Sam has no foo, it's

Re: overriding methods - two questions

2007-11-16 Thread Bruno Desthuilliers
Donn Ingle a écrit : > Hi, > Here's a framework for the questions: > > --- In a module, part of an API --- > class Basis ( object ): > def foo ( self, arg ): > pass > > --- In user's own code --- > class Child ( Basis ): > def foo ( self, not, sure ): > ... > > > Question 1: > > Given th

Re: overriding methods - two questions

2007-11-16 Thread bearophileHUGS
Donn Ingle: > Say I am in class Basis, doing a loop and I have a list of Child objects. I > want to run the foo() method for each one that *has* a foo() method. This may help (on an old Python version): >>> class Sam: pass ... >>> class Judy: ... def foo(self): pass ... >>> children = [Sam()

Re: overriding methods - two questions

2007-11-16 Thread Donn Ingle
> Actually, Python is complaining about your user's poor choice of > argument names. 'not' is a reserved keyword. My example was poor, but my actual test code did't use 'not'. Python simply checks the use of foo() to the local sig of foo() and does not go up the chain. This is understandable and

Re: overriding methods - two questions

2007-11-16 Thread Paul McGuire
On Nov 16, 11:03 am, Donn Ingle <[EMAIL PROTECTED]> wrote: > Hi, > Here's a framework for the questions: > > --- In a module, part of an API --- > class Basis ( object ): > def foo ( self, arg ): > pass > > --- In user's own code --- > class Child ( Basis ): > def foo ( self, not, sure ): > .

Re: Resolving declaring class of a method at runtime

2007-11-16 Thread Janne Härkönen
On Nov 15, 2007 11:07 PM, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Thu, 15 Nov 2007 13:01:27 +0200, Janne Härkönen > wrote: > > Have you tried looking at dir(TheClass) to see what it lists? This is the first thing I did, but it shows both the inherited and own methods. > Also helpful is Th

Re: Python Design Patterns - composition vs. inheritance

2007-11-16 Thread Neil Cerutti
On 2007-11-16, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Thu, 15 Nov 2007 12:28:28 -0800 (PST), "[EMAIL PROTECTED]" ><[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > >> >> As a very simplified example, if I had two classes, Pet and Owner, it >> seems that I would not have

overriding methods - two questions

2007-11-16 Thread Donn Ingle
Hi, Here's a framework for the questions: --- In a module, part of an API --- class Basis ( object ): def foo ( self, arg ): pass --- In user's own code --- class Child ( Basis ): def foo ( self, not, sure ): ... Question 1: Given that the user of the API can choose to override foo() or

Re: gc penalty of 30-40% when manipulating large data structures?

2007-11-16 Thread Istvan Albert
On Nov 16, 10:59 am, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > The GC has a heuristic where it kicks in when (allocations - > deallocations) exceeds a certain threshold, As the available ram increases this threshold can be more easily reached. Ever since I moved to 2Gb ram I stumbled upon issue

Re: What is python?????

2007-11-16 Thread Shawn Milochik
However, the python is not poisonous, so it is also edible if you can kill one before it squeezes you to death. Despite this fact, it is not a major food source for group members, due to our great respect for the mighty python. Shawn On Nov 16, 2007 9:14 AM, Thorsten Kampe <[EMAIL PROTECTED]> w

Re: gc penalty of 30-40% when manipulating large data structures?

2007-11-16 Thread Chris Mellon
On Nov 16, 2007 8:34 AM, Aaron Watters <[EMAIL PROTECTED]> wrote: > Poking around I discovered somewhere someone saying that > Python gc adds a 4-7% speed penalty. > > So since I was pretty sure I was not creating > reference cycles in nucular I tried running the tests with garbage > collection dis

Re: SPAM

2007-11-16 Thread John Bean
On Fri, 16 Nov 2007 15:29:09 GMT, [EMAIL PROTECTED] wrote: >On Fri, 16 Nov 2007 15:08:56 -, "ChrisM" ><[EMAIL PROTECTED]> wrote: > >>In message [EMAIL PROTECTED], >>[EMAIL PROTECTED] <[EMAIL PROTECTED]> Proclaimed from the tallest tower: >> >>> On Wed, 14 Nov 2007 15:12:23 -0500, Lew <[EMAIL P

Any pythonists in guangzhou china!!!

2007-11-16 Thread ce
Hi, wondering if there is any python community in guangzhou/china I need ppl to talk to! I am dieing here -- http://mail.python.org/mailman/listinfo/python-list

Re: SPAM

2007-11-16 Thread ChrisM
In message [EMAIL PROTECTED], [EMAIL PROTECTED] <[EMAIL PROTECTED]> Proclaimed from the tallest tower: > On Wed, 14 Nov 2007 15:12:23 -0500, Lew <[EMAIL PROTECTED]> wrote: > >> just bob wrote: >>> "John Bean" <[EMAIL PROTECTED]> wrote in message >>> news:[EMAIL PROTECTED] On Wed, 14 Nov 2007

Re: list of class initiations ?

2007-11-16 Thread Marc 'BlackJack' Rintsch
On Fri, 16 Nov 2007 13:20:59 +0100, stef mientki wrote: > Is there a way to create a hierarchical list of class headers, including > the parameters. > What I mean (I'm not a programmer) is something like this: > > > class Block ( t_BaseShape ): (self, Pos = [10,10] ): >

Re: implement random selection in Python

2007-11-16 Thread duncan smith
Bruza wrote: > I need to implement a "random selection" algorithm which takes a list > of [(obj, prob),...] as input. Each of the (obj, prob) represents how > likely an object, "obj", should be selected based on its probability > of > "prob".To simplify the problem, assuming "prob" are integers, an

gc penalty of 30-40% when manipulating large data structures?

2007-11-16 Thread Aaron Watters
Poking around I discovered somewhere someone saying that Python gc adds a 4-7% speed penalty. So since I was pretty sure I was not creating reference cycles in nucular I tried running the tests with garbage collection disabled. To my delight I found that index builds run 30-40% faster without gc.

Re: sorting contacts alphabetically, sorted by surname

2007-11-16 Thread J. Clifford Dyer
On Fri, Nov 16, 2007 at 12:31:19PM +, Marie Hughes wrote regarding sorting contacts alphabetically, sorted by surname: > >HI > >I have to write a program that contains a text file in the following >format: > >AcademicPositionRoom Ext. Email

Re: sorting contacts alphabetically, sorted by surname

2007-11-16 Thread Boris Borcic
Wow J. Clifford Dyer wrote: > On Fri, Nov 16, 2007 at 12:31:19PM +, Marie Hughes wrote regarding > sorting contacts alphabetically, sorted by surname: >>HI >> >>I have to write a program that contains a text file in the following >>format: >> >>AcademicPosition

Re: logging.SocketHandler connections

2007-11-16 Thread Vinay Sajip
On Nov 15, 3:23 pm, oj <[EMAIL PROTECTED]> wrote: > However, initially, I had tried it with a server that closed the > connection after receiving each record, and the SocketHandler doesn't > seem to behave as advertised. > > My test script was simply this: > [snip] > The SocketHandler documentation

Re: Volume id

2007-11-16 Thread Dieter Verfaillie
On Thu, 2007-11-15 at 17:05 +0100, Gabor Urban wrote: > OK, you are right... Problem was not precise enough. I need to process > CDs to create a list. Does it ring a bell for you? > > Thanks Hello, The method below will work on linux systems (it uses dbus to communicate with HAL). You'll maybe h

Re: What is python?????

2007-11-16 Thread Thorsten Kampe
* Cope (Fri, 16 Nov 2007 06:09:31 -0800 (PST)) > please tell me what is python.This group is so crowded. A Python is dangerous snake[1]. This group here mainly consists of misguided snake worshippers. You'd better run before they come to your place... Thorsten [1] http://en.wikipedia.org/wiki/P

Re: Python beginner!

2007-11-16 Thread Wildemar Wildenburger
Tony wrote: > On Nov 15, 8:57 pm, Wildemar Wildenburger > Give me back the old comp.lang.python, where anyone could ask anything > and be sure of a range of replies, instead of this sort of > pedanticism. Sorry, nothing personal, maybe Python users have become > too professional and geeky to rememb

What is python?????

2007-11-16 Thread Cope
please tell me what is python.This group is so crowded. Khup http://groups.google.com/group/download-centre -- http://mail.python.org/mailman/listinfo/python-list

Re: PDF library

2007-11-16 Thread kyosohma
On Nov 15, 7:17 pm, james_027 <[EMAIL PROTECTED]> wrote: > hi, > > I am looking for a python PDF library that starts with 'Q' ... I just > found them somewhere in the internet but I can't find them now that I > need it. Does someone knows this? > > Thanks I'm not sure what you're referring to. The

Re: formated local time

2007-11-16 Thread Nikola Skoric
Dana Thu, 15 Nov 2007 10:12:11 -0600, Adam Pletcher <[EMAIL PROTECTED]> kaze: >> -Original Message- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] On > Behalf >> Of [EMAIL PROTECTED] >> Sent: Thursday, November 15, 2007 9:56 AM >> To: python-list@python.org >> Subject: Re: formate

Re: sorting contacts alphabetically, sorted by surname

2007-11-16 Thread Boris Borcic
Marie Hughes wrote: > HI > > I have to write a program that contains a text file in the following format: > > AcademicPositionRoom Ext. Email > Prof Marie Maguire Head of > School M9002 [EMAIL PROTECTED] > > > And

Re: build a hierarchical tree, without using DOM,schema, and sax using expat parser and c

2007-11-16 Thread Wildemar Wildenburger
sharan wrote: > I've been experimenting with the jclark's expat parser. I compiled it > on > linux, and it works just great. However, finding tags and data by > implementing the callback functions in c language is cumbersome. > Has anybody written code that uses the expat callback's in such a way

Leo 4.4.5 beta 1 released

2007-11-16 Thread Edward K Ream
Leo 4.4.5 beta 1 is available at: http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106 Leo is a text editor, data organizer, project manager and much more. See: http://webpages.charter.net/edreamleo/intro.html Leo 4.4.5 fixes several long-delayed bug fixes and adds several

Re: implement random selection in Python

2007-11-16 Thread Boris Borcic
Boris Borcic wrote: > Bruza wrote: >> No. That does not solve the problem. What I want is a function >> >> def randomPick(n, the_items): >> >> which will return n DISTINCT items from "the_items" such that >> the n items returned are according to their probabilities specified >> in the (item, pro)

Re: Looking for docs

2007-11-16 Thread Duncan Booth
Donn Ingle <[EMAIL PROTECTED]> wrote: > Hi, > I have seen strange looking things in various Python code like: > staticmethod and also lines starting with an @ sign, just before > method defs - I can't find an example right now. > I have Python 2.5 installed with it's docs, but I can't find any >

  1   2   >