Re: [Tutor] Suggestions about documenting a function

2006-10-30 Thread Luke Paireepinart
i=i+1 > return rndlist It doesn't seem like this code does what it should, does it? I mean, if you did randomList(9,9,9) wouldn't it go into an infinite loop? And why does the length have to be greater than n2? that doesn't make sense. What if I want to

Re: [Tutor] Using sys.exit()

2006-11-01 Thread Luke Paireepinart
Dick Moores wrote: > At 03:56 PM 11/1/2006, Andreas Kostyrka wrote: > >> Am Mittwoch, den 01.11.2006, 15:43 -0800 schrieb Dick Moores: >> >>> At 12:14 AM 10/31/2006, Alan Gauld wrote: >>> >>> "Dick Moores" <[EMAIL PROTECTED]> wrote > I'd like to know how to use

Re: [Tutor] Using sys.exit()

2006-11-02 Thread Luke Paireepinart
you want to? Remember, Python expects that the developer will be responsible. It won't keep you from shooting yourself in the foot. So try to raise reasonable exceptions. I think SystemExit may have some extra magic, and it's not just a normal exception, but I'm not sure about this. Someone else know? HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Need to be taught a trick or two about printing in neat columns

2006-11-02 Thread Luke Paireepinart
= len(astr) while x < width: astr += ' ' x += 1 HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Performing arithmetic operations with date

2006-11-02 Thread Luke Paireepinart
xamples on usage. The second link down is http://docs.python.org/lib/module-datetime.html which is the module definition from Python.org. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Print Screen

2006-11-02 Thread Luke Paireepinart
Chris Hengge wrote: > I posted this in a similar thread a few days ago, and no replies so I > think it needs its own listing. > > Anyone know of a way to capture special keys like "Print Screen"? > I have a small script to grab all they keycodes, but it doesn't seem > to catch several keys on the

Re: [Tutor] Print Screen

2006-11-02 Thread Luke Paireepinart
Chris Hengge wrote: > Because I dont know any other way to capture the screen? (In my mind > using print screen would be universal) =P The print screen button doesn't do anything. It generates a keycode just like any other button on the keyboard. Windows captures this keypress and interprets it as

Re: [Tutor] Print Screen

2006-11-02 Thread Luke Paireepinart
Chris Hengge wrote: > Awesome! Thanks again Luke > > How do I capture the keycode for print screen? (now I'm just curious, > because like I said, I've got a script that grabs all but maybe half a > dozen keys) Well, how are you doing it now? That's the importa

Re: [Tutor] Print Screen

2006-11-02 Thread Luke Paireepinart
e keypresses, but they'd also still be sent to the e-mail program. Actually, I've never tried it, but I'm pretty sure that's how the GUI packages' key capturing works. You may be asking 'well, it sounds like pyHook does a better job of this anyway!' Ye

Re: [Tutor] How to capture 'Ctrl+c' in Python

2006-11-02 Thread Luke Paireepinart
Chris Hengge wrote: > I've got your code at home, and I know it picks up shift and ctrl > modified items, but it wont register print screen (among a few > others). I can post the code I have at home later if you want to > verify it. I've been given a few methods to try in my other thread I > ju

Re: [Tutor] Print Screen

2006-11-03 Thread Luke Paireepinart
Chris Hengge wrote: > Wow.. I have visions of writing a little wanna-be VNC client/server > now using the ImageGrab.grab() =D > This ImageGrab trick does exactly what I wanted. Thanks for the tip! > > Actually, I want to write a little package for the learning experience > sometime over the holid

Re: [Tutor] question about classes and atributes

2006-11-03 Thread Luke Paireepinart
everything else is as well. And when I execute the code, Python knows how to do all of these things. You see, an interpreted session is not the same as you think of 'at run time' being. For the most part, an interpreted session is exactly the same as if I were to type the code

Re: [Tutor] Print Screen

2006-11-04 Thread Luke Paireepinart
rab trick does exactly what I wanted. Thanks for the tip!>> Actually, I want to write a little package for the learning experience> sometime over the holidays (plus I use VNC fairly often), but I can't > find any direction, or any already made packages for python for the VNC>

