Quote:
|
Originally Posted by zem52887
As for the company_url changes, does that need to be defined? If I'm running this function in isolation it doesn't know what company_url is, no? or are these proposed changes for the actual script -- not the test script?
|
You don't quite understand how functions work.
Take this simple function:
def double(x):
return x * 2 In this function x is an
argument. This means that it is assigned a value whether the function is called:
y = double(2) # x is 2 and y is 4
z = double(3) # x is 3 and z is 6
Any value passed into the function gets assigned to x:
some_value = 5
print double(some_value) # x becomes equal to some_value (ie. 5)
The name of an argument (such as x, or company_url) is local to the function. It has no meaning outside of the function, and is not affected by outside variables.
Let me give another example, to show you what I mean:
x = 10
def foobar(x):
print "Argument x =", x
x = 7
print "Argument x =", x
print "Global x =", x
foobar(16)
print "Global x =", x The output to this code is:
Global x = 10
Argument x = 16
Argument x = 7
Global x = 10
Notice how the x defined at the start (ie. the "global" x) is completely separate from the x inside the function.
Quote:
|
Originally Posted by zem52887
finally, I seem to encounter this error a lot:
output += "<td>" + companyprofile + "</td>"
TypeError: 'NoneType' object is not callable
could you remind me as to what it means so I can try troubleshooting it?
|
It means that a variable which references None cannot be called as a function. The following code demonstrates the error:
None is a special object that roughly means "Nothing", or "Undefined". Functions that don't have a return statement default to returning None.