Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with my code
#1
Hello Guys,
i am working on a school project and could need some help.

command = [getuser(),getpw(),getnewuser(),getnewpw(),getreppw()]
variable = [user,pw,newU,newpw,reppw]
surce = [e1,e2,f1,f2,f3]


for i in range(5) :
    def command[i]:
        global variable[i]
        variable[i] = surce[i].get()
        return variable[i]
As you see i have to create lots of defs and like to shorten this,
because i have to add even more variables and it would be way more efficent if i
could just add it to the list, instead of creating a new def.

def getuser():
    global user
    user = e1.get()
    return user

def getpw():
    global pw
    pw = e2.get()
    return pw

def getnewuser():
    global newU
    newU = f1.get()
    return newU

def getnewpw():
    global newpw
    newpw = f2.get()
    return newpw

def getreppw():
    global reppw
    reppw = f3.get()
    return reppw


Thanks for your help.

Greedings
Godx
Reply


Messages In This Thread
Problem with my code - by Godx - Aug-21-2018, 05:00 PM
RE: Problem with my code - by Gribouillis - Aug-21-2018, 05:36 PM
RE: Problem with my code - by Godx - Aug-21-2018, 06:10 PM
RE: Problem with my code - by Axel_Erfurt - Aug-21-2018, 06:18 PM
RE: Problem with my code - by Godx - Aug-21-2018, 06:48 PM
RE: Problem with my code - by Axel_Erfurt - Aug-21-2018, 08:54 PM
RE: Problem with my code - by perfringo - Aug-22-2018, 05:24 AM

Forum Jump:

User Panel Messages

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