Re: sequence multiplied by -1

2010-09-25 Thread Paul Rubin
Steven D'Aprano writes: > I'm surprised that you think that you should be able to apply > arbitrary mathematical operations to strings *before* turning them > into an int and still get sensible results. That boggles my mind. I think the idea is you should not be able to do mathematical operations

Re: Python in Linux - barrier to Python 3.x

2010-09-25 Thread Lie Ryan
On 09/22/10 02:44, Diez B. Roggisch wrote: > Antoine Pitrou writes: > >> On Tue, 21 Sep 2010 17:59:27 +0200 >> de...@web.de (Diez B. Roggisch) wrote: >>> >>> The problems explained are simply outdated and crippled python >>> versions. >>> >>> And to me, a python version installed that has not th

Re: sequence multiplied by -1

2010-09-25 Thread Steven D'Aprano
On Sat, 25 Sep 2010 22:08:54 -0700, John Nagle wrote: > On 9/25/2010 4:45 AM, Thomas Jollans wrote: >> On Saturday 25 September 2010, it occurred to Yingjie Lan to exclaim: >>> Hi, >>> >>> I noticed that in python3k, multiplying a sequence by a negative >>> integer is the same as multiplying it by

Re: toy list processing problem: collect similar terms

2010-09-25 Thread Paul Rubin
Python solution follows (earlier one with an error cancelled). All crossposting removed since crossposting is a standard trolling tactic. from collections import defaultdict def collect(xss): d = defaultdict(list) for xs in xss: d[xs[0]].extend(xs[1:])

Python 2.7 installation problem

2010-09-25 Thread Ronald Guida
Hi, I am trying to perform a user-install of python 2.7 on Ubuntu 10.04, and my installation is failing. This sequence of commands reproduces the failure on my system: $ tar -zxvf Python-2.7.tgz $ cd Python-2.7/ $ ./configure --prefix=$HOME $ make $ ./python Lib/test/test_collections.py doctest

Re: toy list processing problem: collect similar terms

2010-09-25 Thread Alexander Burger
In PicoLisp: (mapcar '((X) (apply conc (cdr X))) (group List) ) Cheers, - Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: toy list processing problem: collect similar terms

2010-09-25 Thread Gary Herron
On 09/25/2010 09:05 PM, Xah Lee wrote: here's a interesting toy list processing problem. I have a list of lists, where each sublist is labelled by a number. I need to collect together the contents of all sublists sharing the same label. So if I have the list ((0 a b) (1 c d) (2 e f) (3 g h) (1

Re: sequence multiplied by -1

2010-09-25 Thread John Nagle
On 9/25/2010 4:45 AM, Thomas Jollans wrote: On Saturday 25 September 2010, it occurred to Yingjie Lan to exclaim: Hi, I noticed that in python3k, multiplying a sequence by a negative integer is the same as multiplying it by 0, and the result is an empty sequence. It seems to me that there is a

toy list processing problem: collect similar terms

2010-09-25 Thread Xah Lee
here's a interesting toy list processing problem. I have a list of lists, where each sublist is labelled by a number. I need to collect together the contents of all sublists sharing the same label. So if I have the list ((0 a b) (1 c d) (2 e f) (3 g h) (1 i j) (2 k l) (4 m n) (2 o p) (4 q r) (5 s

Re: solve alphametic puzzles in just 9 lines of code

2010-09-25 Thread Yingjie Lan
Sorry, didn't document my code well enough. Here is the code with an example. Yingjie #Code begins### from itertools import permutations def solve(puzzle): """solve alphametic puzzles in just 9 lines of code. Make sure each operator is seperated from the words by wh

Re: sequence multiplied by -1

2010-09-25 Thread Yingjie Lan
Hi all, Thanks for considering this proposal seriously and all your discussions shed light on the pro's and cons (well, more cons than pros, to be honest). It occurrs to me that this proposal is not a sound one, for the reasons already well documented in this thread, which I need not repeat.

Re: sequence multiplied by -1

2010-09-25 Thread Steven D'Aprano
On Sat, 25 Sep 2010 06:54:36 -0700, Yingjie Lan wrote: > For the rule above, how about the > case to reverse and multiply: > L*-3 #L reversed and repeated three times > > v.s. > L[::-1]*3 #L reversed and repeated three times > > The first one is simpler (4 chars v.s. 9 chars). I thou

Re: sequence multiplied by -1

2010-09-25 Thread Steven D'Aprano
On Sat, 25 Sep 2010 13:45:11 +0200, Thomas Jollans wrote: > On Saturday 25 September 2010, it occurred to Yingjie Lan to exclaim: >> Hi, >> >> I noticed that in python3k, multiplying a sequence by a negative >> integer is the same as multiplying it by 0, and the result is an empty >> sequence. It

Re: SocketServer: replace network by hard drive

2010-09-25 Thread Nobody
On Sat, 25 Sep 2010 14:45:29 +0200, Thomas Jollans wrote: >> The problem with using the loopback interface is that it's still >> "network access", which can run into all kinds of issues with security >> policies, firewalls, etc. > > What kind of crappy firewall blocks loopback traffic? Really? T

Re: Learning inheritance

2010-09-25 Thread Niklasro
On Sep 21, 1:30 am, alex23 wrote: > Bruno Desthuilliers > wrote: > > > alex23 a écrit : > > > Python only actually executes a module the first time it's imported, > > > Beware of multithreading and modules imported under different names... > > There can be issues with both in some web frameowrks.

Re: Learning inheritance

2010-09-25 Thread Niklasro
On Sep 20, 7:39 am, Bruno Desthuilliers wrote: > Niklasro a écrit : > > > Good to learn what I'm doing :-) since important being able to explain > > choices taken farther than "doing it because it works". > > I understand the concept of modules may not correspond to java > > programming where I co

Re: sequence multiplied by -1

2010-09-25 Thread Arnaud Delobelle
On 25 Sep, 09:22, Yingjie Lan wrote: > Hi, > > I noticed that in python3k, multiplying a sequence by a negative integer is > the same as multiplying it by 0, and the result is an empty sequence. It > seems to me that there is a more meaningful symantics. > > Simply put, a sequence multiplied by

Re: sequence multiplied by -1

2010-09-25 Thread Stefan Schwarzer
Hi Terry, On 2010-09-25 19:24, Terry Reedy wrote: > On 9/25/2010 4:22 AM, Yingjie Lan wrote: > There is already a builtin reversed() function whose output can be > multiplied. Seemingly, it can't: $ python Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help

Re: Python2.7 on OSX

2010-09-25 Thread Shashwat Anand
On Sun, Sep 26, 2010 at 12:32 AM, Jonas Galvez wrote: > Just installed Python2.7 on my OSX Leopard with make altinstall. > > No missing dependencies, but I have one annoying problem: the delete key > prints '^H' on the Python shell. > > Does anyone know how to fix that? > > Thanks in advance, > I

Python2.7 on OSX

2010-09-25 Thread Jonas Galvez
Just installed Python2.7 on my OSX Leopard with make altinstall. No missing dependencies, but I have one annoying problem: the delete key prints '^H' on the Python shell. Does anyone know how to fix that? Thanks in advance, -- Jonas -- http://mail.python.org/mailman/listinfo/python-list

Re: sequence multiplied by -1

2010-09-25 Thread Emile van Sebille
On 9/25/2010 10:24 AM Terry Reedy said... On 9/25/2010 4:22 AM, Yingjie Lan wrote: I noticed that in python3k, multiplying a sequence by a negative integer is the same as multiplying it by 0, and the result is an empty sequence. This is explicitly documented: "Values of n less than 0 are treat

Re: sequence multiplied by -1

2010-09-25 Thread Terry Reedy
On 9/25/2010 4:22 AM, Yingjie Lan wrote: Hi, I noticed that in python3k, multiplying a sequence by a negative integer is the same as multiplying it by 0, and the result is an empty sequence. This is explicitly documented: "Values of n less than 0 are treated as 0 (which yields an empty sequen

Re: inspect.stack() or inspect.currentframe() gives "list index out of range error"

2010-09-25 Thread Terry Reedy
On 9/25/2010 3:53 AM, deluxstar wrote: The traceback is: 2010-09-25 10:50:38+0300 [-] Traceback (most recent call last): 2010-09-25 10:50:38+0300 [-] File "../appsrv/lqcommon.py", line 983, in getPRMS 2010-09-25 10:50:38+0300 [-] File "/usr/lib/python2.6/inspect.py", line 931, in getouterfra

Re: sequence multiplied by -1

2010-09-25 Thread Mel
Stefan Schwarzer wrote: > On 2010-09-25 15:54, Yingjie Lan wrote: >> The first one is simpler (4 chars v.s. 9 chars). >> I thought it was also intuitive because if you multiply >> a vector by -1, you should get a vector >> in the reversed direction. But, intuitiveness depends >> on who you are, wh

Re: sequence multiplied by -1

2010-09-25 Thread Stefan Schwarzer
Hi, On 2010-09-25 15:54, Yingjie Lan wrote: > The first one is simpler (4 chars v.s. 9 chars). One thing is whether a certain form is shorter, another thing to take into account is how often you need the functionality. > I thought it was also intuitive because if you multiply > a vector by -1, y

solve alphametic puzzles in just 9 lines of code

2010-09-25 Thread Yingjie Lan
Hi, I am teaching Python this semester and as I am trying to explain the code by Raymond Hettinger, I need to make it simpler (this is an introductory course). And it ends up to be just 9 lines of code. Just for fun. See also: http://diveintopython3.org/advanced-iterators.html Regards, Yingji

Re: sequence multiplied by -1

2010-09-25 Thread Yingjie Lan
Hi, > > In my opinion this _isn't_ a situation where it's good. :) > >     L[::-1] > > is only marginally longer than > >     -1 * L > > I think this small gain doesn't justify "violating" this > "Python Zen" rule (from `import this`): > >     There should be one-- and preferably only one >

