Re: mail sending -- smtplib

2010-09-08 Thread Kurian Thayil
Got it fixed. It was a very silly mistake. mssg variable had each line with indent. Removed the indent and it worked. Regards, Kurian Thayil. On Tue, Sep 7, 2010 at 9:57 AM, Kurian Thayil kurianmtha...@gmail.comwrote: Hi All, I am a newbie in python. Just 2-3 days old wanting to learn this

Re: The Samurai Principle

2010-09-08 Thread Ian Kelly
On Tue, Sep 7, 2010 at 9:35 PM, Phlip phlip2...@gmail.com wrote: Exceptions are very dangerous by themselves, because if you don't trap them just right they can cause side-effects. And returning None on failure is dangerous, because if the programmer does not take care to handle that case, the

Re: another way to sort like l.sort(key=lambda x:(x[0][0], -x[1][0]))

2010-09-08 Thread sajuptpm
Detailed Description - l1 = [] l2 = [ ((3,8),(1,2)), ((1,3),(1,7)), ((7,0),(1,8)), ((4,2),(1,2)), ((2,9),(9,1)) ] I need to take each item from l2 and insert into l1 with first element(column)(3,1,7,4,2) sorted in ascending order and second element(column)(8,3,0,2,9)

Re: list of tuples with dynamic change in position

2010-09-08 Thread Ulrich Eckhardt
sajuptpm wrote: i want to find the loaded machine based on cpu and mem and desk utilization by changing this order. I created a UI using that i can change the order of item in the tuple. But the problem is asc and desc sorting How about only changing the order in which the elements are

LZO decompressing with Python 2.5x on Windows for C dummies

2010-09-08 Thread Kim Hansen
Hi list, I have some binary data files which contain embedded LZO compressed payloads mixed with normal C-struct like headers. I would like to have the ability to LZO decompress these payloads using a python 2.5.x script. I was hoping that there was an up-to-date plug-and-play LZO library

Re: The Samurai Principle

2010-09-08 Thread Ian Kelly
On Tue, Sep 7, 2010 at 9:38 PM, Phlip phlip2...@gmail.com wrote: Everyone gets defensive about the design flaws in their own language. But the django.db situation is not even a design flaw; just a misinterpretation of the Samurai Principle. int('yo') shall throw an exception, but a missing

Re: include a file in a python program

2010-09-08 Thread bussiere bussiere
Thanks all for your response i will try out this week, you have give me sufficient hints. Thanks again. Bussiere -- http://mail.python.org/mailman/listinfo/python-list

Re: another way to sort like l.sort(key=lambda x:(x[0][0], -x[1][0]))

2010-09-08 Thread Peter Otten
sajuptpm wrote: Now output is similar to first elements asc and second elements desc.But the problem is the -ve sign, i dont need that. Have any other method to do it?? Sort twice: for item in items: ... print item ... ('adams', 'anne') ('miller', 'arnold') ('miller', 'bill')

console-editor written in python

2010-09-08 Thread Tanje Toolate
hi there, greetings. i am looking for a small, console-based (opensource) texteditor, written in python (or as shellscript!), but i'm not finding something usable. very find would be emacs-keybindings ... dank u well, tanja -- http://mail.python.org/mailman/listinfo/python-list

Re: mutate dictionary or list

2010-09-08 Thread Baba
On 7 sep, 16:46, Ben Finney ben+pyt...@benfinney.id.au wrote: de...@web.de writes: Objects can be mutable or immutable. For example, in Python, integers, strings, floats and tuples are immutable. That means that you can't change their value. Yes. Importantly, wherever you see code that

Re: accessing a text file

2010-09-08 Thread Baba
On 8 sep, 02:07, Ben Finney ben+pyt...@benfinney.id.au wrote: Baba raoul...@gmail.com writes: However the following Wiki excerpt seems to go in my direction: No, it doesn't. It advises that people show kindness; as I've been arguing, that's exactly what you were shown. You haven't shown how

Re: Bit fields in python?

2010-09-08 Thread Kwan Lai Cheng
Thanks everyone for all the suggestions! New to python, so reading up on the struct module Construct library now, hope to get my problem fixed soon. - Original Message - Bitfields are most commonly used for extreme space optimization - i.e. shoving several variables and flags with

Re: accessing a text file

2010-09-08 Thread Paul Rubin
Baba raoul...@gmail.com writes: It is just unfriendly to tell someone to go and look it up by themselves. Someone seeing too many unthoughtful questions from you might tell you to look it up yourself, in the hopes of getting you to change your questioning style, so that your future questions

