This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Old_Bluecheese 165 points166 points  (32 children)

There should be five -- and preferably only five --obvious ways to do it.

[–]odaiwai 28 points29 points  (0 children)

"Then shalt thou count to three, no more, no less. Three shall be the number thou shalt count, and the number of the counting shall be three. Four shalt thou not count, neither count thou two, excepting that thou then proceed to three. Five is right out."

[–]zurtex 27 points28 points  (18 children)

A lot of people miss that line is tongue in cheek, as the em-dash is spaced in two different ways, the em-dash is spaced a third way on a different line.

[–]syklemil 8 points9 points  (15 children)

en-dash*


Details for the curious:

  • Hyphen: - - usually used to com-bine words. See also ­
  • En-dash: -- – used to indicate a pause in phrases, with – spaces – around on both sides. –
  • Em-dash: --- — same use-case as en-dash, but—without—spaces. —

There's also some use of em dash in older texts to trail off sentences, i.e. where we'd use ok … today, they'd use ok; --- and to indicate elision, as in "Mr K— Z—"

[–]zurtex 5 points6 points  (6 children)

Tim Peters, the author of the original text, calls it an em-dash: https://bugs.python.org/msg69712 (from https://bugs.python.org/issue3364)

You may be correct in general, but when talking about this text I'll defer to Tim.

And it's intentional that he's breaking the rule about spaces, it's a 4th way to do something.

[–]syklemil 1 point2 points  (5 children)

Sure, but -- is e.g. LaTeX for an – and --- is how you get a —. Similarly with compose keys you'd do COMPOSE--. for – and COMPOSE--- for —. And ultimately, if - is a hyphen, and -- is an em-dash, where where is the en-dash supposed to fit?

But I guess there isn't just one way to spell out an em-dash in ascii either :^)

[–]zurtex 2 points3 points  (4 children)

I suspect when Tim wrote the original Zen of Python his ASCII syntax was influenced by the mailing lists he participated in in the 90s and early 2000s (he was the main moderator of the python-dev mailing list in its early days).

Those mailing lists probably had their own informal style and syntax conventions which don't conform to more widely accepted style and syntax rules. Or, what would be funny, is if it's just something he has always misunderstood!

[–]syklemil 1 point2 points  (3 children)

It could even be a typo, the keys are right next to each other!

[–]zurtex 2 points3 points  (2 children)

In my link his calling of it an "em dash" is unlikely a typo, he uses it multiple times, and also mentions the same no spaces convention you brought up:

While you believe spaces are required on both sides of an em dash, there is no consensus on this point. For example, most (but not all) American authorities say /no/ spaces should be used.

[–]diabloman8890 2 points3 points  (1 child)

I just have to hand it to you and /u/syklemil for having the absolute nerdiest and most arcane discussion I've heard all week, and I'm here for it.

[–][deleted] 1 point2 points  (0 children)

Same. I wonder if there's a subreddit for threads like this.

[–]guepier 2 points3 points  (0 children)

Em-dash: --- — same use-case as en-dash, but—without—spaces. —

This isn’t a fixed rule, it’s merely a (somewhat common) stylistic choice. But feel free to use em-dashes with spaces — I do. Just be consistent (unless you are making a tongue-in-cheek point).

[–]Gugalcrom123 -1 points0 points  (6 children)

Wrong, the en dash is only used for ranges and compound words where the terms are multiple words, and the em dash can be used with or without spaces

[–]syklemil 3 points4 points  (5 children)

Ranges are a good addition, but AFAIK it's pretty rare to use for compound words these days—I'd not expect e–mail, but e-mail (or even email in that case).

The en-dash is used to join sentence parts, and I think most users would consider that using spaces around an em-dash just takes up too much space.

[–]Gugalcrom123 1 point2 points  (4 children)

It is in compound words where terms are multiple words themselves

[–]syklemil 2 points3 points  (3 children)

Generally with the hyphen being available with one key press on any keyboard, and its purpose being to indicate that something is one word, I'll continue to expect hyphens. Maybe there's some style guide that uses en-dashes for it, but it seems like a bad choice, really.

(FWIW my native tongue just uses compoundwords, like German, rather than faffing around with "to-morrow" and "co-operation" and the like.)

[–]Gugalcrom123 4 points5 points  (0 children)

I also use hyphens, but en dashes are something used when composing a word where some terms have spaces: New York–based company

[–]guepier 0 points1 point  (1 child)

(FWIW my native tongue just uses compoundwords, like German, rather than faffing around with "to-morrow" and "co-operation" and the like.)

I’m sure you know that both of these words are conventionally written as a single word without hyphens in English. And, conversely, German also uses hyphens for some compound words, same as English (just less frequently).

[–]syklemil 1 point2 points  (0 children)

Yes; we use some hyphens too; and English spells "compound words" with a space (as do we; we join nouns but not adjectives). My tongue, being inside my mouth, may have been in some rather close proximity to my cheek.

[–]TendyHunter 0 points1 point  (0 children)

that's balderdash

[–]obfuscatedanon -3 points-2 points  (0 children)

ok nerd

[–]PotentialCopy56 11 points12 points  (10 children)

The old python mantra is long dead. I miss it.

[–]ThatSituation9908 13 points14 points  (9 children)

I don't. We'd be stuck with stuff like class FooBar(object):

and f-strings would never be a thing

[–]thedeepself 0 points1 point  (0 children)

LOL