Re: itertools.groupby

2007-05-27 Thread Steve Howell
--- Raymond Hettinger <[EMAIL PROTECTED]> wrote: > > FWIW, I wrote those docs. Suggested improvements > are > welcome; however, I think they already meet a > somewhat > high standard of quality: > I respectfully disagree, and I have suggested improvements in this thread. Without even reading

Re: Newbie question - better way to do this?

2007-05-28 Thread Steve Howell
--- Nis Jørgensen <[EMAIL PROTECTED]> wrote: > Steve Howell skrev: > > > def firstIsCapitalized(word): > > return 'A' <= word[0] <= 'Z' > > For someone who is worried about the impact of > non-ascii identifiers, > you are makin

Re: itertools.groupby

2007-05-28 Thread Steve Howell
--- Raymond Hettinger <[EMAIL PROTECTED]> wrote: > + The operation of \function{groupby()} is similar > to the \code{uniq} > filter > + in \UNIX{}. [...] Thanks! The comparison of groupby() to "uniq" really clicks with me. To the extent that others like the Unix command line analogy for u

Re: itertools.groupby

2007-05-28 Thread Steve Howell
--- Paul Rubin <"http://phr.cx"@NOSPAM.invalid> wrote: > [...] > Here's yet another example that came up in something > I was working on: > you are indexing a book and you want to print a list > of page numbers > for pages that refer to George Washington. If > Washington occurs on > several conse

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-28 Thread Steve Howell
--- Roy Smith <[EMAIL PROTECTED]> wrote: > It's certainly easier to parse ip_address as > compared to IPAddress. > Same with snmp_manager vs SNMPManager. > Somebody earlier was actually advocating something called proper_case, in which you can capitalize certain letters for clarity, like test

Re: Newbie question - better way to do this?

2007-05-28 Thread Steve Howell
--- Nis Jørgensen <[EMAIL PROTECTED]> wrote: > > I disagree that word.istitle is the correct idiom - > from the naming of > the function in the original example, I would guess > "word[0].isupper" > would do the trick. > That would return something like this: You want to add parens: wor

Re: ten small Python programs

2007-05-28 Thread Steve Howell
--- Stef Mientki <[EMAIL PROTECTED]> wrote: > Steve Howell wrote: > > I've always thought that the best way to introduce > new > > programmers to Python is to show them small code > > examples. > > > This is really a nice piece of missing Python.

Re: itertools.groupby

2007-05-28 Thread Steve Howell
--- Carsten Haese <[EMAIL PROTECTED]> wrote: > On Sun, 2007-05-27 at 18:12 -0700, Steve Howell > wrote: > > [...] there is no way > > that "uniquekeys" is a sensible variable [...] > > That's because the OP didn't heed the advice from > the

Re: itertools.groupby

2007-05-28 Thread Steve Howell
--- Raymond Hettinger <[EMAIL PROTECTED]> wrote: > That's not for everyone, so it isn't a loss if > someone sticks > with writing plain, clear everyday Python instead of > an itertool. > I know most of the module is fairly advanced, and that average users can mostly avoid it, but this is a very

Re: ten small Python programs

2007-05-28 Thread Steve Howell
--- Stef Mientki <[EMAIL PROTECTED]> wrote: > > > >> It would even be nicer, if everybody could drop > >> her/his examples > >> in a standard way, so they would be automatically > >> incorporated in > >> something like the wxPython interactive demo. > >> > > > > Can you elaborate? > > Well if y

Re: ten small Python programs

2007-05-28 Thread Steve Howell
--- Stef Mientki <[EMAIL PROTECTED]> > > > I don't know MoinMoin, > but the answer is Yes (although maybe not for your > ten snippets). > First of all I think all programmers keep there own > collection of code snippets, > which much more valuable then "all the code code > snippets from everyone"

Re: itertools.groupby

2007-05-28 Thread Steve Howell
--- Paul Rubin <"http://phr.cx"@NOSPAM.invalid> wrote: > > > But that is what groupby does, except its notion of > uniqueness is > limited to contiguous runs of elements having the > same key. It occurred to me that we could also rename the function uniq(), or unique(), after its Unix counterpa

Re: itertools.groupby

2007-05-28 Thread Steve Howell
--- Raymond Hettinger <[EMAIL PROTECTED]> wrote: > > > That's not for everyone, so it isn't a loss if > > > someone sticks > > > with writing plain, clear everyday Python > instead of > > > an itertool. > > > > I know most of the module is fairly advanced, and > that > > average users can mostly

Re: itertools.groupby

2007-05-28 Thread Steve Howell
--- Alex Martelli <[EMAIL PROTECTED]> wrote: > Steve Howell <[EMAIL PROTECTED]> wrote: >... > > for has_chars, frags in itertools.groupby(lines, > > lambda x: len(x) > 0): > > Hmmm, it appears to me that itertools.groupby(lines, > bool) should do

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-29 Thread Steve Howell
--- Carsten Haese <[EMAIL PROTECTED]> wrote: > On Sun, 2007-05-27 at 07:30 +, OKB (not > okblacke) wrote: > > Underscores are harder to type than any > alphanumeric character. > > This is a discussion about underscores versus > capital letters denoting > the word boundaries in

Re: Periodic tasks.

2007-05-29 Thread Steve Howell
--- Ramashish Baranwal <[EMAIL PROTECTED]> wrote: > Hi, > > I am trying to execute some tasks periodically, > those familiar with > unix can think of it as equivalent to cron jobs. I > have tried looking > around, but couldn't find a way. Would appreciate > any pointers or > clues.. > I'm also

Re: Periodic tasks.

2007-05-29 Thread Steve Howell
--- vasudevram <[EMAIL PROTECTED]> wrote: > On May 29, 4:39 pm, Steve Holden > <[EMAIL PROTECTED]> wrote: > > > Alternatively, the user could make use of the > already-existing "sched" > > module from the standard library. With a little > threading that would do > > the job fine. > > Yes. Also,

Re: itertools.groupby

2007-05-29 Thread Steve Howell
--- Carsten Haese <[EMAIL PROTECTED]> wrote: > As an aside, while groupby() will indeed often be > used in conjunction > with sorted(), there is a significant class of use > cases where that's > not the case: I use groupby to produce grouped > reports from the results > of an SQL query. In such ca

Re: SMTPAuthenticationError

2007-05-29 Thread Steve Howell
--- Ramashish Baranwal <[EMAIL PROTECTED]> wrote: > > Are you sure that your SMTP server uses this type > of authentication? > > Some SMTP servers use POP3 followed by SMTP to > authenticate instead. > > > > use telnet to verify, this link might help. > > > > > http://www.computerperformance.co.

Re: itertools.groupby

2007-05-29 Thread Steve Howell
On May 29, 2:34 am, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > The gauntlet has been thrown down. Any creative > thinkers > up to the challenge? Give me cool recipes. > I don't make any claims to coolness, but I can say that I myself would have written the code below with significantly more

Re: itertools.groupby (gauntlet thrown down)

2007-05-29 Thread Steve Howell
> Raymond Hettinger <[EMAIL PROTECTED]> writes: > > The gauntlet has been thrown down. Any creative > thinkers > > up to the challenge? Give me cool recipes. > Twin primes? (Sorry, no code, but there's a good Python example somewhere that returns an iterator that keeps doing the sieve, feed it

Re: Examples of high-quality python code?

2007-05-30 Thread Steve Howell
--- kaens <[EMAIL PROTECTED]> wrote: > > Anyhow, I'm looking to expand my understanding of > python, and I feel > that one of the best ways to do that is looking at > other peoples code. > A lot of the built-in Python modules are implemented in pure Python. If you are using any of those so far

a Python person's experience with Ruby

2007-12-07 Thread Steve Howell
Python is my favorite programming language. I've used it as my primary language for about six years now, including four years of using it full-time in my day job. Three months ago I decided to take a position with a team that does a lot of things very well, but they don't use Python. We use Ruby

Re: "Python" is not a good name, should rename to "Athon"

2007-12-08 Thread Steve Howell
--- Jan Claeys <[EMAIL PROTECTED]> wrote: > Op Mon, 03 Dec 2007 14:20:52 +1300, schreef greg: > > > If you want a really appropriate name for a > programming language, I'd > > suggest Babbage. (not for Python, though!) > > Konrad Zuse wrote the first high-level programming > language, so I thin

Re: a Python person's experience with Ruby

2007-12-08 Thread Steve Howell
--- Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Colin J. Williams a écrit : > > I'm not sure that I like add 3, 5, 7 > > > > but it would be nice to be able to drop the > parentheses > > when no argument is required. > > > > Thus: close; > > could replace close(); > > This just cou

Re: Newbie edit/compile/run cycle question

2007-12-08 Thread Steve Howell
--- [EMAIL PROTECTED] wrote: > > What don't I know that I should know to just > edit/run, preferably at > the tap of a function key? Most good editors let you do these things: 1) Save a file. 2) Run a script from the shell. 3) Turn steps 1 and 2 into a macro. 4) Allow you to map th

Re: Newbie edit/compile/run cycle question

2007-12-08 Thread Steve Howell
--- Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] a écrit : > > I'm a java guy used to the effective edit/run > cycle you get with a > > good IDE. > > > > Today I'm writing my first Python, but can't seem > to find the way to > > use Python's inherent edit/run cycle. > > >

Re: Ruby's Template Engine for Python

2007-12-08 Thread Steve Howell
--- Samuel <[EMAIL PROTECTED]> wrote: > Hi, > > Following the masses I was drawn to RoR's website > today and I saw the > following HTML template in one of the screencasts: > I know a lot of Rails goodies have been ported to Python, so you might want to google some variations on "form_remote_

Re: a Python person's experience with Ruby

2007-12-08 Thread Steve Howell
--- Bruno Desthuilliers > > > Another aspect of Ruby is that the final > expression > > evaluated in a method actually gets returned as > the > > result of a method, > > Unless there's an explict return before... > > > which has further implications on > > whether "close" is simply evaluated or

Re: a Python person's experience with Ruby

2007-12-08 Thread Steve Howell
--- Richard Jones <[EMAIL PROTECTED]> wrote: > > class A(object): > def set_a(self, value): > self._a = value > a = property(lambda self: self._a, set_a) > > Note that this differs from a regular attribute > because "a" is not deletable > from instances (the property defines no d

Re: auto-increment operator - why no syntax error?

2007-12-08 Thread Steve Howell
--- Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Sat, 08 Dec 2007 16:58:25 -0800, Karthik Gurusamy > wrote: > > > Why are the following accepted even without a > warning about syntax > > error? > > (I would expect the python grammar should catch > these kind of syntax > > errors) > >

Re: Newbie edit/compile/run cycle question

2007-12-08 Thread Steve Howell
--- Jeremy C B Nicoll <[EMAIL PROTECTED]> wrote: > Steve Howell <[EMAIL PROTECTED]> wrote: > > > There are a zillion powerful editors out there. > I've > > been productive in EditPlus, MultiEdit, SlickEdit, > > vim, and emacs, just to throw out a

Re: Advice for editing xml file using ElementTree and wxPython

2007-12-08 Thread Steve Howell
--- Rick Muller <[EMAIL PROTECTED]> wrote: > If I want to do this, it seems like I need to keep a > connection > between the gui element and the original value in > the elementtree, so > I can update it. But I'm having a hard time > visualizing exactly how > this works. Can someone help me out he

Re: Newbie edit/compile/run cycle question

2007-12-08 Thread Steve Howell
--- Jeremy C B Nicoll <[EMAIL PROTECTED]> wrote: > Steve Howell <[EMAIL PROTECTED]> wrote: > > > > > --- Jeremy C B Nicoll <[EMAIL PROTECTED]> > wrote: > > > > What command (in XP) does one need to issue to > > > syntax check a sa

Re: Serializing Python compiled code.

2007-12-09 Thread Steve Howell
--- [EMAIL PROTECTED] wrote: > In a C++ application having a Python interpreter > embedded, is it > possible to compile a small Python snippet into > object code and > serialize the compiled object code to, for example, > a database? I am > exploring the possibility of writing a data driven > appl

Re: reading list of list to a file

2007-12-09 Thread Steve Howell
--- caroliina <[EMAIL PROTECTED]> wrote: > > i made a list of lists but i cant write it into a > file. how do i get the > first string in a sublist? > -- Try doing this: print list_of_lists print list_of_lists[0] print list_of_lists[0][0] print list_of_lists[0][0][0] It might give you some i

Re: a Python person's experience with Ruby

2007-12-09 Thread Steve Howell
After starting this discussion thread, I found the link below: http://www.b-list.org/weblog/2006/jun/18/lets-talk-about-python-and-ruby/ If you're like me--struggling to learn Ruby while having Python as your primary point of reference--you might find some of the points informative. I suspect vi

Re: a Python person's experience with Ruby

2007-12-09 Thread Steve Howell
--- MonkeeSage <[EMAIL PROTECTED]> wrote: > > Not just callable, but interchangeable. My point was > that in ruby, if > you use a block or a lambda as a HOF, you have to > use #call / #[] / > yield keyword on it to call it. > > def foo(a) > puts a > end > bar = lambda { | a | puts a } > > # t

Re: a strange SyntaxError

2007-12-09 Thread Steve Howell
--- CoolGenie <[EMAIL PROTECTED]> wrote: > self.feed = self.config['feedsrc'] > self.numfeeds = self.config['numfeeds'] > self.numlines = self.config['numlines'] > > self.w = 520 > self.h = 12*self.numfeeds*(self.numlines+1) > adesklets.

Re: a strange SyntaxError

2007-12-09 Thread Steve Howell
--- CoolGenie <[EMAIL PROTECTED]> wrote: > OK, sorry, this was about indents. Stupid VIM! No prob. Add something like this (untested) to your ~/.vimrc: set expandtab set sw=4 set ts=4 Looking for

Re: a strange SyntaxError

2007-12-09 Thread Steve Howell
--- CoolGenie <[EMAIL PROTECTED]> wrote: > OK, sorry, this was about indents. Stupid VIM! One more piece of VIM advice. You can use "set list" to show where tabs are. I prefer to convert my own tabs to spaces automatically, but you inevitably come across code that you don't own where it's nice

Re: a Python person's experience with Ruby

2007-12-09 Thread Steve Howell
--- Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Steve Howell a écrit : > (snip) > > > > Jordan and others, thanks for all your posts; I am > > learning a lot about both languages. > > > > This is what I've gathered so far. > > >

Re: a Python person's experience with Ruby

2007-12-09 Thread Steve Howell
--- MonkeeSage <[EMAIL PROTECTED]> wrote: > On Dec 9, 6:23 pm, MonkeeSage <[EMAIL PROTECTED]> > wrote: > > Hi Bruno, > > > > I think that we've been having a mainly "semantic" > (pun intended) > > dispute. I think you're right, that we've been > using the same words > > with different meanings. >

Re: Distinguishing attributes and methods

2007-12-09 Thread Steve Howell
--- Jan Claeys <[EMAIL PROTECTED]> wrote: > > To conclude this discussion: > > * in Python, methods are attributes > * in Ruby, attributes are methods > So clearly one of the languages has it all wrong. ;) ___

Re: Inter-process communication, how?

2007-12-15 Thread Steve Howell
--- [EMAIL PROTECTED] wrote: > TCP/IP sounds good but isn't it a bit too heavy? It depends on your judgment, of course. On a simplistic level, using TCP/IP shouldn't be any more work than what you'd do if you were reading and writing files, especially if everything you're doing is on the same bo

Re: Self function

2009-05-03 Thread Steve Howell
On May 3, 5:21 pm, Emile van Sebille wrote: > On 5/3/2009 3:39 PM bearophileh...@lycos.com said... > > > > > Sometimes I rename recursive functions, or I duplicate&modify them, > > and they stop working because inside them there's one or more copy of > > their old name. > > This happens to me more

Re: Self function

2009-05-04 Thread Steve Howell
On May 3, 3:39 pm, bearophileh...@lycos.com wrote: > Sometimes I rename recursive functions, or I duplicate&modify them, > and they stop working because inside them there's one or more copy of > their old name. > This happens to me more than one time every year. > So I have written this: > > from i

Re: Self function

2009-05-05 Thread Steve Howell
On May 4, 11:08 pm, Steven D'Aprano wrote: > > I propose a small piece of sugar. When a function is entered, Python > creates an ordinary local name in the function's local namespace, and > binds the function itself to that name. Two possibilities for the name > are `this` or `__this__`, analogous

Re: help with recursive whitespace filter in

2009-05-10 Thread Steve Howell
On May 10, 9:10 am, Rustom Mody wrote: > I am trying to write a recursive filter to remove whitespace-only > nodes for minidom. > The code is below. > > Strangely it deletes some whitespace nodes and leaves some. > If I keep calling it -- like so: fws(fws(fws(doc)))  then at some > stage all the w

Re: help with recursive whitespace filter in

2009-05-10 Thread Steve Howell
On May 10, 10:23 am, rustom wrote: > On May 10, 9:49 pm, Steve Howell wrote: > > > > > On May 10, 9:10 am, Rustom Mody wrote: > > > > I am trying to write a recursive filter to remove whitespace-only > > > nodes for minidom. > > > The code is bel

Re: dict would be very slow for big data

2009-05-11 Thread Steve Howell
On May 11, 8:28 pm, forrest yang wrote: > hi > i am trying to insert a lot of data into a dict, which may be > 10,000,000 level. > after inserting 10 unit, the insert rate become very slow, 50,000/ > s, and the entire time used for this task would be very long,also. > would anyone know some so

Re: piping input to an external script

2009-05-11 Thread Steve Howell
On May 11, 11:04 am, "Tim Arnold" wrote: > Hi, I have some html files that I want to validate by using an external > script 'validate'. The html files need a doctype header attached before > validation. The files are in utf8 encoding. My code: > --- > import os,sys > import codecs,subp

Re: piping input to an external script

2009-05-11 Thread Steve Howell
On May 11, 10:16 pm, norseman wrote: > Tim Arnold wrote: > > Hi, I have some html files that I want to validate by using an external > > script 'validate'. The html files need a doctype header attached before > > validation. The files are in utf8 encoding. My code: > > --- > > import o

Re: piping input to an external script

2009-05-11 Thread Steve Howell
On May 11, 11:31 pm, norseman wrote: > Steve Howell wrote: > > On May 11, 10:16 pm, norseman wrote: > >> Tim Arnold wrote: > >>> Hi, I have some html files that I want to validate by using an external > >>> script 'validate'. The html files ne

Re: piping input to an external script

2009-05-12 Thread Steve Howell
See suggested debugging tip inline of your program On May 11, 11:04 am, "Tim Arnold" wrote: > Hi, I have some html files that I want to validate by using an external > script 'validate'. The html files need a doctype header attached before > validation. The files are in utf8 encoding. My code

Re: Call Web Service using proxy and http authentication

2009-05-12 Thread Steve Howell
On May 12, 8:59 am, wdveloper wrote: > Hi everyone, > > I am trying to call a webservice which requires an http > authentication. > To reach the ws, I must pass from a proxy http. So in the whole I need > go through two authentications before getting the ws working. I am > using SOAPpy and I'm get

Re: Call Web Service using proxy and http authentication

2009-05-13 Thread Steve Howell
On May 12, 12:51 pm, wdveloper wrote: > On May 12, 8:38 pm, Steve Howell wrote: > > > > > On May 12, 8:59 am, wdveloper wrote: > > > > Hi everyone, > > > > I am trying to call a webservice which requires an http > > > authentication. > >

Re: UDP reading on multiple sockets

2009-05-19 Thread Steve Howell
On May 18, 6:19 am, thomas.vo...@likeabird.de wrote: > On 17 Mai, 04:22, Grant Edwards wrote: > > > On 2009-05-17, Thomas Vogel wrote: > > > > I'm currently have the problem that I try to read UDP messages from > > > multiple sockets in parallel. So let's say I get UDP packets from the > > > same

a 100-line indentation-based preprocessor for HTML

2009-11-27 Thread Steve Howell
Python has this really neat idea called indentation-based syntax, and there are folks that have caught on to this idea in the HTML community. AFAIK the most popular indentation-based solution for generating HTML is a tool called HAML, which actually is written in Ruby. I have been poking around w

Re: a 100-line indentation-based preprocessor for HTML

2009-11-27 Thread Steve Howell
On Nov 27, 9:56 pm, "David Williams" wrote: > You might want to take a look at this: > > http://www.ghrml.org/ > Yep, it's not clear how actively they are maintaining that. The fact that it seems to target Genshi only might be limiting their audience, which is unfortunate. -- http://mail.pytho

Re: slightly OT: Python BootCamp

2009-11-29 Thread Steve Howell
On Nov 28, 6:15 pm, J wrote: > Ok... so I've been re-teaching myself python, as it's been several > years since I last really used it.  And in the midst of this, my > contracting company came up to me on Friday and asked if I'd be > interested in filling a last minute vacancy in this: > > http://w

Re: Creating a local variable scope.

2009-11-29 Thread Steve Howell
On Nov 29, 4:26 pm, markolopa wrote: > Less than 3 hours have passed since my last post and got yet another > bug that could be prevented if Python had the functionality that other > languages have to destroy variables when a block ends. Here is the > code: > > = > > arg_columns = [] > for

Re: Trying to understand += better

2009-11-30 Thread Steve Howell
On Nov 22, 8:38 pm, Roy Smith wrote: > In article <4b0a01a...@dnews.tpgi.com.au>, Lie Ryan > wrote: > > > The semantic of the in-place operator is something like: > > x += y > > becomes > > x = x.__iadd__(y) > > > thus > > foo.bar += baz > > becomes > > foo.bar = foo.bar.__iadd__(baz) > > > So th

Re: a 100-line indentation-based preprocessor for HTML

