Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51649
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <beth.mcnany@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.009 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'insert': 0.05; 'subject:Python': 0.06; '"""': 0.07; 'subject:code': 0.07; 'converts': 0.09; 'parsing': 0.09; 'spaces': 0.09; 'statements': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '__future__': 0.16; 'braces': 0.16; 'braces?': 0.16; 'bracket': 0.16; 'curly': 0.16; 'notation': 0.16; 'subject: \n ': 0.16; 'subject:between': 0.16; '(you': 0.16; 'wrote:': 0.18; 'starts': 0.20; 'import': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'script': 0.25; '(for': 0.26; 'read,': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'easy,': 0.31; 'indentation': 0.31; 'subject:that': 0.31; 'probably': 0.32; 'open': 0.33; 'url:python': 0.33; 'could': 0.34; 'problem': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'url:listinfo': 0.36; 'doing': 0.36; 'url:org': 0.36; 'application': 0.37; 'skip:o 20': 0.38; 'skip:& 10': 0.38; 'ends': 0.38; 'pm,': 0.38; 'track': 0.38; 'short': 0.38; 'url:mail': 0.40; 'how': 0.40; 'remove': 0.60; 'lost': 0.61; 'simple': 0.61; "you're": 0.61; "you'll": 0.62; '30,': 0.65; 'to:addr:gmail.com': 0.65; 'readers': 0.68; 'jul': 0.74; '*really*': 0.84; '11:45': 0.84; 'musical': 0.84; 'received:mail-ob0-x22f.google.com': 0.84; 'increases': 0.91; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=qiseSAts7A8lhf9TVYtX7ajfn9uzkYQu3JuJQtZAuCo=; b=IUYisDdm1JD+5Q8OlT6DsG2ZSGgn1C+0AAPs4XKkSbqzq124JQhcXJx2oOYITIl1v+ AQ9AU2XxPRHd4T2e9HvK4G2hZnSvzQ+cSweSju/X5k44ffb/X6UYK0ERjKpUr8fQnO6U BYCR3sySaRdFOMyeQj23xCY1j45wmPa1nzBd7RTclY1+N/6fmRi7AHq1n9/1fFv136Cw RUstzGf5zQ2vA79HKduvN1PzlWd+ZOUffGMGf/hXrPfWQMSir0AU90QT+BAlttwBewtQ LYycAk20VwvT1JWwRNve5iV1OOZEpJK5BpHWVEtt4GAW9QWs0/BTT9a1ioZ3jKkqptcg SfXw== |
| X-Received | by 10.43.57.9 with SMTP id we9mr22650824icb.90.1375274405989; Wed, 31 Jul 2013 05:40:05 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <09DBD544-FA04-48DC-8FEA-1E788FE1C6A6@gmail.com> |
| References | <09DBD544-FA04-48DC-8FEA-1E788FE1C6A6@gmail.com> |
| From | Beth McNany <beth.mcnany@gmail.com> |
| Date | Wed, 31 Jul 2013 08:39:45 -0400 |
| Subject | Re: Script that converts between indentation and curly braces in Python code |
| To | Musical Notation <musicdenotation@gmail.com> |
| Content-Type | multipart/alternative; boundary=bcaec51b1b9f7014b104e2ce0627 |
| X-Mailman-Approved-At | Wed, 31 Jul 2013 14:50:59 +0200 |
| Cc | Python Mailing List <python-list@python.org> |
| 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.19.1375275061.1251.python-list@python.org> (permalink) |
| Lines | 71 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1375275061 news.xs4all.nl 15918 [2001:888:2000:d::a6]:44470 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:51649 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
from __future__ import braces ;) ok, ok, if you *really* want it, you could keep track of how many leading spaces there are (you are using spaces, right?), and insert an open bracket where that number increases and a closing bracket where it decreases. Of course, as with all parsing problems, this is oversimplification... if you have multi-line statements you'll need to check for those (if line starts with """ or ''', ends with \, or if there's an unclosed bracket or paren...) - but that'd be a reasonable place to start if you're only doing short code snippets. Also, I have to ask, how to you intend this to be used? If there's no indentation it will still be difficult to read, and your readers will then have the problem of figuring out which curly braces to remove (for simple code this might be easy, but for longer things you'd probably want an automated way to re-indent, and a simple search-and-replace will screw up any dictionaries, for instance). -beth On Tue, Jul 30, 2013 at 11:45 PM, Musical Notation < musicdenotation@gmail.com> wrote: > Is there any script that converts indentation in Python code to curly > braces? The indentation is sometime lost when I copy my code to an > application or a website. > -- > http://mail.python.org/mailman/listinfo/python-list >
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Script that converts between indentation and curly braces in Python code Beth McNany <beth.mcnany@gmail.com> - 2013-07-31 08:39 -0400
csiph-web