Hi Jean-Paul
> You can do this (if you replace `pass´ with `None´, anyway) or you can pass
> `consumeErrors=True´ to the `DeferredList´ initializer which will make it
> do something equivalent.
Thanks. Sorry - I should have just read the docs again :-)
Terry
--
http://mail.python.org/mailman/lis
> "Peter" == Peter Otten <[EMAIL PROTECTED]> writes:
Peter> [EMAIL PROTECTED] wrote:
[snip]
>> ...can someone explain why invoking a.py prints 0?
>> I would have thought that the global variable 'g' of module 'a' would
>> be set to 1...
Peter> When you run a.py as a script it is put into the s
I'm trying to programmatically install something built using distutils. I
found distutils.core.run_setup and can use it via
>>> dist = run_setup('setup.py', ['-q', 'install'])
Is that the recommended way to do an install from inside Python (as opposed
to doing it on the command line)?
If so, h
Hi Jerry
> I am hoping one or two members of this list might help me locate in Europe
Do you mean you want to re-locate here or that you're trying to locate
(i.e., find) people already here?
> My personal first choice is Spain
I'm in Barcelona (but not looking for work!). There are a couple of
> "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes:
Arnaud> BTW, I keep using the idiom itertools.chain(*iterable). I guess
Arnaud> that during function calls *iterable gets expanded to a tuple.
Arnaud> Wouldn't it be nice to have an equivalent one-argument function
Arnaud> that takes
Hi Arnaud & Benjamin
Here's a version that's a bit more general. It handles keys whose values
are empty dicts (assigning None to the value in the result), and also dict
keys that are not strings (see the test data below). It's also less
recursive as it only calls itself on values that are dicts.
> "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes:
Arnaud> Are you suggesting a new axiom for propositional logic:
Arnaud> ((P => Q) ^ (R => Q)) => (P => R) ?
Arnaud> I.e. in fruit logic: every orange is a fruit and every apple is a
Arnaud> fruit, therefore every orange is an apple.
My output looks better sorted. I.e., for s in sorted(solutions)...
Giving the easier to read/compare:
Target 234, numbers = (100, 9, 7, 6, 3, 1)
(6, 1, 'add', 100, 'mul', 7, 'sub', 9, 'add', 3, 'div')
(6, 9, 'sub', 7, 'mul', 1, 'sub', 100, 'add', 3, 'mul')
(7, 3, 'mul', 6,
> "kj" == kj <[EMAIL PROTECTED]> writes:
kj> I've only recently started programming in Python, trying to wean
kj> myself from Perl. One of the things I *really* miss from Perl is
kj> a 100% mouse-free data inspector, affectionally known as the Perl
kj> debugger, PerlDB, or just perl -d. Wit
> "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes:
>>
>> Ha - you can't have it both ways Arnaud! You don't want the computation to
>> go negative... doesn't that (and my "proof") have something to do with the
>> inverse nature of add and sub? :-)
Arnaud> I think I can have it both wa
> "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes:
Arnaud> FWIW, I have a clear idea of what the space of solutions is, and
Arnaud> which solutions I consider to be equivalent. I'll explain it
Arnaud> below. I'm not saying it's the right model, but it's the one
Arnaud> within which I
Hi Arnaud and Dan
> "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes:
>> What was wrong with the very fast(?) code you sent earlier?
Arnaud> I thought it was a bit convoluted, wanted to try something I
Arnaud> thought had more potential. I think the problem with the second
Arnaud> one
Hi Arnaud
> I've tried a completely different approach, that I imagine as 'folding'. I
> thought it would improve performance over my previous effort but extremely
> limited and crude benchmarking seems to indicate disappointingly comparable
> performance...
I wrote a stack-based version yesterd
> "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes:
Arnaud> Sorry I gave an incorrect example to illustrate my question last
Arnaud> night (I blame this on baby-induced sleep deprivation ;), so I'll
Arnaud> have another go:
Arnaud> Say I have 2, 3, 4, 100 and I want to make 406. AFAIC
> "cokofreedom" == cokofreedom <[EMAIL PROTECTED]> writes:
cokofreedom> Terry, your technique is efficient and pretty readable! All
cokofreedom> that could be added now is a way to output the data in a more
cokofreedom> user-friendly print.
Yes, and a fix for the bug Arnaud just pointed out
> "dg" == dg google groups <[EMAIL PROTECTED]> writes:
dg> It's great how many different sorts of solutions (or almost solutions)
dg> this puzzle has generated. Speedwise, for reference my solution posted
dg> above takes about 40 seconds on my 1.8GHz laptop, and the less elegant
dg> version (o
> "Paul" == Paul Rubin <"http://phr.cx"@NOSPAM.invalid> writes:
Hi Paul
Paul> Here's my latest, which I think is exhaustive, but it is very slow.
Paul> It prints a progress message now and then just to give the user some
Paul> sign of life. It should print a total of 256-8 = 248 of those
Pau
> "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes:
Arnaud> In countdown you are not required to use all numbers to reach the
Arnaud> target. This means you are missing solutions, e.g. (1, 3, 6,
Arnaud> 'mul', 'add', 7 , 'add', 9, 'mul')
Hi Arnaud.
Thanks, I didn't know that. The fix
Here's a solution that doesn't use any copying of lists in for recursion.
It also eliminates a bunch of trivially equivalent solutions. The countdown
function is 37 lines of non-comment code. Sample (RPN) output below.
Terry
from operator import *
def countdown(target, nums, numsAvail, value,
> "Richard" == Richard Szopa <[EMAIL PROTECTED]> writes:
Richard> I am a devoted Emacs user and I write a lot in Python.
Me too.
Richard> I need the following features:
Richard> 1) Tab completion, ideally Slime like. That is, when there's not
Richard> enough letters to unambiguously complet
> "Brian" == Brian Smith <[EMAIL PROTECTED]> writes:
Brian> [EMAIL PROTECTED] wrote:
>> 2. Are there good python libraries for bdb available, that
>> are being maintained?
Brian> I would like to know the answer to this question too--if you have
Brian> used the pybsddb/bsddb.db module, please
> "BJ" == BJ Swope <[EMAIL PROTECTED]> writes:
I (at least) think the code looks much nicer.
BJ> #Referring to files to write in various places...
BJ> open_files['deliveries'].write(flat_line)
BJ> open_files['deliveries'].write('\n')
If you were doing a lot with the deliveries file at some p
> "Fredrik" == Fredrik Lundh <[EMAIL PROTECTED]> writes:
Fredrik> Seriously, for a limited number of files, the dictionary approach
Fredrik> is mostly pointless; you end up replacing
Fredrik> foo = open("foo")
Fredrik> foo.write(...)
Fredrik> with
Fredrik> somedict["foo"] = open("foo")
Fred
Hi BJ
> > Fredrik Lundh <[EMAIL PROTECTED]> writes:
> > Or in a dict:
> >
> > open_files = {}
> > for fn in ['messages', 'recipients', 'viruses']:
> >open_files[fn] = open(getfilename(fn), 'w')
>
> I decided that I was just trying to be "too smooth by 1/2" so I fell back
> to ...
>
> message
> "Raymond" == Raymond Hettinger <[EMAIL PROTECTED]> writes:
Raymond> * in most apps (except for sparse arrays), the initialization time
Raymond> for an array is dominated by the time spent actually doing
Raymond> something useful with the array (iow, this is an odd place to be
Raymond> optimiz
Hi Igor
> "Igor" == Igor V Rafienko <[EMAIL PROTECTED]> writes:
>> Also consider this solution from O'Reilly's Python Cookbook (2nd Ed.)
>> p705
>>
>> def chop(iterable, length=2):
>> return izip(*(iter(iterable),) * length)
Igor> Is this *always* guaranteed by the language to work? Should
> "rgalgon" == rgalgon <[EMAIL PROTECTED]> writes:
rgalgon> I'm new to Python and have been putting my mind to learning it
rgalgon> over my holiday break. I've been looking over the functional
rgalgon> programming aspects of Python and I'm stuck trying to come up with
rgalgon> some concise co
> "Kugutsumen" == Kugutsumen <[EMAIL PROTECTED]> writes:
Kugutsumen> On Dec 27, 7:07 pm, Paul Hankin <[EMAIL PROTECTED]> wrote:
>> On Dec 27, 11:34 am, Kugutsumen <[EMAIL PROTECTED]> wrote:
>>
>> > I am relatively new the python language and I am afraid to be missing
>> > some clever construc
> "Grant" == Grant Edwards <[EMAIL PROTECTED]> writes:
Grant> On 2007-12-19, abhishek <[EMAIL PROTECTED]> wrote:
>>> > Hi everyone, I am trying to generate a PDF printable format file from
>>> > an html page. Is there a way to do this using python. If yes then
>>> > which library and functions
Hi Breal
> I have a list that looks like the following
> [(10, 100010), (15, 17), (19, 100015)]
>
> I would like to be able to determine which of these overlap each
> other. So, in this case, tuple 1 overlaps with tuples 2 and 3. Tuple
> 2 overlaps with 1. Tuple 3 overlaps with
>>>>> "Duncan" == Duncan Booth <[EMAIL PROTECTED]> writes:
Duncan> Terry Jones <[EMAIL PROTECTED]> wrote:
>> Duncan Booth wrote:
Duncan> You'll kick yourself for not seeing it.
Duncan> If you changed fn_inner to:
Duncan> def fn_inner()
o
LOAD/STORE_DEREF?
I find it a bit disconcerting that the simple presence of a nested function
(even if never used) may trigger significant slowdown in variable access
for the rest of the code in the containing function. I'd be happy to know
how/when this happens. I know I probably shouldn't care, but I do.
Thanks,
Terry Jones
--
http://mail.python.org/mailman/listinfo/python-list
32 matches
Mail list logo