Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78995 > unrolled thread

TypeError: 'kwarg' is an invalid keyword argument for this function

Started byroro codeath <rorocodeath@gmail.com>
First post2014-10-12 20:55 +0800
Last post2014-10-12 06:46 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  TypeError: 'kwarg' is an invalid keyword argument for this function roro codeath <rorocodeath@gmail.com> - 2014-10-12 20:55 +0800
    Re: TypeError: 'kwarg' is an invalid keyword argument for this function Rustom Mody <rustompmody@gmail.com> - 2014-10-12 06:46 -0700

#78995 — TypeError: 'kwarg' is an invalid keyword argument for this function

Fromroro codeath <rorocodeath@gmail.com>
Date2014-10-12 20:55 +0800
SubjectTypeError: 'kwarg' is an invalid keyword argument for this function
Message-ID<mailman.14784.1413118559.18130.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

How to implement it in my class?

class Str(str):
    def __init__(self, *args, **kwargs):
        pass

Str('smth', kwarg='a')

# How to implement in my class

class C:
   def __init__(self):
       pass

class C2(C):
    def __init__(self, *args, **kwargs):
        pass
C2(kwarg='a')

[toc] | [next] | [standalone]


#78997

FromRustom Mody <rustompmody@gmail.com>
Date2014-10-12 06:46 -0700
Message-ID<b93efb73-97d8-4d3f-815f-523bfceebd83@googlegroups.com>
In reply to#78995
Whats the problem??
Seems to work (python 2.7.8)

[Ive added a line so that that you can see]

class C:
   def __init__(self):
       pass

class C2(C):
    def __init__(self, *args, **kwargs):
        self.dic = kwargs
        pass
x = C2(kwarg='a')
y = C2(kwarg='a', kwarg2=8)


========================
>>> x.dic
{'kwarg': 'a'}
>>> y.dic
{'kwarg': 'a', 'kwarg2': 8}
>>> 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web