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


Groups > comp.lang.python > #94291

Re: Can I copy/paste Python code?

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
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; 'operator': 0.03; 'subject:Python': 0.05; 'used.': 0.05; '21,': 0.07; 'subject:code': 0.07; 'works.': 0.07; 'cc:addr:python-list': 0.09; 'situation.': 0.09; 'python': 0.10; 'itself.': 0.11; 'file,': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; "pdf's": 0.16; 'received:mail-ig0-x22a.google.com': 0.16; 'tabs': 0.16; 'wrote:': 0.16; 'string': 0.17; 'drawing': 0.18; 'creates': 0.18; '>>>': 0.20; 'together.': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'file.': 0.22; 'trying': 0.22; 'code,': 0.23; 'code.': 0.23; 'seems': 0.23; 'words': 0.24; 'header:In-Reply-To:1': 0.24; 'all.': 0.24; "i've": 0.25; "doesn't": 0.26; 'chris': 0.26; 'message-id:@mail.gmail.com': 0.27; 'data,': 0.27; 'idea': 0.28; 'indentation': 0.29; 'spaces': 0.29; 'typically': 0.29; "i'm": 0.30; 'subject:/': 0.30; 'code': 0.30; 'guess': 0.31; 'software,': 0.32; 'maybe': 0.33; 'belong': 0.33; 'limitations': 0.33; 'thanks!': 0.34; 'tue,': 0.34; 'file': 0.34; 'running': 0.34; 'received:google.com': 0.35; 'exist': 0.35; 'sometimes': 0.35; 'but': 0.36; 'there': 0.36; 'lines': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'operating': 0.37; 'hundreds': 0.37; 'pdf': 0.37; 'creation': 0.38; 'christian': 0.38; 'anything': 0.38; 'copying': 0.38; 'test': 0.39; 'sure': 0.39; 'format': 0.39; 'does': 0.39; 'where': 0.40; 'space': 0.40; 'some': 0.40; 'details,': 0.60; 'your': 0.60; 'leading': 0.61; 'documents': 0.61; 'eyes': 0.70; 'jul': 0.72; 'surprise': 0.72; 'special': 0.73; 'sounds': 0.76; 'actually,': 0.84; 'chrisa': 0.84; 'flaw': 0.84; 'gollwitzer': 0.84; 'mum': 0.84; 'to:none': 0.91; 'acrobat': 0.91
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:cc :content-type; bh=m00d20b6KiWPoBtWOUxvWmOs59J0q3W8dymIVozyhes=; b=EPu567ewS5DPEplLKsZvAaS/vLYupMOMAvUyBeJAc3VOgKHpG/17PRAS+H7vE/fHnF Mu1CLJmq6lNBE0XggU9wi10cd2YK3TMEj4MSCb+Pkr64DsLqIWwHqEaSrzYSLTEYrcRK /XWvramQm6OnGn9bWeP9kQkx0k7CsgSU/BbtglIj6GZMZ6Uijx9IUuDbdpK7J1NlFNPu I20xOf4omIvWZB0nRWA08xPobP9zEY+HU5e1jUT60CUtuDDvAMlmTLv0GtJhG5H8eWuC GsLgY0BO6hPU0Ry5Cv7KF+OE2i6va1DDH6wO49yr9vsqMu4n7l9bRtHRzM4dPoX5YJhX 2dvQ==
MIME-Version 1.0
X-Received by 10.50.136.194 with SMTP id qc2mr25195701igb.6.1437490086893; Tue, 21 Jul 2015 07:48:06 -0700 (PDT)
In-Reply-To <moldt9$tmm$1@dont-email.me>
References <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <mailman.796.1437447312.3674.python-list@python.org> <moldt9$tmm$1@dont-email.me>
Date Wed, 22 Jul 2015 00:48:06 +1000
Subject Re: Can I copy/paste Python code?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.816.1437490089.3674.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1437490089 news.xs4all.nl 2842 [2001:888:2000:d::a6]:44311
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:94291

Show key headers only | View raw


On Tue, Jul 21, 2015 at 10:29 PM, Christian Gollwitzer <auriocus@gmx.de> wrote:
> On 21.07.2015 04:55, Chris Angelico wrote:
>>
>> On Tue, Jul 21, 2015 at 12:49 PM, ryguy7272 <ryanshuell@gmail.com> wrote:
>>>
>>> I'm trying to copy some Python code from a PDF book that I'm reading.  I
>>> want to test out the code, and I can copy it, but when I paste it into the
>>> Shell, everything is all screwed up because of the indentation. Every time I
>>> paste in any kind of code, it seems like everything is immediately
>>> left-justified, and then nothing works.
>>>
>>> Any idea how to make this work easily?  Without re-typing hundreds of
>>> lines of code...
>>
>>
>> Sounds like a flaw in the PDF - it creates indentation in some way
>> other than leading spaces/tabs.
>
>
> PDF never uses tabs and spaces for indentation. In a PDF file, typically all
> words are placed using a drawing operator individually, the space is made up
> by your eyes when see the file. While space characters exist in fonts, they
> are practically never used. Often even inside a word there are breaks,
> because of kerning corrections. When copying the data, the PDF reader has to
> guess where the word breaks are and how the strings belong together. Acrobat
> does a good job, but fails in this special situation. Sometimes it even
> fails for a narrow running font and copies the string without any word
> breaks.

Ah. I've never dug into PDF's internal details, but the above
explanation completely doesn't surprise me.

Tip, to document publishers: Don't use PDF for anything containing
Python code. Thanks!

Actually, maybe don't use PDF at all. I keep having to help my Mum
deal with stupid problems with PDF documents she gets, and I'm never
sure whether the fault is with the PDF creation software, the human
operating said software, or limitations in the file format itself.

ChrisA

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


Thread

Can I copy/paste Python code? ryguy7272 <ryanshuell@gmail.com> - 2015-07-20 19:49 -0700
  Re: Can I copy/paste Python code? Chris Angelico <rosuav@gmail.com> - 2015-07-21 12:55 +1000
    Re: Can I copy/paste Python code? Christian Gollwitzer <auriocus@gmx.de> - 2015-07-21 14:29 +0200
      Re: Can I copy/paste Python code? Chris Angelico <rosuav@gmail.com> - 2015-07-22 00:48 +1000
      Re: Can I copy/paste Python code? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-21 17:12 +0100
        Re: Can I copy/paste Python code? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-07-21 20:05 -0400
      Re: Can I copy/paste Python code? Laura Creighton <lac@openend.se> - 2015-07-21 19:25 +0200
        Re: Can I copy/paste Python code? Grant Edwards <invalid@invalid.invalid> - 2015-07-21 18:55 +0000
        Re: Can I copy/paste Python code? Steven D'Aprano <steve@pearwood.info> - 2015-07-22 10:45 +1000
          Re: Can I copy/paste Python code? Laura Creighton <lac@openend.se> - 2015-07-22 09:01 +0200
            Re: Can I copy/paste Python code? Grant Edwards <invalid@invalid.invalid> - 2015-07-22 13:54 +0000
              Re: Can I copy/paste Python code? Laura Creighton <lac@openend.se> - 2015-07-22 16:37 +0200
                Re: Can I copy/paste Python code? Grant Edwards <invalid@invalid.invalid> - 2015-07-22 14:53 +0000
                Re: Can I copy/paste Python code? Laura Creighton <lac@openend.se> - 2015-07-22 18:53 +0200
                Re: Can I copy/paste Python code? Christian Gollwitzer <auriocus@gmx.de> - 2015-07-22 23:23 +0200
      Re: Can I copy/paste Python code? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-21 20:58 +0100
        Re: Can I copy/paste Python code? Grant Edwards <invalid@invalid.invalid> - 2015-07-21 20:32 +0000
          Re: Can I copy/paste Python code? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-21 21:54 +0100
          Re: Can I copy/paste Python code? Emile van Sebille <emile@fenx.com> - 2015-07-21 14:03 -0700
            Re: Can I copy/paste Python code? Grant Edwards <invalid@invalid.invalid> - 2015-07-21 21:47 +0000
              Re: Can I copy/paste Python code? Emile van Sebille <emile@fenx.com> - 2015-07-21 15:35 -0700
                Re: Can I copy/paste Python code? Grant Edwards <invalid@invalid.invalid> - 2015-07-22 00:10 +0000
                Re: Can I copy/paste Python code? Emile van Sebille <emile@fenx.com> - 2015-07-22 09:49 -0700
                Re: Can I copy/paste Python code? Grant Edwards <invalid@invalid.invalid> - 2015-07-22 19:35 +0000
                Re: Can I copy/paste Python code? Emile van Sebille <emile@fenx.com> - 2015-07-22 14:39 -0700
                Re: [OT] Can I copy/paste Python code? Michael Torrie <torriem@gmail.com> - 2015-07-22 15:56 -0600
                Re: [OT] Can I copy/paste Python code? Grant Edwards <invalid@invalid.invalid> - 2015-07-22 22:50 +0000
                Re: [OT] Can I copy/paste Python code? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-07-23 15:39 +1000
                Re: Can I copy/paste Python code? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-07-23 15:22 +1000
                Re: Can I copy/paste Python code? Grant Edwards <invalid@invalid.invalid> - 2015-07-22 20:49 +0000
              Re: Can I copy/paste Python code? Michael Torrie <torriem@gmail.com> - 2015-07-21 16:36 -0600
                Re: Can I copy/paste Python code? Grant Edwards <invalid@invalid.invalid> - 2015-07-22 00:12 +0000
                Re: Can I copy/paste Python code? Michael Torrie <torriem@gmail.com> - 2015-07-21 19:03 -0600
                Re: Can I copy/paste Python code? Chris Angelico <rosuav@gmail.com> - 2015-07-22 11:12 +1000
              Re: Can I copy/paste Python code? Chris Angelico <rosuav@gmail.com> - 2015-07-22 10:04 +1000
                Re: Can I copy/paste Python code? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2015-07-22 10:55 +0300
                Re: Can I copy/paste Python code? Chris Angelico <rosuav@gmail.com> - 2015-07-22 18:13 +1000
      Re: Can I copy/paste Python code? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-22 08:47 +0100
  Re: Can I copy/paste Python code? Laura Creighton <lac@openend.se> - 2015-07-21 10:24 +0200
  Re: Can I copy/paste Python code? "Peter Heitzer" <peter.heitzer@rz.uni-regensburg.de> - 2015-07-21 08:40 +0000
  Re: Can I copy/paste Python code? ryguy7272 <ryanshuell@gmail.com> - 2015-07-21 08:18 -0700
  Re: Can I copy/paste Python code? Gene Heskett <gheskett@wdtv.com> - 2015-07-21 13:41 -0400

csiph-web