for future reference, i decided to go with 2 functions:
def common_bases(classes):
if not len(classes):
return None
common = set(classes.pop().mro())
for cls in classes:
common.intersection_update(cls.mro()) #all subclasses in common
return [cls for cls in co
On Friday, January 25, 2013 8:08:18 PM UTC+1, Peter Otten wrote:
> lars van gemerden wrote:
>
>
>
> > Hi all,
>
> >
>
> > i was writing a function to determine the common base class of a number
>
> > classes:
>
> >
>
&g
On Friday, January 25, 2013 8:04:32 PM UTC+1, Ian wrote:
> On Fri, Jan 25, 2013 at 10:40 AM, lars van gemerden
>
> wrote:
>
> > Hi all,
>
> >
>
> > i was writing a function to determine the common base class of a number
> > classes:
>
> &g
Hi all,
i was writing a function to determine the common base class of a number classes:
def common_base(classes):
if not len(classes):
return None
common = set(classes.pop().mro())
for cls in classes:
common.intersection_update(cls.mro())
while len(common) > 1:
On Thursday, November 29, 2012 3:59:37 PM UTC+1, lars van gemerden wrote:
> Hi,
>
>
>
> I have encountered some strange behavior of isinstance(/issubclass):
> depending on the import path used for classes i get different output, while
> the classes i compare
Hi,
I have encountered some strange behavior of isinstance(/issubclass): depending
on the import path used for classes i get different output, while the classes i
compare are in the same file.
Basically if i import a class as:
from mod1.mod2 import A
or:
from mod0.mod1.mod2 import A
On Wednesday, November 28, 2012 12:59:38 AM UTC+1, lars van gemerden wrote:
> Hi,
>
>
>
> I get a very strange result when using deepcopy. The following code:
>
>
>
> def __deepcopy__(self, memo):
>
> independent = self.independent()
&g
Hi,
I get a very strange result when using deepcopy. The following code:
def __deepcopy__(self, memo):
independent = self.independent()
if independent is self:
out = type(self)()
out.__dict__ = copy.deepcopy(self.__dict__, memo)
print self._
On Saturday, October 20, 2012 4:00:55 AM UTC+2, Chris Angelico wrote:
> On Sat, Oct 20, 2012 at 10:43 AM, lars van gemerden
>
> wrote:
>
> > Do you have any ideas about to what extend the "lambda" version of the code
> > (custom code is only the 'bod
On Thursday, October 18, 2012 5:16:50 PM UTC+2, Chris Angelico wrote:
> On Fri, Oct 19, 2012 at 2:00 AM, lars van gemerden
> wrote:
>
> > I get your point, since in this case having the custom code option makes
> > the system a whole lot less complex and flexible, i
On Thursday, October 18, 2012 4:29:45 PM UTC+2, Chris Angelico wrote:
> On Fri, Oct 19, 2012 at 1:07 AM, lars van gemerden
> wrote:
>
> > Thanks, Chris,
>
> >
>
> > That works like a charm (after replacig "return ns.function" with "return
&
On Thursday, October 18, 2012 1:49:35 PM UTC+2, Chris Angelico wrote:
> On Thu, Oct 18, 2012 at 10:41 PM, lars van gemerden
>
> wrote:
>
> > NameError: name 'function' is not defined
>
> >
>
> > which seems an odd error, but i think some global v
I am trying to implement a way to let users give a limited possibility to
define functions in text, that wille be stored and executed at a later time. I
use exec() to transform the text to a function. The code is as follows:
class code(str):
def __call__(self, *args):
try:
On Sunday, July 1, 2012 5:48:40 PM UTC+2, Evan Driscoll wrote:
> On 7/1/2012 4:54, Alister wrote:
> > On Sat, 30 Jun 2012 23:45:25 -0500, Evan Driscoll wrote:
> >> If I had seen that in a program, I'd have assumed it was a bug.
> >
> > You would?
> > I have only been using python for 6 - 12 months
On Jun 28, 9:22 am, Benjamin Kaplan wrote:
> On Wed, Jun 27, 2012 at 11:59 PM, lars van gemerden
>
>
>
>
>
>
>
>
>
> wrote:
> > Hi all,
>
> > I have some trouble with the following question: Let say i have the
> > following cl
Hi all,
I have some trouble with the following question: Let say i have the
following classes:
class A(object):
def __init__(self):
self.name = 'a'
def do(self):
print 'A.do: self.name =', self.name
class B(object):
def __init__(self):
self.name = 'b'
The q
On Jan 8, 7:42 am, Steven D'Aprano wrote:
> On Sat, 07 Jan 2012 17:16:22 -0800, lars van gemerden wrote:
> > Hello,
>
> > I have an error message i do not understand:
>
> > My code is in essence:
>
> The code you give works fine. It does not show the error yo
Hello,
I have an error message i do not understand:
My code is in essence:
class A(object):
#no __new__ or __init__
def meth1(self, args):
#some code
def meth2(self, args):
#some code
class B(list, A)
pass
b = B([1,2,3,4])
error:
Traceback (most recent call last):
On Dec 29 2011, 10:55 am, lars van gemerden
wrote:
> Hello,
>
> Can someone help me with the following:
>
> I am using metaclasses to make classes and these classes to make
> instances. Now I want to use multiprocessing, which needs to pickle
> these instances.
>
> P
On Dec 30, 4:56 pm, lars van gemerden wrote:
> On Dec 30, 12:16 pm, lars van gemerden wrote:
>
>
>
>
>
>
>
>
>
> > On Dec 29, 8:55 pm, Ian Kelly wrote:
>
> > > On Thu, Dec 29, 2011 at 2:55 AM, lars van gemerden
> > > wrote:
>
>
On Dec 30, 12:16 pm, lars van gemerden wrote:
> On Dec 29, 8:55 pm, Ian Kelly wrote:
>
>
>
>
>
>
>
>
>
> > On Thu, Dec 29, 2011 at 2:55 AM, lars van gemerden
> > wrote:
>
> > > Hello,
>
> > > Can someone help me with the f
On Dec 29, 8:55 pm, Ian Kelly wrote:
> On Thu, Dec 29, 2011 at 2:55 AM, lars van gemerden
> wrote:
>
> > Hello,
>
> > Can someone help me with the following:
>
> > I am using metaclasses to make classes and these classes to make
> > instances. Now I want
On Dec 29, 8:55 pm, Ian Kelly wrote:
> On Thu, Dec 29, 2011 at 2:55 AM, lars van gemerden
> wrote:
>
> > Hello,
>
> > Can someone help me with the following:
>
> > I am using metaclasses to make classes and these classes to make
> > instances. Now I want
Hello,
Can someone help me with the following:
I am using metaclasses to make classes and these classes to make
instances. Now I want to use multiprocessing, which needs to pickle
these instances.
Pickle cannot find the class definitions of the instances. I am trying
to add a line to the __new__
24 matches
Mail list logo