from a module return a class

kevind0718 at gmail.com kevind0718 at gmail.com
Thu Mar 17 12:19:28 EDT 2016


Hello:

Working with python 2.7.

I have a module promptUser_PWord  that will prompt a user for their user name and pword.  Works fine stand alone.
I also have a module, genXLS that does a bunch of processing it has worked fine for months.  And a class Unamepword define as follows:
class Unamepword:
    ## 
    ## class to hold user name and pWord for Database
    uName = None
    pWord = None
    def __init__(self, uStr, pStr):
        self.uName = uStr
        self.pWord = pStr

There are scenarios where running genXLS requires the user to be prompted for their user name and password.

The final line of promptUser_PWord are:
    user_pword =  Unamepword(dbUser, pWord)
    return user_pword


And in genXLS I have  
    ##  prompt the user for a User name a& pWord
    user_pword = promptUser_PWord()   

I get the error 
  File "H:\dev\eclipse\workspace\genXls\src\genXls\promptUser_PWord.py", line 58
    return user_pword
SyntaxError: 'return' outside function


Here is my complete newbee question:
   How do I stich these pieces together so the user will be prompted and the values (contained in the class Unamepword) will be passed back to genXLS ?

Many thanks for your attention to this matter.

KD






More information about the Python-list mailing list