Re: sequence multiplied by -1

2010-09-25 Thread Stefan Schwarzer
Hi, On 2010-09-25 14:11, Yingjie Lan wrote: > Having more than one way of doing things sometimes is good. In my opinion this _isn't_ a situation where it's good. :) L[::-1] is only marginally longer than -1 * L I think this small gain doesn't justify "violating" this "Python Zen" rule

Re: SocketServer: replace network by hard drive

2010-09-25 Thread Thomas Jollans
On Saturday 25 September 2010, it occurred to Nobody to exclaim: > On Fri, 24 Sep 2010 19:28:45 +0200, Thomas Jollans wrote: > > If you're using UNIX, and you don't actually need the stream to be > > passed via the hard drive (why would you?), but for some reason want to > > use the file system, lo

Re: SocketServer: replace network by hard drive

2010-09-25 Thread Nobody
On Fri, 24 Sep 2010 19:28:45 +0200, Thomas Jollans wrote: > If you're using UNIX, and you don't actually need the stream to be > passed via the hard drive (why would you?), but for some reason want to > use the file system, look info UNIX/local sockets. But, really, I'm > guessing that local TCP s

Re: sequence multiplied by -1

2010-09-25 Thread Yingjie Lan
--- On Sat, 9/25/10, Thomas Jollans wrote: > for every list l and integer n >= 0: >     len(l*n) == len(l)*n Well, this invariance is indeed broken under my proposal. But it is *already broken* in current python3k. However, the following invariance is maintained under my proposal: len(l*n) == le

Re: sequence multiplied by -1

2010-09-25 Thread Thomas Jollans
On Saturday 25 September 2010, it occurred to Yingjie Lan to exclaim: > Hi, > > I noticed that in python3k, multiplying a sequence by a negative integer is > the same as multiplying it by 0, and the result is an empty sequence. It > seems to me that there is a more meaningful symantics. Um... fo

Re: Pyflakes and IPython does not work for Emacs on Windows?

2010-09-25 Thread Thomas Jollans
On Saturday 25 September 2010, it occurred to Dsrt Egle to exclaim: > Thanks for your reply, Ben. Actually I have the paths "C:\Python25;C: > \Python25\Scripts" in the %PATH% variable, and the %PYTHONPATH% has > the following: > > [...] > > Looking at the file C:\Python25\Lib\site-packages\pyflak

Re: inspect.stack() or inspect.currentframe() gives "list index out of range error"

2010-09-25 Thread Wolfgang Rohdewald
On Samstag 25 September 2010, Steven D'Aprano wrote: > My guess is that you've copied the .pyc file onto the server, > BUT there is also an older version of the .py file there as > well. Because the modification date is older than that of the > .pyc file, Python executes the compiled code from the

Re: inspect.stack() or inspect.currentframe() gives "list index out of range error"

2010-09-25 Thread Steven D'Aprano
On Sat, 25 Sep 2010 00:53:13 -0700, deluxstar wrote: > The traceback is: > 2010-09-25 10:50:38+0300 [-] Traceback (most recent call last): > 2010-09-25 10:50:38+0300 [-] File "../appsrv/lqcommon.py", line 983, > in getPRMS > 2010-09-25 10:50:38+0300 [-] File "/usr/lib/python2.6/inspect.py", >

sequence multiplied by -1

2010-09-25 Thread Yingjie Lan
Hi, I noticed that in python3k, multiplying a sequence by a negative integer is the same as multiplying it by 0, and the result is an empty sequence. It seems to me that there is a more meaningful symantics. Simply put, a sequence multiplied by -1 can give a reversed sequence. Then for any

Re: inspect.stack() or inspect.currentframe() gives "list index out of range error"

2010-09-25 Thread deluxstar
On 24 Eylül, 12:39, Peter Otten <__pete...@web.de> wrote: > deluxstar wrote: > > We have an application working on several servers generally written > > with Python 2.6 and Twisted 10. > > The source codes are located in one server and compiled in this > > server. The compiled files are copied to o