Re: Load a list subset with pickle?

2009-10-15 Thread Gabriel Genellina
En Thu, 15 Oct 2009 16:28:11 -0300, Peng Yu escribió: On Thu, Oct 15, 2009 at 12:01 PM, Gabriel Genellina wrote: En Thu, 15 Oct 2009 13:05:18 -0300, Peng Yu escribió: How do I determine if I have loaded all the elements? I use the following code. I'm wondering if there is any better solut

Re: for loop: range() result has too many items

2009-10-15 Thread Tim Roberts
Matt Nordhoff wrote: > >That's what itertools.count() is for. > > > >It'll be faster, too, since it's written in C. Not that it really >matters, but it's always nice. For being such a simple concept, I've been surprised how many place

Re: set using alternative hash function?

2009-10-15 Thread Austin Bingham
On Thu, Oct 15, 2009 at 8:10 PM, Anthony Tolle wrote: > I think that without a practical example of what this would be used > for, we're all going to be a little lost on this one. > > So far, we've not seen the original problem, only the author's > preferred method for solving it.  My guess is the

Re: the usage of 'yield' keyword

2009-10-15 Thread Sean DiZazzo
On Oct 15, 9:48 pm, Sean DiZazzo wrote: > On Oct 13, 6:41 pm, Peng Yu wrote: > > >http://docs.python.org/reference/simple_stmts.html#grammar-token-yiel... > > > The explanation of yield is not clear to me, as I don't know what a > > generator is. I see the following example using 'yield'. Could >

Re: How to schedule system calls with Python

2009-10-15 Thread Minesh Patel
> Again another great suggestion.  I was not aware of the > multiprocessing module, and I'm not (yet) sure if I understand why I > should use instead of multithreading as explained by a previous post. http://docs.python.org/library/multiprocessing.html First paragraph... -- Thanks, --Minesh --

Re: the usage of 'yield' keyword

2009-10-15 Thread Sean DiZazzo
On Oct 13, 6:41 pm, Peng Yu wrote: > http://docs.python.org/reference/simple_stmts.html#grammar-token-yiel... > > The explanation of yield is not clear to me, as I don't know what a > generator is. I see the following example using 'yield'. Could > somebody explain how 'yield' works in this exampl

Re: How to schedule system calls with Python

2009-10-15 Thread Jeremy
On Oct 15, 6:47 pm, Ishwor Gurung wrote: > Jeremy, > Hi > > > I need to write a Python script that will call some command line > > programs (using os.system).  I will have many such calls, but I want > > to control when the calls are made.  I won't know in advance how long > > each program will ru

Re: set using alternative hash function?

2009-10-15 Thread Austin Bingham
On Thu, Oct 15, 2009 at 7:49 PM, Ethan Furman wrote: > Austin Bingham wrote: > I'm feeling really dense about now... What am I missing? What you're missing is the entire discussion up to this point. I was looking for a way to use an alternative uniqueness criteria in a set instance without needin

Re: set using alternative hash function?

2009-10-15 Thread Austin Bingham
On Thu, Oct 15, 2009 at 7:05 PM, Anthony Tolle wrote: > I wrote a quick subclass of set that does something similar, but uses > just one function for the object uniqueness: > > class MySet(set): >    def __init__(self, iterable = (), idfunc = lambda x: x): >        self.idfunc = idfunc >        se

Re: subprocess hangs on reading stdout

2009-10-15 Thread Tim Arnold
"Minesh Patel" wrote in message news:mailman.1408.1255583431.2807.python-l...@python.org... > > >> Any ideas? comments on code welcome also. > > Here's something that I would probably do, there may be better ways. > This only works on python2.6 for the terminate() method. > > > import signal > im

Re: how to write a unicode string to a file ?

2009-10-15 Thread Donn
On Friday 16 October 2009 01:59:43 Stephen Hansen wrote: > Just to say, thanks for that post. I am an old ascii dog and this notion of encoding and decoding is taking such a lng time to penetrate my thick skull. Little snippets like your post are valuable insights. I have made a gnote of it!

Re: How to schedule system calls with Python

2009-10-15 Thread Jeremy
On Oct 15, 6:32 pm, MRAB wrote: > TerryP wrote: > > On Oct 15, 7:42 pm, Jeremy wrote: > >> I need to write a Python script that will call some command line > >> programs (using os.system).  I will have many such calls, but I want > >> to control when the calls are made.  I won't know in advance h

