Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'binary': 0.07; 'collier': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:184.172': 0.09; 'received:gator410.hostgator.com': 0.09; '~ethan~': 0.09; "'or',": 0.16; 'above)': 0.16; 'bitwise': 0.16; 'command.': 0.16; 'integer.': 0.16; 'operations?': 0.16; 'wrote:': 0.18; 'typing': 0.19; '>>>': 0.22; 'example': 0.22; 'header:User- Agent:1': 0.23; '(such': 0.24; 'errors.': 0.24; 'instance,': 0.24; 'script': 0.25; 'task': 0.26; 'header:In-Reply-To:1': 0.27; 'google,': 0.29; 'gives': 0.31; 'url:python': 0.33; 'something': 0.35; 'johnson': 0.35; 'but': 0.35; 'charset:us-ascii': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'future': 0.60; 'tell': 0.60; 'received:173': 0.61; "you'll": 0.62; 'saw': 0.77; 'url:search': 0.81; 'quicker': 0.84; 'edwards': 0.91 Date: Mon, 29 Jul 2013 16:41:38 -0700 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Bitwise Operations References: <51F6FBE8.8000106@Gmail.com> In-Reply-To: <51F6FBE8.8000106@Gmail.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([173.12.184.233]) [173.12.184.233]:59533 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 3 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375141301 news.xs4all.nl 15884 [2001:888:2000:d::a6]:40423 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51522 On 07/29/2013 04:34 PM, Devyn Collier Johnson wrote: > > On 07/29/2013 05:53 PM, Grant Edwards wrote: >> On 2013-07-29, Devyn Collier Johnson wrote: >> >>> On Python3, how can I perform bitwise operations? For instance, I want >>> something that will 'and', 'or', and 'xor' a binary integer. >> http://www.google.com/search?q=python+bitwise+operations >> > I understand the symbols. I want to know how to perform the task in a script or terminal. I have searched Google, but I > never saw a command. Typing "101 & 010" or "x = (int(101, 2) & int(010, 2))" only gives errors. x = (int('101', 2) & int('010', 2)) Notice the quotes. In the future you'll better answers quicker if you tell us what you did (such as your example above) as well as the errors. -- ~Ethan~