From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: Bug: verbatim export of python code block with numpy array returns wrong value [8.2.1 (8.2.1-10-g9c1ef6-elpaplus @ /Users/sbagley/Dropbox/emacsd/elpa/org-plus-contrib-20131014/)] Date: Tue, 22 Oct 2013 10:09:04 +0200 Message-ID: <87hac97mn3.fsf@gmx.us> References: <1382325842.22991.36399041.526C4DD7@webmail.messagingengine.com> <87sivuqbnk.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VYWzO-0008LU-Ct for emacs-orgmode@gnu.org; Tue, 22 Oct 2013 04:07:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VYWzD-0007tH-AE for emacs-orgmode@gnu.org; Tue, 22 Oct 2013 04:06:54 -0400 Received: from plane.gmane.org ([80.91.229.3]:45939) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VYWzD-0007tA-3B for emacs-orgmode@gnu.org; Tue, 22 Oct 2013 04:06:43 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VYWz6-00010u-Lc for emacs-orgmode@gnu.org; Tue, 22 Oct 2013 10:06:36 +0200 Received: from dynamic-adsl-94-34-254-188.clienti.tiscali.it ([94.34.254.188]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 22 Oct 2013 10:06:36 +0200 Received: from rasmus by dynamic-adsl-94-34-254-188.clienti.tiscali.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 22 Oct 2013 10:06:36 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Eric Schulte writes: > Hi Steve, > > Is this a Python problem or is it numpy specific? > > Is repr() a numpy or a Python function i.e., could it replace str() in > every Python code block or only when numpy is loaded? repr is a Python-thing and it's main feature, I guess, is eval(repr(object)) == object cf. below. So e.g. In [1]: import numpy as np In [2]: repr(np.array([1,2,3])) Out[2]: 'array([1, 2, 3])' In [3]: str(np.array([1,2,3])) Out[3]: '[1 2 3]' I'm not sure convinced that repr is necessarily better, tho. Here's the docstrings. In [4]: str? Type: type String Form: Namespace: Python builtin Docstring: str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'. In [5]: ?repr Type: builtin_function_or_method String Form: Namespace: Python builtin Docstring: repr(object) -> string Return the canonical string representation of the object. For most object types, eval(repr(object)) == object. –Rasmus -- Got mashed potatoes. Ain't got no T-Bone. No T-Bone