Re: [Tutor] Encoding and XML troubles

2006-11-04 Thread Luke Paireepinart
Inputting XML into a Python program has nothing to do with what encoding the python source is in.So it seems to me that that particular PEP doesn't apply in this case at all.I'm guessing that the ElementTree module has an option to use Unicode input. ___

Re: [Tutor] (OT) Flame wars

2006-11-06 Thread Luke Paireepinart
llo, World!")) It's like the string example above. It's a waste to have the function definition on two lines, and the call on another line, if the function's compact enough to fit on a single line using lambda. But also note that you can't reuse the lambda function unl

Re: [Tutor] First real script

2006-11-06 Thread Luke Paireepinart
s example, Carlos: >>> aList = [1,2,3,4,5,6] >>> a,b,c = aList[1:4] >>> a 2 >>> b 3 >>> c 4 HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] First real script

2006-11-07 Thread Luke Paireepinart
< A_Len-1: > z = A_List[i+1] > > else: > z = A_List[0] Can just become x,y,z = A_List[i-1:i+1] + [A_List[(i+1) % A_Len]] Though it's slightly less readable, it's also a bit shorter :) Alternately,

Re: [Tutor] Unable to run a simple client server code in in SOAPpy... Help me

2006-11-08 Thread Luke Paireepinart
Asrarahmed Kadri wrote: > > > > socket.error: (10061, 'Connection refused') Sounds like your firewall is blocking communication on this port. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Please help to resolve this...

2006-11-08 Thread Luke Paireepinart
es people and makes it less likely for you to get an answer. People may completely disregard this question now, just as a matter of principle, so that they don't give you the idea that reposting is appreciated. Not mad or anything, just informing you. HTH, -Luke ___

Re: [Tutor] Questions about PIL

2006-11-08 Thread Luke Paireepinart
is equivalent to ImageGrab.grab((0,0,200,200)) In other words, the ImageGrab always takes a screenshot of the entire working area. so if you're expecting this bounding-box to speed anything up, it won't. HTH, -Luke > Thanks! > -

Re: [Tutor] Questions about PIL

2006-11-08 Thread Luke Paireepinart
Chris Hengge wrote: > alist = difference(image1,image2) > a = [b for b in alist.getdata() if b != (0,0,0)] > if len(a) != 0: >print "Not the same" > > is much slower then (9x) > > if im1.tostring() != im2.tostring() >print "something changed!" > > This loop itself is fairly slow by itse

Re: [Tutor] Questions about PIL

2006-11-08 Thread Luke Paireepinart
Chris Hengge wrote: > Thanks for the detailed examples again Luke. Sorry I wasn't more clear > with my implimentation. The loop I was refering to was the one in the > start of my post but using im.tostring() instead. I saw an example to > make a webcam motion detector that use

Re: [Tutor] Drawing simple graphics objects

2006-11-09 Thread Luke Paireepinart
f the game? This graphics library is written in TKinter. I would be using pygame instead for these problems. The stuff I've seen so far, drawing rects, etc. has nothing to do with TKInter and wxpython. Those libraries are for making e-mail clients, web browsers, and stu

Re: [Tutor] Questions about PIL

2006-11-09 Thread Luke Paireepinart
Chris Hengge wrote: > What I want to do with the data shouldn't really matter. I'm not > completely sure what I want to do with the image data anyways, but for > sake of arguement everything is happening in memory at this point, so > 'objects' is correct. Images start in memory, and are being ev

Re: [Tutor] Questions about PIL

2006-11-09 Thread Luke Paireepinart
Chris Hengge wrote: > Yes, I understand what a loop is, and there was a loop but I didn't > write that code into my email because I didn't need commenting on it. > Here is the code so its clear incase you really care =P Just because you don't need commenting on it doesn't mean it's not relevant. E

Re: [Tutor] Looking for some constructive peer review.

2006-11-09 Thread Luke Paireepinart
Chris Hengge wrote: > I write this little IM style client the other night based on some > sample socket and threading examples I found plus a little of my own > twist just to make it more interesting.. > I'd like some constructive peer review just to help me make sure I'm > doing this correctly

