Re: [Tutor] Python 2.7 on Ubuntu 11.10 - Do not unintall
On Wed, Nov 2, 2011 at 11:39 AM, Prasad, Ramit wrote: > >I use OS X / Windows and I have not noticed any dependency issues. So I > was not aware about the same with respect to Ubuntu. I am glad that I > learnt something from this discussion. > > I might be wrong, but Ubuntu itself is not dependent on Python. You can > probably run a minimalist headless Ubuntu server without Python. Especially > since the OP seemed able to login to his machine without it. X/Desktop > requires it. > > Ubuntu is not dependent on Python, but the environments (Unity, GNOME, etc) will brake if you don't have Python. > I am not sure if OS X needs it, but I do know it comes with Python > installed. > > Joel M: Pretty much the only things that require restarting (from my > experience with Debian) are kernel changes and hardware changes. You just > had to restart X / login manager (gdm). > > Yea I know, but I restarted anyhow. > Ramit > > > Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology > 712 Main Street | Houston, TX 77002 > work phone: 713 - 216 - 5423 > > -- > > This email is confidential and subject to important disclaimers and > conditions including on offers for the purchase or sale of > securities, accuracy and completeness of information, viruses, > confidentiality, legal privilege, and legal entity disclaimers, > available at http://www.jpmorgan.com/pages/disclosures/email. > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] login window using Tk
I am also intrested in this topic. Chris were you thinking of using the window.hide() method? -Joel M On Nov 1, 2011 1:21 PM, "Chris Hare" wrote: > > I am working on a python Tk program which involves a login window and I am > looking for some advice. > > Currently the code I have creates a window (Toplevel) where the login > controls are and I am running that using a main loop for the window. The > root window is hidden. The objective is that when the user ha successfully > authenticated, the login window is closed or the main loop os exited and > then the root window is shown and the main loop started for the actual > application. > > Questions: > 1. Is this the best way of doing this or is there a better way? > 2. How do I exit the main loop when the user has authenticated? > > Thanks > > Chris Hare > ch...@labr.net > http://www.labr.net > > > > Chris Hare > ch...@labr.net > http://www.labr.net > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly
On Mon, Oct 31, 2011 at 1:09 PM, Joel Montes de Oca wrote: > On Mon 31 Oct 2011 12:14:40 PM EDT, Hugo Arts wrote: > > > On Mon, Oct 31, 2011 at 4:41 PM, Joel Montes de Oca > wrote: > > > Hello everyone, > > I am having a little trouble with a block of code that isn't behaving the > way I would expect. Maybe you can give me a hand and point where it is > going > wrong. > > The function that is not working correctly belongs to a Paper Rock Scissor > game I am making. > > This particular function is responsible to: > a) Get the user's choice (Paper, Rock, or Scissors) > b) Return the user's choice within the variable choice to the function > that called it. > > The function works correctly as long as the user does not try to enter a > string other than 'P', 'R', or 'S'. > > Logic: > Take the user's string and put it in the variable choice. > If choice is not 'P', 'R', or 'S' then pass a message to the user and > call the function again. > If the choice is 'P', 'R', or 'S' then return choice to where it was > called from. > > The problem is this. > > When the user enters a string other than the valid ones, the if statements > catches it and calls the same function again so the user can enter a valid > string. But the variable choice does not get assigned the new string > entered > by the user, instead it is empty. > > I would expect if the function runs again, the variable choice would be > updated to the last value given by the user. > > The function: ( http://dpaste.com/644857/) > > def UserChoice (): # The function that returns the choice from the user > print 'Please select (P) for paper, (R) for Rock, or (S) for Scissors.' > choice = raw_input('What is your selection?: ') > > if choice.lower() not in ('p', 'r','s'): # Converts the user's choice to > lowercase and confirms the choice is valid > print 'I am sorry, you entered \'' + choice.upper() + '\' which is an > invalid response. Please try again.' > raw_input('Press Enter to try again.') > UserChoice () # If the choice is not valid, run the function over > else: > return choice > > > > Your problem is that you don't quite understand recursion. > > When a function calls itself, it's not actually any different from > when a function A calls another function B. Once function B is done > running and returns, control goes back to function A. It doesn't > matter if function B is actually the same function as A. In fact, even > if A and B are the same function, they don't "share" any variables and > are totally separate as if they were two different functions that just > happened to do the same thing. > > So, how does this apply to your function? Let's go through a run of > it. We call UserChoice (this is function A) and we input a wrong > letter. So, A calls UserChoice again (this is function B), and this > time we input something valid. So, function B runs the line "return > choice." > > Control now returns to function A, right at the point where we called > function B. So what do we do here with the choice that was just > returned from function B? Well, looking at the line where it's called, > it's just "UserChoice()". So we do nothing. We just throw it away. > Then, we continue on with function A, move out of the if statement, > and "fall off the end" of the function. And when that happens, Python > returns None from function A to show you that nothing was returned. > > If you understood all that, you should be able to fix your problem. > > Hugo > > > Hey Hugo, > > I think I understand your explanation. Let me see if I get it. > > The code: > > def UserChoice (): *# I WILL CALL THIS FUNCTION A* > > > print 'Please select (P) for paper, (R) for Rock, or (S) for Scissors.' > choice = raw_input('What is your selection?: ') > > if choice.lower() not in ('p', 'r','s'): > > print 'I am sorry, you entered \'' + choice.upper() + '\' which is an > invalid response. Please try again.' > raw_input('Press Enter to try again.') > > UserChoice () *# I WILL CALL THIS FUNCTION B* > else: > return choice *# I WILL CALL THE ORIGINAL CALLING FUNCTION, FUNCTION > MAIN* > > > OK so when the user uses a valid letter, the variable choice gets > returned to FUNCTION MAIN. Everything works fine. > > When the user e
Re: [Tutor] Method to create small and simple database
On Sat, Oct 29, 2011 at 6:58 PM, Alan Gauld wrote: > On 29/10/11 19:28, Joel Montes de Oca wrote: > > After looking at the Python module documentation for sqlite3 >> (http://docs.python.org/**library/sqlite3.html#module-**sqlite3<http://docs.python.org/library/sqlite3.html#module-sqlite3>), >> it seems >> to me it's the best way to make the small database that I am looking for. >> > > SQLlite is a great way to build small scale SQL databases. > However for this app I'd probably second the advice to use shelve. > Shelve acts like a dictionary in a file so you can associate a list of > items with a user very very easily. > > > > Now I need to look for a basic tutorial on constructing a simple >> database (tables, rows, keys) and how to connect all that stuff >> together. If anyone happens to know of a good intro tutorial or >> documentation to database concepts, please forward it to me. >> > > You can try the database topic in my tutorial(see below). > It's only available for Python v2 at present but the translation > to Python v3 (if that's what you are using) is trivial. > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > > > __**_ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor> > I will take a look into Shelve and Alan's tutorial sometime this coming week. Keep the suggestions coming if there's more. :) -Joel M. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor