On 1/22/2010 9:58 PM, Chris Jones wrote:
On Fri, Jan 22, 2010 at 08:46:35PM EST, Terry Reedy wrote:
Do you mean I should just read the file one character at a time?
Whoops, my misdirection (you can .read(1), but this is s l o w.
I meant to suggest processing it a char at a time.
1. If
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
* 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 keeping my code simple. Once I'm done with an
On Fri, 22 Jan 2010 21:23:37 -0800, Aleksey wrote:
> I write crossplatform program and have next problem under windows
> (under linux is all OK) :
>
> I'm trying to get the UTC modification date of files on the flash
> drive under windows. In the flash card system is FAT.
Timestamps stored on a
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 reasonable implementation, except for its blind spot
>with respect to popping the first element off the list. The
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've departed from the med
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've departed from the median
> heading on the leg. Calculating arit
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 median
> > heading on the leg. Calculatin
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 keeping my code simple. Once I'm done with an
> >
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 the memory for the pointers just
Hi All,
I write crossplatform program and have next problem under windows
(under linux is all OK) :
I'm trying to get the UTC modification date of files on the flash
drive under windows. In the flash card system is FAT. In the winter
time (2010 01 21) Date of modification:
>>> op.getmtime('
oops :)
On Fri, Jan 22, 2010 at 9:41 PM, Steve Holden wrote:
> Dave:
>
> New York classes went well this week, and there appears to be some
> demand for Chicago training. How can we satisfy this demand to our
> common profit?
>
> regards
> Steve
>
> David Beazley 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 keeping my code simple. Once I'm done with an
> element, I do just want to pop it off and keep all
In article ,
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 like an
> > easy way to make
On Fri, Jan 22, 2010 at 08:46:35PM EST, Terry Reedy wrote:
> On 1/22/2010 4:47 PM, Chris Jones wrote:
>> I was writing a script that counts occurrences of characters in source code
>> files:
>>
>> #!/usr/bin/python
>> import codecs
>> tcounters = {}
>> f = codecs.open('/home/gavron/git/screen/src/
Dave:
New York classes went well this week, and there appears to be some
demand for Chicago training. How can we satisfy this demand to our
common profit?
regards
Steve
David Beazley wrote:
> Mastering Python 3 I/O
>** PyCON'2010 Tutorial Preview in Chicago **
Stefan Behnel wrote:
> For those who are a bit less fluent in French:
>
[...]
... and, while having access to e-mail, have not yet come across
translate.google.com?
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org
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 the memory for the pointers just as long, but you also
> prevent the objects themse
On Jan 22, 3:23 pm, "Mr.M" wrote:
> Hi,
>
> i can't understand what i'm doing wrong. I have a c/api that implements
> a new class.
> In (initproc) function i have somethink like this:
>
> [code]
>
> (some declarations omitted here)
You probably shouldn't have, that could be where the error is
On 1/22/10 5:47 PM, G73 wrote:
im trying to update a patch. here is link to various patches
http://bugs.python.org/issue6075
how do i update the patch, say for EditorWindow.patch.
i have located my python installation the EditorWindow.py, and i can
see some differences (which lines from the patc
On 1/22/2010 4:47 PM, Chris Jones wrote:
I was writing a script that counts occurrences of characters in source code
files:
#!/usr/bin/python
import codecs
tcounters = {}
f = codecs.open('/home/gavron/git/screen/src/screen.c', 'r', "utf-8")
for uline in f:
lline = []
for char in uline[:-1
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 median
heading on the leg. Calculating arithmetic medians is
straightforward, but comp
On 2010-01-22 18:09 PM, 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 median
heading on the leg. Calculating arithmetic medians is
s
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
On Fri, Jan 22, 2010 at 5:27 PM, Steve Howell wrote:
> I actually do expect Python to solve performance problems for me that
> are more easily solved in core than in Python itself. So I guess
> that's where we differ.
>
You might be interested in the extension type I wrote (the "blist") that
lo
In article <497af344-31b5-4d1a-9b1a-c3d82feb3...@j5g2000yqm.googlegroups.com>,
Raymond Hettinger wrote:
>
>The performance of an IndexableSkiplist is similar to a B+tree but the
>implementation in pure python is much simpler.
Nice! Can you summarize why IndexableSkipList is simpler?
--
Aahz (a
On Fri, Jan 22, 2010 at 05:07:13PM EST, Arnaud Delobelle wrote:
[..]
> import codecs
> from collections import defaultdict
>
> tcounters = defaultdict(int)
> f = codecs.open('/home/gavron/git/screen/src/screen.c', 'r', "utf-8")
>
> for c in f.read():
> tcounters[c] += 1
>
> for c, n in tco
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 bother to even
> > mention it
Hi,
i can't understand what i'm doing wrong. I have a c/api that implements
a new class.
In (initproc) function i have somethink like this:
[code]
(some declarations omitted here)
static char* keywordlist[] = {"service",
"event_type",
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 shifting all the elements. It would create some
> >>> nuan
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 bother to even
> mention it in the tutorial?
How else are you going to teach new P
Arnaud Delobelle wrote:
Steve Howell writes:
On Jan 22, 12:14 pm, Chris Rebert wrote:
I made the comment you quoted. In CPython, it is O(n) to delete/insert
an element at the start of the list - I know it because I looked at the
implementation a while ago. This is why collections.
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 create some
> > nuances with r
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 shifting all the elements. It would create some
nuances with respect to reclaiming the memory, but it seems like
im trying to update a patch. here is link to various patches
http://bugs.python.org/issue6075
how do i update the patch, say for EditorWindow.patch.
i have located my python installation the EditorWindow.py, and i can
see some differences (which lines from the patch actually go into the
EditorWind
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 just
> > quibbling over
Chris Jones writes:
> I was writing a script that counts occurrences of characters in source
> code files:
>
> #!/usr/bin/python
> import codecs
> tcounters = {}
> f = codecs.open('/home/gavron/git/screen/src/screen.c', 'r', "utf-8")
> for uline in f:
> lline = []
> for char in uline[:-1]:
>
On Jan 21, 9:21 am, Dave Angel wrote:
> Put it inside a dummy class, as follows:
This has been very educational, thank you for all the suggestions.
Here is the resulting code:
class Property: pass # example of a dummy class
Plist = Property() # create a Plist object from the dummy class
# accu
In article <80c56956-f28e-47a3-a723-3a5e3fd29...@j19g2000yqk.googlegroups.com>,
sjdevn...@yahoo.com wrote:
>On Jan 2, 9:35=A0pm, Dave Angel wrote:
>>
>> In Windows, there is a way to do it. It's just not exposed to the
>> Python built-in function open(). You use the CreateFile() function,
>> wit
I was writing a script that counts occurrences of characters in source code
files:
#!/usr/bin/python
import codecs
tcounters = {}
f = codecs.open('/home/gavron/git/screen/src/screen.c', 'r', "utf-8")
for uline in f:
lline = []
for char in uline[:-1]:
lline += [char]
counters = {}
for
On 1/22/2010 2:29 PM, 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.
What is it that allows one to write A.x? If I have a variable A,
You do not really have a 'variable'. You have a name A bound to a
On 22Jan2010 13:19, Mike Driscoll wrote:
| On Jan 22, 3:16 am, George Oliver wrote:
| > hi, I'm wondering if there are any Python programming environments
| > that enable live code reloading, for example something like the Scheme-
| > based impromptu (but also meant for any kind of Python program
Op donderdag 21 januari 2010 schreef Michele:
> I need a small utility to count the lines of Python code in a
> directory, traversing subdirectories and ignoring comments and
> docstrings.
sloccount can do this.
http://www.dwheeler.com/sloccount/
Met vriendelijke groet,
Wilbert Berendsen
--
h
Arnaud Delobelle wrote:
> I made the comment you quoted. In CPython, it is O(n) to delete/insert
> an element at the start of the list - I know it because I looked at the
> implementation a while ago. This is why collections.deque exists I
> guess. I don't know how they are implemented but inser
On Jan 21, 11:54 am, 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 calculations.
>
> One Python program would be collecting data from boat instruments on a
> serial
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 create some
nuances with respect to reclaiming the memory, but it seems like an
e
Robert Kern wrote:
> On 2010-01-21 15:31 , Phlip wrote:
>> Aahz wrote:
>>> In article
>>> <7e09df6a-cda1-480e-a971-8f8a70ac4...@b9g2000yqd.googlegroups.com>,
>>> Phlip wrote:
On Jan 20, 11:20=A0pm, Michele Simionato
wrote:
> pylint does too many things, I want something fast that ju
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:
>
> >> > '''
> >> > It is also possible to use a list as a queue, where
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 just
> quibbling over the meaning of "rarely."
I was speaking from my own po
On 1/22/2010 12:57 PM, ben wrote:
On Jan 20, 8:30 pm, Gringo wrote:
I am following through the python tutorial which gets to a line that
uses the * operator with zip().
All such questions are at least briefly answered in
my complete python3 symbol glossary (all syntax usages) at
http://code
On Jan 21, 10:54 am, 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 calculations.
>
> One Python program would be collecting data from boat instruments on a
> serial
On Jan 22, 3:16 am, George Oliver wrote:
> hi, I'm wondering if there are any Python programming environments
> that enable live code reloading, for example something like the Scheme-
> based impromptu (but also meant for any kind of Python program, not
> just audio/visual generation).
>
> Current
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:
>>
>> > '''
>> > It is also possible to use a list as a queue, where the first element
>> > added is the first element retr
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 like an
> > easy way t
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 like an
> easy way to make lists perform better under a pretty reasonable us
On 1/22/2010 7:17 AM, Gilles Ganault wrote:
Hello
I use a dictionary to keep a list of users connected to a web site.
To avoid users from creating login names that start with digits in
order to be listed at the top, I'd like to sort the list differently
every minute so that it'll start with the
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 first element retrieved (“first-in, first-out”);
Martin Drautzburg wrote:
>> with scope():
>> # ...
>> # use up, down, left, right here
>>
>> # up, down, left, right no longer defined after the with block exits.
Just looked it up again. It's a cool thing. Too bad my locals() hack
would still be required. The result would be less noisy
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 first element retrieved (“first-in, first-out”); however,
> lists are not efficient for this purpose.
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
This has probably been asekd a million times, but if someone could give
a short answer anyways I's be most grateful.
What is it that allows one to write A.x? If I have a variable A, then
what to I have to assign to it to A.x becomes valid?
Or even further: what do I have to do so I can write A.x=
Hi,
I need to create a python subprogress, like this:
myProcess = subprocess.Popen([sys.executable, 'C:\myscript.py'],
env=env, stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
sys.executable was printed out as ''C:\\Pyth
Mark Dickinson wrote:
> On Jan 21, 10:57 pm, Martin Drautzburg
> wrote:
>> Here is a complete expample using a decorator, still a bit noisy
>>
>> def move(aDirection):
>> print "moving " + aDirection
>>
>> #Here comes the decorator
>> def scope(aDict):
>> def save(locals):
>> [...]
>
> Have you
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
On Jan 22, 6:13 am, Muhammad Alkarouri wrote:
> In the python help for itertools, the following function is provided:
>
> def consume(iterator, n):
> "Advance the iterator n-steps ahead. If n is none, consume
> entirely."
> collections.deque(islice(iterator, n), maxlen=0)
>
> What is the a
On Jan 21, 9:00 pm, Michele Simionato
wrote:
> Just for fun I have run cloc on our trunk:
>
> SUM: 8743 272238 215871 1470139 x 1.84 =
> 2708354.95
Nice!
My favorite version of a cloc system can distinguish test from
production code. That's why I always use executable c
Steven D'Aprano wrote:
On Fri, 22 Jan 2010 09:49:32 -0500, Dave Angel wrote:
Seems to me the other solutions I've seen so far are more complex than
needed. I figure you either want an unordered list, in which case you
could use random.shuffle(), or you want a list that's sorted, but starts
On Jan 20, 8:30 pm, Gringo wrote:
> On 1/20/2010 12:38, ben wrote:
>
>
>
> > Hello,
>
> > I am following through the python tutorial which gets to a line that
> > uses the * operator with zip(). I searched and searched but could find
> > no information on the operator or how to use it in general.
On Fri, 22 Jan 2010 17:21:02 +0100, Jean-Michel Pichavant
wrote:
>Ok I realized that picking up a random index prevent from grouping names
>starting with the same letter (to ease visual lookup).
>Then go for the random char, and use char comparison (my first example).
Yup, I think it's a good en
On 22 Jan 2010 15:24:58 GMT, Duncan Booth
wrote:
>Here's another:
Thanks for the sample. It work great, except that it also runs when
the header character doesn't match any item in the list:
===
import bisect
connected = []
connected.append("_test")
connected.append("-test")
connected.appen
a...@pythoncraft.com (Aahz) wrote:
> In article ,
> Duncan Booth wrote:
>>
>>That seems overkill. This does pretty much the same thing:
>>
>> @(C:\Python26\Python -x %~f0 %* || pause) && goto:EOF
>> import sys
>> print sys.version
>> # raise RuntimeError # uncomme
Gilles Ganault wrote:
On Fri, 22 Jan 2010 09:49:32 -0500, Dave Angel wrote:
Seems to me the other solutions I've seen so far are more complex than
needed. I figure you either want an unordered list, in which case you
could use random.shuffle(), or you want a list that's sorted, but starts
On 2010-01-22, Steven D'Aprano wrote:
>> O(N*Log N) + O(N) == O(N**2)?
>
> Oops! :(
>
> Of course, the sort is in fast C, and the linear search is in
> relatively slow Python, so it is quite conceivable that for
> realistic amounts of data, the time could be dominated by the
> searching.
>
> Or t
On Thu, 21 Jan 2010 11:25:08 +0100, Tomas Pelka wrote:
> have a problem with following piece of code:
>
> --
> import subprocess
>
> paattern = "python"
> cmd = "/usr/bin/locate"
> arg1 = " -i"
> arg2 = " -d /var/www/books/mlocate.db"
> arg3 = str(
On Fri, 22 Jan 2010 15:57:07 +, Neil Cerutti wrote:
> On 2010-01-22, Steven D'Aprano
> wrote:
>> Unless you can predict what index to use for (say) names starting with
>> "B", then your scheme doesn't work. In order to find that index, you
>> have to do a linear search of the list after every
Jean-Michel Pichavant wrote:
Gilles Ganault wrote:
On Fri, 22 Jan 2010 14:09:43 +0100, Jean-Michel Pichavant
wrote:
Sorry, the code I provided produce this output:
['1a', 'a', 'ac', 'av', 'b', 'c']
['a', 'ac', 'av', 'b', 'c', '1a']
['b', 'c', '1a', 'a', 'ac', 'av']
['c', '1a', 'a', 'ac', 'a
On Fri, 22 Jan 2010 09:49:32 -0500, Dave Angel wrote:
> Seems to me the other solutions I've seen so far are more complex than
> needed. I figure you either want an unordered list, in which case you
> could use random.shuffle(), or you want a list that's sorted, but starts
> somewhere in the midd
* Aahz:
In article ,
Duncan Booth wrote:
That seems overkill. This does pretty much the same thing:
@(C:\Python26\Python -x %~f0 %* || pause) && goto:EOF
import sys
print sys.version
# raise RuntimeError # uncomment to trigger the 'pause'
What version of Wi
In article ,
Duncan Booth wrote:
>
>That seems overkill. This does pretty much the same thing:
>
> @(C:\Python26\Python -x %~f0 %* || pause) && goto:EOF
> import sys
> print sys.version
> # raise RuntimeError # uncomment to trigger the 'pause'
What version of Windows is
Gilles Ganault wrote:
On Fri, 22 Jan 2010 14:09:43 +0100, Jean-Michel Pichavant
wrote:
Sorry, the code I provided produce this output:
['1a', 'a', 'ac', 'av', 'b', 'c']
['a', 'ac', 'av', 'b', 'c', '1a']
['b', 'c', '1a', 'a', 'ac', 'av']
['c', '1a', 'a', 'ac', 'av', 'b']
['1a', 'a', 'ac', 'a
On 2010-01-22, Steven D'Aprano wrote:
> On Fri, 22 Jan 2010 13:35:26 +, Neil Cerutti wrote:
>> On 2010-01-22, Gilles Ganault wrote:
>>> Hello
>>>
>>> I use a dictionary to keep a list of users connected to a web site.
>>>
>>> To avoid users from creating login names that start with digits in
In article ,
MRAB wrote:
>D'Arcy J.M. Cain wrote:
>> On Thu, 14 Jan 2010 07:52:58 -0800 (PST)
>> chandra wrote:
>>> Folks,
>>>
>>> I am new to Python and could not find a function along the lines of
>>
>> Welcome.
>>
>>> string.ishex in Python. There is however, a string.hexdigits constant
>>> i
On Fri, 22 Jan 2010 13:35:26 +, Neil Cerutti wrote:
> On 2010-01-22, Gilles Ganault wrote:
>> Hello
>>
>> I use a dictionary to keep a list of users connected to a web site.
>>
>> To avoid users from creating login names that start with digits in
>> order to be listed at the top, I'd like to
PS.
22-01-2010 o 15:44:28 Jan Kaliszewski wrote:
22-01-2010, 14:58:58 Gilles Ganault wrote:
On 22 Jan 2010 13:35:26 GMT, Neil Cerutti wrote:
Resorting is more work than is needed. Just choose a different
starting index each time you display the names, and set up your
lister to wrap-around
In the python help for itertools, the following function is provided:
def consume(iterator, n):
"Advance the iterator n-steps ahead. If n is none, consume
entirely."
collections.deque(islice(iterator, n), maxlen=0)
What is the advantage of using a collections.deque against, say, the
foll
Jean-Michel Pichavant wrote:
> Here is one possible solution
>
> l = ['1a', 'a', 'b','c','av','ac'] # you mentioned a dictionary in your
> post, if so, l = myDict.keys()
> l.sort() # sort your list once and for all
> for start in '1abcd':
> result = [name for name in l if name[0] >= start]
Muhammad Alkarouri writes:
> In the python help for itertools, the following function is provided:
>
> def consume(iterator, n):
> "Advance the iterator n-steps ahead. If n is none, consume
> entirely."
> collections.deque(islice(iterator, n), maxlen=0)
>
> What is the advantage of using
Gilles Ganault writes:
> On Fri, 22 Jan 2010 09:49:32 -0500, Dave Angel wrote:
>>Seems to me the other solutions I've seen so far are more complex than
>>needed. I figure you either want an unordered list, in which case you
>>could use random.shuffle(), or you want a list that's sorted, but s
Muhammad Alkarouri writes:
> In the python help for itertools, the following function is provided:
>
> def consume(iterator, n):
> "Advance the iterator n-steps ahead. If n is none, consume
> entirely."
> collections.deque(islice(iterator, n), maxlen=0)
>
> What is the advantage of using
On Fri, 22 Jan 2010 09:49:32 -0500, Dave Angel wrote:
>Seems to me the other solutions I've seen so far are more complex than
>needed. I figure you either want an unordered list, in which case you
>could use random.shuffle(), or you want a list that's sorted, but starts
>somewhere in the middl
Gilles Ganault wrote:
Hello
I use a dictionary to keep a list of users connected to a web site.
To avoid users from creating login names that start with digits in
order to be listed at the top, I'd like to sort the list differently
every minute so that it'll start with the next letter, eg. disp
22-01-2010 Steven D'Aprano wrote:
On Fri, 22 Jan 2010 13:17:44 +0100, Gilles Ganault wrote:
To avoid users from creating login names that start with digits in order
to be listed at the top, I'd like to sort the list differently every
minute so that it'll start with the next letter, eg. displ
* Wolfgang Rohdewald:
On Friday 22 January 2010, Alf P. Steinbach wrote:
I get the impression that there's some message traffic that I don't
see
For example, the recent thread "Covert number into string" started
with a reply in my newreader, using EternalSeptember's NNTP host.
It also start
On Fri, 22 Jan 2010 14:09:43 +0100, Jean-Michel Pichavant
wrote:
>Sorry, the code I provided produce this output:
>
>['1a', 'a', 'ac', 'av', 'b', 'c']
>['a', 'ac', 'av', 'b', 'c', '1a']
>['b', 'c', '1a', 'a', 'ac', 'av']
>['c', '1a', 'a', 'ac', 'av', 'b']
>['1a', 'a', 'ac', 'av', 'b', 'c']
>
>whic
On Jan 22, 1:58 pm, Gilles Ganault wrote:
> On 22 Jan 2010 13:35:26 GMT, Neil Cerutti wrote:
>
> >Resorting is more work than is needed. Just choose a different
> >starting index each time you display the names, and set up your
> >lister to wrap-around to your arbitrary starting index.
>
> Thanks
* Steven D'Aprano:
One implementation-specific trick is that modifying locals does actually
work inside a class definition (at least in Python 2.5):
class Foo(object):
... x = 1
... print locals()
... locals()['x'] = 2
...
{'x': 1, '__module__': '__main__'}
Foo.x
2
But it doe
In the python help for itertools, the following function is provided:
def consume(iterator, n):
"Advance the iterator n-steps ahead. If n is none, consume
entirely."
collections.deque(islice(iterator, n), maxlen=0)
What is the advantage of using a collections.deque against, say, the
follo
On 22 Jan 2010 13:35:26 GMT, Neil Cerutti wrote:
>Resorting is more work than is needed. Just choose a different
>starting index each time you display the names, and set up your
>lister to wrap-around to your arbitrary starting index.
Thanks. In this case, it means that in each loop iteration, I
On 2010-01-22, Gilles Ganault wrote:
> Hello
>
> I use a dictionary to keep a list of users connected to a web
> site.
>
> To avoid users from creating login names that start with digits
> in order to be listed at the top, I'd like to sort the list
> differently every minute so that it'll start wi
On Friday 22 January 2010, Alf P. Steinbach wrote:
> I get the impression that there's some message traffic that I don't
> see
> For example, the recent thread "Covert number into string" started
> with a reply in my newreader, using EternalSeptember's NNTP host.
>
> It also starts with a reply
1 - 100 of 131 matches
Mail list logo