name space misunderstanding

classic Classic list List threaded Threaded
9 messages Options
PCM
Reply | Threaded
Open this post in threaded view
|

name space misunderstanding

PCM
Hi,

On this code:
from wx.py import editor
self.m_notebook = editor.EditorNotebook(parent=self,id=-1,style=wx.NB_LEFT)

I get a
TypeError: __init__() got an unexpected keyword argument 'style'

Yet if I look at the code, style is there ...

Any clue ? thanks

Philippe


--
_________________________
Philippe C. Martin
www.snakecard.com
_________________________



Reply | Threaded
Open this post in threaded view
|

Re: name space misunderstanding

Donn Ingle
> editor.EditorNotebook(parent=self,id=-1,style=wx.NB_LEFT)
> I get a
> TypeError: __init__() got an unexpected keyword argument 'style'
> Yet if I look at the code, style is there ...
I have seen this in other places. As far as I know it means the function is
not expecting **kwargs, only an argument list. So, try dropping the style=
part.

/d



PCM
Reply | Threaded
Open this post in threaded view
|

Re: Re: name space misunderstanding

PCM
On Friday 15 December 2006 09:49, Donn Ingle wrote:

> > editor.EditorNotebook(parent=self,id=-1,style=wx.NB_LEFT)
> > I get a
> > TypeError: __init__() got an unexpected keyword argument 'style'
> > Yet if I look at the code, style is there ...
>
> I have seen this in other places. As far as I know it means the function is
> not expecting **kwargs, only an argument list. So, try dropping the style=
> part.
>
> /d
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]

And that works ... but I do want those tabs on the left :-) !

I'll have to patch editor.py for now I guess.

Thanks,

Philippe


--
_________________________
Philippe C. Martin
www.snakecard.com
_________________________



Reply | Threaded
Open this post in threaded view
|

Re: Re: name space misunderstanding

Paul Koning
In reply to this post by Donn Ingle
>>>>> "Donn" == Donn Ingle <[hidden email]> writes:

 >> editor.EditorNotebook(parent=self,id=-1,style=wx.NB_LEFT) I get a
 >> TypeError: __init__() got an unexpected keyword argument 'style'
 >> Yet if I look at the code, style is there ...
 Donn> I have seen this in other places. As far as I know it means the
 Donn> function is not expecting **kwargs, only an argument list. So,
 Donn> try dropping the style= part.

Something doesn't sound quite right here.  The Python syntax rule is
that any optional argument can be specified either positionally, or by
keyword.  Yes, you often see keyword args when **kwargs is present in
the function definition, but from what I read in the book, that isn't
the only place where it's allowed.

Or is the problem that the function definition effectively has a *args
argument?

    paul



Reply | Threaded
Open this post in threaded view
|

Re: Re: name space misunderstanding

Donn Ingle
> Or is the problem that the function definition effectively has a *args
> argument?
Yes. I think that's it. It has no **kwargs, but is described as if it does.
/d



Reply | Threaded
Open this post in threaded view
|

Re: name space misunderstanding

Robin Dunn
In reply to this post by PCM
Philippe C. Martin wrote:

> Hi,
>
> On this code:
> from wx.py import editor
> self.m_notebook = editor.EditorNotebook(parent=self,id=-1,style=wx.NB_LEFT)
>
> I get a
> TypeError: __init__() got an unexpected keyword argument 'style'
>
> Yet if I look at the code, style is there ...

No it isn't.

class EditorNotebook(wx.Notebook):
     """A notebook containing a page for each editor."""

     def __init__(self, parent):
...

The __init__ method only takes a parent parameter.  You are probably
looking at the next line where it calls wx.Notebook.__init__ and is
passing a style value to it.


--
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!



PCM
Reply | Threaded
Open this post in threaded view
|

Re: name space misunderstanding

PCM
On Friday 15 December 2006 13:42, Robin Dunn wrote:

> Philippe C. Martin wrote:
> > Hi,
> >
> > On this code:
> > from wx.py import editor
> > self.m_notebook =
> > editor.EditorNotebook(parent=self,id=-1,style=wx.NB_LEFT)
> >
> > I get a
> > TypeError: __init__() got an unexpected keyword argument 'style'
> >
> > Yet if I look at the code, style is there ...
>
> No it isn't.
>
> class EditorNotebook(wx.Notebook):
>      """A notebook containing a page for each editor."""
>
>      def __init__(self, parent):
> ...
>
> The __init__ method only takes a parent parameter.  You are probably
> looking at the next line where it calls wx.Notebook.__init__ and is
> passing a style value to it.


Most correct - could these be added ?


--
_________________________
Philippe C. Martin
www.snakecard.com
_________________________



Reply | Threaded
Open this post in threaded view
|

Re: name space misunderstanding

Robin Dunn
Philippe C. Martin wrote:

> On Friday 15 December 2006 13:42, Robin Dunn wrote:
>> Philippe C. Martin wrote:
>>> Hi,
>>>
>>> On this code:
>>> from wx.py import editor
>>> self.m_notebook =
>>> editor.EditorNotebook(parent=self,id=-1,style=wx.NB_LEFT)
>>>
>>> I get a
>>> TypeError: __init__() got an unexpected keyword argument 'style'
>>>
>>> Yet if I look at the code, style is there ...
>> No it isn't.
>>
>> class EditorNotebook(wx.Notebook):
>>      """A notebook containing a page for each editor."""
>>
>>      def __init__(self, parent):
>> ...
>>
>> The __init__ method only takes a parent parameter.  You are probably
>> looking at the next line where it calls wx.Notebook.__init__ and is
>> passing a style value to it.
>
>
> Most correct - could these be added ?
>
>

I don't see why not.  Send me a patch.  (See the bottom of
http://wxpython.org/codeguidelines.php)


--
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!



PCM
Reply | Threaded
Open this post in threaded view
|

Re: name space misunderstanding

PCM
On Friday 15 December 2006 15:27, Robin Dunn wrote:

> Philippe C. Martin wrote:
> > On Friday 15 December 2006 13:42, Robin Dunn wrote:
> >> Philippe C. Martin wrote:
> >>> Hi,
> >>>
> >>> On this code:
> >>> from wx.py import editor
> >>> self.m_notebook =
> >>> editor.EditorNotebook(parent=self,id=-1,style=wx.NB_LEFT)
> >>>
> >>> I get a
> >>> TypeError: __init__() got an unexpected keyword argument 'style'
> >>>
> >>> Yet if I look at the code, style is there ...
> >>
> >> No it isn't.
> >>
> >> class EditorNotebook(wx.Notebook):
> >>      """A notebook containing a page for each editor."""
> >>
> >>      def __init__(self, parent):
> >> ...
> >>
> >> The __init__ method only takes a parent parameter.  You are probably
> >> looking at the next line where it calls wx.Notebook.__init__ and is
> >> passing a style value to it.
> >
> > Most correct - could these be added ?
>
> I don't see why not.  Send me a patch.  (See the bottom of
> http://wxpython.org/codeguidelines.php)

OK

--
_________________________
Philippe C. Martin
www.snakecard.com
_________________________