Re: HTMLgen???

2009-10-15 Thread alex23
On Oct 15, 6:58 pm, an...@vandervlies.xs4all.nl wrote: > Does HTMLgen (Robin Friedrich's) still exsist?? And, if so, where can it > be found? If you're after an easy to use html generator, I highly recommend Richard Jones' html[1] lib. It's new, supported and makes very nice use of context manager

Re: the usage of 'yield' keyword

2009-10-15 Thread Dave Angel
Tim Golden wrote: Dave Angel wrote: def find(root): for pdf in os.walk(root, topdown=False): for file in pdf[2]: yield os.path.join(pdf[0],file) At the risk of nitpicking, I think that a modicum of tuple-unpacking would aid readability here: for dirpath, di

Re: Colour sampling

2009-10-15 Thread Dave Angel
Anthra Norell wrote: Dylan Palmboom wrote: Does anyone know what python libraries are available to do the following: 1. I would like to take a photograph of an object with a colour. In this case, it is a sheet of sponge. 2. Feed this image into a function in a python library and let the func

Re: a splitting headache

2009-10-15 Thread Ishwor Gurung
I think I am getting old :-( Should have Googled already. > My what who where?  You are confusing me with someone else. Andy Rubin- http://en.wikipedia.org/wiki/Andy_Rubin Sorry to bother you. -- Regards, Ishwor Gurung -- http://mail.python.org/mailman/listinfo/python-list

Re: a splitting headache

2009-10-15 Thread Paul Rubin
Ishwor Gurung writes: > Since you're here, any chance of getting your NDK team to look into > getting some small subset of STL, Boost into Android? :-P That'd be > awesome thing you know. My what who where? You are confusing me with someone else. -- http://mail.python.org/mailman/listinfo/pytho

Re: a splitting headache

2009-10-15 Thread Ishwor Gurung
2009/10/16 Ishwor Gurung : > 2009/10/16 Paul Rubin : > [...] >> You might also like: >> >>    from itertools import groupby >>    c = '001110' >>    print list(list(xs) for k,xs in groupby(c)) > Too bad groupby is only available in Python2.6+ OK. I stand corrected

Re: a splitting headache

2009-10-15 Thread Ishwor Gurung
2009/10/16 Paul Rubin : [...] > You might also like: > >    from itertools import groupby >    c = '001110' >    print list(list(xs) for k,xs in groupby(c)) Too bad groupby is only available in Python2.6+ Since you're here, any chance of getting your NDK team to lo

Re: a splitting headache

2009-10-15 Thread Paul Rubin
Mensanator writes: > And the re module doesn't help. > > >>> f = ' 1 2 3 4' > >>> re.split(' ',f) > ['', '', '1', '2', '', '3', '', '', '4', '', '', '', ''] filter(bool, re.split(' ', f)) You might also like: from itertools import groupby c = '001110' print list(list(xs

Re: a splitting headache

2009-10-15 Thread John O'Hagan
On Fri, 16 Oct 2009, Mensanator wrote: > All I wanted to do is split a binary number into two lists, > a list of blocks of consecutive ones and another list of > blocks of consecutive zeroes. [...] > That means I can use re to solve my problem after all. > > >>> c = '001110' > >>> re.sub('0',

Re: a splitting headache

2009-10-15 Thread Mel
Mensanator wrote: > All I wanted to do is split a binary number into two lists, > a list of blocks of consecutive ones and another list of > blocks of consecutive zeroes. > > But no, you can't do that. > c = '001110' c.split('0') > ['', '', '1', '', '', '', '11', ''] [ ... ] > OTOH

Re: a splitting headache

2009-10-15 Thread Ishwor Gurung
Hi 2009/10/16 Mensanator : > All I wanted to do is split a binary number into two lists, > a list of blocks of consecutive ones and another list of > blocks of consecutive zeroes. Just briefly looked at your problem. Try this: http://www.builderau.com.au/program/python/soa/Run-length-encoding-in-P

How about adding slice notation to iterators/generators?

2009-10-15 Thread Eloff
I was just working with a generator for a tree that I wanted to skip the first result (root node.) And it occurs to me, why do we need to do: import sys from itertools import islice my_iter = islice(my_iter, 1, sys.maxint) When we could simply add slice operations to generators? for x in my_it

a splitting headache

2009-10-15 Thread Mensanator
All I wanted to do is split a binary number into two lists, a list of blocks of consecutive ones and another list of blocks of consecutive zeroes. But no, you can't do that. >>> c = '001110' >>> c.split('0') ['', '', '1', '', '', '', '11', ''] Ok, the consecutive delimiters appear as empty s

Re: How to schedule system calls with Python

2009-10-15 Thread Ishwor Gurung
>> How can I use Python to schedule these commands? > If I were as lucky as you, I would have used multiprocessing module[1] > (my platform does not have sem_open() syscall). Others suggestions are > as good as it can be but yeah you could get a lot of work done using > multiprocessing module(all t

Re: How to schedule system calls with Python

2009-10-15 Thread Ishwor Gurung
>> How can I use Python to schedule these commands? > If I were as lucky as you, I would have used multiprocessing module[1] > (my platform does not have sem_open() syscall). Others suggestions are s/have/implement/g -- Regards, Ishwor Gurung -- http://mail.python.org/mailman/listinfo/python-lis

Re: How to schedule system calls with Python

2009-10-15 Thread Ishwor Gurung
Jeremy, Hi > I need to write a Python script that will call some command line > programs (using os.system).  I will have many such calls, but I want > to control when the calls are made.  I won't know in advance how long > each program will run and I don't want to have 10 programs running > when I

Re: How to schedule system calls with Python

2009-10-15 Thread MRAB
TerryP wrote: On Oct 15, 7:42 pm, Jeremy wrote: I need to write a Python script that will call some command line programs (using os.system). I will have many such calls, but I want to control when the calls are made. I won't know in advance how long each program will run and I don't want to h

Re: how to write a unicode string to a file ?

2009-10-15 Thread Stephen Hansen
On Thu, Oct 15, 2009 at 4:43 PM, Stef Mientki wrote: > hello, > > By writing the following unicode string (I hope it can be send on this > mailing list) > > Bücken > > to a file > >fh.write ( line ) > > I get the following error: > > UnicodeEncodeError: 'ascii' codec can't encode character

Re: how to write a unicode string to a file ?

2009-10-15 Thread Benjamin Kaplan
On Thu, Oct 15, 2009 at 7:43 PM, Stef Mientki wrote: > hello, > > By writing the following unicode string (I hope it can be send on this > mailing list) > >   Bücken > > to a file > >    fh.write ( line ) > > I get the following error: > >  UnicodeEncodeError: 'ascii' codec can't encode character

how to write a unicode string to a file ?

2009-10-15 Thread Stef Mientki
hello, By writing the following unicode string (I hope it can be send on this mailing list) Bücken to a file fh.write ( line ) I get the following error: UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 9: ordinal not in range(128) How should I write

Re: organizing your scripts, with plenty of re-use

2009-10-15 Thread bukzor
On Oct 13, 3:20 pm, "Gabriel Genellina" wrote: > En Tue, 13 Oct 2009 17:38:44 -0300, Buck escribió: > > > The only way to get your packages on the PYTHONPATH currently is to: > >    * install the packages to site-packages  (I don't have access) > >    * edit the PYTHONPATH all users' environment

Re: Are there any modules for IRC, that work with Python 3.1?

2009-10-15 Thread TerryP
On Oct 15, 10:36 pm, a...@pythoncraft.com (Aahz) wrote: > Why do you think that would be wise?  If library writers haven't upgraded > their libraries to 3.1, shouldn't that be a message to you? To me, it generally sends this kind of message: if lib.has_lots_of_users: try: avoid.as_long_as_p

Re: Are there any modules for IRC, that work with Python 3.1?

2009-10-15 Thread Andre Pereira
Try IRC IT (II) from suckless (http://tools.suckless.org/ii). Quoting: ii is a minimalist FIFO and filesystem-based IRC client. It creates an irc directory tree with server, channel and nick name directories. In every directory a FIFO in file and a normal out file is created. The in file is

Re: How to schedule system calls with Python

2009-10-15 Thread TerryP
On Oct 15, 8:52 pm, Jeremy wrote: > On Oct 15, 2:15 pm, TerryP wrote: > > If you want simple sequenceal execution of external programs, use a > > suitable blocking function to execute them (like system) combined with > > a simple loop over the sequence of commands to run. > > This is the solution

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Mick Krippendorf
Ben Finney schrieb: > Mick Krippendorf writes: > The word “anormal” appears to have been made up by you. > The negation of the word “normal” is “abnormal”, perhaps you meant > “First Abnormal Form”? Maybe my English (and my memory) is just not so good. I'm german, and here "abnormal" and "anorma

Re: for loop: range() result has too many items

2009-10-15 Thread Mark Dickinson
On Oct 15, 8:39 pm, David C. Ullrich wrote: > >For what it's worth, there *is* a Python oddity lurking > >under the surface here, at least for 64-bit.  Here's > >Python 2.6 on a 64-bit machine: > > Is that a 64-bit Python as well? Yes. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Are there any modules for IRC, that work with Python 3.1?

2009-10-15 Thread Aahz
In article <204e41fe-a00c-46d2-bb78-4f826ae75...@o41g2000yqb.googlegroups.com>, TerryP wrote: > >Does anyone know of any modules for dealing with the IRC protocol, >that will work with Python 3.1? It doens't have to be super great, >just less time consuming then playing with sockets directly (and

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Ben Finney
Mick Krippendorf writes: > Paul Rubin schrieb: > > Ethan Furman writes: > >> If I knew what First Anormal Form was I (hope!) > > > > It appears to be a made-up term. > > I read it somewhere once, I just can't find or even remember the > source. I definitely didn't make it up, though I wish I h

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Paul Rubin
Robert Kern writes: > I believe he mistyped it. Try "First Abnormal Form": > http://www.sqlmag.com/Article/ArticleID/21369/sql_server_21369.html Ah, that makes sense. Article is subscriber-only but would seem to explain the situation. -- http://mail.python.org/mailman/listinfo/python-list

Re: python performance on Solaris

2009-10-15 Thread Adam Vande More
On Thu, Oct 15, 2009 at 4:35 PM, Aahz wrote: > In article < > 1a4707f5-85be-4f5f-ac3e-cf8f5bd21...@b15g2000yqd.googlegroups.com>, > inaf wrote: > > > >I have been following this group for quite some time and I figured > >(after searching enough on google --and on this group-- and not finding >

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Robert Kern
On 2009-10-15 16:37 PM, Paul Rubin wrote: Mick Krippendorf writes: If I knew what First Anormal Form was I (hope!) I read it somewhere once, I just can't find or even remember the source. I definitely didn't make it up, though I wish I had. I found exactly one google hit for it, which is thi

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Paul Rubin
Mick Krippendorf writes: > >> If I knew what First Anormal Form was I (hope!) > I read it somewhere once, I just can't find or even remember the source. > I definitely didn't make it up, though I wish I had. I found exactly one google hit for it, which is this clpy thread. -- http://mail.python

Re: python performance on Solaris

2009-10-15 Thread Aahz
In article <1a4707f5-85be-4f5f-ac3e-cf8f5bd21...@b15g2000yqd.googlegroups.com>, inaf wrote: > >I have been following this group for quite some time and I figured >(after searching enough on google --and on this group-- and not finding >anything useful) I could pose this question here. Can anyone

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Mick Krippendorf
Paul Rubin schrieb: > Ethan Furman writes: >> If I knew what First Anormal Form was I (hope!) > > It appears to be a made-up term. I read it somewhere once, I just can't find or even remember the source. I definitely didn't make it up, though I wish I had. Mick. -- http://mail.python.org/mail

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Mick Krippendorf
Ethan Furman schrieb: > If I knew what First Anormal Form was [...] This refers to the Normal Forms one goes through when normalizing relational databases. (http://en.wikipedia.org/wiki/Database_normalization#Normal_forms) The First Anormal Form (FAN) means just lumpin' data together in a comma s

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Paul Rubin
Ethan Furman writes: > If I knew what First Anormal Form was I (hope!) It appears to be a made-up term. -- http://mail.python.org/mailman/listinfo/python-list

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Ethan Furman
Mick Krippendorf wrote: Ethan Furman schrieb: Mick Krippendorf wrote: BTW, the comma-separted-values-in-a-field is officially called the First Anormal Form. There *has to be* some value to it since I've seen it used quite a few times... Just because you've seen something, doesn't mean it ha

Re: Are there any modules for IRC, that work with Python 3.1?

2009-10-15 Thread Chris Jones
On Sat, Oct 10, 2009 at 01:39:48AM EDT, TerryP wrote: [..] > Having recently been put into search for a new IRC client, and > everything I've thrown in the cauldron having become a > disappointment... OT as always, but I'm surprised you found weechat-curses disappointing. CJ -- http://mail.py

Re: How to schedule system calls with Python

2009-10-15 Thread Jeremy
On Oct 15, 2:15 pm, TerryP wrote: > On Oct 15, 7:42 pm, Jeremy wrote: > > > I need to write a Python script that will call some command line > > programs (using os.system).  I will have many such calls, but I want > > to control when the calls are made.  I won't know in advance how long > > each

Re: Tracking down DLL load errors in Windows ?

2009-10-15 Thread Christian Heimes
Fred P wrote: > Is there any tool and/or methodology I could use to at least pinpoint the > exact DLL that libpyexiv2 is failing to load, and ideally also the reason > why ?... The depencency walker http://www.dependencywalker.com/ works fine for me. Christian -- http://mail.python.org/mailma

Tracking down DLL load errors in Windows ?

2009-10-15 Thread Fred P
Hi, a bit of platform-specific advice sought here... I'm trying to diagnose one of those mysteries Windows is so fond of... Say that I have code that imports some binary Python module from site- packages (in this case, libpyexiv2.pyd through pyexiv2.py, could be anythng else). On three Windows

Re: () vs. [] operator

2009-10-15 Thread Carl Banks
On Oct 15, 12:14 am, Ole Streicher wrote: > Hi, > > I am curious when one should implement a "__call__()" and when a > "__getitem__()" method. > > For example, I want to display functions and data in the same plot. For > a function, the natural interface would to be called as "f(x)", while > the n

Re: id( ) function question

2009-10-15 Thread Erik Max Francis
Mel wrote: My poster-child use of `is` is a MUDD game where `reference1_to_player is reference2_to_player` , if True, means that both refer to the same in-game player. Even that might not last. Well, that usage is fine; I can't see any circumstances under which it might change. `is` work

Re: How to schedule system calls with Python

2009-10-15 Thread TerryP
On Oct 15, 7:42 pm, Jeremy wrote: > I need to write a Python script that will call some command line > programs (using os.system).  I will have many such calls, but I want > to control when the calls are made.  I won't know in advance how long > each program will run and I don't want to have 10 pr

Re: Pack optimization

2009-10-15 Thread Robert Kern
On 2009-10-15 13:57 PM, BDL wrote: I have a large amount of binary data that needs to be pushed across the network. It appears from profiling that the dominant time is being taken up by packing the data. (50%) Here is a CME that shows the problem. from numpy import random from struct import p

How to schedule system calls with Python

2009-10-15 Thread Jeremy
I need to write a Python script that will call some command line programs (using os.system). I will have many such calls, but I want to control when the calls are made. I won't know in advance how long each program will run and I don't want to have 10 programs running when I only have one or two

Re: for loop: range() result has too many items

2009-10-15 Thread David C . Ullrich
On Wed, 14 Oct 2009 01:54:44 -0700 (PDT), Mark Dickinson wrote: >On Oct 13, 10:39 pm, Steven D'Aprano > wrote: >> On Tue, 13 Oct 2009 16:17:58 -0500, Peng Yu wrote: >> > Hi, >> >> > The following code does not run because range() does not accept a big >> > number. >> >> Incorrect. >> >> >>> range

Re: efficient running median

2009-10-15 Thread Janto Dreijer
On Oct 15, 12:41 pm, Raymond Hettinger wrote: > [Janto Dreijer] > > > I found a PDF by Soumya D. Mohanty entitled "Efficient Algorithm for > > computing a Running Median" (2003) by Googling. It has code snippets > > at the end, but it's not going to be a simple cut-and-paste job. It > > will take

Re: Pack optimization

2009-10-15 Thread Paul Rubin
BDL writes: > Is there a faster method to do this? Is it possible to use array? array.tostring is the first thing I'd think of. -- http://mail.python.org/mailman/listinfo/python-list

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Paul Rubin
Ethan Furman writes: > > BTW, the comma-separted-values-in-a-field is officially called the > > First Anormal Form. There *has to be* some value to it since I've > > seen it used quite a few times... Mick. > > Just because you've seen something, doesn't mean it has value; just > because somethin

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Mick Krippendorf
Ethan Furman schrieb: > Mick Krippendorf wrote: >> BTW, the comma-separted-values-in-a-field is officially called the First >> Anormal Form. There *has to be* some value to it since I've seen it used >> quite a few times... > > Just because you've seen something, doesn't mean it has value; [...]

Re: Load a list subset with pickle?

2009-10-15 Thread Peng Yu
On Thu, Oct 15, 2009 at 12:01 PM, Gabriel Genellina wrote: > En Thu, 15 Oct 2009 13:05:18 -0300, Peng Yu escribió: > >> How do I determine if I have loaded all the elements? I use the >> following code. I'm wondering if there is any better solution than >> this. >> >> >> ### >> import

Pack optimization

2009-10-15 Thread BDL
I have a large amount of binary data that needs to be pushed across the network. It appears from profiling that the dominant time is being taken up by packing the data. (50%) Here is a CME that shows the problem. from numpy import random from struct import pack import time lenstim = 10084200 s

Re: Problem with character encoding in commandline

2009-10-15 Thread gialloporpora
Risposta al messaggio di gialloporpora : Dear all, I have a strange problem that I am not able to solve myself. Ok, I have solved my problem, sorry for the post. First I had no view this function: sys.getfilesystemencoding() that return the console encoding, sorry. Sandro *gialloporpora:

Re: ?????? () vs []

2009-10-15 Thread Terry Reedy
SmokingDog wrote: > Interesting interpretation.. but I just gave it a try. > a = (1,2,3,4) a > (1, 2, 3, 4) a.index(3) > 2 a.index(5) > Traceback (most recent call last): > File "", line 1, in > ValueError: tuple.index(x): x not in tuple > > So my Python is say

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Ethan Furman
Mick Krippendorf wrote: Steve Holden wrote: Many such designs make mistakes like using multiple columns (or, even worse, comma-separated values) instead of many-to-many relationships. BTW, the comma-separted-values-in-a-field is officially called the First Anormal Form. There *has to be* som

Re: Module naming convention about StringIO

2009-10-15 Thread Terry Reedy
Peng Yu wrote: It says on http://www.python.org/dev/peps/pep-0008/ Package and Module Names Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names,

Moving subwindows in curses does not seem to work

2009-10-15 Thread Mitko Haralanov
Hi all, I am attempting to learn curses programming and in the process have created a small curses ui program. I am currently working on the code which is handling resizing the terminal window. As part of the resizing of the terminal window, I have to resize and move some of the subwindows in my u

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Mick Krippendorf
Steve Holden wrote: > Many such designs make mistakes like using multiple columns > (or, even worse, comma-separated values) instead of many-to-many > relationships. BTW, the comma-separted-values-in-a-field is officially called the First Anormal Form. There *has to be* some value to it since I'v

Re: set using alternative hash function?

2009-10-15 Thread Anthony Tolle
On Oct 15, 1:49 pm, Ethan Furman wrote: > I'm still not sure I understand your concern about the values in a set, > though.  Sets keep the first object of a given key, dicts keep the last > object of a given key; in both cases, all other objects with the same > key are lost. > > So is that the beh

Python-URL! - weekly Python news and links (Oct 15)

2009-10-15 Thread Gabriel Genellina
QOTW: "It is however, much like the framework in question, best kept private and not made public." - Ed Singleton, on a "perfectly healthful and acceptable" practice ... left unnamed here http://groups.google.com/group/comp.lang.python/msg/987b1a7a4b9 01f3f Looking for a sane way of

struct curiosity

2009-10-15 Thread pjcoup
Hello, I was fooling around with python's struct lib, looking on how we'd unpack some data. I was a little confused by its behavior: Python 2.5.2 (r252:60911, Jul 22 2009, 15:33:10) [GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2 Type "help", "copyright", "credits" or "license" for more information

Re: Problem

2009-10-15 Thread Tim Chase
I can't send emails out. Can u fix this problem please? The problem is on line 72. Oh wait...you didn't include any code or the traceback. Yeah, that's gonna make it a little difficult to diagnose. But I'm gonna guess that "The authentication setting might not be correct for your outgoing e-m

Re: set using alternative hash function?

2009-10-15 Thread Ethan Furman
Austin Bingham wrote: Yes, I can construct a dict as you specify, where all of the keys map to values with name attributes equal to the key. My point is that dict doesn't really help me enforce that beyond simply letting me set it up; it doesn't care about the values at all, just the keys. All th

Re: set using alternative hash function?

2009-10-15 Thread Gabriel Genellina
En Thu, 15 Oct 2009 13:24:18 -0300, Rami Chowdhury escribió: On Thu, 15 Oct 2009 09:11:00 -0700, Austin Bingham wrote: On Thu, Oct 15, 2009 at 5:15 PM, Gabriel Genellina wrote: En Thu, 15 Oct 2009 11:42:20 -0300, Austin Bingham escribió: I think you didn't understand correctly Anthony

Re: Problem

2009-10-15 Thread Xavier Ho
On Fri, Oct 16, 2009 at 3:28 AM, Ander wrote: > I can't send emails out. Can u fix this problem please? > I don't know what I'm missing here, but you evidently sent out an email to the Python mailing list... Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Problem

2009-10-15 Thread Ander
I can't send emails out. Can u fix this problem please? The message could not be sent. The authentication setting might not be correct for your outgoing e-mail [SMTP] server. For help solving this problem, go to Help, search for "Troubleshoot Windows Mail", and read the "I'm having problems sendi

Re: where's self.assertMatch (for Django)?

2009-10-15 Thread Phlip
> When I google (including codesearch) for assertMatch, I get a mishmash of > opinions. Am I missing the One True assertMatch(), or isn't there one and I > gotta write it? or copy and use one of the pretenders? Ookay, try this: def assertMatch(self, pattern, slug): r = re.compile(patt

Re: set using alternative hash function?

2009-10-15 Thread Anthony Tolle
On Oct 15, 12:11 pm, Austin Bingham wrote: > To put it in code, I want this: > >   s = set(hash_func = lambda obj: hash(obj.name), eq_func = ...) >   ... >   x.name = 'foo' >   y.name = 'foo' >   s.add(x) >   s.add(y) # no-op because of uniqueness criteria >   assert len(s) == 1 I wrote a quick s

Re: Load a list subset with pickle?

2009-10-15 Thread Gabriel Genellina
En Thu, 15 Oct 2009 13:05:18 -0300, Peng Yu escribió: How do I determine if I have loaded all the elements? I use the following code. I'm wondering if there is any better solution than this. ### import pickle alist = [1, 2.0, 3, 4+6j] output=open('serialize_list.output/serialize

Re: Load a list subset with pickle?

2009-10-15 Thread Gabriel Genellina
En Thu, 15 Oct 2009 13:05:18 -0300, Peng Yu escribió: How do I determine if I have loaded all the elements? I use the following code. I'm wondering if there is any better solution than this. ### import pickle alist = [1, 2.0, 3, 4+6j] output=open('serialize_list.output/serialize

Re: How to organize code for conversion between different classes? (avoiding cyclic dependencies)

2009-10-15 Thread Stephen Hansen
On Thu, Oct 15, 2009 at 8:02 AM, Peng Yu wrote: > Suppose I have classes 'A', 'B', 'C', 'D'. The definition of these > classes are long enough so that I have to put each class in a separate > module 'mA', 'mB', 'mC', 'mD', which are in packages 'pA', 'pB', 'pC', > 'pD', respectively. And there

Re: Load a list subset with pickle?

2009-10-15 Thread Robert Kern
On 2009-10-15 11:05 AM, Peng Yu wrote: On Tue, Oct 13, 2009 at 1:23 PM, Robert Kern wrote: On 2009-10-13 13:00 PM, Peng Yu wrote: I use pickle to dump a long list. But when I load it, I only want to load the first a few elements in the list. I am wondering if there is a easy way to do so? Tha

Problem with character encoding in commandline

2009-10-15 Thread gialloporpora
Dear all, I have a strange problem that I am not able to solve myself. I have written a little Python script to download image from last.fm, now, if I call it from the python environment it works, if I call it from Windows console it doesn't works If I open the prompt and run python I call

Re: Module naming convention about StringIO

2009-10-15 Thread Tim Golden
Peng Yu wrote: It says on http://www.python.org/dev/peps/pep-0008/ ... don't get too hung up on things like this. Just use the modules. But StringIO does not following this convention. Although on the same page, it also mentions the following. However, since StringIO is in the library, shall

Re: Python XMLRPC question

2009-10-15 Thread prasanna
Thanks a bunch. Qill give it a shot. --p On Oct 14, 8:18 pm, "Gabriel Genellina" wrote: > En Wed, 14 Oct 2009 22:08:09 -0300,prasanna   > escribió: > > > Out of curiosity--one more thing I haven't yet figured out, is there a > > xmlrpc command I can send that stops or restarts the server? > > If

Module naming convention about StringIO

2009-10-15 Thread Peng Yu
It says on http://www.python.org/dev/peps/pep-0008/ Package and Module Names Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the use

Re: python performance on Solaris

2009-10-15 Thread Antoine Pitrou
Le Wed, 14 Oct 2009 22:39:14 -0700, John Nagle a écrit : > > Note that multithreaded compute-bound Python programs really suck > on multiprocessors. Adding a second CPU makes the program go slower, > due to a lame mechanism for resolving conflicts over the global > interpreter lock. I'm not

Re: set using alternative hash function?

2009-10-15 Thread Rami Chowdhury
On Thu, 15 Oct 2009 09:11:00 -0700, Austin Bingham wrote: On Thu, Oct 15, 2009 at 5:15 PM, Gabriel Genellina wrote: En Thu, 15 Oct 2009 11:42:20 -0300, Austin Bingham escribió: I think you didn't understand correctly Anthony Tolle's suggestion: py> class Foo: ...   def __init__(self, name

Re: id( ) function question

2009-10-15 Thread Laszlo Nagy
None, True, False, integers and strings are not mutable. The only time the id is the "same" between two objects is if they are the identical two objects. I'm aware of that. ;-) CPython just (as a performance optimization) re-uses the same objects sometimes even if people think they're usi

Re: set using alternative hash function?

2009-10-15 Thread Austin Bingham
On Thu, Oct 15, 2009 at 5:15 PM, Gabriel Genellina wrote: > En Thu, 15 Oct 2009 11:42:20 -0300, Austin Bingham > escribió: > I think you didn't understand correctly Anthony Tolle's suggestion: > > py> class Foo: > ...   def __init__(self, name): self.name = name > ... > py> objs = [Foo('Joe'), Fo

Re: Load a list subset with pickle?

2009-10-15 Thread Peng Yu
On Tue, Oct 13, 2009 at 1:23 PM, Robert Kern wrote: > On 2009-10-13 13:00 PM, Peng Yu wrote: >> >> I use pickle to dump a long list. But when I load it, I only want to >> load the first a few elements in the list. I am wondering if there is >> a easy way to do so? Thank you! > > Not by pickling th

Re: id( ) function question

2009-10-15 Thread Laszlo Nagy
Christian Heimes írta: Chris Rebert wrote: The built-ins aren't mutable, and the singletons are each immutable and/or unique; so in no case do objects that are both different and mutable have the same ID. Correct, the fact allows you to write code like "type(egg) is str" to check if an

Re: id( ) function question

2009-10-15 Thread Laszlo Nagy
The built-ins aren't mutable, and the singletons are each immutable and/or unique; so in no case do objects that are both different and mutable have the same ID. I know. :-) Although I have no idea how it is that `id({}) == id({})` as a prior posted showed; FWIW, I can't manage to reproduce

Re: id( ) function question

2009-10-15 Thread Christian Heimes
Mel wrote: > As Python has evolved the semantics have got richer, and the implementation > has got trickier with proxy objects and wrapped functions and more. > Whatever use there was for `is` in ordinary code is vanishing. 'is' has important use cases but it's not trivial to use if you leave t

Yet Another Pic Problem

2009-10-15 Thread Victor Subervi
Hi; My code was working fine then I must have inadvertently screwed something up. The result is a mysql insert/update statement that looks something like the following: update productsX set Name=%s, Title=%s, Description=%s, Price=%s, Bedrooms=%s, Bathrooms=%s, Conditions=%s, Acreage=%s, Construct

Re: set using alternative hash function?

2009-10-15 Thread Gabriel Genellina
En Thu, 15 Oct 2009 11:42:20 -0300, Austin Bingham escribió: On Thu, Oct 15, 2009 at 4:06 PM, Anthony Tolle wrote: Why not use a dict?  The key would be the object name.  Pretty much the same behavior as a set (via the key), and you can still easily iterate over the objects. To reiterate

Re: HTMLgen???

2009-10-15 Thread tinnews
Gabriel Genellina wrote: > En Thu, 15 Oct 2009 05:58:02 -0300, escribió: > > > Does HTMLgen (Robin Friedrich's) still exsist?? And, if so, where can it > > be found? > > Would you consider using HyperText? It's inspired on HTMLGen but I like > its design much more (that said, currently I pref

  1   2   >