Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does an old version of “A byte of Python” claim that # is the less-equals operator?

Somebody just showed me an old PDF version of A byte of Python. According to itself, it’s version 3.0 (of the book, not of Python) and from 2014. In the section Operators, there is a section that goes

# (less than or equal to)

Returns whether x is less than or equal to y
x = 3; y = 6; x # y returns True.

In Python 2.7 and Python 3.6, this clearly wrong. Also this would be very bad design since # is also the comment operator.

The current version changed this from # to <=. I am curious why the old version claimed this.

My research and thoughts so far

  • I cannot find anything on the Internet that some old version of Python allowed this.
  • I cannot find any changelog or erratum on this.
  • Since the presumed mistake is made twice, I don’t expect it to be a typo.
  • I don’t expect it to be some autoconversion mistake since it would have to convert two ASCII characters (<=) into one (#).
like image 777
Wrzlprmft Avatar asked Dec 14 '25 04:12

Wrzlprmft


1 Answers

Version 3.0 of the book was written in AsciiDoc. This markup language defines special meaning to some constructs like the Double left arrow <= which is converted to the single Unicode character on transformation to the final output. This is documented in its syntax description at https://asciidoctor.org/docs/asciidoc-syntax-quick-reference/#text-replacement

Now, it appears that during conversation to PDF, this character was lost and replaced with a pound character. This (as well as the initial conversation of the <= sequence to the arrow character itself) is obviously a bug.

Since the current version of the book was converted to Markdown, this bug was fixed there already. You thus likely want to use the current version of the book instead which you can download from GitBook.

like image 140
Holger Just Avatar answered Dec 15 '25 18:12

Holger Just



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!