Re: [Tutor] Troubles with lists and control flow

2009-10-08 Thread Luke Paireepinart
Oops, accidentally replied off-list. -- Forwarded message -- From: Luke Paireepinart Date: Thu, Oct 8, 2009 at 3:36 PM Subject: Re: [Tutor] Troubles with lists and control flow To: Eduardo Vieira On Thu, Oct 8, 2009 at 2:42 PM, Eduardo Vieira wrote: > Hello I'm deve

Re: [Tutor] What is Curses and why do they call it that.

2009-10-12 Thread Luke Paireepinart
Not sure what curses means but that module only works on Unix. It does do what you want though. On 10/12/09, Katt wrote: > Hello all, > > In my search for ways to change the color of text printed to the screen I > came across discussions about curses. > > Some documentation indicate it as a modul

Re: [Tutor] Testing for empty list

2009-10-19 Thread Luke Paireepinart
evaluating to a boolean somehow. (It does, it's False if it's empty and True otherwise). -Luke ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] i can't for the life of me get "#! /usr/bin/env python" or "#!/usr/bin/python" to work

2009-10-21 Thread Luke Paireepinart
On Wed, Oct 21, 2009 at 4:56 PM, Jason Willis wrote: > so i changed the .bashrc and added at the end : > PATH="/home/compy/pythons:$PATH" ###which is the actual path to my python > proggies### No, you have to set the environment variable from within the path, not modifying .bashrc. $PATH refers

Re: [Tutor] i can't for the life of me get "#! /usr/bin/env python" or "#!/usr/bin/python" to work

2009-10-21 Thread Luke Paireepinart
On Wed, Oct 21, 2009 at 5:12 PM, Luke Paireepinart wrote: > > > On Wed, Oct 21, 2009 at 4:56 PM, Jason Willis wrote: > >> so i changed the .bashrc and added at the end : >> PATH="/home/compy/pythons:$PATH" ###which is the actual path to my python >>

Re: [Tutor] A question about the self and other stuff

2009-10-25 Thread Luke Paireepinart
quot;what are the differences"? They are functions that are called in certain situations. For example, a + b will call a.__add__(b) and a['blah'] = b will call a.__setitem__(b) etc. (these __ names may be wrong so don't quote me on them.) > > and the rest of the normal methods for a class.? > Depends on the class. There are no "normal methods", the methods that a class has are based upon the type of class it is. You could have a class with no methods and only attributes (but this would be almost completely useless). -Luke ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] A question about the self and other stuff

2009-10-25 Thread Luke Paireepinart
On Sun, Oct 25, 2009 at 10:10 PM, Luke Paireepinart wrote: > > >> 2- in the final few lines where I assign an object to the class, I notice >> that a parameter was entered in the class name, "Robot(D23)", although when >> defining the class I didn't put

Re: [Tutor] Compute data usage from log

