Re: [Tutor] Question on listing cards, then deleting one or more items by user's choice.

2005-08-09 Thread luke
>Say I deal 5 cards, and then list them. How would I print the list of cards, with the numbers >of each card(the position in the list)? Then delete a certain card or cards, based upon the >user's choice?. hope this points you in the right direction Nathan. -Luke #start of program #--

Re: [Tutor] How do I fix this ValueError?

2005-08-09 Thread Alan G
Nathan, > for site,ID,passcard in sitelist.items(): > ValueError: need more than 2 values to unpack The line is asking a dictionary (sitelist) to return 3 values (site, ID and passcard) from its items() method. But A dictionary stores things as name/value pairs so you can only get 2 items bac

[Tutor] Question on listing cards, then deleting one or more items by user's choice.

2005-08-09 Thread Nathan Pinno
Say I deal 5 cards, and then list them. How would I print the list of cards, with the numbers of each card(the position in the list)? Then delete a certain card or cards, based upon the user's choice?.   Nathan ---Early to bed,Early

Re: [Tutor] How to I make it save the data properly? (was Re: How do Ifix this ValueError?)

2005-08-09 Thread Nathan Pinno
I fixed it. The problem was this line: ID = line.strip().strip() I fixed it so that it now reads: ID = store.next().strip() As a result, the program runs perfectly. Nathan Pinno --- Early to bed, Early to rise, Makes a man healthy, wealt

Re: [Tutor] How to I make it save the data properly? (was Re: How do I fix this ValueError?)

2005-08-09 Thread jfouhy
Quoting Nathan Pinno <[EMAIL PROTECTED]>: > I tried fixing it. Here is the new code: There are two likely places where you could have a problem: In your save function, or in your load function. Have you tried looking at the file where it saved the information? If the file doesn't contain the da

[Tutor] How to I make it save the data properly? (was Re: How do I fix this ValueError?)

2005-08-09 Thread Nathan Pinno
I tried fixing it. Here is the new code: #This is for a password protected program to store passwords. import getpass password = "hello" sitelist = {} def load_file(pw): import os filename = 'passcard.txt' if os.path.exists(filename): store = open(filename,'r') for line

[Tutor] Question on classes/instances

2005-08-09 Thread Negroup -
Hi, Sorry for the subject a bit generic. This question comes from a simple program I'm doing. I could have a working solution, but considering my inexperience, I'm just asking if my approach is acceptable. This is a simple class to manage (actually to create and save) categories of things. Categor

Re: [Tutor] How do I fix this ValueError?

2005-08-09 Thread Nathan Pinno
I think it means that I can't store the data as a dictionary unless I store both the username and passcard as username|passcard. Am I right? --- Early to bed, Early to rise, Makes a man healthy, wealthy, and wise. --Benjamin Franklin

Re: [Tutor] How do I fix this ValueError?

2005-08-09 Thread jfouhy
Quoting Nathan Pinno <[EMAIL PROTECTED]>: > Here is the error: > > Traceback (most recent call last): > File "D:\Python24\password.py", line 91, in -toplevel- > save_file(sitelist) > File "D:\Python24\password.py", line 22, in save_file > for site,ID,passcard in sitelist.items(): > ValueError

[Tutor] How do I fix this ValueError?

2005-08-09 Thread Nathan Pinno
Here is the error:   Traceback (most recent call last):  File "D:\Python24\password.py", line 91, in -toplevel-    save_file(sitelist)  File "D:\Python24\password.py", line 22, in save_file    for site,ID,passcard in sitelist.items():ValueError: need more than 2 values to unpack   Here is th

Re: [Tutor] What can I do with this code?

2005-08-09 Thread R. Alan Monroe
> print random.choice(cool) > What can I do with it, other than let it be a fun example of coding? Make a Magic 8 ball! :^) Alan ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] What can I do with this code?

2005-08-09 Thread Nathan Pinno
I coded the following just for fun:   import randomcool = ['Cool math!','Awesome!','Way to go!','Happy problem solving!']while 1:    start = raw_input("Do you want to do some math? Yes or No")    if start == "Yes":    x = int(raw_input("First number:"))    y = int(raw_input("Second

Re: [Tutor] (OT) Info on card games.

2005-08-09 Thread Alan G
> Nathan. >--- > Early to bed, > Early to rise, > Makes a man healthy, wealthy, and wise. >--Benjamin Franklin >--- > P.S. Is this signature better than the last one? There w

Re: [Tutor] help

2005-08-09 Thread jfouhy
Quoting Dan Deternova <[EMAIL PROTECTED]>: > ok. i know python and want to turn all my programs i made when i was > learning python into Tkinter programs. i dont know how to make if > satments and display the output like this in python: > if cmd == quit: > print "press exit to quit" > i have n

Re: [Tutor] Use functions re avoid Re: Can the following algorithmbe improved?

2005-08-09 Thread Brian van den Broek
Nathan Pinno said unto the world upon 2005-08-09 17:35: > It printed 25.973 as the result. >> I don't think I got the math wrong. My thinking is there are 52**6 >> ways to choose 6 items from 52 if you don't care about duplicates, and >> 52*51*50*49*48*47 ways to choose if you do. (The first

[Tutor] help

2005-08-09 Thread Dan Deternova
ok. i know python and want to turn all my programs i made when i was learning python into Tkinter programs. i dont know how to make if satments and display the output  like this in python: if cmd == quit: print "press exit to quit"   i have no idea how to do that in Tkinter please help.  

Re: [Tutor] Use functions re avoid Re: Can the following algorithmbe improved?

2005-08-09 Thread Nathan Pinno
It printed 25.973 as the result. --- Early to bed, Early to rise, Makes a man healthy, wealthy, and wise. --Benjamin Franklin --- - Original Message - From: "Brian va

Re: [Tutor] Use functions re avoid Re: Can the following algorithmbe improved?

2005-08-09 Thread Brian van den Broek
Nathan Pinno said unto the world upon 2005-08-09 15:35: > Hey all, > > I just fixed it so that it prints. The problem was that it returned the > cards instead of printing them. > > Nathan > >> Hey Brian and all, >> >> Just coded in and tried your program Brian. Doesn't print a thing. >>

Re: [Tutor] deck dealing program

2005-08-09 Thread Nathan Pinno
Thanks Luke. You've helped me out of a jam that I was going to ask without even asking.   Nathan ---Early to bed,Early to rise,Makes a man healthy, wealthy, and wise.--Benjamin Franklin

[Tutor] ANN: Python training, Aug 29-31, San Francisco

2005-08-09 Thread Wesley Chun
hi all, just wanted to announce my next public Python course. it's a 3-day course held near the San Francisco airport. please sign up quickly as there are only 10 more open spots! let me know if you have any questions. the website is http://cyberwebconsulting.com (click "Python training"), but

Re: [Tutor] surprising len() results ???

2005-08-09 Thread Tom Cloyd
Michael and List, You suggestion (see foot of email trail, below) is a bit over my head. As I stated, I removed ActivePython 2.4.1 installed Python 2.4.1 from python.org, and now my program doesn't work, where before it did. I don't understand this. When isn't Python 2.4.1 == Python 2.4.1? I

[Tutor] (OT) Info on card games.

2005-08-09 Thread Nathan Pinno
Hey all,   I marked it off-topic, but it is necessary to mail this to the mailing list. People asked questions when I first put up my blackjack game(the beginning code of it anyway), so here is a site that has the rules of card games, since I'll be writing them on Python.   It's http://www.pa

Re: [Tutor] Use functions re avoid Re: Can the following algorithmbe improved?

2005-08-09 Thread Nathan Pinno
Hey all, I just fixed it so that it prints. The problem was that it returned the cards instead of printing them. Nathan --- Early to bed, Early to rise, Makes a man healthy, wealthy, and wise. --Benjamin Franklin --

Re: [Tutor] Use functions re avoid Re: Can the following algorithm be improved?

2005-08-09 Thread Nathan Pinno
Hey Brian and all, Just coded in and tried your program Brian. Doesn't print a thing. I thought the odds were more like 6/52! or 1/(1.3443029195*10^84). --- Early to bed, Early to rise, Makes a man healthy, wealthy, and wise. --Benjamin

Re: [Tutor] Curses example on Linux?

2005-08-09 Thread Alan G
> "ky = chr(msvcrt.getch())". The other problem is that when > the program is finished the previous terminal state is not > restored (I am using xterm on Linux). Yep, and that applies to my cygwin terminal too. I think there is a setty command you can issue that fixres this but since I hardly ev

Re: [Tutor] Tkinter Menus

2005-08-09 Thread Jorge Louis de Castro
Got it! Because 'menu' is a config option of the top level window's config but not of 'Frame', It's just a matter of calling self.master.config(menu=menu) Thanks j. >From: Kent Johnson <[EMAIL PROTECTED]> >To: Python Tutor >Subject: Re: [Tutor] Tkinter Menus >Date: Tue, 09 Aug 2005 07:39:35 -0

Re: [Tutor] Stuck: unicode in regular expressions

2005-08-09 Thread Kent Johnson
Ron Phillips wrote: > I am expecting users to cut-and-paste DMS data into an application — > like: +40 30 15 E40 15 34.56, -81 0 0, 81 57 34.27E, W 40° 13’ > 27.343”, 40° 13’ 27.343” S, 140° 13’ 27.343”S, S40° 13’ 27.34454, > 81:57:34.27E > > I've been able to write a regex that seems t

[Tutor] Stuck: unicode in regular expressions

2005-08-09 Thread Ron Phillips
I am expecting users to cut-and-paste DMS data into an application — like:  +40 30 15   E40 15 34.56, -81 0 0,   81 57 34.27E, W 40° 13’ 27.343”, 40° 13’ 27.343” S, 140° 13’ 27.343”S, S40° 13’ 27.34454,  81:57:34.27E    I've been able to write a regex that seems to work in redemo.py, but it doesn

Re: [Tutor] Tkinter Menus

2005-08-09 Thread Jorge Louis de Castro
Ah, sorry. Here is the definition of fCanvas: class LogAnalyzerGUI(Frame): def __init__(self, parent=0): Frame.__init__(self, parent) self.type = 2 self.terms = 0 self.master.title('XML Analyzer') self.buildUI() def buildUI(self): fCanvas = Frame(self) Label(fCanva

Re: [Tutor] PyChecker: Installing and or Using

2005-08-09 Thread Dick Moores
Kent Johnson wrote at 06:13 8/9/2005: >Dick Moores wrote: > > Win XP. Python2.4. > > > > Javier Ruere suggested getting PyChecker or PyLint. I found PyChecker > and > > put the pychecker-0.8.14 folder in > > C:\Python24\Lib\site-packages\PyChecker. I don't really know what I'm > > doing (obviously

[Tutor] Default class in module

2005-08-09 Thread Jan Eden
Hi, I'd like to pack some modules in a package. Each module contains a single class, which forces me to from Pythonsite.Show import Page page = Page() ... class Page(Site.DB): #class DB from module Site in package Pythonsite ... Is there a way to define a default class for a module whi

Re: [Tutor] Using urllib to retrieve info

2005-08-09 Thread David Holland
I had a look at urllib2 and I found this example :- import urllib2 # Create an OpenerDirector with support for Basic HTTP Authentication... auth_handler = urllib2.HTTPBasicAuthHandler() auth_handler.add_password('realm', 'host', 'username', 'password') opener = urllib2.build_opener(auth_handler) #

Re: [Tutor] Run a cmd program

2005-08-09 Thread Kent Johnson
oliver wrote: > On 8/9/05, Øyvind <[EMAIL PROTECTED]> wrote: > >>Thanks a lot. However, it didn't work. I got an error stating something >>along: "Is not recognized as an internal or external command, executable >>program or .. file" (I don't know how to translate the word . to >>english).

Re: [Tutor] PyChecker: Installing and or Using

2005-08-09 Thread Kent Johnson
Dick Moores wrote: > Win XP. Python2.4. > > Javier Ruere suggested getting PyChecker or PyLint. I found PyChecker and > put the pychecker-0.8.14 folder in > C:\Python24\Lib\site-packages\PyChecker. I don't really know what I'm > doing (obviously?), but I added > C:\Python24\Lib\site-packages\P

Re: [Tutor] Run a cmd program

2005-08-09 Thread oliver
On 8/9/05, Øyvind <[EMAIL PROTECTED]> wrote: > Thanks a lot. However, it didn't work. I got an error stating something > along: "Is not recognized as an internal or external command, executable > program or .. file" (I don't know how to translate the word . to > english). That looks like a

Re: [Tutor] Run a cmd program

2005-08-09 Thread Kent Johnson
Øyvind wrote: > Hello. > > I need to run a program > (http://www.microsoft.com/ntserver/nts/downloads/management/uptime/default.asp) > thru Python. It is normally run such as "uptime AUTO-SRV-001 /s > /d:04/01/2005" in the command prompt. Is it possible to run a already > compiled exe file in Pyth

Re: [Tutor] Run a cmd program

2005-08-09 Thread Øyvind
Thanks a lot. However, it didn't work. I got an error stating something along: "Is not recognized as an internal or external command, executable program or .. file" (I don't know how to translate the word . to english). But, when I looked in the manual about the commands module, I found th

Re: [Tutor] Use functions re avoid Re: Can the following algorithm be improved?

2005-08-09 Thread Roel Schroeven
Brian van den Broek wrote: > Say you go with your method of defining a deck (cards above) and then > making random choices from it. Try something like this (untested code): > > cards = ["Ace of ...",] # As above > cards_dealt = [] > def get_card(): > while True: > new_card = random

Re: [Tutor] Run a cmd program

2005-08-09 Thread Adam Bark
>>> import commands >>> commands.getoutput("uptime AUTO-SRV-001 /s /d:04/01/2005") that should do itOn 8/9/05, Øyvind <[EMAIL PROTECTED]> wrote: Hello.I need to run a program(http://www.microsoft.com/ntserver/nts/downloads/management/uptime/default.asp)thru Python. It is normally run such as "upti

Re: [Tutor] Curses example on Linux?

2005-08-09 Thread Hossein Movahhedian
Dear Alan Hi, First of all let me thank you very much for that excellent tutorial. As a Python beginner, I learned many things from that. As I have mentioned in my previous message to this list, in that example I had to replace "ky = msvcrt.getch()" with "ky = chr(msvcrt.getch())

[Tutor] PyChecker: Installing and or Using

2005-08-09 Thread Dick Moores
Win XP. Python2.4. Javier Ruere suggested getting PyChecker or PyLint. I found PyChecker and put the pychecker-0.8.14 folder in C:\Python24\Lib\site-packages\PyChecker. I don't really know what I'm doing (obviously?), but I added C:\Python24\Lib\site-packages\PyChecker\pychecker-0.8.14\pycheck

[Tutor] Run a cmd program

2005-08-09 Thread Øyvind
Hello. I need to run a program (http://www.microsoft.com/ntserver/nts/downloads/management/uptime/default.asp) thru Python. It is normally run such as "uptime AUTO-SRV-001 /s /d:04/01/2005" in the command prompt. Is it possible to run a already compiled exe file in Python and thereafter get the re

Re: [Tutor] Tkinter Menus

2005-08-09 Thread Kent Johnson
Jorge Louis De Castro wrote: > Hello, > > I'm having this issue with Tkinter. I have a frame with all my buttons, > checkboxes et al, and all is working fine. I want to add menus and added the > following to my frame (fCanvas) code: > > # create a toplevel menu > menu = Menu(fCanvas) >

Re: [Tutor] Using urllib to retrieve info

2005-08-09 Thread Kent Johnson
David Holland wrote: > Alan, > > Sorry of course that is the problem. These pages are > password protected > Is it possible to download password protected pages (I > know the password but I don't how to get the program > to use it). urllib2 supports basic and digest authentication. There a

Re: [Tutor] function won't import from module

2005-08-09 Thread Dick Moores
Alan G wrote at 03:22 8/9/2005: >>I tried deleting a mycalc.pyc that had been created and the problem >>cleared up! If I remember correctly, for a while I had moved mycalc.py >>to another folder in PYTHONPATH (I had recently learned how to modify >>PYTHONPATH in Win XP), and the .pyc was in this

Re: [Tutor] surprising len() results ???

2005-08-09 Thread Michael Janssen
On 8/9/05, Tom Cloyd <[EMAIL PROTECTED]> wrote: > print len('()ÄäÀÁàáÇçÈÉèéÌÍìíÑñÒÓòóÙÚúù') > print len('--AaAAaaCcEEeeIIiiNnOOooUUuu') > > the result: > > 54 > 28 > > I'm completely mystified by this. All of it. None of it makes sense. This > program was working fine. Now it doesn't. And those

Re: [Tutor] function won't import from module

2005-08-09 Thread Alan G
> I tried deleting a mycalc.pyc that had been created and the problem > cleared up! If I remember correctly, for a while I had moved > mycalc.py to another folder in PYTHONPATH (I had recently learned > how to modify PYTHONPATH in Win XP), and the .pyc was in this > folder. Sorry I don't rememb

[Tutor] Tkinter Menus

2005-08-09 Thread Jorge Louis De Castro
Hello, I'm having this issue with Tkinter. I have a frame with all my buttons, checkboxes et al, and all is working fine. I want to add menus and added the following to my frame (fCanvas) code: # create a toplevel menu menu = Menu(fCanvas) fCanvas.config(menu=menu) # create a pu

Re: [Tutor] function won't import from module

2005-08-09 Thread Dick Moores
Alan G wrote at 00:42 8/9/2005: >Dick, > >I can't see a problem but I notice an inconsistency below: > >>#testof_cmpSeq.py >>import mycalc > >>which produces: >> >>Traceback (most recent call last): >> File "C:\Python24\MyScripts\testof_cmpSeq.py", line 1, in -toplevel- >> from mycalc import

[Tutor] surprising len() results ???

2005-08-09 Thread Tom Cloyd
List, I'm running a program I wrote which I've run a number of times before, successfully. I use the following statement to fix the problem of utf-8 codes which blow up a later part of my production process that I cannot fix: trans_table = maketrans('()ÄäÀÁàáÇçÈÉèéÌÍìíÑñÒÓòóÙÚúù','--AaAAaa

Re: [Tutor] Curses example on Linux?

2005-08-09 Thread Hossein Movahhedian
Dear Danny Hi, Many thanks for your help and especially the references in your reply. Now the code works fine. BTW, I had to replace "ky = msvcrt.getch()" with "ky = chr(msvcrt.getch())". Regards, Hossein On Mon, 8 Aug 2005, Danny Yoo <[EMAIL PROTECTED]> wrote: > > > On Mon, 8 Aug

Re: [Tutor] Using urllib to retrieve info

2005-08-09 Thread Alan G
> Sorry of course that is the problem. These pages are > password protected > Is it possible to download password protected pages (I > know the password but I don't how to get the program > to use it). That will depend on how the protection is implemented. If your server is a J2EE box with

Re: [Tutor] Using urllib to retrieve info

2005-08-09 Thread David Holland
Alan, Sorry of course that is the problem. These pages are password protected Is it possible to download password protected pages (I know the password but I don't how to get the program to use it). David --- Alan G <[EMAIL PROTECTED]> wrote: > > It runs fine but the file saved to disk is

Re: [Tutor] help

2005-08-09 Thread Alan G
Hi Dan, I think you need to back up a little and build the program piece by piece. > i am making a simple script to get the hang of Tkinter. The script is quite complex for a starter. You could focus down on just a single control initially, the area button. Get that to pop up the dialog and

Re: [Tutor] function won't import from module

2005-08-09 Thread Alan G
Dick, I can't see a problem but I notice an inconsistency below: > #testof_cmpSeq.py > import mycalc > which produces: > > Traceback (most recent call last): > File "C:\Python24\MyScripts\testof_cmpSeq.py", line 1, > in -toplevel- > from mycalc import cmpSeq > ImportError: cannot import n

Re: [Tutor] Curses example on Linux?

2005-08-09 Thread Alan G
>>I have copied the following example from "Learning to Program by >> Alan >> Gauld (section: Event Driven Programming)". To run it on Linux >> (Redhat 8.0; Python 2.4) the tutorial says to replace 'msvcrt' >> with 'curses.stdscr'. I thought I'd fixed that fault. The sequence should be: