Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'string.': 0.05; 'binary': 0.07; 'string': 0.09; 'collier': 0.09; 'literal': 0.09; '1234': 0.16; '36,': 0.16; 'binary.': 0.16; 'digits.': 0.16; 'doing,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'notation': 0.16; 'syntax,': 0.16; 'wrote:': 0.18; "python's": 0.19; 'written': 0.21; '>>>': 0.22; "aren't": 0.24; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'quotes': 0.31; "can't": 0.35; 'something': 0.35; 'johnson': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'numbers': 0.61; "you're": 0.61; '30,': 0.65; 'here': 0.66; 'jul': 0.74; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=ZQwuOk2jNlkct+FxDu5CzeHq/Zq99u3/QHwwHPc5MY4=; b=enu9KGMhmXaT6FhaCR/N6tqm3utIwFKQPcwKoSmfFbzhxSu+kSeCUmt3i60yo8c4gJ gXkF7kpHqFa9W90OEo1aChsbKAEoCDMCZ01rAlu0Na7ZTKNHC5j0S1V+QQnTvpekx81U QAdc4k4eKk8KOma3n0X7/zi09Ps1R3qu/+4ejcGdjkao+2Sfm6g0OkgQq208JboSR5Bp SvhXE1X9tKrpoiYrGVwE7LsJi0O6+a/EW247MamZpdtpe4szOtYzhfgOkY9+JgcH9yEw TXOmv9xDun8aufjtggShcSU0x6IC7hxIym73YTSqvuY8IUKGIWVOJBblE/gqNNVUmoRK CXfw== MIME-Version: 1.0 X-Received: by 10.220.169.146 with SMTP id z18mr9366286vcy.80.1375142866958; Mon, 29 Jul 2013 17:07:46 -0700 (PDT) In-Reply-To: <51F6FF52.4040806@Gmail.com> References: <51F6FBE8.8000106@Gmail.com> <51F6FDB2.9040307@stoneleaf.us> <51F6FF52.4040806@Gmail.com> Date: Tue, 30 Jul 2013 01:07:46 +0100 Subject: Re: Bitwise Operations From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375142869 news.xs4all.nl 15919 [2001:888:2000:d::a6]:32868 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51529 On Tue, Jul 30, 2013 at 12:48 AM, Devyn Collier Johnson wrote: > Now here is something that confuses me, the binary numbers are numbers not > strings, so why are they put in quotes as if they are strings? They aren't numbers at that point, they're strings of digits. A number is represented in various forms: >>> 1234, 0x4d2, 0o2322, 0b10011010010 (1234, 1234, 1234, 1234) The two-argument form of int() takes a string of digits and a base: >>> int("ya",36) 1234 In base 36, y and a are digits. But in Python's base syntax, you can't use them that way, so there's no way to render the number other than as a string. For what you're doing, I think the 0b notation is the best. It's an int literal written in binary. ChrisA