SyntaxError: can't assign to function call win32com.client
Hans Nowak
hnowak at cuci.nl
Thu Dec 2 16:12:10 EST 1999
On 1 Dec 99, at 18:35, tiddlerdeja at my-deja.com wrote:
> I'm trying to mirror this VB code (which works) with python code:
>
> objUser.DynamicProperty("BILLING_ADDRESS2") = "3 The Street"
>
> This code works in VB but in python I get the error:
>
> SyntaxError: can't assign to function call
>
> Can you tell me what syntax I need to use for python?
>
> Any help greatly appreciated. I don't want to have to use VB!
This behavior is maybe best mimicked by using dictionaries. A simple
example:
class User:
def __init__(self):
self.DynamicProperty = {}
objUser = User()
objUser.DynamicProperty["blah"] = 4
objUser.DynamicProperty["foo"] = [1, 42, "hello"]
print objUser.DynamicProperty["blah"]
etc...
I don't know much about properties in VB, but an expression like
objUser.DynamicProperty("X")
implies that DynamicProperty is a method of objUser, and thus a
function. Assigning to it isn't possible, compare
def twice(x): return 2*x
twice(4) = 7
Doesn't make much sense, does it? :) Not in Python anyway.
HTH,
--Hans Nowak (zephyrfalcon at hvision.nl)
Homepage: http://fly.to/zephyrfalcon
You call me a masterless man. You are wrong. I am my own master.
More information about the Python-list
mailing list