var1 = var2 = var3

57 views
Skip to first unread message

anotherdjangonewby

unread,
Feb 16, 2016, 3:06:10 PM2/16/16
to django...@googlegroups.com
Hi,

this may be a bit off-topic, but:

How are expressions like:

var1 = var2 = var3

called Python. Without a hint I cannot goolge this.

Thanks

Kai

Alex Heyden

unread,
Feb 16, 2016, 3:13:06 PM2/16/16
to django...@googlegroups.com
That's an assignment statement. See https://docs.python.org/2/reference/simple_stmts.html for more.



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/56C38119.5040807%40gmx.de.
For more options, visit https://groups.google.com/d/optout.

srinivas devaki

unread,
Feb 17, 2016, 6:50:35 AM2/17/16
to django...@googlegroups.com
what a coincidence, i just asked a similar question 7 hours before
you, at pytho...@python.org

here's the link, you can extend the discussion there to get more
answers, as it is more related to the language rather than django.

link: https://mail.python.org/pipermail/python-list/2016-February/703235.html
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/56C38119.5040807%40gmx.de.
> For more options, visit https://groups.google.com/d/optout.



--
Regards
Srinivas Devaki
Junior (3rd yr) student at Indian School of Mines,(IIT Dhanbad)
Computer Science and Engineering Department
ph: +91 9491 383 249
telegram_id: @eightnoteight

Nikolas Stevenson-Molnar

unread,
Feb 17, 2016, 7:28:27 PM2/17/16
to Django users, anotherdj...@gmx.de
The term is "chained assignment" (applied to other languages as well).


_Nik

Bill Freeman

unread,
Feb 18, 2016, 12:02:30 PM2/18/16
to django-users
The interesting thing is how chained assignment is implemented.  In C, the following is an expression, and has a value:

   a = b

This leads to the compiler not being helpful for the famous =/== typo in this like:

  if (a = b)  { ... }

In python the only expression in:

  a = b = c

only has one expression: c

The rest is syntax for the assignment statement, where trailing = identifies each of the targets to which the value of c is to be assigned.

An assignment statement begins with a series of one or more target specifiers and ends with a single expression.

(Targets can be more complex, e.g.; x, y = p = 0, 0)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages