Re: SPAM

2007-11-16 Thread Byung-Hee HWANG
dear "just bob", On Wed, 2007-11-14 at 11:43 -0800, just bob wrote: > "John Bean" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > On Wed, 14 Nov 2007 11:04:35 -0800, "just bob" > > <[EMAIL PROTECTED]> wrote: > > > >> > > > > Your SPAM appears to be non-existent. Vapourware. Not

Re: implement random selection in Python

2007-11-16 Thread Boris Borcic
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) elements inside "the_items

Re: Populating a dictionary, fast [SOLVED SOLVED]

2007-11-16 Thread Hrvoje Niksic
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 testing it on single-CPU, 32 bit systems. Still, I'd like to see a te

Re: implement random selection in Python

2007-11-16 Thread bearophileHUGS
This recipe of mine may help: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/498229 Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Python server j2me client ssl socket handshake error

2007-11-16 Thread eliseo
Hello, I want to make the same application : python Serveur and J2me Client whit ssl socket. I would like to know if you have solved the problem? Can you show me the final version of python server code and the J2ME client code, so that I can make my application with your help. Thanks Best reg

Re: implement random selection in Python

2007-11-16 Thread Boris Borcic
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) elements inside "the_items

Re: implement random selection in Python

2007-11-16 Thread Paul Rubin
Bruza <[EMAIL PROTECTED]> writes: > But how about the general case, for N > 1 and N < len(items)? Is there > some clever algorithm using Python standard "random" package Yeah, I'm not sure what the name for it is, but there'ss a well known algorithm that's sort of an online verison of random.choic

Re: cx_Oracle: Non-ASCII characters handling with different versions

2007-11-16 Thread dwahli
On Nov 14, 2:03 pm, Benjamin Hell <[EMAIL PROTECTED]> wrote: > It's solved: Because of a local full Oracle DB installation the > "working" box had the registry key > HKEY_LOCAL_SYSTEM\SOFTWARE\ORACLE\KEY_OraBD10g_home1\NLS_LANG set to > "AMERICAN_AMERICA.WE8MSWIN1252". A similar key was missing on

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

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

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

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

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

sorting contacts alphabetically, sorted by surname

2007-11-16 Thread Marie Hughes
HI I have to write a program that contains a text file in the following format: AcademicPositionRoom Ext. EmailProf Marie Maguire Head of School M9002 [EMAIL PROTECTED] And produce a output file where conatcts are sorted alphabetically- sor

list of class initiations ?

2007-11-16 Thread stef mientki
hello, 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] ): class t_BaseShape(Shape): (self, x=20, y=20, x2=90

Looking for docs

2007-11-16 Thread Donn Ingle
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 discussion of 'new style' classes and other info.

Re: Looking for docs

2007-11-16 Thread Tim Chase
> I'm not even sure what subject that @ sign stuff falls under. The magic keyword you're looking for is "decorator" which will help you find the docs (a quick google for "python decorator" returns scads of helpful results) -tkc -- http://mail.python.org/mailman/listinfo/python-list

Python Extension in C#?

2007-11-16 Thread jane janet
Hello all, Please tell me how can I create .dll for Python in C#? Every advice would be great. Thank you. All the best, _ Windows Live Hotmail and Microsoft Office Outlook – together at last.  Get it now. http://office.microsof

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

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

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

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

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

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

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

2007-11-16 Thread sharan
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 as to build a hierarchi

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: 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: 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: How to evaluate the code object returned by PyParser_SimplePa rseString function?

2007-11-16 Thread Borse, Ganesh
Thanks this is helpful. -Original Message- From: Gabriel Genellina [mailto:[EMAIL PROTECTED] Sent: 15 November 2007 12:26 To: python-list@python.org Subject: Re: How to evaluate the code object returned by PyParser_SimplePa rseString function? En Wed, 14 Nov 2007 23:20:14 -0300, Borse,

Re: Memory problem

2007-11-16 Thread Rolf Wester
Hi, thank you for your comments and your hints (I probably deserve some kind of subtle irony). I found the problem: I thought a numpy array A has shape (n,) but actually it had shape (n,1). In the loop I sampled a value from that array: v.append(A[i]) So what happened was that I got a view of

Re: Python Design Patterns - composition vs. inheritance

2007-11-16 Thread A.T.Hofkamp
On 2007-11-15, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > inheritance when an object's relationship to another object is 'is-a' > and composition when the relationship is 'has-a'. > > Since this is all new and I'm still learning, I was hoping someone can > give me some pointers on best practice

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1   2   >