def Koben(ben, *args, **kwargs): try: return ben(*args, **kwargs) except Exception as err: print(type(err)) raise a = Koben(nama="koben")
help mising 1 required posisitional rgument
help mising 1 required posisitional rgument
|
Apr-09-2020, 08:31 AM
you have a mandatory positional argument
ben when you call the function you supply just one keyword argument that will be placed in kwargs dict
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs
Apr-09-2020, 09:10 AM
def Koben(ben, *args, **kwargs): try: return ben(*args, **kwargs) except Exception as err: print(type(err)) raise a = Koben(nama="koben") print(a.ben())
(Apr-09-2020, 08:31 AM)buran Wrote: you have a mandatory positional argument that's the same code. You need to supply argument ben . I guess that is supposed to be something callable - function, class..
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs
Apr-11-2020, 12:08 PM
def Contoh(tes, *args, **kwargs): try: return tes(*args, **kwargs) except Exception as err: print(type(err)) raise a = Contoh(nama="Tes") print(a.tes())
Apr-11-2020, 12:18 PM
you have a function
Contoh this function takes arguments. One of these arguments is mandatory - tes . this argument must be callable, e.g. function or classyou keep calling that function without supplying this argument. Can you provide more context? Without it, example would be something like def greet(name): print(f'Hello, {name}') def say(tes, *args, **kwargs): print(tes) print(args) print(kwargs) tes(*args, **kwargs) say(greet, name='John')
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs
Apr-12-2020, 07:00 PM
def example(file, separator, *args): file.write(separator.join(args)) print(file) a = example("Helo",separator='#') print(a)
Please, keep the discussion in one thread, no need to start new thread every time.
In this case the first argument - file must have write method. You pas str which does not have such method.Seriously, you need to go through fundamentals Also, note that the way you call the function - with separator as keyword argument, you virtually make *args` useless
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs
Apr-12-2020, 07:42 PM
do i have instructions on that code
I followed the code in the python documentation
Apr-12-2020, 07:45 PM
(Apr-12-2020, 07:42 PM)kobencry Wrote: I followed the code in the python documentationPost a link to documentation you follow
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs |
|
Users browsing this thread: 1 Guest(s)