Re: Bit fields in python?

2010-09-08 Thread geremy condra
On Tue, Sep 7, 2010 at 9:53 PM, Eli Bendersky eli...@gmail.com wrote: I'm trying to rewrite a c program in python encountered several problems. I have some data structures in my c program like below: typedef struct {     unsigned short size;     unsigned short reserved:8;     unsigned

Re: Speed-up for loops

2010-09-08 Thread Ulrich Eckhardt
BartC wrote: So 'range' is just a class like any other. And that a class is something you can blithely copy from one variable to another. And whenever you see 'range' anywhere, you can't always be certain that someone hasn't done: range = 42 at some point. True. I read an explanation

Re: accessing a text file

2010-09-08 Thread Baba
On 8 sep, 12:46, Paul Rubin no.em...@nospam.invalid wrote: Baba raoul...@gmail.com writes: It is just unfriendly to tell someone to go and look it up by themselves. Someone seeing too many unthoughtful questions from you might tell you to look it up yourself, in the hopes of getting you to

Re: console-editor written in python

2010-09-08 Thread Colin J. Williams
On 08-Sep-10 04:51 AM, Tanje Toolate wrote: hi there, greetings. i am looking for a small, console-based (opensource) texteditor, written in python (or as shellscript!), but i'm not finding something usable. very find would be emacs-keybindings ... dank u well, tanja What operating

Re: console-editor written in python

2010-09-08 Thread Tanje Toolate
What operating system do you use? Colin W. usually linux. sometimes bsd. tanja -- http://mail.python.org/mailman/listinfo/python-list

Re: console-editor written in python

2010-09-08 Thread Tanje Toolate
What operating system do you use? Colin W. usually linux. sometimes bsd. tanja -- http://mail.python.org/mailman/listinfo/python-list

Why Insulation is a Good Investment

2010-09-08 Thread ......
Why Insulation is a Good Investment Investing in products to make homes more energy efficient pays significant dividends over a lifetime — with none of the wild fluctuations of Wall Street. Insulation contributes to: - Greater comfort - Even temperature distribution - Improved acoustics -

Re: accessing a text file

2010-09-08 Thread Paul Rubin
Baba raoul...@gmail.com writes: But where do you draw the line? Can we not just let people ask questions regardless? And let those answer who want to and those who don't just ignore the question? That seems so much easier to me. The first few times, it's easy to ignore the questions. After a

One Jew RASPUTIN hires another gentile RASPUTIN - to look good in comparison - always, profligate white led by a misleader jew - roman polansky, bernard madoff, moshe katsav, Craigslist Killer Philip

2010-09-08 Thread Ann Thracs
One Jew RASPUTIN hires another gentile RASPUTIN - to look good in comparison - always, profligate white led by a misleader jew - roman polansky, bernard madoff, moshe katsav, Craigslist Killer Philip Markoff jew HP CEO Mark Hurd Resigns After Sexual-Harassment Probe JORDAN ROBERTSON and RACHEL

Re: Speed-up for loops

2010-09-08 Thread Steven D'Aprano
On Tue, 07 Sep 2010 11:00:03 +0100, BartC wrote: for i in xrange(1): a = a + f(i) then unrolling the loop is even less useful. The overhead of the loop itself is likely to be trivial compared to the cost of calling f() 100 million times -- the added complexity to shave 3 seconds

Re: Speed-up for loops

2010-09-08 Thread Alain Ketterlin
Steven D'Aprano st...@remove-this-cybersource.com.au writes: With Python 3 and def f(x): return x+1, unrolling this loop 4x improved speed by 15%; 4.00 minutes reduces to 3.30 minutes. I'm afraid that I can't replicate those figures. In my test, unrolling the loop causes a massive SLOWDOWN

Automatic delegation in Python 3

2010-09-08 Thread Steven D'Aprano
Delegation in old-style classes worked fine: # Python 2.6 class Delegate: ... def __init__(self, x): ... self.__dict__['x'] = x ... def __getattr__(self, name): ... return getattr(self.x, name) ... def __setattr__(self, name, value): ...

Re: The Samurai Principle

2010-09-08 Thread Steven D'Aprano
On Tue, 07 Sep 2010 20:35:45 -0700, Phlip wrote: Exceptions are very dangerous by themselves, because if you don't trap them just right they can cause side-effects. Huh? If you don't trap them just right, the cause a stack trace, which is a side-effect I suppose. But it's an *intended*

Re: The Samurai Principle

2010-09-08 Thread Steven D'Aprano
On Tue, 07 Sep 2010 20:38:14 -0700, Phlip wrote: On Sep 7, 5:51 pm, Terry Reedy tjre...@udel.edu wrote: On 9/7/2010 2:53 PM, Phlip wrote: They are for situations which the caller should care not to handle. Python is simply not designed that way. Exception raising and catching is a common

Re: problem with simple multiprocessing script on OS X

2010-09-08 Thread Aahz
In article e4fd2b01-bfde-4614-a2df-50a8de980...@f6g2000yqa.googlegroups.com, Darren Dale dsdal...@gmail.com wrote: About a year ago, I contributed a patch to h5py which checks to see if h5py is being imported into an active IPython session. If so, then a custom tab completer is loaded to make it

Re: The Samurai Principle

2010-09-08 Thread Grant Edwards
On 2010-09-08, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Tue, 07 Sep 2010 20:35:45 -0700, Phlip wrote: Exceptions are very dangerous by themselves, because if you don't trap them just right they can cause side-effects. Huh? If you don't trap them just right, they cause

Re: console-editor written in python

2010-09-08 Thread Thomas Jollans
On Wednesday 08 September 2010, it occurred to Tanje Toolate to exclaim: hi there, greetings. i am looking for a small, console-based (opensource) texteditor, written in python (or as shellscript!), but i'm not finding something usable. Why? (Also, I can't imagine anyone writing a

Re: accessing a text file

2010-09-08 Thread Grant Edwards
On 2010-09-08, Baba raoul...@gmail.com wrote: Thanks for your feedback. My question is: Who owns this forum? If we all do then we are allowed to post questions that are simple and that could otherwise be answered by doing research. Of course you're allowed to post such questions. And people

Re: The Samurai Principle

2010-09-08 Thread Steven D'Aprano
On Wed, 08 Sep 2010 14:44:12 +, Grant Edwards wrote: On 2010-09-08, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Tue, 07 Sep 2010 20:35:45 -0700, Phlip wrote: Exceptions are very dangerous by themselves, because if you don't trap them just right they can cause

Re: console-editor written in python

2010-09-08 Thread mex
On 8 Sep., 16:49, Thomas Jollans tho...@jollybox.de wrote: On Wednesday 08 September 2010, it occurred to Tanje Toolate to exclaim: hi there, greetings. i am looking for a small, console-based (opensource) texteditor, written in python (or as shellscript!), but i'm not finding

Re: accessing a text file

2010-09-08 Thread Bruno Desthuilliers
Baba a écrit : Dear xyz, Your question can easily be researched online. We suggest you give it a try and to look it up yourself. This will be beneficial both to you and to us. We do encourage to ask questions only when they have been researched first. On usenet - as well as on most technical

listening socket

2010-09-08 Thread cerr
Hi, I'm trying to create a listening socket connection on port 1514. I tried to follow the documentation at: http://docs.python.org/release/2.5.2/lib/socket-example.html and came up with following lines: import socket host = '' # Symbolic name meaning all available interfaces

Re: listening socket

2010-09-08 Thread Benjamin Kaplan
On Wed, Sep 8, 2010 at 12:59 PM, cerr ron.egg...@gmail.com wrote: Hi, I'm trying to create a listening socket connection on port 1514. I tried to follow the documentation at: http://docs.python.org/release/2.5.2/lib/socket-example.html and came up with following lines: import socket host

are there pros or contras, keeping a connection to a (sqlite) database ?

2010-09-08 Thread Stef Mientki
hello, I wrap my database in some class, and on creation of the instance, a connection to the database is created, and will stay connected until the program exists, something like this: self.conn = sqlite3.connect ( self.filename ) Now I wonder if there are pros or contras to keep the

Re: listening socket

2010-09-08 Thread cerr
On Sep 8, 10:06 am, Benjamin Kaplan benjamin.kap...@case.edu wrote: On Wed, Sep 8, 2010 at 12:59 PM, cerr ron.egg...@gmail.com wrote: Hi, I'm trying to create a listening socket connection on port 1514. I tried to follow the documentation at:

Re: mutate dictionary or list

2010-09-08 Thread Paul McGuire
On Sep 7, 7:05 am, Baba raoul...@gmail.com wrote: Hi I am working on an exercise which requires me to write a funtion that will check if a given word can be found in a given dictionary (the hand). def is_valid_word(word, hand, word_list):         Returns True if word is in the word_list

Re: The Samurai Principle

2010-09-08 Thread Grant Edwards
On 2010-09-08, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Wed, 08 Sep 2010 14:44:12 +, Grant Edwards wrote: If you don't trap them just right, they cause a stack trace, Not always. That is the effect of not trapping them at all. However, you can trap them

Re: listening socket

2010-09-08 Thread Grant Edwards
On 2010-09-08, Benjamin Kaplan benjamin.kap...@case.edu wrote: On Wed, Sep 8, 2010 at 12:59 PM, cerr ron.egg...@gmail.com wrote: but that is not working, i'm getting this: import: unable to open X server `' @ error/import.c/ImportImageCommand/ [...] now why would it try to open an x server???

Re: are there pros or contras, keeping a connection to a (sqlite) database ?

2010-09-08 Thread John Nagle
On 9/8/2010 10:09 AM, Stef Mientki wrote: hello, I wrap my database in some class, and on creation of the instance, a connection to the database is created, and will stay connected until the program exists, something like this: self.conn = sqlite3.connect ( self.filename ) Now I

executing script in fork

2010-09-08 Thread cerr
Hi There, I want to trigger another script and having it running forked to my mother process. I googled around and came up with following: commandlist=['./GPSsim.pl',proto,'files/gps.txt'] subprocess.Popen(commandlist) print GPS simulator started This however doesn't seem disconnect

Re: Speed-up for loops

2010-09-08 Thread BartC
Steven D'Aprano st...@remove-this-cybersource.com.au wrote in message news:4c878be5$0$3$c3e8...@news.astraweb.com... On Tue, 07 Sep 2010 11:00:03 +0100, BartC wrote: for i in xrange(1): a = a + f(i) With Python 3 and def f(x): return x+1, unrolling this loop 4x improved speed

Re: another way to sort like l.sort(key=lambda x:(x[0][0], -x[1][0]))

2010-09-08 Thread Terry Reedy
I believe I answered your question a day ago. If it has not reached you yet, try the gmane.org archives. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Slice a list of lists?

2010-09-08 Thread Jonno
I know that I can index into a list of lists like this: a=[[1,2,3],[4,5,6],[7,8,9]] a[0][2]=3 a[2][0]=7 but when I try to use fancy indexing to select the first item in each list I get: a[0][:]=[1,2,3] a[:][0]=[1,2,3] Why is this and is there a way to select [1,4,7]? --

cPickle segfault with nested dicts in threaded env

2010-09-08 Thread Kenneth Dombrowski
Hi all, Before creating an issue @ bugs.python.org I wanted to run the following by everyone We are having a difficult time with what looks like a cPickle issue when given a data structure containing 15 nested dictionaries, but only when threading is involved Environment is FreeBSD 8, Python

Re: Slice a list of lists?

2010-09-08 Thread Andreas Waldenburger
On Wed, 8 Sep 2010 13:55:50 -0500 Jonno jonnojohn...@gmail.com wrote: I know that I can index into a list of lists like this: a=[[1,2,3],[4,5,6],[7,8,9]] a[0][2]=3 a[2][0]=7 but when I try to use fancy indexing to select the first item in each list I get: Let me write out in words what

Re: Slice a list of lists?

2010-09-08 Thread Benjamin Kaplan
On Wed, Sep 8, 2010 at 2:55 PM, Jonno jonnojohn...@gmail.com wrote: I know that I can index into a list of lists like this: a=[[1,2,3],[4,5,6],[7,8,9]] a[0][2]=3 a[2][0]=7 but when I try to use fancy indexing to select the first item in each list I get: a[0][:]=[1,2,3] a[:][0]=[1,2,3]

Re: Slice a list of lists?

2010-09-08 Thread Andreas Waldenburger
Let me rephrase what I wrote a bit. On Wed, 8 Sep 2010 15:08:11 -0400 Andreas Waldenburger use...@geekmail.invalid wrote: a[0][:]=[1,2,3] Here you're making a list of all elements of the first element of a. That is, you're making a copy of the first element of a. a[:][0]=[1,2,3]

Re: Slice a list of lists?

2010-09-08 Thread Andreas Waldenburger
On Wed, 8 Sep 2010 15:11:51 -0400 Benjamin Kaplan benjamin.kap...@case.edu wrote: There is no simple way to get [1,4,7] because it is just a list of lists and not an actual matrix. You have to extract the elements yourself. col = [] for row in a: col.append(row[0]) You can do

Re: [Python-ideas] with statement syntax forces ugly line breaks?

2010-09-08 Thread MRAB
On 08/09/2010 19:07, Georg Brandl wrote: Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou

Re: Automatic delegation in Python 3

2010-09-08 Thread Terry Reedy
On 9/8/2010 9:58 AM, Steven D'Aprano wrote: Delegation in old-style classes worked fine: # Python 2.6 class Delegate: ... def __init__(self, x): ... self.__dict__['x'] = x ... def __getattr__(self, name): ... return getattr(self.x, name) ... def

Re: Slice a list of lists?

2010-09-08 Thread Emile van Sebille
On 9/8/2010 12:17 PM Andreas Waldenburger said... On Wed, 8 Sep 2010 15:11:51 -0400 Benjamin Kaplan benjamin.kap...@case.edu wrote: There is no simple way to get [1,4,7] because it is just a list of lists and not an actual matrix. You have to extract the elements yourself. col = [] for row

Re: cPickle segfault with nested dicts in threaded env

2010-09-08 Thread Thomas Jollans
On Wednesday 08 September 2010, it occurred to Kenneth Dombrowski to exclaim: Environment is FreeBSD 8, Python 2.5.5 Which architecture? Also, Python 2.5 is frightfully old. There's not really any problem with still using it, but nobody's maintaining it upstream, so don't bother reporting a

Re: cPickle segfault with nested dicts in threaded env

2010-09-08 Thread Carl Banks
On Sep 8, 11:58 am, Kenneth Dombrowski kdombrow...@gmail.com wrote: Hi all, Before creating an issue @ bugs.python.org I wanted to run the following by everyone We are having a difficult time with what looks like a cPickle issue when given a data structure containing 15 nested dictionaries,

Re: Slice a list of lists?

2010-09-08 Thread Jonno
On Wed, Sep 8, 2010 at 2:11 PM, Benjamin Kaplan benjamin.kap...@case.edu wrote: On Wed, Sep 8, 2010 at 2:55 PM, Jonno jonnojohn...@gmail.com wrote: I know that I can index into a list of lists like this: a=[[1,2,3],[4,5,6],[7,8,9]] a[0][2]=3 a[2][0]=7 but when I try to use fancy indexing to

Re: what should __iter__ return?

2010-09-08 Thread Terry Reedy
On 9/7/2010 9:40 PM, Gregory Ewing wrote: Thomas Jollans wrote: Hmm. Modifying an object while iterating over it isn't a great idea, ever: I wouldn't say never. How about Modifying a collection while iterating over it without understanding the dangers is a bad idea. Algorithms that

Re: Slice a list of lists?

2010-09-08 Thread Jonno
On Wed, Sep 8, 2010 at 3:06 PM, Jonno jonnojohn...@gmail.com wrote: On Wed, Sep 8, 2010 at 2:11 PM, Benjamin Kaplan benjamin.kap...@case.edu wrote: On Wed, Sep 8, 2010 at 2:55 PM, Jonno jonnojohn...@gmail.com wrote: I know that I can index into a list of lists like this:

Re: Slice a list of lists?

2010-09-08 Thread Jonno
On Wed, Sep 8, 2010 at 3:18 PM, Jonno jonnojohn...@gmail.com wrote: On Wed, Sep 8, 2010 at 3:06 PM, Jonno jonnojohn...@gmail.com wrote: On Wed, Sep 8, 2010 at 2:11 PM, Benjamin Kaplan benjamin.kap...@case.edu wrote: On Wed, Sep 8, 2010 at 2:55 PM, Jonno jonnojohn...@gmail.com wrote: I know

Re: Slice a list of lists?

2010-09-08 Thread Terry Reedy
On 9/8/2010 2:55 PM, Jonno wrote: I know that I can index into a list of lists like this: a=[[1,2,3],[4,5,6],[7,8,9]] a[0][2]=3 a[2][0]=7 but when I try to use fancy indexing to select the first item in each list I get: a[0][:]=[1,2,3] a[:][0]=[1,2,3] Why is this and is there a way to select

Re: Slice a list of lists?

2010-09-08 Thread Benjamin Kaplan
On Wed, Sep 8, 2010 at 4:23 PM, Jonno jonnojohn...@gmail.com wrote: On Wed, Sep 8, 2010 at 3:18 PM, Jonno jonnojohn...@gmail.com wrote: On Wed, Sep 8, 2010 at 3:06 PM, Jonno jonnojohn...@gmail.com wrote: On Wed, Sep 8, 2010 at 2:11 PM, Benjamin Kaplan benjamin.kap...@case.edu wrote: On Wed,

Re: Slice a list of lists?

2010-09-08 Thread Andreas Waldenburger
On Wed, 8 Sep 2010 15:23:35 -0500 Jonno jonnojohn...@gmail.com wrote: On Wed, Sep 8, 2010 at 3:18 PM, Jonno jonnojohn...@gmail.com wrote: [snip] Now if I want to select the first item in every 2nd item of list a (ie: [1,7]) can I use ::2 anywhere or do I need to create a list of indices

Re: Automatic delegation in Python 3

2010-09-08 Thread Thomas Jollans
On Wednesday 08 September 2010, it occurred to Steven D'Aprano to exclaim: What's going on here? I *think* this has something to do with special double-underscore methods being looked up on the class, not the instance, for new-style classes, but I'm not entirely sure. Yes, special methods are

Re: Slice a list of lists?

2010-09-08 Thread Jonno
On Wed, Sep 8, 2010 at 3:44 PM, Andreas Waldenburger use...@geekmail.invalid wrote: On Wed, 8 Sep 2010 15:23:35 -0500 Jonno jonnojohn...@gmail.com wrote: On Wed, Sep 8, 2010 at 3:18 PM, Jonno jonnojohn...@gmail.com wrote: [snip] Now if I want to select the first item in every 2nd item of

Re: accessing a text file

2010-09-08 Thread Baba
On 8 sep, 14:39, Paul Rubin no.em...@nospam.invalid wrote: Baba raoul...@gmail.com writes: But where do you draw the line? Can we not just let people ask questions regardless? And let those answer who want to and those who don't just ignore the question? That seems so much easier to me.

Confused about nested scopes and when names get added to namespaces

2010-09-08 Thread Russell Warren
I'm having trouble understanding when variables are added to namespaces. I thought I understood it, but my nested function examples below have me very confused. In each test function below I have an x variable (so x is in the namespace of each test function). I also have a nested function in

Re: Confused about nested scopes and when names get added to namespaces

2010-09-08 Thread Russell Warren
My tests were run in python 2.6.5. -- http://mail.python.org/mailman/listinfo/python-list

Re: Slice a list of lists?

2010-09-08 Thread Robert Kern
On 9/8/10 3:27 PM, Terry Reedy wrote: On 9/8/2010 2:55 PM, Jonno wrote: I know that I can index into a list of lists like this: a=[[1,2,3],[4,5,6],[7,8,9]] a[0][2]=3 a[2][0]=7 but when I try to use fancy indexing to select the first item in each list I get: a[0][:]=[1,2,3] a[:][0]=[1,2,3] Why

Re: what should __iter__ return?

2010-09-08 Thread Steven D'Aprano
On Wed, 08 Sep 2010 16:17:02 -0400, Terry Reedy wrote: On 9/7/2010 9:40 PM, Gregory Ewing wrote: Thomas Jollans wrote: Hmm. Modifying an object while iterating over it isn't a great idea, ever: I wouldn't say never. How about Modifying a collection while iterating over it without

Re: Automatic delegation in Python 3

2010-09-08 Thread Steven D'Aprano
On Wed, 08 Sep 2010 15:45:46 -0400, Terry Reedy wrote: [...] Unfortunately, I need to use delegation, not inheritance, and I need to use a new-style class, since I will be using Python 3. How can I do automatic delegation in Python 3? Is my only hope to give up on the elegance of automatic

Re: are there pros or contras, keeping a connection to a (sqlite) database ?

