Re: Different class 'str' between v3.

2011-09-16 Thread Vincent Vande Vyvre
Le 17/09/11 05:28, Vincent Vande Vyvre a écrit : Le 17/09/11 01:28, Ian Kelly a écrit : On Fri, Sep 16, 2011 at 7:52 AM, Vincent Vande Vyvre wrote: [vincent@myhost ~]$ python string_2.py Python version:  3.2.2 Linux-3.0-ARCH-

Re: Different class 'str' between v3.

2011-09-16 Thread Vincent Vande Vyvre
Le 17/09/11 01:28, Ian Kelly a écrit : On Fri, Sep 16, 2011 at 7:52 AM, Vincent Vande Vyvre wrote: [vincent@myhost ~]$ python string_2.py Python version:  3.2.2 Linux-3.0-ARCH-x86_64-Pentium-R-_Dual-Core_CPU_T4500_@_2.30GHz-with-glibc2.2.5 Path: /home/vince

Re: way to calculate 2**1000 without expanding it?

2011-09-16 Thread Ian Kelly
On Fri, Sep 16, 2011 at 8:19 PM, Grant Edwards wrote: >> Here's another one-liner using a generator instead of map: >> >>      sum(int(c) for c in str(2**1000)) > > Just in case you can't spare the 3KB required for the list of integers > that map creates. :) > > In this case it doesn't matter, but

Re: way to calculate 2**1000 without expanding it?

2011-09-16 Thread Grant Edwards
On 2011-09-16, Gary Herron wrote: > On 09/16/2011 01:17 PM, Arnaud Delobelle wrote: >> On 16 September 2011 21:06, Ian Kelly wrote: >>> On Fri, Sep 16, 2011 at 1:21 PM, zombie >>> wrote: Hi guys, i am writing a program to sum up the digits of a number 2**1000? Is there a

Re: way to calculate 2**1000 without expanding it?

2011-09-16 Thread Steven D'Aprano
Arnaud Delobelle wrote: > Ah go on, let's make a codegolf contest out of it. > My entry: > sum(map(int,str(2**1000))) > 1366 Time for some obfuscated Python! b = (16,13624) for i in range(23, 42, 3): b = (b[0]*b[0], b[1]+1024) for j in range(12345, 8929, -7): b = (b[0]+b[0], b[1]

setuptools: getting data files to be installed

2011-09-16 Thread Paul Paterson
I'm having a problem using setuptools to create a distribution for a project that includes data files. I can get the data files to be included in the zipped package file (*.tar.gz) but when I easy_install the package the data files are not installed. (Ubuntu 11.04, Python2.7). I'm trying to use

Re: Using tuples to eliminate multiple dict values

2011-09-16 Thread Tim Chase
On 09/16/11 13:47, Benshep wrote: I need a dictionary that returns the same value for multiple keys. i.e. (1)>>> dict = { (1,2,3) : 'text' , (5,6,7) : 'other text' } (2)>>>dict[1] (3) 'text' I cant figure out what i need on line 2 to make this scenario work. Is there a simple way to check i

Re: Different class 'str' between v3.

2011-09-16 Thread Ian Kelly
On Fri, Sep 16, 2011 at 7:52 AM, Vincent Vande Vyvre wrote: > [vincent@myhost ~]$ python string_2.py > > Python version:  3.2.2 > Linux-3.0-ARCH-x86_64-Pentium-R-_Dual-Core_CPU_T4500_@_2.30GHz-with-glibc2.2.5 > > Path: /home/vincent/image.jpg, Type: > File exists > Traceback (most recent call las

Re: Using tuples to eliminate multiple dict values

2011-09-16 Thread Chris Angelico
On Sat, Sep 17, 2011 at 4:47 AM, Benshep wrote: > (1)   >>> dict = { (1,2,3) : 'text' , (5,6,7) : 'other text' } > As I understand it, you're looking for a simple syntax for what MRAB posted: > my_dict = {1: 'text', 2: 'text', 3: 'text', 5: 'other text', 6 : 'other > text', 7: 'other text'} Sin

Re: strange results

2011-09-16 Thread Fig
I took out all of the color commands that were in the shape functions and all of the features to the 'draw_house' function showed showed up. I started putting the color commands back into the shape functions and have no problems with some of them but when I put the color command back into others, s

Re: Different class 'str' between v3.

2011-09-16 Thread Terry Reedy
On 9/16/2011 9:52 AM, Vincent Vande Vyvre wrote: Testing the following code, I've differend return with python 3.1.2 and 3.2.2 running on two different machines with two different versions of Linux. I get # -*- coding: utf-8 -*- import os import sys import platform print('\nPython version:

Code Review

2011-09-16 Thread Emeka
Hello All, While learning Python I put together another Text Twist. I would want somebody to go through it and comment. https://github.com/janus/Text-Twist -- Regards, Emeka * * -- http://mail.python.org/mailman/listinfo/python-list

Re: parse html:what is the meaning of "//"?

2011-09-16 Thread Terry Reedy
On 9/16/2011 7:02 AM, Stefan Behnel wrote: 0.00 N/A N/A 115 2,411 Highlighted options are in-the-money. I don't see any highlighting in your text above, Gone with the ascii conversion. and I don't know what you mean by "in-the-money". If a stock sells now for $20, an option to buy it f

Re: Cancel or timeout a long running regular expression

2011-09-16 Thread Terry Reedy
On 9/16/2011 9:57 AM, Nobody wrote: I wonder if there are any heuristics for detecting exponential time re's. Exponential growth results from non-determinism, i.e. if there are multiple transitions for a given character from a given state. Common patterns include: ...(a...)?a...

Re: way to calculate 2**1000 without expanding it?

2011-09-16 Thread Arnaud Delobelle
On 16 September 2011 20:21, zombie wrote: > Hi guys, >         i am writing a program to sum up the digits of a number 2**1000? > Is there a way/formula to do it without expanding it? > > -- > http://mail.python.org/mailman/listinfo/python-list > In base 2, the answer is 1 :) Hopefully-helpfully

create a directory structure

2011-09-16 Thread Andrea Crotti
I would like to write a program which creates a directory structure and fills in a few templated fields some values passed in as arguments. So for example create_struct.py might create base_dir: |_ sub_dir1: |_ sub_file1 ... It's quite simple in theory, but I would also like to make it very

RE: way to calculate 2**1000 without expanding it?

2011-09-16 Thread Prasad, Ramit
>>> sum(map(int,str(2**1000))) *smacks face* Gah, forgot about sum. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 This email is confidential and subject to important disclaimers and conditions inclu

Re: way to calculate 2**1000 without expanding it?

2011-09-16 Thread Stefan Krah
Gary Herron wrote: i am writing a program to sum up the digits of a number 2**1000? Is there a way/formula to do it without expanding it? > > Here's another one-liner using a generator instead of map: > > sum(int(c) for c in str(2**1000)) The OP did not specify the base: >>> bin(2*

Re: way to calculate 2**1000 without expanding it?

2011-09-16 Thread Arnaud Delobelle
On 16 September 2011 21:20, Ian Kelly wrote: > On Fri, Sep 16, 2011 at 2:17 PM, Arnaud Delobelle wrote: >> Ah go on, let's make a codegolf contest out of it. >> My entry: >> > sum(map(int,str(2**1000))) >> 1366 > > That is exactly what mine was. > Slightly longer: >>> eval("+".join(str(2**1

Re: Why do closures do this?

2011-09-16 Thread John Nagle
On 8/27/2011 9:19 PM, Terry Reedy wrote: On 8/27/2011 11:45 PM, John O'Hagan wrote: Somewhat apropos of the recent "function principle" thread, I was recently surprised by this: funcs=[] for n in range(3): def f(): return n funcs.append(f) The last expression, IMO surprisingly, is [2,2,2], n

Re: way to calculate 2**1000 without expanding it?

2011-09-16 Thread Gary Herron
On 09/16/2011 01:17 PM, Arnaud Delobelle wrote: On 16 September 2011 21:06, Ian Kelly wrote: On Fri, Sep 16, 2011 at 1:21 PM, zombie wrote: Hi guys, i am writing a program to sum up the digits of a number 2**1000? Is there a way/formula to do it without expanding it? Possibly, but w

Re: way to calculate 2**1000 without expanding it?

2011-09-16 Thread Ian Kelly
On Fri, Sep 16, 2011 at 2:17 PM, Arnaud Delobelle wrote: > Ah go on, let's make a codegolf contest out of it. > My entry: > sum(map(int,str(2**1000))) > 1366 That is exactly what mine was. -- http://mail.python.org/mailman/listinfo/python-list

Re: way to calculate 2**1000 without expanding it?

2011-09-16 Thread Arnaud Delobelle
On 16 September 2011 21:06, Ian Kelly wrote: > On Fri, Sep 16, 2011 at 1:21 PM, zombie > wrote: >> Hi guys, >>         i am writing a program to sum up the digits of a number 2**1000? >> Is there a way/formula to do it without expanding it? > > Possibly, but why worry about it?  It's only around

RE: way to calculate 2**1000 without expanding it?

2011-09-16 Thread Prasad, Ramit
>> Hi guys, >> i am writing a program to sum up the digits of a number 2**1000? >> Is there a way/formula to do it without expanding it? >Since this sounds like homework, I won't post the one-liner I used to >do it the brute-force way, but I will note that it takes about 200 >microseconds

Re: way to calculate 2**1000 without expanding it?

2011-09-16 Thread Ian Kelly
On Fri, Sep 16, 2011 at 1:21 PM, zombie wrote: > Hi guys, >         i am writing a program to sum up the digits of a number 2**1000? > Is there a way/formula to do it without expanding it? Possibly, but why worry about it? It's only around 300 digits. Since this sounds like homework, I won't po

RE: Using tuples to eliminate multiple dict values

2011-09-16 Thread Prasad, Ramit
-Original Message- From: python-list-bounces+ramit.prasad=jpmorgan@python.org [mailto:python-list-bounces+ramit.prasad=jpmorgan@python.org] On Behalf Of Benshep Sent: Friday, September 16, 2011 1:48 PM To: python-list@python.org Subject: Using tuples to eliminate multiple dict val

Re: Using tuples to eliminate multiple dict values

2011-09-16 Thread Benshep
thanks, I had a feeling that may be the way to go and my data just changed so it will work better that way. Thanks for the quick reply -- http://mail.python.org/mailman/listinfo/python-list

way to calculate 2**1000 without expanding it?

2011-09-16 Thread zombie
Hi guys, i am writing a program to sum up the digits of a number 2**1000? Is there a way/formula to do it without expanding it? -- http://mail.python.org/mailman/listinfo/python-list

Re: Using tuples to eliminate multiple dict values

2011-09-16 Thread MRAB
On 16/09/2011 19:47, Benshep wrote: I need a dictionary that returns the same value for multiple keys. i.e. (1)>>> dict = { (1,2,3) : 'text' , (5,6,7) : 'other text' } That will create a dict with 2 keys, both of which are tuples. (2)>>>dict[1] (3) 'text' I cant figure out what i need o

Using tuples to eliminate multiple dict values

2011-09-16 Thread Benshep
I need a dictionary that returns the same value for multiple keys. i.e. (1) >>> dict = { (1,2,3) : 'text' , (5,6,7) : 'other text' } (2) >>>dict[1] (3) 'text' I cant figure out what i need on line 2 to make this scenario work. Is there a simple way to check if the a number is present in th

Re: unexpected results

2011-09-16 Thread Fig
Sorry, Everyone. I got an error when posting the first post and did'nt come in to see if it had actually posted before I tried another post. -- http://mail.python.org/mailman/listinfo/python-list

unexpected results

2011-09-16 Thread Fig
I am having a problem when I run a graphics program that I created. I do not get an error when I run the program, there are just some weird things going on. I do not know if it is the program causing the problem or a bug in Python. Here is the code for the program: from gasp import * begin_graph

strange results

2011-09-16 Thread Fig
I am having a problem with a graphics program that I created. Actually, I don't know if it is the program or a bug in Python. The code for the program is as follows; from gasp import * begin_graphics(width=640, height=480, title='Houses at Night', background=color.BLACK) def draw_house(x, y):

RE: ImportError: cannot import name dns

2011-09-16 Thread Prasad, Ramit
NOTE: This is all speculation on my part. I am hoping someone on the list will give us more concrete details. 1. check for "dns" in sys.modules (initially not found) 2. create new empty module, add it to sys.modules as "dns" 3. execute dns.py in new module namespace (executes "from foo import udp

Re: Accessing matplotlib-users discussion group?

2011-09-16 Thread Martin Schöön
On 2011-09-15, John Ladasky wrote: > Hate to bump this, but... I found Sourceforge's IRC, and tried to ask > for help there, and it doesn't look like I can get any help until > business hours tomorrow. Anyone? No help really but I 'joined' Sourceforge about a year ago and had no problems whatsoe

Re: Strange Python internal error

2011-09-16 Thread Miki Tebeka
Try to narrow it down: from extension import Template from extension import Syntax from extension import processcmd Which one fails? What is this "extension" package? -- http://mail.python.org/mailman/listinfo/python-list

pyzmail-0.9.9 mail library to read, compose and send emails easily, support for py3k

2011-09-16 Thread aspineux
Now pyzmail include support for python 3.2 and above pyzmail is a high level mail library for Python. It provides functions and classes that help to read, compose and send emails. pyzmail exists because their is no reasons that handling mails with Python would be more difficult than with popular m

Re: why ps/fname of a python interpreter changes across platforms?

2011-09-16 Thread Duncan Booth
keobox wrote: > I don't know why the fname of the python interpreter changes across > platforms. > > I saw a "isapytho" in some solaris 10 platforms. > I saw "python2." in some Linux platforms. > On most platforms the value is "python". > Why? > It shows you part of the name of the program that

Re: create a directory structure

2011-09-16 Thread Andrea Crotti
After some research, I think that paste-script is the best choice in this case. I can define templates and I'll get my directory structure nicely populated for me. -- http://mail.python.org/mailman/listinfo/python-list

Re: Cancel or timeout a long running regular expression

2011-09-16 Thread Nobody
On Thu, 15 Sep 2011 14:54:57 -0400, Terry Reedy wrote: >> I was thinking there might be a technique I could use to evaluate >> regular expressions in a thread or another process launched via >> multiprocessing module and then kill the thread/process after a >> specified timeout period. > > Only s

Different class 'str' between v3.

2011-09-16 Thread Vincent Vande Vyvre
Testing the following code, I've differend return with python 3.1.2 and 3.2.2 --- # -*- coding: utf-8 -*- import os import sys import platform print('\nPython version: ', sys.version.split()[0])

Re: parse html:what is the meaning of "//"?

2011-09-16 Thread 守株待兔
through the following code,i get the content of webpage, import lxml.html url = 'http://finance.yahoo.com/q/op?s=C+Options' root = lxml.html.parse(url).getroot() with your method ,how can i get the content of webpage in my python program? -- Original ---

Re: Turkic I and re

2011-09-16 Thread Oktay Safak
Well, I'm a self taught Turkish python coder. I was bitten by this first in Python 2.3 and asked the group about it then. You can find the correspondence by googling "unicode bug in turkish characters? " There are a couple of

Strange Python internal error

2011-09-16 Thread JKPeck
We have a user on Windows with Python 2.6 who gets this error message when executing an import statement. from extension import Template, Syntax, processcmd SystemError: ..\Objects\listobject.c:169: bad argument to internal function The module can be imported directly via import extension wi

Re: parse html:what is the meaning of "//"?

2011-09-16 Thread Miki Tebeka
As a side note, it's way easier to get this data using YQL. See for example: http://developer.yahoo.com/yql/console/?q=show%20tables&env=store://datatables.org/alltableswithkeys#h=SELECT%20*%20FROM%20yahoo.finance.options%20WHERE%20symbol%3D%27C%27%20AND%20expiration%3D%272011-09%27 Which gives y

Fwd: why ps/fname of a python interpreter changes across platforms?

2011-09-16 Thread Yaşar Arabacı
-- Yönlendirilmiş ileti -- Kimden: Yaşar Arabacı Tarih: 16 Eylül 2011 14:33 Konu: Re: why ps/fname of a python interpreter changes across platforms? Kime: Steven D'Aprano For example, in arch linux, I had 3 different interpreters named python, python26 and python27 because some

Re: why ps/fname of a python interpreter changes across platforms?

2011-09-16 Thread Steven D'Aprano
keobox wrote: > Hello, > I'm writing a little supervisor of some python scripts. > To check if the scrips are running I'm using the ps -o pid,fname > command on both RH Linux and solaris 10. > All the scripts are launched using "python script.py" command, they > are not launched with exec permissi

Re: parse html:what is the meaning of "//"?

2011-09-16 Thread Stefan Behnel
alias, 16.09.2011 08:39: code1: import lxml.html import urllib down='http://finance.yahoo.com/q/op?s=C+Options' content=urllib.urlopen(down).read() root=lxml.html.document_fromstring(content) I see this quite often, but many people don't know that this can be simplified to import lxml.ht

Re: parse html:what is the meaning of "//"?

2011-09-16 Thread Kev Dwyer
alias wrote: > > > > Highlighted options are in-the-money. > (omit something) > there is only one difference between code1 and code2 : > in code1 is : tds=table.xpath("tr[@valign='top']//td") > in code2 is: tds=table.xpath("//tr[@valign='top']//td") > > i want to know why t

why ps/fname of a python interpreter changes across platforms?

2011-09-16 Thread keobox
Hello, I'm writing a little supervisor of some python scripts. To check if the scrips are running I'm using the ps -o pid,fname command on both RH Linux and solaris 10. All the scripts are launched using "python script.py" command, they are not launched with exec permissions. I don't know why the

parse html:what is the meaning of "//"?

2011-09-16 Thread alias
code1: import lxml.html import urllib down='http://finance.yahoo.com/q/op?s=C+Options' content=urllib.urlopen(down).read() root=lxml.html.document_fromstring(content) table = root.xpath("//table[@class='yfnc_mod_table_title1']")[0] tds=table.xpath("tr[@valign='top']//td") for td in tds: print

Fwd: Turkic I and re

2011-09-16 Thread John-John Tedro
On Fri, Sep 16, 2011 at 7:25 AM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > Thomas Rachel wrote: > > > Am 15.09.2011 15:16 schrieb Alan Plum: > > > >> The Turkish 'I' is a peculiarity that will probably haunt us programmers > >> until hell freezes over. > > > Meh, I don't thi

Re: Comparisons of computation timing

2011-09-16 Thread Nizamov Shawkat
> About the codes: Basically it simply solves some non-linear equations > using "fsolve" along with some other calculations. > Looks like you are using some third party libraries like numpy/scipy. Do these libraries have the same version on both platforms? What about python interpreter versions -

Re: Turkic I and re

2011-09-16 Thread Steven D'Aprano
Thomas Rachel wrote: > Am 15.09.2011 15:16 schrieb Alan Plum: > >> The Turkish 'I' is a peculiarity that will probably haunt us programmers >> until hell freezes over. Meh, I don't think it's much more peculiar that any other diacritic issue. If I'm German or English, I probably want ö and O to

Re: Comparisons of computation timing

2011-09-16 Thread Steven D'Aprano
Akand Islam wrote: > I have run my codes (written in Python) in my Notebook (3 GB Ram, Dual- > core CPU T4500 @ 2.3 GHz) and in my lab machine (11.57 GB Ram, i7-920 > CPU @ 2.67 GHz). However, I have found execution time in Notebook > 250.3 seconds, and in Lab machine 333.2 seconds. How is it poss

Re: Turkic I and re

2011-09-16 Thread Thomas Rachel
Am 15.09.2011 15:16 schrieb Alan Plum: The Turkish 'I' is a peculiarity that will probably haunt us programmers until hell freezes over. That's why it would have been nice if the Unicode guys had defined "both Turkish i-s" at separate codepoints. Then one could have the three pairs I, i ("n