Re: [Tutor] Arguments from the command line

2010-09-08 Thread Lawrence D'Oliveiro
In message , 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, since at the underlying POSIX level (exposed by

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 , 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

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, de

Re: cPickle segfault with nested dicts in threaded env

2010-09-08 Thread Aahz
In article , Thomas Jollans 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, and I would be mildly surprised if they upgraded by now). -- Aahz (

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 message, 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. There *is

Re: accessing a text file

2010-09-08 Thread Grant Edwards
On 2010-09-09, Ben Finney wrote: > Grant Edwards 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 t

Re: accessing a text file

2010-09-08 Thread Ben Finney
Grant Edwards 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 life experience and

Re: accessing a text file

2010-09-08 Thread Ben Finney
Baba 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 ask questions? W

Re: Queue cleanup

2010-09-08 Thread Paul Rubin
Lawrence D'Oliveiro 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 is much different than saying the

Re: Queue cleanup

2010-09-08 Thread Lawrence D'Oliveiro
In message <7xeid9gtuq@ruckus.brouhaha.com>, Paul Rubin wrote: > Lawrence D'Oliveiro 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. See how easy it is? > > W

Re: [Tutor] Arguments from the command line

2010-09-08 Thread Lawrence D'Oliveiro
In message , 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 always felt it was more useful to have command argume

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: 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'

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 probl

Re: cPickle segfault with nested dicts in threaded env

2010-09-08 Thread Paul Rubin
Carl Banks 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 against 2.5 as well as l

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: The Samurai Principle

2010-09-08 Thread Paul Rubin
Grant Edwards 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 of other language

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

2010-09-08 Thread Aahz
In article , Russell Warren wrote: > >def test4(): >print "running test4..." >x = 1 >def innerFunc(): >print "inner locals():", >print "%s" % locals() # how is x in locals in this case?? >print x >x = 2 #ONLY ADDED LINE TO TEST3 >innerFunc() >

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. http://www.python.org/dev/peps

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: 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 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 ) > > N

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 automa

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

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: 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

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 e

Re: accessing a text file

2010-09-08 Thread Baba
On 8 sep, 14:39, Paul Rubin wrote: > Baba 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

Re: Slice a list of lists?

2010-09-08 Thread Jonno
On Wed, Sep 8, 2010 at 3:44 PM, Andreas Waldenburger wrote: > On Wed, 8 Sep 2010 15:23:35 -0500 Jonno wrote: > >> On Wed, Sep 8, 2010 at 3:18 PM, Jonno 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

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 ar

Re: Slice a list of lists?

2010-09-08 Thread Andreas Waldenburger
On Wed, 8 Sep 2010 15:23:35 -0500 Jonno wrote: > On Wed, Sep 8, 2010 at 3:18 PM, Jonno 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 to use in a more complex for loop? > >

Re: Slice a list of lists?

2010-09-08 Thread Benjamin Kaplan
On Wed, Sep 8, 2010 at 4:23 PM, Jonno wrote: > On Wed, Sep 8, 2010 at 3:18 PM, Jonno wrote: >> On Wed, Sep 8, 2010 at 3:06 PM, Jonno wrote: >>> On Wed, Sep 8, 2010 at 2:11 PM, Benjamin Kaplan >>> wrote: On Wed, Sep 8, 2010 at 2:55 PM, Jonno wrote: > I know that I can index into a list

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 [1

Re: Slice a list of lists?

2010-09-08 Thread Jonno
On Wed, Sep 8, 2010 at 3:18 PM, Jonno wrote: > On Wed, Sep 8, 2010 at 3:06 PM, Jonno wrote: >> On Wed, Sep 8, 2010 at 2:11 PM, Benjamin Kaplan >> wrote: >>> On Wed, Sep 8, 2010 at 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]]

Re: Slice a list of lists?

2010-09-08 Thread Jonno
On Wed, Sep 8, 2010 at 3:06 PM, Jonno wrote: > On Wed, Sep 8, 2010 at 2:11 PM, Benjamin Kaplan > wrote: >> On Wed, Sep 8, 2010 at 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 t

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 c

