LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-08-2014, 01:39 AM   #1
sryzdn
Member
 
Registered: Feb 2013
Posts: 257

Rep: Reputation: 9
NameErrors in python


Hi, I found this example in the book "introduction to python programming" (NCLAB). Since I am a newbie, some examples seems to have errors for me.

How to fix the following error related to webGL in Python

Code:
from numpy import sin, sqrt, arctan

x0 = 0.0
x1 = 10.0
x2 = 0.0
y1 = 10.0

nx = 100
ny = 100

def f(x, y):
    return sin(sqrt(x**2 + y**2))
lab.surface ((x0, x1, nx), (y0, y1, ny), f)
Quote:
NameError: name 'lab' is not defined

Last edited by sryzdn; 04-08-2014 at 04:30 AM.
 
Old 04-08-2014, 02:11 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,437

Rep: Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842
Well the error seems to make perfect sense. This is the entire script?
 
Old 04-08-2014, 03:39 AM   #3
sryzdn
Member
 
Registered: Feb 2013
Posts: 257

Original Poster
Rep: Reputation: 9
Quote:
Originally Posted by grail View Post
Well the error seems to make perfect sense. This is the entire script?
yes
 
Old 04-08-2014, 04:04 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,645

Rep: Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501
you need to import something at the beginning of the script.
 
Old 04-08-2014, 05:21 AM   #5
sryzdn
Member
 
Registered: Feb 2013
Posts: 257

Original Poster
Rep: Reputation: 9
Quote:
Originally Posted by pan64 View Post
you need to import something at the beginning of the script.
yes, but what object really contains lab?!

Last edited by sryzdn; 04-08-2014 at 05:26 AM.
 
Old 04-08-2014, 06:31 AM   #6
sryzdn
Member
 
Registered: Feb 2013
Posts: 257

Original Poster
Rep: Reputation: 9
"lab" is in nclab and not other editors.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Python wins trademark dispute, rival stops calling itself “Python” LXer Syndicated Linux News 0 03-21-2013 07:40 PM
Python 2.6 dependencies error installing python-sqlite2-2.5.5-1.1.i586.rpm jmp007 Linux - Newbie 1 02-11-2011 11:05 AM
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 08:30 PM
LXer: Review: Programming in Python 3: A Complete Introduction to the Python Language LXer Syndicated Linux News 0 01-26-2009 04:50 AM
LXer: Move to python 2.4 / Changing the packaging style for python packages LXer Syndicated Linux News 0 06-13-2006 07:54 PM


All times are GMT -5. The time now is 02:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration