Python common error messages -TypeError -Arg

TypeError: __init__() takes exactly 2 arguments (1 given)
 
import sys
class tables:
   def __init__(self,w):
       ans = self.T0_r(w)
       print "Result = %s" % (ans)
    
    def T0_r(self, w):
       self.tables_ls()
       self.w = w
       self.s1_t0_r = self.T0[self.w]
       return self.s1_t0_r
   
    def tables_ls(self):    
        self.T0 = ['0xFF563C6' ,'0x84FF7CF8' ,'0x897788EE' ,'0x8EFB7BF6',
               '0xFE2F2FF ' ,'0xBCAF6BD6' ,'0xAA6F6FDE' ,'0xFFC5C591']

def main ():   
    # Read 0 element of the table array by calling class
   y = tables()
main()
 
This will result in error below:
Error

Traceback (most recent call last):
 File "calling_classes.py", line 27, in ?
   main()
 File "calling_classes.py", line 26, in main
   y = tables()
TypeError: __init__() takes exactly 2 arguments (1 given)
 
Issue of above error is in highlighted line in red above. This can be fixed like below. 
 y = tables(0x4) 

LTE - 4G Wireless Technology

Digital fundamentals.

Interview Questions.

Following list of programs are discussed in this sec:

¶ File Operations: 

Tutorials @fullchipdesign.com

Verilog Tutorial.

LTE Tutorial.

Memory Tutorial.

  • Open and read file from within the python program as a single string. Command line arguments lists as string with ‘sys.argv’.
  • Use of  glob module in Python code . Read file using classes, global variables and functions. Program to open and write file.
  • ¶ Program to read file, filter text, conversion to HEX, conversion from Hexadecimal to Signed Magnitude.S Steps for conditional statements, converting string to hexadecimalvalue, strip of white space at end, converting 12 bit hexadecimal values to 12 bit signed values.

    ¶ Advanced python code to cover UNIX shell commands, read lines from a text file, ‘sysargv’ command line operations, use of class and multiple functions. 

    Hope you liked! this page. Don't forgot to access relevant previous and next sections with links below.