Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #20468
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rsengupta@wisc.edu> |
| 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; 'attribute': 0.07; 'advance.': 0.09; 'header:In-reply-to:1': 0.09; 'loop.': 0.09; 'error:': 0.10; 'subject:file': 0.13; '"a")': 0.16; 'innermost': 0.16; 'subject:loops': 0.16; 'subject:writing': 0.16; '\xa0while': 0.16; 'help.': 0.19; "doesn't": 0.22; 'fine,': 0.23; 'code': 0.26; "i'm": 0.28; 'received:144': 0.30; 'thanks': 0.32; 'error.': 0.32; 'loop': 0.34; 'wondering': 0.34; 'hi,': 0.34; 'someone': 0.34; 'to:addr:python-list': 0.35; 'but': 0.37; 'could': 0.38; 'some': 0.38; 'getting': 0.38; 'skip:\xa0 10': 0.39; 'subject:from': 0.39; 'might': 0.40; 'to:addr:python.org': 0.40 |
| MIME-version | 1.0 |
| Content-disposition | inline |
| Content-type | text/plain; charset=iso-8859-1 |
| Date | Wed, 15 Feb 2012 14:12:41 -0600 |
| From | Rituparna Sengupta <rsengupta@wisc.edu> |
| Subject | writing to a file from within nested loops |
| In-reply-to | <7750b096170a1e.4f3c11b5@wiscmail.wisc.edu> |
| To | python <python-list@python.org> |
| X-Mailer | Oracle Communications Messenger Express 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011) |
| Content-language | en |
| Content-transfer-encoding | quoted-printable |
| X-Accept-Language | en |
| Priority | normal |
| X-Spam-Report | AuthenticatedSender=yes, SenderIP=144.92.8.24 |
| X-Spam-PmxInfo | Server=avs-14, Version=5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.2.15.200046, SenderIP=144.92.8.24 |
| References | <75208cce174437.4f3bf1a2@wiscmail.wisc.edu> <77a0ddfa17203f.4f3bf1de@wiscmail.wisc.edu> <775093eb1740b6.4f3bf21b@wiscmail.wisc.edu> <7760fe7a17153d.4f3bf258@wiscmail.wisc.edu> <75909037172f2d.4f3bf294@wiscmail.wisc.edu> <76f0965b175c1f.4f3bf2d0@wiscmail.wisc.edu> <77c0ac1d173db4.4f3bf403@wiscmail.wisc.edu> <7750b096170a1e.4f3c11b5@wiscmail.wisc.edu> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| 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.5849.1329336768.27778.python-list@python.org> (permalink) |
| Lines | 35 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1329336768 news.xs4all.nl 6870 [2001:888:2000:d::a6]:51252 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:20468 |
Show key headers only | View raw
Hi,
I'm working on this code and I keep getting an error. It might be some very basic thing but I was wondering if someone could help. Its a loop within a loop. The part outside the innermost loop gets printed fine, but the part within the innermost loop doesn't get printed. I get an error: 'str' has no attribute 'write'. Thanks in advance.
Ritu
.
.
.
i=0
while i<m
r=name[i]
f=open('file'+'%s' %(r), "a")
f.write("whatever"+r) #part outside innermost loop gets printed
j=0
while j<n
f.write("output of loop") #part within innermost loop doesn't get printed
j=j+1
f.close()
i=i+1
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
writing to a file from within nested loops Rituparna Sengupta <rsengupta@wisc.edu> - 2012-02-15 14:12 -0600
csiph-web