time.sleep(1) and try again. This kind of locking works cross
platform too. You can use it in shell too, eg "mkdir /tmp/lock ||
exit 1" in your cronjob.
You could wrap the locking up into a module of course, and I bet
someone already did.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
)
f.close()
os.rmdir(lock_file)
print "Done!"
You need to do the same thing to the program which currently creates
transfer.lock - so it waits if the transfer.lock is in existence too.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
tence in speech:
print sentence.rstrip('\n')
sys.stdout.flush() # sanity check
else: # EOF
speakers.remove( speaker )
gives
b
o
x
1
b
o
x
3
b
o
x
2
pause...
g
o
o
d
b
y
e
etc...
I'm not sure why readline only returns 1 cha
g xml.minidom?
I've spend some time searching the docs/code/google but I haven't
found the answer to this question!
Thanks
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
>
> > I'm using xml.minidom to parse some of our XML files. Some of these
> > have entities like "°" in which aren't understood by xml.minidom.
>
> ° is not a standard entity
system).
Thanks and look forward to the release
Nick
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
en
> implicitly
None I'd say! Perhaps make a less laborious manual conversion
function, but I don't think implicit conversion is that useful since
decimal and gmpy are solving quite different problems.
Implicit conversions also opens the can of worms - what is the
preferred promotion type?
hecker
catches, so install pychecker and run it on all your programs is the
answer!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
he symbols from the import back in
for name in dir(module):
if not (name.startswith("__") and name.endswith("__")):
setattr(parent, name, getattr(module, name))
# Restore sys.path
sys.path = old_sys_path
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Peter Otten <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
>
> > I'd really like to be able to run an __import__ in the context of the file
> > thats running the include() but I haven't figured that out.
>
> execfile()?
Yes thats exactly what
ll the cmp function N log N times. Its expensive in
terms of memory though.
With python 2.4 you can wrap it up into one line if you want
[ x[-1] for x in sorted([ (x[1],x) for x in lst ]) ]
or even
[ x[-1] for x in sorted((x[1],x) for x in lst) ]
--
Nick Craig-Wood <[EMAIL PROTECTED
Neil Hodgson <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood:
>
> > Since no-one mentioned it and its a favourite of mine, you can use the
> > decorate-sort-undecorate method, or "Schwartzian Transform"
>
> That is what the aforementioned key argument
al port.
You need to set the serial port up not to do automatic handshaking
first (eg setDsrDtr() & setRtsCts())
RS232 levels are +/- 12V, though a lot of computers only generate +/-
5V. The threshold is +/- 3V IIRC.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.
bit OS though.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
search *= 2
lines = lines[-nlines-1:]
print "\n".join(lines)
if __name__ == "__main__":
if len(sys.argv) != 3:
print "Syntax: %s n file" % sys.argv[0]
else:
main(int(sys.argv[1]), sys.argv[2])
--
Nick Craig-Wood &
etc.
[sorry not Python related but may solve your problem!]
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
# raise NoMimeError
return t[0]
for f in ("index.php", "index.php3", "prog.cc", "prog.cpp", "flodge.xsl",
"Makefile", "myMakefile", "potato.123"):
print f, detectMimeType(f)
...
prints
index.php applicatio
2.2.3-10 An interactive high-level object-oriented la
ii python2.3 2.3.4-18 An interactive high-level object-oriented la
ii python2.4 2.4-2 An interactive high-level object-oriented la
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
unstable -> testing (and eventually) -> stable.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Cast5+6, DES, Serpent,
Twofish, TEA, etc. The linux kernel+source surely goes everywhere
python does so I don't think adding strong crypto modules to python is
a problem now-a-days.
AES in the core python library would be very useful and it would
discourage people from writing the
Why is that?
Its a bug!
http://sourceforge.net/tracker/index.php?func=detail&aid=720908&group_id=5470&atid=105470
However its been fixed in a recent Python 2.3.
(I was bitten by the same thing which used to fail but now works after
an upgrade of python 2.3!)
--
Nick Cr
Note that some of these are being worked on at sourceforge just like
python.
Surely it must be possible to add a few simple crypto modules to
python?
That said
a) IANAL
b) 'apt-get install python-crypto' works for me ;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
use this old trick...
a, b, c = (line+"::").split(':')[:3]
Or this version if you want something other than "" as the default
a, b, b = (line.split(':') + 3*[None])[:3]
BTW This is a feature I miss from perl...
--
Nick Craig-Wood <[EMAIL PROTECTED]>
Alex Martelli <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> ...
> > Or this version if you want something other than "" as the default
> >
> > a, b, b = (line.split(':') + 3*[None])[:3]
>
>
7;, line)):
do_add(m.value.group(1), m.value.group(2))
elif m.set(re.search(r'mult (\d+) (\d+)', line)):
do_mult(m.value.group(1), m.value.group(2))
elif m.set(re.search(r'help (\w+)', line)):
show_help(m.value.group(1))
--
Nick Craig-Wood <[EMAIL PROTECTED]> --
ming(), 4)
return result
PS interesting thread - never heard of Hamming sequences before!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
, hamming5) ):
yield n
hamming2, hamming3, hamming5, result = tee(_hamming(), 4)
return result
(Note the iter(...) seemed not to be doing anything useful so I
removed them)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
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):
> >
code]
Thanks for some more examples of fp-style code. I find it hard to get
my head round so its been good exercise!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
order()] * 7
> py> ', '.join(orders)
> 'Spam, Spam, Spam, Spam, Spam, Spam, Spam'
Thats still one Viking making 7 orders surely?
Eg
>>> vikings = [Viking()] * 7
>>> vikings[0] is vikings[1]
True
whereas
>>> vikings = [Viking() for _ in rang
;>> raise MyOldException
Traceback (most recent call last):
File "", line 1, in ?
__main__.MyOldException: <__main__.MyOldException instance at 0xb7df4cac>
>>>
After that I recalled a thread on python-dev about it
http://mail.python.org/pipermail/python-dev
it -s'import operator; string =
"abcdefghij13123kj12l3k1j23lk12j3l12kj3"' \
'reduce(operator.xor, map(ord, string))'
10 loops, best of 3: 15.6 usec per loop
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Philip Smith <[EMAIL PROTECTED]> wrote:
> I understand the algorithm quite well but how to code the multiplication
> stage most efficiently in python eludes me.
You might want to look at
http://gmpy.sourceforge.net/
It has very fast multiplication up to any size you like!
--
ng wrong.
>
> While not a 'real' answer - I use pexpect to automate my ssh scripts
> these days as I had a few problems using ssh with the os.* family
> perhaps you may find pexpect a wee bit easier...
If using 2.4 the subprocess module is a good solution
ome up with, via
Google's Cache.
http://www.google.com/search?q=cache:U5-RsbkSs0MJ:www.cs.chalmers.se/Cs/Grundutb/Kurser/krypto/lect04_4.pdf
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
depend on any other
library or application.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
API. The cryptkit way is better than ECB
> example I gave, but the ECB example shows it's possible to do it in
> one call.
There is a PEP about this...
API for Block Encryption Algorithms v1.0
http://www.python.org/peps/pep-0272.html
--
Nick Craig-Wood <[EMAIL PROTEC
.
...it also uses python for its control programs.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
sions of
DES for instance).
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
tation which is only available in
HTML format - I'd much rather type "pydoc whatever" to see it all,
rather than have to load my browser, and click through several layers
of web pages.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
n Python would make a much better first language than
FORTH. The batteries included approach make a young programmers life
much, much more fun, rather than starting from almost nothing (in
modern terms) with FORTH.
And like FORTH, Python has the interactive console which is essential
when starting out.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
iment TCP yourself.
Actually I'd recommend the OP uses UDP, not TCP. I've implemented a
few systems which speak UDP directly and its very easy. I wouldn't
like to implement TCP though!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
analogous to this...
>>> int(100L)
100L
> Wouldn't also a new function make the intent clearer?
>
> So I think I'm +1 on the text() built-in, and -0 on changing str.
Couldn't basestring() perform this function? Its kind of what
bases
elected at compile time using
C Macro magic.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Scott David Daniels <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> > Splitting the GIL introduces performance and memory penalties
> > However its crystal clear now the future is SMP. Modern chips seem to
> > have hit the GHz barrier, and now the
hip. It's the most radical multicore
design to date from a mainstream server processor manufacturer and
arrives more or less on time.
It goes on later to say "The physical processor has 8 cores and 32
virtual processors" and runs at 1080 MHz.
So fewer GHz but more CPUs is the fu
er /proc/interrupts | awk '{print $2}'`; echo $(($end-$start))
Which prints a number about 1000 on my 2.6 machine.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
5sum(files):
for filename in files:
try:
print "%s %s" % (md5file(filename), filename)
except IOError, e:
print >> sys.stderr, "Error on %s: %s" % (filename, e)
if __name__ == "__main__":
md5sum(sys.argv[1:])
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
0 176 °
> de 222 Þ
> 8a 138
> e3 227 ã
> b5 181 µ
> b7 183 ·
> 51 81 Q
> a7 167 §
> c4 196 Ä
> d8 216 Ø
> e9 233 é
> ed 237 í
> eb 235 ë
>
> which is not even close, and yes, I know that it's not the same
> code.
Actually the hex digi
27;... or die "You [EMAIL PROTECTED]"'
works even better ;-)
Thanks for a very amusing post!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ile = open(fn, "rb")
>>> size = os.path.getsize(fn)
>>> size
8590983168L
>>> hash = md5.md5(mmap.mmap(file.fileno(), size)).hexdigest()
Traceback (most recent call last):
File "", line 1, in ?
OverflowError: memory mapped size is too large (limited by C int)
>>>
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Thomas Heller <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood <[EMAIL PROTECTED]> writes:
> > Here is an implementation of md5sum in python. Its the same speed
> > give or take as md5sum itself. This isn't suprising since md5sum is
> > dominated by CPU usage
ble objecst is the comparability. In java, this is done using the
> equals method.
>
> So in the end, the actual mapping of key, value looks like this:
>
> hash(key) -> [(key, value), ]
Thats called hashing with chaining.
See Knuth: Sorting and Searching if you want to kno
)
[(1, 4), (2, 5), (3, 6)]
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
gt;
> Emacs + CVS (or CVSNT) should work just fine in Windows either.
When I have to edit stuff on windows I use emacs. Cvs works fine on
windows too. I haven't tried cvs in emacs on windows, but I suspect
it will work fine as all emacs does is shell out to the cvs binaries.
--
Nick
Christos TZOTZIOY Georgiou <[EMAIL PROTECTED]> wrote:
> On 09 Feb 2005 10:31:22 GMT, rumours say that Nick Craig-Wood
> <[EMAIL PROTECTED]> might have written:
>
> >But you won't be able to md5sum a file bigger than about 4 Gb if using
> >a 32bit processor (
else:
# do stuff when not found
The last language I saw with this very useful feature was FORTH in
about 1984!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
indows) on a linux
build host. The windows builds are done with a mingw cross compiler.
It would be interesting if we could do this with python + extensions
also.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
lds are done with plain gcc of course.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Yes. Unless you work in the telcoms industry, where, for example if
you order a 2 Mbit/s line you'll get
2 * 1024 * 1000 bits / s
;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ners with one-liners.
c) add a documentation patch
d) add a test suite patch
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ish (being lazy) that there was a seperate
debian package for just it and not the whole of Zope.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
er method to do this? I propose joinany which will
join any type of object together, not just strings
That way it becomes less of a poke in the eye to backwards
compatibility too.
> Nick "Explicit is better than Implicit"
Aye!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http:
f and fcntl is
unspecified.)"
see man lockf and man flock
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
he data you want to pass is structured then you might consider
XML-RPC which is a cross platform way of passing structured data
around. XML-RPC is part of the python standard library
(SimpleXMLRPCServer and xmlrpclib) and there seem to be several
implementations for PHP
http://www.google.co.uk/sea
y the get method) which is often the encapsulation you
really want - and that is something you can't do in C++.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Cameron Laird <[EMAIL PROTECTED]> wrote:
> gf, remember to write
>
>sys.stdout.flush()
>
> rather than
>
>sys.stdout.flush
>
> That's a mistake that catches many.
Many old perl programmers anyway (me included)!
Its also a mistake pychecker
pe (like the warnings subsystem).
This is surely a job for pychecker / pylint?
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ept the right operand: when an instance of
a given class is expected, an instance of a subclass of that class
is always acceptable.
You could try this with a local copy of decimal.py since it is
written in Python.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Dan Sommers <[EMAIL PROTECTED]> wrote:
> On 28 Feb 2005 10:30:03 GMT,
> Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
>
> > Actually I would say just access the attribute directly for both get
> > and set, until it needs to do something special in which case use
complicated code into a method with a useful name,
or add well named intermediate variables, or add an assertion.
Its a point of view... Not 100% sure I agree with it but I see where
he is coming from. I like a doc-string per public method so pydoc
looks nice myself...
--
Nick Craig-Wood <[
t|in|t|ts)|ret(?:ch|ry)|re(?:use|v)|rev's|rev(?:el|s|ue)
As you can see its not perfect.
Find it in http://www.craig-wood.com/nick/pub/words-to-regexp.pl
Yes its perl and rather cludgy but may give you ideas!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
7 S+ 0:00 \_ sh -c sleep 60 > z
5150 pts/77 S+ 0:00 \_ sleep 60
Things to check
1) quoting, python vs shell
2) PATH - check PATH is set the same in shell / python
3) check the whole of the environment
Also if you are using 2.4 check the subprocess module
was
forever blowing up the server with scripts which used too much memory.
sort was always the solution!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
e, and selecting that output
file as the default for print() statements.
The solution posted previously using mmap actually does it in-place
though which will work very well for files < 4GB. (And not at all for
files > 4GB unless you are on a 64 bit machine).
--
Nick Cra
s will complain about removals, but we'll knuckle
down and take our medicine eventually ;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
st ram it in a hash, and write lots of functions acting
on it) rather than creating a specific class for the job which is dead
easy in python anyway and to which you can attach methods etc.
YMMV ;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Steven Bethard <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> > Steven Bethard <[EMAIL PROTECTED]> wrote:
> >
> >> I promised I'd put together a PEP for a 'generic object' data type for
> >> Python 2.5 that allows one to replac
Scott David Daniels <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> > class Hash:
> > def __init__(self, **kwargs):
> > for key,value in kwargs.items():
> > setattr(self, key, value)
> > def __getitem__(self, x):
> >
eading to the critical
> difference in this case:
I think I finally understand now - thank you to you both!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
orlds
If someone did wrap PARI in python it would certainly be easier to use
than GP which I found very unintuitive!
In fact I just found this which looks like just the job!
http://www.fermigier.com/fermigier/PariPython/readme.html
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://
area of computer science! Its also rather big
and expensive so you'll probably want to look at in the library...
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
e
l
l
o
...and this works because str supports __getitem__ according to the
docs.
So there is some magic going on here! Is str defined to never have an
__iter__ method? I see no reason why that it couldn't one day have an
__iter__ method though.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
doesn't
catch any exceptions it shouldn't)
def flatten( i ):
if hasattr(i, "__iter__"):
for j in i:
for k in flatten(j):
yield k
else:
yield i
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Robert Kern <[EMAIL PROTECTED]> wrote:
> Personally, I loathe writing at any length inside a Web browser and
> prefer to use a real editor at all times.
Me too! You need mozex...
http://mozex.mozdev.org/
Not sure about Mac support though
/OT
--
Nick Craig-Wood <[
Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> Robert Kern <[EMAIL PROTECTED]> wrote:
> > Personally, I loathe writing at any length inside a Web browser and
> > prefer to use a real editor at all times.
>
> Me too! You need mozex...
>
>http://mozex
l(["ls", "-l"])
total 381896
-rw-r--r--1 ncw ncw 1542 Oct 12 17:55 1
[snip]
-rw-r--r--1 ncw ncw 713 Nov 16 08:18 z~
>>> print rc
0
IMHO the new subprocess module is a very well thought out interface...
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Keith Dart <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> > This sounds rather like the new subprocess module...
> >
> >>>>import subprocess
> >>>>rc = subprocess.call(["ls", "-l"])
> >
> > total 381896
dvert
for AMD ;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
7;++', '--'.
>
> It does already.
>
>
$ cat plusplus.py
def main():
i = 1
return ++i
$ pychecker plusplus
Processing plusplus...
Warnings...
plusplus.py:4: Operator (++) doesn't exist, statement has no effect
--
Nick Craig-Wood <[EMAIL PROTECTED]>
in
range(1000)])' 'map = {}
for key, value in sequence:
if map.has_key(key):
map[key].append(value)
else:
map[key] = [ value ]'
1000 loops, best of 3: 1.11e+03 usec per loop
Not that timing is everything of course ;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ying around instead which is much more
flexible than perl. You can even pass self.__dict__ if you are in a
class method so you can access attributes.
>>> class A: pass
...
>>> a=A()
>>> a.amount=10
>>> a.what="rutabaga"
>>> a
Jim Hill <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> >I prefer this
> >
> > ... I'll have %(amount)s %(what)s
> > ... for $%(cost)s please""" % locals()
>
> Looks pretty slick. This might just be what I need.
>
;float $1\n";
}
else {
print "unknown thing $line\n";
}
Is there an easy way round this? AFAIK you can't assign a variable in
a compound statement, so you can't use elif at all here and hence the
problem?
I suppose you could use a monstrosity like this, which relies on
.
xml = re.compile(r"""
<([/?!]?\w+) # 1. tags
|&(\#?\w+); # 2. entities
|([^<>&'\"=\s]+) # 3. text strings (no special characters)
|(\s+) # 4. whitespace
|(.) # 5. special characters
""&quo
mentation.
This is probably what Windows people look at by default but Unix
hackers like me expect everything (or at least a hint) to be in the
man/pydoc pages.
Just noticed in pydoc2.4 a new section
MODULE DOCS
http://www.python.org/doc/current/lib/module-sre.html
Which is at least a hint that you are looking in the wrong place!
...however that page doesn't exist ;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
. Processes can share this integer over
mmap, via shared segments or because they share memory space, in which
case the application is commonly called multithreaded.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Paul Rubin wrote:
> Nick Craig-Wood <[EMAIL PROTECTED]> writes:
> > I believe futex is the thing you want for a modern linux. Not
> > very portable though.
>
> That's really cool, but I don't see how it can be a pure userspace
> operation if the futex
mode=thread&noheader=1&q=queue+timeout+python#doc_011f680b2dac320c
Interesting thread.
How about leaving the current threading alone, but adding a pthreads
module for those OSes which can use or emulate posix threads? Which is
windows and most unixes?
--
Nick Craig-Wood <[EMAIL PROTECTED]&g
172b1b50474351364749a33996a81ba8847347a8411b850b79a03018291672aa0945656a159aa6aa0a845531a592005b8a34366b882257107b190969a846474836a9800750778920ba797297a2791101b0685a86bb704b9baa17b055293679843b35215b0a8b1182b611953b080aa5431b219907a8448a81b1a9493245676b88013b470335240859594158621014216!
619553246570601967448b470174b9244892444817453865a4003b5aa7176451aab906
[EMAIL PROTECTED]'
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
1 - 100 of 641 matches
Mail list logo