Re: [Tutor] Can't figure out why this is printing twice

2009-06-08 Thread Wayne
his stack/heap is somehow getting altered from outside python (or inside, I suppose) So Mike, can you provide a screenshot of your code/execution? Sending it directly (at least to me) will prevent it getting delayed while the attachment is approved. -Wayne > > On Mon, Jun 8, 2009 at 16

Re: [Tutor] Can't figure out why this is printing twice

2009-06-08 Thread Wayne
On Mon, Jun 8, 2009 at 10:53 AM, The Green Tea Leaf < thegreenteal...@gmail.com> wrote: > On Mon, Jun 8, 2009 at 17:26, Wayne wrote: > > On Mon, Jun 8, 2009 at 10:07 AM, The Green Tea Leaf > > wrote: > >> > >> Could it be some import statement? That the g

Re: [Tutor] Can't figure out why this is printing twice

2009-06-09 Thread Wayne
On Tue, Jun 9, 2009 at 6:34 AM, The Green Tea Leaf < thegreenteal...@gmail.com> wrote: > I got an email from him that he had a gzip.pyc file in that folder. > Once he deleted that everything works OK. Heh... I think I've made that mistake before; "My import statement doesn't work right! When I

Re: [Tutor] smtplib question

2009-06-09 Thread Wayne
s what you have told it to do. If it's the latter, I'm not sure what the problem is, unless it has something to do with your debug level. HTH, Wayne > > > Pointers, anyone? > > Thanks! > Albert-Jan > > import smtplib, email.utils > from email.mime.text im

Re: [Tutor] Can't figure out why this is printing twice

2009-06-09 Thread Wayne
at the BDFL would/has said. /me wanders off to see what he can find... -Wayne -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its enn

Re: [Tutor] gui further explained

2009-06-09 Thread Wayne
hat Popen can't find the the file. The other problem is that what you're thinking of really makes no sense. Pygame doesn't need (and shouldn't) run a program "inside" the window. You should have all of your game processes available to the main program and when you

Re: [Tutor] python and serial port

2009-06-09 Thread Wayne
so the funtions. > Please help me check this out: http://pyserial.wiki.sourceforge.net/pySerial and there are plenty of tutorials online. HTH, Wayne -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every we

Re: [Tutor] gui further explained

2009-06-09 Thread Wayne
ime to really look over my code I find the solution to my problem. HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] gui further explained

2009-06-10 Thread Wayne
7;t be a whole lot more complex than that. And that's really the most simple example I could think of and it's really not very good. For instance you could put the original code into a "game" function and then call it if the choice was P. HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help running a simple python script for one time operation (noob)

2009-06-10 Thread Wayne
y dbs on my host, all I need is to > be pointed in the right direction. Anyone? > It looks like it should be straightforward. I don't have the sqlobject library installed though, so it complains to me. Traceback (most recent call last): File "C:\Documents and Settings\Wayne\My

Re: [Tutor] GUI recommendations/tutorials?

2009-06-10 Thread Wayne
JPG, for example, as a background? > I don't *think* the turtle module allows loading a jpg as a background, but definitely allows you to draw a line. Tkinter's canvas PyGTK's DrawingArea Pygame pyglet matplotlib and even just using the PIL (Python Image(ing?) Library) could all ac

Re: [Tutor] file/subprocess error

2009-06-10 Thread Wayne
ad the games > images which couse this error is there a subprocess command to fix thisTried > python.org btw The last error specifically tells you what it is and what is wrong: pygame.error: Couldn't open data\up-1-.png it can't find that file. Are yo

Re: [Tutor] subprocess/files help

2009-06-10 Thread Wayne
On Wed, Jun 10, 2009 at 4:21 PM, Essah Mitges wrote: > > The problem I am have now is that once my game is initiated from the menu > file the modules that are with cannot import the imagesthe folder looks like > thisWODDSdataAll images and sound for gamegamelib > ObjectsU

Re: [Tutor] Syntax Error First Example

2009-06-10 Thread Wayne
really only if you start switching to Python 3 that you'll have a problem - specifically a lot of statements have turned into functions... but that's a discussion for a different day :) HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread Wayne
ike something is wrong with the way I am redirecting stdin, > but I have no idea what the problem is. Any suggestions gratefully received > I've not done much with subprocess, but I know you can use the subprocess.PIPE to redirect stdin/stdout. This may be of some help too, http://www.oreillynet.com/onlamp/blog/2007/08/pymotw_subprocess_1.html -Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Need a Solution!

2009-06-11 Thread Wayne
l the last part... so what you might say is: after the user enters a guess, if the number of guesses is over 5, then check if the guess is correct. If the guess is correct, print "You win!" and finish the game. Otherwise, print "You lose!" and ask the user if they would like to try again. Now see if you can translate that into code. HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] quarry,

2009-06-12 Thread Wayne
it > to install this program". What should i do? I am new in python. > > Do you have administrator privileges on your Windows box? If not, you need to get your system administrator to install python for you. Nothing to do with Python, everything to do with Windows. HTH, Wayne -- To be c

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-12 Thread Wayne
ime today I'll have to try that. -Wayne -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation

Re: [Tutor] Best Python Editor

2009-06-13 Thread Wayne
ith and enjoy. And of course I believe that everyone should enjoy vim ;) But you should give all the aforementioned tools a try and see what works best for you. HTH! Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Best Python Editor

2009-06-14 Thread Wayne
hat's probably the case for a few people - and certainly the reason those tools exist in the first place. If I were working on a quite large program I might consider using an IDE, but in reality I'm probably just as comfortable jumping around code to look for the information I need as

Re: [Tutor] Help Needed

2009-06-15 Thread Wayne
; Python has a slice operator the colon, so mystr[0] gives me the character at 0, and mystr[1:] gives me everything from the first character to the end (if you add something after the colon it will only return whatever is up to that point: In [10]: mystr[2:5] Out[10]: '

Re: [Tutor] Best Python Editor

2009-06-15 Thread Wayne
hard to use a real mouse for anything except graphics editing. The mouse wins there, and gaming, and that's really it for me. -Wayne -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every

Re: [Tutor] (no subject)

2009-06-16 Thread Wayne
in the other? Do you have an audio file you want to link with a video file? If you can give us a good idea about what you want, you will likely get a helpful response. -Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] which is better solution of the question

2009-06-16 Thread Wayne
s them in a big-endian (most important) first, or without reverse if I wanted the least important value. This assumes that you can't have two values of the same weight, of course. If you're looking for speed, I'd look at timeit: http://docs.python.org/l

Re: [Tutor] Conversion question

2009-06-16 Thread Wayne
[23]: int('Man', 2) --- ValueErrorTraceback (most recent call last) /home/wayne/ in () ValueError: invalid literal for int() with base 2: 'Man' Or do you mean this? In [24]: mystr = 'some

Re: [Tutor] Conversion question

2009-06-16 Thread Wayne
# 255 34. 35. print 36. 37. # check the exceptions 38. print Denary2Binary(0) 39. print Denary2Binary(-5) # should give a ValueError from http://www.daniweb.com/code/snippet285.html# HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] printing a list to a window

2009-06-16 Thread Wayne
window: f = open('somefile.txt', 'r') for line in f.readlines(): print line Just translate that. HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help needed

2009-06-16 Thread Wayne
add that (or substitute xrange) to the loop: for i in xrange(len(msg)-1, -1,-1): print msg[i] HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] converting encoded symbols from rss feed?

2009-06-17 Thread Wayne
is: http://www.siber-sonic.com/mac/charsetstuff/Soniccharset.html HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] List Splicing

2009-06-17 Thread Wayne
extend(range(3, itemsin+1,2)) Which would save you at least half the time in your generation. Since your first step should be removing multiples of two, that should be a big help. HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Fast way to access items in a dictionary

2009-06-17 Thread Wayne
mydict.get('spam') In [99]: mydict.get('knights') Out[99]: 'say ni' In [100]: if mydict.get(3): .: print 'Hi' .: .: In [101]: if mydict.get('death'): .: print mydict['death'] .: .: pointy teeth HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Tkinter idiosyncracies?

2009-06-19 Thread Wayne
lbl.config(text='Bar')) Am I missing something essential here? Or is this a bug that nobody has encountered yet? I appreciate any help! TIA, Wayne -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: ev

Re: [Tutor] how to manage an encrypted file?

2009-06-20 Thread Wayne
) I used a program called AxCrypt ( http://www.axantum.com/AxCrypt/ ) that seemed to work alright. If you want the most basic encryption you could simply XOR the file. It's fairly easy to break, though, because the same character patterns will be present as with your original file. HTH,

[Tutor] variable length precision

2009-06-22 Thread Wayne
er formatting (or use variables in place of string constants... of course some of us know that string objects really are references to constant strings...) - you just have to add %% where you want the final one: In [45]: 'some numbers %%.%sd' % 8 % 4 Out[45]: 'some numbers 0004'

Re: [Tutor] does python have something like "#include" in C?

2009-06-29 Thread Wayne
can define functions, classes, etc. you call them as whatever.function(), unless you say from module import * - then it willl import everything into the namespace of your original file. HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] does python have something like "#include" in C?

2009-06-29 Thread Wayne
the namespaces name for the object it's useless because there's nothing you can do with it. (And really it shouldn't be the responsibility of an outside function to modify the value of a variable anyway! It's also bad from a data security POV. You don't want functions messing with your data just by accident) Anyway... that's as far as I've been taught (and taught myself)... anyone notices any errors, please correct them! HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Needing Help

2009-06-30 Thread Wayne
Oops, forgot my reply-to-all On Tue, Jun 30, 2009 at 2:20 PM, Wayne wrote: > On Tue, Jun 30, 2009 at 1:06 PM, Bob Rea wrote: > >> >> If I input my own name and dob, it works: >> b...@gandalf:~/python/MakingUse/Chapter05> python code1.py >> Enter your first n

Re: [Tutor] Python Programming exercise

2009-07-01 Thread Wayne
right after line 4 or right after line 11. When you're incrementing a value it's best to do it at the beginning or end of a loop. (and certainly never in between an if and else!) So with this in mind, what could you do once it prints "Password confirmed" to make sure t

[Tutor] Replace a character by index

2009-07-16 Thread Wayne
uitous 'Why?' Normally I would lean towards the first method because reassigning a value in a list seems more natural than string concatenation. In this particular application I'm not exactly worried about performance - on even an archaic computer I don't think one would notice.

Re: [Tutor] Replace a character by index

2009-07-16 Thread Wayne
On Thu, Jul 16, 2009 at 5:50 AM, Kent Johnson wrote: > On Thu, Jul 16, 2009 at 4:29 AM, Wayne wrote:> I have > two different ways I can put _ in the word: > > word = 'cat' > > > > ''.join(list(word)[1] = '_') > > Not in any Pyt

Re: [Tutor] interactive naming of pointers

2009-07-16 Thread Wayne
f one single reason that it would be a) a good idea, or b) necessary. Of course I may be wrong and there is a single reason, but your case is not it. > Whatever code could make this happen I could loop through it several times, create various array names, and when the operator > > wa

Re: [Tutor] How to limit logs

2009-07-17 Thread Wayne
eserve the log from the previous run), seek to the beginning and write whatever is in the lines. Each time I add a line I'd check len(lines) > 1000: del(lines[0]), then write the lines and seek back to the front of the file. I don't know if

Re: [Tutor] sending to a file

2009-07-17 Thread Wayne
On Fri, Jul 17, 2009 at 5:10 PM, wrote: > > > On Fri Jul 17 17:51 , Wayne sent: > > >On Fri, Jul 17, 2009 at 1:55 PM, wrote: > > > > > > > > > >I have a form and script that works. I can enter values into the fields, > however > > &g

Re: [Tutor] Pygame

2009-07-20 Thread Wayne
about the pyweek games is when you download them you can examine the source code so you can see exactly how many lines of code went into writing the games. HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] I need help to the Python blackjack code

2009-07-20 Thread Wayne
ee if you can make the program stop once the user makes it to 21. HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] how to monitor if their data in a variable/object

2009-07-20 Thread Wayne
r own method to read a few kilobytes at a time, you can easily update a status bar. Otherwise if you know the file it's downloading to (i.e. not a temp file) you could continually call os.stat to update the status bar (especially if you know the size it's sup

Re: [Tutor] sftp get single file

2009-07-20 Thread Wayne
erver's policy forbids it. > Perhaps I need to chdir on the local host? That shouldn't make a difference as far as getting the file is concerned - unless you're trying to put it in a file on your computer that doesn't exist! I'd really recommend playing around in the interpreter - especially if you have ipython. Good luck, HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] advice on creating and working with a complex datastructure

2009-07-21 Thread Wayne
usually need to crteate collection > classes, we can just use a standard collection type. Maybe File would be > better although it could be confused with a comuter file... Maybe Record > would be best? If the candidate can file reports, p

Re: [Tutor] Bouncing mail

2009-07-22 Thread Wayne
On Wed, Jul 22, 2009 at 3:33 PM, Sander Sweers wrote: > 2009/7/22 Dave Angel : > > Anyone else seeing these? > > Unfortunately yes. Very annoying... :( Yep, and not the only ones I've seen ___ Tutor maillist - Tutor@python.org http://mail.python.org/

Re: [Tutor] Mapping of co-ordinates... pygame

2009-07-23 Thread Wayne
id to the middle. I don't know any of the pygame methods, but here's what it might look like: def draw_pixel(x, y): w = screen.get_width() h = screen.get_height() screen.draw_pixel(w/2+x, h/2+y) That should give you what you need. It starts right in the middle of the screen (w/2

Re: [Tutor] Need to start learning again

2009-07-25 Thread Wayne
a lot easier to use than some of the bigger GUIs, like GTK, but it also sacrifices a lot of features to go with that simplicity. A couple of folks on this mailing list have python tutorials that are certainly worth a read. HTH, Wayne ___ Tutor mai

Re: [Tutor] First code snipet

2009-07-25 Thread Wayne
Any feedback is appreciated. > There's a spot in your code that could be turned into a function. I'm not sure what you'd call it, but where you "lay down" 1-4 cards. Since you're doing the same thing for each stack, you may as well turn

Re: [Tutor] searching for an ip and subnets in a dir of csv's

2009-07-29 Thread Wayne
2, do you want it to return nothing? Or both 192.168.1.1 and 192.168.1.10? Or only 192.168.1.1 as it's the closest match? Also, I don't know if I'd do re.compile on the raw sys.argv data, but perhaps filter it - just compiling is error prone and possibly a security hole. Even

Re: [Tutor] concerning help() function

2009-07-29 Thread Wayne
ile) This goes back to pythons objects. If something is an object in python, you can probably pass it to help(), otherwise you need to pass a string. >>> operator = 'foo' >>> help(operator) Welcome to ASCII Assassin! (1) Start Game

Re: [Tutor] searching for an ip and subnets in a dir of csv's

2009-07-29 Thread Wayne
)] for ip in iplist: if ip.startswith(ipnet): matches.append(ip) and that should give you a list of all IPs within that same subnet. HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] flag to call methods on objects?

2009-07-30 Thread Wayne
le def xor_crypt_string(data, key): return ''.join(chr(ord(x) ^ ord(y)) for (x,y) in izip(data, cycle(key))) On the page provided someone also gave their code that can encrypt files. Of course any of these methods presume you're just trying to keep the casual snoop from getting a

Re: [Tutor] flag to call methods on objects?

2009-07-30 Thread Wayne
l name '_Cripto__compress' is not defined > You're trying to call a method __compress which doesn't exist. self.__compress exists, but __compress doesn't. HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Program to Simulate Keystrokes

2009-08-04 Thread Wayne
7;python', 'asdf.py'], stdout=subprocess.PIPE, stdin=subpro cess.PIPE) p.stdin.write('\r\n') print p.stdout.readlines() - the contents of asdf.py are just these: raw_input("Press enter to continue") print "Works!" HTH! -Wayne, who just learned a little s

Re: [Tutor] monitor number of files in a folder

2009-08-06 Thread Wayne
on/temp/theQuicktimeCommandTest.sh') You really just want a while loop: while imagecount >= framecount: time.sleep(60) # Call script here I guess that's the easiest way. Probably not the most effective, but I'm not sure if the implementation of an alternate solution w

