Re: harmful str(bytes)

2010-10-11 Thread Stefan Behnel
Hallvard B Furuseth, 11.10.2010 23:45: If there were a __plain_str__() method which was supposed to fail rather than start to babble Python syntax, and if there were not plenty of Python code around which invoked __str__, I'd agree. Yes, calling str() "just in case" has a clear code smell. I th

Re: sending commands to the unix shell

2010-10-11 Thread Chris Rebert
On Mon, Oct 11, 2010 at 7:30 PM, Rodrick Brown wrote: > Trying to do something very trivial why is it failing It would have been helpful if you had specified in exactly what way(s) they were failing. > I've tried three approaches >     1. os.system("/bin/cat %s | /bin/mail -s \'connection error\

Re: Standardizing RPython - it's time.

2010-10-11 Thread alex23
John Nagle wrote: >      All the schemes to speed up Python as defined by CPython seem to hit > a wall on speed improvement.  Some of the numeric benchmarks go faster > on implementations that don't box all numbers, but 2x seems to be about > as good as it gets, even with a JIT compiler. That has

Re: Standardizing RPython - it's time.

2010-10-11 Thread John Nagle
On 10/11/2010 1:47 PM, Ryan Kelly wrote: On Mon, 2010-10-11 at 13:01 -0700, John Nagle wrote: It may be time to standardize "RPython". There are at least three implementations of "RPython" variants - PyPy, Shed Skin, and RPython for LLVM. The first two are up and running. There's a theory

Re: isnan

