Re: Why are there no ordered dictionaries?

2005-11-22 Thread Fredrik Lundh
Tom Anderson wrote: > Incidentally, can we call that the "Larosa-Foord ordered mapping"? The implementation, sure. > Then it sounds like some kind of rocket science discrete mathematics stuff But math folks usually name things after the person(s) who came up with the idea, not just some random

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
Alex Martelli schrieb: > Perl hashes now keep track of 'order of keys'? That's new to me, they > sure didn't back when I used Perl! Maybe I shouldn't have talked about Perl when I'm an ignoramus about that language... You're right, Perl has unordered arrays. That was new to me since I associate

Re: linking one extension module to another (Mac OSX)

2005-11-22 Thread pianomaestro
Martin v. Löwis wrote: > Simon Burton wrote: > > I'm having some trouble linking one extension module to another because > > the linker expects a "lib" prefix and my python modules cannot have > > this prefix. > > This is a Good Thing (tm) :-) Don't link extension modules to each > other; this is

Re: about sort and dictionary

2005-11-22 Thread Duncan Booth
Magnus Lycka wrote: > Actually, I guess it's possible that sorted() is done so > that it works like below, but I don't think pre-sorted() > versions of Python support keyword arguments to list.sort() > anyway... > > def sorted(l, *p, **kw): s=l[:];s.sort(*p, **kw);return s One part you missed, s

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
Bengt Richter schrieb: > Ok, so if not in the standard library, what is the problem? Can't find what > you want with google and PyPI etc.? Or haven't really settled on what your > _requirements_ are? That seems to be the primary problem people who complain > with "why no sprollificator mode?" quest

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Fredrik Lundh
Alex Martelli wrote: > What about PHP? Thanks! according to some random PHP documentation I found on the intarweb: An array in PHP is actually an ordered map. A map is a type that maps values to keys. and later: A key may be either an integer or a string. If a key is the standard

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
Bengt Richter wrote: > d = OrderedDict(); d[1]='one'; d[2]='two' =>> list(d) => [1, 2] > ok, now we do d[1]='ein' and what is the order? list(d) => [2, 1] ?? > Or do replacements not count as "insertions"? If you simply set a value for a key that already exists, the order should not be change

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Kay Schluehr
Christoph Zwerschke wrote: > That would be also biased (in favour of Python) by the fact that > probably very little people would look for and use the package in the > cheese shop if they were looking for ordered dicts. Does anyone actually use this site? While the Vaults offered a nice place and

Re: ownership problem?

2005-11-22 Thread Fredrik Lundh
Alex Martelli wrote: > Python 2.5 should introduce a 'with' statement that may go partways > towards meeting your qualms; it's an approved PEP, though I do not > recall its number offhand. http://www.python.org/peps/pep-0343.html (this is one in a series of PEP:s based on the observation that th

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Fuzzyman
Christoph Zwerschke wrote: > Fredrik Lundh wrote: [snip..] > You're right; I found creating a Larosa/Foord OrderedDict in this > example to be even 8 times slower than an ordinary dict. However, two > things need to be said here: 1) The dictionary in my exmaple was pretty > small (only 3 items), so

Re: best cumulative sum

2005-11-22 Thread [EMAIL PROTECTED]
David Isaac wrote: > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > He seems to want scanl > > Yes. But it's not in Python, right? > (I know about Keller's version.) > > Robert Kern wrote: > > Define better. More accurate? Less code? > > Good point. > As Bonono (?) suggested: I

Re: Application Plugin Framework

2005-11-22 Thread Harald Armin Massa
Ron, > I'm attempting to develop a plugin framework for an application that I'm > working on. I wish to develop something in which all plugins exist in a > directory tree. The PIL of the effbot is doing exactly this. (Python Image Library). I know it, because I had to work around that dynamic

Re: about sort and dictionary

2005-11-22 Thread [EMAIL PROTECTED]
Magnus Lycka wrote: > sorted_l = l.sort() > > and while sorted_l would contain what one might expect, it > would in fact just be another name referencing exactly the > same sorted list as l, and it would probably be surprising > that l was also sorted, and that subsequent changes would > show up i

Re: How to paste python code on wordpress?

