Re: [Tutor] using a function as a dictionary value?

2004-12-13 Thread Liam Clarke
Hey Justin, Tricky one this.. as far as I know, and I'm a beginner myself, a dictionary stores a reference to the function, not the actual function. So - > command = {'1': spam(), > '2': breakfast(), > '3': bridgekeeper() > } Try this instead - command =

Re: [Tutor] Difference between for i in range(len(object)) andfor i in object

2004-12-13 Thread Liam Clarke
Good luck trying to find a decent Python book for beginners. I haven't been able to source Alan Gauld's book yet, (I'm saving for Amazon's shipping... I live in the Antipodes.), but afaik that's about the best one out, if his online tutorial (which I highly recommend Kumar, link at end.) is indic

[Tutor] using a function as a dictionary value?

2004-12-13 Thread justinstraube
When I run this, regardless of which option I select all three functions are called. Is there a way I can do this where only the option selcted is called? Im using 2.3.3 if that matters any. Thanks. # def spam(): print 'Hello world' def breakfast(): print 'Spam, Spam, Chips, and Spa

Re: [Tutor] using a function as a dictionary value?

2004-12-13 Thread Kent Johnson
Liam Clarke wrote: Hey Justin, Tricky one this.. as far as I know, and I'm a beginner myself, a dictionary stores a reference to the function, not the actual function. Yes. In fact this is a good way to think about all variables in Python. A variable stores a reference to a value, not the value it

Re: [Tutor] OT?: how to google just the 2.4 tutorial?

2004-12-13 Thread Alan Gauld
> I know how to limit google search results to a single site, but is it > possible to google just one section of a site? Can't speak for Google but... > I'd like to be able to search just the 2.4 tutorial, > http://www.python.org/doc/2.4/tut/tut.html > Possible? And if so, how to? Have you trie

Re: [Tutor] listing all combinations of elements of a list

2004-12-13 Thread Alan Gauld
> def combination(items) > list = [] > for i in range(0,len(items)): >for j in range(0,len(items)): for i in items: for j in items: Is both shorter and faster - no len() function calls. Or if you want to use indices: size = len(items) # only calculate once, it won

[Tutor] Re: [ANN] RUR: a Python Learning Environment (alpha)

2004-12-13 Thread André Roberge
This looks like a very nice effort -- I am trying to get it running, since I am working with some other newbies to learn more Python. I wish there were a link from http://rur-ple.sourceforge.net/index.html to the download page! I will fix that; thanks. And I am not sure which of the downloaded f

[Tutor] Problems with unsigned integers

2004-12-13 Thread Loptr Chaote
Hello everyone! I'm having problems with signed/unsigned (32bit) integers in python. Example code: seq = 0L seq = socket.ntohl(struct.unpack("L", data[38:42])[0]) print seq This sometimes produces a negative output, how is that possible since I booth initialized seq with "0L" and also spe

Re: [Tutor] Problems with unsigned integers

2004-12-13 Thread Loptr Chaote
On Mon, 13 Dec 2004 12:43:17 -0500, QoD SEC <[EMAIL PROTECTED]> wrote: > I do not believe that python has anything like signed and unsigned > integers. The 'L' after an integer makes the number a type long (which > is not the same as C's long). Also in your code you do this seq = > socket.ntohl(str

[Tutor] Re: [ANN] RUR: a Python Learning Environment (alpha)

2004-12-13 Thread Ron Phillips
Can't get it running -- it keeps saying:   Traceback (most recent call last):  File "C:/source/RUR/RURmain.py", line 28, in ?    messenger.loadImages()    # load them up here after initialising Handlers  File "C:\source\RUR\messenger.py", line 27, in loadImages    HIT_WALL_IMAGE = wxImage('

Re: [Tutor] using a function as a dictionary value?

2004-12-13 Thread justinstraube
Thanks Liam and Kent! Regards, Justin On Mon, 13 Dec 2004 07:57:45 -0500, you wrote: > >Liam Clarke wrote: >> Hey Justin, >> >> Tricky one this.. >> >> as far as I know, and I'm a beginner myself, a dictionary stores a >> reference to the function, not the actual function. > >Yes. In fact this i

Re: [Tutor] Problems with unsigned integers

2004-12-13 Thread Kent Johnson
It seems that ntohl doesn't understand about unsigned values, at least on Win32: Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from struct import pack, unpack >>> pack('L', -1) '\xff\xff\xff\xf

Re: [Tutor] Problems with unsigned integers

2004-12-13 Thread Loptr Chaote
On Mon, 13 Dec 2004 13:27:25 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote: > It seems that ntohl doesn't understand about unsigned values, at least on > Win32: > Wow, I've never actually considered using the interpreter/CLI like that. Thank you! I'm writing my own u_ntohl() now which checks to

[Tutor] Re: [ANN] RUR: a Python Learning Environment (alpha)

2004-12-13 Thread André Roberge
This is weird (to me, anyways) as it works well on my computer. However, I remember that I had to create "loadImages()" to initialize the handlers early on, otherwise it was complaining that it couldn't "ConvertToBitmap". I'll have to see if I can move this statement elsewhere; I will reply private

Re: [Tutor] cgi with system calls

2004-12-13 Thread Kent Johnson
Nik wrote: hi, I'm trying to write a python cgi script that can control certain processes on my server, but I'm having some trouble. The script is; #!/usr/bin/python import cgitb; cgitb.enable() print "Content-type: text/plain\n\n" You may need explicit \r\n here, I'm not sure: print "Content-typ

[Tutor] Opening and reading .cvs files in Python

2004-12-13 Thread Johan Geldenhuys
Hi, I want to find out how to open a .cvs file on a remote Windows machine and get file to my local linux folder. Any help would be appreciated. --    Johan -- This E-Mail has been scanned Enjoy your day ___ Tutor maillist - [EMAIL

Re: [Tutor] cgi with system calls

2004-12-13 Thread Nik
no luck I'm afraid. Also, to make it even more annoying, omitting the os call and going for #!/usr/bin/python import cgitb; cgitb.enable() print "Content-type: text/plain\n\n" import os status = """PID TTY TIME CMD 3649 pts0 00:00:00 su 3652 pts0 00:00:00 bash 5197 pts0 00:00

[Tutor] Re: [ANN] RUR: a Python Learning Environment (alpha)

2004-12-13 Thread Ron Phillips
This looks like a very nice effort -- I am trying to get it running, since I am working with some other newbies to learn more Python.   I wish there were a link from http://rur-ple.sourceforge.net/index.html to the download page! And I am not sure which of the downloaded files to run. I thou

[Tutor] Non-escaped utf-8 rendering in the interactive shell under XP?

2004-12-13 Thread Patrick Hall
Hi folks, Being a Linux guy, I don't know my way around Windows software too well. I've been trying to help some friends learn a bit of Python, and they use OSX and XP. OSX is close enough to Linux that I've not run into many barriers, but I'm having a specific problem with the XP users: Is ther

[Tutor] Re: How to launch multiple processes from script?

2004-12-13 Thread Andrey Ivanov
> I'm working my way through the sockets module. To test my simple > server and clients, I'd like a way to launch the server and multiple > clients from one script or batch file,all running simultaneously. Each > server/client should run as it's own process and have a console > window. I've briefl