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


Groups > comp.lang.python > #45790

Re: Scope of a class..help???

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.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.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'assign': 0.07; 'problem:': 0.07; 'assigning': 0.09; 'python': 0.11; 'def': 0.12; '23,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iteration': 0.16; 'node.': 0.16; 'subject:???': 0.16; 'traceback.': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'thu,': 0.19; 'written': 0.21; 'saying': 0.22; 'print': 0.22; 'post': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'node': 0.31; 'class': 0.32; 'actual': 0.34; 'received:google.com': 0.35; 'really': 0.36; 'method': 0.36; 'error.': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'unable': 0.39; 'how': 0.40; 'skip:u 10': 0.60; 'skip:n 30': 0.60; "you're": 0.61; 'name': 0.63; 'end.': 0.84; 'local,': 0.84; 'subject:..': 0.84; '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:date:message-id:subject:from:to :content-type; bh=zbhnDSdv3UKdJNnMg72iuziUwBGa7um6n8xiaU9oYnk=; b=ZSBN3s1rdj+4R+lv1xNeLEifk7Ek8DJQWSde263TfK1ir9VdAp5pgEifYF13UrL6aV wOTi5UYasoDuoIV6J6VVcy8PyrDolbtW+m/FAqZfX2NBI5XwUz/xK2PaiHtrcLJgKawk KrYe0Gc4cWG/ed/v2frL6pkozF+5Rq+7WwDYEbD8spTYclT3YM0113ER9N8jgvMd/YPm FvRqTIPWQ0cnNgdvzPh8CcN4K8z4HXSEyJtjA/bjXWUjmecYwz3x70rh4yBRiS9SMqjg N1GCRIJ0N4hIbsuLeW8GOiAeFyiZ5zr7y3E83clRfKercElJ8qmKQaUUyvCN7RssdrwK XDZw==
MIME-Version 1.0
X-Received by 10.52.175.200 with SMTP id cc8mr3992792vdc.94.1369303227147; Thu, 23 May 2013 03:00:27 -0700 (PDT)
In-Reply-To <913d7fc1-4608-4ff5-8b51-2ae2cd67781a@googlegroups.com>
References <913d7fc1-4608-4ff5-8b51-2ae2cd67781a@googlegroups.com>
Date Thu, 23 May 2013 20:00:27 +1000
Subject Re: Scope of a class..help???
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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.2005.1369303610.3114.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1369303610 news.xs4all.nl 15999 [2001:888:2000:d::a6]:35784
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45790

Show key headers only | View raw


On Thu, May 23, 2013 at 7:51 PM,  <lokeshkoppaka@gmail.com> wrote:
> i had written the following code i am unable to create the instance of the class "Node" in the method "number_to_LinkedList" can any one help me how to do ??
> and what is the error??

It would really help if you post the actual exception and traceback.
It's UnboundLocal, not Unbounded... and here's the problem:

> def number_to_LinkedList(numbers):
>       head_node = Node() #unable to create the instance saying UnboundedLocal
>       while Node:
>         print Node.data
>         Node = Node.next

You're assigning to Node. I think you mean to have some other local
variable here, for the iteration at the end. Since you assign to the
name Node inside the function (and don't have a global declaration),
the name Node is local to the function. Python doesn't let you
reference the global "prior to" shadowing it with the local, so you
get this error.

ChrisA

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


Thread

Scope of a class..help??? lokeshkoppaka@gmail.com - 2013-05-23 02:51 -0700
  Re: Scope of a class..help??? Chris Angelico <rosuav@gmail.com> - 2013-05-23 20:00 +1000
  Re: Scope of a class..help??? Peter Otten <__peter__@web.de> - 2013-05-23 12:18 +0200
  Re: Scope of a class..help??? lokeshkoppaka@gmail.com - 2013-05-23 03:23 -0700
    Re: Scope of a class..help??? Chris Angelico <rosuav@gmail.com> - 2013-05-23 20:27 +1000
  Re: Scope of a class..help??? lokeshkoppaka@gmail.com - 2013-05-23 03:25 -0700
    Re: Scope of a class..help??? Chris Angelico <rosuav@gmail.com> - 2013-05-23 21:40 +1000
    Re: Scope of a class..help??? Tim Roberts <timr@probo.com> - 2013-05-23 22:05 -0700

csiph-web