Re: Slice a list of lists?

2010-09-08 Thread Jonno
On Wed, Sep 8, 2010 at 2:11 PM, Benjamin Kaplan wrote: > On Wed, Sep 8, 2010 at 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 >>

Re: cPickle segfault with nested dicts in threaded env

2010-09-08 Thread Carl Banks
On Sep 8, 11:58 am, Kenneth Dombrowski 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, but > only wh

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 b

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 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[

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 __setattr__(

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 the

Re: Slice a list of lists?

2010-09-08 Thread Andreas Waldenburger
On Wed, 8 Sep 2010 15:11:51 -0400 Benjamin Kaplan 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 this in one line u

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 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] > > > And here you'r

Re: Slice a list of lists?

2010-09-08 Thread Benjamin Kaplan
On Wed, Sep 8, 2010 at 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 a

Re: Slice a list of lists?

2010-09-08 Thread Andreas Waldenburger
On Wed, 8 Sep 2010 13:55:50 -0500 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: Let me write out in words what you're doing, and

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 2.

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]? -- http://mail.python.org/ma

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

Re: Speed-up for loops

2010-09-08 Thread BartC
"Steven D'Aprano" 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 by 15%; 4.00 minutes reduces to 3.

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 stdo

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 wonder

Re: listening socket

2010-09-08 Thread Grant Edwards
On 2010-09-08, Benjamin Kaplan wrote: > On Wed, Sep 8, 2010 at 12:59 PM, cerr 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??? :o > > Because it's not executing it

Re: The Samurai Principle

2010-09-08 Thread Grant Edwards
On 2010-09-08, Steven D'Aprano 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 incorrectly -- which can result in

Re: mutate dictionary or list

2010-09-08 Thread Paul McGuire
On Sep 7, 7:05 am, Baba 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 and is

Re: listening socket

2010-09-08 Thread cerr
On Sep 8, 10:06 am, Benjamin Kaplan wrote: > On Wed, Sep 8, 2010 at 12:59 PM, cerr 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

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 conn

Re: listening socket

2010-09-08 Thread Benjamin Kaplan
On Wed, Sep 8, 2010 at 12:59 PM, cerr 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 = ''        

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 port

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

Re: console-editor written in python

2010-09-08 Thread mex
On 8 Sep., 16:49, Thomas Jollans 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 something > > u

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 > 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

Re: accessing a text file

2010-09-08 Thread Grant Edwards
On 2010-09-08, Baba 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 are allowed to i

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

Re: The Samurai Principle

2010-09-08 Thread Grant Edwards
On 2010-09-08, Steven D'Aprano 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 a stack trace, Not always

Re: problem with simple multiprocessing script on OS X

2010-09-08 Thread Aahz
In article , Darren Dale 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 easier to navigate hdf5 >files. In the development version of IPython, a funct

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 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 flo

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* side

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): ... setattr(

Re: Speed-up for loops

2010-09-08 Thread Alain Ketterlin
Steven D'Aprano 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 of 37%, not a speed up. Here is

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

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 ME

Re: accessing a text file

2010-09-08 Thread Paul Rubin
Baba 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 few more times,

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 - Better

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

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 syste

Re: accessing a text file

2010-09-08 Thread Baba
On 8 sep, 12:46, Paul Rubin wrote: > Baba 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,

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 explanati

Re: Bit fields in python?

2010-09-08 Thread geremy condra
On Tue, Sep 7, 2010 at 9:53 PM, Eli Bendersky 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; >>     unsign

Re: accessing a text file

2010-09-08 Thread Paul Rubin
Baba 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 will be more though

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 Baba
On 8 sep, 02:07, Ben Finney wrote: > Baba 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 the > information being imparted could

Re: mutate dictionary or list

2010-09-08 Thread Baba
On 7 sep, 16:46, Ben Finney 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 you *think* is chang

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: 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') ('

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: The Samurai Principle

2010-09-08 Thread Ian Kelly
On Tue, Sep 7, 2010 at 9:38 PM, Phlip 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 record could be the