468,287 Members | 2,024 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,287 developers. It's quick & easy.

Class name as argument

Snippet 1 below doesn't do much but works (more code is inserted by a
generator). In the next to last line the class name is also used as
argument. I have seen this construct before and have had error
messages tell me that the name is expected. Why is this so? In snippet
2 that I concocted is not required. Is it related to __init__ perhaps?

Thanks,

jvh

# Snippet 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

from PyHttpTestCase import PyHttpTestCase

# definition of test class
class MaxQTest(PyHttpTestCase):
def runTest(self):
self.msg('Test started')

# ^^^ Insert new recordings here. (Do not remove this line.)

# Code to load and run the test
if __name__ == 'main':
test = MaxQTest("MaxQTest")
test.Run()
# Snippet 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class topClass():
str = 'abc'
def tcMsg(self):
print 'topClass tcMsg'

class one(topClass):
strOne = 'class one'

def classOneFun(self):
print 'this is classOneFun'
self.tcMsg()

if __name__ == 'main':
test = one()
test.classOneFun()

May 14 '07 #1
1 1035
En Mon, 14 May 2007 19:34:52 -0300, HMS Surprise <jo**@datavoiceint.com>
escribió:
Snippet 1 below doesn't do much but works (more code is inserted by a
generator). In the next to last line the class name is also used as
argument. I have seen this construct before and have had error
messages tell me that the name is expected. Why is this so? In snippet
2 that I concocted is not required. Is it related to __init__ perhaps?
The arguments are those expected by the class constructor: __new__, and
initializer: __init__.
It's up to the class designer to define which arguments are required -if
any- and which ones are optional -if any-.
In your case, see the documentation for PyHttpTestCase.

--
Gabriel Genellina

May 15 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Andrew Dalke | last post: by
4 posts views Thread by Neil Zanella | last post: by
10 posts views Thread by Chris Green | last post: by
18 posts views Thread by John M. Gabriele | last post: by
3 posts views Thread by kackson | last post: by
5 posts views Thread by Dylan Moreland | last post: by
5 posts views Thread by Joe Van Dyk | last post: by
13 posts views Thread by Hussein B | last post: by
2 posts views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.