2010-09-08 Thread CM
On Sep 8, 1:09 pm, Stef Mientki stef.mien...@gmail.com wrote:  hello, I wrap my database in some class, and on creation of the instance, a connection to the database is created, and will stay connected until the program exists, something like this:     self.conn = sqlite3.connect (

Re: accessing a text file

2010-09-08 Thread Bar Shirtcliff
| Hi Paul | | If i look where i was 4 weeks ago and the progress i made in learning | Python i am quite delighted. This forum has helped me and i appreciate | it. I don't think i will ever tell a beginner to do me a favour and | to look things up by himself nor will i use the RTFM line (refering

Re: Confused about nested scopes and when names get added to namespaces

2010-09-08 Thread Emile van Sebille
On 9/8/2010 2:18 PM Russell Warren said... I'm having trouble understanding when variables are added to namespaces. I thought I understood it, but my nested function examples below have me very confused. Take a look at PEP 227 where nested scopes are introduced.

Re: Confused about nested scopes and when names get added to namespaces

2010-09-08 Thread Aahz
In article d020e332-f2f2-4a82-ae1b-2ae071211...@n3g2000yqb.googlegroups.com, Russell Warren russandheat...@gmail.com wrote: def test4(): print running test4... x = 1 def innerFunc(): print inner locals():, print %s % locals() # how is x in locals in this case??

Re: The Samurai Principle

2010-09-08 Thread Paul Rubin
Grant Edwards inva...@invalid.invalid writes: I find it much easier to screw things up using the exceptional return value method than the exception raise method. That may be partly due to Python's not-so-good facilities for implementing the exceptional return value method. To be fair, plenty

Re: accessing a text file

2010-09-08 Thread Bar Shirtcliff
| HEREow can you be learning so much python if you're constantly expressing typo there. I'm not sure how that happens, sometimes, but it's an untimely abbrev-expansion, in emacs VM. I meant to say, How can you... Cheers, Bar -- http://mail.python.org/mailman/listinfo/python-list

Re: cPickle segfault with nested dicts in threaded env

2010-09-08 Thread Paul Rubin
Carl Banks pavlovevide...@gmail.com writes: Since Python 2.7 is released, Python 2.5 is no longer accepting bug fixes, only security fixes. So be aware. Segfaults should be treated as security holes unless there's convincing reasons that no exploit is possible. So the bug should be reported

Re: Bit fields in python?

2010-09-08 Thread Justin Mayfield
Instead of rewriting your code you might consider wrapping it with the C-API. I prefer this approach (over ctypes) for anything low level. http://docs.python.org/c-api/ On 09/06/2010 10:06 PM, Kwan Lai Cheng wrote: Hi, I'm trying to rewrite a c program in python encountered several

Re: accessing a text file

2010-09-08 Thread MRAB
On 08/09/2010 23:56, Bar Shirtcliff wrote: | HEREow can you be learning so much python if you're constantly expressing typo there. I'm not sure how that happens, sometimes, but it's an untimely abbrev-expansion, in emacs VM. I meant to say, How can you... An unkind soul would say that it's

Re: Class changes in circular imports when __name__ == '__main__'

2010-09-08 Thread Spencer Pearson
All right, thank you for helping! I'd had a little voice in the back of my mind nagging me that it might not be logical to include a bunch of classes and function definitions in my startup file, but I never got around to splitting it up. The module/script distinction makes sense, and it seems more

Re: [Tutor] Arguments from the command line

2010-09-08 Thread Lawrence D'Oliveiro
In message mailman.501.1283789339.29448.python-l...@python.org, Hugo Arts wrote: sys.argv is a list of all arguments from the command line ... Interesting that Python didn’t bother to mimic the underlying POSIX convention of passing the command line as arguments to the mainline routine. I

Re: Queue cleanup

2010-09-08 Thread Lawrence D'Oliveiro
In message 7xeid9gtuq@ruckus.brouhaha.com, Paul Rubin wrote: Lawrence D'Oliveiro l...@geek-central.gen.new_zealand writes: That reinforces my point, about how easy it was to check the correctness of the code. In this case one simple fix, like this ... would render the code watertight.

Re: Queue cleanup

2010-09-08 Thread Paul Rubin
Lawrence D'Oliveiro l...@geek-central.gen.new_zealand writes: In that case, I can similarly discount your attempts to fix up issues with garbage collectors after they’re pointed out, can I not? Adapting GC algorithms to improve their performance or better use the capabilities of new hardware

Re: accessing a text file

2010-09-08 Thread Ben Finney
Baba raoul...@gmail.com writes: Thanks for your feedback. My question is: Who owns this forum? If we all do then we are allowed to post questions that are simple and that could otherwise be answered by doing research. That's a rather subservient perspective. Why are you seeking permission to

Re: accessing a text file

2010-09-08 Thread Ben Finney
Grant Edwards inva...@invalid.invalid writes: I'm sure you'd prefer that everything was handed to you for free on a silver platter with a side order of beer and cookies. I'd prefer I was 20 years younger and 30 pounds lighter. Life's tough that way. Hell no. I'd prefer to have the total of my

Re: accessing a text file

2010-09-08 Thread Grant Edwards
On 2010-09-09, Ben Finney ben+pyt...@benfinney.id.au wrote: Grant Edwards inva...@invalid.invalid writes: I'm sure you'd prefer that everything was handed to you for free on a silver platter with a side order of beer and cookies. I'd prefer I was 20 years younger and 30 pounds lighter. Life's

Re: [Tutor] Arguments from the command line

2010-09-08 Thread Robert Kern
On 9/8/10 7:38 PM, Lawrence D'Oliveiro wrote: In messagemailman.501.1283789339.29448.python-l...@python.org, Hugo Arts wrote: sys.argv is a list of all arguments from the command line ... Interesting that Python didn’t bother to mimic the underlying POSIX convention of passing the command

Re: cPickle segfault with nested dicts in threaded env

2010-09-08 Thread Aahz
In article mailman.583.1283975836.29448.python-l...@python.org, Thomas Jollans tho...@jollybox.de wrote: Also, Python 2.5 is frightfully old. [...] Frightfully??? I'm sure plenty of people are still using Python 2.3 in production environments (certainly my last job did as of 1.5 years ago,

Re: Queue cleanup

2010-09-08 Thread Steven D'Aprano
On Thu, 09 Sep 2010 12:41:20 +1200, Lawrence D'Oliveiro wrote: Part of the problem is C itself. And yet, what are these complicated garbage collectors, that you intend relying on to work correctly with all their layers of tricks upon tricks, written in? C. Not necessarily. Pascal, despite

Re: [Tutor] Arguments from the command line

2010-09-08 Thread Steven D'Aprano
On Thu, 09 Sep 2010 12:38:04 +1200, Lawrence D'Oliveiro wrote: In message mailman.501.1283789339.29448.python-l...@python.org, Hugo Arts wrote: sys.argv is a list of all arguments from the command line ... Interesting that Python didn’t bother to mimic the underlying POSIX convention of

Re: [Tutor] Arguments from the command line

2010-09-08 Thread Lawrence D'Oliveiro
In message mailman.599.1284008342.29448.python-l...@python.org, Dennis Lee Bieber wrote: None of them have command line arguments passed in to some starting point -- all had to use some runtime library function to ask for the command line contents. It’s always a language-specific routine,

[issue9786] Native TLS support for pthreads

2010-09-08 Thread Kristján Valur Jónsson
Kristján Valur Jónsson krist...@ccpgames.com added the comment: Hm, both the test you mention are using the (non-recursive) lock to synchronize threads. I can't see anything wrong there. Could you please try to replace the cod in pthread_getspecific() with this: int err = errno void *result

[issue9796] Add summary tables for unittest API

2010-09-08 Thread Raymond Hettinger
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: Just focus on the table for assert* methods. This is the one category that users will need to look-up over and over again. The goal is to make the docs more usable, not more voluminous. Also, I suggest finding meaningful

[issue6114] distutils build_ext path comparison only based on strings

2010-09-08 Thread Sven Rebhan
Sven Rebhan odinsho...@googlemail.com added the comment: Of course there is a secret distutils comunity using git! ;-) The three ppl mentioned there found and fixed the problem, that's why. But back to the issue: Can we use a switch or wrapper function to change the test method for this path

