Re: How to use a contiguous memory location of n bytes in python

2008-11-14 Thread Aaron Brady
On Nov 13, 6:40 pm, [EMAIL PROTECTED] wrote: > chachi: > > > I want to know how to instantiate a data structure which has n bytes > > (given by me) and is internally stored in a contiguous fashion. > > array.array("B", ...) may be fit for you. You can also use a numpy > array of bytes. > > Bye, > b

Re: Code generation architecture question

2008-11-14 Thread Aaron Brady
On Nov 13, 7:16 pm, Alex_Gaynor <[EMAIL PROTECTED]> wrote: > I'm trying to figure out what the best architecture for doing code > generation would be.  I have a set of ASTs that define a program, so > what should I do to for code generation.  As I see it the 2 choices > are to have the ASTs have a

Re: To throw or to throw not?

2008-11-14 Thread Aaron Brady
On Nov 13, 10:09 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Thu, 13 Nov 2008 17:11:26 -0800, Emanuele D'Arrigo wrote: > > I'm pondering on what is a bit of a philosophical dilemma. When should I > > throw an exception and when should I not? > > > Suppose I have myFunc1()

Re: using "private" parameters as static storage?

2008-11-14 Thread Aaron Brady
On Nov 13, 10:25 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 14 Nov 2008 13:35:02 +1100, Ben Finney wrote: > > Instead, it looks like you're falling foul of one of the classic > > mistakes in the “How to ask questions the smart way” document: you've > > got a goal, b

Re: setuptools for 2.6 and windows?

2008-11-14 Thread werner
On Nov 14, 2:22 am, Allan <[EMAIL PROTECTED]> wrote: > "Werner F. Bruhin" <[EMAIL PROTECTED]> writes: > > > I would like to start looking into Python 2.6 and do some testing. > > > First hurdle I run into is that I can not find a 2.6 installer for > > Windows for setuptools-0.6.9c, only Py2.4 and P

Re: using "private" parameters as static storage?

2008-11-14 Thread Peter Otten
Steven D'Aprano wrote: > On Thu, 13 Nov 2008 19:52:13 -0700, Joe Strout wrote: > >> Pity there isn't a way for a function to get a reference to itself >> except by name. Still, when you rename a method, you're going to have >> to update all the callers anyway -- updating a couple of extra >> ref

Re: Avoiding local variable declarations?

2008-11-14 Thread bearophileHUGS
Paul McGuire: > Really?  Looking at randrange, it sure seems to do a lot of work in > pursuit of handling all possible cases for specifying range > boundaries, step values, etc. Well, randrange is the simpler thing to read and understand here, and maybe the one less likely to get wrong too. But I

Re: email notifier question ??

2008-11-14 Thread Jorgen Grahn
On Thu, 13 Nov 2008 18:48:04 -0800, Chris Rebert <[EMAIL PROTECTED]> wrote: > 2008/11/13 yoma <[EMAIL PROTECTED]>: >> hi guys! >>I want to use python send an email to acceptor. And i hope to >> receive the message that the acceptor has read my email. >> >> So how to realize that get the messa

[UnicodeEncodeError] Don't know what else to try

2008-11-14 Thread Gilles Ganault
Hello Data that I download from the web seems to be using different code pages at times, and Python doesn't like this. Google returned a way to handle this, but I'm still getting an error: print output.decode('utf-8') File "C:\Python25\lib\encodings\utf_8.py", line 16, in decode

Re: [UnicodeEncodeError] Don't know what else to try

2008-11-14 Thread Martin v. Löwis
> print output.decode('utf-8') > File "C:\Python25\lib\encodings\utf_8.py", line 16, in decode > return codecs.utf_8_decode(input, errors, True) > UnicodeEncodeError: 'ascii' codec can't encode character u'\xe2' in > position 47: > ordinal not in range(128) Notice that it complains abou

Re: Little direction please Python MySQL

2008-11-14 Thread Bruno Desthuilliers
len a écrit : Hi all; I am looking for a little direction in moving from novice python MySQL to real world processing. I can connect to MySQL databases and have performed most of the various select, create, update, insert, etc given the examples in the various books and internet tutorials not t

Identifying unicode punctuation characters with Python regex

2008-11-14 Thread Shiao
Hello, I'm trying to build a regex in python to identify punctuation characters in all the languages. Some regex implementations support an extended syntax \p{P} that does just that. As far as I know, python re doesn't. Any idea of a possible alternative? Apart from manually including the punctuat

Windows PE and Python 2.6 (Side-by-Side error)