2009-10-26 Thread Luke Paireepinart
ather than repeated addition (sum is implemented in C) and because list comprehensions in general are a tad faster than explicit iteration, if i recall correctly (don't hold me to that though, I may be wrong.) > > Of course this has no error checking and or niceties, but I will lea

Re: [Tutor] Function design

2009-10-26 Thread Luke Paireepinart
quot;. So you should get rid of all your "final" code and just return the list of rows. I would also suggest renaming the function to find_zeros() and obviously you would pass just the input filename. Then you would have another function write_rows(outfile, rows) and it would output

Re: [Tutor] Can python determine Battery or AC Power?

2009-10-28 Thread Luke Paireepinart
If you're on Windows and you can find an example using the Win32 api (in C++ for example) you can use pywin32 module to do the same thing through python. It's a little complicated sometimes though. So what O.S. are you on? On Wed, Oct 28, 2009 at 4:15 PM, Nick Hird wrote: > Is there a way in p

Re: [Tutor] Can python determine Battery or AC Power?

2009-10-28 Thread Luke Paireepinart
On Wed, Oct 28, 2009 at 4:28 PM, Nick Hird wrote: > I am running Windows XP. > My advice applies then ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Sorting points on a 2D plane

2009-10-28 Thread Luke Paireepinart
figure out how to improve your algorithm. -Luke > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Luke Paireepinart
Are you sure you're using the 3.1 version of Python to run the script? Welcome back, btw. haven't heard from you in a while. On Tue, Nov 3, 2009 at 2:09 AM, Richard D. Moores wrote: > I'm in the process to learning Python 3.1, and need to convert a bunch > of handy functions I wrote and stole ov

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Luke Paireepinart
st me, though. No one else seems to mind having to hit "reply to all" to send a message to the list either. Hopefully Google will succeed in their mission to replace e-mail with Wave and all messages will be in context and there will be no need for quoting one way or the other. -Luke ___

Re: [Tutor] Logfile multiplexing

2009-11-10 Thread Luke Paireepinart
> Traceback (most recent call last): > File "", line 1, in ? > File "kent.py", line 11, in __iter__ >if stamp.startswith(date): > NameError: global name 'date' is not defined > > How does __iter__ know about date? Should that be self.date? > Yes. self.date is set in the constructor. _

Re: [Tutor] class initialization with a lot of parameters

2009-11-10 Thread Luke Paireepinart
On Tue, Nov 10, 2009 at 1:21 PM, Dave Angel wrote: > (Removing out of sequence history) > > DaveA > > instances of that class. Better than using tuples. > makes sense to make a class to hold the seven parameters, and pass two > If you're passing two sets of 7 parameters to the same function, it

Re: [Tutor] How to call a method with a print statement?

2009-11-12 Thread Luke Paireepinart
On Thu, Nov 12, 2009 at 5:29 AM, Jeff R. Allen wrote: > You are looking for the __str__ method. See > http://docs.python.org/reference/datamodel.html#object.__str__ > > Can't you also implement __repr__? (bottom-posted for Dave) -Luke

Re: [Tutor] Writing code while tired, counterproductive?

2009-11-16 Thread Luke Paireepinart
I hate to be the odd one out here, but I actually find that I am extremely productive when I'm tired. It's easier for me to commit completely to the code, when I'm well-rested I dream about running through fields of sunflowers and such, get distracted more easily. The code I write when I'm tired

Re: [Tutor] I love python / you guys :)

2009-11-16 Thread Luke Paireepinart
at can enable and one that can disable, and make sure tehre's no harm if you run either one multiple times consecutively. Hope that helps, and yes, we know you guys appreciate the help, that's why we do it! We certainly don't get paid anything. It's nice to hear you say it anyway

Re: [Tutor] proxy switcher - was Re: I love python / you guys :)

2009-11-16 Thread Luke Paireepinart
in file: > for setting in settings: >if setting in line: > if line[0] == '#': >line = line[1:] > else: >line = '#' + line >output.write(line) > Also, you didn't define 'output' anywhere. Is

Re: [Tutor] Faster list searching?

2009-11-18 Thread Luke Paireepinart
ode that makes more sense) and extremely quick as well. If you're interested in it, Bill, reply to me off-list and I'll send it to you. -Luke ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Faster list searching?

2009-11-18 Thread Luke Paireepinart
On Wed, Nov 18, 2009 at 5:54 PM, Luke Paireepinart wrote: > This is really just a round-about way of using sets. > I don't really want to give a code-sample unless he's confirmed he's not > doing this as homework, but the set version is much more simple (shorter > code

Re: [Tutor] Can a method be added to dictionary?

2009-11-20 Thread Luke Paireepinart
Does the partial just do a lambda in the background? It's a neat example, thanks! I've never seen this used before. Sorry if reply is top-posted or otherwise weird, posting from mobile. On 11/20/09, Lie Ryan wrote: > lau...@protopc.com wrote: >> John, >> >> Thank you so much for your help! -- Pro

Re: [Tutor] Global Variables

2009-11-20 Thread Luke Paireepinart
--- ~~~ main.py --- import somemodule somemodule.foobar() --- This will make it much easier to understand your question, because I don't see how the code sample you provided applies to your question whatsoever. Also, if you have a lot o

Re: [Tutor] Global Variables

2009-11-20 Thread Luke Paireepinart
, query) #display the results order.display_qtys(filtered_results) -- I strongly recommend reading more tutorials about proper function definition, in the long run (and whenever you have a large scale project to work on, or even a medium-scale one, at that) handling values between

Re: [Tutor] multiple assignment on one line

2009-11-22 Thread Luke Paireepinart
On Sun, Nov 22, 2009 at 2:30 AM, Shashwat Anand wrote: > Ok, this is silly but i want to know is multiple assignment is possible in > one line using "+=, -=, *= etc" operators on python 2.6.4 > > like a,b = 0,1 which is equal to > a = 0 > b = 1 > on seperate lines. > similarly a = b = 0 which is e

Re: [Tutor] functions--how long is too long?

2009-12-07 Thread Luke Paireepinart
If your code is not sensitive information, it might help us if you post it to pastebin or something so we can take a look. In general though, functions should be as long as they need to be (and no longer!). 57 lines is not inordinately long. If it's hard for you to read, though, you should refact

Re: [Tutor] functions--how long is too long?

2009-12-08 Thread Luke Paireepinart
On Tue, Dec 8, 2009 at 4:17 AM, spir wrote: > Luke Paireepinart dixit: > > > I'd say my personal hard-limit for functions before I start refactoring > is > > probably around 150-200 lines. But it's rare that functions get that > long > > anyway. >

Re: [Tutor] Append mode dilemma