[issue9632] Remove sys.setfilesystemencoding()

2010-09-08 Thread Marc-Andre Lemburg
Marc-Andre Lemburg m...@egenix.com added the comment: STINNER Victor wrote: STINNER Victor victor.stin...@haypocalc.com added the comment: keep the C function Hum, currently, Python3 only has a *private* function called _Py_SetFileSystemEncoding() which can only be called after

[issue2745] Add support for IsWow64Process

2010-09-08 Thread Pete Bartlett
Pete Bartlett peter.bartl...@nomura.com added the comment: Hi, I am a Python user seeking an implementation of iswow64 and found this tracker. Unfortunately I don't think Martin's suggested alternative approach works. os.environ[PROCESSOR_ARCHITECTURE] returns x86 on my system when run from

[issue3871] cross and native build of python for mingw32 with distutils

2010-09-08 Thread Luke Kenneth Casson Leighton
Luke Kenneth Casson Leighton l...@lkcl.net added the comment: sorry to have to ask, but could we get some feedback please so that this issue may move forward? currently there is a conflict between what is required and what is stated as being absolute law. let's imagine that it is reasonable

[issue4947] sys.stdout fails to use default encoding as advertised

2010-09-08 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: I commited my patch (with a new test, iso-8859-1:replace) to 2.7: r84621. I will no backport to 2.6 because this branch now only accept security fixes. -- resolution: - fixed status: open - closed

[issue9797] wrong assumption in pystate.c

2010-09-08 Thread Antoine Pitrou
New submission from Antoine Pitrou pit...@free.fr: pystate.c assumes that when autoTLSkey is 0, it hasn't been created yet. However, some TLS implementations can return 0 as a valid key value. Lots of interesting things then happen. Here is a patch. -- files: autotlskey.patch

  1   2   >