Probably simple syntax error

Dustin MacDonald dmacdonald95 at gmail.com
Mon Jul 2 00:40:28 EDT 2007


Hi everyone.

This is my first time posting to this newsgroup, and although I
maintain my netiquette I might've missed something specific to the
newsgroup, so hopefully you can avoid flaming me if I have :) I
apologize for the length of this post but I figure the more
information the better.

My problem is that I'm getting a syntax error in some Python code that
looks quite simple. The original code was in Object Pascal as I'm a
recent Delphi-turned-Python programmer.

I took the code (which is only about 130 lines in OP) and 'translated'
it the best I could into Python (ended up being one line shy of 80
when I was done). I can't see any problems with the code but it's
coming up with a bunch of errors, which I'm guessing are probably my
assuming something is the same in Python as it is in Pascal, and being
wrong.

Anyway, here's the code I'm having trouble with (the same error comes
up several times but this is the first part of the code it shows up
in):

[code]
randomizing_counter = 0
# Put the loop counter for the randomizing to zero.
until_val = 36
# Set the "until val" to 36. We'll compare them to make sure we're not
at the end of our wordlist_both.

while randomizing_counter < until_val:
	big_randomized_int = RandRange(0,100)
	# Make a random value and store it.
	small_randomized_int = big_randomized_int / 100
	# Divide that random value and store it in a different variable.
	small_randomized_int = Round(small_randomized_int, 2)
	# Round that value to 2 decimal places
	**weights_array(randomizing_counter) = small_randomized_int
	# Assign the first randomized value to our first word to be weighted.
	randomizing_counter = randomizing_counter + 1
	# Up the counter and repeat.
[/code]

The starred line is the one getting the error message: "SyntaxError:
can't assign to function call"

Now, I do understand what this means. I'm trying to assign to a
function instead of the value that the function should create. But
since when is weights_array or small_randomizing_int a function? Both
are being declared in the code on their first usage. This one has got
me stumped, maybe you guys can help me out with it?

Thanks,
~Dustin




More information about the Python-list mailing list