Hi,
I am a Python beginner and using PyCrust to process data for my research work.
I found I not able to import a .py file directly. But I have to type in every lines every time. Or I can save the script in function. Then call out the function in PyCrust. But it's not convenient. And it causes global variable problem.
The case is even I import the numpy lib in the function file.py, but it shows error: “NameError: global name 'append' is not defined” when I call out the function in Pycrust. Could anyone tell me why it shows "append" is not defined even I "import numpy" already?
And how to open the script directly in PyCrust?
Besides, how can I import and export the array with PyCrust ? (As I want to export the array from PyCrust and then run it in the script with SciTE)
Thanks for help.
P.S. The versions I use are:
enthon-python2.4-1.0.0
numpy-1.0.3.1.win32-py2.4
Kanis
6 3573
Hi,
I am a Python beginner and using PyCrust to process data for my research work.
I found I not able to import a .py file directly. But I have to type in every lines every time. Or I can save the script in function. Then call out the function in PyCrust. But it's not convenient. And it causes global variable problem.
The case is even I import the numpy lib in the function file.py, but it shows error: “NameError: global name 'append' is not defined” when I call out the function in Pycrust. Could anyone tell me why it shows "append" is not defined even I "import numpy" already?
And how to open the script directly in PyCrust?
Besides, how can I import and export the array with PyCrust ? (As I want to export the array from PyCrust and then run it in the script with SciTE)
Thanks for help.
P.S. The versions I use are:
enthon-python2.4-1.0.0
numpy-1.0.3.1.win32-py2.4
Kanis
Please try using IDLE instead of PyCrust. IDLE will let you save your scripts and run them from the Run menu.
Please try using IDLE instead of PyCrust. IDLE will let you save your scripts and run them from the Run menu.
Because the interface I using is embedded with PyCrust only. And the data is read in that interface. So if I use IDLE to process the data, I think I have to know how to export the array data first. Do u know how to import and export the array in Python?
Because the interface I using is embedded with PyCrust only. And the data is read in that interface. So if I use IDLE to process the data, I think I have to know how to export the array data first. Do u know how to import and export the array in Python?
In that case, PyAlaMode will let you save your files. -
>>> import numpy
-
>>> a1darray = numpy.zeros(10)
-
>>> a1darray
-
array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
-
>>>
In that case, PyAlaMode will let you save your files. -
>>> import numpy
-
>>> a1darray = numpy.zeros(10)
-
>>> a1darray
-
array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
-
>>>
The interface I use can create a data array called "dataobj" already, then if I want to process the data, I open the embedded "PyCrust" console and the "dataobj" is already defined there. But if I run the Python directly (I mean not use the PyCrust inside the interface), the "dataobj" array is undefined. So, I would like to export the "dataobj" array, let say export it to a file, and then I can read it again when I use the IDLE or other Python Shell or Matlab. How can I export the array into a file?
In the console (PyCrust), the script works:
>>> def x():
... r = array([1,2,3])
... return r
...
>>> x()
array([1, 2, 3])
------------------------------------------ while I save it as a function named "f()"
import numpy
def f():
r = array([1,2,4])
return r and call out the function in console, error arouse:
>>> from test_array import f
>>> f()
Traceback (most recent call last):
File "<input>", line 1, in ?
File "C:\Documents and Settings\wckan\My Documents\Python_script\test_array.py", line 3, in f
r = array([1,2,4])
NameError: global name 'array' is not defined
HOW CAN I SOLVED THIS PROBLEM?
In the console (PyCrust), the script works:
>>> def x():
... r = array([1,2,3])
... return r
...
>>> x()
array([1, 2, 3])
------------------------------------------ while I save it as a function named "f()"
import numpy
def f():
r = array([1,2,4])
return r and call out the function in console, error arouse:
>>> from test_array import f
>>> f()
Traceback (most recent call last):
File "<input>", line 1, in ?
File "C:\Documents and Settings\wckan\My Documents\Python_script\test_array.py", line 3, in f
r = array([1,2,4])
NameError: global name 'array' is not defined
HOW CAN I SOLVED THIS PROBLEM?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Henk Verhoeven |
last post by:
(Reply on this newsgroup to an email - reply by email did not work)
Wolfman wrote:
>
> Hi,
> I found your Email in the php Newsgroup.
> I was looking for some way to resize some graphiks on my...
|
by: Daniel Joyce |
last post by:
When I try and run pycrust, I get...
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "/usr/bin/pycrust", line 4, in ?
from wxPython.lib.PyCrust.PyCrustApp...
|
by: Arun Seetharam |
last post by:
Dear Folks,
The application I am working on uses Frames (TopFrame, SideFrame(Left)
and the MainFrame). On the occurance of a certain event, I am closing
the window from one of the frames. This...
|
by: Randell D. |
last post by:
Folks,
I have got this working before, in part with some help from this ng but
I never really understood how I got it working... and last time, I was
using it via a popup window as opposed to an...
|
by: niconedz |
last post by:
Hi
The following code works fine in IE but not Firefox.
It's a little script that zooms an image and resizes the window to fit.
Can anybody tell me what's wrong?
Thanks
Nico
== btw.....
|
by: ZMan |
last post by:
Scenario:
This is about debugging server side scripts that make calls to
middle-tier business DLLs. The server side scripts are legacy ASP 3.0
pages, and the DLLs are managed DLLs...
|
by: Anthony |
last post by:
Below is a script I found at http://javascript.internet.com/ for a
cascading menu. The script works great but there is one thing that I
would like modified. BecauseI am just learning javascript,...
|
by: Stephany Young |
last post by:
When one uses the System.Diagnostics.Process.Start method to launch a common
or garden Console application, one can set the WindowStyle property of the
StartInfo object to ProcessWindowStyle.Hidden...
|
by: Kanis |
last post by:
(e.g. a file name g.py with class called "test")
evreytime I change the content in test and saved , it will not update my script when I type
>>> from g import test
But it only work when I...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |