Having written something with similar purpose (https://github.com/aht/extproc),
here are my comments:
* Having command parsed from a string is complicated. Why not just have an OOP
API to construct commands? extproc does this, but you opted to write a
recursive descent parser. I'm sure it's
It's not hard for the user
I think most users like to use Python, or they'd use Bash. I think people
prefer not another language that is different from both, and having little
benefits. My own opinion of course.
Re. threads fork():
For a careful impl of fork-exec with threads, see
http://golang.org/src/pkg/syscall/exec_unix.go
I forgot to mention that this impl is indeed correct only because you cannot
start thread or call fork() directly in the Go language, other than use
goroutines and the ForkExec() function
On Monday, February 13, 2012 3:13:17 AM UTC+7, Vinay Sajip wrote:
On Feb 12, 3:35 pm, Anh Hai Trinh anh.hai.tr...@gmail.com wrote:
I think most users like to use Python, or they'd use Bash. I think people
prefer not another language that is different from both, and having little
Objection! Does the defense REALLY expect this court to believe that
he can testify as to how MOST members of the Python community would or
would not favor bash over Python? And IF they do in fact prefer bash,
is this display of haughty arrogance nothing more than a hastily
stuffed straw-man
I'd like to announce an early release of pc.py.
pc.py is a layer on top of subprocess. The subprocess module
supports a rich API but is clumsy for many common use cases,
namely sync/async fork-exec, command substitution and pipelining,
all of which is trivial to do on system shells.
The goal is
Anh Hai Trinh anh.hai.tr...@gmail.com added the comment:
I've written a package which can do this with arbitrary redirection in all
subcommands (and some more).
You can, for example, do this:
Pipe(Sh('echo -n foo 2', {2: 1}), Sh('cat; echo ERROR 2', {2:
os.devnull})).capture(1).read
On Feb 23, 1:03 pm, Alf P. Steinbach al...@start.no wrote:
Uhm, Paganini...
As I understand it he invented the destroy your instruments on stage. :-)
Cheers,
- Alf (off-topic)
You probably meant Franz Liszt, who regularly broke piano strings.
Paganini was also a rock-star virtuoso but he
On Feb 23, 10:08 am, Lawrence D'Oliveiro l...@geek-
central.gen.new_zealand wrote:
Let me suggest an alternative approach: use Python itself as the assembler.
Call routines in your library to output the code. That way you have a
language more powerful than any assembler.
See
On Feb 19, 1:44 pm, Steve Howell showel...@yahoo.com wrote:
def coroutine(co):
def _inner(*args, **kwargs):
gen = co(*args, **kwargs)
gen.next()
return gen
return _inner
def squares_and_cubes(lst, target):
for n in lst:
target.send((n * n, n
On Feb 4, 10:46 am, John Nagle na...@animats.com wrote:
There's enough intercommunication between the threads working on
a single site that it's a pain to do them as subprocesses. And I
definitely don't want to launch subprocesses for each page; the
Python load time would be worse than
On Jan 18, 6:03 pm, Phlip phlip2...@gmail.com wrote:
On Jan 12, 7:09 am, ikuta liu ikut...@gmail.com wrote:
Go language try to merge low level, hight level and browser language.
Go uses := for assignment.
Except that it doesn't. := is a declaration.
s := foo
is short for
var s string =
I am pleased to announce that stream 0.8 is available.
Stream is a module that lets one express a list-processing task as a
pipeline and provide ways to easily parallelize it.
An introductory article is available at http://blog.onideas.ws/stream.py.
The reference documentation can be viewed
On Dec 19, 5:47 am, Bearophile bearophileh...@lycos.com wrote:
It seems you have missed my post, so here it is, more explicitly:
http://www.boostcon.com/site-media/var/sphene/sphwiki/attachment/2009...
Interestingly, my `listagent` can be used as a lazy iterator and thus
using itertools we
On Dec 20, 12:04 am, Anh Hai Trinh anh.hai.tr...@gmail.com wrote:
chain:
sorted(itertools.chain(listagent(x)[::2], listagent(y)[-1:1:-2]))
[0, 4, 8, 12, 13, 15, 16, 17, 19]
zip:
sorted(itertools.izip(listagent(z)[1::3], listagent(x)[2::3]))
[(452, 16), (758, 4), (898, 10)]
I
On Dec 18, 3:07 am, Brendan Miller catph...@catphive.net wrote:
Well, it doesn't really need to be any slower than a normal list. You
only need to use index and do extra additions because it's in python.
However, if listagent were written in C, you would just have a pointer
into the contents
I have a couple of thoughts:
1. Since [:] by convention already creates a copy, it might violate
people's expectations if that syntax were used.
Indeed, listagent returns self on __getitem__[:]. What I meant was
this:
x = [0, 1, 2, 3, 4, 5, 6, 7]
a = listagent(x)[::2]
a[:] =
On Dec 16, 10:39 am, Brendan Miller catph...@catphive.net wrote:
I was trying to reimplement some of the c++ library of generic
algorithms in c++ in python, but I was finding that this is
problematic to do this in a generic way because there isn't any
equivalent of c++'s forward iterators,
On Dec 16, 2:48 pm, Brendan Miller catph...@catphive.net wrote:
No, that's what I'm getting at... Most of the existing mutating
algorithms in python (sort, reverse) operate over entire collections,
not partial collections delimited by indexes... which would be really
awkward anyway.
Ok it
from numpy import s_
s_[1:2:3]
slice(1, 2, 3)
s_[1:2:3, ..., 4:5]
(slice(1, 2, 3), Ellipsis, slice(4, 5, None))
Or would it be possible to define slice itself so that it implements
__getitem__ and __getslice__?
Indeed!
Python 2.6.4 (r264:75706,
I'm just curious which formula for pi is given here: http://
docs.python.org/library/decimal.html#recipes?
def pi():
Compute Pi to the current precision.
print pi()
3.141592653589793238462643383
getcontext().prec += 2 # extra digits for intermediate steps
three =
1) google list of prime numbers
2) see Prime numbers list in the results (number 3 in the results)
3) click link that leads towww.prime-numbers.org
I found 455042511 prime numbers in approx 15 seconds.
Not bad at all. How about using http://www.sagemath.org/ (written in
Python).
sage:
Yes, just about any ‘map()’ operation has a corresponding list
comprehension. (Does anyone know of a counter-example, a ‘map()’
operation that doesn't have a correspondingly simple list
comprehension?)
Try turning this into a list comprehension:
vectorsum = lambda *args: map(sum,
On the other hand, list comps using an if clause can't be written as pure
maps. You can do this:
[func(x) for x in seq if cond(x)]
filter(cond, map(func, seq))
but the second version may use much more temporary memory if seq is huge
and cond very rarely true.
You could use ifilter, imap
Try turning this into a list comprehension:
vectorsum = lambda *args: map(sum, zip(*args))
vectorsum([1,2], [3,4], [5,6])
-[9, 12]
vectorsum([1,2], [3,4], [5,6], [7,8])
-[16, 20]
Nvm, it's actually easy:
vectorsum = lambda *args: [sum(i) for i in zip(*args)]
--
I've written something that is better than you could've imagine.
Get it here: http://github.com/aht/stream.py
It works with anything iterable, no need to alter anything.
from itertools import count
from stream import item
c = count()
c item[1:10:2]
-[1, 3, 5, 7, 9]
c item[:5]
-[10,
Changes by Anh Hai Trinh anh.hai.tr...@gmail.com:
--
nosy: +aht
versions: +Python 2.6
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6280
Does it have any advantage to generator comprehension?
import re
mm = mapmethod('strip') # Is mapmethod something in the stdlib?
pat = re.compile('[Pp]attern')
result = (mm(line) for line in open('log') if pat.search(line))
which is also lazy
Generator expression accomplishes the
Hello all,
I just want to share with you something that I've worked on recently.
It is a library which implements streams -- generalized iterators with
a pipelining mechanism and lazy-evaluation to enable data-flow
programming in Python.
The idea is to be able to take the output of a function
29 matches
Mail list logo