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 3586 bartonc 6,596
Recognized Expert Expert
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?
bartonc 6,596
Recognized Expert Expert
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:\Documen ts and Settings\wckan\ My Documents\Pytho n_script\test_a rray.py", line 3, in f
r = array([1,2,4])
NameError: global name 'array' is not defined
HOW CAN I SOLVED THIS PROBLEM?
bartonc 6,596
Recognized Expert Expert
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:\Documen ts and Settings\wckan\ My Documents\Pytho n_script\test_a rray.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 HP , to fit
the actual Browser size. So I found this:
>
> <HTML><HEAD></HEAD>
|
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 import main
File
"/usr/lib/python2.2/site-packages/wxPython/lib/PyCrust/PyCrustApp.py", line
8, in ?
from crust import CrustFrame
|
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 is the script I use.
function CloseWin ()
{
window.opener = window;
window.close();
|
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 IFRAME. I've got several
months of javascript under my belt and can resolve most things without
errors in my Mozilla Javascript Console, but this one just does not do
it for me.
This is the picture:
|
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.. sorry for the long post ==
| |
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 converted/developed with VB.NET.
What I want from debugging is to be able to step into the methods in
the DLLs called from ASP scripts using Visual Studio .NET.
Background:
For typical script debugging issues, you can read and follow the two
documents on...
|
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, I did not
want to try to modify the code without a little help. When you place
the mouse over the menu bar, this script calls the function to show the
menu. I would like it modified to hide the menu when the mouse is
removed. Please help. The...
|
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 so that the window for the
Console application is not visible.
However, when using some of the 'advanced' properties of the StartInfo
object, like Username, Password and Domain, the WindowsStyle property of the
StartInfo object is ignored....
|
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 reopen the PyCrust, is there any other method rather than reload the PyCrust again?
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |