Numpy array index handling
Being a Matlab user wanting to switch to Python/SciPy, I'd like to know how the following Matlab code would be written in Python: % First, just some artificial data N = 100 ; input = sign(randn(1, N)) ; a = (1 : N) ; % This is what I'd like to do; % for indices where the input has a certain value, compute and store something % for indices where the input has another certain value, compute and store something else output(input < 0) = 10 * a(input < 0) ; output(input > 0) = 20 * a(input > 0) ; I have tried the following in Python: N = 100 input = sign(randn(N)) a = arange(N) output = zeros(N) output[input < 0] = 10 * a[input < 0] output[input > 0] = 20 * a[input > 0] However, that gives me in IndexError. Of course I could use a for-loop, but I assume that there is another way (although I haven't been able to find it in any documentation). Many thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list
Re: Numpy array index handling
Thanks a lot for your reply. I'll have a look at the numpy-discussion for future issues. FYI, I'm using Python 2.4.3 for Windows (Enthought Edition) and the included IPython shell. I found my mistake; importing of pylab. E.g., this works from pylab import * ; from scipy import * ; y = arange(3) ; y[y>1] = 0 but not from scipy import * ; from pylab import * ; z = arange(3) ; z[z>1] = 0 Using the 'whos' command, I can see that y is an ndarray type, whereas z is an array type. (I also see a lot of functions, etc. How can I list just the variables?) It seems a bit risky to use 'from scipy import *'. Maybe it's better to use 'import scipy' and then scipy.arange, to be sure what is actually being used? Would there be any disadvanages with that approach, other than more use of the keyboard? -- http://mail.python.org/mailman/listinfo/python-list
Installation of eyeD3 on Windows (newbie)
As a Python introduction exercise, I plan to write a script to automatically rename my music files according to the information in the ID3 tag (v2.X), and update the tag if necessary. To read/write ID3 tags, I found the eyeD3 library (http:// eyed3.nicfit.net/). However, I could not find any downloads or installation instructions for Windows, only for other OSs. I downloaded "eyeD3-0.6.13.tar.gz" anyway and unpacked it. Since I couldn't find any installation instructions for Windows, I tried renaming the file "setup.py.in" to "setup.py" to run the command "python setup.py install" from the command window in the directory of "eyeD3-0.6.13". After that, I tried "import eyeD3" and "from eyeD3 import *;", as in the file "eyeD3" in the bin directory without any success: import eyeD3 Traceback (most recent call last): File "", line 1, in File "C:\Program Files\Python\Lib\site-packages\eyeD3-0.6.13\bin \eyeD3.py", line 33, in from eyeD3.tag import *; ImportError: No module named tag I would highly appreciate if someone could help me with how to proceed (step-by-step) to get started and use the eyeD3 library in Windows? Many thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list
Automatic login to website (newbie)
I'm trying to use PAMIE to login to a website: import cPAMIE # python.org - just a test, works fine ie = cPAMIE.PAMIE() website = "http://www.python.org"; ie.navigate(website) ie.textBoxSet('q', 'pamie') ie.buttonClick('submit') # expekt.com - this is what I want to do, but it fails ie = cPAMIE.PAMIE() website = "http://www.expekt.com/eng"; ie.navigate(website) ie.textBoxSet('user', 'MyLogin') ie.textBoxSet('pass', 'MyPassword') ie.buttonClick('actn') The first part of the script works fine, i.e., I can successfully open IE, navigate to python.org, and do a search for "pamie". However, when trying to login to the Expekt website, nothing is entered in the text boxes, since they cannot be found. If I manually navigate to the Expekt website, right click next to the login boxes, and view source it looks like this: https://www.expekt.com: 443/userServlet?action=login" autocomplete="off" target="_top"> user: password: Forgot my password To my (limited) understanding, it looks like I have the correct names of the text boxes ("user" and "pass")? Problem with frames? Any ideas how to make it work? Is there a better way of automatically logging in to websites (and then navigating within the site)? Many thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list
Re: Automatic login to website (newbie)
On 15 Mai, 16:25, "Tim Williams" <[EMAIL PROTECTED]> wrote: > The frame URL ishttp://www.expekt.com/contenttop.jsp, you could try > navigating directly to the frame to see if it helps > > website = "http://www.expekt.com/contenttop.jsp"; > ie.navigate(website) > ie.textBoxSet('user', 'MyLogin') > ie.textBoxSet('pass', 'MyPassword') > ie.buttonClick('actn') Thanks a lot, it helped! (after also changing the last line to ie.buttonClick('login')) Next, I'd like to follow links within the website, but I ran into similar problems again. The following code navigates me to the desired website: # python.org ie = cPAMIE.PAMIE() website = "http://www.python.org"; ie.navigate(website) ie.textBoxSet('q', 'pamie') ie.buttonClick('submit') ie.linkClick('Agile Testing with Python Test Frameworks') But nothing happens when using the any of the linkClick commands in the code below (I'd like to click the "odds" link in the upper menu): # expekt.com ie = cPAMIE.PAMIE() website = "http://www.expekt.com/eng"; ie.navigate(website) ie.linkClick(' odds') #ie.linkClick('odds') #ie.linkClick('http://www.expekt.com/livebetting/index.jsp') #ie.linkClick('subMenusport1') I guess that I have to do something like "in the frame called 'menu', follow the link called 'odds'" (and similar for login; in the frame called 'contenttop', enter 'MyLogin' in the text box called 'user' and 'MyPassword' in the text box called 'pass'). Any ideas on how to accomplish this? Code samples (and/or documentation) to * launch IE (succeeded: IE = win32com.client.DispatchEx('InternetExplorer.Application.1')) * navigate to website (succeeded: IE.Navigate(website)) * fill in specific text box(es) in specific frame(s) and submit (need support) * follow specific link(s) in specific frame(s) (need support) using win32.client (or PAMIE or other) would be very welcome! Any help highly appreciated. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Image capture from Alacron FastFrame-CB
Hi. I would like to perform some image processing using Python. Can someone please point me in the right direction on how to get images from the framegrabber (Alacron FastFrame-CB)? Is VideoCapture (http://videocapture.sourceforge.net/) the correct way to go? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list