Jordan Rastrick wrote:
Wow, if I'm going to get replies (with implemented solutions!) this
quickly, I'll post here more often :-)
That is indeed typical of this most attentive group :-)
Its taken me a while to get a rough understanding of this code, but I
think I have some idea.
It is just an exam
Scott David Daniels wrote:
Michael Spencer wrote:
itertools.groupby enables you to do this, you just need to define a
suitable grouping function, that stores its state:
Michael, this would make a great Python Cookbook Recipe.
OK, will do. What would you call it? Something like: "Sta
Sean McIlroy wrote:
Fair enough. Here's the verbose version:
##
from time import sleep,time,localtime
wakeuptime = (7,00)
## I WANT TO BE WOKEN UP AT 7AM (FOR EXAMPLE)
onehourlater = (wakeuptime[0]+1, wakeuptime[1])
## ONE HOUR
Ron_Adam wrote:
Is there a way to hide global names from a function or class?
I want to be sure that a function doesn't use any global variables by
mistake. So hiding them would force a name error in the case that I
omit an initialization step. This might be a good way to quickly
catch some hard
James Stroud wrote:
Hello,
I have strings represented as a combination of an alphabet (AGCT) and a an
operator "/", that signifies degeneracy. I want to split these strings into
lists of lists, where the degeneracies are members of the same list and
non-degenerates are members of single item lis
Brian van den Broek wrote:
Much nicer than mine. =| :-)
^
|
(hats off)
Cool ascii art (but thanks for the translation)!
Michael
--
http://mail.python.org/mailman/listinfo/python-list
Bill Mill wrote:
for very long genomes he might want a generator:
def xgen(s):
l = len(s) - 1
e = enumerate(s)
for i,c in e:
if i < l and s[i+1] == '/':
e.next()
i2, c2 = e.next()
yield [c, c2]
else:
yield [c]
for g in xge
[EMAIL PROTECTED] wrote:
What if I want to call other methods as well? Modifying your example a
bit, I'd like the reset() method call of Child to invoke both the
Mother and Father reset() methods, without referencing them by name,
i.e., Mother.reset(self).
---
class Mother(object):
Jack Diederich wrote:
On Sun, Mar 27, 2005 at 02:20:33PM -0700, Steven Bethard wrote:
Michele Simionato wrote:
I am surprised nobody suggested we put those two methods into a
separate module (say dictutils or even UserDict) as functions:
from dictutils import tally, listappend
tally(mydict, key)
Bill Mill wrote:
> [long genomes might justify a generator approach]
That's a good point. I should have said: *If* you are going to put the items
into a list anyway, then there is no point generating the list items individually.
Michael Spencer wrote:
>>[Bill's solution didn&
Steven Bethard wrote:
Ville Vainio wrote:
"Raymond" == Raymond Hettinger <[EMAIL PROTECTED]> writes:
Raymond> If the experience works out, then all you're left with is
Raymond> the trivial matter of convincing Guido that function
Raymond> attributes are a sure cure for the burden of ty
Steven Bethard wrote:
Michael Spencer wrote:
> While we're on the topic, what do you think of having unary,
> non-summary builtins automatically map themselves when called with an
> iterable that would otherwise be an illegal argument:
I personally don't much like the idea be
MackS wrote:
I'm new to Python. In general I manage to understand what is happening
when things go wrong. However, the small program I am writing now fails
with the following message:
In general you are more likely to get helpful responses from this group if you
post the actual code that has the p
Grant Edwards wrote:
On 2005-03-31, Cesar Andres Roldan Garcia <[EMAIL PROTECTED]> wrote:
How can I control an ALU from a PC using Python?
The ALU is buried pretty deep in the CPU. The ALU is part of
what is actually executing the instructions that _are_ Python.
Maybe:
>>> from __builtin__ impo
Ben wrote:
This is an exercise from the Non-programmers tutorial for Python
by Josh Cogliati.
The exercise is:
Write a program that has a user guess your name, but they only get 3
chances to do so until the program quits.
Here is my script:
--
count = 0
name = raw_input("Gue
chirayuk wrote:
Hi,
I am trying to treat an environment variable as a python list - and I'm
sure there must be a standard and simple way to do so. I know that the
interpreter itself must use it (to process $PATH / %PATH%, etc) but I
am not able to find a simple function to do so.
os.environ['PATH']
chirayuk wrote:
However, I just realized that the following is also a valid PATH in
windows.
PATH=c:\A"\B;C"\D;c:\program files\xyz"
(The quotes do not need to cover the entire path)
Too bad! What a crazy format!
So here is my handcrafted solution.
def WinPathList_to_PyList (pathList):
pIter
Georg Brandl wrote:
Hello,
in follow-up to the recent "dictionary accumulator" thread, I wrote a
little module with several subclassed dicts.
Comments (e.g. makes it sense to use super), corrections, etc.? Is this
PEP material?
Docstrings, Documentation and test cases are to be provided later.
mfg
Georg Brandl wrote:
I think I like Jeff's approach more (defaultvalues are just special
cases of default factories); there aren't many "hoops" required.
Apart from that, the names just get longer ;)
Yes Jeff's approach does simplify the implementation and more-or-less eliminates
my complexity obje
Brendan wrote:
Hi everyone
I'm new to Python, so forgive me if the solution to my question should
have been obvious.
...
Good question. For a thorough explanation see:
http://www.python.org/dev/doc/devel/ref/naming.html
Simple version follows:
OK, here's my problem: How do I best store and cha
[EMAIL PROTECTED] wrote:
Hi, folks,
First, the obligatory cheerleading -- then, my questions...
I love Python! I am only an occasional programmer. Still, the logic
of the language is clear enough that I can retain pretty much all that
I have learned from one infrequent programming session to the
Steven Bethard wrote:
Michael Spencer wrote:
def __deepcopy__(self, memo={}):
from copy import deepcopy
result = self.__class__()
memo[id(self)] = result
result.__init__(deepcopy(tuple(self), memo))
return result
I know this is not your recipe, but is
David Handy wrote:
I had a program fail on me today because the following didn't work as I
expected:
class C:
... def f(self):
... pass
...
c = C()
m = c.f
m is c.f
False
I would have expected that if I set a variable equal to a bound method, that
variable, for all intents and purposes
David Handy wrote:
I had a program fail on me today because the following didn't work as I
expected:
class C:
... def f(self):
... pass
...
c = C()
m = c.f
m is c.f
False
I would have expected that if I set a variable equal to a bound method, that
variable, for all intents and purposes
[EMAIL PROTECTED] wrote:
...
I see Steve Bethard has answered most of the points in your last eMail
On line 11 we create a
dictionary item in memo, [id(self):type(self)]...So now I'm confused as
to the purpose of memo. Why should it contain the ID of the *original*
object?
No, you create memo[id(s
Steve Holden wrote:
Not at all - we just apply the same division techniques to the buffer
space until we can map the pieces of cake one-to-one onto the buffers.
That technique can be applied to layer cakes, but not all real cakes.
Michael
--
http://mail.python.org/mailman/listinfo/python-list
Terry Reedy wrote:
"Chris Fonnesbeck" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
However, on Windows (have tried on Mac, Linux) I get the following
behaviour:
inf = 1e1
inf
1.0
while I would have expected:
1.#INF
On my Windows machine with 2.2.1, I get exactly what you ex
there for 2.3.4 (May 25 2004, 21:17:02). This is not
necessarily a bug in the sense of a fixable bug; floating point has
vagaries that are not necessarily easily controllable from the C source
side.
While this may be true, it's pretty strange that Michael Spencer reports
apparently correct re
Scott David Daniels wrote:
Steve Holden wrote:
Scott David Daniels wrote:
Terry Reedy wrote:
On my Windows machine with 2.2.1, I get exactly what you expected:
1e1
1.#INF
...
If you get wrong behavior on a later version, then a bug has been
introduced somewhere, even perhaps in VC 7, used for
Scott David Daniels wrote:
Scott David Daniels wrote:
Bengt Richter wrote:
Aha! Same version (2.3.4):
Idle:
>>> 1e1
1.0
>>> import struct; struct.pack('d', 1e1)
'\x00\x00\x00\x00\x00\x00\xf0?'
(which is actually 1.0)
python via command line (readline support):
>>> 1e1
Michael Spencer wrote:
Problem is associated with executing iteractive input in a subprocess.
>python idle.py -n
IDLE 1.1 No Subprocess
>>> 1e1
1.#INF
>>>
Michael
It seems that the culprit is pickle - used to send messages between the IDLE
shell and
OK - I think this is it:
My last post fingering pickle was almost but not quite right*. Actually the
cuplrit is marshal, which produces the incorrect result that was noted. The bug
has nothing to do with IDLE, except that it uses marshal for inter-process
communication.
Here's the failure cas
George Sakkis wrote:
I'm not sure if it was clear to you, but my problem is the dummy
WorldModel_v1.MovableObject class. It doesn't do anything by itself,
but it has to be in the inheritance chain to make its descendants work
properly.
George,
since you explicit allowed metaprogramming hacks :-),
praba kar wrote:
Dear All
In Php we can find in_array() function
which function is mainly useful to check
whether a specific value is exist in the array
or not.
But In python In cannot find any function
like that. I want to check a list have specific
value or not. So If any one know regard
George Sakkis wrote:
Nice try, but ideally all boilerplate classes would rather be avoided
(at least being written explicitly).
It depends on how much magic you are prepared to accept; this goal is somewhat
in conflict with the next one...
Also, it is not obvious in your
solution why and which p
Tim Tyler wrote:
Like C, Python seems to insist I declare functions before calling
them - rather than, say, scanning to the end of the current script
when it can't immediately find what function I'm referring to.
C lets you predeclare functions to allow for the existence of
functions with circular
George Sakkis wrote:
Have you considered a 'macro' solution composing source?
Can you elaborate on this a little ? You mean something like a
template-based code generating script that creates all the boilerplate
code for each version before you start customising it ?
I was thinking more along the
Steven Bethard wrote:
> It looks like you want to create a new _instance_ of the same type as an
_instance_ passed in to a function. If this is correct, you can do this
by:
...
If you need to support old-style classes, replace type(obj) with
obj.__class__.
You can use obj.__class__ for both ol
Fredrik Lundh wrote:
Tiziano Bettio wrote:
could someone please tell me that this thread wasn't a aprilsfoll day
joke and it is for real...
i'm pretty much able to go down to a single bit but what would be the
reverse algorithm as stated by martin...
magic?
I suggest running my script on a couple
Marcus Goldfish wrote:
I'd like advice/opinions on when it is appropriate to do
Just an opinion...
attribute/property validation in python. I'm coming from a C#/Java
background, where of course tons of "wasted" code is devoted to
property validation. Here is a toy example illustrating my question
Marcus Goldfish wrote:
So what do you consider when making this decision
Python style tends away from validating what doesn't need to be validated. The
argument seems to be that the additional validating code comes at the price of
legibility, and perhaps flexibility.
It's common in Python to us
AdSR wrote:
Fellow Pythonistas,
Please check out
http://spyced.blogspot.com/2005/04/how-well-do-you-know-python-part-3.html
if you haven't done so yet. It appears that you can specify a function
explicitly to take n-tuples as arguments. It actually works, checked
this myself. If you read the refere
Steve Holden wrote:
I've been wondering whether it's possible to perform a similar analysis
on non-mapping-type format strings, so as to know how long a tuple to
provide, or whether I'd be forced to lexical analysis of the form string.
regards
Steve
I do not know if it is possible to do that.
B
Skip Montanaro wrote:
steve> I propose that an additional a URL be set up for the Python HTML
steve> documentation. This URL will always contain the current version
steve> of the documentation. Suppose we call it "current". Then (while
steve> 2.4 is still the current version) the
James Stroud wrote:
Hello,
I am looking for a nice way to take only those charachters from a string that
are in another string and make a new string:
astr = "Bob Carol Ted Alice"
letters = "adB"
some_func(astr,letters)
"Bad"
I can write this like this:
astr = "Bob Carol Ted Alice"
letters = "adB
Bengt Richter wrote:
> I think this will be worth it if your string to modify is _very_ long:
>>> def some_func(s, letters, table=''.join([chr(i) for i in
xrange(256)])):
... return s.translate(table,
...''.join([chr(i) for i in xrange(256) if chr(i) not in letters]))
...
>>>
Michael Spencer wrote:
Bengt Richter wrote:
> I think this will be worth it if your string to modify is _very_ long:
>>> def some_func(s, letters, table=''.join([chr(i) for i in
xrange(256)])):
... return s.translate(table,
...''.join([chr(i) fo
Peter Otten wrote:
Michael Spencer wrote:
def func_join(s, letters):
... return "".join(letter for letter in s if letter in set(letters))
Make that
def func_join(s, letters):
letter_set = set(letters)
return "".join(letter for letter in s if letter in letter_set
Kent Johnson wrote:
Michael Spencer wrote:
Anyway, here are the revised timings...
... print shell.timefunc(func_translate1, "Bob Carol Ted Alice" *
multiplier, 'adB')
What is shell.timefunc?
This snippet, which I attach to my interactive shell, since I find timeit
aw
Bengt Richter wrote:
On Wed, 20 Apr 2005 11:01:28 +0200, Peter Otten <[EMAIL PROTECTED]> wrote:
...
"%s %(x)s %(y)s" % D()
My experiments suggest that you can have a maximum of one unnamed argument in a
mapping template - this unnamed value evaluates to the map itself
...
So under what circumstanc
Andrew Dalke wrote:
I see you assume that only \w+ can fit inside of a %()
in a format string. The actual Python code allows anything
up to the balanced closed parens.
Gah! I guess that torpedoes the regexp approach, then.
Thanks for looking at this
Michael
--
http://mail.python.org/mailman/listin
Martin v. Löwis wrote:
Apparently nobody has proposed this yet:
>>>filter(letters.__contains__, astr)
'Bad'
>>>filter(set(letters).__contains__, astr)
'Bad'
Everyone is seeking early PEP 3000 compliance ;-)
filter wins on conciseness - it's short enought to use in-line, but for a fair
speed compa
Steve Holden wrote:
Michael Spencer wrote:
Andrew Dalke wrote:
I see you assume that only \w+ can fit inside of a %()
in a format string. The actual Python code allows anything
up to the balanced closed parens.
Gah! I guess that torpedoes the regexp approach, then.
Thanks for looking at this
Steven Bethard wrote:
I have a list of strings that looks something like:
['O', 'B_X', 'B_Y', 'I_Y', 'O', 'B_X', 'I_X', 'B_X']
I'd have done it the same way as you, but here's 'another' way:
>>> def grp(lst):
... stack = []
... for label in lst:
... prefix = label[0]
...
[EMAIL PROTECTED] wrote:
I'm back...
[wondering why copy.deepcopy barfs on array instances]
http://www.python.org/doc/2.3.3/lib/module-copy.html
deepcopy:
...
This version does not copy types like module, class, function, method, stack
trace, stack frame, file, socket, window, *array*, or any sim
Michael Spencer wrote:
http://www.python.org/doc/2.3.3/lib/module-copy.html
deepcopy:
...
This version does not copy types like module, class, function, method,
stack trace, stack frame, file, socket, window, *array*, or any similar
types.
...
On reflection, I realize that this says that the
Steven Bethard wrote:
Bengt Richter wrote:
On Thu, 21 Apr 2005 15:37:03 -0600, Steven Bethard
<[EMAIL PROTECTED]> wrote:
I have a list of strings that looks something like:
['O', 'B_X', 'B_Y', 'I_Y', 'O', 'B_X', 'I_X', 'B_X']
[snip]
With error checks on predecessor relationship,
I think I'd do
[EMAIL PROTECTED] wrote:
...
list = [[10,11,12,13,14,78,79,80,81,300,301,308]]
how do I convert it so that I arrange them into bins .
so If i hvae a set of consecutive numbers i would like to represent
them as a range in the list with max and min val of the range alone.
I shd get something like
l
Thomas Köllmann wrote:
Hi, everybody!
I'm teaching myself Python, and I have no experience in programming
apart from some years of shell scripting. So, please bear with me.
These two funktions are part of an administrative script I've set
myself as a first lesson, and, as you will see, they're prac
Terry Reedy wrote:
"Charles Krug" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Both of these techniques look promising here.
Here a third, the closure approach (obviously not directly tested):
Just for grins, here's a fourth approach, using the descriptor protocol
>>> def func_w
andrea wrote:
I was thinking to code the huffman algorithm and trying to compress
something with it, but I've got a problem.
How can I represent for example a char with only 3 bits??
I had a look to the compression modules but I can't understand them much...
...
I understand I can't do it easily i
Jeff Winkler wrote:
I've come up with...
cssClass=['rssLink','rssLinkNew'][hoursOld<12]
Not hideous, but:
>>> cssClass=('rssLink','rssLinkNew')[hoursOld<12]
is IMO, slightly less surprising,
and in this context:
>>> cssClass = hoursOld<12 and 'rssLinkNew' or 'rssLink'
>>>
reads better too
Micha
andrea wrote:
No it's not for homework but for learning purposes...
Bengt wrote:
I think I prefer little-endian bit streams though,
good point: should lead to easier decoding via right-shifts
e.g. (just hacked, not tested beyond
what you see
Yep, yours looks better. Pretty soon there isn't going
alexk wrote:
I've a simple question. Why the following:
words = "[EMAIL PROTECTED]@^%[wordA] [EMAIL PROTECTED]".split('[EMAIL
PROTECTED]&*()_+-=[]{},./')
doesn't work? The length of the result vector is 1.
I'm using ActivePython 2.4
Alex
Do you mean, why doesn't it split on every character in '[EM
David Murmann wrote:
Shane Hathaway wrote:
That was pretty fun. Good for a Friday. Too bad it comes to an abrupt
"temporary end".
Shane
P.S. I hope I didn't hammer your server on step 3. I was missing the
mark. :-)
Interestingly step 3 is actually wrong... there is an additional
solution, whic
Bengt Richter wrote:
Just thought None as the first argument would be both handy and mnemonic,
signifying no translation, but allowing easy expression of deleting characters,
e.g.,
s = s.translate(None, 'badcharshere')
Regards,
Bengt Richter
+1
Michael
--
http://mail.python.org/mailman/listinfo/
ator for adding entries to
draw_functions, but this is basically how it'd work.
The second way feels kludgey to me, but I'm leaning towards it because
it seems like so much less work and I'm out of ideas. Can anyone help,
explaining either a different way to do it or why one of these isn't
as bad as I think?
Thanks for your time!
-Spencer
--
http://mail.python.org/mailman/listinfo/python-list
On Dec 23, 9:13 am, Terry Reedy wrote:
> On 12/22/2011 3:21 AM, Spencer Pearson wrote:
>
> > I'm writing a geometry package, with Points and Lines and Circles and
> > so on, and eventually I want to be able to draw these things on the
> > screen. I have two options
(I'm sorry for my delayed response -- I've been travelling and not had
reliable Internet access.)
>> Spencer, i would re-think this entire project from the
>> beginning. You are trying to make an object out of everything. You
>> don't need to make an object of EV
asonable. I'll definitely reconsider
making the draw() method a requirement for all GeometricObjects.
>> I've never modified an existing class before, and I fear the
>> unfamiliar. If that's what you meant... it's really an acceptable
>> thing to do?
>
> Yes,
(I'm sorry for my delayed response -- I've been travelling and not had
reliable Internet access.)
On 2011-12-25, Ian Kelly wrote:
> On Thu, Dec 22, 2011 at 1:21 AM, Spencer Pearson
> wrote:
>> I see a problem with this, though. The intersection of two lines is
>>
[EMAIL PROTECTED] wrote:
> Hi,
>
> I'd need to perform simple pattern matching within a string using a
> list of possible patterns. For example, I want to know if the substring
> starting at position n matches any of the string I have a list, as
> below:
>
> sentence = "the color is $red"
> patte
Jacob Rael wrote:
> Hello,
>
> I would like write a function that I can pass an expression and a
> dictionary with values. The function would return a function that
> evaluates the expression on an input. For example:
>
> fun = genFun("A*x+off", {'A': 3.0, 'off': -0.5, 'Max': 2.0, 'Min':
> -2.0}
Bengt Richter wrote:
> On 12 Dec 2005 21:38:23 -0800, "Jacob Rael" <[EMAIL PROTECTED]> wrote:
>
>> Hello,
>>
>> I would like write a function that I can pass an expression and a
>> dictionary with values. The function would return a function that
>> evaluates the expression on an input. For exampl
Dennis Benzinger wrote:
> Christopher Subich schrieb:
>> Paul McGuire wrote:
>>
>> [...]
>> For the example listed, pyparsing is even overkill; the OP should
>> probably use the csv module.
>
> But the OP wants to parse lines with key=value pairs, not simply lines
> with comma separated values. U
Catalina Scott A Contr AFCA/EVEO wrote:
> I have a file with lines in the following format.
>
> pie=apple,quantity=1,cooked=yes,ingredients='sugar and cinnamon'
> Pie=peach,quantity=2,ingredients='peaches,powdered sugar'
> Pie=cherry,quantity=3,cooked=no,price=5,ingredients='cherries and sugar'
>
Fuzzyman wrote:
> Hello all,
>
> I'm writing a module that takes user input as strings and (effectively)
> translates them to function calls with arguments and keyword
> arguments.to pass a list I use a sort of 'list constructor' - so the
> syntax looks a bit like :
>
>checkname(arg1, "arg 2"
Peter Otten wrote:
>
> If you could provide a function with a different namespace when it's called,
> e. g
>
> f() in namespace
>
> would look up its globals in namespace, that might be an interesting concept
> but it's not how Python works.
>
> Peter
>
It does seem like an interesting concep
Daniel Nogradi wrote:
> I have class 'x' with member 'content' and another member 'a' which is an
> instance of class '_a'. The class '_a' is callable and has a method 'func'
> which I would like to use to modify 'content' but I don't know how to
> address 'content' from the class '_a'. Is it pos
What is the recommended way to change the icon of the exe ExeMaker* produces?
(I tried replacing the exemaker.ico file, and indeed removing it; but that had
no effect.)
Thanks
Michael
*http://effbot.org/zone/exemaker.htm
--
http://mail.python.org/mailman/listinfo/python-list
Tim Hochberg wrote:
> Shane Hathaway wrote:
>> Andrew Durdin wrote:
>>
>>> On 12/28/05, Shane Hathaway <[EMAIL PROTECTED]> wrote:
>>>
>>>
I just found a 125 character solution. It's actually faster and more
readable than the 133 character solution (though it's still obscure.)
>>>
>>> Hav
Claudio Grondi wrote:
> ...I analysed the outcome of it and have
> come to the conclusion, that there were two major factors which
> contributed to squeezing of code:
>
>(1). usage of available variants for coding of the same thing
>(2). sqeezing the size of used numeric and string litera
Bengt Richter wrote:
...
>
> This could be achieved by a custom import function that would capture the AST
> and e.g. recognize a declaration like __inline__ = foo, bar followed by defs
> of foo and bar, and extracting that from the AST and modifying the rest of the
> AST wherever foo and bar call
> Bengt Richter wrote:
...
>> >>> from itertools import repeat, chain, izip
>> >>> it = iter(lambda z=izip(chain([3,5,8],repeat("Bye")),
>> chain([11,22],repeat("Bye"))):z.next(), ("Bye","Bye"))
>> >>> for t in it: print t
>> ...
>> (3, 11)
>> (5, 22)
>> (8, 'Bye')
>>
>> (Feel free to gene
Paul Rubin wrote:
> Michael Spencer <[EMAIL PROTECTED]> writes:
>> for i in range(10):
>> result = []
>> ...
>
> Do you mean "while True: ..."?
>
oops, yes!
so, this should have been:
from itertools import repeat
def izip2(
rh0dium wrote:
> Hi all,
>
> I am using python to drive another tool using pexpect. The values
> which I get back I would like to automatically put into a list if there
> is more than one return value. They provide me a way to see that the
> data is in set by parenthesising it.
>
...
>
> CAN S
rh0dium wrote:
> Michael Spencer wrote:
>> >>> def parse(source):
>> ... source = source.splitlines()
>> ... original, rest = source[0], "\n".join(source[1:])
>> ... return original, rest_eval(get_tokens(rest))
>
> This is
Jean-Paul Calderone wrote:
> On 10 Jan 2006 15:18:22 -0800, [EMAIL PROTECTED] wrote:
>> I want to be able to pass a sequence (tuple, or list) of objects to a
>> function, or only one.
>
...
> but in case you're curious, the easiest
> way to tell an iterable from a non-iterable is by trying to ite
> Robin Becker schrieb:
>> Is there some smart/fast way to flatten a level one list using the
>> latest iterator/generator idioms.
...
David Murmann wrote:
> Some functions and timings
...
Here are some more timings of David's functions, and a couple of additional
contenders that time faster
Tim Hochberg wrote:
> Michael Spencer wrote:
>> > Robin Becker schrieb:
>> >> Is there some smart/fast way to flatten a level one list using the
>> >> latest iterator/generator idioms.
>> ...
>>
>> David Murmann wrote:
>> > Some
uences and
un-equal lengths, with only modest loss of speed:
def interleave(*args, **kw):
"""Peter Otten flatten7 (generalized by Michael Spencer)
Interleave any number of sequences, padding shorter sequences if kw pad
is supplied"""
dopad = "pa
[EMAIL PROTECTED] wrote:
> It's important that I can read the contents of the dict without
> flagging it as modified, but I want it to set the flag the moment I add
> a new element or alter an existing one (the values in the dict are
> mutable), this is what makes it difficult. Because the values a
> Michael Spencer wrote:
>> result[ix::count] = input + [pad]*(maxlen-lengths[ix])
Peter Otten rewrote:
> result[ix:len(input)*count:count] = input
Quite so. What was I thinking?
Michael
--
http://mail.python.org/mailman/listinfo/python-list
Before I get too carried away with something that's probably
unnecessary, please allow me to throw around some ideas. I've been
looking for a method of transparent, scalable, and human-readable object
persistence, and I've tried the standard lib's Shelve, Zope's ZODB,
Divmod's Axiom, and others
Michele Simionato wrote:
> [EMAIL PROTECTED] wrote:
>> I need to find out if an object is a class.
>> Which is quite simply awful...does anyone know of a better way to do
>> this?
>
> inspect.isclass
>
> M.S.
>
...which made me wonder what this canonical test is. The answer:
def isclass(o
Why does code.InteractiveConsole support command history on Windows, but
not in a Gnome terminal (all I get is ^[[A^[[B)? Or does it not support
history at all, and the Windows console is implementing it's own? Is
there any way to get command history working with InteractiveConsole on
Linux?
C
vbgunz wrote:
> vbgunz wrote:
>>> Why does code.InteractiveConsole support command history on Windows, but
>>> not in a Gnome terminal (all I get is ^[[A^[[B)? Or does it not support
>>> history at all, and the Windows console is implementing it's own? Is
>>> there any way to get command history wo
Robert Kern wrote:
> Chris Spencer wrote:
>> Why does code.InteractiveConsole support command history on Windows,
>> but not in a Gnome terminal (all I get is ^[[A^[[B)? Or does it not
>> support history at all, and the Windows console is implementing it's
>&
Robert Kern wrote:
> Chris Spencer wrote:
>> Robert Kern wrote:
>>> Chris Spencer wrote:
>>>> Why does code.InteractiveConsole support command history on Windows,
>>>> but not in a Gnome terminal (all I get is ^[[A^[[B)? Or does it not
>>>&
[EMAIL PROTECTED] wrote:
> Chris> Yeah, "import readline" works just fine. My problem isn't hard to
> Chris> replicate. Can anyone else on Linux get command history to work
> Chris> with the following code? Note, it should be saved and run from a
> Chris> file.
>
> Command history
201 - 300 of 428 matches
Mail list logo