Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91463
| References | <1432869619.871453.281061217.70B58077@webmail.messagingengine.com> <CAPTjJmpRycvcU_v4W3PQcn3gB2qeReQnTKg3u6beXT-BQrBDwg@mail.gmail.com> <20150529055315.5334cfeb@bigbox.christie.dr> |
|---|---|
| Date | 2015-05-30 00:38 +1000 |
| Subject | Re: Logic problem: need better logic for desired thruth table. |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.185.1432910840.5151.python-list@python.org> (permalink) |
On Fri, May 29, 2015 at 8:53 PM, Tim Chase <python.list@tim.thechases.com> wrote: > On 2015-05-29 13:48, Chris Angelico wrote: >> That said, though, using 0 for False and 1 for True is easily >> the most common convention in use today, and the next most likely >> case is that comparing booleans would give a simple and immediate >> error. So it's most likely to be safe to do. > > There are popular exceptions though. coughshellscriptingcough Yes, so you'd have to be careful if you port your complex script to bash [1]. I'm also not sure how you'd even implement the comparison. But shell scripting is still dwarfed by languages in which false is 0 and true is (usually) 1. Using Redmonk rankings: 1 JavaScript 2 Java 3 PHP 4 Python 5 C# 5 C++ 5 Ruby 8 CSS 9 C 10 Objective-C 11 Perl 11 Shell I'm not sure about Ruby, and I don't think CSS has a concept of boolean arithmetic, but ten languages outrank shell scripting (Perl is tied) and of them eight (maybe nine) use 0/1. Using langpop.com stats, shell scripting comse up rather higher, but it's still beaten out - and by considerable margins - by C, Java, PHP, JavaScript, C++, and Python, all of which use 0/1. The Tiobe index seems to split up several shells, which penalizes them severely (Bourne shell and bash both come up in the 51-100 range), but even if they were merged, they're unlikely to be able to nudge out the top five of Java, C, C++, Objective-C, and C#. So while it's clearly false to state that 0/1 is the _only_ convention in use today, it's fairly justifiably the _most common_. And of course, there are plenty of historical systems that were different, as have been mentioned. But most programmers aren't going to come across those... I hope! ChrisA [1] You'd also have to be insane. A bash script should not, in my opinion, exceed about a page or two of code. I'm not sure how large a bash script has to be before it collapses under its own gravity and forms a black hole out of which no comprehension or sanity can escape, but I'm taking no chances.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Logic problem: need better logic for desired thruth table. Chris Angelico <rosuav@gmail.com> - 2015-05-30 00:38 +1000
csiph-web