Re: compare range objects

2011-10-22 Thread SigmundV
On Oct 22, 6:32 am, Steven D'Aprano wrote: > > Sure. But the downside of sets is that, like lists, they are not lazy, Thank you for pointing this out. I agree that it's not a viable alternative for large domains. Storing the bounds and the resolution should be enough. /Sigmund -- http://mail.py

Re: compare range objects

2011-10-21 Thread SigmundV
On Oct 21, 2:55 am, Yingjie Lan wrote: > > In simulation, one can use range objects to denote a discrete domain, > and domain comparison could be very useful. Not just equality, but also > things like if one domain is contained in another. Can't sets [help(set)] be used for this? -- http://mail

Re: 1/2 evaluates to 0

2011-10-13 Thread SigmundV
On Oct 13, 10:04 am, Laurent Claessens wrote: > Thanks all for your ansers. I'll import division from __future__ > Most of what I'm using in Python is with Sage[1]. Thus I'm not about to > step to 3.x :( You should get in touch with the Sage developers. In the Sage FAQ they say that "until SciPy

Re: pairwise combination of two lists

2011-08-18 Thread SigmundV
On Aug 17, 9:22 pm, Yingjie Lin wrote: > I found zip() but it only gives [('a', '1'), ('b', '2')],  not exactly what I > am looking for. Yet, if you feed the zip into a list comprehension you get what you want: li3 = [''.join(l) for l in zip(li1,li2)] Sigmund -- http://mail.python.org/mailma

Re: Ten rules to becoming a Python community member.

2011-08-17 Thread SigmundV
Bloody hell! This is the most persistent troll I've seen to date. He expected to get a raging army of pythoners after him, but people are just laughing at him. This is a mailing list, not a novel, so colloquialisms are welcome. The language on a mailing list should be informal and not necessarily g

Re: String concatenation - which is the fastest way ?

2011-08-12 Thread SigmundV
On Aug 12, 8:10 am, przemol...@poczta.fm wrote: > Good question but I try to explain what motivates me to do it. > First reason (I think the most important :-) ) is that I want to learn > something new - I am new to python (I am unix/storage sysadmin but with > programming > background so python w

Re: String concatenation - which is the fastest way ?

2011-08-11 Thread SigmundV
When I saw the headline I thought "oh no, not string concatenation again... we have had scores of these thread before...", but this is a rather interesting problem. The OP says he's not a database developer, but why is he then fiddling with internal database operations? Wouldn't it be better to go

Re: learning another programing language

2011-07-25 Thread SigmundV
On Jul 24, 9:59 am, Benjamin Gregg wrote: > Hi > python was my first language but I need to learn C++ and java for a > project (No there isn't an alternative) > and I want to know is there any good tutorials or tips for learning > C++/java after using python? I think it's always best to approach

Re: python.org is down?

2011-07-25 Thread SigmundV
On Jul 24, 8:43 am, Laszlo Nagy wrote: > Can it be a problem on my side? I have tried from several different > computers. I cannot even ping it. Whenever a page can't be accessed, although your connection is good, http://www.downforeveryoneorjustme.com/ is a good site to check. Sigmund -- http

Re: Convert '165.0' to int

2011-07-25 Thread SigmundV
On Jul 25, 10:48 am, Steven D'Aprano wrote: > > One other important proviso: if your map function is a wrapper around a > Python expression: > > map(lambda x: x+1, data) > [x+1 for x in data] > > then the list comp will be much faster, due to the overhead of the function > call. List comps and gen

Re: Convert '165.0' to int

2011-07-24 Thread SigmundV
On Jul 21, 10:31 am, "Frank Millman" wrote: > Is there a short cut, or must I do this every time (I have lots of them!) ? > I know I can write a function to do this, but is there anything built-in? I'd say that we have established that there is no shortcut, no built- in for this. You write you ow

Re: Python 2.6 OR 3.2

2011-06-13 Thread SigmundV
I'm using 2.7.1, because that's what my Ubuntu 11.04 bundles (python -- version reports 2.7.1+ though, no idea what the + means). On the other hand, Ubuntu provides 3.2 packages via apt-get, so I'm in the process of migrating to 3k. I really like the focus on laziness in 3k (don't know if 'focus' i

Re: Faster Recursive Fibonacci Numbers

2011-05-20 Thread SigmundV
There is a nice matrix representation of consecutive Fibonacci numbers: [[1, 1], [1, 0]] ** n = [[F_n+1, F_n], [F_n, F_n-1]]. Using the third party mpmath module, which uses arbitrary precision floating point arithmetic, we can calculate the n'th Fibonacci number for an arbitrary n as follows: imp

Re: Converting a set into list

2011-05-15 Thread SigmundV
I'm sorry I top posted. I'll remember not to top post next time. Sigmund -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting a set into list

2011-05-15 Thread SigmundV
I think the OP wants to find the intersection of two lists. list(set(list1) & set(list2)) is indeed one way to achieve this. [i for i in list1 if i in list2] is another one. Sigmund On May 15, 4:11 am, Chris Torek wrote: > In article <871v00j2bh@benfinney.id.au> > Ben Finney   wrote: > > >As