Re: [Tutor] First realscript + Game of Life

2006-11-09 Thread Luke Paireepinart
o add reply-munging so replies only go straight to the whole list like on Pygame. Otherwise, I use reply-all so I don't have to type in 'tutor@python.org' every time. The side effect of other people getting the e-mails is generally not too annoying, because the list is s

Re: [Tutor] pygame rpg

2006-11-09 Thread Luke Paireepinart
federico ramirez wrote: > Hi! im trying to make a rpg game with pygame, of ocurse i will first > to try make simpler games, anyways, i could not find any good > tutorial, example, article, not anything about making a rpg with > pygame and the documentations is pretty poor... only some tutorials

Re: [Tutor] pygame rpg

2006-11-09 Thread Luke Paireepinart
a 'google it.' but you never know, and if you must try, I can do nothing to stop you :). -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] First realscript + Game of Life

2006-11-10 Thread Luke Paireepinart
http://en.wikipedia.org/wiki/Information_hiding>), both of which can make complex programs easier to understand.' Not sure what exactly a module is (I get it confused with packages) in Python. Perhaps someone can help here? >> 89+11 = 100, which is longer than the list. >>

Re: [Tutor] __init__.py for running a file from commandline?

2006-11-10 Thread Luke Paireepinart
Marcus Goldfish wrote: > Hoping someone can help with this... > > I have a logical python namespace using a directory tree and > __init__.py files. For example, PYTHONPATH points to ~pyroot, and I > have the following: > > ~pyroot/ > ~pyroot/utils/ > ~pyroot/utils/commands/mygrep.py > > Which ma

Re: [Tutor] Second attempt convert DateTimeTyep to datetime.datetime

2006-11-10 Thread Luke Paireepinart
johnf wrote: > Hi, > > I'm using FreeTDS (MS SQL database access lib) and for datetime fields it > returns a type 'DateTimeType'. I need it in type 'datetime.datetime'. There > is very little in the form of a tutorial that explains what I need to do. > if a datetimetype object has a __str_

Re: [Tutor] winsound mac

2006-11-10 Thread Luke Paireepinart
> Finally, does pygame exist for Macs? If so it has > some sound features. > yep, yep. Pygame has mac support. You can use numeric arrays to generate various different sounds. It also has support for playing midi, mp3, ogg, etc. At least in some cases it does. > HTH, > > Alan G. > > > ___

Re: [Tutor] Syntax when using classes question.

2006-11-10 Thread Luke Paireepinart
10) will give you a NameError because random is not defined in that namespace. So yes, that's not pythonic, because it's not valid syntax :) > > Method 2: (C Style?) > from lib import class > myClass = class() > myLib.class(param1, param2) I don't understand what t

Re: [Tutor] Syntax when using classes question.

2006-11-10 Thread Luke Paireepinart
ogram, except you refer to it all by module name. #- config.py a = 1 #- # test.py import config print config.a #-- etc. > > FYI... I dont know where it happened, but these last few e-mails are > off tutor. Oops, yeah. This one is forwarded to tutor and if anyone wants to

Re: [Tutor] First realscript + Game of Life

2006-11-11 Thread Luke Paireepinart
Kent Johnson wrote: > Luke Paireepinart wrote: > >> > working> > > I think you are a bit confused here. > Quite possible! > It's important to make a distinction between the way a number is > actually stored in the computer and the string that is created

Re: [Tutor] First realscript + Game of Life

2006-11-11 Thread Luke Paireepinart
Kent Johnson wrote: > Luke Paireepinart wrote: >> I was trying to make it clear that Python wasn't directly accessing >> the binary from memory with this function Carlos had. >> The function just mathematically converted a base-10 number into a >> base-2 numb

Re: [Tutor] First realscript + Game of Life

2006-11-11 Thread Luke Paireepinart
representation, which is in base-10, decimal, and using mathematical tricks to manipulate it back into the base-2 bit pattern. His program doesn't deal with the internal representation of the integer as base-2, it deals with the external representation of base-10. If it could access the internal representation, the program would be much more simple. bitpattern = list(integer.bits) or something. Hopefully ;) -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Syntax when using classes question.

2006-11-11 Thread Luke Paireepinart
ed multiple functions to act upon the contents of a file, you'd do something like f = file('input1.txt') text = f.readlines() f.close() function1(text) function2(text) function3(text) etc. Now, if these were all in a class, you could just have an instance variable self.text that contains the

Re: [Tutor] First realscript + Game of Life

2006-11-11 Thread Luke Paireepinart
Bob Gailer wrote: > Luke Paireepinart wrote: >>>> The function just mathematically converted a base-10 number into a >>>> base-2 number. >>>> > For what its worth - we say "base 10" to mean "decimal". But 10 = > decimal onl

Re: [Tutor] church numerals

2006-11-11 Thread Luke Paireepinart
eally interesting link. Thanks, Danny. I never thought of our time as a base-60 number. (referring to the Sexagesimal System subsection of that link) Oh, and the church numerals were quite breathtaking :) -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help me with this problem relating to datetime

2006-11-15 Thread Luke Paireepinart
n you help me to implement this functionality? yes. http://catb.org/esr/faqs/smart-questions.html#prune :). -Luke > > TIA. > > Best Regards, > Asrarahmed > > > > -- > To HIM you shall return. > ---

Re: [Tutor] A Million Sevens

2006-11-17 Thread Luke Paireepinart
Chris Hengge wrote: > I'm thinking you either have a problem with a memory leak (my memory > isn't changing, just at 100% CPU), or your CPU overheated from poor > cooling since it is at 100% utilization. yeah I second this... there's no reason why this would reboot your computer. At Chris: It's b

Re: [Tutor] A Million Sevens

2006-11-17 Thread Luke Paireepinart
's a string of length 5 with the contents just the original character, '7', repeating. You can do something similar with a string rather than a character, >>> 'hello' * 3 'hellohellohello' Now consider this: >>> '7' * 2 ** 5 '777

Re: [Tutor] (no subject)

2006-11-18 Thread Luke Paireepinart
27;t try to determine who it is that wants help and who it is that is helping other people. It wouldn't be very helpful if everyone just got the e-mails of the questions they asked, would it? SO in other words, if it's bothering you, sign up for a digest, or unsubscribe. Hope that helps,

Re: [Tutor] (no subject)

2006-11-18 Thread Luke Paireepinart
hen the largest audience of people who may benefit from your discussion are reached. If you mean to reply to the list, the 'reply-all' button serves this purpose quite well, and should be used unless it's necessary to reply privately. Thank you for your time, and I wish you the best of

Re: [Tutor] os.popen, xp

2006-11-18 Thread Luke Paireepinart
Coen van der Kamp wrote: > Hello, > I've got a problem with the following code: > > import os, sys, string > mycolors = os.popen("coloryze --monochromatic --total=6 &").read().rstrip() > print mycolors > > This works fine on OS X, but when i tried it on XP the only result was > an empty string. Wh

Re: [Tutor] One question......

2006-11-24 Thread Luke Paireepinart
e doing horizontal bar graphs) The following distinctions can be made: - I have a target height that they all must fit within (the height of the canvas) - Only the maximum value should be the full height of the canvas. - the others should be less t

Re: [Tutor] (no subject)

2006-11-24 Thread Luke Paireepinart
atch and a python installation? Just remember that very few programs come in completely enclosed .exes. Examples include Anim8or, and Hmm. I can't think of any others. Anyway, that's enough out of me. Time for you to get on with your pythoneering! Hope I helped, -Luke > ---

Re: [Tutor] Question about HORIZONTAL BAR CHART.....

2006-11-26 Thread Luke Paireepinart
(remember this is a horizontal bar chart, so the heights of the bars will all be the same, but the widths will be different) you will want to set it up so that the largest data value is set to the widest bar, and the rest are percentages of this width. I hop

Re: [Tutor] program spontaneously closes...

2006-11-26 Thread Luke Paireepinart
10) at the end of your program, or a raw_input, if you want to view the results. Eventually you'll get into scripts that have a menu, that's displayed in a loop, and then you'll have a 'quit' option to exit out of the loop. Otherwise, the loop just runs through again and you can look back at your previous data if you want. SO in this case you could see the previously calculated rectangle values while it's asking you for the new data. HTH, -_-Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] adjust key bindings