[Tutor] Fwd: Noobish Syntay Error?

2009-08-06 Thread Wayne
Forgot reply-all -- Forwarded message -- From: Wayne Date: Thu, Aug 6, 2009 at 3:32 PM Subject: Re: [Tutor] Noobish Syntay Error? To: Anna - Sophie Maeser On Thu, Aug 6, 2009 at 2:08 PM, Anna - Sophie Maeser < annasop...@dautzenberg.org> wrote: > Hi! > I want

Re: [Tutor] droplet like behaviour in Python

2009-08-10 Thread Wayne
'll go and have a hunt in my MacOS books but sadly I don't have my iBook > available just now to try anything. I'm not sure if this will be of any help: http://docs.python.org/library/carbon.html http://sourceforge.net/projects/appscript/ But that's all I could come up wit

Re: [Tutor] list question

2009-08-11 Thread Wayne
[r1, r2, r3] (incidentally you could just do robots = [Robot(), Robot(), Robot()] ), and lists don't have x y attributes, which you're trying to access. I presume you're really trying to access the x y attributes of your Robot() class, which is an entirely different object from your list. HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] droplet like behaviour in Python

2009-08-11 Thread Wayne
asiest thing - you'd probably have to use an os module call to check the system to determine the proper course of action or something otherwise technically advanced. -Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Automating creation of presentation slides?

2009-08-12 Thread Wayne
ave images. IIRC that feature may be included in matplotlib. I don't know what other methods are available, but I'd probably do a quick google search for the options. -Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] write program to extract data

2009-08-14 Thread Wayne
iles" for some specific pointers. Are you familiar with comma separated value (.csv) files? It's fairly trivial to import those into a spreadsheet program, and if you're the one writing the .csv it's not too difficult to get them written the right way. HTH, Wayne > > &g

[Tutor] Packaging for distribution

2009-08-20 Thread Wayne
(which means I could write my own installer in the time it would take me to learn these), or produce massive files (in the case of py2exe). Does anyone know of any guides/resources, or are these my best bet? Thanks, Wayne -- To be considered stupid and to be told so is more painful than being ca

Re: [Tutor] Algorithm

2009-08-24 Thread Wayne
r] >mainword[letter]: return False else: return False I think that should work. First you're looping over each letter in cmpword. Because mainword is also a dictionary the order isn't terribly important. Then you check if the letter is in mainword. If it's not, obviously cmpword isn't in mainword, so return False. If the letter is, compare the counts. If cmpword has more letters than mainword, it's not in the word so again return False. HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Algorithm

2009-08-24 Thread Wayne
On Mon, Aug 24, 2009 at 10:48 AM, kreglet wrote: > > Wayne, > > The reason I used print sorted is that using just print throws a syntax > error: > > print (lettercount.iteritems(), key=itemgetter(1)) ---> error > print lettercount.iteritems(), key=itemgetter(1

Re: [Tutor] Algorithm

2009-08-25 Thread Wayne
On Mon, Aug 24, 2009 at 8:58 PM, kreglet wrote: > > Wayne, > > > def myfunc(cmpword, mainword): > > for letter in cmpword: > > if mainword.gets(letter): > > if cmpword[letter] >mainword[letter]: > > return False > >

Re: [Tutor] Algorithm

2009-08-25 Thread Wayne
On Tue, Aug 25, 2009 at 2:14 PM, kreglet wrote: > > Wayne, > I appreciate your patience with me. I still can't get this to work: > > > from operator import itemgetter > class testwords: > def __init__(self): >

Re: [Tutor] Declaration order of classes... why it is important?

2009-08-26 Thread Wayne
following code evaluates as expected, indeed. > > def fone(): > ftwo() > def ftwo(): > print "hello" > fone() Try it with a class definition instead: In [1]: class One: ...: Two() ...: ...: -----

Re: [Tutor] how to read and transmit/send only section of the image (sub-image)

2009-09-03 Thread Wayne
o the location on disk. AFAIK it's the latter, in which case opening the file and seeking to the correct place, reading a specific size, and saving that data would be all you need to do. HTH, Wayne ___ Tutor maillist - Tutor@python.org T

Re: [Tutor] mapping/filtering a sequence

2009-09-05 Thread Wayne
y flexible or permanent? A bit more info would be helpful in finding a solution. -Wayne ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] mapping/filtering a sequence

2009-09-05 Thread Wayne
ach incoming integer to the closest one available. I know, > it is idiosyncratic. I also need to be able to do this with other > idiosyncratic gap toothed sets. I think the simplest way is to use a dictionary. You could, of course, use a sort to fi

Re: [Tutor] Pyduino

2009-09-08 Thread Wayne
t following the tutorials you can pretty much figure out everything you need to know. It's basically a simplified version of C++. HTH, Wayne ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Sorting 2-d data

2009-09-12 Thread Wayne
, 2 and I'm wondering if there are any included ways to sort data like this. I've currently got a 2d list by columns, but I could easily convert that to rows if it would work better. I'm about to check if sorting a list of lists will work in that fashion. Thanks for any help/advice

Re: [Tutor] Sorting 2-d data

2009-09-13 Thread Wayne
On Sun, Sep 13, 2009 at 7:27 AM, Rich Lovely wrote: > 2009/9/13 Lie Ryan : > > Wayne wrote: > >> > > if your data is like this: > > mylist = [ > >[3, 2, 4, 1], > >[4, 1, 2, 3], > >[3, 1, 2, 1], > >[2, 1, 1, 1], > >

Re: [Tutor] New guy question...

2009-09-14 Thread Wayne
nput() made things work, so I think it's the implicit eval(). On python3 they changed input to work like raw_input, or am I mistaken? But as I test, my 2.6 gives an identical error so I'm suspecting there's a problem with that shebang line. I also suspect if the OP puts import pl

Re: [Tutor] NameError

2009-09-21 Thread Wayne
x27;t defined here. I think you should be declaring a self.btnStat in the __init__ method (which I usually put as the first function in my class - I'm honestly not sure if it makes a difference), and calling self.btnStat Unlike C/C++, python is explicit when dealing with mem

Re: [Tutor] Confusion with $PATH

2009-09-25 Thread Wayne
s (on Ubuntu): /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/wayne/.bin I don't remember the syntax for adding files to the path, but a quick google search should yield plenty of results. HTH, Wayne ___ Tutor maillist

Re: [Tutor] Confusion with $PATH

2009-09-25 Thread Wayne
helloworld.py (or whatever the filename is) You also need the "shebang" line at the top: #!/usr/bin/env python is one of the variations. HTH, Wayne (included the list in reply... Hit reply-all when replying to list) -- To be considered stupid and to be told so is more painful tha

Re: [Tutor] New to python: some advises for image processing tool

2009-10-02 Thread Wayne
ly because of the rather extensive documentation. I've used both Tkinter and PyGTK and the latter is much easier to deal with when using images, though YMMV. The most difficult task would be analyzing the image and possibly some of the graph generation. HTH, Wayne ___

Re: [Tutor] New to python: some advises for image processing tool

2009-10-05 Thread Wayne
I think you forgot to hit Reply-all, so forwarding on to the list with my response On Mon, Oct 5, 2009 at 11:38 AM, Nicola De Quattro < lead.express...@gmail.com> wrote: > Wayne ha scritto: > >> The most difficult task would be analyzing the image and possibly some of >&

Re: [Tutor] Poorly understood error involving class inheritance

2009-10-05 Thread Wayne
ribly clear or makes much sense, it's a bit of a difficult concept to wrap my head around, but I *think* I've got it. Hopefully you can get it, too, Wayne ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Which version to start with?

2009-10-05 Thread Wayne
have issues. For beginning there's probably nothing wrong with 3.1, but I think I'd recommend sticking with 2.6. HTH, Wayne ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] if n == 0 vs if not n

2009-10-06 Thread Wayne
"if not returncode == 0" > shows clearer what is going on than "if returncode". > If it's checking the returncode against a value, Vern makes a good point: if returncode != 0 makes a whole lot more sense than "if not returncode == 0" Though when dealing

Re: [Tutor] Which version to start with?

2009-10-06 Thread Wayne
popped into my mind :) I kinda hopped around to various tutorials, especially since I've programmed before (and am a CS major), so a lot of the concepts were a bit easier for me to grasp. Alan's tutorial does a great job explaining a lot of concepts behind programming in general and ties t

Re: [Tutor] Checking for Python version

2009-10-06 Thread Wayne
quot; >> directive. >> >> Is there a prettier way or is this fine? > > Is there anything wrong with using this? import sys if sys.version < '2.4': sys.exit("Need at least Python 2.4") AFAIK the string comparison is reliable -Wayne ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Checking for Python version

2009-10-06 Thread Wayne
On Tue, Oct 6, 2009 at 9:46 AM, Steve Willoughby wrote: > On Tue, Oct 06, 2009 at 09:42:04AM -0500, Wayne wrote: > > On Tue, Oct 6, 2009 at 9:26 AM, Christian Witts >wrote: > > if sys.version < '2.4': > >sys.exit("Need at least Python 2.4")

Re: [Tutor] Checking for Python version

2009-10-06 Thread Wayne
On Tue, Oct 6, 2009 at 9:57 AM, Steve Willoughby wrote: > On Tue, Oct 06, 2009 at 09:47:43AM -0500, Wayne wrote: > > On Tue, Oct 6, 2009 at 9:46 AM, Steve Willoughby > wrote: > > > > > On Tue, Oct 06, 2009 at 09:42:04AM -0500, Wayne wrote: > > > > On Tue,

Re: [Tutor] if n == 0 vs if not n

2009-10-06 Thread Wayne
case - checking a return code against zero, should it still be considered unreliable? The only case that you are looking for correctness is 0 == 0, any other case should evaluate as false, so I guess the question is does python always optimize for zero? Any other optimization is i

Re: [Tutor] Package for verify validity of any kind of IP

2009-10-08 Thread Wayne
, just use a regex (google can give you explicit examples if you don't want to make your own) hth, wayne ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Finding and Inserting missing dates in a date range.

2009-10-09 Thread Wayne
t I haven't found the correct python module that > does it ;) > The datetime module exists... you could easily write a function that does something along the lines of: def date_range(startdate, enddate): #do something here to make a range of dates though you may want to write a fu

Re: [Tutor] [OT] Secure coding guidelines

2009-10-10 Thread Wayne
try: n1 = int(n1) n2 = int(n2) except ValueError: print "Error! Cannot convert values to int!" return n1+n2 Or do something similar. HTH, Wayne -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious,

Re: [Tutor] class with objects

2009-10-11 Thread Wayne
tion if you get stuck. For an explanation of /how/ to ask a good question, check out this: http://catb.org/~esr/faqs/smart-questions.html#examples HTH, Wayne > > Here's my code: > > class Ship(object): >"""A spaceship""" >to

Re: [Tutor] Carriage return

2009-10-11 Thread Wayne
much as windows/linux. IIRC, Linux only uses a newline, while windows uses a CRLF. There's the dos2unix util: http://linuxcommand.org/man_pages/dos2unix1.html that may help. -Wayne ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] complete neophyte question here

2009-10-12 Thread Wayne
these for? I haven't read the book, but I'm sure Dawson gives a good explanation of if statements and loops. HTH, Wayne -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every

Re: [Tutor] Porting PHP web app to Python GUI

2009-10-12 Thread Wayne
PyQt seem to > have a reasonable learning curve for this application? > I've never used PyQT so I don't know about that. I mainly use PyGTK+, but for something this simple I'd just use Tkinter. HTH, Wayne ___ Tutor maillist

Re: [Tutor] Switching to other version of Python

2009-10-12 Thread Wayne
e aggressively come summer of '10. HTH, Wayne ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Masking operation

2009-10-14 Thread Wayne
e, 25), so I would have: mask = 'secretsecretsecretsecrets' The way I'm currently doing it is: mask = mask * (len(message)/len(mask)) for l, m in zip(message, mask): word += chr(ord(l) ^ ord(m)) but I'm wondering if there are any easier/more pythonic ways. Thanks, Wayne -- To be consid

  1   2   3   4   5   6   7   8   9   >