Python 2.7.x - problem with obejct.__init__() not accepting *args and **kwargs

2013-05-15 Thread wzab
I had to implement in Python 2.7.x a system which heavily relies on
multiple inheritance.
Working on that, I have came to very simplistic code which isolates
the problem:
(The essential thing is that each base class receives all arguments
and uses only those,
which it understands).

class a(object):
  def __init__(self,*args,**kwargs):
super(a,self).__init__(*args,**kwargs)
print args
print kwargs
print "init in a"

class b(object):
  def __init__(self,*args,**kwargs):
super(b,self).__init__(*args,**kwargs)
print args
print kwargs
print "init in b"

class c(a,b):
  def __init__(self,*args,**kwargs):
super(c,self).__init__(*args,**kwargs)
print args
print kwargs
print "init in c"

z=c(test=23,data="eee")

In Python 2.5.2 the above code works correctly, and produces:

$python test1.py
()
{'test': 23, 'data': 'eee'}
init in b
()
{'test': 23, 'data': 'eee'}
init in a
()
{'test': 23, 'data': 'eee'}
init in c

Unfortunately in Python 2.7 the above code generates an exception:
$ python test1.py
Traceback (most recent call last):
  File "test1.py", line 22, in 
z=c(test=23,data="eee")
  File "test1.py", line 17, in __init__
super(c,self).__init__(*args,**kwargs)
  File "test1.py", line 3, in __init__
super(a,self).__init__(*args,**kwargs)
  File "test1.py", line 10, in __init__
super(b,self).__init__(*args,**kwargs)
TypeError: object.__init__() takes no parameters

I have found a workaround:

# Class my_object added only as workaround for a problem with
# object.__init__() not accepting any arguments.

class my_object(object):
  def __init__(self,*args,**kwargs):
super(my_object,self).__init__()

class a(my_object):
  def __init__(self,*args,**kwargs):
super(a,self).__init__(*args,**kwargs)
print args
print kwargs
print "init in a"

class b(my_object):
  def __init__(self,*args,**kwargs):
super(b,self).__init__(*args,**kwargs)
print args
print kwargs
print "init in b"

class c(a,b):
  def __init__(self,*args,**kwargs):
super(c,self).__init__(*args,**kwargs)
print args
print kwargs
print "init in c"

z=c(test=23,data="eee")

The above works correctly, producing the same results as the first
code in Python 2.5.2,
but anyway it seems to me just a dirty trick...
What is the proper way to solve that problem in Python 2.7.3?

--
TIA,
Wojtek
-- 
http://mail.python.org/mailman/listinfo/python-list


IIR filter conversion routines for Python?

2009-05-06 Thread wzab
Hi,
I'm looking for procedures converting the IIR filters into cascade and/
or parallel forms. Something like dir2cas.m or dir2par.m known in the
Matlab/Octave world.
Unfortunately SciPy does not contain such functions.
If they are not available, I would be grateful for any hints helping
me to implement them myself.
--
TIA, BR,
WZab
--
http://mail.python.org/mailman/listinfo/python-list


Re: IIR filter conversion routines for Python?

2009-05-09 Thread wzab
On May 8, 7:30 am, Dennis Lee Bieber  wrote:
> On Wed, 6 May 2009 11:03:57 -0700 (PDT), wzab 
> declaimed the following in gmane.comp.python.general:
>
> > Hi,
> > I'm looking for procedures converting theIIRfilters into cascade and/
> > or parallel forms. Something like dir2cas.m or dir2par.m known in the
> > Matlab/Octave world.
> > Unfortunately SciPy does not contain such functions.
>
>         Well... If they are Matlab scripts (as the .m seems to imply),
> couldn't one just take the source and recode them in SciPy terms.
> --
>         Wulfraed        Dennis Lee Bieber               KD6MOG
>         wlfr...@ix.netcom.com               wulfr...@bestiaria.com
>                 HTTP://wlfraed.home.netcom.com/
>         (Bestiaria Support Staff:               web-a...@bestiaria.com)
>                 HTTP://www.bestiaria.com/

Unfortunately the Matlab scripts that are floating around the net  do
not contain the license information.
(e.g. takasila.coe.psu.ac.th/~s4810685/DSP/proakis/PWS_DSP/dir2cas.m )
So I don't know if it sufficient to consider the "public domain"...
Additionally Python is simply different and allows some thing to do in
different (better?) way.
In fact I have almost finished the simple dir2cas.py converter.
I'll post the source as soon, as it is ready.
--
Regards,
WZab

--
http://mail.python.org/mailman/listinfo/python-list


Re: IIR filter conversion routines for Python?

2009-05-09 Thread wzab
> In fact I have almost finished the simple dir2cas.py converter.
> I'll post the source as soon, as it is ready.

OK. So here it is as public domain code. Any hints and suggestions
of improvements are appreciated.

http://groups.google.com/group/alt.sources/browse_thread/thread/924fbe2255f8c42d

--
Regards, WZab
--
http://mail.python.org/mailman/listinfo/python-list