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


Groups > comp.lang.python > #28573

Re: Need help fixing this error please:NameError: global name is not defined

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; '21,': 0.07; 'subject:help': 0.07; 'python': 0.09; 'argument,': 0.09; 'cursor': 0.09; 'name)': 0.09; 'nameerror:': 0.09; 'sep': 0.09; 'def': 0.10; 'subject:error': 0.11; 'subject:not': 0.11; 'class)': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'function;': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'thu,': 0.17; 'skip:" 30': 0.20; 'received:209.85.214.174': 0.21; 'skip:c 70': 0.22; 'defined': 0.22; 'idea': 0.24; "we'd": 0.24; 'pass': 0.25; 'header:In-Reply-To:1': 0.25; 'looks': 0.26; 'appreciated': 0.27; 'subject:please': 0.27; 'message-id:@mail.gmail.com': 0.27; '(since': 0.29; 'skip:/ 40': 0.29; "i'm": 0.29; "skip:' 10": 0.30; 'function': 0.30; 'error': 0.30; 'code': 0.31; 'file': 0.32; 'function.': 0.33; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'skip:d 20': 0.34; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'your': 0.60; 'further': 0.61; 'subject:Need': 0.61; 'different': 0.63; 'more': 0.63; 'other.': 0.64; 'results': 0.65; 'member,': 0.66; 'subject::': 0.83; 'subject:this': 0.84; 'skip:/ 30': 0.91
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=3ybLEz8VPvpj4lYHW0j7CZb24yLy+dkdLsnMcpxRVz8=; b=ZNm2l6eQeVpx5pnz9Le87IL4/jMKQegWJxgYlLNmq05Mw4YxMeo0zSdm0hApU8YbUb vdHKoluNLpla3h9uWWqfvcHDVFSnF1HfJt3mcA8XKkJAE27WkoM17zbHVMHX1tSH1KE7 fu++H9UCThMrLvSX9GoBMjfxBWED7LY1p61pzPf/Z7qaaFPugtpT+l+ULDyz6VGvGLas 7Z/bdJVPDv8gb4bNrrI1GrQsfNgTfWGczqZ/ZtitWIIERE5yD2EJrmb22588a0H7q/Tr Ie0NoNBec8jpdA2Mc25KjXRiXtcOJUL3Fp1I8qjEI7aEC9fxzDjOXPhymC/WkUw/ciaw ZQpA==
MIME-Version 1.0
In-Reply-To <149e9472-ec31-4b74-9f20-d4945a9fb678@googlegroups.com>
References <149e9472-ec31-4b74-9f20-d4945a9fb678@googlegroups.com>
Date Thu, 6 Sep 2012 21:05:29 +1000
Subject Re: Need help fixing this error please:NameError: global name is not defined
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.290.1346929532.27098.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1346929532 news.xs4all.nl 6914 [2001:888:2000:d::a6]:37198
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:28573

Show key headers only | View raw


On Thu, Sep 6, 2012 at 8:45 PM, shaun <shaun.wiseman91@gmail.com> wrote:
> ////CODE///////////////////////////////
>
> def databasebatchcall(self,tid, bid):
>         con=cx_Oracle.connect('user/user123@odb4.dcc.company/ODB4TEST.COMPANY.COM')
>         cur = con.cursor()
>         cur.execute("SELECT * FROM name)
>         results = cur.fetchall()
> //////////////////////////////////////////
>
> From this last line I get the following error which I don't understand I'm very new to python and have no idea about this any help would be appreciated
>
>
> //////////////////////////////////////////////
>
> File "/home/dcroke/mdcFDACStringCall.py", line 21, in fetchbatchdata
>     results = cur.fetchall()
> NameError: global name 'cur' is not defined
>
> //////////////////////////////////////////////
>

Not quite, actually. The traceback names a different function. Look in
your code for a 'fetchbatchdata' function; it looks like you need to
pass the cursor from one function to the other.

To further assist, we'd need to see more of the code; but for a guess,
I would say that you either need to make cur a function argument, or
else (since this is class) an instance member, which you'd reference
as 'self.cur'.

ChrisA

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


Thread

Need help fixing this error please:NameError: global name is not defined shaun <shaun.wiseman91@gmail.com> - 2012-09-06 03:45 -0700
  Re: Need help fixing this error please:NameError: global name is not defined Chris Angelico <rosuav@gmail.com> - 2012-09-06 21:05 +1000
  Re: Need help fixing this error please:NameError: global name is not defined Dave Angel <d@davea.name> - 2012-09-06 07:05 -0400
  Re: Need help fixing this error please:NameError: global name is not defined Peter Otten <__peter__@web.de> - 2012-09-06 13:07 +0200
  Re: Need help fixing this error please:NameError: global name is not defined Chris Angelico <rosuav@gmail.com> - 2012-09-06 21:53 +1000
  Re: Need help fixing this error please:NameError: global name is not defined shaun <shaun.wiseman91@gmail.com> - 2012-09-06 05:07 -0700
    Re: Need help fixing this error please:NameError: global name is not defined Chris Angelico <rosuav@gmail.com> - 2012-09-06 23:16 +1000
  Re: Need help fixing this error please:NameError: global name is not defined MRAB <python@mrabarnett.plus.com> - 2012-09-06 13:08 +0100
  Re: Need help fixing this error please:NameError: global name is not defined Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-09-06 17:16 -0400

csiph-web