Python Forum
Python seems to be randomly blowing up
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python seems to be randomly blowing up
#1
I've been getting this weird error that seems to be unfounded:
# class.py
class Name(Parent):
    def __init__(self, dictionary):
        self.dictionary = dictionary
    .
    .
    .

# loaded_file.py
from . import class.py

dictionary = {...}
ClassName = Name(dictionary)
Here's the error:

TypeError: __init__() missing 1 required positional argument: 'dictionary'

Adding two print statements, like this:
# class.py
class ...
    def __init__(dictionary):
        print(dictionary)
        self.dictionary = dictionary
        print(self.dictionary)
    .
    .
    .
yields the same error, with the passed-in dictionary being printed out. Can anyone explain this to me?
Reply
#2
(Aug-22-2018, 09:15 PM)parmort Wrote: def __init__(dictionary):
Are you actually not including self, or did you not copy/paste correctly?
Reply
#3
I am not including self.
Reply
#4
(Aug-22-2018, 09:15 PM)parmort Wrote:
    def __init__(dictionary):
        print(dictionary)
        self.dictionary = dictionary
You should be getting an error, about how self isn't defined, then.
Reply
#5
Sorry, I read the question wrong. I am including self, something like
def __init__(self, dictionary):
Reply
#6
(Aug-22-2018, 09:15 PM)parmort Wrote:
class Name(Parent):
    def __init__(self, dictionary):
        self.dictionary = dictionary

Alright, let's try this. What's the Parent look like, and are you calling it's __init__ method, with whichever arguments it expects?
Reply
#7
The parent is an API-like class, with a bunch of user-over-writable methods. It doesn't have an __init__ method, however.

class Parent(object):
Know what (I should have done this earlier), here's the repo/commit.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pyaudio seems to randomly halt input. elpidiovaldez5 2 390 Jan-22-2024, 09:07 AM
Last Post: elpidiovaldez5
  Problem with code / audio is playing randomly, not matching csv requirements Daniel_kcr 2 640 Sep-07-2023, 05:09 PM
Last Post: deanhystad
  how to take a screnshot by Pyautogui automatically and randomly rachidel07 0 3,560 Feb-03-2021, 01:16 PM
Last Post: rachidel07
  module logging posting randomly DJ_Qu 2 2,226 May-14-2019, 06:41 AM
Last Post: DJ_Qu
  Can I search from Python, automatically and randomly generated keywords in Google? xX_Prophit_Xx 0 2,313 Sep-07-2018, 04:43 PM
Last Post: xX_Prophit_Xx
  Randomly changing numbers NicoConti 4 3,431 Mar-27-2018, 03:07 PM
Last Post: NicoConti
  How to print the names of assignments if they are randomly selected Kongurinn 2 3,334 Oct-22-2017, 07:31 AM
Last Post: buran
  Logic error when comparing randomly generated integers SadoDeomeoon 5 4,680 Jun-05-2017, 02:38 PM
Last Post: SadoDeomeoon
  Classes are blowing my mind! mcmxl22 5 5,139 Jan-03-2017, 05:01 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020