Python Forum
Why are two similar bits of code giving different results?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why are two similar bits of code giving different results?
#7
(Dec-08-2016, 11:01 AM)godmode Wrote: Which comes first?
Does they even change a value, or just after the next cycle?

No single value comes first. First all three values on the right side are calculated, only then the original values are replaced. So, yes just after the line, all values are changed at the same time. This is an easier way to write it without storing extra variables. Consider this:

a, b = b, a
When you want to split it in multiple lines, you need a third value c. Try it, maybe it's easier.
Reply


Messages In This Thread
RE: Why is it differ for giving a value - by nilamo - Dec-07-2016, 09:58 PM
RE: Why is it differ for giving a value - by Kebap - Dec-09-2016, 11:12 AM
RE: Why is it differ for giving a value - by nilamo - Dec-08-2016, 10:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [closed] check whether an integer is 32 or 64 bits paul18fr 4 198 May-27-2024, 04:55 PM
Last Post: deanhystad
  Is it possible to extract 1 or 2 bits of data from MS project files? cubangt 8 1,228 Feb-16-2024, 12:02 AM
Last Post: deanhystad
  Code works but doesn't give the right results colin_dent 2 801 Jun-22-2023, 06:04 PM
Last Post: jefsummers
  Compiles Python code with no error but giving out no output - what's wrong with it? pythonflea 6 1,702 Mar-27-2023, 07:38 AM
Last Post: buran
  How to rotate bits ? korenron 2 1,703 Mar-23-2022, 04:05 PM
Last Post: Larz60+
  From list of bits to PDF drimades 1 1,983 Nov-02-2021, 08:55 PM
Last Post: Gribouillis
  Sum similar items tester_V 3 2,047 Jun-29-2021, 06:58 AM
Last Post: tester_V
Exclamation Help in breaking bytes into bits through masking and shifting kamui123 9 4,752 Jan-11-2021, 07:42 AM
Last Post: kamui123
  Code giving same output no matter the input. Yort 2 2,664 Dec-20-2020, 05:59 AM
Last Post: buran
  Compiling Python 3.8.5 source code results in build error Deepan 0 2,233 Sep-14-2020, 04:11 AM
Last Post: Deepan

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020