def __del__(self):
fcntl.flock(self.lock.fileno(), fcntl.LOCK_UN)
self.lock.close()
In this case, if interpreter dies, the lock is released by OS.
If you try to create another instance in the same interpreter
or another, the call will block in __init__. You can change it to
raise an exception instead.
> If anyone has ideas for how to find such people within
> this geographic area, I'd much appreciate suggestions..
Try to post it at
http://www.python.org/Jobs.html
BranoZ
--
http://mail.python.org/mailman/listinfo/python-list
This was tricky..
python -c $'import sys;\nfor i in range(5): print i,'
Separate statements with and enclose it in $'string'.
BranoZ
--
http://mail.python.org/mailman/listinfo/python-list
In "man python"
"Here command may contain multiple statements separated by
newlines. Leading whitespace is significant in Python statements!"
In "man bash" search for \n (/\\n)
Frankly, I know bash for 10 years, but this has surprised me, too.
BranoZ
--
http://ma
..
In vi it looks like [EMAIL PROTECTED] At CLI it realy does a newline.
I guess, you can no longer call it an one-liner ;-)
I'm not sure whether Ctrl-v is a bash feature. More probably
the tty driver. So, it may be worth tring it on bash-less UNIXes
(that deserve to extinct)
BranoZ
--
http://mail.python.org/mailman/listinfo/python-list
mp;MyType as 'class' argument to:
PyInstance_New(PyObject *class, PyObject *arg, PyObject *kw)
It failed the PyClass_Check.
I have also found a couple of PyObject_New functions which accept
PyTypeObject as an argument. They look very low-level and obviously
don't call __init__. Shoul
peer _if_ the pipe was created by your common
parent, the shell. Only the parent knows retcodes of its children.
You can communicate the status over the pipe. E.g. when producer will
successufuly finish it will write (let say) last line with only one '.'
Didn't help you much
flocks descriptor.
2. Process H unlinks /var/tmp/test1
3. Process B opens file /var/tmp/test1, and flocks _another_
descriptor
4. Processes A and B are running simultaneously
Do you need protection agains H ?
Use file that is writeable by A and B in a directory that is
writeable only by root.
sically, I try all n*n combinations, and remove substring lines
"in-place".
BranoZ
--
http://mail.python.org/mailman/listinfo/python-list
ern in
"132443".
"132443" is a 'subsubstring' "0134314244133" because:
0134314244133
-#####-#-
Maybe "234" is just a typo, and it should be "243".
def subsubstr(a, b):
if b == '':
return True
if a == '':
return False
else:
if a[0] == b[0]:
return subsubstr(a[1:], b[1:])
else:
return subsubstr(a[1:], b)
I can give you more efficient, index-based sulution, but this
one looks nicer.
BranoZ
--
http://mail.python.org/mailman/listinfo/python-list
ortant
housekeeping stuff around them.
BranoZ
--
http://mail.python.org/mailman/listinfo/python-list
he type. For example:
>
>if type(x) == type(3):
> print 'x is an integer'
or
x = 5
isinstance(x, int)
True
BranoZ
--
http://mail.python.org/mailman/listinfo/python-list
.
How do you implement some methods in C without subclassing ?
BranoZ
--
http://mail.python.org/mailman/listinfo/python-list
name 'z' is not defined
In worse case, somebody will send you a carefuly formated
input that you will run blindy (just like in case of buffer
overflows).
CSV is easy with the module..
import csv
cr = csv.reader((x,))
print cr.next()
['z', '22', '44'
x27;)
fcntl.flock(lockfile.fileno(),
fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError:
print sys.exc_info()[1]
sys.exit(-1)
You can flock any open file, no matter if it is read/write/append.
BranoZ
--
http://mail.python.org/mailman/listinfo/python-list
How about:
a = [ [i**2 for j in range(256)] for i in range(256) ]
b = sum(a, [])
c = [ b[slice(i,i+256)] for i in range(0,256*256,256) ]
>>> a is c
False
>>> a == c
True
BranoZ
--
http://mail.python.org/mailman/listinfo/python-list
16 matches
Mail list logo