Re: [Tutor] Python Logo
On Tue, Mar 24, 2009 at 6:26 PM, wrote: > http://img99.imageshack.us/img99/5422/webpy.png That is the logo for web.py (a Python web framework), not for the Python language itself. http://luke.jottit.com/webpy_logo Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Difference between SimpleCookie and SmartCookie
On Wed, Mar 25, 2009 at 12:35 AM, Kumar wrote: > Thanks a lot for the reply Kent . > Could you please tell me If I will try to move from SmartCookie to > SimpleCokkie in out application, what precautions should I take care? Make sure that all the values in the Morsels are strings. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] problem of windmill on ssl website
I have problem using windmill with a ssl website (https). The console output of looks like this: windmill ie https://www.example.org https://www.example.org is not a windmill argument. Sticking in functest registry. Server running... The browser does not go to the website, showing a tutor page instead. How can I resolve this? Warmest Regards, Coco___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Question about Python.
Hi. I'm working on Paper, Rock, Scissors in Python. I need to make it a loop, and test the values (1, 2, 3, /Rock/Paper/Scissors) yet, but i'm kind of stuck. Could you help me? import random #Imports the random modual from the library. def main(): #First function. print 'Lets play Paper Rock Scissors!\n' print '1 For Rock\n2 For Paper\n3 For Scissors\n4 To Quit' number=raw_input ('What do you choose? ') #Gets users input. pc = ComputerChoice() PlayerChoice(number, pc) def ComputerChoice(): #Compuers function ComputerChoice = random.randrange(1, 4) #Computers random range. return ComputerChoice def PlayerChoice(number, CC): #Uses the users input & compares number = int(number) #With the computers. print "\n" if CC == 1 and number == 3: print 'Computer wins: Rock beats Scissors' elif CC == 1 and number == 2: print 'Player wins: Paper beats Rock' elif CC == 2 and number == 3: print 'Player wins: Scissors beat paper' elif CC == 3 and number == 1: print 'Player wins: Rock beats scissors' elif CC == 2 and number == 1: print 'Computer wins: Paper beats rock' elif CC == number: print '''Draw!''' #Trying it with 3 elif CC == 3 and number == 2: print 'Computer wins: Scissors beats rock' elif number == 4: print 'Goodbye' else: print CC print number if number != 4: print '\n' main() #Start of program main() _ Windows Live™ SkyDrive: Get 25 GB of free online storage. http://windowslive.com/online/skydrive?ocid=TXT_TAGLM_WL_skydrive_032009___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Question about Python.
T wrote: Hi. I'm working on Paper, Rock, Scissors in Python. I need to make it a loop, and test the values (1, 2, 3, /Rock/Paper/Scissors) yet, but i'm kind of stuck. Could you help me? import random #Imports the random modual from the library. def main(): #First function. print 'Lets play Paper Rock Scissors!\n' print '1 For Rock\n2 For Paper\n3 For Scissors\n4 To Quit' number=raw_input ('What do you choose? ') #Gets users input. pc = ComputerChoice() PlayerChoice(number, pc) def ComputerChoice(): #Compuers function ComputerChoice = random.randrange(1, 4) #Computers random range. return ComputerChoice def PlayerChoice(number, CC): #Uses the users input & compares In ComputerChoice(), you obtain the choice of the computer. In PlayerChoice() however, you do not obtain the player choice, but instead decide on the result. I would suggest to modify PlayerChoice() to just obtain the player choice (code which you now have in main()). Next write a new function that takes the computer choice and the player choice, and decides on the outcome. (that function should have 3 possible return values). Then in the main loop combine all three functions. The construct you should investigate seems the 'while' statement. (while the game is not decided, call the functions) Sincerely, Albert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Question about Python.
"T" wrote I'm working on Paper, Rock, Scissors in Python. I need to make it a loop, and test the values (1, 2, 3, /Rock/Paper/Scissors) yet, but i'm kind of stuck. Could you help me? What exactly puzzles you? You know you need a loop so you presumably realize that you need to repeat some part of your program. What bit needs to be repeated? Is it the bit that you ask the platyer to choose a value? Or where the computer calculates a value? Or where you work out the result? Or all of these? And how many times, or until what condition, should it repeat? How will you detect that value? If you answer those questions you might start to see what needs to be done? There are a few commens on the code below: def main(): #First function. print 'Lets play Paper Rock Scissors!\n' print '1 For Rock\n2 For Paper\n3 For Scissors\n4 To Quit' number=raw_input ('What do you choose? ') #Gets users input. number sems a bit vague, this is actually the players choice. So call it PlayersChoice or some such descriptive name. Even just pc maybe - see below... pc = ComputerChoice() And pc seems an odd name to choose for ComputersChoice() Why not cc? PlayerChoice(number, pc) And this function doesn't actually return the players choice, it displays the result. So maybe DisplayResult wouldbe a better name? def ComputerChoice(): #Compuers function ComputerChoice = random.randrange(1, 4) #Computers random range. return ComputerChoice Its not a good idea to use a variable name the same as the function. This will prevent you using recursion (which you might not know about yet but is important later!) You could simply use 'choice', its shorter to type too! def PlayerChoice(number, CC): #Uses the users input & compares number = int(number) #With the computers. Its probably better to convert the number where you read it from the user - that way you can tell them they made a mistake and get a better response before you call this function. And the function can just expect a number as input. print "\n" if CC == 1 and number == 3: print 'Computer wins: Rock beats Scissors' elif CC == 1 and number == 2: print 'Player wins: Paper beats Rock' elif CC == 2 and number == 3: print 'Player wins: Scissors beat paper' elif CC == 3 and number == 1: print 'Player wins: Rock beats scissors' elif CC == 2 and number == 1: print 'Computer wins: Paper beats rock' elif CC == number: print '''Draw!''' #Trying it with 3 elif CC == 3 and number == 2: print 'Computer wins: Scissors beats rock' elif number == 4: print 'Goodbye' OK, This is stuff you probably want to take out and put beside the code for reading the user input. Its not really part of the game. In fact this might be what you use to terminate your loop? else: print CC print number if number != 4: print '\n' main() Looks like you discovered recursion already, although I suspect you don't know it yet? :-) #Start of program main() HTH, -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/l2p/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] problem of windmill on ssl website
"Coco Yeh" wrote I have problem using windmill with a ssl website (https). The browser does not go to the website, showing a tutor page instead. How can I resolve this? My initial response was to say "ask on a windmill list," but, not having heard of windmill, I googled and discovered that this is a Python package on the Wiki. Although it is still in Beta. I think my initial response is probably still right, its a bit off mainstream for the tutor list. But somebody might be using it, you never know. http://www.getwindmill.com/documentation/mailing-lists Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Logo
On Wednesday 25 March 2009, you wrote: > On Tue, Mar 24, 2009 at 6:26 PM, wrote: > > http://img99.imageshack.us/img99/5422/webpy.png > > That is the logo for web.py (a Python web framework), not for the > Python language itself. > http://luke.jottit.com/webpy_logo All the same, I was glad to see it. I never knew about webpy, and now I do. Have found django and turbogears way too big for me. Now I will check out webpy. thanks to all tim ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Using C in python
what are the ways in which i can use C in python programs . I know there is SWIG bindings are there any other . Also Could anyone explain how Swig bindings work? -- A-M-I-T S|S ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Using C in python
On Wed, Mar 25, 2009 at 5:13 PM, amit sethi wrote: > what are the ways in which i can use C in python programs . I know there is > SWIG bindings are there any other . Also Could anyone explain how Swig > bindings work? There are quite a few options: SIP, SWIG and ctypes (in the std lib) build wrappers for C libraries. http://www.scipy.org/Weave lets you include C++ in a Python module. boost::python wraps C++ libraries. Pyrex and Cython compile Python-like source code to C extensions. I haven't used any of these and can't tell you much about them. Google will get you more info. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Using C in python
There's a section in the Python docs just on this topic: http://docs.python.org/extending/index.html There's probably also some stuff in the wiki, although I'm not familiar with anything specific: http://wiki.python.org/moin/ The SWIG documentation is extensive, and while not the user-friendliest, should get you started: http://www.swig.org/doc.html The quick intro to SWIG is that you create and "interface file" which defines how Python interfaces to your C code. In the braindead simple cases, this can be simply the header files with your function prototypes. In actual usage, it's a good deal more complicated, but the SWIG docs show you the way. Cheers On Wednesday 25 March 2009 16:13, amit sethi wrote: > what are the ways in which i can use C in python programs . I know there is > SWIG bindings are there any other . Also Could anyone explain how Swig > bindings work? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Using C in python
amit sethi wrote: > what are the ways in which i can use C in python programs . Here is a short example that uses Cython to call a couple of C functions in OpenGL and libc ("math.h"). The functions are declared in the "cdef extern" blocks at the top. http://misc.slowchop.com/misc/browser/muckaround/cython-game-optimise-tutorial/fast_circles.pyx See: http://cython.org/ Stefan ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Using C in python
"amit sethi" wrote what are the ways in which i can use C in python programs . You can't use C directly what you can do is access libraries written in C. In fact quite a few of the standard libraries are written that way. So it depends what you want to do. If you have C source code that you want to execute from Python you can either:: a) Build a library and create a Python wrapper so it looks like a module b) Build an executable file and call that using subprocess/popen etc c) If its one of the common C libraries or a Windows DLL you can probably use an existing framework to call it. For example ctypes will access a lot of stuff. If you want to execute Python code from a C program, you can do that too, but it doesn't sound like thats what you need? SWIG bindings are there any other . Also Could anyone explain how Swig bindings work? SWIG bindings just expose C code in the right format for Python to see the code as a Python module. Its slightly easier than doing it by hand in C because it automates what is a pretty brain dead repetitive process. ( I've only used SWIG with Tcl but I assume its a similar process for Python.) HTH, -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Posting to Tkinter NG in new.gmane.org
Title: Signature.html I'm not having any luck posting to Subject. I keep getting a message from Moz/SeaMonkey that says "The message could not be moved or copied to the folder "Drafts" because writing to the folder failed. To gain disk space, from the File menu, ...Empty Trash folder, then choose Compact Folders, ... My e-mail address is valid. Any ideas? I've compacted related Trash folders, etc -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor