James Stroud <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> > Did anyone write a contextmanager implementing a timeout for
> > python2.5?
> >
> > I'd love to be able to write something like
> >
> > with timeout(5.0) as exceeded
to kill one thread from another thread. There is a
ctypes hack to do it, which sort of works... It needs some core
support I think.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> On Mon, 26 Mar 2007 16:50:33 +0200, Thomas Dybdahl Ahle <[EMAIL PROTECTED]>
> wrote:
> >Den Mon, 26 Mar 2007 06:30:04 -0500 skrev Nick Craig-Wood:
> >> Under linux the only priviledge you need is CAP_NET_RAW. It i
; command as ordinary user.
>
> The workaround your ping command is using btw, is probably running
> suid root.
Under linux the only priviledge you need is CAP_NET_RAW. It is
possible to give this to a process - a bit of searching with google
will show you how!
--
Nick Craig-Wood <[EM
ss platform way!
>From my experiments with timeouts I suspect it won't be possible to
implement it perfectly in python 2.5 - maybe we could add some extra
core infrastructure to Python 3k to make it possible?
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/ni
password, eg...
$ svn ls svn+ssh://[EMAIL PROTECTED]/svn /dev/null 2>&1
Password:
I don't know exactly how it does that but I suspect it is to do with
the controlling terminal...
On my system
$ setsid svn ls svn+ssh://[EMAIL PROTECTED]/svn /dev/null 2>&1
Pops up a gui box askin
any fragmentation worries.
However if you have lots of small allocations then the heap will be
fragmented and you'll never be able to return the memory to the OS.
However that is why we have virtual memory systems.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
quot;ls -l")
6
>>> s.prompt()
True
>>> print s.before
ls -l
total 30944
-rw-r--r-- 1 user user 936 Nov 3 14:52 #z.c#
[snip]
-rw-r--r-- 1 user user 221 Jan 30 11:51 z~
>>> s.logout()
>>>
I'm using the debian packaged version 2.1-1 with python 2.4
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ert data into dictionary
You could try Construct
http://construct.wikispaces.com/
This allows you to build a python class which will translate to and
from that datastructure.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
t goes round the while loop on average 0.5 times.
If 0 isn't required then just test for it and go around the loop again
if found. That of course skews the distribution in difficult to
calculate ways!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http:/
Robert Marshall <[EMAIL PROTECTED]> wrote:
> On Fri, 09 Mar 2007, Bruno Desthuilliers wrote:
>
> >
> > Nick Craig-Wood a ?crit :
> >> [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >>> What if 2 new 'special' comment-like character
. ''' and ''' (if you normally use
""" """ for docstrings)
Python just ignores strings that lie around.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
well the problem I have only occurs when my python app. is running as a
Windows Service. if I run the python app. as a process (i.e. from the
command line) it works as epxected via Remote Desktop.
still not sure what's going on.
On 2/28/07, Sick Monkey <[EMAIL PROTECTED]> wrote:
I have just
see
that in a daemonize recipe before?
> else:
> # time for child to die
> os._exit(0)
> else:
> # wait for child to die and then bail
> os.wait()
> sys.exit()
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Delaney, Timothy (Tim) <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
>
> > x += a
> >
> > does not equal
> >
> > x = x + a
> >
> > which it really should for all types of x and a
>
> Actually, this will *never* be t
eError: can only concatenate list (not "tuple") to list
>>>
Ie
x += a
does not equal
x = x + a
which it really should for all types of x and a
(That is the kind of statement about which I'm sure someone will post
a perfectly reasonable counterexample ;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
by a dummy request, which seems a bit awkward.
Can't you get SocketServer to timeout and return you control
regularly?
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
John Pye <[EMAIL PROTECTED]> wrote:
> On Feb 19, 6:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> > John Pye <[EMAIL PROTECTED]> wrote:
> > > application from running on the Debian Etch AMD64 platform.
> > > It seems that the 'dl' mo
nd for this -- perhaps another way to
> access the values of those RTLD flags?
Read stuff out of /usr/include/bits/dlfcn.h ?
It seems to be a constant 1 anyway
#define RTLD_LAZY 0x1
You could try compiling the dl module by hand.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http
it would be more elegant...
>>> n = 1
>>> for i in range(16):
... print ("%X" % n).replace('0', ' ').replace('1', '*')
... n = n ^ (n << 4)
...
*
**
* *
* *
** **
* * * *
* *
** **
* * * *
* * * *
** ** ** **
* * * * * * * *
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
016001
>>> start = cpu_time(); f(); dt = cpu_time() - start; print dt
0.012001
>>> start = cpu_time(); f(); dt = cpu_time() - start; print dt
0.008001
You'll see the result is quantised to 4 ms (not sure what the .01
bits are about!)
4ms is the clock rate of this machine,
ot;
total = x
power = x
divisor = 1
old_delta = None
while 1:
power *= x
power *= x
power = -power
divisor += 2
old_total = total
total += power / divisor
delta = abs(total - old_total)
if old_delta is not None and
under windows you get a quite different
result :-
>>> from time import clock, time
>>> print clock(), time()
7.54285810068e-006 1169574534.84
>>> print clock(), time()
3.32073322168 1169574538.16
>>> print clock(), time()
7.32428004118 1169574542.15
r there is something
going on in your program that we don't know about or there is a bug
somewhere, either in the OS or in python.
Can you make a short program to replicate the problem? That will help
narrow down the problem.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-
a MemoryError. It is asking for
a new bit of memory and it is failing so it throws a MemoryError.
Could memory allocation under windows be affected by a large chunk of
mmap()ed file which is physically swapped in at the time of the
allocation?
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- h
e written out if dirty
and then dropped.
The OS will try to keep hold of pages as long as possible just in case
you need them again. The pages dropped should be the least recently
used pages.
I wouldn't have expected a MemoryError though...
Did you do mmap.flush() after writing?
--
Nick C
t?
You might want to check out this modification to subprocess which does
non-blocking pipes.
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554
I personally think something like that should be built into subprocess
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.crai
)
def pi_ferguson():
return 4*(3*arctan(_1/4) + arctan(_1/20) + arctan(_1/1985))
def pi_hutton():
return 4*(2*arctan(_1/3) + arctan(_1/7))
def pi_gauss():
return 4*(12*arctan(_1/18) + 8*arctan(_1/57) - 5*arctan(_1/239))
def pi_euler():
return 4*(5*arctan(_1/7) + 2*arctan(_3/79))
pi in 0.1 seconds and 10,000 digits in 20 seconds.
"""
Standalone Program to calculate PI using python only
Nick Craig-Wood <[EMAIL PROTECTED]>
"""
import sys
from time import time
class FixedPoint
sys 0m0.068s
> # I used python2.5 and perl 5.8.6
Playing for the other side temporarily, this is nearly twice as fast...
$ time perl -lne 'print if m/destroy/oi' bigfile >pl.out
real0m0.133s
user 0m0.120s
sys 0m0.012s
vs
$ time ./z.pl >pl.out.orig
conversions by hand. It is a bit
tedious but a good editor with macros will let you fly through the
job. I used emacs.
--
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:
>
> > A regular expression matcher uses a state machine to match strings.
>
> unless it's the kind of regular expression matcher that doesn't use a
> state machine, like the one in Pyt
achine
generating all possible matches at each point.
Luckily the python regexp matcher is written in python, so you have
access to the state machine directly if you want.
Take a look at sre*.py in the python library and you might be able to
work out what to do! I had a brief look myself, and it
looked
oto err;
}
label[i] = xstrdup(item_cstr);
Py_DECREF(item);
item = 0;
[snip]
err:;
PyErr_Print();
out:;
if (value)
Py_DECREF(value);
if (item)
Py_DECREF(item);
return rc;
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
as overwritten.
Maybe it is a string you can identify... You'll also want to start
reading the gdb manual on breakpoints and watchpoints at this moment!
Find memory corruptions can be tricky and time consuming.
Valgrind can help also.
Good luck!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
not post the output.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ent and accurate style -
this matches the next character which gets added back into the string.
>>> re.sub(r",([^\s])", r", \1", s)
'One, Two, Three, Four, File'
>>>
This shows a fundamental difference between the two methods
>>> t
Rob <[EMAIL PROTECTED]> wrote:
> Craig,
>
> In the embedded firmware, the each box re-transmits after it finishes
> reading the packet. This is a very rudimentary system, and uses no
> flow control. The topology is that each embedded box has a master and
> a slave p
ill tell you how to use it.
I've broken a lot of serial port drivers with that program ;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
):
"""Quote all the metacharacters in the args for the unix shell"""
return " ".join([re.sub(r"([^A-Za-z0-9_])", r"\\\1", string) for string in
args])
>>> print quotemeta(['a', "'b", 'c'])
a \'b c
> (or better, subprocess.call).
A good idea!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
not
> limited to use the generic *args and **kw.
If you don't want to use a register() function on each class you could
introspect like this (untested) to make the registry :-
registry = {}
for obj in sys.modules[__name__].__dict__.values():
try:
if issubclass(obj, Base):
Terry Reedy wrote:
> "Craig" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Thanks so much for the response. I have an array of individual bytes
> > which will eventually make up a binary bitmap image that is loaded onto
> > an LCD sc
Matimus wrote:
> Craig wrote:
> > I'm trying to switch binary numbers around so that the MSB becomes the
> > LSB etc.
>
> What do you mean 'binary numbers'? They are all binary. If you mean the
> int type, they are 32 bits long and there are 16 bit
Hi there,
I'm trying to switch binary numbers around so that the MSB becomes the
LSB etc. Is there an easy way of doing this as I can't seem to find
anything. If you could help that would be great. Thanks and good
luck.
Craig
--
http://mail.python.org/mailman/listinfo/python-list
uages like Python when used in a web environment.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
p://pexpect.sourceforge.net/
>>> import pexpect
>>> p = pexpect.spawn("python")
>>> p.expect(">>>")
0
>>> p.sendline("print 10\n")
10
>>> p.readline()
' print 10\r\n'
>>> p.readline()
'10\r\n&
1000(0xBC). Is there an easy way to flip the bits
after the im.tobitmap() conversion has been done or do I have to find
another way? If you could help that would be greatly appreciated.
Thanks and good luck.
Craig
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik Lundh wrote:
> Craig wrote:
>
> > I'm trying to open colour BMPs using PIL and I'm getting the following
> > errors.
>
> what program did you use to produce those BMP files? can you prepare
> reasonably small samples using the same program and post
o read the return code of the command and
its stderr both of which you'll need if you are programming
defensively!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
packages\PIL\BmpImagePlugin.py", line 164,
in _open
self._bitmap(offset=offset)
File "C:\python25\lib\site-packages\PIL\BmpImagePlugin.py", line 96,
in _bitmap
raise IOError("Unsupported BMP header type (%d)" % len(s))
IOError: Unsupported BMP header type (108)
>>>
I am using Windows XP with Python 2.5. I can open monochrome BMPs fine
but I don't want that. If you could help that would be greatly
appreciated. Thanks and good luck.
Craig
--
http://mail.python.org/mailman/listinfo/python-list
can be used
to fulfil the task. If you could let me know that would be great.
Thanks and good luck.
Craig
--
http://mail.python.org/mailman/listinfo/python-list
or x in range(0,12):
(x + 3) & ~0x3
Which prints 0,4,4,4,4,8,8,8,8,12...
You could also consider the funky
x>>2<<2
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Martin v. Löwis <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood schrieb:
> > So it looks like python mkdir() is applying the umask where as
> > /bin/mkdir doesn't. From man 2 mkdir
>
> Actually, mkdir(1) has no chance to not apply the umask: it also
> has to us
os.mkdir() ?
>
> No, I didn't. What is the difference/advantage of that approach?
If you use use os.umask(0) then the os.mkdir(dir, perms) will create
the directory with exactly those permissions, no chmod needed.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
st'
Size: 4096Blocks: 8 IO Block: 4096 directory
Device: 806h/2054d Inode: 2453906 Links: 2
Access: (0770/drwxrwx---) Uid: ( 518/ ncw) Gid: ( 518/ ncw)
Access: 2006-12-02 09:48:04.0 +
Modify: 2006-12-02 09:48:04.0 +
Change: 2
mkdir() works just like its C equivalent, see
> http://docs.python.org/dev/lib/os-file-dir.html:
>
> "Where it is used, the current umask value is first masked out."
>
> Use os.chmod() after os.mkdir() to get the desired permissions.
I think you meant use os.umask(0) befor
raise IOError("Unsupported BMP compression (%d)" % compression)
IOError: Unsupported BMP compression (1)
I can open a windows monochrome bitmap fine using PIL but the colour
options are more desirable. I am using Windows 2000 if that is any
help and I am saving the different BMP's using Microsoft Paint. If you
could help that would be great.
Craig
--
http://mail.python.org/mailman/listinfo/python-list
quot;"
end_time = time() + timeout
output = ""
while time() < end_time:
try:
output += p.stdout.read(1024)
except IOError, e:
if e.errno != EAGAIN:
raise
return output
p.stdin.write("ls\n")
print read_output(p)
p.stdin.write("uname -a\n")
print read_output(p)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Mitja Trampus <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> > I'm not sure how you do open stdout to /dev/null in python though!
> > I suspect something like this...
> > import posix
> > posix.close(1)
> > posix.open("/dev/null",
ly. What can I do to make the code correct
and the output being 100% correct as well. Any help would be greatly
appreciated.
Craig
--
http://mail.python.org/mailman/listinfo/python-list
Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Tue, 28 Nov 2006 04:30:09 -0600, Nick Craig-Wood
> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
>
> >
> > If you run this
> >
> > import os,sys,time
> > print
eamonisation under unix.
I'm not sure how you do open stdout to /dev/null in python though!
I suspect something like this...
import posix
posix.close(1)
posix.open("/dev/null", posix.O_WRONLY)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
John Machin wrote:
> Craig wrote:
>
> > Great. Got that sorted. The problem I have now is that some of the
> > XML data is not copied across to the file when I have the text
> > information included. The number of characters that is lost is equal
> > to the numbe
Diez B. Roggisch wrote:
> Craig schrieb:
> > Fredrik Lundh wrote:
> >
> >> Craig wrote:
> >>
> >>> I'm only new to Python so please bear with me. I using ElementTree to
> >>> generate an XML file that will reference a DTD and an XSL
Fredrik Lundh wrote:
> Craig wrote:
>
> > I'm only new to Python so please bear with me. I using ElementTree to
> > generate an XML file that will reference a DTD and an XSL file. The
> > header information I want at the start of the file is as follows:
> >
&g
t find any
documentation or examples on how you can do this. Any help would be
appreciated. Thank you and good luck.
Craig Williamson
--
http://mail.python.org/mailman/listinfo/python-list
-th port?
Also are you running as adminstrator? You may need admin rights to
open a serial port under windows (I'm not sure).
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
helpful, eg
@echo off
set DEMOHOME=%CD%
set PYTHONHOME=%DEMOHOME%\Python24
set PYTHONPATH=%PYTHONHOME%;%DEMOHOME%\Demo\Python
set PYTHON=%PYTHONHOME%\python.exe
set PYTHONW=%PYTHONHOME%\pythonw.exe
set PATH=%PYTHONHOME%;%PATH%
start "Demo" "%PYTHONW%" "demo.pyw"
es():
... print "Running yes command..."
... pexpect.run('yes', timeout=5)
...
>>> t = threading.Thread(target=runyes)
>>> t.start()
>>> Running yes command...
t.join()
[never returns]
I'd guess at differences between the pexpect versions. You could try
the pexpect from debian/testing easily enough I expect.
--
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:
>
> > The only sensible things you can do from a signal handler is set a
> > global flag, or call sem_post on a semaphore, to record the delivery
> > of the signal. The remainder of the pr
ogram can then either poll the
global flag, or use sem_wait() and sem_trywait() on the semaphore.
Another option is to do nothing in the signal handler, and dedicate
one thread (preferably the initial thread) to wait synchronously for
signals, using sigwait(), and send messages to the other t
pexpect has a timeout parameter exactly for this case
import os, pexpect, threading
def runyes():
print "Running yes command..."
pexpect.run('yes', timeout=5)
t = threading.Thread(target=runyes)
t.start()
t.join()
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
look a lot nicer
Eg debian
ii gtk2-engines-gtk-qt 0.7-1 theme engine using Qt for GTK+ 2.x
You get a control panel for GTK apps in the KDE control center also.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Christophe <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood a écrit :
> > There is also PyQT which we wrote off as we wanted to write commercial
> > applications too. As it happens we have a commercial QT licence, but
> > we decided we didn't want to have to
7;hello')
>>> random.shuffle(L)
>>> L
array('c', 'elohl')
>>> L.tostring()
'elohl'
Which is some way towards a mutable string...
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
QT licence, but
we decided we didn't want to have to incurr the additional expense of
renewing it.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
>>>
You can then add to attributes in the subclasses
class MagicCharacter(Character):
attributes = Character.attributes | set(['spells', 'wand'])
>>> MagicCharacter('name', strength=10, dexterity=5, intelligence=3,
luck=0, spells=1)
*
resource.getpagesize()
...
>>> print memory_used()
4575232
>>> a=1000*"x"
>>> print memory_used()
14577664
>>>
If anyone knows a (unix) portable way of doing this I'd be interested!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
def __str__(self):
return "%s(%s)" % (self.__class__.__name__, self.value)
a = NumX(4)
b = NumX(2)
print a,b
print a+b
print (a+b)/2
This prints
----
Nu
appropriate maps for
the modern computing language territory.
I was born and bred on flow charts and I admit they were useful back
in the days when I wrote 1000s of lines of assembler code a week.
Now-a-days a much better map for the the territory is pseudo-code.
Python is pretty much executable pseudo-
7;m just learning!).
http://www.wxpython.org/maillist.php
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
major-mode. Syntax colouring, indentation
that sort of thing. There is also IM-Python for code navigation, and
bycycle repair man for refactoring support. You can run stuff at the
interactive python prompt from within emacs.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ing to search for...
ctypes.pythonapi.PyThreadState_SetAsyncExc
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
-the-box'.
Neither of those statements are true. It is fairly easy to build
python extensions using mingw hosted on linux which work with the
standard python.org install - see my other post in this thread.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://
ensions with mingw under linux,
using -lpython2.4 which will run under windows.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
\\n, \\t and
\\any_char into
CR, LF, TAB and any_char"""
def _translate(m):
return m.group(1).translate(_unescape_mapping)
return _unescape_re.sub(_translate, s)
(These functions have been through the optimisation mill which is why
they may not look immediately like how you might first think of
writing them!)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
urn var * 2
>
But yes, defining a sentinel like this is a good idea.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
late to ''.
None is the traditional value to use for value not present, then you'd
get this for the function
def mainFunction(var, template=None):
if template is None:
template = 'base'
And this for the calling bit
if not_set_properly(template):
template = None
return mainFunction(var, template)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
n python.
http://svn.mythtv.org/trac/
A nice extra is that it is written in python.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
and .jar, and
openoffice and all of its many extensions.
If you are feeling really paranoid then encrypt it.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Moreover match becomes a string method. No need for extra importing
> re and applying re.compile(). Both can be done in str.match() if
> necessary.
I'm happy with the re module. Having transitioned from perl to python
some time ago now, I find myself using many fewer regexps due to the
much better built in string methods of python. This is a good thing,
because regexps should be used sparingly and they do degenerate into
line noise quite quickly...
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Duncan Booth <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
>
> > In python when making __slots__ or module.__all__ you end up typing
> > lists of objects or methods and they turn out like this which is quite
> > a lot of extra typ
)
which is nearly as neat as qw//, but not quite since the split() bit
comes at the end so it doesn't notify you that you have an array of
strings rather than a string.
I don't expect a replacement for %w{}, qw// to ever be added to
python, it is not the python way. And the python way is why I am now
a python programmer not a perl programmer!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ds just fine.
RSI is a complicated disease - there are lots of different forms of it
all caused by different things. You'll need some professional advice
to sort it out.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
on-dev about what you've done
Thats what I've done in the past anyway!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
s return False for X_OK under
> Win32. I'm happy to submit the patch, but is it worth it?
Wouldn't returning X_OK as true if the file exists be more sensible?
Ie the file might be executable, you'll have to try it, rather than,
no this file is definitely not executable...
-
Tim Golden <[EMAIL PROTECTED]> wrote:
> [Nick Craig-Wood]
>
> | Tim Golden <[EMAIL PROTECTED]> wrote:
> | > if os.path.isfile (filepath):
> | >print filepath
> |
> | You might get a more accurate result using
> |
> | os.
Tim Golden <[EMAIL PROTECTED]> wrote:
> if os.path.isfile (filepath):
>print filepath
You might get a more accurate result using
os.access(filepath, os.X_OK)
instead of
os.path.isfile(filepath)
Which checks the file is executable
--
Nick Craig-Wood <[
N/Cookbook/Python/Recipe/475155
Thanks anyway
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
TheSeeker <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> > Does anyone have some hints / tips / experience with making a cross
> > platform systray icon? It should work on Windows, Gnome and KDE at
> > minimum.
> You might do a search for TaskBarIcon in th
501 - 600 of 861 matches
Mail list logo