TypeError: 'bytes' object is not callable
<h1>Edit:</h1>

<p>I made the very trivial mistake of having bound <code>bytes</code> to something else previous to executing the following code. This question is now entirely trivial and probably doesn't help anyone. Sorry.</p>

<h1>Original question:</h1>

<p>Code:</p>

<pre><code>import sys
print(sys.version)
b = bytes([10, 20, 30, 40])
print(b)
</code></pre>

<p>Output:</p>

<pre><code>3.5.1 (v3.5.1:37a07cee5969, Dec  5 2015, 21:12:44) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-38-21fec5626bc3&gt; in &lt;module&gt;()
      1 import sys
      2 print(sys.version)
----&gt; 3 b = bytes([10, 20, 30, 40])
      4 print(b)

TypeError: 'bytes' object is not callable
</code></pre>

<p>Documentation:</p>

<pre><code>Type:        bytes
String form: b'hello world'
Length:      11
Docstring:
bytes(iterable_of_ints) -&gt; bytes
bytes(string, encoding[, errors]) -&gt; bytes
bytes(bytes_or_buffer) -&gt; immutable copy of bytes_or_buffer
bytes(int) -&gt; bytes object of size given by the parameter initialized with null bytes
bytes() -&gt; empty bytes object

Construct an immutable array of bytes from:
  - an iterable yielding integers in range(256)
  - a text string encoded using the specified encoding
  - any object implementing the buffer API.
  - an integer
</code></pre>

<p>What am I doing wrong?</p>

<p>You have assigned <em>a <code>bytes</code> value</em> to the name <code>bytes</code>:</p>

<pre><code>&gt;&gt;&gt; bytes([10, 20, 30, 40])
b'\n\x14\x1e('
&gt;&gt;&gt; bytes = bytes([10, 20, 30, 40])
&gt;&gt;&gt; bytes([10, 20, 30, 40])
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
TypeError: 'bytes' object is not callable
</code></pre>

<p><code>bytes</code> is now bound to the value <code>b'\n\x14\x1e('</code>, which is not callable. This global is shadowing the built-in. Delete it:</p>

<pre><code>del bytes
</code></pre>

<p>to reveal the built-in again.</p>

python byte