dgdev wrote:
> I would like to pickle an extension type (written in pyrex). I have
> it working thus far by defining three methods:
>
> class C:
> # for pickling
> __getstate__(self):
> ... # make 'state_obj'
> return state_obj
>
> __reduce__
looping wrote:
> Hi,
> for the fun I try operator overloading experiences and I didn't
> exactly understand how it works.
>
> Here is my try:
> >>> class myint(int):
>
> def __pow__(self, value):
> return self.__add__(value)
>
> >>> a = myint(3)
> >>> a ** 3
>
> 6
>
> OK, it
David Abrahams wrote:
> I'm seeing highly surprising (and different!) behaviors of
> PyImport_ImportModule on Linux and Windows when used in a program with
> python embedding.
>
> On Linux, when attempting to import a module xxx that's in the current
> directory, I get
>
> ImportError: No module
John Nagle wrote:
>
> That's fascinating. Is that a documented feature of the language,
> or a quirk of the CPython interpreter?
>
Its a documented feature of the language. From the Reference Manual:
"An assignment statement evaluates the expression list (remember that
this can be a single ex
Nick Alexander wrote:
> Hello,
>
> I am writing a python extension (compiled C code) that defines an
> extension type with PyNumberMethods. Everything works swimmingly,
> except I can't deduce a clean way to set the docstring for tp_*
> methods. That is, I always have
>
> type.__long__.__doc__ ==
Andrew Felch wrote:
> Thanks for checking. I think I narrowed the problem down to
> inheritance. I inherit from list or some other container first:
>
> class PointList( list, AutoReloader ):
> def PrintHi1(self):
> print "Hi2"
>
> class MyPrintingClass( AutoReloader ):
> def Prin
Andrew Felch wrote:
> I pasted the code into mine and replaced the old. It seems not to
> work for either unpickled objects or new objects. I add methods to a
> class that inherits from AutoReloader and reload the module, but the
> new methods are not callable on the old objects. Man! It seems
Andrew Felch wrote:
>
> Thanks Ziga. I use pickle protocol 2 and binary file types with the
> command: "cPickle.dump(obj, file, 2)"
>
> I did your suggestion, i commented out the "__call__" function of
> MetaInstanceTracker and copied the text to the __new__ function of
> AutoReloader (code append
Alex Martelli wrote:
> On Feb 27, 2007, at 2:59 AM, Daniel Nogradi wrote:
>
> > Hi Alex,
>
> > I did another test, this time with python 2.4 on suse and things are
> > worse than in the previous case (which was python 2.5 on fedora 3),
> > ouput of 'python gmp_test.py' follows:
>
> Interesting! gm
Andrew Felch wrote:
> Hello all,
>
> I'm using the metaclass trick for automatic reloading of class member
> functions, found
> at:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/160164
>
> My problem is that if I
> 1) pickle an object that inherits from "AutoReloader"
> 2) unpickle the ob
ahaldar wrote:
> Hi:
>
> I have some large data structure objects in memory, and when I attempt
> to pickle them, I get the following error:
>
> SystemError: frexp() out of range
>
> Are there some objects that are just too large to serialize, and if
> so, is there an easy workaround without breaki
Chris Mellon wrote:
> Considering that it's a backwards incompatible breaking change
> (although I understand why it was done), you'd think it deserved
> mention in the more prominent "Whats new in Python 2.5" section on the
> website, in addition to a one-liner in the NEWS file. Ah well, while
> I
On Feb 26, 7:44 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> This appears to be a change in behavior from Python 2.4 to Python 2.5,
> which I can't find documented anywhere. It may be windows only, or
> related to Windows behavior.
>
> In 2.4, the current directory (os.curdir) was on sys.path. I
zefciu wrote:
> Ok. Now I do it this way:
>
> c_real = PyFloat_AsDouble(PyTuple_GetItem(coord,0));
> c_imag = PyFloat_AsDouble(PyTuple_GetItem(coord,1));
>
> And it worked... once. The problem is really funny - in the interactive
> the function fails every second time.
>
> >>> mandelpixel((1.5, 1
George Sakkis wrote:
> I was kinda surprised that setting __class__ or __dict__ goes through
> the __setattr__ mechanism, like a normal attribute:
>
> class Foo(object):
> def __setattr__(self, attr, value):
> pass
>
> class Bar(object):
> pass
>
> >>> f = Foo()
> >>> f.__class__ =
Mark Dickinson wrote:
> Does anyone know of a good reason for the above behaviour? Would a
> patch to complexobject.c that `fixes' this be of any interest to
> anyone but me? Or would it likely break something else?
I think this is a bug in the PyComplex_AsCComplex function. To get
more feedbac
Thomas Heller wrote:
>
> Do you have a pointer to that post?
>
I think that he was refering to this post:
http://mail.python.org/pipermail/python-list/2006-December/416241.html
If you are interested in various implementations there is also this:
http://mail.python.org/pipermail/python-list/2006-A
Colin J. Williams wrote:
> It would be helpful if the rules of the game were spelled out more clearly.
>
> The conditional expression is defined as X if C else Y.
> We don't know the precedence of the "if" operator. From the little test
> below, it seem to have a lower precedence than "or".
The r
On Jan 26, 10:41 am, [EMAIL PROTECTED] wrote:
> Python 2.4.4
> mod_python 3.2.10 + Apache 2.0
>
> def index( req, **params ):
> from xml.dom.minidom import parseString
> doc = parseString( "whatever" )
>
> => blank screen, _no_any_exception_; Apache error_log:
> [Fri Jan 26 10:18:48 200
Nick Maclaren wrote:
> I can't find any description of these. Most are obvious, but some
> are not. Note that this is from the point of view of IMPLEMENTING
> them, not USING them. Specifically:
The Python equivalents of these methods are described in the
reference manual:
http://docs.python.or
Nick Maclaren wrote:
> Hmm. The extensions documentation describes how to add instance
> members to a class (PyMemberDef), but I want to add a class member.
> Yes, this is constant for all instances of the class.
>
> Any pointers?
Add something like this to your PyMODINIT_FUNC after you have
init
Mark wrote:
[a lot of valid, but long concerns about types that return
an object of their own type from some of their methods]
I think that the best solution is to use an alternative constructor
in your arithmetic methods. That way users don't have to learn about
two different factories for the
Nick Maclaren wrote:
> Well, it's not felt necessary to distinguish those at top level, so
> why should it be when they are in a sequence?
Well, this probably wasn't the best example, see the links below
for a better one.
> But this whole thing is getting ridiculous. The current implementation
Nick Maclaren wrote:
> I think that you should. Where does it say that tuple's __str__ is
> the same as its __repr__?
>
> The obvious interpretation of the documentation is that a sequence
> type's __str__ would call __str__ on each sub-object, and its __repr__
> would call __repr__.
How would y
[EMAIL PROTECTED] wrote:
> Hello,
>
> I've written a C embedded application. I want to open a python gui
> application in my C program but when I do :
>
> PyRun_String( "import gui.py", file_input, pDictionary, pDictionary );
>
> the interpreter emits an error: tkinter module not defined
>
> What s
Frank Niessink wrote:
> I tried to lookup the python source code where the actual comparison
> happens. I think it is in methodobject.c (I'm not familiar with the
> python source so please correct me if I'm wrong), meth_compare. That
> function did not change between python 2.4.4 and 2.5. Moreover,
Bob Greschke wrote:
> I want to cause any traceback output from my applications to show up in one
> of my dialog boxes, instead of in the command or terminal window (between
> running on Solaris, Linux, OSX and Windows systems there might not be any
> command window or terminal window to show the t
Steven D'Aprano wrote:
[snip]
> The important thing to notice is that alist[1:] makes a copy. What if the
> list has millions of items and duplicating it is expensive? What do people
> do in that case?
>
> Are there better or more Pythonic alternatives to this obvious C-like
> idiom?
>
> for i in r
[EMAIL PROTECTED] wrote:
> Hi all
>
> I'm currently having some issues with a process getting deadlocked. The
> problem is that the only way I can seem to find information about where
> it deadlocks is by making a wild guess, insert a pdb.set_trace() before
> this point, and then step until it lock
Sébastien Ramage wrote:
> oh!
> sorry, I made some search on comp.lang.python and fr.comp.lang.python
> and finally I forgot where I was...
>
> My question is :
> how use pyopengl with python 2.5 ??
> it seems that pyopengl was stop on 2005
PyOpenGL is still maintained, but most of the development
zloster wrote:
> I'm using Python 2.4.3 for Win32.
> I was trying to run a few child processes simultaneously in separate
> threads and get their STDOUT, but the program was leaking memory and I
> found that it was because of subprocess operating in another thread.
> The following code works fine,
[EMAIL PROTECTED] wrote:
> im plugging away at the problems at
> http://www.mathschallenge.net/index.php?section=project
> im trying to use them as a motivator to get into advanced topics in
> python.
> one thing that Structure And Interpretation Of Computer Programs
> teaches is that memoisation i
Iljya wrote:
> I have reproduced the error with Numpy 1.0b1
>
> The output with v.1.0b1 reads:
> PicklingError: Can't pickle : it's not found as
> __builtin__.float32scalar
>
> Has anyone else encountered this?
>
> Thanks,
>
> Iljya
>
> Iljya wrote:
> > Hello,
> >
> > I need to pickle the type nump
Pedro Werneck wrote:
> Hi
[snip]
> Well... I'm not talking about metaclass attributes... that's perfectly
> consistent, agreed.
>
> I'm saying that when the class implements a custom __getattribute__,
> when you try to access the instance attributes from itself, it uses it.
> But if the class is a
Martin Höfling wrote:
> Hi there,
>
> is it possible to put the methods of a class in different files? I just
> want to order them and try to keep the files small.
>
> Regards
> Martin
You could use something like this:
"""
Example usage:
>>> class Person(object):
... def __init__(self
Dave Potts wrote:
> Hi,
>
> I'm just starting a development project in Python having spent time in
> the Java world. I was wondering what tool advice you could give me
> about setting up a continuous integration environment for the python
> code: get the latest source, run all the tests, package u
Kirk Strauser wrote:
[snip]
> OK, now for the good stuff. In the code below, how can I find the name of
> the class that 'bar' belongs to:
>
> >>> class Foo(object):
> ... def bar(self):
> ... pass
> ...
> >>> b = Foo.bar
>>> print b.im_class.__name__
Foo
But if you are writing
[EMAIL PROTECTED] wrote:
> Please, confirm me one thing. According to Python documentation for
> Windows the objects .pyd and .dll have the same characteristics. I
> observed that in Python24 it does not produce errors when importing
> xx.dll or xx.pyd, however in python25b2, it only accepts nto im
Paddy wrote:
> I followed the recent anouncement of version 0.9 of PyPi and found out
> that there was work included on adding constraint satisfaction solvers
> to PyPy:
> http://codespeak.net/pypy/dist/pypy/doc/howto-logicobjspace-0.9.html
>
> I was wondering if this was a possibiity for "mainst
[EMAIL PROTECTED] wrote:
> What's the best way to traverse the web of inheritance? I want to take
> a class and traverse its bases and then the bases' bases etc
> looking for a particular class. What first came to mind was nested for
> loops. However, I want to know if there's some pre-existing
Barry Kelly wrote:
[snipped]
> Yet when I try this with the 'type' type, it doesn't work:
>
> ---8<---
> >>> x.__class__.__class__
>
> >>> x.__class__.__getattribute__('__class__')
> Traceback (most recent call last):
> File "", line 1, in ?
> TypeError: descriptor '__getattribute__' requires a
Sreeram Kandallu wrote:
> I'm writing an extension type, for which i'd like to implement only ==
> and !=, but not the other comparison operators like <,<=,>,>=.
> What is the right way to do this?
> I currently have a tp_richcompare function, which handles Py_EQ, and
> Py_NE, but raises a TypeErro
Michael Yanowitz wrote:
> Is there something like a .pythoninitrc which can run whenever we start
> Python
> that can load a file with many sys.path.append(), etc?
> If not is there some way to modify the Python shell constructor and
> destructor?
>
> Thanks in advance:
> Michael yanowitz
Yes, t
lcaamano wrote:
> We have a tracing decorator that automatically logs enter/exits to/from
> functions and methods and it also figures out by itself the function
> call arguments values and the class or module the function/method is
> defined on. Finding the name of the class where the method we ju
BBands wrote:
> There must be a better way to multiply the elements of one list by
> another:
[snipped]
> Perhaps a list comprehension or is this better addressed by NumPy?
If you have a large amount of numerical code, it is definetly better to
use numpy, since it is intended just for that purpo
jelle wrote:
> Hi Michele,
>
> Thanks for pointing that out, cool!
>
> I would argue -even- that is too much programming effort.
> Like method docstring, variables docstrings should be effortless to
> write.
I don't know what exactly do you mean with variable docstrings, but
if you just want to ad
Kirill Simonov wrote:
> Could someone explain why __reduce__(2) works for files while
> __reduce__(1) doesn't?
I think it is a bug. Both should raise an error.
__reduce__ and __reduce_ex__ are part of the pickle protocol.
Files are not meant to be pickable, since they are already
persistent. With
Fredrik Lundh wrote:
> (reposted from doc-sig, which seems to be mostly dead
> these days).
>
> over at the pytut wiki, "carndt" asked:
>
> Are there any guidelines about conventions concerning
> punctuation, text styles and language style (e.g. how
> to address the reader)?
>
> any sug
Fabiano Sidler wrote:
[snipped]
> The problem with this is that the func_code attribute would contain
> the code of PrintingFunction instead of func. What I wanted to do, is
> to keep the original behaviour, i.e. set the variable __metaclass__ to
> DebugMeta and so get debug output, without chang
David Isaac wrote:
> "Ziga Seilnacht" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > >>> a = 1
> > >>> b = 1
> > >>> a == b
> > True
> > >>> a is b
> > False
>
> Tw
Steven Watanabe wrote:
> PEP 8 says, "Comparisons to singletons like None should always be done
> with 'is' or 'is not', never the equality operators." I know that "is"
> is an identity operator, "==" and "!=" are the equality operators, but
> I'm not sure what other singletons are being referred t
Darren Dale wrote:
> I am trying to work with properties, using python 2.4.2. I can't get the
> docstrings to work, can someone suggest what I'm doing wrong? I think the
> following script should print "This is the doc string.", but instead it
> prints:
>
> "float(x) -> floating point number
>
> Co
Michele Simionato wrote:
There is a minor bug in your code:
> def thisclass(proc, *args, **kw):
>""" Example:
>>>> def register(cls): print 'registered'
>...
>>>> class C:
>...thisclass(register)
>...
>registered
>"""
># basic idea stolen from zope.interf
Christian Eder wrote:
> Hi,
>
> I think I have discovered a problem in context of
> metaclasses and multiple inheritance in python 2.4,
> which I could finally reduce to a simple example:
I don't know if this is a bug; but I will try to expain
what is happening; here is an example similar to yours
David Isaac wrote:
> 1. "Without a __dict__ variable,
> instances cannot be assigned new variables not listed in the __slots__
> definition."
>
> So this seemed an interesting restriction to impose in some instances,
> but I've noticed that this behavior is being called by some a side effect
> the
bruno at modulix wrote:
> Hi
>
> I'm currently playing with some (possibly weird...) code, and I'd have a
> use for per-instance descriptors, ie (dummy code):
> Now the question: is there any obvious (or non-obvious) drawback with
> this approach ?
Staticmethods won't work anymore:
>>> class
Lonnie Princehouse wrote:
> Occaisionally, the first two lines of The Zen of Python conflict with
> one another.
>
> An API I'm working on involves a custom namespace implementation using
> dictionaries, and I want a pretty syntax for initializing the custom
> namespaces. The fact that these names
Christoph Zwerschke wrote:
> Alex Martelli wrote:
> > Sathyaish wrote:
> >
> >> I tried it on the interpreter and it looks like it is the "to the power
> >> of" operator symbol/function. Can you please point me to the formal
> >> definition of this operator in the docs?
> >
> > http://docs.python.
Georg Brandl wrote:
> Hi,
>
> can someone please tell me that this is correct and why:
>
> >>> class C(object):
> ... pass
> ...
> >>> c = C()
> >>> c.a = 1
> >>> c.__dict__
> {'a': 1}
> >>> c.__dict__ = {}
> >>> c.a
> Traceback (most recent call last):
> File "", line 1, in ?
> AttributeErr
David Bear wrote:
> I was wondering if anyone has written an apache config file parser in
> python. There seem to be a number of perl mods to do this. But I don't seem
> to be able to find anything in python.
>
> --
> David Bear
> -- let me buy your intellectual property, I want to own your thought
ther constant
filename = f.f_code.co_filename
import py
co = py.code.Code(func)
new_code = co.new(co_lineno=lineno, co_filename=filename)
new_func = new.function(new_code, func.func_globals, nm,
func.func_defaults, func.func_closure)
> -- Ed Leafe
> -- http://leafe.com
> -- http://dabodev.com
Ziga Seilnacht
--
http://mail.python.org/mailman/listinfo/python-list
RayS wrote:
> I've begun a Python module to provide a complete interface to the
> Meade LX200 command set, and have searched for a style/development
> guide for Python Lib/site-packages type modules, but only saw guides
> for C-modules. I realize that I need to make some changes to follow
> http:/
Russ wrote:
> I know that python packages are available for representing physical
> units, but I am getting frustrated trying to find them and determine
> which is the best.
> Where can I find a good package that does this? Thanks.
Unum is a special package just for this purpose:
http://home.tisc
:
http://mail.python.org/mailman/listinfo/pythondotnet .
Ziga Seilnacht
--
http://mail.python.org/mailman/listinfo/python-list
R. Bernstein wrote:
.
.
.
> which is perhaps is a little more honest since one is not really in a
> file called . However the way the debugger gets this *is*
> still a little hoaky in that it looks for something in the frame's
> f_code.co_filename *called* . And from that it *assumes* this
> is an
Paul Watson wrote:
.
.
.
> I need to call GetVersionInfo() and handle VERSIONINFO information. I
> thought that distutils might have something, but I do not see it yet.
> Any suggestions?
This information is provided with sys.getwindowsversion().
--
http://mail.python.org/mailman/listinfo/pyth
Sorry, the previous post is wrong. I mixed the function names.
--
http://mail.python.org/mailman/listinfo/python-list
Fuzzyman wrote:
> Does anyone know how to use _winreg to get path information (location
> of install) for all versions of Python installed (and also which is the
> most recent) ?
This should probably work:
import _winreg
def get_subkey_names(reg_key):
index = 0
L = []
while True:
Jon Guyer wrote:
> >>> This is a fake line to confuse the stupid top-posting filter at gmane
>
> We have a rather complicated class that, under certain circumstances, knows
> that it cannot perform various arithmetic operations, and so returns
> NotImplemented. As a trivial example:
>
> >>> cl
You can also just use:
t.dynamic = dynamic.__get__(t)
--
http://mail.python.org/mailman/listinfo/python-list
Never mind, I forgot that class inheritance tree is a tree.
Resulting type of adding Broken and Working from previous
example would also depend on the order of operands.
Ziga
--
http://mail.python.org/mailman/listinfo/python-list
"""
I am trying to write some classes representing the quaternion number.
I wrote a base class, which implements only the numerical interface,
and a few subclasses, which provide methods for their specific domain.
Since the operator methods will be the same for all these classes,
the base class op
72 matches
Mail list logo