2006-11-26 Thread Luke Paireepinart
uot;) bindKey[keypress]()#this will call the 'aFunc' function if they type 'down', otherwise, it'll probably crash. bindKey['z'] = aFunc bindKey['z']()# now performs the same function as bindkey['down']()#this does. If you really do want

Re: [Tutor] to learn

2006-11-26 Thread Luke Paireepinart
re's no need for you to look for a MAC specific one because Python is largely the same on any OS you use it on. > a very fresh starter. > THANKS ED > > Glad to hear from ya, ed! -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Game programming - inventory management (was Help)

2006-11-28 Thread Luke Paireepinart
Bob Gailer wrote: > Please use a meaningful subject line. Many of us try to follow > "threads", and "help" does not help. > I have provided one for this case. > > Mohammed H. Hafeji wrote: > >> Need some help in python. >> >> How do i make the user choose wheter or not to pick it up? (i can d

Re: [Tutor] which file runs

2006-12-05 Thread Luke Paireepinart
Chris Hengge wrote: > I have a script that makes my python scripts into .pyc files and I can > run those without a .py in the directory or anywhere else on the > system for that matter. No clever tricks needed. > Why would you want to do this? ___ Tutor

Re: [Tutor] XP & catching execl o/p ?

2006-12-05 Thread Luke Paireepinart
Dave S wrote: > Hi all, > > Struggling with python & XP again. My app needs to know if a certain program > is running on my XP box > > Ideal world - I can get the output of 'tasklist.exe' into a string. > > I have tried > > os.execl('') > It throws the output to the terminal + I need the exact

Re: [Tutor] XP & catching execl o/p ?

2006-12-05 Thread Luke Paireepinart
Dave S wrote: > On Tuesday 05 December 2006 20:58, Luke Paireepinart wrote: > >> Dave S wrote: >> >>> Hi all, >>> >>> Struggling with python & XP again. My app needs to know if a certain >>> program is running on my XP box >>&

Re: [Tutor] Integer?

2006-12-05 Thread Luke Paireepinart
Eli Zabielski wrote: > How can I check if a variable is an integer? if type(aVar) == type(1): should do the trick. > > > ___ > Tutor maillist - Tutor@python.org > http://mail.pyth

Re: [Tutor] Integer?

2006-12-06 Thread Luke Paireepinart
gt;> print sys.stdout ', mode 'w' at 0x0097E068> with its own version, which I replaced with my own version (the class instance with the write method). All that matters is that the object has a 'write' method for it to be used as stdout (AFAIK). HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] subprocess & pyw conflict ?

2006-12-06 Thread Luke Paireepinart
;", line 1, in -toplevel-\n', 'salfjdsljfka321423\n', "NameError: name 'salfjdsljfka321423' is not defined\n"] Except instead of a file-like class, you could just use a real file. But then it would only leave the last line intact. So you'd p

Re: [Tutor] ***SPAM*** List to dictionary

2006-12-06 Thread Luke Paireepinart
his :D # Remove duplicates from a list: >>> L = [1,2,2,3,3,3] >>> [x for x in L if x not in locals()['_[1]'].__self__] [1,2,3] [accessed at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/204297 ] Also, why is ther

Re: [Tutor] List to dictionary

2006-12-07 Thread Luke Paireepinart
Dick Moores wrote: > At 09:53 PM 12/6/2006, Luke Paireepinart wrote: >> # Remove duplicates from a list: >> >>> L = [1,2,2,3,3,3] >> >>> [x for x in L if x not in locals()['_[1]'].__self__] >> [1,2,3] > > Why not > >>> L = [1

Re: [Tutor] OT GPL project finished, presentation looming

2006-12-07 Thread Luke Paireepinart
ut it would violate the list > rules :( > You can just upload the PNGs to a free webhost and link us to them, like Photobucket or Imageshack. I imagine people just don't want big attachments in their e-mail. If you give them a link to the picture then they only have t

Re: [Tutor] Newbie question: random.sample illusion?

2006-12-07 Thread Luke Paireepinart
Moedeloos Overste wrote: > Hi everybody, > > I'm in the process of learning Python and working my way through O'Reilly's > "Learning Python". As an excercise I wrote (some copy/paste as well) a small > lottery program just to learn how to work with lists and dictionarys etc. > > The user has to e

Re: [Tutor] Newbie question: random.sample illusion?

2006-12-07 Thread Luke Paireepinart
Moedeloos Overste wrote: > Hi everybody, > > I'm in the process of learning Python and working my way through O'Reilly's > "Learning Python". As an excercise I wrote (some copy/paste as well) a small > lottery program just to learn how to work with lists and dictionarys etc. > > The user has to e

Re: [Tutor] Tkinter Canvas

2006-12-08 Thread Luke Paireepinart
Asrarahmed Kadri wrote: > > > Hi Folks, > > I have a Tkinter canvas and a yscrollbar attached to it. It is working > fine but what I want is that when the mouse is in the canvas region, > the scroll button of the mouse should be able to control the upward > and downward movement, How to achieve

Re: [Tutor] Starting over with Python

2006-12-13 Thread Luke Paireepinart
ave a separate variable that stores the sums and add to that each time. The problem is since you're iterating over odd, you're changing what the 'if (odd%2)' statement is seeing, if you change odd +1 to odd+odd. Hope that helps, -Luke > If anyo

Re: [Tutor] Best method for filtering lists in lists...

2006-12-15 Thread Luke Paireepinart
point me > in the right direction? > > Thanks! > Didn't we give multiple solutions to a similar problem with lists with redundant elements a few weeks ago? Well, the solutions will be the same, regardless that the elements inside are lists themselves. HTH, -Luke ___

Re: [Tutor] Best method for filtering lists in lists...

2006-12-15 Thread Luke Paireepinart
1 unique elements or two? If it is 1, then just sort all the lists before you check for redundancy. I don't think there are any algorithms that are specific to lists of lists, though there may be. -Luke P.S. please reply on-list :) > > On 12/15/06, *Luke Paireepinart* <[EMAIL PROTECT

Re: [Tutor] Best method for filtering lists in lists...

2006-12-16 Thread Luke Paireepinart
Roel Schroeven wrote: > Alan Gauld schreef: > >> "Chris Hengge" <[EMAIL PROTECTED]> wrote >> >> >>> I'm terming a redundant list just like I posted in the original >>> message: >>> [[1,2,3], [4,5,6],[1,2,3]] >>> >>> [0][0] and [0][2] are redundant, so I only want to keep one of them. >>>

Re: [Tutor] Problems writing data into a file

2006-12-18 Thread Luke Paireepinart
use a variable for the filename, I.E. g = open('output%i' % x, 'w') which will open output1, output2, output3, etc... for each time through the loop, or you should open the file before the loop begins and only have writes inside the loop. Then you can close the file after

Re: [Tutor] How many times X is in a list?

2006-12-20 Thread Luke Paireepinart
on 2.5): > sum(1 for name in built_Objects if name.startswith('Circulation')) > I thought sum only worked on lists. Is that supposed to be a list comprehension inside of sum or am I wrong? (still using 2.4.3, so I can't check) Thanks, -Luke > Kent > > _

Re: [Tutor] python coding using regular expression

2006-12-21 Thread Luke Paireepinart
son' == 'davis thomson' False Unless you have some other requirements you haven't mentioned. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Lists on the fly?

2006-12-22 Thread Luke Paireepinart
so you can have an idea: >> >> for i in range(5): >> 'list_%i' % (i) = [] >> Note, though this is pretty arbitrary :) and only saves you 2 characters... You don't need to create a tuple if you're only packing in one value. >>> i = 1 >>> &#

Re: [Tutor] [tutor] sort a list

2006-12-23 Thread Luke Paireepinart
eneral/why-doesn-t-list-sort-return-the-sorted-list/ for an explanation. Basically, as we can see here > (the python is "Python 2.4.3 (#69, Mar 29 2006, 17:35:34) > [MSC v.1310 32 bit (Intel)] on win32") > you're using Pyt

Re: [Tutor] Lists on the fly?

2006-12-23 Thread Luke Paireepinart
e']) except KeyError: Lev_List[keystr] = [Element['Name']] I suspect the try/accept would be the fastest, but you'd have to timeit to be sure, of course. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Lists on the fly?

2006-12-23 Thread Luke Paireepinart
Kent Johnson wrote: > Luke Paireepinart wrote: > >> I think a better way to do this is to check if 'Level_%i' is in your >> dictionary already. > I am a fan of dict.setdefault() which has this logic built in: > Lev_List = {} > for Element in Elements:

Re: [Tutor] Infinite Loops (and threads)

2006-12-24 Thread Luke Paireepinart
that 'blocking' means when you call 'recv' it will return '' if it didn't receive anything.) I'd appreciate any links that I could read up on, or any advice on how to make socket inputs with event notification, as Kent mentioned earlier. Basically, as Kent

Re: [Tutor] Possible with list comprehension?

2006-12-25 Thread Luke Paireepinart
n consists of an expression followed by a for clause, then zero or more for or if clauses. The result will be a list resulting from evaluating the expression in the context of the for and if clauses which follow it. So I guess it just counts as a single list comprehension. HTH, -Luke -

Re: [Tutor] RandomArray and numeric

2006-12-25 Thread Luke Paireepinart
ssage -- From: Luke Paireepinart <[EMAIL PROTECTED]> Date: Dec 26, 2006 12:52 AM Subject: Re: [Tutor] RandomArray and numeric To: "linda. s" <[EMAIL PROTECTED]> On 12/25/06, linda.s <[EMAIL PROTECTED]> wrote: Since RandomArray is with Numeric, why I saw a code has so

Re: [Tutor] about array

2006-12-25 Thread Luke Paireepinart
Oops, another one where I replied off-list. -- Forwarded message -- From: Luke Paireepinart <[EMAIL PROTECTED]> Date: Dec 26, 2006 12:46 AM Subject: Re: [Tutor] about array To: "linda. s" <[EMAIL PROTECTED]> On 12/26/06, linda.s <[EMAIL PROTECTED]&

Re: [Tutor] idle and version

2006-12-25 Thread Luke Paireepinart
Another where I replied off-list. :( On 12/26/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote: Python is installed just like any other program. If you install Counter-Strike 1.5, and then Counter-Strike 1.6 (video games), the shortcut on your desktop will be changed to refer to Counter-

Re: [Tutor] about reload

2006-12-29 Thread Luke Paireepinart
Danny Yoo wrote: > On Fri, 29 Dec 2006, linda.s wrote: > > >> I read something about reload of modules. >> #test.py >> from ABC import M # M is an attribute of Module ABC >> >> if I change module ABC, I need import ABC and reload ABC before "from >> ABC import M" work. in IDLE, I just click F5

Re: [Tutor] about reload

2006-12-30 Thread Luke Paireepinart
f the script that's using the module, and take it out when you're done. Or, a better solution, start IDLE from the start menu, instead of right-clicking and choosing "Edit..." and it will open a subprocess, and none of these 'imported stuff hanging around' problems will occur. HTH - tell me if anything's unclear -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] XML-RPC data transfers.

2006-12-30 Thread Luke Paireepinart
that. I had all the clues right there, I just couldn't piece them together. So we've given you clues. Kent suggested - try to get the image data directly without going through a save-open process. You already know how to send binary data. So how do you get binary data from the image?

Re: [Tutor] XML-RPC data transfers.

2006-12-30 Thread Luke Paireepinart
Chris Hengge wrote: > This works... > d = xmlrpclib.Binary(open("C:\\somefile.exe", "rb").read()) > > What I need is more like > screenShot = ImageGrab.Grab() > d = xmlrpclib.Binary(screenShot) because screenShot is not binary data. It's an instance of the class Image.

Re: [Tutor] Starting python from a DOS prompt from any directory?

2006-12-31 Thread Luke Paireepinart
tat it). > Also, if you just need a temporary fix (say you're using Python on someone else's system and you don't want to permanently change their PATH) you can type path = %path%;c:\python25 to add it to your path just for that DOS session. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] display text in colors

2007-01-01 Thread Luke Paireepinart
think it's pretty important what operating system you're using here. Could you let us know before we try to help further? Thanks, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] mod_python

2007-01-02 Thread Luke Paireepinart
Jalil wrote: > I was just wondering if anyone know of a any good site with examples > of mod_python tutorial. > the mod_python manual assume isnt really that helpful. I have been learning mod_python recently and I found the manual to be quite good... what are you having problems with specifically

Re: [Tutor] how to know if a file exists

2007-01-03 Thread Luke Paireepinart
except: > return False You should except IOError here, just to be clear and such. > > but i thought that there would be an easier way. The os module has some function for checking if files exist, I think. Or you could do if targetfile not in os.listdir(directory): return False else: return

Re: [Tutor] coin toss program without using the for/range loop

2007-01-04 Thread Luke Paireepinart
e loop as well. But if you're indexing into a specific list, it becomes much more clear why we use python's 'for', to index directly into that list without having to deal with an index variable. for x in some_list: // do something with x rather than index = 0 while i

Re: [Tutor] Tutor Digest, Vol 35, Issue 18

2007-01-06 Thread Luke Paireepinart
e? Or part of the original response? is it a question or a statement? This is what all those '>' that your mail client puts before the replies are for. I can't follow what's happening here. Not that it really matters, but I was curious why the e-mail was formatted this way. Sorry for being a stickler, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] need help with sending email