2008-11-14 Thread Werner Merkl
Hallo, I like Python 2.6 and I like to use it anywhere, even within Windows PE. In former version of Python (<= 2.5.x) it was easy to bring it to a Windows PE system: Install Python to Windows XP or Vista and (robo-) copy the whole directory off Python (and all sub directories) to the Windows P

Re: Identifying unicode punctuation characters with Python regex

2008-11-14 Thread Martin v. Löwis
> I'm trying to build a regex in python to identify punctuation > characters in all the languages. Some regex implementations support an > extended syntax \p{P} that does just that. As far as I know, python re > doesn't. Any idea of a possible alternative? You should use character classes. You can

Re: Identifying unicode punctuation characters with Python regex

2008-11-14 Thread Shiao
On Nov 14, 11:27 am, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > I'm trying to build a regex in python to identify punctuation > > characters in all the languages. Some regex implementations support an > > extended syntax \p{P} that does just that. As far as I know, python re > > doesn't. Any

Re: using "private" parameters as static storage?

2008-11-14 Thread Bruno Desthuilliers
Joe Strout a écrit : One thing I miss as I move from REALbasic to Python is the ability to have static storage within a method s/method/function/ -- i.e. storage that is persistent between calls, but not visible outside the method. I frequently use this for such things as caching, or for ke

Re: Identifying unicode punctuation characters with Python regex

2008-11-14 Thread Mark Tolonen
"Shiao" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hello, I'm trying to build a regex in python to identify punctuation characters in all the languages. Some regex implementations support an extended syntax \p{P} that does just that. As far as I know, python re doesn't. Any ide

Re: Identifying unicode punctuation characters with Python regex

2008-11-14 Thread Mark Tolonen
"Mark Tolonen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] "Shiao" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hello, I'm trying to build a regex in python to identify punctuation characters in all the languages. Some regex implementations support an extended

xlutils 1.1.0 released!

2008-11-14 Thread Chris Withers
Hi All, I'm pleased to announce a new release of xlutils. This is a small collection of utilities that make use of both xlrd and xlwt to process Microsoft Excel files. The list of utilities included in this release are: xlutils.display Utility functions for displaying information about xlrd-r

Re: Python IF THEN chain equivalence

2008-11-14 Thread Paul Boddie
On 14 Nov, 00:19, jzakiya <[EMAIL PROTECTED]> wrote: > > It's interesting to see people think it's strange to have code that > has multiple nested levels of IF THEN.  Apparently you haven't seen > any Forth, assembly, et al code. [...] > Just as a suggestion :-)  a little humility would go a long

Clustering the keys of a dict according to its values

2008-11-14 Thread Florian Brucker
Hi everybody! Given a dictionary, I want to create a clustered version of it, collecting keys that have the same value: >>> d = {'a':1, 'b':2, 'c':1, 'd':1, 'e':2, 'f':3} >>> cluster(d) {1:['a', 'c', 'd'], 2:['b', 'e'], 3:['f']} That is, generate a new dict which holds for each value of the o

Re: Clustering the keys of a dict according to its values

2008-11-14 Thread bearophileHUGS
Florian Brucker: > We may assume that all values in the > original dict/list can be used as dict keys. Are you sure? Is this for school? Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Clustering the keys of a dict according to its values

2008-11-14 Thread Florian Brucker
Are you sure? Is this for school? Yes, I'm pretty sure (the values of the original dict are integers), and no, this isn't for school :) If the "We may assume ..." made you think so, I guess that's the way everybody formulates requirements after having read to many math papers :D If it is of

Re: Clustering the keys of a dict according to its values

2008-11-14 Thread alex23
Florian Brucker <[EMAIL PROTECTED]> wrote: > Given a dictionary, I want to create a clustered version of it, > collecting keys that have the same value: > >  >>> d = {'a':1, 'b':2, 'c':1, 'd':1, 'e':2, 'f':3} >  >>> cluster(d) > {1:['a', 'c', 'd'], 2:['b', 'e'], 3:['f']} > > That is, generate a new

Re: Clustering the keys of a dict according to its values