2010-10-11 Thread Andre Alexander Bell
Hi Kenny, On 10/12/2010 05:58 AM, Kenny wrote: > I have an array A, and another one B with same dimention and size. Now I > want to change the delete the elements in A where the same position in B > is nan. How can I do. > > Similar to the matlab code A(find(isnan(B)) = [] How about this: >>> f

Re: Help with sets

2010-10-11 Thread Steve Howell
On Oct 11, 5:11 pm, Gregory Ewing wrote: > Robert Kern wrote: > > The reasoning for this decision is spelled out in the PEP introducing > > the iterator feature: > > >  http://www.python.org/dev/peps/pep-0234/ > > There's also the question of whether 'if x in dict' should > compare keys only or bo

Re: Installing new module

2010-10-11 Thread alex23
On Oct 12, 1:34 pm, ronald brown wrote: > I uzipped to python Lib directory and try to run sample prog got this > error. What am I doing wrong? At a guess, you're not reading the documentation. You should add modules to Lib/site-packages, not directly to Lib/ itself. In Python 2.6+, you can also

Re: help!!!

2010-10-11 Thread Andreas Waldenburger
On Mon, 11 Oct 2010 20:04:28 -0500 Jorge Biquez wrote: > At 06:30 p.m. 11/10/2010, Robert Kern wrote: > >On 10/11/10 6:17 PM, Steven D'Aprano wrote: > >>On Mon, 11 Oct 2010 10:11:37 -0500, Robert Kern wrote: > >> > >>>On 10/11/10 8:44 AM, Jason Swails wrote: > > > On Mon, Oct 11, 20

isnan

2010-10-11 Thread Kenny
Hi All, I have an array A, and another one B with same dimention and size. Now I want to change the delete the elements in A where the same position in B is nan. How can I do. Similar to the matlab code A(find(isnan(B)) = [] Thank you. -- Best regards, Kenny -- http://mail.python.org/mailman

Installing new module

2010-10-11 Thread ronald brown
I uzipped to python Lib directory and try to run sample prog got this error. What am I doing wrong? Traceback (most recent call last): File "F:/Python25/Lib/MIDIUtil-0.87/a11", line 3, in from midiutil.MidiFile import MIDIFile ImportError: No module named midiutil.MidiFile -- http://mail.p

Re: 2D List

2010-10-11 Thread Tom Pacheco
On 10/11/2010 12:24 PM, Fasihul Kabir wrote: a = [0]*5 for i in range(0, 4): for j in range(0, i): a[i].append(j) why the above codes show the following error. and how to overcome it. Traceback (most recent call last): File "", line 3, in a[i].append(j) AttributeError: 'int

sending commands to the unix shell

2010-10-11 Thread Rodrick Brown
Trying to do something very trivial why is it failing I've tried three approaches 1. os.system("/bin/cat %s | /bin/mail -s \'connection error\' %s" % (logFile,notifyList)) 2. os.system("/bin/mail -s \'connection error\' %s < %s" % (notifyList,logFile)) 3. p1 = sp.Popen(["/bin/cat", log

Re: How is correct use of eval()

2010-10-11 Thread Nobody
On Tue, 12 Oct 2010 01:26:25 +0100, Nobody wrote: >>> What is correct way to use this function? >> >> To not use it in the first place if at all possible (use int(), >> float(), getattr(), etc. instead, > > Use read(). Oh wait, Python doesn't have that. Because parsing literals > and executing c

Re: help!!!

2010-10-11 Thread Jorge Biquez
At 06:30 p.m. 11/10/2010, Robert Kern wrote: On 10/11/10 6:17 PM, Steven D'Aprano wrote: On Mon, 11 Oct 2010 10:11:37 -0500, Robert Kern wrote: On 10/11/10 8:44 AM, Jason Swails wrote: On Mon, Oct 11, 2010 at 9:25 AM, Andreas Waldenburger wrote: On Mon, 11 Oct 2010 23:51:46 +1300 La

Re: Python deadlocks when Popen in multithread.

2010-10-11 Thread INADA Naoki
On Oct 12, 5:33 am, Jed Smith wrote: > On Mon, Oct 11, 2010 at 4:19 PM, INADA Naoki wrote: > > def worker(): > >    p = Popen(["cat"], stdin=PIPE, stdout=PIPE, stderr=STDOUT) > >    out = p.communicate("hoge")[0] > >    print "%s %s" % (current_thread().name, out) > > If, instead of spawning work

Re: How is correct use of eval()

2010-10-11 Thread Chris Rebert
On Mon, Oct 11, 2010 at 5:26 PM, Nobody wrote: > On Mon, 11 Oct 2010 11:18:37 -0700, Chris Rebert wrote: >>> What is correct way to use this function? >> >> To not use it in the first place if at all possible (use int(), >> float(), getattr(), etc. instead, > > Use read(). Oh wait, Python doesn't

Re: How is correct use of eval()

2010-10-11 Thread Nobody
On Mon, 11 Oct 2010 11:18:37 -0700, Chris Rebert wrote: >> What is correct way to use this function? > > To not use it in the first place if at all possible (use int(), > float(), getattr(), etc. instead, Use read(). Oh wait, Python doesn't have that. Because parsing literals and executing code

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-11 Thread Nobody
On Mon, 11 Oct 2010 05:42:39 -0700, Ethan Furman wrote: >>>If I'm catching exceptions in order to perform clean-up, I'll use a bare >>>except and re-raise the exception afterwards. In that situation, a bare >>>except is usually the right thing to do. >> >> Wrong way to do it. > > What, then, is

Re: Help with sets

2010-10-11 Thread Gregory Ewing
Robert Kern wrote: The reasoning for this decision is spelled out in the PEP introducing the iterator feature: http://www.python.org/dev/peps/pep-0234/ There's also the question of whether 'if x in dict' should compare keys only or both keys and values. This was also hotly debated back whe

Re: Class-level variables - a scoping issue

2010-10-11 Thread Gregory Ewing
Lawrence D'Oliveiro wrote: In message <8hfq23fet...@mid.individual.net>, Gregory Ewing wrote: How would you intend to enforce such a restriction? The same way it’s already enforced. I don't see how that's possible, except in a very limited and unreliable way. The compiler would have to be a

Re: help!!!

2010-10-11 Thread Robert Kern
On 10/11/10 6:17 PM, Steven D'Aprano wrote: On Mon, 11 Oct 2010 10:11:37 -0500, Robert Kern wrote: On 10/11/10 8:44 AM, Jason Swails wrote: On Mon, Oct 11, 2010 at 9:25 AM, Andreas Waldenburger wrote: On Mon, 11 Oct 2010 23:51:46 +1300 Lawrence D'Oliveiro wrote: > In m

Re: help!!!

2010-10-11 Thread Steven D'Aprano
On Mon, 11 Oct 2010 10:11:37 -0500, Robert Kern wrote: > On 10/11/10 8:44 AM, Jason Swails wrote: >> >> >> On Mon, Oct 11, 2010 at 9:25 AM, Andreas Waldenburger >> wrote: >> >> On Mon, 11 Oct 2010 23:51:46 +1300 Lawrence D'Oliveiro >> wrote: >> >> > In message >

Re: How is correct use of eval()

2010-10-11 Thread Steven D'Aprano
On Mon, 11 Oct 2010 11:18:37 -0700, Chris Rebert wrote: > On Mon, Oct 11, 2010 at 11:11 AM, Cata wrote: >> Hi . >> I read about eval(). >> I also read about this "bug" : >> cod = raw_input ('Enter:") >> eval (cod) >> if i use  "rm -rf ~"  all files will be deleted . > > That's incorrect. eval()

Re: Missing modules for python

2010-10-11 Thread Steven D'Aprano
On Mon, 11 Oct 2010 10:32:44 -0400, Jed Smith wrote: > simplejson got merged into the standard library in Python 2.6. In > libcloud, I wrote this: > > try: import json > except ImportError, excp: import simplejson as json I'm curious why you bother to bind the exception to the excp when you

Re: urllib2 script slowing and stopping

2010-10-11 Thread Dantium
On Oct 11, 10:07 pm, Ian wrote: > On Oct 11, 2:48 pm, Dantium wrote: > > > I have a small script that reads several CSV files in a directory and > > puts the data in a DB using Django. > > > There are about 1.7 million records in 120 CSV files, I am running the > > script on a VPS with about 512m

Re: Class-level variables - a scoping issue

2010-10-11 Thread Ixokai
On 10/9/10 10:30 PM, John Nagle wrote: > Python protects global variables from similar confusion > by making them read-only when referenced from an inner scope > without a "global" statement. No. It doesn't. Assignments simply always apply to local variables, unless you explicitly indicate oth

Re: EOF while scanning triple-quoted string literal

2010-10-11 Thread Ian Kelly
On Mon, Oct 11, 2010 at 3:59 PM, Rhodri James wrote: > On Mon, 11 Oct 2010 10:37:09 +0100, bussiere bussiere > wrote: > > > i've looked on the web and here but i didn't find an answer : here is my >> code >> >> zlib.decompress(""" >> xワᆳヤ=ラᄇHナs~Ʀᄑç\ムîà >> z...@ÑÁÔqÇlxÇÆïpp >> ~ýVãì゙M6ÛÐ|ê֭ᄁᄂヤ=)}

Re: harmful str(bytes)

2010-10-11 Thread Antoine Pitrou
On Mon, 11 Oct 2010 21:50:32 +0200 Hallvard B Furuseth wrote: > > I'd just posted an example in article : > > urllib.parse.urlunparse(('', '', '/foo', b'bar', '', '')) returns > "/foo;b'bar'" instead of raising an exception or returning 2.6's correct > "/foo;bar". Oh, this looks like a bug in u

Re: Unicode Decode Error

2010-10-11 Thread Ian Kelly
On Mon, Oct 11, 2010 at 3:44 PM, Pratik Khemka wrote: > I tried to solve it using this *wbk = xlwt.Workbook('utf-8')... *The > problem still persists. Is there a way I can solve this problem..? > > *Traceback (most recent call last): > File "C:\Documents and Settings\pkhemka\My Documents\merge_

Re: EOF while scanning triple-quoted string literal

2010-10-11 Thread Rhodri James
On Mon, 11 Oct 2010 10:37:09 +0100, bussiere bussiere wrote: i've looked on the web and here but i didn't find an answer : here is my code zlib.decompress(""" xワᆳヤ=ラᄇHナs~Ʀᄑç\ムîà z...@ÑÁÔqÇlxÇÆïpp~ývãì゙m6ÛÐ|ê֭ᄁᄂヤ=)}éÓUe﬿ö3ᄎᄌú"}ʿïÿ÷1þ8ñ́U÷ᄏñíLÒVi:`ᄈᄎL!Ê҆p6-%Fë^ヘ÷à,Q.K!ユô`ÄA!ÑêweÌ ÊÚAロYøøÂjôóᅠÂcñ

Re: harmful str(bytes)

2010-10-11 Thread Hallvard B Furuseth
Stefan Behnel writes: >Hallvard B Furuseth, 11.10.2010 21:50: >> Fine, so programs will have to do it themselves... > > Yes, they can finally handle bytes and Unicode data correctly and > safely. Having byte data turn into Unicode strings unexpectedly makes > the behaviour of your code hardly predi

Re: harmful str(bytes)

2010-10-11 Thread Hallvard B Furuseth
Terry Reedy writes: >On 10/8/2010 9:45 AM, Hallvard B Furuseth wrote: >>> Actually, the implicit contract of __str__ is that it never fails, so >>> that everything can be printed out (for debugging purposes, etc.). >> >> Nope: >> >> $ python2 -c 'str(u"\u1000")' >> Traceback (most recent call last)

RE: Unicode Decode Error

2010-10-11 Thread Pratik Khemka
This is the original full traceback. when I was getting the Unicode Decode Error.. Traceback (most recent call last): File "C:\Documents and Settings\pkhemka\My Documents\merge_py.py", line 315, i n wbk.save('p4_merge.xls') File "C:\Python25\lib\site-packages\xlwt\Workbook.py", line

Re: help!!!

2010-10-11 Thread Jed Smith
On Mon, Oct 11, 2010 at 5:02 PM, Seebs wrote: > and something like scanf(), where I've never heard of a compiler doing > anything of the sort. By default, MSVC complains hard enough when using scanf() to make you regret it (I think? been a while). -- Jed Smith j...@jedsmith.org -- http://mai

Re: help!!!

2010-10-11 Thread geremy condra
On Mon, Oct 11, 2010 at 12:11 PM, Jason Swails wrote: > > > On Mon, Oct 11, 2010 at 3:05 PM, Robert Kern wrote: >> >> On 10/11/10 11:44 AM, Jason Swails wrote: >>> >>> >>> On Mon, Oct 11, 2010 at 11:11 AM, Robert Kern >> > wrote: >>> >>>    On 10/11/10 8:44 AM, Jason

Re: urllib2 script slowing and stopping

2010-10-11 Thread Ian
On Oct 11, 2:48 pm, Dantium wrote: > I have a small script that reads several CSV files in a directory and > puts the data in a DB using Django. > > There are about 1.7 million records in 120 CSV files, I am running the > script on a VPS with about 512mb of memory python 2.6.5 on ubuntu > 10.04. >

Re: Standardizing RPython - it's time.

2010-10-11 Thread Ryan Kelly
On Mon, 2010-10-11 at 13:01 -0700, John Nagle wrote: > It may be time to standardize "RPython". > >There are at least three implementations of "RPython" variants - PyPy, > Shed Skin, and RPython for LLVM. The first two are up and running. > There's a theory paper on the subject: > > http://c

Re: help!!!

2010-10-11 Thread Seebs
On 2010-10-11, Lawrence D'Oliveiro wrote: > In message , Seebs wrote: >> ... but I wasn't aware that it had been deprecated, except in the sense of >> being derided and dismissed as of no value. > What more did you want? :) Well, formal "deprecation" in the language standards sense, as in, "warn

urllib2 script slowing and stopping

2010-10-11 Thread Dantium
I have a small script that reads several CSV files in a directory and puts the data in a DB using Django. There are about 1.7 million records in 120 CSV files, I am running the script on a VPS with about 512mb of memory python 2.6.5 on ubuntu 10.04. The script gets slow and seems to lock after ab

Re: Standardizing RPython - it's time.

2010-10-11 Thread John Nagle
On 10/11/2010 1:01 PM, John Nagle wrote: (Correct Shed Skin tutorial link) > Shed Skin: > http://shedskin.googlecode.com/files/shedskin-tutorial-0.3.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Python deadlocks when Popen in multithread.

2010-10-11 Thread Jed Smith
On Mon, Oct 11, 2010 at 4:19 PM, INADA Naoki wrote: > def worker(): >    p = Popen(["cat"], stdin=PIPE, stdout=PIPE, stderr=STDOUT) >    out = p.communicate("hoge")[0] >    print "%s %s" % (current_thread().name, out) If, instead of spawning workers you directly call worker(), does it succeed?

Re: Standardizing RPython - it's time.

2010-10-11 Thread Jed Smith
On Mon, Oct 11, 2010 at 4:01 PM, John Nagle wrote: > file:///C:/Users/nagle/AppData/Local/Temp/shedskin-tutorial-0.3.html This gives me a 404. Your Web server is broken! Fix it! ;) Temporarily mirrored: http://jedsmith.org/tmp/shedskin-tutorial-0.5.html -- Jed Smith j...@jedsmith.org -- http

Re: harmful str(bytes)

2010-10-11 Thread Stefan Behnel
Hallvard B Furuseth, 11.10.2010 21:50: Antoine Pitrou writes: 2) some unicode objects didn't have a succesful str() Python 3 fixes both these issues. Fixing 1) means there's no automatic coercion when trying to mix bytes and unicode. Fine, so programs will have to do it themselves... Yes, t

Python deadlocks when Popen in multithread.

2010-10-11 Thread INADA Naoki
On Ubuntu 10.10 amd64 and dual-core CPU, following code deadlocks. What's wrong on this code? #http://codepad.org/GkoXHbik #!/usr/bin/env python from subprocess import * from threading import * THREAD_COUNT=50 def worker(): p = Popen(["cat"], stdin=PIPE, stdout=PIPE, stderr=STDOUT) out

Standardizing RPython - it's time.

2010-10-11 Thread John Nagle
It may be time to standardize "RPython". There are at least three implementations of "RPython" variants - PyPy, Shed Skin, and RPython for LLVM. The first two are up and running. There's a theory paper on the subject: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.142.1457&rep=rep

Re: Adding to an Array inside a Dict

2010-10-11 Thread Arnaud Delobelle
MRAB writes: > On 11/10/2010 15:55, MacOSX @ Rocteur.cc wrote: >> Hi, >> >> Is there an easier way to do this, I am adding/creating to an array >> inside a dict but can find a cleaner way: >> >> So I first check if the key exists already, if it does then I know I use >> append, if it does not I c

Re: Difficulty in easy_install

2010-10-11 Thread Diez B. Roggisch
sankalp srivastava writes: > I am having difficulty in easy_installing > I use a proxy server and strange errors , like it can't fetch the > package is showing up . > the package is pyspeech ...please help me :( > > I don't know if the proxy server is causing the problems , in linux i > would ha

Re: harmful str(bytes)

2010-10-11 Thread Hallvard B Furuseth
Antoine Pitrou writes: >Hallvard B Furuseth wrote: >>Antoine Pitrou writes: >>>Hallvard B Furuseth wrote: The offender is bytes.__str__: str(b'foo') == "b'foo'". It's often not clear from looking at a piece of code whether some data is treated as strings or bytes, particularly when

Re: help!!!

2010-10-11 Thread Emile van Sebille
On 10/11/2010 12:11 PM Jason Swails said... But tabs ARE spaces (specifically 3 of them), in a row ;) Hoo boy Duckingly, Emile -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding to an Array inside a Dict

2010-10-11 Thread Robert Kern
On 10/11/10 1:29 PM, MRAB wrote: On 11/10/2010 15:55, MacOSX @ Rocteur.cc wrote: Hi, Is there an easier way to do this, I am adding/creating to an array inside a dict but can find a cleaner way: So I first check if the key exists already, if it does then I know I use append, if it does not I c

Re: harmful str(bytes)

2010-10-11 Thread Hallvard B Furuseth
Terry Reedy writes: >On 10/8/2010 9:31 AM, Hallvard B Furuseth wrote: >> That's not the point - the point is that for 2.* code which _uses_ str >> vs unicode, the equivalent 3.* code uses str vs bytes. Yet not the >> same way - a 2.* 'str' will sometimes be 3.* bytes, sometime str. So >> upgraded

Re: help!!!

2010-10-11 Thread Jason Swails
On Mon, Oct 11, 2010 at 3:05 PM, Robert Kern wrote: > On 10/11/10 11:44 AM, Jason Swails wrote: > >> >> >> On Mon, Oct 11, 2010 at 11:11 AM, Robert Kern > > wrote: >> >>On 10/11/10 8:44 AM, Jason Swails wrote: >> >> >> >>On Mon, Oct 11, 2010 at 9:25 AM, A

Re: How is correct use of eval()

2010-10-11 Thread Robert Kern
On 10/11/10 1:11 PM, Cata wrote: Hi . I read about eval(). I also read about this "bug" : cod = raw_input ('Enter:") eval (cod) if i use "rm -rf ~" all files will be deleted . What is correct way to use this function? There are cases when you are writing meta-programming tools for programmer

Re: help!!!

2010-10-11 Thread Robert Kern
On 10/11/10 11:44 AM, Jason Swails wrote: On Mon, Oct 11, 2010 at 11:11 AM, Robert Kern mailto:robert.k...@gmail.com>> wrote: On 10/11/10 8:44 AM, Jason Swails wrote: On Mon, Oct 11, 2010 at 9:25 AM, Andreas Waldenburger wrote: On Mon, 11 Oct 2010 2

Re: emdding python gui in c code - OS independent

2010-10-11 Thread Diez B. Roggisch
tinauser writes: > On Oct 11, 6:49 pm, Chris Rebert wrote: >> On Mon, Oct 11, 2010 at 6:16 AM, tinauser wrote: >> > hi there, >> > i need to embed python GUI in a c++ code. I've seen that,while on >> > windows running GUI is no problem, in mac i need to use pythonw >> > instead python. >> > the

Re: Adding to an Array inside a Dict

2010-10-11 Thread MRAB
On 11/10/2010 15:55, MacOSX @ Rocteur.cc wrote: Hi, Is there an easier way to do this, I am adding/creating to an array inside a dict but can find a cleaner way: So I first check if the key exists already, if it does then I know I use append, if it does not I create it. if osmdict.has

Re: How is correct use of eval()

2010-10-11 Thread Chris Rebert
On Mon, Oct 11, 2010 at 11:11 AM, Cata wrote: > Hi . > I read about eval(). > I also read about this "bug" : > cod = raw_input ('Enter:") > eval (cod) > if i use  "rm -rf ~"  all files will be deleted . That's incorrect. eval() does not (directly) run shell commands. It does evaluate arbitrary Py

How is correct use of eval()

2010-10-11 Thread Cata
Hi . I read about eval(). I also read about this "bug" : cod = raw_input ('Enter:") eval (cod) if i use "rm -rf ~" all files will be deleted . What is correct way to use this function? Thank's -- http://mail.python.org/mailman/listinfo/python-list

Re: logging.handlers.SMTPHandler and fileConfig

2010-10-11 Thread Chris Withers
On 11/10/2010 15:52, pstatham wrote: I'm trying to use pythons logging.handlers.SMTPHandler with a configuration file (so that I don't have to have passwords etc. inside of the script) Use MailingLogger and ZConfig ;-) http://groups.google.com/group/simplistix/browse_thread/thread/f4223c3a92e9

"char buffer type not available" error while gunzip

2010-10-11 Thread Istvan Gouritz
Hello! I'm getting exception while trying to gunzip data, which is stored in db: File "helper.py", line 33, in gunzip f = StringIO(data) "exceptions.TypeError: char buffer type not available" function which does gunzipping: def gunzip(s): print type(data)) #print

Re: emdding python gui in c code - OS independent

2010-10-11 Thread tinauser
On Oct 11, 6:49 pm, Chris Rebert wrote: > On Mon, Oct 11, 2010 at 6:16 AM, tinauser wrote: > > hi there, > > i need to embed python GUI in a c++ code. I've seen that,while on > > windows running GUI is no problem, in mac i need to use pythonw > > instead python. > > the question is,how should i t

Re: "Strong typing vs. strong testing"

2010-10-11 Thread Vic Kelson
On Sep 28, 10:55 am, Tim Bradshaw wrote: > There's a large existing body of knowledge on dimensional analysis > (it's a very important tool for physics, for instance), and obviously > the answer is to do whatever it does.  Raising to any power is fine, I > think (but transcendental functions, for

Re: 2D List

2010-10-11 Thread Gary Herron
On 10/11/2010 09:24 AM, Fasihul Kabir wrote: a = [0]*5 for i in range(0, 4): for j in range(0, i): a[i].append(j) why the above codes show the following error. and how to overcome it. Traceback (most recent call last): File "", line 3, in a[i].append(j) AttributeError: 'int'

Re: Class-level variables - a scoping issue

2010-10-11 Thread Chris Rebert
On Mon, Oct 11, 2010 at 9:44 AM, Dennis Lee Bieber wrote: > On Mon, 11 Oct 2010 10:43:04 -0400, John Posner > declaimed the following in gmane.comp.python.general: >> No surprising behavior, just a surprising look: >> >>    self.EGGS = ... >> >> ... which might remind the programmer what's going

Re: Many newbie questions regarding python

2010-10-11 Thread Peter Pearson
On Sun, 10 Oct 2010 18:36:27 -0700, Ethan Furman wrote: [snip] > > My question is more along the lines of: a mutable object was passed in > to func()... what style of loop could be used to turn that one object > into /n/ distinct objects? A list comp won't do it, but neither will a > for loop,

Re: emdding python gui in c code - OS independent

2010-10-11 Thread Chris Rebert
On Mon, Oct 11, 2010 at 6:16 AM, tinauser wrote: > hi there, > i need to embed python GUI in a c++ code. I've seen that,while on > windows running GUI is no problem, in mac i need to use pythonw > instead python. > the question is,how should i tell the program that if the OS is mac, > it should py

Re: help!!!

2010-10-11 Thread Jason Swails
On Mon, Oct 11, 2010 at 11:11 AM, Robert Kern wrote: > On 10/11/10 8:44 AM, Jason Swails wrote: > >> >> >> On Mon, Oct 11, 2010 at 9:25 AM, Andreas Waldenburger >> >> wrote: >> >>On Mon, 11 Oct 2010 23:51:46 +1300 Lawrence D'Oliveiro >> wrote: >> >> > In message >

Re: 2D List

2010-10-11 Thread Chris Rebert
On Mon, Oct 11, 2010 at 9:24 AM, Fasihul Kabir wrote: > a = [0]*5 >  for i in range(0, 4): >     for j in range(0, i): >         a[i].append(j) > > why the above codes show the following error. and how to overcome it. > > Traceback (most recent call last): >   File "", line 3, in >     a[i].appen

Re: 2D List

2010-10-11 Thread Nitin Pawar
the declaration is wrong if you want to create a two dimensional array try to use functions like arange and reshape On Mon, Oct 11, 2010 at 9:54 PM, Fasihul Kabir wrote: > a = [0]*5 > for i in range(0, 4): > for j in range(0, i): > a[i].append(j) > > why the above codes show the fo

2D List

2010-10-11 Thread Fasihul Kabir
a = [0]*5 for i in range(0, 4): for j in range(0, i): a[i].append(j) why the above codes show the following error. and how to overcome it. Traceback (most recent call last): File "", line 3, in a[i].append(j) AttributeError: 'int' object has no attribute 'append' --

Re: logging.handlers.SMTPHandler and fileConfig

2010-10-11 Thread Chris Rebert
On Mon, Oct 11, 2010 at 7:52 AM, pstatham wrote: > I'm trying to use pythons logging.handlers.SMTPHandler with a > configuration file (so that I don't have to have passwords etc. inside > of the script) > > Now the guide I'm following is [URL="http://docs.python.org/library/ > logging.html#configu

Re: Reading Outlook .msg file using Python

2010-10-11 Thread Tim Golden
On 11/10/2010 4:39 PM, John Henry wrote: I am trying your code but when it get to the line: mapi.MAPIInitialize ((mapi.MAPI_INIT_VERSION, 0)) I got the error message: Either there is no default mail client or the current mail client cannot fulfill the messsage requrest. Please run Micr

Re: Reading Outlook .msg file using Python

2010-10-11 Thread John Henry
On Oct 11, 3:56 am, Tim Golden wrote: > On 10/10/2010 22:51, John Henry wrote: > > > I have a need to read .msg files exported from Outlook.  Google search > > came out with a few very old posts about the topic but nothing really > > useful.  The email module in Python is no help - everything come

Re: Adding to an Array inside a Dict

2010-10-11 Thread Robert Kern
On 10/11/10 9:55 AM, MacOSX @ Rocteur.cc wrote: Hi, Is there an easier way to do this, I am adding/creating to an array inside a dict but can find a cleaner way: So I first check if the key exists already, if it does then I know I use append, if it does not I create it. if osmdict.has

Re: help!!!

2010-10-11 Thread Robert Kern
On 10/11/10 8:44 AM, Jason Swails wrote: On Mon, Oct 11, 2010 at 9:25 AM, Andreas Waldenburger wrote: On Mon, 11 Oct 2010 23:51:46 +1300 Lawrence D'Oliveiro wrote: > In message mailto:mailman.1417.1286438621.29448.python-l...@python.org>>, > Emile van Sebille wrote: >

Re: Help with sets

2010-10-11 Thread Robert Kern
On 10/11/10 6:11 AM, Lawrence D'Oliveiro wrote: In message<8h9ob9fku...@mid.individual.net>, Gregory Ewing wrote: Lawrence D'Oliveiro wrote: Did you know that applying the “set” or “frozenset” functions to a dict return a set of its keys? Seems a bit dodgy, somehow. That's just a consequ

Adding to an Array inside a Dict

2010-10-11 Thread MacOSX @ Rocteur.cc
Hi, Is there an easier way to do this, I am adding/creating to an array inside a dict but can find a cleaner way: So I first check if the key exists already, if it does then I know I use append, if it does not I create it. if osmdict.has_key(token): osmdict[token]['user'].app

logging.handlers.SMTPHandler and fileConfig

2010-10-11 Thread pstatham
I'm trying to use pythons logging.handlers.SMTPHandler with a configuration file (so that I don't have to have passwords etc. inside of the script) Now the guide I'm following is [URL="http://docs.python.org/library/ logging.html#configuration-file-format"]here[/URL], now the RotatingFileHandler i

Re: Class-level variables - a scoping issue

2010-10-11 Thread John Posner
On 10/10/2010 7:02 PM, Steven D'Aprano wrote: On Sun, 10 Oct 2010 18:14:33 -0400, John Posner wrote: Class attributes are often used as "class constants", so how about naming them with UPPERCASE names, like other constants? When you choose to override one of these constants, like this: se

Re: Can't find pythonwin

2010-10-11 Thread Jed Smith
On Mon, Oct 11, 2010 at 3:46 AM, Dennis Lee Bieber wrote: > On Sun, 10 Oct 2010 20:33:09 -0400, Jed Smith > declaimed the following in gmane.comp.python.general: > >> >> As far as I know, Pythonwin is a collection of extensions to Python >> that are available on Windows (and antiquated). >> >    

Wingware Python IDE 3.2.11 released

2010-10-11 Thread Wingware
Hi, Wingware has released version 3.2.11 of Wing IDE, an integrated development environment designed specifically for the Python programming language. This release includes the following improvements: * Improved Perforce integration * Improved vi and Visual Studio modes, and keyboard navigation

Re: Missing modules for python

2010-10-11 Thread Jed Smith
On Mon, Oct 11, 2010 at 8:43 AM, Sunil Saggar wrote: > I was trying to make exe from python program and found the following errors > > The following modules appear to be missing > ['email.FeedParser', 'email.Generator', 'email.Iterators', 'email.Message', > 'email.Utils', 'simplejson', 'socks'] >

Re: binary vtk file

2010-10-11 Thread Robert Kern
On 10/11/10 5:16 AM, Paul Biegel wrote: Hi, I have a question related to read a binary vtk file. This file has been created using Matlab by the command "fread". However, this file must be processed further within Python. It is not known to me which codec is used to encode this file. It starts wit

Re: if the else short form

2010-10-11 Thread Neville Dempsey
On Oct 11, 11:46 am, Lawrence D'Oliveiro wrote: > Nowadays we take it for granted that the core language should be a strong > and compact basis to build on, rather than providing lots of built-in > features, and all the rest should come from run-time libraries. Fast forward to 1972... In 1972 Bri

Re: help!!!

2010-10-11 Thread Jason Swails
On Mon, Oct 11, 2010 at 9:25 AM, Andreas Waldenburger wrote: > On Mon, 11 Oct 2010 23:51:46 +1300 Lawrence D'Oliveiro > wrote: > > > In message , > > Emile van Sebille wrote: > > > > > Oh come now -- isn't being lazy a primary programmer's attribute? > > > > I wonder if that’s why more men are g

Re: help!!!

2010-10-11 Thread Andreas Waldenburger
On Mon, 11 Oct 2010 23:51:46 +1300 Lawrence D'Oliveiro wrote: > In message , > Emile van Sebille wrote: > > > Oh come now -- isn't being lazy a primary programmer's attribute? > > I wonder if that’s why more men are good at it than women... You may want to think about whether this really was y

Re: Class-level variables - a scoping issue

2010-10-11 Thread Jean-Michel Pichavant
John Nagle wrote: Here's an obscure bit of Python semantics which is close to being a bug: >>> class t(object) : ... classvar = 1 ... ... def fn1(self) : ... print("fn1: classvar = %d" % (self.classvar,)) ... self.classvar = 2 ... print("fn1: classvar = %d" % (

Re: [Python-Dev] PyArg_ParseTuple

2010-10-11 Thread Brian Curtin
On Mon, Oct 11, 2010 at 07:06, Ioan Ferencik wrote: > I would like to ask where can I find more detailed info on > PyArg_ParseTuple function. > > I find the doc limited on the matter. > Mainly I am curious why the function requires an address of a pointer. > > I have issues in the following case

emdding python gui in c code - OS independent

2010-10-11 Thread tinauser
hi there, i need to embed python GUI in a c++ code. I've seen that,while on windows running GUI is no problem, in mac i need to use pythonw instead python. the question is,how should i tell the program that if the OS is mac, it should pythonw, otherwise python is fine? -- http://mail.python.org/ma

Re: Help with sets

2010-10-11 Thread Ethan Furman
Lawrence D'Oliveiro wrote: In message <8h9ob9fku...@mid.individual.net>, Gregory Ewing wrote: Lawrence D'Oliveiro wrote: Did you know that applying the “set” or “frozenset” functions to a dict return a set of its keys? Seems a bit dodgy, somehow. That's just a consequence of the fact tha

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-11 Thread Ethan Furman
Lawrence D'Oliveiro wrote: In message , Nobody wrote: If I'm catching exceptions in order to perform clean-up, I'll use a bare except and re-raise the exception afterwards. In that situation, a bare except is usually the right thing to do. Wrong way to do it. What, then, is the right way to

Missing modules for python

2010-10-11 Thread Sunil Saggar
I was trying to make exe from python program and found the following errors The following modules appear to be missing ['email.FeedParser', 'email.Generator', 'email.Iterators', 'email.Message', 'email.Utils', 'simplejson', 'socks'] I am using Python 2.6 -- Regards Sunil Saggar -- http://mai

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-11 Thread Ethan Furman
Antoon Pardon wrote: On Sat, Oct 09, 2010 at 01:37:03AM +, Steven D'Aprano wrote: On Fri, 08 Oct 2010 15:53:17 -0400, Jed Smith wrote: On Fri, Oct 8, 2010 at 1:26 PM, Steven D'Aprano wrote: On Fri, 08 Oct 2010 10:21:16 +0200, Antoon Pardon wrote: Personnaly I find it horrible that

Re: Eclipse/PyDev - BOM Lexical Error

2010-10-11 Thread Ethan Furman
Lawrence D'Oliveiro wrote: In message , Ethan Furman wrote: Lawrence D'Oliveiro wrote: In message , Ethan Furman wrote: Lawrence D'Oliveiro wrote: But they can only recognize it as a BOM if they assume UTF-8 encoding to begin with. Otherwise it could be interpreted as some other codi

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-11 Thread Peter Otten
Steven D'Aprano wrote: > On Tue, 05 Oct 2010 13:57:11 +1100, Ben Finney wrote: > >> chad writes: >> >>> while 1: >> >> A minor point: this is more explanatory and less misleading if you write >> it as ‘while True’. > > Why is it misleading? Is there some circumstance in Python where the > lit

EOF while scanning triple-quoted string literal

2010-10-11 Thread bussiere bussiere
i've looked on the web and here but i didn't find an answer : here is my code zlib.decompress(""" xワᆳヤ=ラᄇHナs~Ʀᄑç\ムîà z...@ÑÁÔqÇlxÇÆïpp~ývãì゙m6ÛÐ|ê֭ᄁᄂヤ=)}éÓUe﬿ö3ᄎᄌú"}ʿïÿ÷1þ8ñ́U÷ᄏñíLÒVi:`ᄈᄎL!Ê҆p6-%Fë^ヘ÷à,Q.K!ユô`ÄA!ÑêweÌ ÊÚAロYøøÂjôóᅠÂcñ䊧fᆴùテúN :nüzAÝ7%ᄌcdUタᄌ3ôPۂタlンyHᆲᄑ$/yzᄒíàヌ'ÕÓ&`|S!<'ᄂ÷Zļᄐ2ホモ;ニ(ÅÛf

Re: Many newbie questions regarding python

2010-10-11 Thread Jean-Michel Pichavant
Peter Pearson wrote: On Sat, 09 Oct 2010 19:30:16 -0700, Ethan Furman wrote: Steven D'Aprano wrote: [snip] But that doesn't mean that the list comp is the general purpose solution. Consider the obvious use of the idiom: def func(arg, count): # Initialise the list. L = [ar

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-11 Thread Antoon Pardon
On Mon, Oct 11, 2010 at 06:25:49AM -0400, Dave Angel wrote: > On 2:59 PM, Antoon Pardon wrote: > >On Sat, Oct 09, 2010 at 01:37:03AM +, Steven D'Aprano wrote: > > > >>But the point was that Antoon claimed that there is no numeric value for > >>the end position that will include L[0] in the rev

Re: Help with sets

2010-10-11 Thread Lawrence D'Oliveiro
In message <8h9ob9fku...@mid.individual.net>, Gregory Ewing wrote: > Lawrence D'Oliveiro wrote: > >> Did you know that applying the “set” or “frozenset” functions to a dict >> return a set of its keys? > >> Seems a bit dodgy, somehow. > > That's just a consequence of the fact that dicts produce

Re: del() function - cannot find documentation

2010-10-11 Thread Lawrence D'Oliveiro
In message , Tim Roberts wrote: > This kind of confusion is, in my opinion, the primary reason why > parentheses should never be used with "del" and "return", as we so > commonly see. It’s the kind of “confusion” that could be cleared up with 30 seconds’ access to a Python interpreter: l...

  1   2   >