from a module return a class

kevind0718 at gmail.com kevind0718 at gmail.com
Fri Mar 18 15:19:23 EDT 2016


On Friday, March 18, 2016 at 12:16:13 PM UTC-4, John Gordon wrote:
> In <mailman.332.1458315013.12893.python-list at python.org> Wolfgang Maier <wolfgang.maier at biologie.uni-freiburg.de> writes:
> 
> > > So promptUser_PWord is a module?  Well, I'm confused.  You gave us this
> > > bit of code:
> > >
> > >      user_pword = promptUser_PWord()
> > >
> > > But that can't work if promptUser_PWord is a module; modules aren't
> > > callable.  promptUser_PWord() has to be a function or a class.
> > >
> 
> > Yes, but I guess the OP's program will run into the SyntaxError when 
> > trying to import the module, i.e., before it ever encounters the 
> > TypeError: 'module' object is not callable.
> 
> Good point; I hadn't thought of that.
> 
> -- 
> John Gordon                   A is for Amy, who fell down the stairs
> gordon at panix.com              B is for Basil, assaulted by bears
>                                 -- Edward Gorey, "The Gashlycrumb Tinies"

true I get the following:  
  File "H:\dev\eclipse\workspace\genXls\src\genXls\genXlswPrompt.py", line 11, in <module>
    import promptUser_PWord
  File "H:\dev\eclipse\workspace\genXls\src\genXls\promptUser_PWord.py", line 58
    return user_pword
SyntaxError: 'return' outside function

so what I get from the various postings is promptUser_PWord must be
converted to a class.  True?



More information about the Python-list mailing list