2005-11-22 Thread Fredrik Lundh
Dan Lowe wrote > Replace < with < > > Replace > with > > > (where those abbreviations stand for "less than" and "greater than") > > Before: if x < 5: > > After: if x < 5: > > Another common character in code that you "should" do similarly is > the double quote ("). For that, use " > > Before: if x

Re: keys in dictionary

2005-11-22 Thread Georges Barthelemy
use (1,2) , (3,4) "Shi Mu" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] I run the following code and got wrong message, but I still want to make [1,2],[4,3] and [6,9] to be keys of the dictionary or change the style a little bit. How to do that? Thanks! >>> p=[[1,

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Fuzzyman
Kay Schluehr wrote: > Christoph Zwerschke wrote: > > > That would be also biased (in favour of Python) by the fact that > > probably very little people would look for and use the package in the > > cheese shop if they were looking for ordered dicts. > > Does anyone actually use this site? While th

Re: How to paste python code on wordpress?

2005-11-22 Thread Iain King
Dan Lowe wrote: > On Nov 22, 2005, at 12:30 AM, could ildg wrote: > > > Thank you~ > > It works! > > but how can paste "<" and ">", please? > > these 2 symbols will also confuse wordpress and I can't publish > > what I want. > > Replace < with < > > Replace > with > > > (where those abbreviations

Re: about sort and dictionary

2005-11-22 Thread [EMAIL PROTECTED]
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > > so what would an entry-level Python programmer expect from this > > > piece of code? > > > > > > for item in a.reverse(): > > > print item > > > for item in a.reverse(): > > > print item > > > > > I would expect it to

Re: about sort and dictionary

2005-11-22 Thread [EMAIL PROTECTED]
Fredrik Lundh wrote: > so what would an entry-level Python programmer expect from this > piece of code? > > for item in a.reverse(): > print item > for item in a.reverse(): > print item > I would expect it to first print a in reverse then a as it was. a=[1,2,3] I expect i

Re: about sort and dictionary

2005-11-22 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > > so what would an entry-level Python programmer expect from this > > piece of code? > > > > for item in a.reverse(): > > print item > > for item in a.reverse(): > > print item > > > I would expect it to first print a in reverse then a as it was.

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Steven D'Aprano
On Tue, 22 Nov 2005 09:20:34 +0100, Fredrik Lundh wrote: > Tom Anderson wrote: > >> Incidentally, can we call that the "Larosa-Foord ordered mapping"? > > The implementation, sure. > >> Then it sounds like some kind of rocket science discrete mathematics stuff > > But math folks usually name t

Re: about sort and dictionary

2005-11-22 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Since python's '=' is just name binding and that most objects(other > than those like int/float/string?) are mutable, I don't quite > understand why this is a gotcha that is so worrying. > > a = [1,2,3] > a.sorted() > b = a > > even an entry level python programmer can'

Converting a flat list to a list of tuples

2005-11-22 Thread metiu uitem
Say you have a flat list: ['a', 1, 'b', 2, 'c', 3] How do you efficiently get [['a', 1], ['b', 2], ['c', 3]] I was thinking of something along the lines of: for (key,number) in list: print key, number but it's not working... Thank you -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Magnus Lycka
Christoph Zwerschke wrote: > But please see my other reply: If the dictionary has more than 3 items > (say 10 or 20), and an effective ordered dict is used, it's not really > "a lot" slower. At least if we are talking about a situation were "on > demand" is "always". So, on the other side there

Re: Why are there no ordered dictionaries?

2005-11-22 Thread [EMAIL PROTECTED]
Bengt Richter wrote: > Ok, so if not in the standard library, what is the problem? Can't find what > you want with google and PyPI etc.? Or haven't really settled on what your > _requirements_ are? That seems to be the primary problem people who complain > with "why no sprollificator mode?" questi

Re: Converting a flat list to a list of tuples

2005-11-22 Thread Duncan Booth
metiu uitem wrote: > Say you have a flat list: > ['a', 1, 'b', 2, 'c', 3] > > How do you efficiently get > [['a', 1], ['b', 2], ['c', 3]] That's funny, I thought your subject line said 'list of tuples'. I'll answer the question in the subject rather than the question in the body: >>> aList = [

Re: Why are there no ordered dictionaries?

2005-11-22 Thread [EMAIL PROTECTED]
Christoph Zwerschke wrote: > Bengt Richter schrieb: > > Ok, so if not in the standard library, what is the problem? Can't find what > > you want with google and PyPI etc.? Or haven't really settled on what your > > _requirements_ are? That seems to be the primary problem people who complain > > wi

Re: Why are there no ordered dictionaries?

2005-11-22 Thread [EMAIL PROTECTED]
Christoph Zwerschke wrote: > Fredrik Lundh wrote: > > I'll repeat this one last time: for the use cases presented by Zwerschke > > and "bonono", using a list as the master data structure, and creating the > > dictionary on demand, is a lot faster than using a ready-made ordered > > dict implementa

Re: Converting a flat list to a list of tuples

2005-11-22 Thread Steven D'Aprano
On Tue, 22 Nov 2005 02:57:14 -0800, metiu uitem wrote: > Say you have a flat list: > ['a', 1, 'b', 2, 'c', 3] > > How do you efficiently get > [['a', 1], ['b', 2], ['c', 3]] def split_and_combine(L): newL = [] for i in range(len(L)//2): newL.append( [L[2*i], L[2*i+1]] ) retur

Re: Converting a flat list to a list of tuples

2005-11-22 Thread Fredrik Lundh
"metiu uitem" wrote: > Say you have a flat list: > ['a', 1, 'b', 2, 'c', 3] > > How do you efficiently get > [['a', 1], ['b', 2], ['c', 3]] simplest possible (works in all Python versions): L = ['a', 1, 'b', 2, 'c', 3] out = [] for i in range(0, len(L), 2): out.append(L[i:i+

Re: Converting a flat list to a list of tuples

2005-11-22 Thread [EMAIL PROTECTED]
Duncan Booth wrote: > metiu uitem wrote: > > > Say you have a flat list: > > ['a', 1, 'b', 2, 'c', 3] > > > > How do you efficiently get > > [['a', 1], ['b', 2], ['c', 3]] > > That's funny, I thought your subject line said 'list of tuples'. I'll > answer the question in the subject rather than the

Re: Converting a flat list to a list of tuples

2005-11-22 Thread Laurent Rahuel
metiu uitem wrote: > Say you have a flat list: > ['a', 1, 'b', 2, 'c', 3] > > How do you efficiently get > [['a', 1], ['b', 2], ['c', 3]] > > I was thinking of something along the lines of: > for (key,number) in list: > print key, number > > but it's not working... > > Thank you Hi, newLis

Re: about sort and dictionary

2005-11-22 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > so what would an entry-level Python programmer expect from this > piece of code? > > for item in a.reverse(): > print item > for item in a.reverse(): > print item > > I would expect it to first print a in reverse then a as it was. > > a=[1,2,3] > > I expect it to pri

Re: Converting a flat list to a list of tuples

2005-11-22 Thread metiu uitem
Thanks for the answer... yes the example was wrong! -- http://mail.python.org/mailman/listinfo/python-list

matching a string to extract substrings for which some function returns true

2005-11-22 Thread Amit Khemka
Hello All, say you have some string: "['a', 'b', 1], foobar ['d', 4, ('a', 'e')]" Now i want to extract all substrings for which "isinstance(eval(substr), list)" is "True" . now one way is to walk through the whole sample string and check the condition, I was wondering if there is any smarter way

Re: best cumulative sum

2005-11-22 Thread Gerard Flanagan
David Isaac wrote: > What's the good way to produce a cumulative sum? > E.g., given the list x, > cumx = x[:] > for i in range(1,len(x)): > cumx[i] = cumx[i]+cumx[i-1] > > What's the better way? > > Thanks, > Alan Isaac Don't know about better, but this is what I came up with: class PartialSum

Re: Converting a flat list to a list of tuples

2005-11-22 Thread Steven D'Aprano
On Tue, 22 Nov 2005 11:11:23 +, Duncan Booth wrote: aList = ['a', 1, 'b', 2, 'c', 3] it = iter(aList) zip(it, it) > [('a', 1), ('b', 2), ('c', 3)] I'm not sure if I should fall to my knees in admiration of a Cool Hack, or recoil in horror at a Bogus Kludge :-) The code looks l

sort in the list

2005-11-22 Thread Shi Mu
I use Python 2.3 to run the following code: >>> a=[[1,2],[4,8],[0,3]] >>> a.sort() >>> a [[0, 3], [1, 2], [4, 8]] >>> I wonder whether the sort function automatically consider the first element in the list of list as the sorting criteria or it just happens to be? Thanks! -- http://mail.python.org/

Re: Numeric array in unittest problem

2005-11-22 Thread [EMAIL PROTECTED]
Thanks all, I will use alltrue and allclose as Alex and Robert point out.. Cheers, pujo -- http://mail.python.org/mailman/listinfo/python-list

Re: matching a string to extract substrings for which some function returns true

2005-11-22 Thread Steven D'Aprano
On Tue, 22 Nov 2005 16:57:41 +0530, Amit Khemka wrote: > Hello All, > > say you have some string: "['a', 'b', 1], foobar ['d', 4, ('a', 'e')]" > Now i want to extract all substrings for which > "isinstance(eval(substr), list)" is "True" . That's an awfully open-ended question. Is there some sort

Using gettext to provide different language-version of a script

2005-11-22 Thread Thomas W
I'm trying to wrap my head around the docs at python.org related to the gettext-module, but I'm having some problem getting it to work. Is there any really simple, step-by-step on how to use this module available? This is my script so far : import gettext gettext.install('test2', '.', unicode=1)

Re: Converting a flat list to a list of tuples

2005-11-22 Thread Fredrik Lundh
Duncan Booth wrote: > That's funny, I thought your subject line said 'list of tuples'. I'll > answer the question in the subject rather than the question in the body: > > >>> aList = ['a', 1, 'b', 2, 'c', 3] > >>> it = iter(aList) > >>> zip(it, it) > [('a', 1), ('b', 2), ('c', 3)] yesterday, we g

Re: Why are there no ordered dictionaries?

2005-11-22 Thread A.M. Kuchling
On 22 Nov 2005 01:41:44 -0800, Kay Schluehr <[EMAIL PROTECTED]> wrote: > Does anyone actually use this site? While the Vaults offered a nice > place and a nice interface the Cheese Shop has the appeal of a code > slum. Looking at the Cheese Shop's home page at http://cheeseshop.python.or

Re: matching a string to extract substrings for which some function returns true

2005-11-22 Thread Amit Khemka
Well actually the problem is I have a list of tuples which i cast as string and then put in a html page as the value of a hidden variable. And when i get the string again, i want to cast it back as list of tuples: ex: input: "('foo', 1, 'foobar', (3, 0)), ('foo1', 2, 'foobar1', (3, 1)), ('foo2', 2,

Re: Converting a flat list to a list of tuples

2005-11-22 Thread André Malo
* Duncan Booth <[EMAIL PROTECTED]> wrote: > metiu uitem wrote: > > > Say you have a flat list: > > ['a', 1, 'b', 2, 'c', 3] > > > > How do you efficiently get > > [['a', 1], ['b', 2], ['c', 3]] > > That's funny, I thought your subject line said 'list of tuples'. I'll > answer the question in t

Re: matching a string to extract substrings for which some functionreturns true

2005-11-22 Thread Fredrik Lundh
Amit Khemka wrote: > Well actually the problem is I have a list of tuples which i cast as > string and then put in a html page as the value of a hidden variable. > And when i get the string again, i want to cast it back as list of tuples: > ex: > input: "('foo', 1, 'foobar', (3, 0)), ('foo1', 2, '

Re: Converting a flat list to a list of tuples

2005-11-22 Thread [EMAIL PROTECTED]
André Malo wrote: > * Duncan Booth <[EMAIL PROTECTED]> wrote: > > > metiu uitem wrote: > > > > > Say you have a flat list: > > > ['a', 1, 'b', 2, 'c', 3] > > > > > > How do you efficiently get > > > [['a', 1], ['b', 2], ['c', 3]] > > > > That's funny, I thought your subject line said 'list of tupl

Re: How to write an API for a Python application?

2005-11-22 Thread Duncan Grisby
In article <[EMAIL PROTECTED]>, Piet van Oostrum <[EMAIL PROTECTED]> wrote: >On http://www.zeroc.com/performance/ they compare it with TAO and it seems >to be faster. It looks also a bit simpler. I don't have experience with Ice >myself but a colleague of mine experimented with it and was enthous

Re: sort in the list

2005-11-22 Thread Fredrik Lundh
"Shi Mu" wrote: >I use Python 2.3 to run the following code: a=[[1,2],[4,8],[0,3]] a.sort() a > [[0, 3], [1, 2], [4, 8]] > I wonder whether the sort function automatically consider the first > element in the list of list as the sorting criteria or it just happens > to be? the

Re: need help about time.sleep, timer

2005-11-22 Thread Sinan Nalkaya
Bengt Richter wrote: >On Mon, 21 Nov 2005 10:35:20 +0200, Sinan Nalkaya <[EMAIL PROTECTED]> wrote: > > > >>Dennis Lee Bieber wrote: >> >> >> >>>On Fri, 18 Nov 2005 22:45:37 -0500, Peter Hansen <[EMAIL PROTECTED]> >>>declaimed the following in comp.lang.python: >>> >>> >>> >>> >>>

Re: bsddb185 question

2005-11-22 Thread thakadu
It seems it doesnt implement ALL of the dictionary interface though. dir({}) yields many more methods than dir(bsddb185.open(f)). So bsddb185 is missing many of the methods that I am used to in bsddb. I mentioned some above that are missing, pop() in particular would be useful in my situation but t

Geodetic Functions as DLL

2005-11-22 Thread killet
Hi, here is an information for the people who must develop programs with geodetic background and who asked me for a Englisch documentation of the geodetic functions included in GeoDLL. The DLL is present now with a complete English and German documentation! In the Dynamic Link Library are geodeti

Re: Tkinter's coordinates setting

2005-11-22 Thread Ben Bush
On 11/21/05, Steve Juranich <[EMAIL PROTECTED]> wrote: On 11/17/05, Shi Mu <[EMAIL PROTECTED]> wrote: > why subtract 1 from max_y - original_y?Because in the computer science world we like starting to count at 0.image_size = 1000original_y = 25 # Really the 26th pixel line.new_y = 1000 - 25 - 1 #

Re: Python install minimum requirements

2005-11-22 Thread Philippe C. Martin
Thanks I'll take a look. PS: www.u3.com Regards, Philippe [EMAIL PROTECTED] wrote: > If I found the right "U3" when I googled, then maybe this is relevant: > http://www.voidspace.org.uk/python/movpy/ > > Jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: How to paste python code on wordpress?

2005-11-22 Thread [EMAIL PROTECTED]
If you're using vim [1] as your editor, or even if you have it installed, you can make use of the 2html.vim script [2] to convert your python code to HTML complete with syntax highlighting. In vim, try running: :run! syntax/2html.vim If you don't want to run vim as your editor, but just want to c

Python in Optimized mode with /usr/bin/env

2005-11-22 Thread Paulo Eduardo Neves
This is more of a shell or env question, but I believe others here have gone through this. I want to run an optimized python using the portable /usr/bin/env, but the obvious ways aren't working. #!/usr/bin/env python -O when I run ./test.py I get: /usr/bin/env: python -O: No such file or directo

Re: matching a string to extract substrings for which some functionreturns true

2005-11-22 Thread Amit Khemka
Fredrik, thanks for your suggestion. Though the html page that are generated are for internal uses and input is verified before processing. And more than just a solution in current context, actually I was a more curious about how can one do so in Python. cheers, amit. On 11/22/05, Fredrik Lundh

Re: Converting a flat list to a list of tuples

2005-11-22 Thread David Isaac
"Duncan Booth" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >>> aList = ['a', 1, 'b', 2, 'c', 3] > >>> it = iter(aList) > >>> zip(it, it) > [('a', 1), ('b', 2), ('c', 3)] That behavior is currently an accident. http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail

Re: about sort and dictionary

2005-11-22 Thread [EMAIL PROTECTED]
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > so what would an entry-level Python programmer expect from this > > piece of code? > > > > for item in a.reverse(): > > print item > > for item in a.reverse(): > > print item > > > > I would expect it to first print a in reverse then a as it wa

Re: Python in Optimized mode with /usr/bin/env

2005-11-22 Thread Christoph Zwerschke
Paulo Eduardo Neves schrieb: > I want to run an optimized python using the portable /usr/bin/env, but > the obvious ways aren't working. Seems to be a Linux problems others also experienced: http://blog.ianbicking.org/shebang.html -- Christoph -- http://mail.python.org/mailman/listinfo/python-li

Re: sort the list

2005-11-22 Thread Nick Craig-Wood
Daniel Schüle <[EMAIL PROTECTED]> wrote: > lst.sort(lambda x,y: cmp(x[1], y[1])) Since no-one mentioned it and its a favourite of mine, you can use the decorate-sort-undecorate method, or "Schwartzian Transform" eg lst = [[1,4],[3,9],[2,5],[3,2]] # decorate - ie make a copy of each item with th

Re: Looking for magic method to override to prevent dict(d) from grabbing subclass inst d contents directly

2005-11-22 Thread Mike Meyer
[EMAIL PROTECTED] (Bengt Richter) writes: > Has anyone found a way besides not deriving from dict? > Shouldn't there be a way? > TIA > (need this for what I hope is an improvement on the Larosa/Foord OrderedDict > ;-) > > I guess I can just document that you have to spell it dict(d.items()), but I

after sorted from the lists

2005-11-22 Thread Ben Bush
I have a list: [[1,2],[2,1],[3,1],[1,4],[3,3],[1,4]] How to remove all the duplicate or same after sorted from the lists? That is, [1,2] and [2,1] are the same after sorting them. I want the result to be: [[1,2],[3,1],[1,4],[3,3]] -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Kay Schluehr
A.M. Kuchling wrote: > On 22 Nov 2005 01:41:44 -0800, > Kay Schluehr <[EMAIL PROTECTED]> wrote: > > Does anyone actually use this site? While the Vaults offered a nice > > place and a nice interface the Cheese Shop has the appeal of a code > > slum. > > Looking at the Cheese Shop's home page

Re: the first element in the list of list

2005-11-22 Thread Fredrik Lundh
Ben Bush wrote: > I have a lis: > [[1,3],[3,4],[5,6],[8,9],[14,0],[15,8]] > I want a code to test when the difference between the first element in > the list of list is equal to or larger than 6, then move the previous > lists to the end of the list. that is: > [[14,0],[15,8],[1,3],[3,4],[5,6],[8,

Re: the first element in the list of list

2005-11-22 Thread bruno at modulix
Ben Bush wrote: > I have a lis: > [[1,3],[3,4],[5,6],[8,9],[14,0],[15,8]] > I want a code Then write it. And when (if) you have problems with it, repost, we'll then be happy to help you. > to test when the difference between the first element in > the list of list is equal to or larger than 6,

Re: Application Plugin Framework

2005-11-22 Thread Kay Schluehr
Ron wrote: > Hello, > > I'm attempting to develop a plugin framework for an application that I'm > working on. I wish to develop something in which all plugins exist in a > directory tree. The framework need only be given the root of the tree. The > framework then uses os.path.walk to search al

Re: the first element in the list of list

2005-11-22 Thread Dennis Benzinger
Ben Bush schrieb: > I have a lis: > [[1,3],[3,4],[5,6],[8,9],[14,0],[15,8]] > I want a code to test when the difference between the first element in > the list of list is equal to or larger than 6, then move the previous > lists to the end of the list. that is: > [[14,0],[15,8],[1,3],[3,4],[5,6],[8

Re: after sorted from the lists

2005-11-22 Thread Micah Elliott
On Nov 22, Ben Bush wrote: > I have a list: > [[1,2],[2,1],[3,1],[1,4],[3,3],[1,4]] > How to remove all the duplicate or same after sorted from the lists? > That is, [1,2] and [2,1] are the same after sorting them. > I want the result to be: > [[1,2],[3,1],[1,4],[3,3]] You've described the code in

Re: after sorted from the lists

2005-11-22 Thread jepler
>>> ll = [[1,2],[2,1],[3,1],[1,4],[3,3],[1,4]] >>> ls = [frozenset(i) for i in ll] >>> ss = set(ls) >>> ss set([frozenset([1, 3]), frozenset([1, 2]), frozenset([1, 4]), frozenset([3])]) >>> [list(i) for i in ss] [[1, 3], [1, 2], [1, 4], [3]] pgphz7iINDVUi.pgp Description: PGP signature -- http:/

the first element in the list of list

2005-11-22 Thread Ben Bush
I have a lis: [[1,3],[3,4],[5,6],[8,9],[14,0],[15,8]] I want a code to test when the difference between the first element in the list of list is equal to or larger than 6, then move the previous lists to the end of the list. that is: [[14,0],[15,8],[1,3],[3,4],[5,6],[8,9]] -- http://mail.python.or

Re: after sorted from the lists

2005-11-22 Thread Ben Bush
On 11/22/05, Ben Bush <[EMAIL PROTECTED]> wrote: > I have a list: > [[1,2],[2,1],[3,1],[1,4],[3,3],[1,4]] > How to remove all the duplicate or same after sorted from the lists? > That is, [1,2] and [2,1] are the same after sorting them. > I want the result to be: > [[1,2],[3,1],[1,4],[3,3]] I want

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Fuzzyman
Of course ours is ordered *and* orderable ! You can explicitly alter the sequence attribute to change the ordering. I think we're looking at improving performance based on some of the suggestions here - as well as possibly widening it to include some of the alternative use cases. (Or at least Nico

Re: about sort and dictionary

2005-11-22 Thread Fredrik Lundh
> Still don't see why even you ask it again. fyi, I'm not " [EMAIL PROTECTED] ", and I've never, as far I know, posted from "readfreenews.net" -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting a flat list to a list of tuples

2005-11-22 Thread George Sakkis
"Laurent Rahuel" wrote: > Hi, > > newList = zip(aList[::2], aList[1::2]) > newList > [('a', 1), ('b', 2), ('c', 3)] > > Regards, > > Laurent Or if aList can get very large and/or the conversion has to be performed many times: from itertools import islice newList = zip(islice(aList,0,None,2), isl

Dictionary string parser

2005-11-22 Thread Sebastjan Trepca
Hi, is there any library or some way to parse dictionary string with list, string and int objects into a real Python dictionary? For example: >>> my_dict = dict_parser("{'test':'123','hehe':['hooray',1]}") I could use eval() but it's not very fast nor secure. Thanks, Sebastjan -- http://mail.

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Alex Martelli
Fredrik Lundh <[EMAIL PROTECTED]> wrote: ... > But math folks usually name things after the person(s) who came > up with the idea, not just some random implementer. The idea of Wrong: you're forgetting Stigler's Law of Misonomy (which I imagine must have NOT been discovered by Stigler...;-).

Re: about sort and dictionary

2005-11-22 Thread [EMAIL PROTECTED]
Fredrik Lundh wrote: > > Still don't see why even you ask it again. > > fyi, I'm not " [EMAIL PROTECTED] ", and I've > never, as far I know, posted from "readfreenews.net" > I have no idea what you are talking about. I read this list through Google's group and I saw two of the same post. Google un

Re: the first element in the list of list

2005-11-22 Thread Ben Bush
On 11/22/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Ben Bush wrote: > > > I have a lis: > > [[1,3],[3,4],[5,6],[8,9],[14,0],[15,8]] > > I want a code to test when the difference between the first element in > > the list of list is equal to or larger than 6, then move the previous > > lists to t

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Magnus Lycka
Christoph Zwerschke wrote: > I still believe that the concept of an "ordered dictionary" ("behave > like dict, only keep the order of the keys") is intuitive and doesn't > give you so much scope for ambiguity. Sure. Others think so too. The problem is that if you and these other people actually

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Alex Martelli
Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > Alex Martelli schrieb: > > Perl hashes now keep track of 'order of keys'? That's new to me, they > > sure didn't back when I used Perl! > > Maybe I shouldn't have talked about Perl when I'm an ignoramus about > that language... You're right, Perl

Re: help with using temporary files

2005-11-22 Thread Jeremy Jones
Gerard Flanagan wrote: >Hello > > I'm sure its basic but I'm confused about the error I get with the >following code. Any help on basic tempfile usage? > > >ActivePython 2.4.1 Build 247 (ActiveState Corp.) based on >Python 2.4.1 (#65, Jun 20 2005, 17:01:55) [MSC v.1310 32 bit (Intel)] >on win32 >

port script to embedded device - decompile pyinstaller exe?

2005-11-22 Thread niclane
Hi, I have some python scripts, I need to run a netgear router, i have a cross compilation setup that works for c code no problem. the python interpreter doesn't appear to have been successfully cross compiled to this netgear router although others have tried. what i'd like to do is get these scr

help with using temporary files

2005-11-22 Thread Gerard Flanagan
Hello I'm sure its basic but I'm confused about the error I get with the following code. Any help on basic tempfile usage? ActivePython 2.4.1 Build 247 (ActiveState Corp.) based on Python 2.4.1 (#65, Jun 20 2005, 17:01:55) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits

Re: Backwards compatibility [was Re: is parameter an iterable?]

2005-11-22 Thread Tom Anderson
On Tue, 22 Nov 2005, Steven D'Aprano wrote: > Are there practical idioms for solving the metaproblem "solve problem X > using the latest features where available, otherwise fall back on older, > less powerful features"? > > For instance, perhaps I might do this: > > try: >built_in_feature >

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Stuart McGraw
"A.M. Kuchling" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [...] > What would improve the Cheese Shop's interface for you? Getting rid of those damn top level links to old versions. Seeing a long list of old versions, when 99% of visitors are only interested in the current vers

Re: Dictionary string parser

2005-11-22 Thread Fredrik Lundh
Sebastjan Trepca wrote: > is there any library or some way to parse dictionary string with list, > string and int objects into a real Python dictionary? > > For example: > > >>> my_dict = dict_parser("{'test':'123','hehe':['hooray',1]}") > > I could use eval() but it's not very fast nor secure. i

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Anton Vredegoor
Christoph Zwerschke wrote: > But of course, it will always be slower since it is constructed on top > of the built-in dict. In end effect, you always have to maintain a > sequence *plus* a dictionary, which will be always slower than a sheer > dictionary. The ordered dictionary class just hides th

Re: about sort and dictionary

2005-11-22 Thread rurpy
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > so what would an entry-level Python programmer expect from this > > piece of code? > > > > for item in a.reverse(): > > print item > > for item in a.reverse(): > > print item > > > > I would expect it to first print a in reverse then a as it was

Re: after sorted from the lists

2005-11-22 Thread Ben Bush
On 11/22/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > >>> ll = [[1,2],[2,1],[3,1],[1,4],[3,3],[1,4]] > >>> ls = [frozenset(i) for i in ll] > >>> ss = set(ls) > >>> ss > set([frozenset([1, 3]), frozenset([1, 2]), frozenset([1, 4]), frozenset([3])]) > >>> [list(i) for i in ss] > [[1, 3], [1, 2]

python win32 and COM? for internet monitoring

2005-11-22 Thread Matthew Thorley
Greetings, I have a question I hope some one with more back ground can give me a little help with. I want to write a simple internet monitoring script for windows that watches out bound http traffic and keeps a list of all the site visited. I am thinking that I might be able to use pywin32 and

Getting standard config directory

2005-11-22 Thread Mardy
Hi, I'm looking for a standard way to determine where to store a configuration file for my app, using distutils. At the moment, I'm using os.geteuid() == 0 to decide whether the configuration file should be written in /etc/myapp.cfg or in $HOME/.myapp.cfg (if the user running the setup.py is roo

Re: examining python objects

2005-11-22 Thread rurpy
Colin J. Williams wrote: > [EMAIL PROTECTED] wrote: > > Bruno Desthuilliers wrote: > > > >>[EMAIL PROTECTED] a écrit : > >> > >>>Is there a function/class/module/whatever I can use to > >>>look at objects? I want something that will print the object's > >>>value (if any) in pretty-printed form, an

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Fredrik Lundh
Stuart McGraw wrote > > What would improve the Cheese Shop's interface for you? > > Getting rid of those damn top level links to old versions. > Seeing a long list of old versions, when 99% of visitors are > only interested in the current version, is just visual noise, > and really lame. Move the

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Ben Sizer
Fredrik Lundh wrote: > Ben Sizer wrote: > > This is interesting; I would have thought that the tuple is read and a > > dictionary created by inserting each pair sequentially. Is this not the > > case? > > pointers to the members of each pair, yes. but a pointer copy is a > cheap operation (for the

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Bengt Richter
On 22 Nov 2005 02:16:22 -0800, "Fuzzyman" <[EMAIL PROTECTED]> wrote: > >Kay Schluehr wrote: >> Christoph Zwerschke wrote: >> >> > That would be also biased (in favour of Python) by the fact that >> > probably very little people would look for and use the package in the >> > cheese shop if they wer

drawline

2005-11-22 Thread Ben Bush
I had the following code and when I clicked the left mouse button one time. I got green line and the second click got a purple line and the green disappeared. I was confused by two questions: First, Clicknum increases when every time I click the button. Is it possible to reset Clicknum to 0? Second

Re: after sorted from the lists

2005-11-22 Thread Ben Bush
On 11/22/05, Ben Bush <[EMAIL PROTECTED]> wrote: > On 11/22/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > >>> ll = [[1,2],[2,1],[3,1],[1,4],[3,3],[1,4]] > > >>> ls = [frozenset(i) for i in ll] > > >>> ss = set(ls) > > >>> ss > > set([frozenset([1, 3]), frozenset([1, 2]), frozenset([1, 4]),

Re: the first element in the list of list

2005-11-22 Thread Fredrik Lundh
"Ben Bush" wrote: > This question just came to my mind and not assigned by anyone. given that you and "Shi Mu" are asking identical questions, and that you've both started to send questions via direct mail, can you please ask your course instructor to contact me asap. thanks /F -- http://ma

Timeout for regular expression

2005-11-22 Thread citronelu
Hi All, Is there a way to set a timeout interval when executing with a re.search ? Sometimes (reason being maybe a "bad" pattern), the search takes forever and beyond... -- http://mail.python.org/mailman/listinfo/python-list

  1   2   3   >