Aug-26-2018, 08:49 PM
(Aug-23-2018, 03:04 PM)ichabod801 Wrote: I would not name the class method input, rather from_input or something similar. Since it's a method, it won't override the input built-in, but it just makes me cringe. I think it's a good habit never to name things after built-ins, so that you never do it when it could cause a problem.
I would also assign the inputs to some local variables, and then create the class with the local variables. Yeah, you can get user input as a parameter, but it strikes me as a bad idea for some reason. Also, you will want it set up my way if you ever do any validation on the user input.
Hi ichabod801, sorry for the late response. Please see my updated code below and let me know if I need to improve it? Thank you
class Studentform: def __init__(self, fname, lname, email, ccode, mobile, github, country, identity, want, codelevel, subs, like): self.fname = fname self.lname = lname self.email = email self.ccode = ccode self.mobile = mobile self.github = github self.country = country self.identity = identity self.want = want self.codelevel = codelevel self.subs = subs self.like = like @classmethod def raw_input(cls): return cls(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12) var1 = input("First Name: \n") var2 = input("Last Name: \n") var3 = input("Email: \n") var4 = int(input("Country code: \n")) var5 = int(input("Phone number: \n")) var6 = input("Github profile: \n") var7 = input("Country: \n") var8 = input("Identity (Woman/Non Binary/Man): \n") var9 = input("I want to (Find my next job/Become a freelancer/Start my own tech startup): \n") var10 = input("My coding level is (Beginner/Intermediate/Advanced): \n") var11 = input("I want to subscribe to and join the following groups (Student/Working/Job seeking/Entrepreneur/Mom/Single Mom/Non-Binary/Trans/Retired/Career changer): \n") var12 = input("I would also like to (Volunteer/Mentor/Hire): \n") user = Studentform.raw_input()
Blockchain Visionary & Aspiring Encipher/Software Developer
me = {'Python Learner' : 'Beginner\'s Level'}
http://bit.ly/JoinMeOnYouTube
me = {'Python Learner' : 'Beginner\'s Level'}
http://bit.ly/JoinMeOnYouTube