5

I am reading a Python book that uses the symbol

<-

It seems to be used interchangeably with the = sign. Is this a normal symbol to explain this? I have never seen it used elsewhere. enter image description here

CoderJK
  • 251
  • 2
  • 7
  • 1
    The difference of these assignment operators is actually a more [popular discussion in R](http://stackoverflow.com/questions/1741820/assignment-operators-in-r-and). Possibly, your citation referred to R and not Python? – Parfait Jul 18 '15 at 19:30
  • Definitely R syntax. – Malik Brahimi Jul 18 '15 at 19:36
  • 1
    I suppose it could be the `(*p).` C operator in a right-to-left language. But seriously, it is poor typesetting for the symbol `←` which I've seen used mostly in pseudo-code. It is pronounced "gets" as in "userAge gets 0". – msw Jul 18 '15 at 19:37
  • This isn't a question about Python at all -- it's a question about syntax and typography in the book you're reading, which *wasn't* following Python convention in that example. – Charles Duffy Jul 18 '15 at 19:42
  • Now that I know the answer, I absolutely agree it is no longer a Python question. – CoderJK Jul 19 '15 at 14:44

3 Answers3

6

It's not a symbol, it's simply showing that when you make an assignment using '=' you are placing the value on the right into the variable on the left.

Ajaypayne
  • 507
  • 6
  • 12
5

a <- b (better formatted as a < -b) means "a less than minus b" , so

>>> a = -5
>>> b = 3
>>> a <- b
True

>>> a = 3
>>> b = 4
>>> a <- b
False

In your image, as others have pointed out, the author is just indicating an assignment, it's unfortunate that the typography made it look like code, it wasn't meant to be a "less than minus".

Roshan Mathews
  • 5,560
  • 2
  • 24
  • 36
3

It's just a pseudo-code example, not Python syntax.

melpomene
  • 81,915
  • 7
  • 76
  • 137
DeepSpace
  • 72,713
  • 11
  • 96
  • 140