| | |
Return a class in function definition???
Thread Solved |
•
•
Join Date: Oct 2007
Posts: 30
Reputation:
Solved Threads: 0
Here is the code:
def ols(x, y):
class output:
pass
results = output()
results.method = 'ols'
results.y = y
results.nobs = n
results.nvar = nvar
results.beta = B
return results
It looks like the above is not working with exit code 0 after exeuction. What normally python return exit code after execution? I tested one with exit code 0. I am not sure it is normal or not.
Another thing is there any good debug tool in IDE showing the values in variables during debug? The one IDE coming with Python Win does not have this function. Maybe I am wrong.
def ols(x, y):
class output:
pass
results = output()
results.method = 'ols'
results.y = y
results.nobs = n
results.nvar = nvar
results.beta = B
return results
It looks like the above is not working with exit code 0 after exeuction. What normally python return exit code after execution? I tested one with exit code 0. I am not sure it is normal or not.
Another thing is there any good debug tool in IDE showing the values in variables during debug? The one IDE coming with Python Win does not have this function. Maybe I am wrong.
•
•
Join Date: Jul 2006
Posts: 608
Reputation:
Solved Threads: 150
This code runs fine:
I think the problem with yours might have been that you were accessing non-existent variables n, nvar, and B.
Jeff
Python Syntax (Toggle Plain Text)
def ols(x, y): class output: pass results = output() results.method = 'ols' results.y = y #results.nobs = n #results.nvar = nvar #results.beta = B return results r = ols(1,2) print r
I think the problem with yours might have been that you were accessing non-existent variables n, nvar, and B.
Jeff
•
•
Join Date: Oct 2007
Posts: 30
Reputation:
Solved Threads: 0
•
•
•
•
This code runs fine:
Python Syntax (Toggle Plain Text)
def ols(x, y): class output: pass results = output() results.method = 'ols' results.y = y #results.nobs = n #results.nvar = nvar #results.beta = B return results r = ols(1,2) print r
I think the problem with yours might have been that you were accessing non-existent variables n, nvar, and B.
Jeff
Thanks so much, Jeff.
John
![]() |
Similar Threads
- How Do I . . . Make a Class Accessible from a DLL (C++)
- How do I declare a class member function in another class? (Python)
- Deciding return type of a function at runtime (C++)
- Settle a discussion about Template contruct (C++)
- Implementing a C++ class for a ring buffer (C++)
- Compiler error (C++)
- Adding memberfunctions into a class? (C++)
- Printing to Screen in a Class (C++)
- Function Error Message Help (C++)
- Accessing functions from base class (C)
Other Threads in the Python Forum
- Previous Thread: Convert negative decimal to binary
- Next Thread: xmlrpc register multiple instances
| Thread Tools | Search this Thread |
abrupt accessdenied anti apache application approximation argv array beginner book builtin calculator change converter countpasswordentry curved dan08 dictionaries dictionary dynamic edit enter examples file float format function gui heads homework import inches input java keyboard lapse launcher library line lines linux list lists loop microphone mouse movingimageswithpygame mysqlquery newb number numbers numeric output parameters parsing path phonebook plugin port prime programming projects py2exe pygame pyopengl python random recursion redirect remote reverse scrolledtext session simple software sprite statictext string strings syntax table terminal text textarea thread threading time tlapse trick tuple tutorial twoup ubuntu unicode unit urllib urllib2 variable wordgame wxpython






