Re: Interesting problem about uuid1

2011-11-21 Thread alex23
On Nov 21, 5:33 pm, sword wrote: > My colleague asks me an interesting problem about uuid library in > python. In multicore system with multiprocessing, is it possible to > get the duplicated uuid with uuid1? > > I just check the RFC 4122, and I can't find anything about mul

Interesting problem about uuid1

2011-11-20 Thread sword
My colleague asks me an interesting problem about uuid library in python. In multicore system with multiprocessing, is it possible to get the duplicated uuid with uuid1? I just check the RFC 4122, and I can't find anything about multicore environment. Python's uuid1 method generates the

Re: Interesting Problem

2010-01-20 Thread alex23
Victor Subervi wrote: > I think I finally have an interesting problem for y'all. I need to import a > script from a lower dir, forcing me to change dirs: I'm surprised that no one has yet mentioned packages. Suppose you have the following folder layout and you stick an empty __i

Re: Interesting Problem

2010-01-20 Thread M.-A. Lemburg
Victor Subervi wrote: > Hi; > I think I finally have an interesting problem for y'all. I need to import a > script from a lower dir, forcing me to change dirs: > > cwd = os.getcwd() > os.chdir('%s/..' % cwd) > sys.path.append(os.getcwd()) > from templateFram

Re: Interesting Problem

2010-01-20 Thread MRAB
James Matthews wrote: Also as a side point... It's best to anonymize the code as best you can so people cannot attach your code to your site (IP theft and security risk) [snip] Security risk, yes; IP theft, not so much. ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Interesting Problem

2010-01-20 Thread Victor Subervi
On Wed, Jan 20, 2010 at 12:30 PM, Stephen Hansen wrote: > On Wed, Jan 20, 2010 at 7:19 AM, Victor Subervi > wrote: > >> Hi; >> I think I finally have an interesting problem for y'all. I need to import >> a script from a lower dir, forcing me to change dirs: &

Re: Interesting Problem

2010-01-20 Thread James Matthews
Also as a side point... It's best to anonymize the code as best you can so people cannot attach your code to your site (IP theft and security risk) On Wed, Jan 20, 2010 at 8:38 AM, MRAB wrote: > Victor Subervi wrote: > >> Hi; >> I think I finally have an interesting probl

Re: Interesting Problem

2010-01-20 Thread Gary Herron
Victor Subervi wrote: Hi; I think I finally have an interesting problem for y'all. I need to import a script from a lower dir, forcing me to change dirs: Wait a moment... Your assumption that you need to change directories is invalid. (And that means everything you do below this

Re: Interesting Problem

2010-01-20 Thread MRAB
Victor Subervi wrote: Hi; I think I finally have an interesting problem for y'all. I need to import a script from a lower dir, forcing me to change dirs: cwd = os.getcwd() os.chdir('%s/..' % cwd) sys.path.append(os.getcwd()) from templateFrame import top, bottom os.chdir(cw

Re: Interesting Problem

2010-01-20 Thread Stephen Hansen
On Wed, Jan 20, 2010 at 7:19 AM, Victor Subervi wrote: > Hi; > I think I finally have an interesting problem for y'all. I need to import a > script from a lower dir, forcing me to change dirs: > Don't do that. If you must, then the correct way to do it is to adjust your s

Interesting Problem

2010-01-20 Thread Victor Subervi
Hi; I think I finally have an interesting problem for y'all. I need to import a script from a lower dir, forcing me to change dirs: cwd = os.getcwd() os.chdir('%s/..' % cwd) sys.path.append(os.getcwd()) from templateFrame import top, bottom os.chdir(cwd) Because I've fou

Re: Interesting (?) problem

2010-01-11 Thread Nobody
On Mon, 11 Jan 2010 18:57:24 +0100, mk wrote: >> I have two lists of IP addresses: >> >> hostips = [ 'a', 'b', 'c', 'd', 'e' ] >> >> thread_results = [ 'd', 'b', 'c' ] >> >> I need to sort thread_results in the same order as hostips. > > P.S. One clarification: those lists are actually more co

Re: Interesting (?) problem

2010-01-11 Thread Paul Rubin
mk writes: > I have two lists of IP addresses: > > hostips = [ 'a', 'b', 'c', 'd', 'e' ] > > thread_results = [ 'd', 'b', 'c' ] > > I need to sort thread_results in the same order as hostips. Assuming each address in hostips appears just once: from itertools import izip,count d = dict(iz

Re: Interesting (?) problem

2010-01-11 Thread Peter Otten
mk wrote: > mk wrote: >> Hello everyone, >> >> I have two lists of IP addresses: >> >> hostips = [ 'a', 'b', 'c', 'd', 'e' ] >> >> thread_results = [ 'd', 'b', 'c' ] >> >> I need to sort thread_results in the same order as hostips. > > P.S. One clarification: those lists are actually more com

Re: Interesting (?) problem

2010-01-11 Thread Jean-Michel Pichavant
mk wrote: mk wrote: Hello everyone, I have two lists of IP addresses: hostips = [ 'a', 'b', 'c', 'd', 'e' ] thread_results = [ 'd', 'b', 'c' ] I need to sort thread_results in the same order as hostips. P.S. One clarification: those lists are actually more complicated (thread_result is a

Re: Interesting (?) problem

2010-01-11 Thread Arnaud Delobelle
mk writes: > Hello everyone, > > I have two lists of IP addresses: > > hostips = [ 'a', 'b', 'c', 'd', 'e' ] > > thread_results = [ 'd', 'b', 'c' ] > > I need to sort thread_results in the same order as hostips. [...solution:] > hostips_limited = [] > for h in hostips: > if h in thread_resul

Re: Interesting (?) problem

2010-01-11 Thread mk
mk wrote: Hello everyone, I have two lists of IP addresses: hostips = [ 'a', 'b', 'c', 'd', 'e' ] thread_results = [ 'd', 'b', 'c' ] I need to sort thread_results in the same order as hostips. P.S. One clarification: those lists are actually more complicated (thread_result is a list of tup

Re: Interesting (?) problem

2010-01-11 Thread Jean-Michel Pichavant
mk wrote: Incidentally, it *seems* that list comprehension preserves order: hostips_limited = [ h for h in hostips if h in thread_results ] Empirically speaking it seems to work (I tested it on real ips), but please correct me if that's wrong. Regards, mk Sounds good to me. List are *o

Interesting (?) problem

2010-01-11 Thread mk
Hello everyone, I have two lists of IP addresses: hostips = [ 'a', 'b', 'c', 'd', 'e' ] thread_results = [ 'd', 'b', 'c' ] I need to sort thread_results in the same order as hostips. (Obviously, hostips can contain any valid ip addresses as strings, they are sorted alphabetically here just f

Re: not homework... something i find an interesting problem

2009-04-21 Thread MRAB
bearophileh...@lycos.com wrote: MRAB: I think I might have cracked it: ... print n, sums Nice. If you don't want to use dynamic programming, then add a @memoize decoration before the function, using for example my one: http://code.activestate.com/recipes/466320/ And you will see an inter

Re: not homework... something i find an interesting problem

2009-04-21 Thread bearophileHUGS
MRAB: > I think I might have cracked it: > ... >      print n, sums Nice. If you don't want to use dynamic programming, then add a @memoize decoration before the function, using for example my one: http://code.activestate.com/recipes/466320/ And you will see an interesting speed increase, even if

Re: not homework... something i find an interesting problem

2009-04-21 Thread MRAB
Trip Technician wrote: On 21 Apr, 14:46, MRAB wrote: Trip Technician wrote: Thank you Dave. This does it but slowly. takes every subset of the list a ofsquares, and then gets a 'partition' that will work, many are very inefficient (with lots of 1s). any hints about how to speed up ? def subset

Re: not homework... something i find an interesting problem

2009-04-21 Thread Trip Technician
On 21 Apr, 14:46, MRAB wrote: > Trip Technician wrote: > > Thank you Dave. This does it but slowly. takes every subset of the > > list a ofsquares, and then gets a 'partition' that will work, many > > are very inefficient (with lots of 1s). > > > any hints about how to speed up ? > > > def subset(

Re: not homework... something i find an interesting problem

2009-04-21 Thread MRAB
Trip Technician wrote: Thank you Dave. This does it but slowly. takes every subset of the list a of squares, and then gets a 'partition' that will work, many are very inefficient (with lots of 1s). any hints about how to speed up ? def subset(x): for z in range(1,2**len(x)): q=bin(

Re: not homework... something i find an interesting problem

2009-04-21 Thread Trip Technician
Thank you Dave. This does it but slowly. takes every subset of the list a of squares, and then gets a 'partition' that will work, many are very inefficient (with lots of 1s). any hints about how to speed up ? def subset(x): for z in range(1,2**len(x)): q=bin(z) subs=[]

Re: not homework... something i find an interesting problem

2009-04-18 Thread Dave Angel
Trip Technician wrote: although it's not homework (how can i prove that...?) i am still happy with just hints +++ we want to express integers as sums of squares. (repeated squares are allowed) most numbers have one minimal representation e.g. 24=16+4+4, some have two or more e.g. 125 = 121+4 =

not homework... something i find an interesting problem

2009-04-18 Thread Trip Technician
although it's not homework (how can i prove that...?) i am still happy with just hints +++ we want to express integers as sums of squares. (repeated squares are allowed) most numbers have one minimal representation e.g. 24=16+4+4, some have two or more e.g. 125 = 121+4 = 100+25 so far I have cr

Re: HTML tags optimization [ interesting problem]

2005-09-02 Thread DENG
hi, Sybren, thanks for your reply, if use CSS: texttexttext optimise to: texttexttext what i need is the METHOD to do optimization, in fact, i have ready write a program to analyse the syntax of CSS, to make it works with all situation -- http://mail.python.org/mailman/listinfo/python-list

Re: HTML tags optimization [ interesting problem]

2005-09-01 Thread Sybren Stuvel
DENG enlightened us with: > i use SGMLParser to process HTML files, in order to do some > optimizations, > > something like this: > >TEXT1TEXT2 > > optimise to > >TEXT1TEXT2 Why not optimize it to: TEXT1 TEXT2? > [ snipped stuff about tags ] If you're serious about using HTML, I suggest you re

Re: HTML tags optimization [ interesting problem]

2005-09-01 Thread DENG
I know very well Tidy, sir Tidy do a nice job but it is writen in Java, and have Python ported my aim is to learn Python, learn how to program I know many people write "hello the world" in 2005, why I can not write this program in 2005? you are french, right? peut etre we can talk about it in e

HTML tags optimization [ interesting problem]

2005-08-31 Thread DENG
hi all, i use SGMLParser to process HTML files, in order to do some optimizations, something like this: TEXT1TEXT2 optimise to TEXT1TEXT2 at the very beginning, i was thinking of analysing each text-block, to know their color, size, if is bold or italic, but i found it was too complicated.

Re: Got an interesting problem. (platform ruuning issue)

2005-06-29 Thread John Abel
Jeffrey Maitland wrote: >when running scripts they seem to work fine on ia-32 but I get >segfault on ia-64 what the heck should I be looking for? > >I did notice that it seems to work ok only for certain scripts but any >script that imports MySQLdb or glob seems to make this occur. > >Thanks Jeff

Got an interesting problem. (platform ruuning issue)

2005-06-29 Thread Jeffrey Maitland
when running scripts they seem to work fine on ia-32 but I get segfault on ia-64 what the heck should I be looking for? I did notice that it seems to work ok only for certain scripts but any script that imports MySQLdb or glob seems to make this occur. Thanks Jeff -- http://mail.python.org/mailm