Hello,
I have a problem with using select. I can reliably reproduce a situation
where select.select((sock.fileno(),), (), (), 0) returns ((),(),())
(i.e., no data ready for reading), but an immediately following
sock.recv() returns data without blocking.
I am pretty sure that this is not a race c
Nikolaus Rath writes:
> Hello,
>
> I have a problem with using select. I can reliably reproduce a situation
> where select.select((sock.fileno(),), (), (), 0) returns ((),(),())
> (i.e., no data ready for reading), but an immediately following
> sock.recv() returns dat
Hello,
I'm trying to debug a problem. As far as I can tell, one of my methods
is called at a point where it really should not be called. When setting
a breakpoint in the function, I'm getting this:
> /home/nikratio/in-progress/s3ql/src/s3ql/backends/s3c.py(693)close()
-> if not self.md5_checked:
Hello,
(This may or may not be related to my mail about a "corrupted stack
trace").
I've instrumented one of my unit tests with a conditional
'pdb.set_trace' in some circumstances (specifically, when a function is
called by a thread other than MainThread). However, when trying to print
a back tra
Chris Angelico writes:
> On Wed, Jun 4, 2014 at 12:30 PM, Nikolaus Rath wrote:
>> I've instrumented one of my unit tests with a conditional
>> 'pdb.set_trace' in some circumstances (specifically, when a function is
>> called by a thread other than MainThread)
Chris Angelico writes:
> On Wed, Jun 4, 2014 at 12:20 PM, Nikolaus Rath wrote:
>> File "/usr/lib/python3.3/threading.py", line 878 in _bootstrap
>
> Can you replicate the problem in a non-threaded environment? Threads
> make interactive debugging very hairy.
Hmm. I
Chris Angelico writes:
> On Wed, Jun 4, 2014 at 12:30 PM, Nikolaus Rath wrote:
>> I've instrumented one of my unit tests with a conditional
>> 'pdb.set_trace' in some circumstances (specifically, when a function is
>> called by a thread other than MainThread)
Paul Rubin writes:
> Nikolaus Rath writes:
>> Still no context before the ominous close() call. I'm very confused.
>
> close() could be getting called from a destructor as the top level
> function of a thread exits, or something like that.
Shouldn't the destructor h
Nikolaus Rath writes:
> Chris Angelico writes:
>> On Wed, Jun 4, 2014 at 12:30 PM, Nikolaus Rath wrote:
>>> I've instrumented one of my unit tests with a conditional
>>> 'pdb.set_trace' in some circumstances (specifically, when a function is
&g
dieter writes:
[...]
> Someone else already mentioned that the "close" call
> can come from a destructor. Destructors can easily be called
> at not obvious places (e.g. "s = C(); ... x = [s for s in ...]";
> in this example the list comprehension calls the "C" destructor
> which is not obvious whe
Chris Angelico writes:
> On Fri, Jun 6, 2014 at 12:16 PM, Nikolaus Rath wrote:
>> - Is there some way to make the call stack for destructors less confusing?
>
> First off, either don't have refloops, or explicitly break them.
The actual code isn't as simple as the exa
Hello,
Can someone explain help me understand what this exception means?
[...]
File
"/usr/local/lib/python3.4/dist-packages/dugong-3.2-py3.4.egg/dugong/__init__.py",
line 584, in _co_send
len_ = self._sock.send(buf)
File "/usr/lib/python3.4/ssl.py", line 679, in send
v = self._sslob
Hello,
I have a strange problem with pexpect:
$ cat test.py
#!/usr/bin/python
import pexpect
child = pexpect.spawn("./test.pl")
while True:
try:
line = raw_input()
except EOFError:
break
child.sendline(line)
print child.readline().rstrip("\r\n")
child.close()
Hi,
Consider these two files:
, mytest.py -
| #!/usr/bin/env python
| import unittest
|
| class myTestCase(unittest.TestCase):
| def test_foo(self):
| pass
|
| # Somehow important according to pyunit documentation
| def suite():
| return unittest.makeSuite(myTestCase)
`---
Dave Angel writes:
> Nikolaus Rath wrote:
>> Hi,
>>
>> Consider these two files:
>>
>> , mytest.py -
>> | #!/usr/bin/env python
>> | import unittest
>> | | class myTestCase(unittest.TestCase):
>> | def test_foo(self):
&g
Hello,
I am really surprised that I am asking this question on the mailing
list, but I really couldn't find it on python.org/doc.
Why is there no proper way to protect an instance variable from access
in derived classes?
I can perfectly understand the philosophy behind not protecting them
from a
Terry Reedy <[EMAIL PROTECTED]> writes:
> Torsten Bronger wrote:
>> Hallöchen!
> > And why does this make the implicit insertion of "self" difficult?
>> I could easily write a preprocessor which does it after all.
>
> class C():
> def f():
> a = 3
>
> Inserting self into the arg list is triv
Terry Reedy <[EMAIL PROTECTED]> writes:
> Nikolaus Rath wrote:
>> Terry Reedy <[EMAIL PROTECTED]> writes:
>>> Torsten Bronger wrote:
>>>> Hallöchen!
>>> > And why does this make the implicit insertion of "self" difficult?
>>>
Terry Reedy <[EMAIL PROTECTED]> writes:
>> What he wants is to write
>>
>
> > class foo:
>>def bar(arg):
>>self.whatever = arg + 1
>>
>> instead of
>>
>> class foo:
>>def bar(self, arg)
>>self.whatever = arg + 1
>>
>> so 'self' should *automatically* only be inserted in the
castironpi <[EMAIL PROTECTED]> writes:
>> I think you misunderstood him. What he wants is to write
>>
>> class foo:
>> def bar(arg):
>> self.whatever = arg + 1
>>
>> instead of
>>
>> class foo:
>> def bar(self, arg)
>> self.whatever = arg + 1
>>
>> so 'self' should *automaticall
Michael Torrie <[EMAIL PROTECTED]> writes:
> Colin J. Williams wrote:
>>>
>>> def fun( ., cat):
>>>
>> I don't see the need for the comma in fun.
>
> It (the entire first variable!) is needed because a method object is
> constructed from a normal function object:
>
> def method(self,a,b):
>
Bruno Desthuilliers <[EMAIL PROTECTED]> writes:
> The fact that a function is defined within a class statement doesn't
> imply any "magic", it just creates a function object, bind it to a
> name, and make that object an attribute of the class. You have the
> very same result by defining the functio
"Russ P." <[EMAIL PROTECTED]> writes:
> The issue here has nothing to do with the inner workings of the Python
> interpreter. The issue is whether an arbitrary name such as "self"
> needs to be supplied by the programmer.
>
> All I am suggesting is that the programmer have the option of
> replacing
Michael Torrie <[EMAIL PROTECTED]> writes:
> I think the biggest reason why an implicit self is bad is because it
> prevents monkey-patching of existing class objects. Right now I can add
> a new method to any existing class just with a simple attribute like so
> (adding a new function to an exist
Hello,
From `pydoc os`:
symlink(...)
symlink(src, dst)
Create a symbolic link pointing to src named dst.
Is there any reason why this is so deliberately confusing? Why is the
target of the symlink, the think where it points *to*, called the
`src`? It seems to me tha
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes:
> Nikolaus Rath wrote:
>
>> Hello,
>>
>>>From `pydoc os`:
>>
>> symlink(...)
>> symlink(src, dst)
>>
>> Create a symbolic link pointing to
Hi,
Sorry for replying so late. Your MUA apparently messes up the
References:, so I saw you reply only now and by coincidence.
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes:
> Nikolaus Rath schrieb:
>> Hello,
>>
>> I am really surprised that I am asking this
Bruno Desthuilliers <[EMAIL PROTECTED]> writes:
> Nikolaus Rath a écrit :
>> Michael Torrie <[EMAIL PROTECTED]> writes:
>
> (snip)
>
>>> In short, unlike what most of the implicit self advocates are
>>> saying, it's not just a simple change to
Hello,
I have a number of conceptually separate tests that nevertheless need
a common, complicated and expensive setup.
Unfortunately, unittest runs the setUp method once for each defined
test, even if they're part of the same class as in
class TwoTests(unittest.TestCase):
def setUp(self):
Jean-Paul Calderone <[EMAIL PROTECTED]> writes:
> On Tue, 29 Jul 2008 16:35:55 +0200, Nikolaus Rath <[EMAIL PROTECTED]> wrote:
>>Hello,
>>
>>I have a number of conceptually separate tests that nevertheless need
>>a common, complicated and expensive setup
Jean-Paul Calderone <[EMAIL PROTECTED]> writes:
> On Tue, 29 Jul 2008 19:26:09 +0200, Nikolaus Rath <[EMAIL PROTECTED]> wrote:
>>Jean-Paul Calderone <[EMAIL PROTECTED]> writes:
>>> On Tue, 29 Jul 2008 16:35:55 +0200, Nikolaus Rath <[EMAIL PROTECTED]> wro
Hello,
Can someone explain to me the difference between a type and a class?
After reading http://www.cafepy.com/article/python_types_and_objects/
it seems to me that classes and types are actually the same thing:
- both are instances of a metaclass, and the same metaclass ('type')
can instant
Thomas Troeger <[EMAIL PROTECTED]> writes:
>> Can someone explain to me the difference between a type and a class?
>
> If your confusion is of a more general nature I suggest reading the
> introduction of `Design Patterns' (ISBN-10: 0201633612), under
> Specifying Object Interfaces'.
>
> In short:
oj <[EMAIL PROTECTED]> writes:
> On Jul 31, 11:37 am, Nikolaus Rath <[EMAIL PROTECTED]> wrote:
>> So why does Python distinguish between e.g. the type 'int' and the
>> class 'myclass'? Why can't I say that 'int' is a class and
Maric Michaud <[EMAIL PROTECTED]> writes:
>> > Can someone explain to me the difference between a type and a class?
>>
>> If your confusion is of a more general nature I suggest reading the
>> introduction of `Design Patterns' (ISBN-10: 0201633612), under
>> `Specifying Object Interfaces'.
>>
>> In
Maric Michaud <[EMAIL PROTECTED]> writes:
> Le Thursday 31 July 2008 14:30:19 Nikolaus Rath, vous avez écrit :
>> oj <[EMAIL PROTECTED]> writes:
>> > On Jul 31, 11:37 am, Nikolaus Rath <[EMAIL PROTECTED]> wrote:
>> >> So why does Python distinguish
Maric Michaud <[EMAIL PROTECTED]> writes:
> Le Thursday 31 July 2008 16:46:28 Nikolaus Rath, vous avez écrit :
>> Maric Michaud <[EMAIL PROTECTED]> writes:
>> >> > Can someone explain to me the difference between a type and a class?
>> >>
>&
Maric Michaud <[EMAIL PROTECTED]> writes:
>>> What the means is that int is not a user type but a
>>> builtin type, instances of int are not types (or classes) but common
>>> objects, so its nature is the same as any classes.
>>>
>>> The way it prints doesn't matter, it's just the __repr__ of any
Miles <[EMAIL PROTECTED]> writes:
> On Thu, Jul 31, 2008 at 1:59 PM, Nikolaus Rath wrote:
>> If it is just a matter of different rendering, what's the reason for
>> doing it like that? Wouldn't it be more consistent and straightforward
>> to denote builtin type
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> So, to the Original Poster:
>
> In Python, new-style classes and types are the same, but it is
> traditional to refer to customer objects as "class" and built-in
> objects as "types". Old-style classes are different, but you are
> discouraged from using
Hello,
I need to synchronize the access to a couple of hundred-thousand
files[1]. It seems to me that creating one lock object for each of the
files is a waste of resources, but I cannot use a global lock for all
of them either (since the locked operations go over the network, this
would make the
Ulrich Eckhardt <[EMAIL PROTECTED]> writes:
> Nikolaus Rath wrote:
>> I need to synchronize the access to a couple of hundred-thousand
>> files[1]. It seems to me that creating one lock object for each of the
>> files is a waste of resources, but I cannot use a glo
Nikolaus Rath <[EMAIL PROTECTED]> writes:
>> This should work, at least the idea is not flawed. However, I'd say
>> there are too many locks involved. Rather, you just need a simple
>> flag and the global lock. Further, you need a condition/event that
>> tell
Carl Banks <[EMAIL PROTECTED]> writes:
> Freaky... I just posted nearly this exact solution.
>
> I have a couple comments. First, the call to acquire should come
> before the try block. If the acquire were to fail, you wouldn't want
> to release the lock on cleanup.
>
> Second, you need to change
Tobiah <[EMAIL PROTECTED]> writes:
> On Mon, 04 Aug 2008 15:30:51 +0200, Nikolaus Rath wrote:
>
>> Hello,
>>
>> I need to synchronize the access to a couple of hundred-thousand
>> files[1]. It seems to me that creating one lock object for each of the
>> f
Neal Becker <[EMAIL PROTECTED]> writes:
> Sounds simple, but how, given an instance, do I find the class?
It does not only sound simple. When 'inst' is your instance, then
inst.__class__
or
type(inst)
is the class.
Best,
-Nikolaus
--
»It is not worth an intelligent man's time to
LaundroMat <[EMAIL PROTECTED]> writes:
> Hi -
>
> I'm trying to calculate unique hash values for binary files,
> independent of their location and filename, and I was wondering
> whether I'm going in the right direction.
>
> Basically, the hash values are calculated thusly:
>
> f = open('binaryfile
Hello,
All my Python files have extension .py. However, I would like to install
scripts that are meant to be called by the user without the suffix, i.e.
the file scripts/doit.py should end up as /usr/bin/doit.
Apparently the scripts= option of the setup() function does not support
this directly.
Lie Ryan writes:
> On 12/5/2009 11:34 AM, Nikolaus Rath wrote:
>> Hello,
>>
>> All my Python files have extension .py. However, I would like to install
>> scripts that are meant to be called by the user without the suffix, i.e.
>> the file scripts/doit.
Wolodja Wentland writes:
> On Fri, Dec 04, 2009 at 19:34 -0500, Nikolaus Rath wrote:
>> All my Python files have extension .py. However, I would like to install
>> scripts that are meant to be called by the user without the suffix, i.e.
>> the file scripts/doit.py should en
Hello,
I want to create an extension module that provides an interface to a
couple of C functions that take arguments of type struct iovec, struct
stat, struct flock, etc (the FUSE library, in case it matters).
Now the problem is that these structures contain attributes of type
fsid_t, off_t, dev
Hello,
Consider the following function:
def check_s3_refcounts():
"""Check s3 object reference counts"""
global found_errors
log.info('Checking S3 object reference counts...')
for (key, refcount) in conn.query("SELECT id, refcount FROM s3_objects"):
refcount2 = conn.get
"Gabriel Genellina" writes:
> En Wed, 07 Apr 2010 18:44:39 -0300, Nikolaus Rath
> escribió:
>
>> def check_s3_refcounts():
>> """Check s3 object reference counts"""
>>
>> global found_errors
>> log.
Hi,
I'm trying to be very clever:
class tst(object):
def destroy(self):
print 'Cleaning up.'
self.__del__ = lambda: None
def __del__(self):
raise RuntimeError('Instance destroyed without running destroy! Hell
may break loose!')
However, it doesn't work:
Hi,
Please consider this example:
#!/usr/bin/env python
import apsw
import tempfile
fh = tempfile.NamedTemporaryFile()
conn = apsw.Connection(fh.name)
# Fill the db with some data
cur = conn.cursor()
datafh = open("/dev/urandom", "rb")
cur.execute("CREATE TABLE foo (no INT, data BLOB)")
for i
Nikolaus Rath writes:
> Hi,
>
> Please consider this example:
[]
I think I managed to narrow down the problem a bit. It seems that when
a function returns normally, its local variables are immediately
destroyed. However, if the function is left due to an exception, the
local variabl
Hi,
Are there any best practices for handling multi-line log messages?
For example, the program,
main = logging.getLogger()
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s
%(message)s'))
main.addHandler(handler)
main.setLev
Hello,
I want to implement a caching data structure in Python that allows me
to:
1. Quickly look up objects using a key
2. Keep track of the order in which the objects are accessed (most
recently and least recently accessed one, not a complete history)
3. Quickly retrieve and remove the le
Carl Banks writes:
>> This is one area in which Perl still whips Python...
>
> No way. Perl's man pages are organized so poorly there is no
> ergonomic pit deep enough to offset them. Quick, what man page is the
> "do" statement documented in?
Of course there is:
$ perldoc -f do | head
Hi,
I want to monkeypatch an object so that it becomes callable, although
originally it is not meant to be. (Yes, I think I do have a good reason
to do so).
But simply adding a __call__ attribute to the object apparently isn't
enough, and I do not want to touch the class object (since it would
mo
Hello,
I am trying to profile a Python program that primarily calls a C
extension. From within the C extension, a callback Python function is
then called concurrently in several threads.
When I tried to profile this application with
import c_extension
def callback_fn(args):
# Do all so
Bruno Desthuilliers writes:
> 7stud a écrit :
> (snip)
>> class Wrapper(object):
>> def __init__(self, obj, func):
>> self.obj = obj
>> self.func = func
>>
>> def __call__(self, *args):
>> return self.func(*args)
>>
>> def __getattr__(self, name):
>> ret
62 matches
Mail list logo