11

SO's Google code prettify on python wrongly handles // (floor division) as a C-style comment, as noted here, even when the question is tagged .

Here is a more recent example from this SO question:

a[:len(a)//3*3]
  • 2
    How is March 6th 2011 "two years ago"? – balpha Jul 5 '11 at 8:13
  • Sorry, my tired brain misread 'edited Mar 6 at 20:08'. Doh. Edited that out. – smci Jul 5 '11 at 8:15
-2

Because Python is a "webby" language, and code snippets in those posts tend to contain a mixture of

  • HTML
  • CSS
  • Python

The syntax highlighting mode for the all questions tagged is set to default, that is, infer.

If you wish to override it, you can add the following hint above a code block.

<!-- language: lang-py -->

Per https://stackoverflow.com/editing-help#syntax-highlighting

  • I was documenting the known issue; at first glance I thought 'WTF?'. This issue was known two years ago, I assume someone at SO already filed that bug with Google Prettify, is that not so? – smci Jul 5 '11 at 8:01
  • I mean at first glance I couldn't understand what was happening and thought the highlighting was broken. Then I did some reading on meta and found this is a known issue. Thanks Jeff. – smci Jul 5 '11 at 8:07
  • @smci oh wait, I see. let me edit. – Jeff Atwood Jul 5 '11 at 8:08
  • Sorry, as balpha points out, the issue was noted 5 months ago, not 2 years. – smci Jul 5 '11 at 8:17
  • 1
    Is it not better to associate html with lang-html, css with lang-css, and python with lang-py, such that the tag-based language selection causes questions tagged with any combination of these tags to continue to use default, but single-tagged questions are specific? – Eric Aug 16 '13 at 14:37
  • 4
    Python is not a webby language. The number of Python posts that contain HTML or CSS are minimal. – Martijn Pieters Aug 16 '13 at 14:58

Not the answer you're looking for? Browse other questions tagged .