2009-12-09 Thread Luke Paireepinart
ou output a new line at the end of your outputs. > fobj = open(fname, 'a') > fobj.write('\n'.join(all)) > fobj.close() > > Are you aware of how 'join' works? try print "#".join(['a','b',&

Re: [Tutor] Append mode dilemma

2009-12-09 Thread Luke Paireepinart
On Wed, Dec 9, 2009 at 12:49 PM, biboy mendz wrote: > >> Are you aware of how 'join' works? >> > Hi Luke, > > Thank you. To be honest I'm confused of the different string methods like > join(), split(), etc. Anyway I will practice them to see how they w

Re: [Tutor] Append mode dilemma

2009-12-09 Thread Luke Paireepinart
On Wed, Dec 9, 2009 at 1:02 PM, biboy mendz wrote: > > Luke Paireepinart wrote: >> That's because there is NOT a new line at the end of the file. >> It's a file you're appending to, it's up to YOU to create that new line. >> And all files should end w

Re: [Tutor] Append mode dilemma

2009-12-09 Thread Luke Paireepinart
On Wed, Dec 9, 2009 at 2:46 PM, Lie Ryan wrote: > On 12/10/2009 6:12 AM, Luke Paireepinart wrote: > >> This won't work unless you have STDOUT redirected to your file. It >> would be better just to do >> fobj.write('\n'.join(all) + '\n') >&g

Re: [Tutor] Hat lands in ring

2009-12-12 Thread Luke Paireepinart
On Sat, Dec 12, 2009 at 3:47 PM, Kirk Z Bailey wrote: > I'm Baaacck... > > How'd your wiki sales go? Find lots of road warriors? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/li

Re: [Tutor] computer basics

2009-12-29 Thread Luke Paireepinart
Pqa pAzazqzz /// / // @?&// ?/& /@ /q On 12/28/09, Richard Hultgren wrote: > I am learning Python slowly.  I would like to begin learning all about how > computers work from the bottom up.  I have an understanding of binary code. > Where should I go from here; can you suggest continued

Re: [Tutor] computer basics

2009-12-30 Thread Luke Paireepinart
Srry sorry! Phone left on in pocket!! On 12/30/09, Luke Paireepinart wrote: > Pqa > pAzazqzz /// / // @?&// ?/& /@ /q > > On 12/28/09, Richard Hultgren wrote: >> I am learning Python slowly.  I would like to begin learning all about >> how >> comp

Re: [Tutor] Question on "import foobar" vs "from foobar import *"

2010-01-08 Thread Luke Paireepinart
our global namespace, but you'd be aware of which you were importing. So in your example you'd want to do from socket import gethostbyname so you're sure you know what you're importing into your namespace and you can avoid polluting it. HTH, -Luke On Fri, Jan 8, 2010 at 1:

Re: [Tutor] Question on "import foobar" vs "from foobar import *"

2010-01-08 Thread Luke Paireepinart
where it's preferable to use the "from" syntax, it's mostly just a laziness thing. -Luke On Fri, Jan 8, 2010 at 1:39 PM, Rob Cherry wrote: > Extending on this advice somewhat - is it *ever* correct to "import > foobar". > > There are countless examples of >

[Tutor] Case acceptance using raw_input

2005-02-15 Thread Luke Jordan
Hi all, thanks to all for running such a great list. Is there a better way for raw_input to accept both caps and lower case letters than: def aFunction(): action = raw_input("Perform an action?(y,n): ") if action == 'y' or action == 'Y': anotherFunction() elif action == 'n' or act

[Tutor] Print text position problems when using triple quotes

2005-02-24 Thread Luke Jordan
quot;here's 80 characters" print "now another 80" etc. Also, I've tried string.ljust(), but either I'm doing it wrong or it isn't the trick I'm looking for. Thanks for the help. Luke -- "If you think that was good, wait 'til you taste the antidote!" ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Print text position problems when using triple quotes

2005-02-24 Thread Luke Jordan
Execllent. Many Thanks, Luke On Thu, 24 Feb 2005 13:15:41 -0500, Bill Mill <[EMAIL PROTECTED]> wrote: > On Thu, 24 Feb 2005 13:14:13 -0500, Bill Mill <[EMAIL PROTECTED]> wrote: > > On Thu, 24 Feb 2005 10:02:44 -0800, Luke Jordan <[EMAIL PROTECT

[Tutor] Functions Calling Functions

2005-02-25 Thread Luke Jordan
Hi - I'm working on a command-line game. Is there anything wrong with having each 'chapter' of the game be a function that links to other chapters by calling them? I only ask because when a recent traceback returned about 40 lines worth of error message, I realized that the functions are all bein

[Tutor] Associate functinos with Dictionary/Class Usage

2005-04-07 Thread Luke Jordan
: def takeItem(item): items.append(item) print "You took the", item action = raw_input(">>> ") if action == "take": what = raw_input("What do you want to take? ") takeItem(takeWhat) elif action == "drink":

Re: [Tutor] Associate functinos with Dictionary/Class Usage

2005-04-08 Thread Luke Jordan
Yes, Danny - that makes sense. I was getting hung up how to handle the parens in this part dict['some'](thing) all clear now. :-) On Apr 7, 2005 4:40 PM, Danny Yoo <[EMAIL PROTECTED]> wrote: > > > On Thu, 7 Apr 2005, Luke Jordan wrote: > > > I am looking

[Tutor] "Dispatching" functions with args

2005-04-13 Thread Luke Jordan
t;E:/gibberish/current work/test2.py", line 14, in ? dispatch(aFunc,1) File "E:/gibberish/current work/test2.py", line 12, in dispatch func = func(funcArg) TypeError: 'tuple' object is not callable I understand *that* a tuple is not callable, but not why this is happening h

[Tutor] Filtering Spreadsheet Data

2005-05-23 Thread Luke Jordan
eport that I can do detailed research and analysis on. The reports come to me in Excel format. I have a solid understanding of basic programming. Any guidance/advice/starting points would be greatly appreciated. Thanks! Luke ___ Tutor maillist -

[Tutor] dictionary values

2005-07-08 Thread luke p
st = alphavalues[0] lowestlocation = 0 and just do for x in range(26):#or is it 25? can't remember if value is included if alphavalues[x] < lowest: lowest = alphavalues[x] lowestlocation = x but for future reference I just wondered about the dictionary thing. thanks in advance. -L

Re: [Tutor] imported module/global

2007-04-16 Thread Luke Paireepinart
Andreas Kostyrka wrote: > OTOH, module globals are seldom used, and usually frowned on. E.g. the > python2.5 standard lib (>200K lines, 584 py files), uses exactly 104 > distinct global statements. > > [EMAIL PROTECTED]:/usr/lib/python2.5> grep -r "^[ \t]*global " . | sed 's/[ > \t][ \t]*/ /' | so

Re: [Tutor] sys.argv?

2007-04-17 Thread Luke Paireepinart
Rikard Bosnjakovic wrote: > On 4/17/07, Kirk Bailey <[EMAIL PROTECTED]> wrote: > > >> IF my memory serves well, argument 0 in that list is the name of the >> program itself, as well as the path to it if any was provided. >> > > Stop replying to my mailbox. > I really wish this list would

Re: [Tutor] celcius to farenheit converter.

2007-04-17 Thread Luke Paireepinart
Rikard Bosnjakovic wrote: > On 4/18/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > >> I found this site and I'm practicing coding and I write this script, but >> I'm unsure why its not working. Everything goes well until it gets to the >> part where it tries to calculate the formula. Inp

Re: [Tutor] screen scraping without the request

2007-04-22 Thread Luke Paireepinart
t;> page I need. Perhaps Python can use the session cookie and then pull >> the right page? >> Have you tried using Firebug? It's an extension for Firefox. You might be able to run it while you're navigating the site, and see the communciat

Re: [Tutor] IDE / development environment

2007-04-22 Thread Luke Paireepinart
nk it's so much that the e-mail is in his inbox, just that it's in ONLY his inbox, and he feels bad letting it rot there, for fear that the person who can't remember whether to use reply or reply-all for this group may have had something useful to contribute - and he thus is force

Re: [Tutor] IDE / development environment

2007-04-23 Thread Luke Paireepinart
t are sent to you and to the list. > I only ever get one copy, even when people CC me. I'm CCing this to you, Rikard, as motivation for you to figure out how to configure yours this way :P -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Tkinter import error

2007-04-23 Thread Luke Paireepinart
lem is in your 2.5 install? Can you just use a binary package or do you need to compile from scratch? You can use the #! first line in your source code to specify which Python interpreter to use, I believe, so you could direct it at one of your other installs for now until you get 2.5 working Just a thought. -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] detecting data member changes

2007-04-23 Thread Luke Paireepinart
atus array. It's not necessarily a bad thing for my own use, but it seems like it'd be off-putting to other people using my library. So is there a way to detect such changes that's Pythonic? Thanks, -Luke ___ Tutor maillist - Tutor@python

Re: [Tutor] detecting data member changes

2007-04-24 Thread Luke Paireepinart
apologize, I should've waited till the morning to e-mail so I could be more coherent. Is this properties method acceptable Python form or is it more proper to have modifying member functions like Alan said? Or is it really up to me on how I want to implement it? Thanks, -Luke > > Kent > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] detecting data member changes

2007-04-24 Thread Luke Paireepinart
ant way of doing things to me (with properties vs. an explicit method), at least in this case. > >> Or is it really up to me on how I want to implement it? > > Of course, it's your code, right? Yes, but it's code I plan on open-sourcing,

Re: [Tutor] best search/replace method?

2007-04-25 Thread Luke Paireepinart
Rikard Bosnjakovic wrote: > On 4/25/07, John Washakie <[EMAIL PROTECTED]> wrote: > > >> cat raw.html | >> sed 's/ImagePathReplaceMe/NewPathToImage/g' | >> sed 's/TitleReplaceMe/NewTitle/g' > new.html >> > > One line's sufficient: > > sed -e 's/ImagePathReplaceMe/NewPathToImage/g;s/TitleRepl

Re: [Tutor] best search/replace method?

2007-04-25 Thread Luke Paireepinart
the target string. Refer to my other e-mail on why Rikard's didn't work. -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] python internet archive API?

2007-04-25 Thread Luke Paireepinart
Switanek, Nick wrote: > > I’m a novice Python programmer, and I’ve been looking for a way to > collect archived web pages. I would like to use the data on Internet > Archive, via the “Wayback Machine”. Look, for example, at > http://web.archive.org/web/*/http://www.python.org >

Re: [Tutor] The IDLE subprocess

2007-04-29 Thread Luke Paireepinart
Alan Gilfoy wrote: > Often, when I am developing code, I get an error message saying that > "IDLE's subprocess can't make connection" > > Sometimes this happends when I have IDLE open, and am about to hit F5 > to run a program-in-process. > Sometimes it happens when I opne up IDLE the first tim

Re: [Tutor] listing files in an html directory

2007-04-29 Thread Luke Paireepinart
http servers disallow directory listing. Even ones that do (like Apache default) there has to be no index.html in the directory, and they dump the directory listing to a webpage you'd have to parse. -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help python coding not working

2007-05-08 Thread Luke Paireepinart
to read the source, it was so messy. If you attach your code, it keeps the wrapping from occurring. -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] how to stop output to terminal

2007-05-11 Thread Luke Paireepinart
shawn bright wrote: > lo there all, > > i have a simple thread that i want to run without piping any output to > the terminal. > like if i do an > > x = os.system("ping -c 1 www.google.com ") > > i don't want it to show all the stuff in the terminal. if you use os.popen or t

Re: [Tutor] How to test for a remainder from division

2007-05-14 Thread Luke Paireepinart
i.e. a remainder of 0 indicates a perfect divisor.) so you could do: if year % 4 or year % 100 or year % 400: #then it's divisible perfectly by any of [4,100,400] for example. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] html links

2007-05-14 Thread Luke Paireepinart
input("Where would you like to create the file? ") And this can vary in difficulty; if you wanted, for example, a GUI that lets them browse their directory tree graphically for the file they want, you could do that too. > > thanks yw -Luke

Re: [Tutor] File access by os.system

2007-05-15 Thread Luke Paireepinart
p() would do it. Returns an object with a file-like interface; the name of the file is accessible as file.name. The file will be automatically deleted when it is closed. So I'd expect to use command = "dsspcmbi -v %s %s" %(Pdb, temp1.name) That is, unless __str__ and/or __repr__ return the file name also. -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] I want some help with arrays...

2007-05-17 Thread Luke Paireepinart
at do we index? 0[1] -> this doesn't work, it raises an error. Whereas this: command: array[0][1] array[ ... what do we index? 0 ] -> we index the first item. so now we have this: command: ["0.0","0.1"][1] ["0.0","0.1"] [ ...

Re: [Tutor] I want some help with arrays...

2007-05-17 Thread Luke Paireepinart
ment, for example, you'd retrieve the 0th element for me, and so on. The indexing itself isn't changed, merely the interface to it. Note that you don't actually index the list starting at the 1th element (the 2nd one) you index it starting at the 0th element, but use inde

Re: [Tutor] I want some help with arrays...

2007-05-17 Thread Luke Paireepinart
James Matthews wrote: > http://www.goldwatches.com/watches.asp?Brand=39 Also, please stop spamming us with this link. You have a gmail account, so there's no reason for us to believe that you are required to put it there by a company you work for or otherwise. It's an

Re: [Tutor] (no subject)

2007-05-18 Thread Luke Paireepinart
read because it has the same subject line.) Thanks, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help with excetion handing and making my code more efficient needed please

2007-05-18 Thread Luke Paireepinart
ys be 1 (assuming you don't do checks on whether they should stay alive for already dead squares!) You can add an if statement to remove this case, or, easier (and probably more efficient) just subtract 1 from your result. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help with excetion handing and making my code more efficient needed please

2007-05-18 Thread Luke Paireepinart
gt;> > > I need to not text matrix[x][y] is there a simple way to exclude this from > the possible combinations of values from the two tuples? see my other reply, Matt. -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] question re: executing exe files with arguments

2007-05-18 Thread Luke Paireepinart
string because of the /'s within it. I'm not > sure of any other approaches. > '\' is the only reason you'd need to use a raw string, not '/'. This is because backslash is used for special character sequences. For example, a new line

Re: [Tutor] two input acceptions

2007-05-18 Thread Luke Paireepinart
emails into another program and reformat them just so they can read them. Also, if your code is more than a few lines, sending it as an attachment keeps it from getting all weird from e-mail client formatting. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help with excetion handing and making my code more efficient needed please

2007-05-19 Thread Luke Paireepinart
Matt Smith wrote: >> the possible combinations of values from the two tuples? >> see my other reply, Matt. >> -Luke >> > > Hi Luke, > > Sorry if I'm missing something but which other reply? > All the info in my other reply Alan reiterated, I bel

Re: [Tutor] I want some help with arrays...

2007-05-19 Thread Luke Paireepinart
t is that they extrapolate from that the general usefulness of the technique (be it recursion or munging with indexes) so that, later, they will hopefully be able to recognize the situation where it's better to do it a different way. Giving them more tools on their belt so they

Re: [Tutor] string replacement

2007-05-21 Thread Luke Paireepinart
gt; I can perform the same using a loop. But how do i append i > (1,2,..n) while i am writing into the file.(I mean inside the > handle.write) For each write you use a string substitution, and you do the write in a loop. Or you use writelines like my above example. Also

Re: [Tutor] [Fwd: Re: trouble with "if"]

2007-06-02 Thread Luke Paireepinart
sk us questions if you get stuck with those. But really, experimenting within the constraints of the tutorial, to begin, will help you to see common problems and things that frustrate people, and the manner in which to work around them. Also, if

Re: [Tutor] using re

2007-06-04 Thread Luke Paireepinart
> Thanks for you response. You are correct and I have determined that > something > is wrong with the "self.BackColor == "pink" " statement because it does not > turn the background pink but is firing. > == is comparison, not assignment.

Re: [Tutor] clarification on os.path.walk

2007-06-11 Thread Luke Paireepinart
nto the subdirectories whose names remain in fnames; this can be used to implement a filter, or to impose a specific order of visiting. No semantics are defined for, or required of, arg, beyond that arg is always passed to func. It can be used, e.g., to pass a filename pattern, or a mutable object designed to accumulate statistics. Passing None for arg is common. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Automatic generation of an "all possible combinations" array

2007-06-15 Thread Luke Paireepinart
m unsure how efficient it is. You'd have to test it out. But it might be faster for large n, compared to a repeated-division or recursive approach (I have no idea.) I used strings for brevity of the code, but you could do the same with lists. obviously you'd need another loop to generate your values (0 -> n) so that this can convert them to hex. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] iterating over a sequence question..

2007-06-17 Thread Luke Paireepinart
#x27;) not exactly Pythonic either, and you are assuming that l is longer than t (it is easy to account for opposite case as well.) a more expanded version that accounts for either list being the longer one, or both being the same length, would be: >>> if l

Re: [Tutor] Class error

2007-06-17 Thread Luke Paireepinart
ookEntry): > > def __init__(self, nm, ph, id, em): > AddrBookEntry.__init__(self, nm, ph) > I believe this should be "AddrBookEntry.AddrBookEntry.__init__" I can't be certain, but that's what it looks like off the top of my head. -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] iterating over a sequence question..

2007-06-18 Thread Luke Paireepinart
On 6/18/07, Simon Hooper <[EMAIL PROTECTED]> wrote: Hi Luke, * On 17/06/07, Luke Paireepinart wrote: > a more expanded version that accounts for either list being the longer > one, or both being the same length, would be: > > >>> if len(t) > len(l): x = len(t) &

Re: [Tutor] tips for writing a program

2007-06-19 Thread Luke Paireepinart
help on a certain function, just use the builtin method "help" >>> help(os.rename) Help on built-in function rename in module nt: rename(...) rename(old, new) Rename a file or directory. so this tells us we can do, for example, os.rename("C:\\test.txt&quo

Re: [Tutor] (no subject)

2007-06-22 Thread Luke Paireepinart
starts up, I have to scroll up 2 pages in my mail reader every time there's a new message. it doesn't even have to be a meaningful subject. Just anything but (no subject.) thanks, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] ongoing saga

2007-06-23 Thread Luke Paireepinart
yway, I'm just a college kid with no experience in this kind of stuff, so if I'm completely wrong then correct me, but that's how I'd see it as working. P.S. my money tree's a little dried up right now but I hope with some water and some love it'll be rejuvenated soon.

Re: [Tutor] Tutor Digest, Vol 40, Issue 54

2007-06-23 Thread Luke Paireepinart
s just a waste of bandwidth and time to make .exe versions. But then, I haven't sold anything I've written yet, and my target audience is usually other programmers. Honestly, though, Python's easy and quick to install, especially compared to Java. I don't think it should be

Re: [Tutor] Animating changes with Numpy arrays

2007-06-26 Thread Luke Paireepinart
e let you have a character map of the terminal, versus a top-to-bottom line printing mode. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Beginner Game: Rock, Paper, Scissors

2007-06-26 Thread Luke Paireepinart
Johnny Jelinek wrote: > sure, I wouldn't mind looking at your code :D! Also, the graphical > one you sent me was using gif's, do you know how to render svg's on > screen? The advantage to vector rather than raster is that you can > resize it as big as you could ever desire and it will never lo

Re: [Tutor] Beginner Game: Rock, Paper, Scissors

2007-06-26 Thread Luke Paireepinart
ou of other python modules that can render svg files. I don't have any resources for doing this, I just assumed since you mentioned Cairo could do it that you knew how to use Cairo to do it. -Luke ___ Tutor maillist - Tutor@python.org http://mail.py

Re: [Tutor] Finding all locations of a sequence

2007-06-27 Thread Luke Paireepinart
x27;:[3. 5], 'AAC':[0] > > the setdefault(key, []).append(location) thing sort of does what I > want, but I don't want the result to be a list of lists...just one big > list. The production of a new dictionary is not necessary, but it made > sense to

[Tutor] database question

2007-06-29 Thread Luke Jordan
update the existing records to include the new fields? Thanks, Luke -- "If you think that was good, wait 'til you taste the antidote!" ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Reading image dimensions before it is loaded from a web form using python.

2007-06-29 Thread Luke Paireepinart
27; you meant 'filesize' you could do this much more simply (using Javascript) than having to process the actual image data to find the resolution. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] 200 dollar questions!

2007-06-30 Thread Luke Paireepinart
rate method of timing it. For example, using the timeit module and getting an average of 1,000 iterations, or something of that nature. > > any hints on performance increase? It depends what you're trying to do. Give us more info and we can help. -Luke

Re: [Tutor] 200 dollar questions!

2007-06-30 Thread Luke Paireepinart
etpixel ((10, 12)) These loops don't go 0-1023 and 0-768 they go 1-1023 and 1-767 There is a function called getdata() that you can use to get all of the pixel data of the image at once. -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] 200 dollar questions!

2007-06-30 Thread Luke Paireepinart
o it. > > I am told to optimize getpixel (x, y) alone, so that's the only thing > i am trying, it's part of a project that will go live in september, so > the prof we are under hasn't one anything but some introductory readings. Then keep wo

Re: [Tutor] write a movie file thumbnail in Linux...

2007-07-01 Thread Luke Paireepinart
ous movie types. The documentation isn't the greatest (especially compared to most other Python libraries) but I'm pretty sure it will work for pulling out specific frames (or just the first, or whatever.) -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] optimization: faster than for

2007-07-01 Thread Luke Paireepinart
gt;>> will often end up as 3 vertical bars in e-mail clients. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] optimization: faster than for

2007-07-01 Thread Luke Paireepinart
elis aeris wrote: > oh crancky! C# ! > > > i better try to find the best way to do it with the official python > genre before venturing into that world of pain without PIL ! What are you talking about. ___ Tutor maillist - Tutor@python.org http://ma

<    1   2   3   4   5   6   7   8   9   >