Re: sort functions in python

2008-02-09 Thread Steven D'Aprano
On Fri, 08 Feb 2008 19:09:06 -0800, Jeff Schwab wrote: > Steven D'Aprano wrote: >> On Fri, 08 Feb 2008 17:00:27 -0800, t3chn0n3rd wrote: >> >>> Do you think it is relatively easy to write sort algorithms such as >>> the common Bubble sort in Python as compared to other high level >>> programming

troika 2008

2008-02-09 Thread bots
Hello programmers, IEEE Student branch, Delhi College of Engineering invites you to be a part of its much awaited technical fest TROIKA '08 Get ready to enter the battle where your analytical skills and mental acumen are tested to their maximum, where time runs fast and beating the odds is a dire

Re: Pure Python Salsa20 Stream Cipher Implementation

2008-02-09 Thread Paul Rubin
[EMAIL PROTECTED] writes: > The reason for a pure python is that it would be independent from the > platform. A C implementation is faster, but you need to compile it for > every platform. A python implementation doesn't have that problem and > could be used to fall back upon. But why salsa20 in t

Re: Pure Python Salsa20 Stream Cipher Implementation

2008-02-09 Thread Paul Rubin
"Gabriel Genellina" <[EMAIL PROTECTED]> writes: > On most platforms -with a notable exception- there is a C compiler > available as a standard tool, which is used to compile Python itself. The notable exception that you're thinking of is pervasive, but since Python is usually distributed as a bina

Re: multi-Singleton-like using __new__

2008-02-09 Thread Hrvoje Niksic
Matt Nordhoff <[EMAIL PROTECTED]> writes: > Steven D'Aprano wrote: >> Except that using has_key() means making an attribute lookup, which takes >> time. > > I was going to say that, but doesn't 'in' require an attribute lookup of > some sort too, of __contains__ or whatever? It doesn't. Frequen

Re: how to run python script on remote machine

2008-02-09 Thread Tim Golden
Tim Golden wrote: > ... You can, for example, use DCOM to instantiate a > remote Python interpreter but the rest you probably be quite hard > word. (Ahem!) Or maybe: You can, for example, use DCOM to instantiate a remote Python interpreter but doing the rest you'll probably find quite hard work.

Re: which one is more efficient

2008-02-09 Thread bearophileHUGS
Michael Spencer: > # perhaps faster > $ python -mtimeit -s"t='D'" "if t in 'DE': pass" > 100 loops, best of 3: 0.204 usec per loop That may be faster indeed, but it gives true if t is "DE" too, and that may be bad. The new string search done by Effbot is really good :-) Bye, bearophile -- ht

online marketing make money

2008-02-09 Thread sam
It is new one online business you can earn minimum 1000$ per month great oppertunity to students,house wives,retired persons andall others . http://onlinemarketingmakemoney.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Pure Python Salsa20 Stream Cipher Implementation

2008-02-09 Thread bearophileHUGS
Gabriel Genellina: > On most platforms -with a notable exception- there is a C compiler > available as a standard tool, which is used to compile Python itself. For that platform the Python site may offer a version of binary Python bundled with the MingGW (and Cython too, maybe), like ShedSkin does

Recursion limit of pickle?

2008-02-09 Thread Victor Lin
Hi, I encounter a problem with pickle. I download a html from: http://www.amazon.com/Magellan-Maestro-4040-Widescreen-Navigator/dp/B000NMKHW6/ref=sr_1_2?ie=UTF8&s=electronics&qid=1202541889&sr=1-2 and parse it with BeautifulSoup. This page is very huge. When I use pickle to dump it, a RuntimeErr

Edit Python code programmatically

2008-02-09 Thread Alex
Which library could you recommend to perform simple editing of Python code (from Python program)? For example, open *.py file, find specific function definition, add another function call inside, find existing call and change parameter value, etc. What I'm trying to implement isn't a real visua

Re: Edit Python code programmatically

2008-02-09 Thread Guilherme Polo
2008/2/9, Alex <[EMAIL PROTECTED]>: > Which library could you recommend to perform simple editing of Python > code (from Python program)? For example, open *.py file, find specific > function definition, add another function call inside, find existing > call and change parameter value, etc. > Y

Re: Edit Python code programmatically

2008-02-09 Thread Ben Finney
Alex <[EMAIL PROTECTED]> writes: > Which library could you recommend to perform simple editing of > Python code (from Python program)? For example, open *.py file, find > specific function definition, add another function call inside, find > existing call and change parameter value, etc. You migh

Re: Edit Python code programmatically

2008-02-09 Thread Alex
Guilherme Polo wrote: > 2008/2/9, Alex <[EMAIL PROTECTED]>: > >> Which library could you recommend to perform simple editing of Python >> code (from Python program)? For example, open *.py file, find specific >> function definition, add another function call inside, find existing >> call and

Re: Edit Python code programmatically

2008-02-09 Thread Alex
Steven D'Aprano wrote: > On Sat, 09 Feb 2008 14:38:29 +0300, Alex wrote: > > >> Which library could you recommend to perform simple editing of Python >> code (from Python program)? >> > > I'm not even sure such a library exists. > Yes they exist, that field is called "code-generation",

Re: which one is more efficient

2008-02-09 Thread Steven D'Aprano
On Sat, 09 Feb 2008 02:08:15 -0800, bearophileHUGS wrote: > The new string search done by Effbot is really good :-) Care to explain what "new string search" you're referring to? Inquiring minds want to know. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Edit Python code programmatically

2008-02-09 Thread Steven D'Aprano
On Sat, 09 Feb 2008 14:38:29 +0300, Alex wrote: > Which library could you recommend to perform simple editing of Python > code (from Python program)? I'm not even sure such a library exists. > For example, open *.py file, find specific > function definition, add another function call inside, f

Re: multi-Singleton-like using __new__

2008-02-09 Thread Arnaud Delobelle
On Feb 9, 1:38 am, Freek Dijkstra <[EMAIL PROTECTED]> wrote: > J Peyret wrote: [...] > I'll use __metaclass__ solution. Here is my (non-threaded) version: Great! There's nothing voodoo about metaclasses. > class RDFObject(object): >     _cache = {}   # class variable is shared among all RDFObject

Re: Edit Python code programmatically

2008-02-09 Thread Dustan
On Feb 9, 6:10 am, Alex <[EMAIL PROTECTED]> wrote: > Guilherme Polo wrote: > > 2008/2/9, Alex <[EMAIL PROTECTED]>: > > >> Which library could you recommend to perform simple editing of Python > >> code (from Python program)? For example, open *.py file, find specific > >> function definition, add

Re: Edit Python code programmatically

2008-02-09 Thread Guilherme Polo
2008/2/9, Alex <[EMAIL PROTECTED]>: > Guilherme Polo wrote: > > 2008/2/9, Alex <[EMAIL PROTECTED]>: > > > >> Which library could you recommend to perform simple editing of Python > >> code (from Python program)? For example, open *.py file, find specific > >> function definition, add another

Re: Edit Python code programmatically

2008-02-09 Thread Guilherme Polo
2008/2/9, Arnaud Delobelle <[EMAIL PROTECTED]>: > On Feb 9, 12:32 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > > 2008/2/9, Alex <[EMAIL PROTECTED]>: > > > > > Guilherme Polo wrote: > > > > 2008/2/9, Alex <[EMAIL PROTECTED]>: > > > > > > >> Which library could you recommend to perform si

Re: Edit Python code programmatically

2008-02-09 Thread Arnaud Delobelle
On Feb 9, 12:32 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > 2008/2/9, Alex <[EMAIL PROTECTED]>: > > > Guilherme Polo wrote: > >  > 2008/2/9, Alex <[EMAIL PROTECTED]>: > > >  >> Which library could you recommend to perform simple editing of Python > >  >>  code (from Python program)? For examp

[ANN] XPN 1.0.0 released

2008-02-09 Thread Nemesis
XPN (X Python Newsreader) is a multi-platform newsreader with Unicode support. It is written with Python+GTK. It has features like scoring/actions, X-Face and Face decoding, muting of quoted text, newsrc import/export, find article and search in the body, spoiler char/rot13, random taglines and con

Re: Edit Python code programmatically

2008-02-09 Thread Steve Holden
Guilherme Polo wrote: > 2008/2/9, Arnaud Delobelle <[EMAIL PROTECTED]>: >> On Feb 9, 12:32 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: >> > 2008/2/9, Alex <[EMAIL PROTECTED]>: >> > >> > > Guilherme Polo wrote: >> > > > 2008/2/9, Alex <[EMAIL PROTECTED]>: >> >> > > >> Which library could

Re: are elements of a list in sequence in list b

2008-02-09 Thread bearophileHUGS
Steven D'Aprano: > What you're trying to do is the equivalent of substring searching. There > are simple algorithms that do this, and there are fast algorithms, but > the simple ones aren't fast and the fast ones aren't simple. > However, for your use case, the simple algorithm is probably fast eno

Re: Edit Python code programmatically

2008-02-09 Thread Alex
Guilherme Polo wrote: > 2008/2/9, Arnaud Delobelle <[EMAIL PROTECTED]>: > >> On Feb 9, 12:32 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: >> > 2008/2/9, Alex <[EMAIL PROTECTED]>: >> > >> > > Guilherme Polo wrote: >> > > > 2008/2/9, Alex <[EMAIL PROTECTED]>: >> >> >> > > >> Which l

Sudden pyexpat error with ElementTree

2008-02-09 Thread Simon Pickles
Hi, I've been using ElementTree for a few weeks without problem, with Stackless Python. Suddenly I have an error importing expat, in both application and console: [EMAIL PROTECTED]:~$ python Python 2.5.2a0 Stackless 3.1b3 060516 (release25-maint:60694M, Feb 9 2008, 13:21:41) [GCC 4.1.3 200709

Re: OT: Speed of light [was Re: Why not a Python compiler?]

2008-02-09 Thread Martin P. Hellwig
Steven D'Aprano wrote: > On Wed, 06 Feb 2008 10:14:10 -0600, Reedick, Andrew wrote: > 'c' is also the speed of light. >>> 'c' is the speed of light _in_a_vacuum_. >> True. >> >> And since nothing can travel faster than light... >>> Nothing can travel faster than the speed of light _in_a_

Re: OT: Speed of light [was Re: Why not a Python compiler?]

2008-02-09 Thread Thomas Dybdahl Ahle
On Sat, 2008-02-09 at 14:56 +0100, Martin P. Hellwig wrote: > > Propagate, travel, what's the difference? > > > Unfortunately, I didn't study any of this but I sure do remember the > answer one drunk physic said to me in a bar when I ask him the question: > "Does light travel or propagate?" > H

Re: Edit Python code programmatically

2008-02-09 Thread Guilherme Polo
2008/2/9, Alex <[EMAIL PROTECTED]>: > Guilherme Polo wrote: > > 2008/2/9, Arnaud Delobelle <[EMAIL PROTECTED]>: > > > >> On Feb 9, 12:32 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > >> > 2008/2/9, Alex <[EMAIL PROTECTED]>: > >> > > >> > > Guilherme Polo wrote: > >> > > > 2008/2/9,

Re: are elements of a list in sequence in list b

2008-02-09 Thread Steven D'Aprano
On Sat, 09 Feb 2008 05:44:27 -0800, bearophileHUGS wrote: > def issubseq(sub, items): > """issubseq(sub, items): return true if the sequence 'sub' is a > contiguous subsequence of the 'items' sequence. [snip] A stylistic note for you... I believe that it is considered an abuse of doctest to

Re: Edit Python code programmatically

2008-02-09 Thread Guilherme Polo
2008/2/9, Alex <[EMAIL PROTECTED]>: > Guilherme Polo wrote: > > 2008/2/9, Alex <[EMAIL PROTECTED]>: > > > >> Guilherme Polo wrote: > >> > 2008/2/9, Arnaud Delobelle <[EMAIL PROTECTED]>: > >> > > >> >> On Feb 9, 12:32 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > >> >> > 2008/2/9, Al

Re: Edit Python code programmatically

2008-02-09 Thread Alex
Guilherme Polo wrote: > 2008/2/9, Alex <[EMAIL PROTECTED]>: > >> Guilherme Polo wrote: >> > 2008/2/9, Arnaud Delobelle <[EMAIL PROTECTED]>: >> > >> >> On Feb 9, 12:32 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: >> >> > 2008/2/9, Alex <[EMAIL PROTECTED]>: >> >> > >> >> > > Guilherme

Re: Sudden pyexpat error with ElementTree

2008-02-09 Thread Stefan Behnel
Simon Pickles wrote: > ImportError: > /usr/lib/python2.5/site-packages/_xmlplus/parsers/pyexpat.so: undefined > symbol: PyUnicodeUCS4_Decode You changed the build-time configuration of your Python installation, so you should rebuild PyXML for the new interpreter (or uninstall it, as you don't need

Re: OT: Speed of light [was Re: Why not a Python compiler?]

2008-02-09 Thread Grant Edwards
On 2008-02-09, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote: > > On Sat, 2008-02-09 at 14:56 +0100, Martin P. Hellwig wrote: >> > Propagate, travel, what's the difference? >> > >> Unfortunately, I didn't study any of this but I sure do remember the >> answer one drunk physic said to me in a bar

Re: keyword 'in' not returning a bool?

2008-02-09 Thread Eyal Lotem
Arnaud Delobelle wrote: > On Feb 8, 5:20 pm, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: >> > -Original Message- >> > From: [EMAIL PROTECTED] [mailto:python- >> > [EMAIL PROTECTED] On Behalf Of c james >> > Sent: Friday, February 08, 2008 12:10 PM >> > To: [EMAIL PROTECTED] >> > Subject:

Re: Edit Python code programmatically

2008-02-09 Thread Benjamin
On Feb 9, 5:47 am, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > 2008/2/9, Alex <[EMAIL PROTECTED]>: > > > Which library could you recommend to perform simple editing of Python > > code (from Python program)? For example, open *.py file, find specific > > function definition, add another function

Error on Python

2008-02-09 Thread maehhheeyy
Hi, right now I'm using Python and Multicast. I have the code for Multicast receiver on Python but I keep getting this error; File "", line 1, in bind error: (10049, "Can't assign requested address") The error is coming from this line; sock.bind ((MCAST_ADDR, MCAST_PORT)) Can anyone please help

Re: dependency order

2008-02-09 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > i'm having trouble trying to figure this out... it's part of a build > system i'm writing in python. maybe someone has a good simple way to > solve this. i'm trying to create a dependency order out of multiple > lists. > > list1: B C > list2: A B > list3: A C > > i

dependency order

2008-02-09 Thread belred
i'm having trouble trying to figure this out... it's part of a build system i'm writing in python. maybe someone has a good simple way to solve this. i'm trying to create a dependency order out of multiple lists. list1: B C list2: A B list3: A C i want the end result to be the list: A B C i'm v

Re: are elements of a list in sequence in list b

2008-02-09 Thread Paddy
On 9 Feb, 15:20, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 09 Feb 2008 05:44:27 -0800, bearophileHUGS wrote: > > def issubseq(sub, items): > > """issubseq(sub, items): return true if the sequence 'sub' is a > > contiguous subsequence of the 'items' sequence. > > [s

C function in a Python context

2008-02-09 Thread castironpi
To write quick C things that Python won't do up to speed. So it's got a redundancy. import ext extA= ext.Ext() extA[ 'enumfactors' ]= r""" int enumfactors( int a, const char* sep ) { int ret= 0, i; for( i= 1; i<= a; i++ ) { if( a% i== 0 ) { ret+= 1;

Re: dependency order

2008-02-09 Thread belred
On Feb 9, 11:10 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] schrieb: > > > i'm having trouble trying to figure this out... it's part of a build > > system i'm writing in python. maybe someone has a good simple way to > > solve this. i'm trying to create a dependency orde

Re: are elements of a list in sequence in list b

2008-02-09 Thread bearophileHUGS
Steven D'Aprano: > I believe that it is considered an abuse of doctest to write a function > with 28 lines of code and 19 tests I agree with you. Most of my functions/methods have more compact doctests (putting things on many lines has the advantage of letting you locate the failing tests in a sim

wxpython file dialog

2008-02-09 Thread Janwillem
Is there a way to force the wx.FileDialog to show as default the thumbnails vie in stead of list view? thanks, janwillem -- http://mail.python.org/mailman/listinfo/python-list

Re: OT: Speed of light [was Re: Why not a Python compiler?]

2008-02-09 Thread Doug Morse
So, showing of my physics ignorance: I presume then that this means that light, say from the sun, is actually sending particles to the earth, since the space between is mostly vacuum? Or is there enough material in the near-vacuum of space for propogation to occur? On Sat, 09 Feb 2008 12:25:51

Re: C function in a Python context

2008-02-09 Thread castironpi
On Feb 9, 1:48 pm, [EMAIL PROTECTED] wrote: > To write quick C things that Python won't do up to speed.  So it's got > a redundancy. > > import ext > extA= ext.Ext() > extA[ 'enumfactors' ]= r""" >     int enumfactors( int a, const char* sep ) { >         int ret= 0, i; >         for( i= 1; i<= a;

Re: OT: Speed of light [was Re: Why not a Python compiler?]

2008-02-09 Thread Jeff Schwab
Grant Edwards wrote: > On 2008-02-09, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote: >> On Sat, 2008-02-09 at 14:56 +0100, Martin P. Hellwig wrote: Propagate, travel, what's the difference? >>> Unfortunately, I didn't study any of this but I sure do remember the >>> answer one drunk phys

Re: wxpython file dialog

2008-02-09 Thread Guilherme Polo
2008/2/9, Janwillem <[EMAIL PROTECTED]>: > Is there a way to force the wx.FileDialog to show as default the > thumbnails vie in stead of list view? > thanks, janwillem > > -- > http://mail.python.org/mailman/listinfo/python-list > You should be using wx.lib.imagebrowser.ImageDialog instead of w

different key, same value in dictionaries

2008-02-09 Thread Magdoll
Is there a cleaner way to do this example: d = {('a','b'): 10, ('a','c'): 20, ('b','c'): 30} The key is always a pair (x,y), but d[(x,y)] should have the same result as d[(y,x)]. So either I would have to store both d[(x,y)] and d[(y,x)] (unncessary extra space?), or write something like: if x <

Re: sort functions in python

2008-02-09 Thread Jeff Schwab
Carl Banks wrote: > On Feb 8, 10:09 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote: >> If you expect your data to be pretty nearly sorted >> already, but you just want to make sure (e.g. because a small number of >> elements may have been inserted or removed since the last sort), >> bubble-sort is a goo

Re: sort functions in python

2008-02-09 Thread Jeff Schwab
Steven D'Aprano wrote: > On Fri, 08 Feb 2008 19:09:06 -0800, Jeff Schwab wrote: > >> Steven D'Aprano wrote: >>> On Fri, 08 Feb 2008 17:00:27 -0800, t3chn0n3rd wrote: >>> Do you think it is relatively easy to write sort algorithms such as the common Bubble sort in Python as compared to ot

Turn off ZeroDivisionError?

2008-02-09 Thread Neal Becker
I'd like to turn off ZeroDivisionError. I'd like 0./0. to just give NaN, and when output, just print 'NaN'. I notice fpconst has the required constants. I don't want to significantly slow floating point math, so I don't want to just trap the exception. If I use C code to turn off the hardware s

Re: sort functions in python

2008-02-09 Thread Hrvoje Niksic
Steven D'Aprano <[EMAIL PROTECTED]> writes: > It depends on what you mean by "bubble sort". There are many different > variations of bubble sort, that are sometimes described by names such as > comb sort, cocktail sort, exchange sort, and sometimes merely referred to > bubble sort. I've never

Re: sort functions in python

2008-02-09 Thread Steven D'Aprano
On Sat, 09 Feb 2008 13:37:23 -0800, Jeff Schwab wrote: > Carl Banks wrote: >> On Feb 8, 10:09 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote: >>> If you expect your data to be pretty nearly sorted already, but you >>> just want to make sure (e.g. because a small number of elements may >>> have been ins

Re: different key, same value in dictionaries

2008-02-09 Thread Steven D'Aprano
On Sat, 09 Feb 2008 13:51:34 -0800, Magdoll wrote: > Is there a cleaner way to do this example: > > d = {('a','b'): 10, ('a','c'): 20, ('b','c'): 30} > > The key is always a pair (x,y), but d[(x,y)] should have the same result > as d[(y,x)]. So either I would have to store both d[(x,y)] and d[(y

pyinstall and matplotlib

2008-02-09 Thread John Henry
Has anybody been able to create an exe of their python applications involving matplotlib using pyinstall (ver 1.3)? I am getting a: RuntimeError: Could not find the matplotlib data files when I attempt to run the exe created. In searching the web, it appears this is an issue when others tr

Re: OT: Star Wars and parsecs

2008-02-09 Thread Bjoern Schliessmann
Lou Pecora wrote: [parsecs] > Which is the Earth's orbit. So, long, long ago in a galaxy far, > far away did they know about the Earth and decide to use it as the > basis for length in the universe? Even before people on earth > defined it? No, even simpler: In the Star Wars galaxy, parsec is a

Re: Pure Python Salsa20 Stream Cipher Implementation

2008-02-09 Thread Aahz
In article <[EMAIL PROTECTED]>, Gabriel Genellina <[EMAIL PROTECTED]> wrote: >En Sat, 09 Feb 2008 01:34:30 -0200, <[EMAIL PROTECTED]> escribió: >> On 8 Feb., 17:18, Paul Rubin wrote: >>> >>> I don't understand why a pure python version of salsa20 would be >>> interesting.

Re: sort functions in python

2008-02-09 Thread Jeff Schwab
Steven D'Aprano wrote: > On Sat, 09 Feb 2008 13:37:23 -0800, Jeff Schwab wrote: > >> Carl Banks wrote: >>> On Feb 8, 10:09 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote: If you expect your data to be pretty nearly sorted already, but you just want to make sure (e.g. because a small number of

Re: Turn off ZeroDivisionError?

2008-02-09 Thread Ryszard Szopa
On Feb 9, 11:03 pm, Neal Becker <[EMAIL PROTECTED]> wrote: > I'd like to turn off ZeroDivisionError. I'd like 0./0. to just give NaN, > and when output, just print 'NaN'. I notice fpconst has the required > constants. I don't want to significantly slow floating point math, so I > don't want to j

Re: different key, same value in dictionaries

2008-02-09 Thread Gary Herron
Magdoll wrote: > Is there a cleaner way to do this example: > > d = {('a','b'): 10, ('a','c'): 20, ('b','c'): 30} > > The key is always a pair (x,y), but d[(x,y)] should have the same > result as d[(y,x)]. So either I would have to store both d[(x,y)] and > d[(y,x)] (unncessary extra space?), or wr

Re: different key, same value in dictionaries

2008-02-09 Thread Matt Nordhoff
Gary Herron wrote: > You could use ImmutableSets as indexes. (In fact this is the whole > reason for the existence of ImmutableSets.) > > You could derive your own dictionary type from the builtin dictionary > type, and map an index operation d[(x,y)] to > d[ImmutableSet(a,b)]. Then all of d[a,b

What is wrong with this

2008-02-09 Thread nure123
Hi, I am new to Python and would be grateful if anyone could tell me what is wrong with the following statement. Y=array([1/S, 0*lam]) where S=[1, 2, 3, 4] lam=[5, 6, 7, 8] I am using Numeric not the NumPy and the original module in which this statement appears is supposed to be working perfect

Re: different key, same value in dictionaries

2008-02-09 Thread Paul Rubin
Matt Nordhoff <[EMAIL PROTECTED]> writes: > Since Python 2.4, sets are built-in types. Use "set" and "frozenset" > instead of "sets.Set" and "sets.ImmutableSet", respectively. > > If you need Python 2.3 compatibility, you can do something like this: As an alternative, you could canonicalize the k

Re: sort functions in python

2008-02-09 Thread Steven D'Aprano
On Sat, 09 Feb 2008 23:07:44 +0100, Hrvoje Niksic wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: > >> It depends on what you mean by "bubble sort". There are many different >> variations of bubble sort, that are sometimes described by names such >> as comb sort, cocktail sort, exchange sort

Is there an easy way to sort a list by two criteria?

2008-02-09 Thread neocortex
Hello! I am a newbie in Python. Recently, I get stuck with the problem of sorting by two criteria. In brief, I have a two-dimensional list (for a table or a matrix). Now, I need to sort by two columns, but I cannot figure out how to do that. I read somewhere that it is possible to do: >>> table.sor

help with data extraction

2008-02-09 Thread Amitava Maity
Hello, I have a data file (data.csv) that is something like this: data, Conductor, ACSR data, diameter, 0.02862 data, cross-section, 0.0004845 data, weight, 1.621 data, Mod, 70 data, Uts, 13450 data, Coef, 0.193 data, Cr, 20 data, span, 350 data, Wind pres, 0 data, temp, 32 data, ten,

Re: Is there an easy way to sort a list by two criteria?

2008-02-09 Thread Jeff Schwab
neocortex wrote: > Hello! > I am a newbie in Python. Recently, I get stuck with the problem of > sorting by two criteria. In brief, I have a two-dimensional list (for > a table or a matrix). Now, I need to sort by two columns, but I cannot > figure out how to do that. I read somewhere that it is po

Re: What is wrong with this

2008-02-09 Thread Steven D'Aprano
On Sat, 09 Feb 2008 16:44:52 -0800, nure123 wrote: > Hi, > > I am new to Python and would be grateful if anyone could tell me what is > wrong with the following statement. > > Y=array([1/S, 0*lam]) > > where > S=[1, 2, 3, 4] > lam=[5, 6, 7, 8] Oh, a guessing game! I love guessing games. Let'

Re: Is there an easy way to sort a list by two criteria?

2008-02-09 Thread Steve Holden
neocortex wrote: > Hello! > I am a newbie in Python. Recently, I get stuck with the problem of > sorting by two criteria. In brief, I have a two-dimensional list (for > a table or a matrix). Now, I need to sort by two columns, but I cannot > figure out how to do that. I read somewhere that it is po

Re: Error on Python

2008-02-09 Thread Tim Roberts
maehhheeyy <[EMAIL PROTECTED]> wrote: >Hi, right now I'm using Python and Multicast. I have the code for >Multicast receiver on Python but I keep getting this error; > >File "", line 1, in bind >error: (10049, "Can't assign requested address") > >The error is coming from this line; >sock.bind ((MC

Re: Is there an easy way to sort a list by two criteria?

2008-02-09 Thread Steven D'Aprano
On Sat, 09 Feb 2008 18:05:14 -0800, neocortex wrote: > Hello! > I am a newbie in Python. Recently, I get stuck with the problem of > sorting by two criteria. In brief, I have a two-dimensional list (for a > table or a matrix). Now, I need to sort by two columns, but I cannot > figure out how to do

Re: help with data extraction

2008-02-09 Thread Andrew Seaford
Amitava Maity wrote: > Hello, > > I have a data file (data.csv) that is something like this: > > data, Conductor, ACSR > data, diameter, 0.02862 > data, cross-section, 0.0004845 > data, weight, 1.621 > data, Mod, 70 > data, Uts, 13450 > data, Coef, 0.193 > data, Cr, 20 > data, span, 3

Re: shelve.open call gives error

2008-02-09 Thread Gabriel Genellina
En Sat, 09 Feb 2008 03:35:14 -0200, waltbrad <[EMAIL PROTECTED]> escribi�: > On Feb 8, 5:29 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: >> En Fri, 08 Feb 2008 06:36:53 -0200, waltbrad <[EMAIL PROTECTED]> >> escribió: >> >> > Working through the Mark Lutz book Programming Python 3rd Editio

Re: Is there an easy way to sort a list by two criteria?

2008-02-09 Thread thebjorn
On Feb 10, 3:05 am, neocortex <[EMAIL PROTECTED]> wrote: > Hello! > I am a newbie in Python. Recently, I get stuck with the problem of > sorting by two criteria. In brief, I have a two-dimensional list (for > a table or a matrix). Now, I need to sort by two columns, but I cannot > figure out how to

Re: Recursion limit of pickle?

2008-02-09 Thread Gabriel Genellina
En Sat, 09 Feb 2008 09:49:46 -0200, Victor Lin <[EMAIL PROTECTED]> escribi�: > I encounter a problem with pickle. > I download a html from: > > http://www.amazon.com/Magellan-Maestro-4040-Widescreen-Navigator/dp/B000NMKHW6/ref=sr_1_2?ie=UTF8&s=electronics&qid=1202541889&sr=1-2 > > and parse it w

Re: What is wrong with this

2008-02-09 Thread nure123
On Feb 9, 8:56 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 09 Feb 2008 16:44:52 -0800, nure123 wrote: > > Hi, > > > I am new to Python and would be grateful if anyone could tell me what is > > wrong with the following statement. > > > Y=array([1/S, 0*lam]) > > > wher

Re: dependency order

2008-02-09 Thread Gabriel Genellina
En Sat, 09 Feb 2008 16:57:44 -0200, <[EMAIL PROTECTED]> escribi�: > i'm having trouble trying to figure this out... it's part of a build > system i'm writing in python. maybe someone has a good simple way to > solve this. i'm trying to create a dependency order out of multiple > lists. > > list1

Re: sort functions in python

2008-02-09 Thread Carl Banks
On Feb 9, 4:37 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > On Feb 8, 10:09 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote: > >> If you expect your data to be pretty nearly sorted > >> already, but you just want to make sure (e.g. because a small number of > >> elements may have be

Re: Error on Python

2008-02-09 Thread Steve Holden
Tim Roberts wrote: > maehhheeyy <[EMAIL PROTECTED]> wrote: > >> Hi, right now I'm using Python and Multicast. I have the code for >> Multicast receiver on Python but I keep getting this error; >> >> File "", line 1, in bind >> error: (10049, "Can't assign requested address") >> >> The error is com

Re: Recursion limit of pickle?

2008-02-09 Thread Victor Lin
On 2月10日, 上午11時42分, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Sat, 09 Feb 2008 09:49:46 -0200, Victor Lin <[EMAIL PROTECTED]> > escribi�: > > > I encounter a problem with pickle. > > I download a html from: > > >http://www.amazon.com/Magellan-Maestro-4040-Widescreen-Navigator/dp/B... > >

Using Cookie and Proxy handler with urllib2

2008-02-09 Thread Joshua Gilman
Hello, here is my current code: import urllib, urllib2, cookielib class wrapper: def __init__(self): self.setupCookies() def request(self, address, postData=None, headers={ }): if not postData == None: postData = urllib.urlencode(postData) req = urllib

Re: OT: Star Wars and parsecs [was Re: Why not a Python compiler?]

2008-02-09 Thread [EMAIL PROTECTED]
On Feb 8, 2:53�pm, Lou Pecora <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > �Grant Edwards <[EMAIL PROTECTED]> wrote: > > > On 2008-02-08, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > > > > � � � A Parsec is a fixed value (which, admittedly, presumes the culture > > > developed a

Re: OT: Speed of light [was Re: Why not a Python compiler?]

2008-02-09 Thread Gabriel Genellina
En Sat, 09 Feb 2008 19:01:31 -0200, Doug Morse <[EMAIL PROTECTED]> escribi�: > So, showing of my physics ignorance: I presume then that this means that > light, say from the sun, is actually sending particles to the earth, > since the > space between is mostly vacuum? Or is there enough materi

Re: Pure Python Salsa20 Stream Cipher Implementation

2008-02-09 Thread Gabriel Genellina
En Sat, 09 Feb 2008 20:29:58 -0200, Aahz <[EMAIL PROTECTED]> escribió: > In article <[EMAIL PROTECTED]>, > Gabriel Genellina <[EMAIL PROTECTED]> wrote: >> En Sat, 09 Feb 2008 01:34:30 -0200, <[EMAIL PROTECTED]> >> escribió: >>> On 8 Feb., 17:18, Paul Rubin wrote:

Re: sort functions in python

2008-02-09 Thread Steven D'Aprano
On Sat, 09 Feb 2008 14:28:15 -0800, Jeff Schwab wrote: > Steven D'Aprano wrote: >> On Sat, 09 Feb 2008 13:37:23 -0800, Jeff Schwab wrote: >> >>> Carl Banks wrote: On Feb 8, 10:09 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote: > If you expect your data to be pretty nearly sorted already, but

Re: What is wrong with this

2008-02-09 Thread Steven D'Aprano
On Sat, 09 Feb 2008 19:40:25 -0800, nure123 wrote: > But I am still interested in knowing why did the original > programmer did not get any error whereas I got an error with the > statement : Y=array([1/S, 0*lam]) *shrug* How do you know it worked fine for the original programmer? Maybe he rel

Re: Is there an easy way to sort a list by two criteria?

2008-02-09 Thread Duncan Booth
thebjorn <[EMAIL PROTECTED]> wrote: > I'm not sure which Python is default for Ubuntu 6.06, but assuming you > can access a recent one (2.4), the list.sort() function takes a key > argument (that seems to be rather sparsely documented in the tutorial > and the docstring...). E.g.: > lst = [(

Re: which one is more efficient

2008-02-09 Thread Christian Heimes
ki lo wrote: > I have type variable which may have been set to 'D' or 'E' > > Now, which one of following statements are more efficient > > if type =='D' or type == 'E': > > or > > if re.search("D|E", type): > > Please let me know because the function is going to called 10s of millions > of ti

Python Beginner needs help with for loop

2008-02-09 Thread [EMAIL PROTECTED]
Hi, I'm trying to write a for loop in place of the string method .replace() to replace a character within a string if it's found. So far, I've got s = raw_input("please enter a string: ") c = raw_input("please enter a character: ") b_s = s[::-1] #string backwards found = False #character's exist

Re: which one is more efficient

2008-02-09 Thread Paul Rubin
> ki lo wrote: > > I have type variable which may have been set to 'D' or 'E' > > > > Now, which one of following statements are more efficient > > > > if type =='D' or type == 'E': > > > > or > > > > if re.search("D|E", type): > > > > Please let me know because the function is going to called

Re: Python Beginner needs help with for loop

2008-02-09 Thread Gabriel Genellina
En Sun, 10 Feb 2008 04:06:54 -0200, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribi�: > I need to replace s2 = s.replace(c,"!") with a for loop function > somehow. > > I don't really see how a for loop would iterate through the string and > replace the character, and would like to see an example i

Re: Python Beginner needs help with for loop

2008-02-09 Thread [EMAIL PROTECTED]
On Feb 10, 12:06 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, I'm trying to write a for loop in place of the string > method .replace() to replace a character within a string if it's > found. > > So far, I've got > > s = raw_input("please enter a string: ") > c = raw_input("please enter

Re: Python Beginner needs help with for loop

2008-02-09 Thread Paul Rubin
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Hi, I'm trying to write a for loop in place of the string > method .replace() to replace a character within a string if it's > found. I think you mean you want to replace the last occurrence of the character in the string, but leave other occurrenc

Better way to negate a boolean list?

2008-02-09 Thread David Trémouilles
Hi, Is there any better (shorter) way to negate a boolean list than: >>> negated_boolean_list = [not elem for elem in boolean_list] ? I tried: >>> map(not, boolean_list) but it seems that "not" is not a function. Thanks in advance, David -- http://mail.python.org/mailman/listinfo/python-li

Re: Python Beginner needs help with for loop

2008-02-09 Thread [EMAIL PROTECTED]
I'm replacing all occurrences of the character in the string with '!', which in turn is the new string, s2. I'm also not allowed to use rfind or rindex or replace() because we are supposed to be learning about for loops. Thanks for the advices so far, I will try some more on my own. -- http://ma