Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51526

Re: Bitwise Operations

Path csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <devyncjohnson@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.090
X-Spam-Evidence '*H*': 0.82; '*S*': 0.00; 'binary': 0.07; 'collier': 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; 'code': 0.31; 'received:10.0.0': 0.31; '>>>>': 0.31; 'quotes': 0.31; 'thanks!': 0.32; 'url:python': 0.33; 'something': 0.35; 'johnson': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'thanks': 0.36; 'received:10.0': 0.36; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'future': 0.60; 'tell': 0.60; 'numbers': 0.61; "you'll": 0.62; 'here': 0.66; 'close': 0.67; 'believe': 0.68; 'saw': 0.77; 'url:search': 0.81; 'ethan': 0.84; 'furman': 0.84; 'quicker': 0.84; 'edwards': 0.91; 'habit': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=Fr20c2/cENK6fM3jHh/wYdg2zNr/h3JxFSHAcUlrKCo=; b=qebiaBcBASge2l/R8h8rz4efC/IYICrHfd0qS7GCTkbPWDRnlAREhC0/PgQwcbqOAp cIypzsczalIjJ8CHaSmPKcUAwFbxdRzAqPpTlQ1+YJKhqTfpEPLOO8fR6+HT+fRCrCN9 sK83dJOnR8HSKAs0nEZij42CVF03zoSeiyH1pdESoceC00jPIIjLGgASd9hGN92ATeuM YsFY+voeDiVZ81acDCbRkVgLjyu4Qf6GAgilXw1zhckn8C/TzfZz9Zkme8KVA5YPKidp Yv4S6xojxH5BWkq+kz8IXk2060ZUT1dHWECHxO481tt244ot7tdPDGQdpx54zitWJI9o Ue/Q==
X-Received by 10.236.113.176 with SMTP id a36mr28553187yhh.14.1375141716866; Mon, 29 Jul 2013 16:48:36 -0700 (PDT)
Date Mon, 29 Jul 2013 19:48:34 -0400
From Devyn Collier Johnson <devyncjohnson@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7
MIME-Version 1.0
To Python Mailing List <python-list@python.org>
Subject Re: Bitwise Operations
References <mailman.5275.1375134621.3114.python-list@python.org> <kt6o8t$l55$1@reader1.panix.com> <51F6FBE8.8000106@Gmail.com> <51F6FDB2.9040307@stoneleaf.us>
In-Reply-To <51F6FDB2.9040307@stoneleaf.us>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5291.1375141726.3114.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1375141726 news.xs4all.nl 15888 [2001:888:2000:d::a6]:47812
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:51526

Show key headers only | View raw


On 07/29/2013 07:41 PM, Ethan Furman wrote:
> 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 <devyncjohnson@gmail.com> 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~
Thanks Ethan for the code help and the tip. I need to get out of that 
habit of not including errors. This code works well, thanks! I cannot 
believe I was that close to the solution!

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?


Mahalo,

DCJ

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Bitwise Operations Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-29 17:25 -0400
  Re: Bitwise Operations Grant Edwards <invalid@invalid.invalid> - 2013-07-29 21:53 +0000
    Re: Bitwise Operations Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-29 19:34 -0400
      Re: Bitwise Operations Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-07-30 08:20 +0200
    Re: Bitwise Operations Ethan Furman <ethan@stoneleaf.us> - 2013-07-29 16:41 -0700
    Re: Bitwise Operations Chris Angelico <rosuav@gmail.com> - 2013-07-30 00:44 +0100
    Re: Bitwise Operations Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-29 19:48 -0400
    Re: Bitwise Operations Chris Angelico <rosuav@gmail.com> - 2013-07-30 01:07 +0100
    Re: Bitwise Operations MRAB <python@mrabarnett.plus.com> - 2013-07-30 02:55 +0100
    Re: Bitwise Operations Terry Reedy <tjreedy@udel.edu> - 2013-07-30 01:46 -0400

csiph-web