Hack Forums
[Python] Syntax Error While Creating Object [Python 3.6.1] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Syntax Error While Creating Object [Python 3.6.1] (/showthread.php?tid=5667292)



Syntax Error While Creating Object [Python 3.6.1] - JuiceWater - Jul 11, 2017

Good day, everyone.
Trying to get more experience with OOP in Python. It seemed very familiar to most languages, but after trying to get more practice with it now I'm not so sure anymore.

Code
import urllib2
import sys

class Account:

    entry_commands = ["register", "login", "exit"]
    account_commands = ["view_details", "edit_details", "logout"]
    admin_commands = ["delete_user", "view_user_details"]
    misc_commands = ["promote", "demote", "clear_user_details", "clear_everyone"]

    #def generate_id(self):


    def register_user(self, name, password, date_of_birth, sex):
        print("Lmao")

    def __init__(self):
      print("Welcome to the login")
      for com in self.member.commands:
          print("[%s] %s" %(self.member.commands.index(com), com


JuiceWater = Account()

Code
JuiceWater = Account()
             ^
SyntaxError: invalid syntax

Code
E0001:invalid syntax (<string>, line 23)


I get an error at when trying to initialize JuiceWater. It says invalid syntax, but this is the way I've been creating objects for days. Does anyone know why I'm not able to create Account objects, or am I just a dumbass for not seeing the obvious?

Any explanations would be much appreciated. 🤝



* - Retribute - Jul 11, 2017

You are missing your closing brackets on line 20.
PHP Code

<?php 
print("[%s] %s" %(self.member.commands.index(com), com)) 



* - JuiceWater - Jul 11, 2017

(Jul 11, 2017 05:26 PM)Retribute Wrote:  You are missing your closing brackets on line 20.
PHP Code

<?php 
print("[%s] %s" %(self.member.commands.index(com), com)) 

I'm an idiot. Thanks a lot.🤝