2008-11-14 Thread Arnaud Delobelle
On Nov 14, 1:16 pm, Florian Brucker <[EMAIL PROTECTED]> wrote: > Hi everybody! > > Given a dictionary, I want to create a clustered version of it, > collecting keys that have the same value: > > >>> d = {'a':1, 'b':2, 'c':1, 'd':1, 'e':2, 'f':3} > >>> cluster(d) > {1:['a', 'c', 'd'], 2:['b', 'e']

Re: Clustering the keys of a dict according to its values

2008-11-14 Thread bearophileHUGS
Not much tested: from collections import defaultdict def cluster(pairs): """ >>> d = {'a':1, 'b':2, 'c':1, 'd':1, 'e':2, 'f':3} >>> cluster(d) == {1:['a', 'c', 'd'], 2:['b', 'e'], 3:['f']} True >>> p = [1, 2, 1, 1, 2, 3] >>> cluster(p) == {1: [0, 2, 3], 2: [1, 4], 3: [5]}

Re: Clustering the keys of a dict according to its values

2008-11-14 Thread bearophileHUGS
Alternative version: def cluster(data): d = defaultdict(list) pairs = enumerate(data) if isinstance(data, list) else data.iteritems() for k, v in pairs: d[v].append(k) return d Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use a contiguous memory location of n bytes in python

2008-11-14 Thread Nick Craig-Wood
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > chachi: > > I want to know how to instantiate a data structure which has n bytes > > (given by me) and is internally stored in a contiguous fashion. > > array.array("B", ...) may be fit for you. You can also use a numpy > array of bytes. The mmap

Re: win32com and DispatchWithEvents

2008-11-14 Thread RyanN
On Nov 13, 2:16 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote: > On Nov 13, 10:27 am, RyanN <[EMAIL PROTECTED]> wrote: > > > > > Greetings, > > > I'm trying to get DispatchWithEvents() to work with HyperAccess > > (terminal program) without much success. I've done a bunch of > > searching and found s

Re: Clustering the keys of a dict according to its values

2008-11-14 Thread alex23
On Nov 14, 11:24 pm, [EMAIL PROTECTED] wrote: > Alternative version: > > def cluster(data): >     d = defaultdict(list) >     pairs = enumerate(data) if isinstance(data, list) else > data.iteritems() >     for k, v in pairs: >         d[v].append(k) >     return d > > Bye, > bearophile Very nice,

Re: [UnicodeEncodeError] Don't know what else to try

2008-11-14 Thread Gilles Ganault
On Fri, 14 Nov 2008 11:01:27 +0100, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: >Add >print type(output) >here. If it says "unicode", reconsider the next line > >> print output.decode('utf-8') In case the string fetched from a web page turns out not to

Re: Identifying unicode punctuation characters with Python regex

2008-11-14 Thread Shiao
On Nov 14, 12:30 pm, "Mark Tolonen" <[EMAIL PROTECTED]> wrote: > "Mark Tolonen" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > > > > > "Shiao" <[EMAIL PROTECTED]> wrote in message > >news:[EMAIL PROTECTED] > >> Hello, > >> I'm trying to build a regex in python to identify pun

Re: using "private" parameters as static storage?

2008-11-14 Thread Luis Zarrabeitia
Quoting Joe Strout <[EMAIL PROTECTED]>: > Hi Luis, > > > A lot of languages have ditched the "concept" of a static variable > > on a method (how do > > you parse that sentence, btw?) in favour of using encapsulation. > > A static variable IS encapsulation. Encapsulation happens at many >

Re: Python IF THEN chain equivalence

2008-11-14 Thread Steven D'Aprano
On Fri, 14 Nov 2008 01:24:32 +0100, M.-A. Lemburg wrote: >> Apparently you haven't seen >> any Forth, assembly, et al code. All you're doing is having the branch >> point for each conditional be the end of the chain, otherwise it falls >> through to the code after the conditional. This is done al

urllib2 - safe way to download something

2008-11-14 Thread konstantin
Hi, I wonder if there is a safe way to download page with urllib2. I've constructed following method to catch all possible exceptions. def retrieve(url): user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' headers = {'User-Agent':user_agent} request = urllib2.Request(url, he

Re: urllib2 - safe way to download something

2008-11-14 Thread konstantin
I mean I don't want to catch all unexpected errors with empty "except:" :). -- http://mail.python.org/mailman/listinfo/python-list

Proxy + cookie: urllib2? httplib2? Other?

2008-11-14 Thread Gilles Ganault
Hello I need a library that supports both going out through a proxy, and handling cookies automagically (the server uses a sessionID to keep track of the user). UrlLib2 supports the proxy part, httplib2 supports the cookie part but... Google didn't return code that shows both uses in the same lib

Re: urllib2 - safe way to download something

2008-11-14 Thread Steven D'Aprano
On Fri, 14 Nov 2008 06:35:27 -0800, konstantin wrote: > Hi, > > I wonder if there is a safe way to download page with urllib2. I've > constructed following method to catch all possible exceptions. See here: http://niallohiggins.com/2008/04/05/python-and-poor-documentation- urllib2urlopen-except

running same script on same data on two different machines --> different result

2008-11-14 Thread Christopher Brewster
I am running the same script on the same data on two different machines (the folder is synchronised with Dropbox). I get two different results. All the script does is count words in different files and perform a simple set operation on the word lists. The laptop is a Macbook Pro (2 1/2 years old) r

Re: running same script on same data on two different machines --> different result

2008-11-14 Thread Steve Holden
Christopher Brewster wrote: > I am running the same script on the same data on two different > machines (the folder is synchronised with Dropbox). > I get two different results. All the script does is count words in > different files and perform a simple set operation on the word lists. > The lapto

Re: The return code

2008-11-14 Thread Sion Arrowsmith
Jeff McNeil <[EMAIL PROTECTED]> wrote: >> On Nov 13, 6:15 am, "devi thapa" <[EMAIL PROTECTED]> wrote: >> > I am running one service in the python script eg like >> > "service httpd status". >> > If I execute this command in normal shell kernel, the return code is >> > 3. But in the pytho

Re: running same script on same data on two different machines --> different result

2008-11-14 Thread Christopher Brewster
On Nov 14, 3:22 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > Christopher Brewster wrote: > > I am running the same script on the same data on two different > > machines (the folder is synchronised with Dropbox). > > I get two different results. All the script does is count words in > > different f

Re: running same script on same data on two different machines --> different result

2008-11-14 Thread Philip Semanchuk
On Nov 14, 2008, at 10:14 AM, Christopher Brewster wrote: I am running the same script on the same data on two different machines (the folder is synchronised with Dropbox). I get two different results. All the script does is count words in different files and perform a simple set operation on t

Re: running same script on same data on two different machines --> different result

2008-11-14 Thread Steven D'Aprano
On Fri, 14 Nov 2008 07:14:20 -0800, Christopher Brewster wrote: > I am running the same script on the same data on two different machines > (the folder is synchronised with Dropbox). I get two different results. > All the script does is count words in different files and perform a > simple set ope

Re: Proxy + cookie: urllib2? httplib2? Other?

2008-11-14 Thread Gilles Ganault
On Fri, 14 Nov 2008 16:03:13 +0100, Gilles Ganault <[EMAIL PROTECTED]> wrote: >I need a library that supports both going out through a proxy, and >handling cookies automagically (the server uses a sessionID to keep >track of the user). For those interested, it seems like a good combination is urll

Re: Clustering the keys of a dict according to its values

2008-11-14 Thread Bruno Desthuilliers
Florian Brucker a écrit : Hi everybody! Given a dictionary, I want to create a clustered version of it, collecting keys that have the same value: >>> d = {'a':1, 'b':2, 'c':1, 'd':1, 'e':2, 'f':3} >>> cluster(d) {1:['a', 'c', 'd'], 2:['b', 'e'], 3:['f']} That is, generate a new dict which

C or C++ with Pyparsing?

2008-11-14 Thread Greg Copeland
Anyone have a pyparsing file for parsing C/C++ they are willing to share? -- http://mail.python.org/mailman/listinfo/python-list

Determine the best buffer sizes when using socket.send() and socket.recv()

2008-11-14 Thread Giampaolo Rodola'
Hi, I'd like to know if there's a way to determine which is the best buffer size to use when you have to send() and recv() some data over the network. I have an FTP server application which, on data channel, uses 8192 bytes as buffer for both incoming and outgoing data. Some time ago I received a r

Re: Clustering the keys of a dict according to its values

2008-11-14 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : Alternative version: def cluster(data): d = defaultdict(list) pairs = enumerate(data) if isinstance(data, list) else data.iteritems() What is data is another type of sequence or iterable ?-) for k, v in pairs: d[v].append(k) return d By

Re: using "private" parameters as static storage?

2008-11-14 Thread Bruno Desthuilliers
Matimus a écrit : On Nov 13, 9:16 am, Joe Strout <[EMAIL PROTECTED]> wrote: (snip) def spam2(): if not hasattr(spam2,'count'):spam2.count=0 spam2.count += 1 return "spam2 " * spam2.count This is definitely preferred over the first. I beg to disagree. This solution stores

Free Downloadable Presentations--http://www.yfrindia.com/resources/Presentations

2008-11-14 Thread Mr. Lonely
Dear Friend, Preparing to GET A JOB? Applying for a competitive exam? Heading for GATE, CAT, XAT, MAT, TOEFL, GRE? Want to clear a certification, like MCP, SCJP? We have solution to all your answers. YFRIndia.com presents you a new approach in online education for all your preparation needs to get

Can I check if I'm running from the interpreter prompt?

2008-11-14 Thread skip
Is there a reliable way (this is on Solaris if that matters) to tell if I'm running in the interactive interpreter as opposed to in a script? I think examining sys.argv works, but wanted to double check. Thx, Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: Determine the best buffer sizes when using socket.send() and socket.recv()

2008-11-14 Thread Greg Copeland
On Nov 14, 9:56 am, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > Hi, > I'd like to know if there's a way to determine which is the best > buffer size to use when you have to send() and recv() some data over > the network. > I have an FTP server application which, on data channel, uses 8192 > by

SWIG: C++ and Python/ vector

2008-11-14 Thread Thomas
Hi, I have a C++-Class "compiled" with SWIG into a Python-Modul. It works fine. But there's is a problem with the C++-Returntype vector. If I call in my compiled Python-Module a certain method (from the C++- Class) there is no vector as result - although the C++-Counterpart returns a vector. The P

Re: [UnicodeEncodeError] Don't know what else to try

2008-11-14 Thread Marc 'BlackJack' Rintsch
On Fri, 14 Nov 2008 14:57:42 +0100, Gilles Ganault wrote: > On Fri, 14 Nov 2008 11:01:27 +0100, "Martin v. Löwis" > <[EMAIL PROTECTED]> wrote: >>Add >>print type(output) >>here. If it says "unicode", reconsider the next line >> >>> print output.decode('u

Re: [UnicodeEncodeError] Don't know what else to try

2008-11-14 Thread Martin v. Löwis
Gilles Ganault wrote: > On Fri, 14 Nov 2008 11:01:27 +0100, "Martin v. Löwis" > <[EMAIL PROTECTED]> wrote: >> Add >>print type(output) >> here. If it says "unicode", reconsider the next line >> >>> print output.decode('utf-8') > > In case the string fetc

Re: Text based screens without ncurses

2008-11-14 Thread Shawn Milochik
On Thu, Nov 13, 2008 at 2:10 PM, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-11-13, Mirat Can Bayrak <[EMAIL PROTECTED]> wrote: > >> Hi, i'll try to write a editor in python, i want it run under >> terminal (no qt or gtk) but i dont want to use urwid or curses >> modules. >> >> Can i write m

Re: Windows PE and Python 2.6 (Side-by-Side error)

2008-11-14 Thread Martin v. Löwis
> Has anyone an idea? You should not install "for all users" before copying it, but "just for me". Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: using "private" parameters as static storage?

2008-11-14 Thread Chris Mellon
On Thu, Nov 13, 2008 at 10:25 PM, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Fri, 14 Nov 2008 13:35:02 +1100, Ben Finney wrote: > >> Instead, it looks like you're falling foul of one of the classic >> mistakes in the "How to ask questions the smart way" document: you've >> got a goal, but you'

automatic reload

2008-11-14 Thread Alan Baljeu
I need a solution for automatically reloading files I edited. This is in a unit testing/fixing context, so there shouldn't be much problem with leftover data. I just need to be able to call a reload_changed() method of some sort before rerunning tests. Stopping and restarting the python inter

Re: urllib2 - safe way to download something

2008-11-14 Thread konstantin
On 14 нояб, 18:12, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 14 Nov 2008 06:35:27 -0800, konstantin wrote: > > Hi, > > > I wonder if there is a safe way to download page with urllib2. I've > > constructed following method to catch all possible exceptions. > > See here:

Re: automatic reload

2008-11-14 Thread Mike Driscoll
On Nov 14, 11:04 am, Alan Baljeu <[EMAIL PROTECTED]> wrote: > I need a solution for automatically reloading files I edited.  This is in a > unit testing/fixing context, so there shouldn't be much problem with leftover > data.  I just need to be able to call a reload_changed() method of some sort

Building musical chords starting from (a lot of) rules

2008-11-14 Thread Mr . SpOOn
Hi, I'm writing a method to create musical chords. This method must follow a specific set of syntax rules. At least, this is my idea, but maybe there's a better way. Anyway, in the code I have class Chord which is a set. The costrunction of a chord is based on a root note and a structure, so by d

Re: using "private" parameters as static storage?

2008-11-14 Thread Joe Strout
On Nov 13, 2008, at 3:23 PM, Arnaud Delobelle wrote: Aaron Brady <[EMAIL PROTECTED]> writes: One way around it, which I like the idea of but I'll be honest, I've never used, is getting a function a 'self' parameter. You could make it a dictionary or a blank container object, or just the funct

Re: using "private" parameters as static storage?

2008-11-14 Thread Joe Strout
On Nov 13, 2008, at 8:26 PM, Steven D'Aprano wrote: def spam(_count=[0]): _count[0] += 1 return "spam " * _count[0] This is a common trick, often used for things like caching. One major advantage is that you are exposing the cache as an *optional* part of the interface, which make

Re: Avoiding local variable declarations?

2008-11-14 Thread Mark Wooding
Chris Mellon <[EMAIL PROTECTED]> wrote: > Any time you port between languages, it's rarely a good idea to just > convert code verbatim. For example: > > import random, string > def random_char(): > return random.choice(string.ascii_letters + string.digits) Note that this code doesn't preserve

Re: Building musical chords starting from (a lot of) rules

2008-11-14 Thread Dan Upton
On Fri, Nov 14, 2008 at 1:00 PM, Mr. SpOOn <[EMAIL PROTECTED]> wrote: > Hi, > I'm writing a method to create musical chords. > > This method must follow a specific set of syntax rules. At least, this > is my idea, but maybe there's a better way. > Anyway, in the code I have class Chord which is a s

Re: Building musical chords starting from (a lot of) rules

2008-11-14 Thread Paul McNett
Mr.SpOOn wrote: Anyway, I think I can use a chain of if-clauses, one per rule and at the end remove the notes marked with "no". But this seems to me a very bad solution, not so pythonic. Before I proceed for this way, do you have any suggestion? Hope the problem is not too complicated. I say,

Sort dictionary by value when value is a list

2008-11-14 Thread major-john
I'm having trouble sorting a dictionary based on values when the values are all lists, and i want to sort the list by key with the largest value lists in decreasing size. Currently, I have the following: from operator import itemgetter dict = {'A': [(10, 20), (12, 18), (5, 11), (18, 25)], 'C': [

Re: Clustering the keys of a dict according to its values

2008-11-14 Thread Mark Wooding
Florian Brucker <[EMAIL PROTECTED]> wrote: > That is, generate a new dict which holds for each value of the old > dict a list of the keys of the old dict that have that very value. > Another requirement is that it should also work on lists, in that case > with indices instead of keys. We may assum

Re: Building musical chords starting from (a lot of) rules

2008-11-14 Thread bvdp
Mr.SpOOn wrote: Hi, I'm writing a method to create musical chords. This method must follow a specific set of syntax rules. At least, this is my idea, but maybe there's a better way. Anyway, in the code I have class Chord which is a set. The costrunction of a chord is based on a root note and a

Unsubscriptable object when using Exec

2008-11-14 Thread Indian
Hi Friends I'm getting the TypeError Unsubscriptable object when using Exec in a class Here's the example class Fake(object): def __init__(self, reg): self._reg = reg def OpenKey(self, rootkey, path): open_key = self._reg path_string='[\'HKLM\']' for key in path.split('\\'):

Re: What is the best Python GUI API?

2008-11-14 Thread rm
On Nov 13, 7:08 pm, Stef Mientki <[EMAIL PROTECTED]> wrote: > rm wrote: > > On Nov 13, 2:23 pm, James Harris <[EMAIL PROTECTED]> > > wrote: > > >> On 13 Nov, 18:59, Stef Mientki <[EMAIL PROTECTED]> wrote: > > >>> Abah Joseph wrote: > >  What is the best Python GUI API? I am planning to start m

Re: What is the best Python GUI API?

2008-11-14 Thread rm
On Nov 14, 1:59 pm, rm <[EMAIL PROTECTED]> wrote: > On Nov 13, 7:08 pm, Stef Mientki <[EMAIL PROTECTED]> wrote: > > > rm wrote: > > > On Nov 13, 2:23 pm, James Harris <[EMAIL PROTECTED]> > > > wrote: > > > >> On 13 Nov, 18:59, Stef Mientki <[EMAIL PROTECTED]> wrote: > > > >>> Abah Joseph wrote: > >

Fw: automatic reload

2008-11-14 Thread Alan Baljeu
Alan Baljeu http://www.collaborative-systems.org Intelligent software that works _with_ you. - Forwarded Message From: Alan Baljeu <[EMAIL PROTECTED]> To: Mike Driscoll <[EMAIL PROTECTED]> Sent: Friday, November 14, 2008 2:06:26 PM Subject: Re: automatic reload I thought I was readi

Re: Sort dictionary by value when value is a list

2008-11-14 Thread Vlastimil Brom
2008/11/14 major-john <[EMAIL PROTECTED]> > I'm having trouble sorting a dictionary based on values when the values are > all lists, and i want to sort the list by key with the largest value lists > in decreasing size. > > Currently, I have the following: > > from operator import itemgetter > > di

find() a larger string within a smaller string

2008-11-14 Thread korean_dave
stringa = "hi" stringb = "hiy" I'd like it to return -1 when I do: returnVal = stringa.find(stringb); Instead, it treats stringa as "hi" and stringb as "hi". How do I solve this? -- http://mail.python.org/mailman/listinfo/python-list

Re: duck-type-checking?

2008-11-14 Thread pruebauno
On Nov 14, 12:47 am, George Sakkis <[EMAIL PROTECTED]> wrote: > On Nov 13, 10:55 pm, Steven D'Aprano <[EMAIL PROTECTED] > > cybersource.com.au> wrote: > > Take this example: > > > def foo(alist): > > alist.sort() > > alist.append(5) > > > The argument can be any object with sort and append

Re: find() a larger string within a smaller string

2008-11-14 Thread Mensanator
On Nov 14, 1:20 pm, korean_dave <[EMAIL PROTECTED]> wrote: > stringa = "hi" > stringb = "hiy" > > I'd like it to return -1 when I do: > > returnVal = stringa.find(stringb); > > Instead, it treats stringa as "hi" and stringb as "hi". > > How do I solve this? Try this: >>> stringa = 'hi' >>> st

Re: find() a larger string within a smaller string

2008-11-14 Thread John Machin
On Nov 15, 6:20 am, korean_dave <[EMAIL PROTECTED]> wrote: > stringa = "hi" > stringb = "hiy" > > I'd like it to return -1 when I do: > > returnVal = stringa.find(stringb); > > Instead, it treats stringa as "hi" and stringb as "hi". You appear to be gravely mistaken: | >>> stringa = "hi" | >>

special editor support for indentation needed.

2008-11-14 Thread Eric S. Johansson
in trying to make programming in Python more accessible to disabled programmers (specifically mobility impaired speech recognition users), and hitting a bit of a wall. The wall (for today) is indentation. I need a method of getting the "right indentation" without having to speak a bunch of unnece

Looking for traffic generating utility (like ping)

2008-11-14 Thread [EMAIL PROTECTED]
Hello, I am looking for a utility that will generate any number of pings per second, and allow me to check how many of the pings in the last X seconds have been dropped, while it is still running. The reason I can't use the built-in Unix ping is that 1) it does not provide overall feedback while i

Re: Determine the best buffer sizes when using socket.send() and socket.recv()

2008-11-14 Thread Giampaolo Rodola'
On Nov 14, 5:27 pm, Greg Copeland <[EMAIL PROTECTED]> wrote: > On Nov 14, 9:56 am, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > > > > > > > Hi, > > I'd like to know if there's a way to determine which is the best > > buffer size to use when you have to send() and recv() some data over > > the n

Re: find() a larger string within a smaller string

2008-11-14 Thread Gary Herron
korean_dave wrote: > stringa = "hi" > stringb = "hiy" > > I'd like it to return -1 when I do: > > returnVal = stringa.find(stringb); > > Instead, it treats stringa as "hi" and stringb as "hi". > No it doesn't. stringb is "hiy" and it "treats" it that way. (And just what do you mean

Re: special editor support for indentation needed.

2008-11-14 Thread Almar Klein
Hi Eric, First of all, I like your initiative. I'm not sure if I undestand you correctly, but can't you just increase indentation after each line that ends with a colon? That's how I do it in my editor. The user would then only need to specify when to decrease indentation. Cheers, Almar 2008/

Re: Sort dictionary by value when value is a list

2008-11-14 Thread Chris Rebert
On Fri, Nov 14, 2008 at 10:26 AM, major-john <[EMAIL PROTECTED]> wrote: > I'm having trouble sorting a dictionary based on values when the values are > all lists, and i want to sort the list by key with the largest value lists > in decreasing size. > > Currently, I have the following: > > from oper

Re: running same script on same data on two different machines --> different result

2008-11-14 Thread John Machin
On Nov 15, 2:14 am, Christopher Brewster <[EMAIL PROTECTED]> wrote: > I am running the same script on the same data on two different > machines (the folder is synchronised with Dropbox). > I get two different results. All the script does is count words in > different files and perform a simple set

Re: special editor support for indentation needed.

2008-11-14 Thread Matimus
On Nov 14, 11:41 am, "Eric S. Johansson" <[EMAIL PROTECTED]> wrote: > in trying to make programming in Python more accessible to disabled > programmers > (specifically mobility impaired speech recognition users), and hitting a bit > of > a wall.  The wall (for today) is indentation.  I need a met

Question: what to do, my Python is getting crazy

2008-11-14 Thread Pekeika
Good morning group, When I open my Python window, this is appearing instead of the command line >>>. (I'm somehow new to Python). File "boot_com_servers.py", line 21, in File "C:\Python25\lib\site-packages\pythoncom.py", line 3, in pywintypes.__import_pywin32_system_module__("pythoncom"

Re: duck-type-checking?

2008-11-14 Thread Joe Strout
On Nov 14, 2008, at 12:27 PM, [EMAIL PROTECTED] wrote: What would be actually interesting would be an switch to the python interpreter that internally annotated function parameters with how they are used in the function and raised an exception as soon as the function is called instead of later.

web site feedback page using python for sending email

2008-11-14 Thread KAM.covad
Here is a great reference: http://www.thinkspot.net/sheila/staticpages/index.php?page=gypsymail However, the code will not work for an SMTP site like gmail that requires authentication. Anyone know of a site that has that code? I am a nube with python and am looking for a way to learn as well a

Multiprocessing vs. [Pyro, RPyC]

2008-11-14 Thread Jeffrey Barish
With the release of multiprocessing in Python 2.6, is there any reason to use Pyro or RPyC? -- Jeffrey Barish -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiprocessing vs. [Pyro, RPyC]

2008-11-14 Thread skip
Jeffrey> With the release of multiprocessing in Python 2.6, is there any Jeffrey> reason to use Pyro or RPyC? As far as I know the multiprocessing module only works on one machine (multi-cpu or multi-core), not across machines. -- Skip Montanaro - [EMAIL PROTECTED] - http://smontanaro.d

Re: Multiprocessing vs. [Pyro, RPyC]

2008-11-14 Thread Jeffrey Barish
[EMAIL PROTECTED] wrote: > > Jeffrey> With the release of multiprocessing in Python 2.6, is there > any Jeffrey> reason to use Pyro or RPyC? > > As far as I know the multiprocessing module only works on one machine > (multi-cpu or multi-core), not across machines. So I thought at first,

Re: return a value to shell script

2008-11-14 Thread News123
I don't know what exactly your python script is doing and what kind of return value you have, Let's assume your python application prints nothing to stdout, then python could print out the return value and you could get it with the back ticks (reverse single quote) (at least for sh bash csh tcsh a

Re: special editor support for indentation needed.

2008-11-14 Thread Eric S. Johansson
Almar Klein wrote: > Hi Eric, > > First of all, I like your initiative. there's nothing like self interest to drive one's initiative. :-) 14 years with speech recognition and counting. I'm so looking to my 15th anniversary of being injured next year another initiative is exporting the spee

Re: duck-type-checking?

2008-11-14 Thread Paul McGuire
On Nov 14, 1:27 pm, [EMAIL PROTECTED] wrote: > On Nov 14, 12:47 am, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > > > On Nov 13, 10:55 pm, Steven D'Aprano <[EMAIL PROTECTED] > > > cybersource.com.au> wrote: > > > Take this example: > > > > def foo(alist): > > >     alist.sort() > > >     alist

Re: Avoiding local variable declarations?

2008-11-14 Thread Paul McGuire
On Nov 14, 12:08 pm, Mark Wooding <[EMAIL PROTECTED]> wrote: > Chris Mellon <[EMAIL PROTECTED]> wrote: > > Any time you port between languages, it's rarely a good idea to just > > convert code verbatim. For example: > > > import random, string > > def random_char(): > >     return random.choice(str

Re: Can I check if I'm running from the interpreter prompt?

2008-11-14 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: Is there a reliable way (this is on Solaris if that matters) to tell if I'm running in the interactive interpreter as opposed to in a script? I think examining sys.argv works, but wanted to double check. import sys, traceback try: raise ValueError

Re: duck-type-checking?

2008-11-14 Thread Joe Strout
On Nov 14, 2008, at 2:07 PM, Paul McGuire wrote: Or to be even more thorough: def sub(x: must have getitem, y: must have strip and strip must be callable, and y.strip must return something that has replace and replace must be callable) So even this simple example gets nasty in a hurry, let alon

  1   2   >