Re: [Tutor] Usenet comp.lang.python

2011-11-19 Thread Alexander
On Sat, Nov 19, 2011 at 6:47 PM, Alan Gauld wrote: > On 19/11/11 19:48, Alexander wrote: > >> Hi. Does anybody know about using the comp.lang.python usenet news >> feed(?) ? >> I'd like help configuring it. I can't seem to find documentation helping >> me. >> Thanks for reading, >> > > The easiest

Re: [Tutor] python telnet

2011-11-19 Thread Rayon
Hi all got my code to work. I used an in queue and an out queue passed it to the telnet session . I am sending commands to the in_q using sockets and passing them back data with the out_q. Below is the code for a nonstop python telnet session. Thanks for the help, it got me thinking and that w

Re: [Tutor] Stacks and Stack underflow/Stack overflow

2011-11-19 Thread Walter Prins
Hi Steve/Joe, On 20 November 2011 00:09, Steven D'Aprano wrote: > Walter Prins wrote: > > pickle files are binary files and you probably opened it as a text file. >> See here: >> http://docs.python.org/py3k/**library/functions.html#open

Re: [Tutor] Stacks and Stack underflow/Stack overflow

2011-11-19 Thread Hugo Arts
On Sun, Nov 20, 2011 at 2:29 AM, Alan Gauld wrote: > On 20/11/11 00:09, Steven D'Aprano wrote: >> >> Walter Prins wrote: >> >>> pickle files are binary files and you probably opened it as a text file. >>> See here: http://docs.python.org/py3k/library/functions.html#open >> >> Not so. Pickle protoc

Re: [Tutor] Stacks and Stack underflow/Stack overflow

2011-11-19 Thread Alan Gauld
On 20/11/11 00:09, Steven D'Aprano wrote: Walter Prins wrote: pickle files are binary files and you probably opened it as a text file. See here: http://docs.python.org/py3k/library/functions.html#open Not so. Pickle protocol 0 is text, and it happens to be the default protocol used if you don

Re: [Tutor] Stacks and Stack underflow/Stack overflow

2011-11-19 Thread Steven D'Aprano
Walter Prins wrote: pickle files are binary files and you probably opened it as a text file. See here: http://docs.python.org/py3k/library/functions.html#open Not so. Pickle protocol 0 is text, and it happens to be the default protocol used if you don't instruct it different. So by default, p

Re: [Tutor] Stacks and Stack underflow/Stack overflow

2011-11-19 Thread Steven D'Aprano
Joe Batt wrote: Hi All Could some kind soul please explain why you get a stack underflow and a stack overflow. I don't, because I never make misteaks. *grin* Stack underflow and stack overflow are generic errors. You get a stack underflow when you have (say) five items on a stack and try to

Re: [Tutor] Usenet comp.lang.python

2011-11-19 Thread Alan Gauld
On 19/11/11 19:48, Alexander wrote: Hi. Does anybody know about using the comp.lang.python usenet news feed(?) ? I'd like help configuring it. I can't seem to find documentation helping me. Thanks for reading, The easiest way is probably to set up your newsreader to point at the gmane server.

[Tutor] FW: How do i show discount?(sorted)

2011-11-19 Thread ADRIAN KELLY
From: kellyadr...@hotmail.com To: kellyadr...@hotmail.com Subject: RE: How do i show discount? Date: Sat, 19 Nov 2011 23:34:27 + sorted it guys, used a third function Adrian From: kellyadr...@hotmail.com To: tutor@python.org Subject: How do i show discount? Date

Re: [Tutor] Stacks and Stack underflow/Stack overflow

2011-11-19 Thread Alan Gauld
On 19/11/11 19:37, Joe Batt wrote: File "/Users/joebatt/Desktop/python/pickling puzzle 5.py", line 39, in a=pickle.load(file) _pickle.UnpicklingError: unpickling stack underflow when I am running the following import pickle file=open('///Users/joebatt/Desktop/banner.p.webarchive','rb') I do

Re: [Tutor] How do i show discount?

2011-11-19 Thread Steven D'Aprano
ADRIAN KELLY wrote: how would i show the discount in main? Look at your shop() function: def shop(total_spend): min_spend=25 discount_amount=150 discount=0.05 if total_spend >= min_spend and total_spend > discount_amount: checkout=total_spend-(total_spend*discount)

Re: [Tutor] Can I shorten this code?

2011-11-19 Thread Alan Gauld
On 19/11/11 19:01, Mic wrote: Hi! I am new to programming and it have recently come to my attention that alot of my code could be shortened. Most peoples code could be shortened. And most of it would be the worse for it. There are a few occasions when shortening makes sense, especially if its

Re: [Tutor] Usenet comp.lang.python

2011-11-19 Thread Steven D'Aprano
Alexander wrote: Hi. Does anybody know about using the comp.lang.python usenet news feed(?) ? I'd like help configuring it. I can't seem to find documentation helping me. Thanks for reading, What is there to configure? It's a news group. You tell your news reader program to subscribe to the n

Re: [Tutor] command=F.quit not closing the sample TK program in Vista

2011-11-19 Thread Alan Gauld
On 19/11/11 14:59, Cranky Frankie wrote: I added C:\Python32 to the path environment variable in Vista, rebooted, and tried the test programs at the command prompt, and it says it can't find the program. You need to provide the full path to the file. C\WINDOWS> python C:\the\full\path\to\myf

[Tutor] Fw: Further pickle problem :0(

2011-11-19 Thread ALAN GAULD
Forwarding to list Always use ReplyAll, it keeps everyone involved. I don't know what the error means, hopefully somebody else does... Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ - Forwarded Message From: Joe Batt To: alan.ga...@btinternet.com Sent:

[Tutor] How do i show discount?

2011-11-19 Thread ADRIAN KELLY
def shop(total_spend):min_spend=25discount_amount=150discount=0.05 if total_spend >= min_spend and total_spend > discount_amount: checkout=total_spend-(total_spend*discount) discount=total_spend*discountelse:checkout = total_spend discount =

Re: [Tutor] Stacks and Stack underflow/Stack overflow

2011-11-19 Thread Walter Prins
Hi, On 19 November 2011 19:37, Joe Batt wrote: > I am getting the following error in Python 3 > > Traceback (most recent call last): > File "/Users/joebatt/Desktop/python/pickling puzzle 5.py", line 39, in > > a=pickle.load(file) > _pickle.UnpicklingError: unpickling stack underflow > >

Re: [Tutor] Stacks and Stack underflow/Stack overflow

2011-11-19 Thread Terry Carroll
On Sat, 19 Nov 2011, Joe Batt wrote: Hi All  Could some kind soul please explain why you get a stack underflow and a stack overflow. I am getting the following error in Python 3 Traceback (most recent call last):   File "/Users/joebatt/Desktop/python/pickling puzzle 5.py", line 39, in     a=p

[Tutor] Usenet comp.lang.python

2011-11-19 Thread Alexander
Hi. Does anybody know about using the comp.lang.python usenet news feed(?) ? I'd like help configuring it. I can't seem to find documentation helping me. Thanks for reading, -- Alexander ___ Tutor maillist - Tutor@python.org To unsubscribe or change su

[Tutor] Stacks and Stack underflow/Stack overflow

2011-11-19 Thread Joe Batt
Hi All Could some kind soul please explain why you get a stack underflow and a stack overflow. I am getting the following error in Python 3 Traceback (most recent call last): File "/Users/joebatt/Desktop/python/pickling puzzle 5.py", line 39, in a=pickle.load(file)_pickle.UnpicklingError:

Re: [Tutor] A recursion question

2011-11-19 Thread Kĩnũthia Mũchane
On 11/19/2011 04:59 PM, Dave Angel wrote: On 11/19/2011 01:36 AM, Kĩnũthia Mũchane wrote: On 11/19/2011 06:03 AM, Asokan Pichai wrote: Another way to do that is to avoid any intermediate variables altogether That may be easier to understand YMMV def counter(mylist, val): if len(mylist ==

[Tutor] Fwd: Re: The Perennial 3.2 vs 2.7

2011-11-19 Thread Mark Lybrand
Whoops. Hit reply only again. Sorry terry. -- Forwarded message -- From: "Mark Lybrand" Date: Nov 19, 2011 11:02 AM Subject: Re: [Tutor] The Perennial 3.2 vs 2.7 To: "Terry Carroll" Based on what everyone has said and the fact that my learning material is for 3, I think I will be

[Tutor] Can I shorten this code?

2011-11-19 Thread Mic
Hi! I am new to programming and it have recently come to my attention that alot of my code could be shortened. I have managed to shorten some of the code, but I ran into a problem with this piece of code: #Testing changing color and text on two buttons in a GUI. from tkinter import* value1=

Re: [Tutor] The Perennial 3.2 vs 2.7

2011-11-19 Thread Terry Carroll
On Thu, 17 Nov 2011, Wayne Werner wrote: On Thu, Nov 17, 2011 at 8:45 PM, Mark Lybrand wrote: so, use my 2.7 and not my 3.2 for my study? Or use my 3.2 for study and then do what I have to in 2.7 after including those lines? Honestly it probably doesn't matter. Many 3rd part

Re: [Tutor] Further pickle problem :0(

2011-11-19 Thread Alan Gauld
On 19/11/11 15:33, Joe Batt wrote: file=open('///Users/joebatt/Desktop/banner.p.webarchive','r') Try opening it on binary mode. Pickle files are not plain text. a=pickle.load(file) file.close() print (a) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ __

Re: [Tutor] command=F.quit not closing the sample TK program in Vista

2011-11-19 Thread Alan Gauld
On 19/11/11 14:59, Cranky Frankie wrote: I suspect you were trying to run the program from IDLE or Pythonwin? If so don't. Run the GUI examples from the command line or via Windows Explorer. If you double click the .py file a DOS Box may open in the background, just ignore it for now. But the G

Re: [Tutor] Guess my number game

2011-11-19 Thread Alan Gauld
On 19/11/11 12:53, myles broomes wrote: ...Here is the pseudocode I have written up: Once the user has thought of their number, take a guess While the number has not been guessed correctly Increase the number of 'tries' by 1 Ask the user if the guess was too high or too low

[Tutor] Further pickle problem :0(

2011-11-19 Thread Joe Batt
Hi all again Thank you to those that have helped me previously with this problem it is appreciated. Thanks to Walter I have actually found the pickle file that I am trying to restore to a variable however I am getting the following error Traceback (most recent call last): File "/Users/joebatt/

Re: [Tutor] Guess my number game

2011-11-19 Thread bob gailer
On 11/19/2011 8:14 AM, delegb...@dudupay.com wrote: Hi Myles, Pseudocodes are what anyone would write but they only lay an idea of what you intend to achieve. To get quick help, you need to write the actual code and tell us where the trouble spot is. This way we can help you get along. [sni

[Tutor] command=F.quit not closing the sample TK program in Vista

2011-11-19 Thread Cranky Frankie
More info: I added C:\Python32 to the path environment variable in Vista, rebooted, and tried the test programs at the command prompt, and it says it can't find the program. If I type Python at the command prompt it opens the Python intrepreter, but it will not run the test.py program. Now I'm re

[Tutor] command=F.quit not closing the sample TK program in Vista

2011-11-19 Thread Cranky Frankie
I'm playing around with the Tkinter examples on: http://www.alan-g.me.uk/l2p/index.htm and, at least on my Vista laptop, the sample window will not close when you click the Quit button, which is: bQuit = Button(fButtons, text="Quit", command=F.quit) Anyone else have this problem with the sample

Re: [Tutor] A recursion question

2011-11-19 Thread Dave Angel
On 11/19/2011 01:36 AM, Kĩnũthia Mũchane wrote: On 11/19/2011 06:03 AM, Asokan Pichai wrote: Another way to do that is to avoid any intermediate variables altogether That may be easier to understand YMMV def counter(mylist, val): if len(mylist == 0): return 0 if mylist[0]

Re: [Tutor] Pickling files in Python

2011-11-19 Thread Walter Prins
Hi Joe, On 19 November 2011 13:28, Joe Batt wrote: > I am new to programming and on a very steep curve. I am using Python 3 to > learn and I am having trouble understanding exactly what pickling is. > I have written a program that asks for a URL and then writes the source > code from the URL to

[Tutor] Pickling files in Python

2011-11-19 Thread Joe Batt
Hi all I am new to programming and on a very steep curve. I am using Python 3 to learn and I am having trouble understanding exactly what pickling is. I have written a program that asks for a URL and then writes the source code from the URL to a file, then pickles the file I just creat

Re: [Tutor] Guess my number game

2011-11-19 Thread delegbede
Hi Myles, Pseudocodes are what anyone would write but they only lay an idea of what you intend to achieve. To get quick help, you need to write the actual code and tell us where the trouble spot is. This way we can help you get along. Cheers. Sent from my BlackBerry wireless device from M

[Tutor] Guess my number game

2011-11-19 Thread myles broomes
I am currently learning Python from the 'Python Programming for the Absolute Beginner' book. At the end of each chapter, you are given challenges and one of the challenges is to make a 'Guess My Number' game where the player thinks of a number between 1 and 100 and the computer has to guess the

Re: [Tutor] python telnet

2011-11-19 Thread Rayon
Thanks but still not working, I am wondering if I need to give the script some kind of special permission to execute on windows 7. -Original Message- From: tutor-bounces+evosweet=hotmail@python.org [mailto:tutor-bounces+evosweet=hotmail@python.org] On Behalf Of James Chapman Sent:

Re: [Tutor] python telnet

2011-11-19 Thread James Chapman
traceback has: child = winspawn('telnet 192.168.0.55:210') When using telnet from CLI (on windows), you would type: telnet 192.168.0.55 210 Note the space between the IP and port number and not a :colon. Not sure this is your problem but probably worth mentioning. -- James At Saturday, 19/11

Re: [Tutor] python telnet

2011-11-19 Thread Rayon
I used the turn on turn off feature, and I can start a telnet session from the command line. -Original Message- From: tutor-bounces+evosweet=hotmail@python.org [mailto:tutor-bounces+evosweet=hotmail@python.org] On Behalf Of Steven D'Aprano Sent: 19 November 2011 07:04 To: tutor@py

Re: [Tutor] python telnet

2011-11-19 Thread Steven D'Aprano
Rayon wrote: I installed the telnet client but still the same error. How did you install it? Windows includes a telnet application, but it has to be enabled first: http://windows.microsoft.com/en-AU/windows-vista/Telnet-frequently-asked-questions If you run "telnet" from the Windows shell (

Re: [Tutor] Shorten Code.

2011-11-19 Thread ALAN GAULD
> >> > > for var in [value,value_1]: >> > > var = "green" >> >> > Um, that won't work. You typed that example too quickly. > > >> Excuse: It was early morning and I hadn't had any coffee... > >> In your defense Alan, after you typed that code in your response you >mentioned > the necessity o