Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33343
| References | <CAFqGZRGYDM_3H657gid9GUxrSbnM_92nCZEsWWcWhFua5xEpmw@mail.gmail.com> |
|---|---|
| Date | 2012-11-14 11:02 -0500 |
| Subject | Re: Error |
| From | Joel Goldstick <joel.goldstick@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3689.1352908956.27098.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
On Wed, Nov 14, 2012 at 10:18 AM, inshu chauhan <insideshoes@gmail.com>wrote: > > for this code m getting this error : > > CODE : > def ComputeClasses(data): > radius = .5 > points = [] > for cy in xrange(0, data.height): > for cx in xrange(0, data.width): > if data[cy,cx] != (0.0,0.0,0.0): > This code is only run if the test above is true > centre = data[cy, cx] > points.append(centre) > > > change = True > > while change: > > for ring_number in xrange(1, 1000): > change = False > new_indices = GenerateRing(cx, cy, ring_number) > > > for idx in new_indices: > point = data[idx[0], idx[1]] > > if point == (0.0, 0.0, 0.0 ): > continue > else: > dist = distance(centre, point) > centre is only set if the test above is true. In your run, it apparently wasn't > if dist < radius : > print point > points.append(point) > change = True > print change > > > break > > > ERROR : > Traceback (most recent call last): > File "Z:\modules\classification2.py", line 74, in <module> > ComputeClasses(data) > File "Z:\modules\classification2.py", line 56, in ComputeClasses > dist = distance(centre, point) > UnboundLocalError: local variable 'centre' referenced before assignment > > And i am unable to understand .. WHY ? > > > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- Joel Goldstick
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Error Joel Goldstick <joel.goldstick@gmail.com> - 2012-11-14 11:02 -0500
csiph-web