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


Groups > comp.lang.python > #35716

Re: Wrapping statements in Python in SPSS

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <msirenef@lightbird.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'indicating': 0.05; 'column': 0.07; 'main()': 0.07; 'python': 0.09; 'alan': 0.09; 'python:': 0.09; 'src,': 0.09; 'def': 0.10; 'cetera.': 0.16; 'cleanly': 0.16; 'columns': 0.16; 'main():': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'sources,': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'variable': 0.20; 'issue.': 0.20; 'names.': 0.22; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'setting': 0.26; 'values': 0.26; 'lines': 0.28; 'run': 0.28; 'loop,': 0.29; 'code': 0.31; 'to:addr:python-list': 0.33; 'skip:d 20': 0.34; 'list': 0.35; 'doing': 0.35; 'pm,': 0.35; 'really': 0.36; 'but': 0.36; 'should': 0.36; 'subject:: ': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'little': 0.39; 'received:192.168': 0.40; 'end': 0.40; 'think': 0.40; 'email addr:gmail.com': 0.63; 'more': 0.63; 'here': 0.65; 'manage,': 0.84; 'measure,': 0.84; 'understand,': 0.84; 'good,': 0.91
Date Fri, 28 Dec 2012 13:20:15 -0500
From Mitya Sirenef <msirenef@lightbird.net>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: Wrapping statements in Python in SPSS
References <7fcd8949-c781-425c-b6d2-7d0a634b12b7@googlegroups.com> <mailman.1397.1356711013.29569.python-list@python.org> <596420c8-b88c-4b4d-89d9-a0c22ac7180b@googlegroups.com> <mailman.1400.1356714756.29569.python-list@python.org> <11d39988-ba47-4bc7-b2d4-6f33a52d398d@googlegroups.com> <50DDDCF7.1080503@lightbird.net> <50DDDF84.8090606@lightbird.net>
In-Reply-To <50DDDF84.8090606@lightbird.net>
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.1408.1356718820.29569.python-list@python.org> (permalink)
Lines 79
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1356718820 news.xs4all.nl 6990 [2001:888:2000:d::a6]:57777
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:35716

Show key headers only | View raw


On 12/28/2012 01:05 PM, Mitya Sirenef wrote:
> On 12/28/2012 12:55 PM, Mitya  Sirenef wrote:
 >> On 12/28/2012 12:33 PM, alankrinsky@gmail.com wrote:
 >>> I think 396 just comes from the end of the Python loop, without 
indicating which line in the loop is
 >> at issue.
 >> >
 >> > Here is the full code from this section of the loop:
 >> >
 >> >
 >> > for (
 >> > msr, brk, dmn, src, dspd1, dspd2, dspd3, dspd4, dspd5, dspd6, 
dspd7, dspd8, dspd9, dspd10, dspd11, dspd12,
 >> > period1, period2, period3, period4, period5, period6, period7, 
period8, period9, period10, period11, period12
 >> > ) in zip(
 >> > Measure, BreakVariable, Dimension, Sources, 
DimensionSourceTimeFrame1, DimensionSourceTimeFrame2, 
DimensionSourceTimeFrame3, DimensionSourceTimeFrame4,
 >> > DimensionSourceTimeFrame5, DimensionSourceTimeFrame6, 
DimensionSourceTimeFrame7, DimensionSourceTimeFrame8, 
DimensionSourceTimeFrame9,
 >> > DimensionSourceTimeFrame10, DimensionSourceTimeFrame11, 
DimensionSourceTimeFrame12,
 >> > TimeFrame1, TimeFrame2, TimeFrame3, TimeFrame4, TimeFrame5, 
TimeFrame6, TimeFrame7, TimeFrame8, TimeFrame9, TimeFrame10, 
TimeFrame11, TimeFrame12
 >> > ):
 >> >
 >> >
 >> > spss.Submit(r"""
 >> >
 >> >
 >> > Alan
 >> >
 >> >
 >>
 >> By the way, when lines run so long they can get hard to manage, edit,
 >> understand, et cetera. You should consider setting things up cleanly
 >> before doing the loop and using a list of names for columns like so:
 >>
 >>
 >> def main():
 >> l1, l2 = [1,2], [3,4]
 >> zipped = zip(l1, l2)
 >> colnames = "first second".split()
 >>
 >> for columns in zipped:
 >> coldict = dict(zip(colnames, columns))
 >> print("coldict", coldict)
 >>
 >
 >
 > Should really be 'for column in zipped:' !
 >
 > -m
 >

Doh - the code is good, but I got a little confused with variable names.
This should be more like it:

def main():
     c1, c2   = [1,2], [3,4]
     zipped   = zip(c1, c2)
     colnames = "first second".split()

     for values in zipped:
         valdict = dict(zip(colnames, values))
         print("valdict", valdict)

main()


  -m


-- 
Lark's Tongue Guide to Python: http://lightbird.net/larks/

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


Thread

Wrapping statements in Python in SPSS alankrinsky@gmail.com - 2012-12-28 08:01 -0800
  Re: Wrapping statements in Python in SPSS Chris Angelico <rosuav@gmail.com> - 2012-12-29 03:10 +1100
    Re: Wrapping statements in Python in SPSS alankrinsky@gmail.com - 2012-12-28 08:43 -0800
      Re: Wrapping statements in Python in SPSS Peter Otten <__peter__@web.de> - 2012-12-28 18:07 +0100
      Re: Wrapping statements in Python in SPSS Chris Angelico <rosuav@gmail.com> - 2012-12-29 04:12 +1100
        Re: Wrapping statements in Python in SPSS alankrinsky@gmail.com - 2012-12-28 09:33 -0800
          Re: Wrapping statements in Python in SPSS Mitya Sirenef <msirenef@lightbird.net> - 2012-12-28 12:55 -0500
          Re: Wrapping statements in Python in SPSS Mitya Sirenef <msirenef@lightbird.net> - 2012-12-28 13:05 -0500
          Re: Wrapping statements in Python in SPSS Mitya Sirenef <msirenef@lightbird.net> - 2012-12-28 13:20 -0500
        Re: Wrapping statements in Python in SPSS alankrinsky@gmail.com - 2012-12-28 09:33 -0800
    Re: Wrapping statements in Python in SPSS alankrinsky@gmail.com - 2012-12-28 08:43 -0800

csiph-web