2007-01-06 Thread Luke Paireepinart
ers for free? Thanks, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Query about using Pmw entry widget...

2007-01-06 Thread Luke Paireepinart
r in field "fieldname" .' That's most likely the easiest way to do this. If you just google for tkinter validate entry you should come up with the other way, IIRC (where they can't input incorrect values). HTH, -Luke. > > -- > To HIM you shall return. > -

Re: [Tutor] Help Installing Livewires

2007-01-07 Thread Luke Paireepinart
Stormtrooper30 wrote: > Hi > > I succesfully installed pygame and then attempted to install Livewires > on my Windows laptop. I am using Python 2.4 and when I try to call a > module from Livewires it says that "module Livewires does not exist". > I double clicked the setup program and it dis

Re: [Tutor] Query about using Pmw entry widget...

2007-01-07 Thread Luke Paireepinart
Alan Gauld wrote: > "Luke Paireepinart" <[EMAIL PROTECTED]> wrote > > OP>> Can some one help me how to add validation : only integers are > allowed > OP>> and minimum value should be 1. > OP>> > OP>> timeInterval = Pmw.EntryField(labe

Re: [Tutor] Question about __name__ global variable (Was: Tutor Digest, Vol 35, Issue 27)

2007-01-09 Thread Luke Paireepinart
n't be run. # import test-script print "The number 3 passed to someFunction is: " + someFunction(3) #- if the 'if __name__ == '__main__' ' test weren't in the original test-script.py, the 42 version of the print statement would be run whenever som

Re: [Tutor] Question on joining out of order dictionary elements

2007-01-11 Thread Luke Paireepinart
like you did, it creates a new thread in Thunderbird. I believe the 'reply all' button has some kind of magic that tells mail clients it's a reply to another message. In addition, please don't use bolding. If you reply normally, it will be clear what text is yours and what

Re: [Tutor] Image Question, List of Image Colors

2007-01-11 Thread Luke Paireepinart
x27;) > im = Image.open("Wind_Test_01") > You should include your traceback whenever you have a problem. For example, if it said "File Wind_Test_01 not found" I would say 'You probably need to specify the file extension, like you w

Re: [Tutor] Is Python the language for me?

2007-01-14 Thread Luke Paireepinart
find that, by them giving you only a week to make a game, it really opens your eyes to the design issues that will present themselves whenever you begin to make your turn-based strategy game. Even if you don't finish a game (I've competed in 3 Pyweeks so far, and haven't ever completed a game enough that I would submit a final entry), it's a great learning experience. Sorry for the long-winded reply ;) Hope That Helps, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

<    2   3   4   5   6   7   8   9   >