Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #105697

Re: Tkinter --> Why multiple windows

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Newsgroups comp.lang.python
Subject Re: Tkinter --> Why multiple windows
Date 2016-03-25 13:03 -0400
Organization IISS Elusive Unicorn
Message-ID <mailman.6.1458925358.28225.python-list@python.org> (permalink)
References <d1b257d3-6d27-4201-b3db-e363409b2623@googlegroups.com> <OYWdncAt39_MDmnLnZ2dnUU7-I-dnZ2d@giganews.com> <7d191efb-fe80-488f-87db-268b4b893d42@googlegroups.com>

Show all headers | View raw


On Fri, 25 Mar 2016 06:41:48 -0700 (PDT), kevind0718@gmail.com declaimed
the following:


>class Unamepword:
>    ## 
>    ## class to hold user name and pWord for Database
>    uName = None
>    pWord = None

	Those are essentially useless...

>    def __init__(self, uStr, pStr):

		uStr and pStr are required arguments to the instance creation, and

>        self.uName = uStr
>        self.pWord = pStr
>
here you bind them to the instance specific uName/pWord attributes. The
class-wide uName/pWord will never be visible unless somewhere you
explicitly use
		Unamepword.uName
or 
		Unamepword.pWord 
in some method of the class, in order to bypass the instance attribute.

	Since you don't show the entire class I can't comment further -- if all
it does is set those attributes you could just as easily use a dictionary

login = Unamepword("bob", "secret")

print login.uName, login.pWord

vs

login = {	"uName" : "bob",		"pWord" : "secret" }

print login["uName"], login["pWord"]

	Note: I'm not necessarily recommending the latter -- just offering
alternatives... If you assume username is always first a simple tuple might
do

login = ("bob", "secret")
print login[0], login[1]

...

UNAME = 0
PWORD = 1

print login[UNAME], login[PWORD]
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Tkinter -->  Why multiple windows kevind0718@gmail.com - 2016-03-24 13:24 -0700
  Re: Tkinter -->  Why multiple windows Random832 <random832@fastmail.com> - 2016-03-24 16:28 -0400
    Re: Tkinter -->  Why multiple windows kevind0718@gmail.com - 2016-03-24 13:43 -0700
      Re: Tkinter --> Why multiple windows Terry Reedy <tjreedy@udel.edu> - 2016-03-24 21:27 -0400
  Re: Tkinter -->  Why multiple windows Wildman <best_lay@yahoo.com> - 2016-03-24 20:24 -0500
    Re: Tkinter -->  Why multiple windows kevind0718@gmail.com - 2016-03-25 06:41 -0700
      Re: Tkinter -->  Why multiple windows Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-03-25 13:03 -0400

csiph-web