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
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 typing
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 because I expect 'int
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
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't work for multiple
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
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
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
Tim Hochberg wrote:
Jordan Rastrick wrote:
itertools.groupby enables you to do this, you just need to define a suitable
grouping function, that stores its state:
For example, if short lines should be appended to the previous line:
from itertools import groupby
linesource = \
Here is a long line,
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
An Abridged Python Tutorial
There are tips for the novice and tricks
that will add to your programming kicks.
But the cardinal rule
that you must learn at school
is that spaces and tabs never mix.
If there's syntax you don't understand,
assistance is always at hand:
a glance at the
Simon Brunning wrote:
On 23 Mar 2005 21:03:04 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Is there something out there like Python for kids which would explain
*basic* programming concepts in a way which is accessible and
entertaining for kids aged 10-14 (that about where her brain is right
Wow - Alex Martelli's 'Black Magic' Pycon notes
http://www.python.org/pycon/2005/papers/36/pyc05_bla_dp.pdf
include this gem:
Functions 'r descriptors
def adder(x, y): return x + y
add23 = adder.__get__(23)
add42 = adder.__get__(42)
print add23(100), add42(1000)
123 1042
This means
Paul L. Du Bois wrote:
Xah Lee wrote:
I think i'll just post...
[ snipped ]
That is a very good analysis. Can you submit a documentation patch? I
would, but I'm too lazy to contribute. That doesn't mean I'm not
thankful for your efforts, though!
p
Or if not a doc patch, how about a limerick?
How about a category for executable limericks?
Here's one to get the ball rolling:
# voice only the alphanumeric tokens
from itertools import repeat
for feet in [3,3,2,2,3]:
print .join(DA-DA-DUM
for dummy in [None]
for foot in repeat(metric, feet))
Michael
P.S. I know 'three' doesn't
MCD wrote:
Thanks Alessandro... I'll have to try that as well.
I have a modified working version of John's code (thanks John!). I'm
able to output the bins by 5min intervals, sum one of the fields, and
get the high and low of each field. So far I'm really happy with how it
works. Thank you to
MCD wrote:
Hi Michael, thanks for responding. I actually don't use a method to get
each bin...
That's because you picked the wrong suggestion ;-) No, seriously, you can do it
easily with this approach:
the bin outputs are nested in the loop. Here's my code:
data_file = open('G:\file.txt')
[EMAIL PROTECTED] wrote:
[trying to create a single Python class with the equivalent of the following
overloaded constructors]
wxFoldWindowItem(wxWindow *wnd, int flags = wxFPB_ALIGN_WIDTH,
int ySpacing = wxFPB_DEFAULT_YSPACING,
int leftSpacing =
Raymond Hettinger wrote:
I would like to get everyone's thoughts on two new dictionary methods:
def count(self, value, qty=1):
try:
self[key] += qty
except KeyError:
self[key] = qty
def appendlist(self, key, *values):
Kay Schluehr wrote:
Maybe also the subclassing idea I introduced falls for short for the
same reasons. Adding an accumulator to a dict should be implemented as
a *decorator* pattern in the GoF meaning of the word i.e. adding an
interface to some object at runtime that provides special facilities.
Raymond Hettinger wrote:
I would like to get everyone's thoughts on two new dictionary methods:
+1 count
? appendlist
The proposed names could possibly be improved (perhaps tally() is more
active
and clear than count()).
IMO 'tally' is exactly the right method name
One issue is with negative
John Hunter wrote:
les == les ander [EMAIL PROTECTED] writes:
les Hi, matlab has a useful function called textread which I am
les trying to reproduce in python.
les two inputs: filename, format (%s for string, %d for integers,
les etc and arbitary delimiters)
Builing on John's
Steve wrote:
Is it possible to design interfaces that classes must implement in
Python?
There are some well-known 'independent' implementations of interfaces:
Zope Interfaces :http://www.zope.org/Wikis/Interfaces/FrontPage
- a separable component of the much larger app
F. Petitjean wrote:
Le Tue, 15 Mar 2005 23:21:02 -0800, Michael Spencer a écrit :
def output(seq, linelength = 60):
if seq:
iterseq = iter(seq)
while iterseq:
print .join(islice(iterseq,linelength))
I suppose you mean :
print .join( str(item) for item
Giovanni Bajo wrote:
Michael Spencer wrote:
In fact, I believe my solution to be totally safe,
That's a bold claim! I'll readily concede that I can't access
func_globals from restricted mode eval (others may know better). But
your interpreter is still be vulnerable to DOS-style attack from
Steven Bethard wrote:
Michael Spencer wrote:
def output(seq, linelength = 60):
if seq:
iterseq = iter(seq)
while iterseq:
print .join(islice(iterseq,linelength))
Worth noting: while iterseq only works because for this case, you have
a list iterator, which provides
Jacob Lee wrote:
There are a bunch of new tests up at shootout.alioth.debian.org for which
Python does not yet have code. I've taken a crack at one of them, a task
to print the reverse complement of a gene transcription. Since there are a
lot of minds on this newsgroup that are much better at
Jacob Lee wrote:
On Tue, 15 Mar 2005 21:38:48 -0800, Michael Spencer wrote:
string.translate is a good idea. Note you can handle upper-casing and
translation in one operation by adding a mapping from lower case to the
complement i.e.,
table = string.maketrans('ACBDGHK\nMNSRUTWVYacbdghkmnsrutwvy
[EMAIL PROTECTED] wrote:
I have a dictionary. Each key contains a list. I am using the
contents of the list to build a portion of a command line.
However, before I can build the command line, I have to make sure that
the command isn't too long.
Depending on how you join the list items, you may
Giovanni Bajo wrote:
Michael Spencer wrote:
* this means that, eval(sys.exit()) will likely stop your
interpreter, and
there are various other inputs with possibly harmful consequences.
Concerns like these may send you back to your original idea of doing
your own expression parsing.
I use
()
LOAD_CONST(1)
BINARY_SUBTRACT()
ROT_THREE()
ROT_TWO()
POP_TOP()
POP_TOP()
return
# ByteCode.py --
Python ByteCode Assembler
Author: Michael Spencer
Version: 0 - Experiment
3/11/2005
Brian Kazian wrote:
Thanks for the help, I didn't even think of that.
I'm guessing there's no easy way to handle exponents or logarithmic
functions? I will be running into these two types as well.
Artie Gold [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
eval will handle exponents
Charles Hartman wrote:
I'm still shaky on some of sre's syntax. Here's the task: I've got
strings (never longer than about a dozen characters) that are guaranteed
to be made only of characters 'x' and '/'. In each string I want to find
the longest continuous stretch of pairs whose first
George Sakkis wrote:
The S-expression parser below works, but I wonder if it can be simplified; it's
not as short and
straightforward as I would expect given the simplicity of S-expressions. Can
you see a simpler
non-recursive solution ?
How about this (minus your error checking)?
def
Leeds, Mark wrote:
I have a dictionary grp that has lists
for each element ( excuse my terminology if it's
incorrect).
So gname might be automobiles, finance, construction etc
and grp[gname] is a list and this list
has elements that are strings
such as [AAA,BBB,AAA,CCC]
Is there a quick way to
Jeffrey Barish wrote:
class super:
'''All the generic stuff goes here'''
Better not to call the class super: it's a built-in type
class linux_subclass(super):
def func(self):
'''linux-specific function defined here'''
class windows_subclass(super):
def func(self):
James Stroud wrote:
Hello,
Its not obvious to me how to do this. I would like to iterate using a tuple as
an index. Say I have two equivalently sized arrays, what I do now seems
inelegant:
for index, list1_item in enumerate(firstlist):
do_something(list1_item, secondlist[index])
I would like
Felix Steffenhagen wrote:
[snip]
In:
http://www.informatik.uni-freiburg.de/~steffenh/bayes.py
[bayes.test gives different results each time it is called]
Without looking in the slightest at what you are implementing or how, this
implies that state is maintained between calls to test
The
Guido van Rossum wrote:
See my blog: http://www.artima.com/forums/flat.jsp?forum=106thread=98196
Do we even need a PEP or is there a volunteer who'll add any() and all() for me?
Surely these can be written easily with existing constructs:
def any(S):
return reduce(lambda x, y: bool(x or y),
[EMAIL PROTECTED] wrote:
What i'm trying to do is tie special methods of a proxy instance
to another instance:
...
new style classes:
def test2():
print test2
class Container(object):
def __init__( self, data ):
self.data = data
# self.__dict__[__getitem__] =
Marc Christiansen wrote:
Michael Spencer [EMAIL PROTECTED] wrote:
Nice. When you replace None by an object(), you have no restriction on
the elements any more:
Thanks for the suggestion, Marc.
Note that if there is no need to access the middle of the collection, then the
implementation
Dave Opstad wrote:
In this snippet:
d = {'x': 1}
value = d.get('x', bigscaryfunction())
the bigscaryfunction is always called, even though 'x' is a valid key.
Is there a short-circuit version of get that doesn't evaluate the
second argument if the first is a valid key? For now I'll code around
Andy Leszczynski wrote:
so e.g.
x={}
x['a']=1
x['A']=2
print x['a'] #prints 2
Thx, A.
http://www.google.com/search?q=python+case+insensitive+dictionary
Michael
--
http://mail.python.org/mailman/listinfo/python-list
Delaney, Timothy C (Timothy) wrote:
Michael Hoffman wrote:
For those who don't know, these implement a hash set/map which
iterates in the order that the keys were first added to the set/map.
I would love to see such a thing.
I've proposed this on python-dev, but the general feeling so far is
Steven Bethard wrote:
Nick Coghlan wrote:
Hmm, it might be nice if there was a UserList.ListMixin that was the
counterpart to UserDict.DictMixin
I've thought this occasionally too. One of the tricky issues though is
that often you'd like to define __getitem__ for single items and have
David S. wrote:
This still fails to work for instances variables of the class. That is
if I use your property in the following:
py ...class Flags(object):
...def __init__(self):
... a = singlechar
...
you should write that as:
class Flags(object):
a = singlechar
def
Anthony Liu wrote:
I cannot figure out how to specify a list of a
particular size.
For example, I want to construct a list of size 10,
how do I do this?
A list does not have a fixed size (as you probably know)
But you can initialize it with 10 somethings
[None]*10
[None, None, None, None,
[EMAIL PROTECTED] wrote:
When I look at how classes are set up in other languages (e.g. C++), I
often observe the following patterns:
1) for each data member, the class will have an accessor member
function (a Getwhatever function)
2) for each data member, the class will have a mutator member
[EMAIL PROTECTED] wrote:
If the class had two attributes--x and y--would the code look like
something lik this:
class C(object):
def __init__(self):
self.__x = 0
self.__y = 0
def getx(self):
return self.__x
def setx(self, x):
gf gf wrote:
[wants to extract ASCII from badly-formed HTML and thinks BeautifulSoup is too complex]
You haven't specified what you mean by extracting ASCII, but I'll assume that
you want to start by eliminating html tags and comments, which is easy enough
with a couple of regular expressions:
Mike Meyer wrote:
It also fails on tags with a in a string in the tag. That's
well-formed but ill-used HTML.
mike
True enough...however, it doesn't fail too horribly:
striptags(sometag attribute = ''the text/sometag)
'the text
and I think that case could be rectified rather
David Eppstein wrote:
In article [EMAIL PROTECTED],
Xah Lee [EMAIL PROTECTED] wrote:
given a list aList of n elements, we want to return a list that is a
range of numbers from 1 to n, partition by the predicate function of
equivalence equalFunc.
In the worst case, this is going to have to take
[EMAIL PROTECTED] wrote:
Kent Johnson wrote:
[EMAIL PROTECTED] wrote:
p.s. the reason I'm not sticking to reversed or even reverse :
suppose
the size of the list is huge.
reversed() returns an iterator so list size shouldn't be an issue.
What problem are you actually trying to solve?
Kent
Oh, you
Johannes Nix|Johannes.Nix@uni-oldenburg.de wrote:
Hi,
I have a tricky problem with Numeric. Some time ago, I have generated
a huge and complex data structure, and stored it using the cPickle
module. Now I want to evaluate it quickly again on a workstation
cluster with 64-Bit Opteron CPUs - I have
Christos TZOTZIOY Georgiou wrote:
On Sat, 12 Feb 2005 16:01:26 -0800, rumours say that Michael Spencer
[EMAIL PROTECTED] might have written:
Yup, that's basically what I'm doing right now. The question was really
how to define that adapter function. =)
Steve
OK - then my entry
Grant Edwards wrote:
On 2005-02-17, Steven Bethard [EMAIL PROTECTED] wrote:
py class C(object):
... def f(self, *args):
... print f:, args
... def g(self, *args):
... print g:, args
...
py class D(C):
... pass
...
py class Wrapper(object):
... def __init__(self,
John Lenton wrote:
On Thu, Feb 17, 2005 at 07:32:55PM +, Grant Edwards wrote:
I'd usually put big fat warnings around this code, and explain exaclty
why I need to do things this way...
As a low-tech alternative, what about sourcecode generation, since you are
targetting a python module?
peter wrote:
Hello, nice solution:
but it puzzles me :)
can anyone tell me why
---correct solution
def fA(input):
return input
def newFA(input, f= fA):
return f(input)
fA = newFA
is correct and:
-infinite loop-
def fA(input):
return input
Steven Bethard wrote:
So, I have a list of lists, where the items in each sublist are of
basically the same form. It looks something like:
...
Can anyone see a simpler way of doing this?
Steve
You just make these up to keep us amused, don't you? ;-)
If you don't need to preserve the ordering,
Terry Reedy wrote:
Michael Spencer [EMAIL PROTECTED] wrote in message
We are both interested in the murky edges at and beyond conventional usage.
...
I am quite aware that multiple iterators for the same iterable (actual or
conceptual) can be useful (cross products, for example). But I am
Adam DePrince wrote:
How is a spencerator [an iterator that doesn't return itself unmodified on iter]
different than itertools.tee?
Taking your question literally, it changes the behavior of an itertools.tee
object 'tee', so that iter(tee) returns tee.__copy__(), rather than tee itself.
It
Michael Spencer wrote:
def resample2(data):
... bag = {}
... random.shuffle(data)
... return [[(item, label)
... for item, label in group
... if bag.setdefault(label,[]).append(item)
... or len(bag[label]) 3
Michael Spencer wrote:
But, notwithstanding the docs, it is not essential that
iter(iterator) is iterator
Terry Reedy wrote:
iter(iterator) is iterator is part of the iterater protocol
[...]I interpret [your post] as saying three things:
1. There is more than one possible definition of 'iterator
Peter Hansen wrote:
Felix Wiemann wrote:
Sometimes (but not always) the __new__ method of one of my classes
returns an *existing* instance of the class. However, when it does
that, the __init__ method of the existing instance is called
nonetheless, so that the instance is initialized a second
naturalborncyborg wrote:
Hi, I'm using nested lists as arrays and having some problems with
that approach. In my puzzle class there is a swapelement method which
doesn't work out.
What doesn't work out? On casual inspection that method seems to work:
p = Puzzle(2)
p.elements[0][0] = 1
Terry Reedy wrote:
[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
def setRandomState(self):
# container for the elements to pick from
container = [1,2,3,4,5,6,7,8,-1]
# create elements of puzzle randomly
i = 0
j = 0
while i = self.dim-1:
while
Francis Girard wrote:
Example 8
Running after your tail with itertools.tee
The beauty of it is that recursive running after their tail
Roose wrote:
Yeah, as we can see there are a million ways to do it. But none of them are
as desirable as just having a library function to do the same thing. I'd
argue that since there are so many different ways, we should just collapse
them into one: any() and all(). That is more in keeping
Francis Girard [EMAIL PROTECTED] wrote in message
an iterator doesn't have to support the __iter__ method
Terry Reedy wrote:
Yes it does. iter(iterator) is iterator is part of the iterater protocol
for the very reason you noticed...
But, notwithstanding the docs, it is not essential that
Roose wrote:
Previous discussion on this topic:
http://groups-beta.google.com/group/comp.lang.python/msg/a76b4c2caf6c435c
Michael
OK, well then. That's really the exact same thing, down to the names of the
functions. So what ever happened to that?
I don't recall: probably
Frans Englich wrote:
Hello,
Have a look at this recursive function:
def walkDirectory( directory, element ):
element = element.newChild( None, directory, None ) # automatically
appends to parent
element.setProp( name, os.path.basename(directory))
for root, dirs, files in os.walk(
Steven Bethard wrote:
Peter Hansen wrote:
Of course, most of the other definitions of is a number that
have been posted may likewise fail (defined as not doing what the
OP would have wanted, in this case) with a numarray arange.
Or maybe not. (Pretty much all of them will call an arange a
Steven Bethard wrote:
Michael Spencer wrote:
Steven Bethard wrote:
Peter Hansen wrote:
Of course, most of the other definitions of is a number that
have been posted may likewise fail (defined as not doing what the
OP would have wanted, in this case) with a numarray arange.
How about explicitly
Tim Peters wrote:
[Frans Englich]
...
[snip]
class HasPath:
def __init__(self, path):
self.path = path
def __lt__(self, other):
return self.path other.path
class Directory(HasPath):
def __init__(self, path):
HasPath.__init__(self, path)
self.files = []
Bernhard Herzog wrote:
Michael Spencer [EMAIL PROTECTED] writes:
So, here's factorial in one line:
# state refers to list of state history - it is initialized to [1]
# on any iteration, the previous state is in state[-1]
# the expression also uses the trick of list.append() = None
# to both
Jeremy Bowers wrote:
That's not a generator expression, that's a generator function. Nobody
contests they can reference earlier states, that's most of their point :-)
Are you sure?
I just wrote my examples in functions to label them
Here's your example with this method:
import itertools as it
Jeremy Bowers wrote:
OK then, I still don't quite see how you can build a Turing Machine in one
LC, but an LC and one preceding list assignment should be possible,
although the resulting list from the LC is garbage;
Not necessarily garbage - could be anything, say a copy of the results:
results
Jeremy Bowers [EMAIL PROTECTED] writes:
On Tue, 08 Feb 2005 17:36:19 +0100, Bernhard Herzog wrote:
Nick Vargish [EMAIL PROTECTED] writes:
Xah Lee [EMAIL PROTECTED] writes:
is it possible to write python code without any indentation?
Not if Turing-completeness is something you desire.
Bernhard
Carl Banks wrote:
Pay attention, chief. I suggested this days ago to remove duplicates
from a list.
from itertools import *
[ x for (x,s) in izip(iterable,repeat(set()))
if (x not in s,s.add(x))[0] ]
;)
Sorry, I gave up on that thread after the first 10 Million* posts. Who knows
what other
Steven Bethard wrote:
Do you mean there should be a separate Namespace and Bunch class? Or do
you mean that an implementation with only a single method is less useful?
The former.
If the former, then you either have to repeat the methods __repr__,
__eq__ and update for both Namespace and Bunch,
Alex Martelli wrote:
Steven Bethard [EMAIL PROTECTED] wrote:
Hmm... interesting. This isn't the main intended use of
Bunch/Struct/whatever, but it does seem like a useful thing to have...
I wonder if it would be worth having, say, a staticmethod of Bunch that
produced such a view, e.g.:
class
Alex Martelli wrote:
Hmmm, you do realize that wrapdict uses a lot of indirection while my
equivalent approach, just posted, is very direct, right? To reiterate
the latter, and dress it up nicely too, it's
class wrapwell(object):
def __init__(self, somedict):
self.__dict__ = somedict
Alex Martelli wrote:
Nick Coghlan [EMAIL PROTECTED] wrote:
...
Michael Spencer also posted ...
Wasted indirection, IMHO. A better implementation:
class attr_view(object):
def __init__(self, data):
self.__dict__ = data
Alex
Indeed! A complete brain-blip
Michael
--
http
Steven Bethard wrote:
Nick Coghlan wrote:
class attr_view(object):
def __init__(self, data):
self.__dict__ = data
I think the idea definitely deserves mention as a possible
implementation strategy in the generic objects PEP, with the data
argument made optional:
That's basically
Steven Bethard wrote:
I have lists containing values that are all either True, False or None,
e.g.:
[True, None, None, False]
[None, False, False, None ]
[False, True, True, True ]
etc.
For a given list:
* If all values are None, the function should return None.
* If at
Bo Peng wrote:
Dear list,
I have many dictionaries with the same set of keys and I would like to
write a function to calculate something based on these values. For
example, I have
a = {'x':1, 'y':2}
b = {'x':3, 'y':3}
def fun(dict):
dict['z'] = dict['x'] + dict['y']
fun(a) and fun(b) will set
Bo Peng wrote:
Michael Spencer wrote:
There are hundreds of items in the dictionary (that will be needed in
the calculation) so passing the whole dictionary is a lot better than
passing individual items.
...
def fun(d):
exec 'z = x + y' in globals(), d
seems to be more readable than
def fun
Fahri Basegmez wrote:
reduce(lambda x, y: x or y, lst)
works but when I tried
import operator
reduce(operator.or_, lst)
this did not work. It pukes
Traceback (most recent call last):
File interactive input, line 1, in ?
TypeError: unsupported operand type(s) for |: 'NoneType' and 'bool'
Any
Nick Coghlan wrote:
Michael Spencer wrote:
def fun(dict):
# set dict as local namespace
# locals() = dict?
z = x + y
As you no doubt have discovered from the docs and this group, that
isn't doable with CPython.
Not entirely impossible:
Py def f(d):
... exec locals().update(d
Fahri Basegmez wrote:
Michael Spencer [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Fahri Basegmez wrote:
reduce(lambda x, y: x or y, lst)
works but when I tried
import operator
reduce(operator.or_, lst)
this did not work. It pukes
Traceback (most recent call last):
File
Steven Bethard wrote:
I'm sorry, I assume this has been discussed somewhere already, but I
found only a few hits in Google Groups... If you know where there's a
good summary, please feel free to direct me there.
I have a list[1] of objects from which I need to remove duplicates. I
have to
Paul Rubin wrote:
Francis Girard [EMAIL PROTECTED] writes:
Thank you Nick and Steven for the idea of a more generic imerge.
If you want to get fancy, the merge should use a priority queue (like
in the heapsort algorithm) instead of a linear scan through the
incoming iters, to find the next item
Francis Girard wrote:
The following implementation is even more speaking as it makes self-evident
and almost mechanical how to translate algorithms that run after their tail
from recursion to tee usage :
Thanks, Francis and Jeff for raising a fascinating topic. I've enjoyed trying
to get my
Nick Craig-Wood wrote:
Steven Bethard [EMAIL PROTECTED] wrote:
Nick Craig-Wood wrote:
Thinking about this some more leads me to believe a general purpose
imerge taking any number of arguments will look neater, eg
def imerge(*generators):
values = [ g.next() for g in generators ]
while True:
Steven Bethard wrote:
I wish there was a way to, say, exec something with no builtins and
with
import disabled, so you would have to specify all the available
bindings, e.g.:
exec user_code in dict(ClassA=ClassA, ClassB=ClassB)
but I suspect that even this wouldn't really solve
Steven Bethard wrote:
I wish there was a way to, say, exec something with no builtins and
with import disabled, so you would have to specify all the available
bindings, e.g.:
exec user_code in dict(ClassA=ClassA, ClassB=ClassB)
but I suspect that even this wouldn't really solve the
Steven Bethard wrote:
Michael Spencer wrote:
Safe eval recipe posted to cookbook:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/364469
This recipe only evaluates constant expressions:
Description:
Evaluate constant expressions, including list, dict and tuple using the
abstract syntax
Cameron Laird wrote:
In article [EMAIL PROTECTED],
Michael Spencer [EMAIL PROTECTED] wrote:
.
.
.
Right - the crux of the problem is how to identify dangerous objects. My point
is that if such as test is possible, then safe
201 - 300 of 308 matches
Mail list logo