2009-11-30 Thread Steve Howell
On Nov 28, 4:46 am, "Colin W." wrote: > On 27-Nov-09 22:04 PM, Steve Howell wrote: > > > > > Python has this really neat idea called indentation-based syntax, and > > there are folks that have caught on to this idea in the HTML > > community. > &

twenty years ago Guido created Python

2009-12-31 Thread Steve Howell
FYI: http://twitter.com/gvanrossum Python is a truly awesome programming language. Not only is Guido a genius language designer, but he is also a great project leader. What an accomplishment. Congratulations to everybody who has contributed to Python in the last two decades! -- http://mail.p

Re: twenty years ago Guido created Python

2010-01-01 Thread Steve Howell
On Jan 1, 9:03 am, MRAB wrote: > J Peyret wrote: > > On Dec 31 2009, 2:06 pm, Steve Howell wrote: > >> FYI: > > >>http://twitter.com/gvanrossum > > >> Python is a truly awesome programming language.  Not only is Guido a > >> genius language des

ANN: shpaml 0.94b

2010-01-18 Thread Steve Howell
Hi everybody, I would like to announce the latest version of shpaml, which is an indentation-based markup language similar to haml, but different. Shpaml allows you to author HTML-like content with an indentation- based syntax that eliminates the need to write and read close tags and angle bracket

Re: Python decorator syntax limitations

2010-01-18 Thread Steve Howell
On Jan 18, 8:44 am, Jonathan S wrote: > Hi all, > The following is what I want to do, but this results in a syntax > error: > > @news_page('template.html').lookup(News, 'news_id', 'news') > def view(request, group, news): >     pass > > What does work is the equivalent old way of doing decorating:

inner methods and recursion

2010-01-18 Thread Steve Howell
Hi, I have a style/design question relating to recursion and inner methods. I wrote some code recently that implements a recursive algorithm that takes several parameters from the original caller. Once the algorithm starts running and recursing, those parameters remain the same, so I define an in

Re: inner methods and recursion

2010-01-18 Thread Steve Howell
On Jan 18, 6:07 pm, "Gabriel Genellina" wrote: > En Mon, 18 Jan 2010 19:00:17 -0300, Steve Howell   > escribió: > > > Hi, I have a style/design question relating to recursion and inner > > methods. > > > I wrote some code recently that implements a re

simple pub/sub

2010-01-21 Thread Steve Howell
Hi, I'm looking for ideas on building a simple architecture that allows a bunch of independent Python processes to exchange data using files and perform calculations. One Python program would be collecting data from boat instruments on a serial port, then writing that info out to a file, and also

Re: simple pub/sub

2010-01-21 Thread Steve Howell
On Jan 21, 9:03 am, Adam Tauno Williams wrote: > On Thu, 2010-01-21 at 08:54 -0800, Steve Howell wrote: > > Hi, I'm looking for ideas on building a simple architecture that > > allows a bunch of independent Python processes to exchange data using > > files and perform ca

Re: simple pub/sub

2010-01-21 Thread Steve Howell
On Jan 21, 9:37 am, a...@pythoncraft.com (Aahz) wrote: > In article > <0af0eff2-50e2-44aa-81f1-b3d12cb26...@a15g2000yqm.googlegroups.com>, > Steve Howell   wrote: > > > > >Hi, I'm looking for ideas on building a simple architecture that > >allows a

list.pop(0) vs. collections.dequeue

2010-01-22 Thread Steve Howell
The v2.6.4 version of the tutorial says this: ''' It is also possible to use a list as a queue, where the first element added is the first element retrieved (“first-in, first-out”); however, lists are not efficient for this purpose. While appends and pops from the end of list are fast, doing inser

Re: A.x vs. A["x"]

2010-01-22 Thread Steve Howell
On Jan 22, 11:29 am, Martin Drautzburg wrote: > This has probably been asekd a million times, but if someone could give > a short answer anyways I's be most grateful. Not sure there is exactly a short answer, and I am only qualified to maybe clarify some of the things you can and cannot do, not e

Re: list.pop(0) vs. collections.dequeue

2010-01-22 Thread Steve Howell
On Jan 22, 12:14 pm, Chris Rebert wrote: > On Fri, Jan 22, 2010 at 11:14 AM, Steve Howell wrote: > > The v2.6.4 version of the tutorial says this: > > > ''' > > It is also possible to use a list as a queue, where the first element > > added is the

Re: list.pop(0) vs. collections.dequeue

2010-01-22 Thread Steve Howell
On Jan 22, 12:40 pm, Christian Heimes wrote: > Steve Howell wrote: > > Is that really true in CPython?  It seems like you could advance the > > pointer instead of shifting all the elements.  It would create some > > nuances with respect to reclaiming the memory, but it seems

Re: list.pop(0) vs. collections.dequeue

2010-01-22 Thread Steve Howell
On Jan 22, 1:08 pm, Arnaud Delobelle wrote: > Steve Howell writes: > > On Jan 22, 12:14 pm, Chris Rebert wrote: > >> On Fri, Jan 22, 2010 at 11:14 AM, Steve Howell wrote: > >> > The v2.6.4 version of the tutorial says this: > > >> > '

Re: list.pop(0) vs. collections.dequeue

2010-01-22 Thread Steve Howell
On Jan 22, 1:29 pm, Christian Heimes wrote: > Steve Howell wrote: > > I disagree that Python code rarely pops elements off the top of a > > list.  There are perfectly valid use cases for wanting a list over a > > dequeue without having to pay O(N) for pop(0).  Maybe we are ju

Re: list.pop(0) vs. collections.dequeue

2010-01-22 Thread Steve Howell
On Jan 22, 1:32 pm, Terry Reedy wrote: > On 1/22/2010 2:14 PM, Steve Howell wrote: > > > The v2.6.4 version of the tutorial says this: > > Is that really true in CPython?  It seems like you could advance the > > pointer instead of shifting all the elements.  It would crea

Re: list.pop(0) vs. collections.dequeue

2010-01-22 Thread Steve Howell
On Jan 22, 2:54 pm, Dave Angel wrote: > Steve Howell wrote: > > On Jan 22, 12:40 pm, Christian Heimes wrote: > > >> Steve Howell wrote: > > >>> Is that really true in CPython?  It seems like you could advance the > >>> pointer instead of

Re: list.pop(0) vs. collections.dequeue

2010-01-22 Thread Steve Howell
On Jan 22, 3:17 pm, Christian Heimes wrote: > Steve Howell wrote: > > That maybe would be an argument for just striking the paragraph from > > the tutorial.  If it's rare that people pop the head off the list in > > code that is performance critical or prominent, why bot

medians for degree measurements

2010-01-22 Thread Steve Howell
I just saw the thread for medians, and it reminded me of a problem that I need to solve. We are writing some Python software for sailing, and we need to detect when we've departed from the median heading on the leg. Calculating arithmetic medians is straightforward, but compass bearings add a twi

Re: list.pop(0) vs. collections.dequeue

2010-01-22 Thread Steve Howell
On Jan 22, 6:20 pm, Steven D'Aprano wrote: > On Fri, 22 Jan 2010 14:38:18 -0800, Steve Howell wrote: > > I know the Python programmer could simply iterate through the list > > rather than popping off unused elements, but that just means that you > > not only tie up t

Re: list.pop(0) vs. collections.dequeue

2010-01-22 Thread Steve Howell
On Jan 22, 7:09 pm, Roy Smith wrote: > In article > <3ac173bd-4124-434d-b726-0b9baaeec...@36g2000yqu.googlegroups.com>, >  Steve Howell wrote: > > > In my case I'm not really concerned about giving the memory back right > > away, it's more about keepin

Re: medians for degree measurements

2010-01-22 Thread Steve Howell
On Jan 22, 5:12 pm, MRAB wrote: > Steve Howell wrote: > > I just saw the thread for medians, and it reminded me of a problem > > that I need to solve.  We are writing some Python software for > > sailing, and we need to detect when we've departed from the med

Re: medians for degree measurements

2010-01-22 Thread Steve Howell
On Jan 22, 10:29 pm, Nobody wrote: > On Fri, 22 Jan 2010 16:09:03 -0800, Steve Howell wrote: > > I just saw the thread for medians, and it reminded me of a problem > > that I need to solve.  We are writing some Python software for > > sailing, and we need to detect when we

Re: list.pop(0) vs. collections.dequeue

2010-01-22 Thread Steve Howell
On Jan 22, 11:10 pm, a...@pythoncraft.com (Aahz) wrote: > > >I know Python's number one concern will never be speed, but if Python > >makes an O(1) operation into an unnecessarily O(N) operation for no > >good reasons other than "it's too complicated, " or it "adds another > >pointer to the structu

Re: list.pop(0) vs. collections.dequeue

2010-01-23 Thread Steve Howell
On Jan 22, 11:10 pm, a...@pythoncraft.com (Aahz) wrote: > In article <83082e19-9130-45a8-91f2-8601c1fda...@22g2000yqr.googlegroups.com>, > Steve Howell   wrote: > > > > > > >I really want to use list *normally* with all its perfectly good > >semantics and re

Re: list.pop(0) vs. collections.dequeue

2010-01-23 Thread Steve Howell
On Jan 23, 12:13 am, Terry Reedy wrote: > > Challenge yes, mock no. > > Part of writing good basic data structures is not adding needless > complication from featuritis and not penalizing 99.99% of access to > satify a .01% need better satisfied another way. > I would like to challenge your asser

Re: list.pop(0) vs. collections.dequeue

2010-01-23 Thread Steve Howell
On Jan 23, 12:32 am, "Alf P. Steinbach" wrote: > * Steve Howell: > > > On Jan 23, 12:13 am, Terry Reedy wrote: > >> Challenge yes, mock no. > > >> Part of writing good basic data structures is not adding needless > >> complication fr

Re: list.pop(0) vs. collections.dequeue

2010-01-23 Thread Steve Howell
On Jan 23, 12:13 am, Terry Reedy wrote: > On 1/23/2010 12:58 AM, Steve Howell wrote: > > > I really want to use list *normally* with all its perfectly good > > semantics and reasonable implementation, except for its blind spot > > with respect to popping the first element

Re: list.pop(0) vs. collections.dequeue

2010-01-23 Thread Steve Howell
On Jan 23, 1:24 am, Terry Reedy wrote: > On 1/23/2010 3:23 AM, Steve Howell wrote: > > > On Jan 23, 12:13 am, Terry Reedy  wrote: > > >> Challenge yes, mock no. > > >> Part of writing good basic data structures is not adding needless > >> complication

Re: list.pop(0) vs. collections.dequeue

2010-01-23 Thread Steve Howell
On Jan 23, 5:46 am, Christian Heimes wrote: > Steve Howell wrote: > > Another benchmark is that deques are slower than lists for accessing > > elements. > > deques are optimized for accessing, inserting and removing data from > both ends. For anything else it's slower

Re: list.pop(0) vs. collections.dequeue

2010-01-23 Thread Steve Howell
On Jan 23, 6:40 am, Roy Smith wrote: > In article > , >  Steve Howell wrote: > > > This innocent program here literally moves about a million bytes of > > memory around for no good reason: > > >     lst = [] > >     for i in range(2000): >

Re: list.pop(0) vs. collections.dequeue

2010-01-23 Thread Steve Howell
On Jan 23, 4:12 am, Steven D'Aprano wrote: > > > An alternative would be to do exactly what you want lists to do: track > the start of the list. Untested: > >     def recurse(prefix_lines): >         start = 0 >         end = len(prefix_lines) >         while start < end: >             prefix, lin

Re: list.pop(0) vs. collections.dequeue

2010-01-23 Thread Steve Howell
On Jan 23, 4:12 am, Steven D'Aprano wrote: > On Fri, 22 Jan 2010 21:42:43 -0800, Steve Howell wrote: > > This innocent program here literally moves about a million bytes of > > memory around for no good reason: > > >     lst = [] > >     for i in ra

Re: list.pop(0) vs. collections.dequeue

2010-01-23 Thread Steve Howell
On Jan 23, 7:54 am, Steven D'Aprano wrote: > On Sat, 23 Jan 2010 09:57:04 -0500, Roy Smith wrote: > > In article , > >  "Alf P. Steinbach" wrote: > > >> But it would IMHO have been better if it wasn't called "list", which > >> brings in the wrong associations for someone used to other languages.

Re: list.pop(0) vs. collections.dequeue

2010-01-24 Thread Steve Howell
On Jan 23, 8:00 pm, Raymond Hettinger wrote: > [Steve Howell] > > > Why wouldn't you get a competent C programmer simply make > > list_ass_slice smart enough to make list.pop(0) O(1)? > > When this suggestion was discussed on python-dev years ago, > it was reje

Re: list.pop(0) vs. collections.dequeue

2010-01-24 Thread Steve Howell
On Jan 24, 3:20 am, Steven D'Aprano wrote: > On Sun, 24 Jan 2010 02:33:36 -0800, Steve Howell wrote: > > You are also a brilliant computer scientist, despite the fact that you > > are defending a list implemenation that can't pop the first element off > > the list

<    1   2   3   4   5   >