z= 0
for x in range (1,5):
if x is not 3:
y = x = z
z=x+2*y-100
print(y)
#print(x)
0
-100
-400
z= 0
for x in range (1,5):
if x is not 3:
y = x = z
z=x+2*y-100
print(y)
print(x)
0
0
-100
-100
-400
-400
Is there a way I can simply get the y and x values directly? Like…
0
-100
-400
0
-100
-400
No debugging, please… It’s irrational for me.
What I’ve tried so far with the Python programming language is nonsense. In a nutshell, the guy who wrote Python is duping people. It’s a good thing for him because he could sit in the seat forever. I watched his interview once, and yet he didn’t (intentionally) address the core part of the language.
Direct answers, such as “What is the VALUE of x and y?” Visually, it’s similar to the current push-pull operation. My eyeball has to track each line of action.
Then just print X or Y… they’re both the same value all the time anyway, they’re actually the same variable. You expected 2 print statements per run of the loop to print one thing?
here is what your original code means & does, step by step
at iteration #
0: x is 1
z is 0
set x and y to 0
set z to 0+(2*0)-100 = -100
1: x is 2
z is -100
set x and y to -100
set z to -100+(2*-100)-100 = -400
2: x is 4
z is -400
set x and y to -400
set z to -400+(2*-400)-100 = -1300
3: x is 5
z is -1300
set x and y to -1300
set z to -1300+(2*-1300)-100 = -4000
at end
x is -1300
y is -1300
z is -4000
when you write y = x = z, it is like writing
tmp = z
y = tmp
x = tmp
there is nothing irrational here, creating a language entails making design decisions
and one goal in designing a language is that it should help programmers do the right thing, so what happened in your example where z was not defined, is that python’s design says it should assume you have mistakenly used an undefined variable, and refuse to continue on in an undefined state – this is a good thing, not a bad one
Because it’s like a math language, but it’s not strictly. However, it’s also like a math language. Conceptually, they’re almost similar but not exact, like 100%.
Hmm, very deep… I think I’m too rooted in the real world to understand this sort of higher plane philosophical statement…
Speaking of real world, what is your goal here? Are you wanting to learn to script/program functions in Rhino with Python, or is this more of a theoretical investigation into the language and its structure…
From a practical standpoint, on this forum and elsewhere are thousands of scripts for Rhino written in Python which work great, not to mention the bazillions of other people using Python to program all sorts of things, so calling it “nonsense” is actually nonsense.
Yes, because that’s how I’m oriented. RhinoPython is a long way from where I am now, but I have some theories (nothing serious, just personal interests as a hobby) about how to combine everything.
“Nonsense” is based on mathLang (?); it’s subjective as well, as everyone’s mind is his or her own universe.
I also believe that this universe is “what you and I defined.”
I guess almost every programming language then is stupid.
And to be honest, that is how people work too. If you don’t define a new concept in a discussion, but leave it up to imagination, you’ll get essentially undefined behavior. Unexpected results from what you were intending. People not understanding what you are trying to say.