Re: [Tutor] Comments appreciated

2005-01-05 Thread hugonz
and just work with parameter passing. >> > > Lovely, thank you. I started a project that is for learning spanish > on-line, of currently 300 lines or so, that is proceeding rapidly > thanks to these lessons learned. Thank you Python Tutors, and thank > you Python! Hola Luis, I'd like to help with

Re: [Tutor] Comments appreciated

2004-12-29 Thread Luis N
> [Jeff] > > Also, even though this is intended to be a quick shell script, it's > > not a bad idea to make everything except function defs into a little > > main() function, and call it in a script-only section. > > > [Luis] > > > The only thing I'm not clear about is how 'trashcan' can be a >

Re: [Tutor] Comments appreciated

2004-12-27 Thread Alan Gauld
> file. This allows me to pass a single object that contains loads of conf > data to the important init functions (which my, indeed, change the data > depending on various factors). Now, memory wise this may not be the best > thing to do. As a matter of interest why do you think its a problem memo

Re: [Tutor] Comments appreciated

2004-12-27 Thread jasonchild
[edited for sanity] > An advantage here is that this guess() function is less tied to outside > global resources, and is, in theory, more easily reused. If we wanted to > rewrite the program so that we take three different passwords, the version > without global variables is easy to write: > >

Re: [Tutor] Comments appreciated

2004-12-27 Thread Alan Gauld
> example. The only thing I'm not clear about is how 'trashcan' can be a > local variable inside main() when it's required by both trash() and > can() It's not local. It is a global variable. It is defined outside of any of the functions. > The only thing that's missing is that this script can't

Re: [Tutor] Comments appreciated

2004-12-27 Thread Danny Yoo
[Jacob] > > BTW, trashcan IS a module level variable because it's defined at the > > module level. Why it says it's local is beyond me. [Danny] > Ah, you must be running into the global/local gotcha. [long rambling text cut] Wait, wait. Forget everything I said. *grin* I should have read the

Re: [Tutor] Comments appreciated

2004-12-27 Thread Danny Yoo
On Sun, 26 Dec 2004, Jacob S. wrote: > > The only thing that's missing is that this script can't handle paths > > like ~/dir/junkthis > > I believe you're looking for os.path.expanduser("~/dir/junkthis") > > BTW, trashcan IS a module level variable because it's defined at the module > level. Why

Re: [Tutor] Comments appreciated

2004-12-26 Thread Jacob S.
> The only thing that's missing is that this script can't handle paths > like ~/dir/junkthis I believe you're looking for os.path.expanduser("~/dir/junkthis") BTW, trashcan IS a module level variable because it's defined at the module level. Why it says it's local is beyond me. HTH, Jacob Schmid

Re: [Tutor] Comments appreciated

2004-12-26 Thread Luis N
Hi, Jeff Shanon, thanks for your help. I was wondering if there was a function to automatically get the user on a *nix system, and had tried the if __name__ == __main__ but didn't really get it until your example. The only thing I'm not clear about is how 'trashcan' can be a local variable inside

Re: [Tutor] Comments appreciated

2004-12-22 Thread Alan Gauld
> junk = [] > for arg in sys.argv: > junk.append(arg) > > junk = junk[1:] Why not for arg in sys.argv[1:]: junk.append(arg) Or even easier and faster: junk = sys.argv[1:] All I had time to look at, sorry. Alan G. ___ Tutor maillist - [E

Re: [Tutor] Comments appreciated

2004-12-21 Thread Jeff Shannon
Luis N wrote: This is the most meaningful thing this newbie has ever done. Comments are appreciated: Okay, here's a few thoughts... junk = [] for arg in sys.argv: junk.append(arg) junk = junk[1:] You can write these four lines much simpler as: junk = sys.argv[1:] if len(junk) is 0 and empty ==

[Tutor] Comments appreciated

2004-12-21 Thread Luis N
This is the most meaningful thing this newbie has ever done. Comments are appreciated: #!/usr/local/bin/python trashcan = "/home/anewby/.trashcan" import os, sys, shutil junk = [] for arg in sys.argv: junk.append(arg) junk = junk[1:] empty = False if "-e" in junk: empty = True ju