[Tutor] Installing numpy on Ubuntu
I've installed numpy on Ubuntu 12.04 with sudo apt-get install python3-numpy. Everything seems to go OK, yet when I try to use it I get this error: Python 3.3.3 (default, Dec 9 2013, 08:33:48) [GCC 4.6.3] on linux Type help, copyright, credits or license for more information. import numpy Traceback (most recent call last): File stdin, line 1, in module ImportError: No module named 'numpy' What am I doing wrong, Your help is appreciated, PierreD. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Installing numpy on Ubuntu
On 14-02-27 05:40 PM, eryksun wrote: On Thu, Feb 27, 2014 at 5:11 PM, Danny Yoo d...@hashcollision.org wrote: You mentioned you're using Ubuntu 12.04. But the version of Python 3 in that Ubuntu is Python 3.1: http://packages.ubuntu.com/lucid/python/python3 12.04 (precise), not 10.04 (lucid). So the python3-numpy package targets Python 3.2, but it's the same problem. Thank you all, You were right on, I was running a mix of 3.3 and 3.2. I've made the corrections and now it works PierreD. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Recommendation For A Complete Noob
On 14-02-09 05:37 PM, Altrius wrote: Hi, I’m completely new to programming in general and everything I have read so far has pointed me to Python. I’ll put this another way: All I know is that a programming language is a medium for a human to tell a computer what to do. After that I’m kinda lost. I was just hoping to get some input as to where I might start. I'd start with Guido van Rossum http://www.network-theory.co.uk/docs/pytut/ for a gentle introduction. Then I'd follow up with http://swaroopch.com http://www.diveintopython3.net/ by Mark Pilgrim and Learning to program by Alan Gauld http://www.freenetpages.co.uk/hp/alan.gauld/ You may also want to check http://www.linuxlinks.com/article/20121228122317781/20oftheBestFreePythonBooks-Part1.html for more advice. Welcome and good luck, PierreD. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python .decode issue
On 14-02-08 12:55 AM, james campbell wrote: header_bin = header_hex.decode('hex') AttributeError: 'str' object has no attribute 'decode' What I understand is that you are trying to decode 'hex', which is a string. The interpreter is telling you that strings cannot be decoded. I do not know header_hex.decode(), but I suspect it's expecting an hex number, check it out. PierreD. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] most useful ide
On 14-02-02 01:16 PM, Kodiak Firesmith wrote: Pycharm is nice for bigger projects (since tou can collapse any section); but it's crazy resource intensive. For Linux Gedit can be made very nice I prefer Geany as it will run my code with a click of the mouse. for python, and of course vim in the shell is very nice with the right ~/.vimrc. On Feb 2, 2014 11:20 AM, scurvy scott stopitscu...@gmail.com wrote: Hi Are there any recommendations for python ide's ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Best version for novice
On 14-02-01 08:20 PM, Steven D'Aprano wrote: On Sat, Feb 01, 2014 at 06:41:10PM +, Ian D wrote: Hi Is it better to use python 3 as a newcomer who isn't really going to be writing any software as such just using it for learning? Yes, you should use Python 3, with one proviso: many tutorials, especially the older ones, are based on Python 2. That means that you Steven is not a newbie, but I am. I suppose that makes me the expert on tutorials, LOL. I find that most useful tut are now for Python 3, when you find a Python 2 tutorial you need to convert the print statement, the tkinter import statement, and ignore any references to cPickle. In my experience everything else works as posted. PierreD. either need to find another tutorial, or mentally adjust from Python 2 to 3 when you read it. That's easy for an experienced user, but perhaps not for a beginner. The differences aren't really that great, no more different than between (say) British English and American English, but it may be disconcerting for somebody who isn't confident with the language. Python 3 is the future of Python. All improvements are going into 3, 2 is only getting bug fixes. If you aren't *required* to stick with Python 2 for some reason, you should use 3. Also in 2.7 I use no subprocess by giving my python exe a -n argument, otherwise my canvas program's freeze. I'm afraid that I have no idea what you are talking about here, Python doesn't accept a -n argument: [steve@ando ~]$ python2.7 -n Unknown option: -n usage: python2.7 [option] ... [-c cmd | -m mod | file | -] [arg] ... Try `python -h' for more information. Regards, ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] ValueError: could not convert string to float: '13,2'
Not very elegant, but it'll work. I don't suppose there is a function for determining the number of digits after the decimal, is it? It looks like you are trying to avoid rounding errors in decimal arithmetic. You might be interested in Python's decimal.Decimal type then. That's right, I had never heard of decimal.Decimal. I'll check it up. Also, anybody knows the maximum and/or minimum integer python will accept? Integers in Python (*) are unlimited 10**1000 -1 99 99 In practice the amount of available memory will be the limit, but you are unlikely to reach that. (*) Python 2 had int and long where values that could not represented by machine integers were automatically propagated to long. In Python 3 the int and long have been united as int. Thank you very much, ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Naming variables
Hello, I wish to fill a list called years[] with a hundred lists called year1900[], year1901[], year1902[], ..., year1999[]. That is too much typing of course. Any way of doing this in a loop? I've tried stuff like (year + str(1900)) = [0,0] but nothing works. Any solution? Thank you, PierreD. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] ValueError: could not convert string to float: '13,2'
On 13-12-31 04:09 PM, Keith Winston wrote: Hi PierreD, I think if you iterate over your strings with something like this, it will do what you want, if I understand correctly (snum is your string number, like 123,321): fnum = float(snum.replace(,, .) keith: rank beginner, take everything with a grain of salt! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor Thank you all who responded, for now I'll go with Keith's solution and keep the locale for next time. As all the data has one digit after the decimal I can get away with myInt = int(temp.replace(',','')) to convert a string representation of a float to an integer. I'll just need to remember to divide everything by ten once the calculations are done. Not very elegant, but it'll work. I don't suppose there is a function for determining the number of digits after the decimal, is it? Also, anybody knows the maximum and/or minimum integer python will accept? Thank you, PierreD. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] ValueError: could not convert string to float: '13,2'
Hi, I'm trying to convert a list of strings to float. Unfortunately the numbers are written with a decimal comma instead of a decimal point. What is the best way to replace these commas with decimal points? Do I need to write a function that will iterate over every alphanumeric, replace the comma with a point and then rewrite the list, or is there a better way? Thank you, PierreD. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] menu-libre broken? :p:
On 13-12-20 05:59 AM, Paradox wrote: On 12/19/2013 10:46 PM, Keith Winston wrote: I did this sequence of commands: sudo add-apt-repository ppa:menulibre-dev/devel sudo apt-get update sudo apt-get install menulibre But at the end of the update I got: W: Failed to fetch http://ppa.launchpad.net/menulibre-dev/devel/ubuntu/dists/saucy/main/source/Sources Alan is correct, this is an Ubuntu problem rather than a Python problem. You may well have better luck getting this answered on the Ubuntu forums. I have run into this with a few PPAs before, seems like sometimes the PPAs are not accessible for whatever reason. Obviously if the PPA is not accessible, you can't install the package. You may want to try to contact the developers of the package (there should be a contact method on the PPA's website). thomas ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor If you go to the website http://ppa.launchpad.net/menulibre-dev/devel/ubuntu/dists/ you'll see that precise, quantal and raring are the only distributions offered, saucy is not. I don't know why, but like Thomas said you should contact the developers of the package, or just wait, a fix is probably underway. PierreD. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] No module named '_tkinter'
On 13-12-08 10:57 PM, Reuben wrote: Can you try importing the module '_tkinter' On 09-Dec-2013 6:43 AM, pierre dagenais eq...@ncf.ca wrote: Hi, I'm running Ubuntu 10.04 and I've installed python 3.3.3 from the tarball at http://python.org/ftp/python/3.3.3/Python-3.3.3.tar.xz Here is the error I get when trying to run tkinter. pierre@Sprint:~$ python3.3 Python 3.3.3 (default, Dec 2 2013, 11:10:53) [GCC 4.6.3] on linux Type help, copyright, credits or license for more information. import tkinter Traceback (most recent call last): File stdin, line 1, in module File /usr/local/lib/python3.3/tkinter/__init__.py, line 40, in module import _tkinter # If this fails your Python may not be configured for Tk ImportError: No module named '_tkinter' I've tried installing python3-tk from the Ubuntu repository but it doesn't help. Any suggestion on how to install the tkinter module with this version? Thank you, PierreD. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor I get a similar error. ImportError: No module named '_tkinter' import _tkinter Traceback (most recent call last): File stdin, line 1, in module ImportError: No module named '_tkinter' ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] No module named '_tkinter' ***solved***
On 13-12-09 03:14 AM, eryksun wrote: On Sun, Dec 8, 2013 at 2:36 PM, pierre dagenais eq...@ncf.ca wrote: I'm running Ubuntu 10.04 and I've installed python 3.3.3 from the tarball at http://python.org/ftp/python/3.3.3/Python-3.3.3.tar.xz Here is the error I get when trying to run tkinter. ImportError: No module named '_tkinter' I've tried installing python3-tk from the Ubuntu repository but it doesn't help. It looks like you didn't install the development dependencies before building. The build-dep for Lucid's 3.1 package should do the trick. sudo apt-get update sudo apt-get build-dep python3.1 python3.1 is not available on precise pangolin, so used python3.2 instead. For good measure run the following, too: sudo apt-get install build-essential \ libbz2-dev libdb-dev libexpat1-dev libffi-dev \ libgdbm-dev liblzma-dev libncursesw5-dev \ libreadline6-dev libsqlite3-dev libssl-dev \ tk-dev zlib1g-dev A few of these were missing, installed now. Then do a `make clean` and rebuild. Don't know what a 'make clean' is. I skipped it and rebuilt, looks good now. I can 'import tkinter' without error. Thank you, much appreciated, PierreD. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] No module named '_tkinter'
Hi, I'm running Ubuntu 10.04 and I've installed python 3.3.3 from the tarball at http://python.org/ftp/python/3.3.3/Python-3.3.3.tar.xz Here is the error I get when trying to run tkinter. pierre@Sprint:~$ python3.3 Python 3.3.3 (default, Dec 2 2013, 11:10:53) [GCC 4.6.3] on linux Type help, copyright, credits or license for more information. import tkinter Traceback (most recent call last): File stdin, line 1, in module File /usr/local/lib/python3.3/tkinter/__init__.py, line 40, in module import _tkinter # If this fails your Python may not be configured for Tk ImportError: No module named '_tkinter' I've tried installing python3-tk from the Ubuntu repository but it doesn't help. Any suggestion on how to install the tkinter module with this version? Thank you, PierreD. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Test - please ignore
___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] httplib2.RelativeURIError: Only absolute URIs are allowed. uri
Hi, I'm running python 3.2 on Ubuntu 11.04 and have a problem with httplib2. I'm not sure if it's my ignorance or a bug in the code. This code works: #! /usr/bin/python3.2 import urllib.request sock = urllib.request.urlopen(file:///home/pierre/bookmarks.html) htmlSource = sock.read() sock.close() print (htmlSource) and so does this one: #! /usr/bin/python3.2 import httplib2 h = httplib2.Http('.cache') response, content = h.request(http://google.com;) print(response) but this one doesn't: #! /usr/bin/python3.2 import httplib2 h = httplib2.Http('.cache') response, content = h.request(file:///home/pierre/bookmarks.html) print(response) I get this error message when I run it: Traceback (most recent call last): File Meteo5.py, line 6, in module response, content = h.request(file:///home/pierre/bookmarks.html) File /usr/lib/python3/dist-packages/httplib2/__init__.py, line 984, in request (scheme, authority, request_uri, defrag_uri) = urlnorm(uri) File /usr/lib/python3/dist-packages/httplib2/__init__.py, line 137, in urlnorm raise RelativeURIError(Only absolute URIs are allowed. uri = %s % uri) httplib2.RelativeURIError: Only absolute URIs are allowed. uri = file:///home/pierre/bookmarks.html Isn't file:///home/pierre/bookmarks.html a valid URI? It works fine with urllib, why not with httplib2? Your help is appreciated, ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] python2 vs python3 urllib
On 11-04-23 06:58 PM, pierre dagenais wrote: The following code works as expected with python version 2.6.5, but with version 3.1.2 I get the following error: pierre:/MyCode/mesProjets$ py3 test.py Traceback (most recent call last): File test.py, line 3, in module sock = urllib.urlopen(http://diveintopython.org/;) AttributeError: 'module' object has no attribute 'urlopen' The code: #example 8.5 of diveintopython.org/ import urllib sock = urllib.urlopen(http://diveintopython.org/;) htmlSource = sock.read() sock.close() print (htmlSource) What is the proper syntax in version 3? Thank you, Your help is much appreciated. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor Thank you everybody, The short answer was of course: import urllib.request instead of : import urllib I realize I'm still confused about packages, libraries, modules, classes, etc... Right now they're all more or less the same to me. I've got some reading to do. Thanks again, Pierre ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] python2 vs python3 urllib
The following code works as expected with python version 2.6.5, but with version 3.1.2 I get the following error: pierre:/MyCode/mesProjets$ py3 test.py Traceback (most recent call last): File test.py, line 3, in module sock = urllib.urlopen(http://diveintopython.org/;) AttributeError: 'module' object has no attribute 'urlopen' The code: #example 8.5 of diveintopython.org/ import urllib sock = urllib.urlopen(http://diveintopython.org/;) htmlSource = sock.read() sock.close() print (htmlSource) What is the proper syntax in version 3? Thank you, Your help is much appreciated. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] plotting pixels
On 10-09-18 07:39 PM, ALAN GAULD wrote: It appears that the Tk canvas widget does not support simply plotting a pixel. Correct, and I agree it seems odd, but in practice drawing either lines or ovals of one-pixel do the equivalent job - albeit a little more slowly. The primitive obviously exists in the underlying code, It probably exists in the native graphics toolkit (Xlib or Win32 or Aqua) but it doesn't exist at the Tk level which is why Tkinter can't expose it. FWIW wxPython does provide a DrawPoint() method as part of its DeviceContext class. Digging a little deeper it seems the idiomatic way to do this in Python is to use PIL the Python Imaging Library to create a GIF or bitmap image and then insert that into Tkinters cancvas as an image object. The Pil ImageDraw class has a point() ethod I've never tried this but it is described in Grayson's (now out of print?) book on Tkinter where he uses it to draw a Mandelbrot The book may be available online these days... Nowdownloadall.com seems to have it although I've no idea of the legality of it! HTH, Alan G. Here's a link, just don't download everything. It would be excessively large. http://isohunt.com/download/212380933/%22Python+and+Tkinter+Programming%22.torrent ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Installation Problems
Matthew Hill wrote: oops I ment to say 2.5.2 is what blender wanted and 2.6 was the newest one I had Then blender is likely to look for python.exe in c:\python25 while on your computer it's probably under c:\python26. Try renaming the directory c:\python26 to c:\python25 and see if that works. You might also have to modify the PATH and PYTHONPATH environments. If you wish to install python v2.5.2 maybe you need to uninstall v 2.6, just gessing. HTH Pierre --- On Thu, 10/9/08, Pierre Dagenais [EMAIL PROTECTED] wrote: From: Pierre Dagenais [EMAIL PROTECTED] Subject: Re: [Tutor] Installation Problems To: Cc: tutor@python.org Date: Thursday, October 9, 2008, 7:55 PM Matthew Hill wrote: I am a newly beginning aspiring programmer. I have been learning Blender 3D and I want to use python with it. I downloaded the newest version of python and I tried running it with Blender 2.47. Python would work alone but would not with Blender. I read on a forum that I needed to get python 5.52 to match with what blender wants. Version 5.52 ??? The latest version of python is 2.6 (3.0 for beta). Only the new (5.52) version won't install. It says 'contact the vender to verify this is a windows program' when I try the install. What is going on? Is 5.52 compatible with windows vista? Am I just missing something? The prompt I got inside blender with 2.6 was: 'import site' failed; use -v for traceback checking for installed Python... no installed Python found. Sounds like a blender problem, blender can't find python.exe which usually is in C:\python26. Unfortunately I'm not familiar with blender. Only built-in modules are available. some scripts may not run. continuing happily. any insight to these problems would really help me out ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.173 / Virus Database: 270.7.6/1715 - Release Date: 08/10/2008 7:19 PM ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.173 / Virus Database: 270.8.0/1717 - Release Date: 09/10/2008 4:56 PM ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Installation Problems
Matthew Hill wrote: I am a newly beginning aspiring programmer. I have been learning Blender 3D and I want to use python with it. I downloaded the newest version of python and I tried running it with Blender 2.47. Python would work alone but would not with Blender. I read on a forum that I needed to get python 5.52 to match with what blender wants. Version 5.52 ??? The latest version of python is 2.6 (3.0 for beta). Only the new (5.52) version won't install. It says 'contact the vender to verify this is a windows program' when I try the install. What is going on? Is 5.52 compatible with windows vista? Am I just missing something? The prompt I got inside blender with 2.6 was: 'import site' failed; use -v for traceback checking for installed Python... no installed Python found. Sounds like a blender problem, blender can't find python.exe which usually is in C:\python26. Unfortunately I'm not familiar with blender. Only built-in modules are available. some scripts may not run. continuing happily. any insight to these problems would really help me out ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.173 / Virus Database: 270.7.6/1715 - Release Date: 08/10/2008 7:19 PM ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] first call - newcomer
Anthony Smith wrote: This is my first post - I will be brief... One: I have programmed before - but it has been DECADES...so just a few simple queries: 1. A brief (but complete) description regarding the use of script editor (I will be using command prompt in Windows), as: a. details about loading and saving programs (not in that order) and little specs about pathnames or other requirements (I will probably store all my little goodies in one folder or space). Hi, You save programs by writing them in a file with a .py extension. Ex.: myProgram.py Then there are different ways of loading a program, from the dos command line you can do: C:\myProgram.py, that one I couldn't find in the litterature, I had to ask, thank you Alan. That should get me going ... a book and manual by my side should suffice for the rest - - - except for one thing: 2. I have been unable to locate the gizmo in the literature to get ascii codes in python. In the old days, it was a list of 256 (or so) characters that represented all keyboard symbols (A equalled 36; B equalled 37; et cetera). To assign a value, you used Let A$ = ASC (36) where A$ was a variable and 36 was the ASCII value for 'A'. I believe the reverse of this process was PRINT VAL(A$) or something. I want to play with a program that will assign a number to a word (using a simple algorhythm that will give a specific number to every word). Other stuff is pretty easy to find with the book and on-line literature. I will need to get an ascii code out of a string (whose content is not known to the programmer, as raw_input). Then to assign, I will need the actual list with assigned numbers. You will be giving me probably the only boost I will need! I will be available later on, if I want to take part in the ask/answer system here. Thanks a lot, Anthony 8:27 pm PST October 4th, 2008 _ Get more out of the Web. Learn 10 hidden secrets of Windows Live. http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.173 / Virus Database: 270.7.6/1710 - Release Date: 06/10/2008 9:23 AM ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
Timothy Grant wrote: On Tue, Sep 30, 2008 at 10:20 PM, Pierre Dagenais [EMAIL PROTECTED] wrote: kayla bishop wrote: I can't figure out how to write a program where you flip a coin 100 times and it keeps track of how many heads and tails you flipped but it has to be random. Can you please help _ Get more out of the Web. Learn 10 hidden secrets of Windows Live. http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.173 / Virus Database: 270.7.5/1698 - Release Date: 29/09/2008 7:25 PM Here is how one newbie would do it: import random # Initialize variables head = 0 tail = 0 # Flip the coin a hundred times for x in range(100): choice = random.randint(1,2) # Is it 'head'? if choice == 1 : head = head + 1 # If not 'head' then it must be tail else : tail = tail + 1 print head = ,head print tail = ,tail ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Please let us know if Pierre gets an an A on that assignment or not Kayla. If that's what it is, and I thought it might be, he won't learn how to program but on exam day he'll realize that cheating is very expensive. A great lesson to learn early in life if possible. On the other hand if Kayla is just new to programming and learning on his own, then some silly mistake can take weeks to figure out and is a huge waste of time, as I experienced when learning basic on my beloved ZX81. Besides any teacher worth it's wiff should scan this list for cheaters, right? Have a nice day, both of you. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] python: can't open file 'test.py' : [Errno 2] No such file or directory
Timothy Grant wrote: On Tue, Sep 30, 2008 at 9:01 PM, Pierre Dagenais [EMAIL PROTECTED] wrote: Timothy Grant wrote: On Tue, Sep 30, 2008 at 12:58 PM, Pierre Dagenais [EMAIL PROTECTED] wrote: The file test.py is in I:\Python25\MyCode, if I enter: C:\Python25\MyCode\python25 test.py at the DOS prompt, everything works as I would expect. However when I enter the same command from any other directory I get this error: C:\python test.py python: can't open file 'test.py' : [Errno 2] No such file or directory I've set the environment variable pythonpath as C:\set pythonpath = C:\\Python25\\MyCode what am I doing wrong, Thank u for your help, ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor You need to give the full path to your test.py file. PYTHONPATH sets the python library search path. Thank you Tim, Definitively C:\python \python25\mycode\test.py does work. If you're right about having to give the full path, and I suspect you are, Then this means that python knows to search the currennt working directory for the file to execute, but nowhere else. It seems a strange behavior. Maybe this is on Mr. Guido van Rossum todo list. Why is that strange? Would you expect any other program not on the path to execute without a fully qualified path? Make your python code executable, and put it somewhere on the path and I'm quite sure it would run as expected (though it has been over 10 years since I last had to work on a Windows box so I'm not quite sure how to do that). Yes Tim, but both PATH and PYTHONPATH are set to \python25 and \python25\MyCode, so I don't understand why python searches the CWD but neither the path nor pythonpath directories. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] python: can't open file 'test.py' : [Errno 2] No such file or directory
If you're right about having to give the full path, and I suspect you are, Then this means that python knows to search the currennt working directory for the file to execute, but nowhere else. Correct, just like every other program. If you run notepad foo.txt notepad will open a new foo.txt in the current folder it will not search your drive to find some other foo.txt that you created prevbiously. Why would python be any different? I didn't realize other program were also behaving that way, I don't work much with the command prompt anymore :-) The trick to do what you want is not to execute python but to execute the script and allow the OS to associate Python with it. That is what I was missing, C:\test.py will execute. So either just type the script name into the prompt (assuming it is on the PATH) or double click in explorer and Windows will find Python itself. HTH, It sure does, thanks everybody for the great replies, ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
kayla bishop wrote: ok i imported the random module and set it up with a 2... i can't get it to loop correctly to where it keeps going until the total of heads and tails is 100 Date: Wed, 1 Oct 2008 00:18:51 -0400 From: [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] (no subject) kayla bishop wrote: I can't figure out how to write a program where you flip a coin 100 times and it keeps track of how many heads and tails you flipped but it has to be random. Can you please help Hi Kayla, Have you read the other posts on the list? bhaaluu sent you a great little tutorial showing how a pro would go about solving this problem. Read it carefully, it's really worth all the time you will spend on it. Your problem seems to be that you expect the random module to return a 100 answers, it won't. Random returns only one choice for everytime you run it. That's why we use a loop, to run random a 100 times. Don't despair, in the beginning everybody trips on silly details like that, keep at it and soon you'll be the expert. Kent, I didn't realize the list had a policy, I'm sorry for breaking it. Were can I read it? ignorance not being an excuse. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] python: can't open file 'test.py' : [Errno 2] No such file or directory
The file test.py is in I:\Python25\MyCode, if I enter: C:\Python25\MyCode\python25 test.py at the DOS prompt, everything works as I would expect. However when I enter the same command from any other directory I get this error: C:\python test.py python: can't open file 'test.py' : [Errno 2] No such file or directory I've set the environment variable pythonpath as C:\set pythonpath = C:\\Python25\\MyCode what am I doing wrong, Thank u for your help, ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] python: can't open file 'test.py' : [Errno 2] No such file or directory
W W wrote: On Tue, Sep 30, 2008 at 2:58 PM, Pierre Dagenais [EMAIL PROTECTED]wrote: The file test.py is in I:\Python25\MyCode, if I enter: C:\Python25\MyCode\python25 test.py at the DOS prompt, everything works as I would expect. However when I enter the same command from any other directory I get this error: C:\python test.py python: can't open file 'test.py' : [Errno 2] No such file or directory I've set the environment variable pythonpath as C:\set pythonpath = C:\\Python25\\MyCode I'm not entirely sure about Windows, but my guess is that your problem is that the pythonpath isn't what you need to set. I would venture to guess that it's searching for test.py in your current path. If I'm correct in my thinking, all it does when you set the python path is tells python to execute in that directory, so if your script contains something like f = open(myfile.txt, w) it will put it in that directory. You may want to try this: The path is now managed by Windows 2000 / Windows XP and not the autoexec.bat or autoexec.nt files. To change the system environment variables, follow the below steps. 1. From the desktop http://www.computerhope.com/jargon/d/desktop.htm, right-click My Computer and click properties. 2. In the System Properties windowhttp://www.computerhope.com/jargon/w/window.htm, click on the Advanced tab http://www.computerhope.com/jargon/t/tab.htm. 3. In the Advanced section, click the Environment Variables buttonhttp://www.computerhope.com/jargon/p/pushbutt.htm . 4. Finally, in the Environment Variables window, highlight the path variable in the Systems Variable section and click edit. Add or modify the path lines with the paths you wish the computer to access. Each different directory is separated with a semicolon as shown below. C:\Program Files;C:\Winnt;C:\Winnt\System32 from: http://www.computerhope.com/issues/ch000549.htm Try adding the path to your code in that way, and see if it works. HTH, Wayne Thank you Wayne, My path does include C:\python25;C\python25\mycode among other things. Is that is what you meant? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] python: can't open file 'test.py' : [Errno 2] No such file or directory
Timothy Grant wrote: On Tue, Sep 30, 2008 at 12:58 PM, Pierre Dagenais [EMAIL PROTECTED] wrote: The file test.py is in I:\Python25\MyCode, if I enter: C:\Python25\MyCode\python25 test.py at the DOS prompt, everything works as I would expect. However when I enter the same command from any other directory I get this error: C:\python test.py python: can't open file 'test.py' : [Errno 2] No such file or directory I've set the environment variable pythonpath as C:\set pythonpath = C:\\Python25\\MyCode what am I doing wrong, Thank u for your help, ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor You need to give the full path to your test.py file. PYTHONPATH sets the python library search path. Thank you Tim, Definitively C:\python \python25\mycode\test.py does work. If you're right about having to give the full path, and I suspect you are, Then this means that python knows to search the currennt working directory for the file to execute, but nowhere else. It seems a strange behavior. Maybe this is on Mr. Guido van Rossum todo list. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
kayla bishop wrote: I can't figure out how to write a program where you flip a coin 100 times and it keeps track of how many heads and tails you flipped but it has to be random. Can you please help _ Get more out of the Web. Learn 10 hidden secrets of Windows Live. http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008 Which part are you having a problem with? Flipping the coin or keeping track of the results, or both? Try to be little more explicit please. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
kayla bishop wrote: I can't figure out how to write a program where you flip a coin 100 times and it keeps track of how many heads and tails you flipped but it has to be random. Can you please help _ Get more out of the Web. Learn 10 hidden secrets of Windows Live. http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.173 / Virus Database: 270.7.5/1698 - Release Date: 29/09/2008 7:25 PM Here is how one newbie would do it: import random # Initialize variables head = 0 tail = 0 # Flip the coin a hundred times for x in range(100): choice = random.randint(1,2) # Is it 'head'? if choice == 1 : head = head + 1 # If not 'head' then it must be tail else : tail = tail + 1 print head = ,head print tail = ,tail ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] newbie graphing question
Peter Petto wrote: I'm about to try some Python programming for drawing simple geometric pictures (for math classes I teach) and was hoping to get some advice that will send me off in the best direction. I want to write programs that can draw figures with commands akin to point(x,y) to draw a point at coordinates (x,y), or segment (x1,y1,x2, y2) to draw a segment between points (x1, y1) and (x2, y2)? I'd appreciate recommendations as to the best facility or library to use to this end. I primarily use a Mac, but my students primarily use Windows. I'd love to hear any and all pointers or comments. Thanks! Hi Peter, I'm just trying to do the same, draw points and lines without having to spend the next six months learning a GUI environment and then finding I've been learning the wrong one all this time. Then I stumbled on these pages at py4fun, it's a quick and dirty introduction to the basics of Tkinter, just a few commands and you're in business. Hope that is what you're looking for, http://ibiblio.org/obp/py4fun/gui/tkPhone.html http://ibiblio.org/obp/py4fun/wave/wave.html ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor