Re: [Tutor] class design

2009-06-06 Thread ALAN GAULD
> In simple terms I was trying to create a 'folder with a view' which > displays all the data it contains on one page, rather than having to > view each node individually. In that case I'd probably create a FolderView class with a show or display method. If you want to do something with the c

Re: [Tutor] creating a range above & below a given number

2009-06-06 Thread Alan Gauld
for n in range(lower, upper+!) if n < median-threshold or n > medianthreshold] eg: [n for n in range(5,21) if n < 10 or n > 16] [5, 6, 7, 8, 9, 17, 18, 19, 20] HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ __

Re: [Tutor] gui menu

2009-06-07 Thread Alan Gauld
ions? Or is it displaying them using the image? The more specific your question the more likely that someone will answer it. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http:

Re: [Tutor] gui menu

2009-06-07 Thread ALAN GAULD
pert on pygame but can you tell us more > specifically what you are finding so hard about putting > your 4 buttons on the image? > > It is creating the button objects or is it linking them to the functions? > Or is it displaying them using the image? > > The more specific your q

Re: [Tutor] Stop a long loop in python console or in wxpython?

2009-06-08 Thread Alan Gauld
dea is, is that I want to cut short the process of a piece of code in order to start another piece of code. You can put a terminating flag in the timer code or you can send a message to stop a thread, either way will work. HTH, -- Alan Gauld Author of the Learn to Program web sit

Re: [Tutor] Stop a long loop in python console or in wxpython?

2009-06-08 Thread Alan Gauld
op = True tk = Tk() result = Label(tk, text="Not started yet") result.pack() Button(tk,text="Start", command=counter).pack() Button(tk, text="Stop", command=doStop).pack() tk.mainloop() ### hth, -- Alan Gauld Author of the Learn to Program web site http://www

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

2009-06-08 Thread Alan Gauld
"Mike Hoy" wrote I have the following code: Is this in a file or are you typing it at the python interpreter >>> primpt? import gzip import datetime date = datetime.date.today() name = date.strftime('%m-%d-%Y')+'.gz' date.strftime('%m-%d-%Y')+'.gz' print "The name of the file will be", na

Re: [Tutor] Hi

2009-06-08 Thread Alan Gauld
en find answers to a lot of your own questions :-) -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] question about class

2009-06-09 Thread Alan Gauld
et/set method, but in Python we usually just use direct access. But in general it's best to call a higher level method of the class and let it make the change! Remember to ask yourself what is this class's responsibilities, what do I want it to do for me? Think about behaviours first,

Re: [Tutor] question about class

2009-06-09 Thread Alan Gauld
and observe values once for each instance. This is a class with only an __init__ method, that's usually a suspicious sign. What does the class do? BTW its also unusual to have verbs as attributes. (Unless they are boolean flags and even then its better to make it a question eg. doesObs

Re: [Tutor] gui

2009-06-09 Thread Alan Gauld
) File "C:\Python26\lib\subprocess.py", line 804, in _execute_child startupinfo) WindowsError: [Error 2] The system cannot find the file specified Also could anyone help me to display the contents of a text file in a pyg4m3 window HTH, -- Alan Gauld Author of the Learn to Program we

Re: [Tutor] python and serial port

2009-06-10 Thread Alan Gauld
"Ranjeeth P T" wrote I am new to python i want to communicate i.e send and receive b/n an arm device and pc via a serial port, and "Jacob Mansfield" wrote does anyone know how to make a parallel or serial interface with respective software, i would prefer parallel because it is easy to ut

Re: [Tutor] GUI recommendations/tutorials?

2009-06-10 Thread Alan Gauld
frameworks for comparison. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Need help solving this problem

2009-06-10 Thread Alan Gauld
ll be good enough for your purposes! Otherwise take a look at my tutorial for the various topics Raw Materials - variables and data Loops Branches File handling - for a very brief intro to reading the time HTH, -- Alan Gauld Author of the Learn to Program web site http://www.al

Re: [Tutor] file/subprocess error

2009-06-10 Thread Alan Gauld
then importing that into your menu module. You can then call the game function using import Utilities # menu code here Utilities.startGame() And so that you can still ru n it as Utilities.py add a clause at the end of IUtilities.py like if __name__ == "__main__": startGame

Re: [Tutor] file/subprocess error

2009-06-11 Thread Alan Gauld
"Essah Mitges" wrote But will it work I run 3 module for this game utilites is just 1 It doesn't matter how many modules you use, although it changes how many you have to import maybe. But in princiople if your game is started by calling a single function then you only need to import th

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread Alan Gauld
"eShopping" wrote C:\> poly.exe < poly_files.txt in a CMD program (or COMMAND or whatever the console program is called nowadays at Win* systems). Tried piping the input as suggested but POLY ignores the pipe and just asks me for the names of the files as if we were in interactive mode.

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread Alan Gauld
"Tino Dai" wrote I know that this is a python group but you might want to try the open source utility called Expect. It does what you need it to do without having having to go through this trial and error process with subprocess. http://expect.nist.gov/ Or use the Python wrapper around

Re: [Tutor] Need a Solution!

2009-06-11 Thread Alan Gauld
raw_input("Take a guess:")) tries += 1 if tries > 5: guess == the_number But you need to do the same thing here print "You're right" else: print "You lose" raw_input("\n\nPress the enter key to exit")

Re: [Tutor] Help..Concatenaton Error

2009-06-12 Thread Alan Gauld
"Randy Trahan" wrote Attached is an error I cannot get to work, I was doing a print concatenation but it won't let me get past "+ "ibly impressive. " \ (then to next line) You don;t appear to have a quote in front of the string - immediately after the print statement? BTW While that is OK a

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-12 Thread Alan Gauld
"eShopping" wrote Or use the Python wrapper around expect - pyexpect??? Alan G Installed pexpect and rewrote the code to look like this: Now I get these errors: Traceback (most recent call last): File "C:\Projects\Active\Alun\US_DOE_EOR\test_poly.py", line 1, in -toplevel- import p

Re: [Tutor] Need a solution.

2009-06-12 Thread Alan Gauld
done!" break else: guess = int(raw_input('Guess again-> ')) except GuessError: print "Sorry, too many guesses, the number was", target.number You could add another loop to ask if the player wanted to go again, in which case you call targ

Re: [Tutor] quarry,

2009-06-12 Thread Alan Gauld
r when it is more established. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ And if you insist on using v3: http://www.alan-g.me.uk/l2p/ (Which is still under construction) ___ Tutor maillist - Tutor@python.org

Re: [Tutor] parallel port commands

2009-06-12 Thread Alan Gauld
pes module, especially if they are in a Windows DLL. There is a way to access the parallel port from Python as was mentioned in a thread earlier this week(?) using pyParallel. http://pyserial.wiki.sourceforge.net/pyParallel But pyParallel is still in development... HTH, -- Alan Gauld Aut

Re: [Tutor] Need a solution.

2009-06-13 Thread Alan Gauld
"David" wrote class GuessError(Exception): pass class GuessedNumber: def __init__(self,tries=None,limits=None):... def generate(self, limits=None):... def __cmp__(self, aNumber): if self.count >= self.tries: raise GuessError Thanks always for the feedback, i came up with t

Re: [Tutor] Need a solution.

2009-06-13 Thread Alan Gauld
Do we save them in a file? Then maybe we need a save() method? Do we do some calculations? Maybe we should have a calculate() method? Do we draw them... well, I'm sure you get the idea :-) -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Best Python Editor

2009-06-13 Thread Alan Gauld
uses the same components and is very similar to scite) But there are zillions of programmers editors and choice is extremely personal. Other popular choices for Windows include Eclipse, Winedit, emacs, etc... But for Python specific work I'd go with Pythonwin. -- Alan Gauld Author of the

Re: [Tutor] Best Python Editor

2009-06-13 Thread Alan Gauld
"Tom Green" wrote For Windows check out PyScripter. I just did, Wow!, this looks like a superb IDE. Thanks for posting, its a new one for me although its been out for quite a while. And the P4D delphi plugin looks useful too. Thanks again, Alan G. ___

Re: [Tutor] Best Python Editor

2009-06-13 Thread Alan Gauld
"Alan Gauld" wrote I just did, Wow!, this looks like a superb IDE. I spoke a wee bit too soon. The editor is nice but the debugger and some of the other tools windows (eg variables) are broken. Pity, lots of potential here. Alan G. ___

Re: [Tutor] Need a solution.

2009-06-13 Thread ALAN GAULD
> Ok, I think I am getting somewhere now :) A lot better, now add the comparison methods: > class GuessedNumber: > def __init__(self, count=0, attempts=None): > self.attempts = attempts > self.number = randrange(1,99) > self.count = count > def step(self): >

Re: [Tutor] Best Python Editor

2009-06-13 Thread Alan Gauld
wrote The current release of Pyscripter is not stable. Drop back one release and you'll find a very solid product. Sounds interesting. What is the stable version and where can it be found? Here's the version we use: Version 1.7.2, Oct 2006 http://mmm-experts.com/Downloads.aspx?ProductId

Re: [Tutor] Best Python Editor

2009-06-14 Thread Alan Gauld
too. Remember that IDEs as such didn't really come into existence till about 12-15 years ago. Those of us who have notched up more than 2 or 3 decades of coding have probably just not got used to the new concepts yet! Unix was the original IDE! :

Re: [Tutor] Best Python Editor

2009-06-14 Thread Alan Gauld
"Alan Gauld" wrote Some of this might just be what we are used to too. Remember that IDEs as such didn't really come into existence till about 12-15 years Sigh! I'm getting old In fact the first thing I would call an IDE in the modern sense was probably Turbo

Re: [Tutor] Best Python Editor

2009-06-14 Thread Alan Gauld
"Alan Gauld" wrote [ And of course Smalltalk80 had a very complete IDE in 1980, (See Squeek screenshots for some idea of how it differs from modern GUIs!) but Smalltalk has always been an exception to the rules! ] I'm not doing well today. Since I last looked Squea

Re: [Tutor] Need a solution.

2009-06-15 Thread Alan Gauld
"spir" wrote Actually, it seems that only in the scientific field values are everywhere top-level things. Values _are_ the kind of things maths manipulate. Right? Thats an interesting observation that had not occured to me but I think you are right. What is interesting to me is that when

Re: [Tutor] Best Python Editor

2009-06-15 Thread Alan Gauld
"Emile van Sebille" wrote Anyone know of any studies comparing text based vs GUI IDE based code development? As I recall, programming productivity is measured in LOC/day and last time I noticed it seemed to be a very small number. When I started in "software engineering" (c1985) the typical

Re: [Tutor] Help Needed

2009-06-15 Thread Alan Gauld
"Raj Medhekar" wrote I am looking to build a program that gets a message from the user and then prints it backward. I 've been at it for hours now but I can't seem to figure it out. So tell us what you re thinking? How would you solve it manually? I've been having trouble trying to inde

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

2009-06-16 Thread Alan Gauld
a purely readability point of view, and if I had any control over the data formats I'd personally convert it to a dictionary of value,item pairs and not bother with two lists. Sorting then becomes a unified operation. -- Alan Gauld Author of the Learn to

Re: [Tutor] Help Needed

2009-06-16 Thread Alan Gauld
really needed print 'hello'[-1:-6:-1] Look at the description of slicing to see why... However all you really need to do is print message[::-1] and let Python figure out the boundaries itself. Keep it simple... -- Alan Gauld Author of the Learn to Program web site http://www.al

Re: [Tutor] printing a list to a window

2009-06-16 Thread Alan Gauld
t like to try getting it to work by printing on a console first! Then worry about the GUI bits. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help needed

2009-06-16 Thread Alan Gauld
wrote mystring="Mary had a little lamb." mystring.split() ['Mary', 'had', 'a', 'little', 'lamb.'] And then you can use slicing to reverse the created list the same way you did with the full string. Or use the reverse() method of the list... Alan G __

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

2009-06-18 Thread Alan Gauld
e for the times you miss d = {1:7,2:9,3:12} d.get(2,-1) 9 d.get(12,-1) -1 HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Checking Syntax

2009-06-18 Thread Alan Gauld
tr(os.path.split(clipFeatures)[1]): GP.Clip(fc, clipFeatures, outFeatureClass, clusterTolerance) fc = fcs.Next() I suspect all of these lines should be indented too... except: GP.AddMessage(GP.GetMessages(2)) print GP.GetMessages(2) HTH, -- Alan Gauld Author of the

Re: [Tutor] list of instance objects, access attribute

2009-06-19 Thread Alan Gauld
of values is a suspicious design smell. Any processing of or rules about the data should be in a method. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mai

Re: [Tutor] home directory usage script

2009-06-19 Thread Alan Gauld
"dave chachi" wrote create a python that will accomplish the following tasks: issue: /home partition is partitioned to 80 or so G of space 24 G's is used A. What is taking up this amount of space B. Not alot of packages are installed and shouldnt take up much space While a Python script

Re: [Tutor] Handling Generator exceptions in Python 2.5

2009-06-19 Thread Alan Gauld
"Joe Python" wrote *result = [(ListA[i] - ListB[i-1])/ListA[i] for i in range(len(ListA))]* The above generator, throws '*ZeroDivisionError*' exception if ListA[i] = 0. Is there a way to say 'Don't divide by ListA[i] if its equal to 0 (within that statement)'. You could use an 'or' sidef

Re: [Tutor] Tkinter idiosyncracies?

2009-06-19 Thread Alan Gauld
fter the handler exits which means both updates get done at the same time. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

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

2009-06-20 Thread Alan Gauld
"Tim Golden" wrote encrypted text file? I want to store passwords and associated contact information in a file and feel confident that if the file is stolen the information couldn't be read. If you're on Windows, just encrypt the file under Explorer. Although that's not very secure: if you

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

2009-06-22 Thread Alan Gauld
there must be a Security Now episode that explains the thing pretty well (could be this one http://www.grc.com/sn/sn-011.htm). Eek! I tried to read that but it was so garbled and basically illiterate that I gave up! It's the nearest thing I've seen to plain text encryption! Sample: """ We don't,

Re: [Tutor] filtering NaN values

2009-06-22 Thread Alan Gauld
OR mylist = [item/divisor for item in biglist if divisor != 0] # avoids the division If you can't do either of those then we need a bit more information about how the "NaN"s come about. -- Alan Gauld Author of the Learn to Progr

Re: [Tutor] extracting lines in large file

2009-06-22 Thread Alan Gauld
ems if there really is binary data in there but it might just work... -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] filtering NaN values

2009-06-22 Thread Alan Gauld
nteresting! How is a NaN stored in Python? ie. How do you get to the point of having one in the first place? Python continues is symbiosis with JavaScript... -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tuto

Re: [Tutor] Trouble with passing commands / variables to os.system()

2009-06-23 Thread Alan Gauld
can do directly - as well as how to use subprocess. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] string pickling and sqlite blob'ing

2009-06-24 Thread Alan Gauld
ou can't store it in the database directly or in chunks. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] intefaces in python

2009-06-28 Thread Alan Gauld
"Amit Sethi" wrote Hi , I don't suppose python has a concept of interfaces. Yes and No, I'll come back to that... But can somebody tell me if their is a way i can implement something like a java interface in python. First, can you tell me why you would want to? Java style interfaces tend

Re: [Tutor] syntax error

2009-06-28 Thread Alan Gauld
learn because v3 has introduced several new concepts (not just print() ) that are not covered in most tutorials. Once you understand Python 2.6 you will be in a better position to understamd v3s new features, and probably by then most tutorials will have caught up. -- Alan Gauld Author of the

Re: [Tutor] intefaces in python

2009-06-29 Thread Alan Gauld
using this for? I have found a few cases where abstract interfaces are useful but they are very few and far between. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.

Re: [Tutor] intefaces in python

2009-06-29 Thread Alan Gauld
"Amit Sethi" wrote Well I want to implement plug-in like mechanism for an application . I want to define some minimum functions that any body writing a plugin has to implement. For that i thought an interface would be best because in a scenario where the function is not implemented some kind

Re: [Tutor] intefaces in python

2009-06-29 Thread Alan Gauld
e you a great sense of freedom! -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] "Print" on 3.1 for Mac?

2009-06-29 Thread Alan Gauld
r code from 2.6 to 3. But if you are moving from 2.3 to 3 that is a big jump and you should definitely go to 2.6 as an interim step. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - T

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

2009-06-29 Thread Alan Gauld
"Robert Lummis" wrote I'm looking for a way to get boiler plate code into the main program file. Of course I could copy and paste it with an editor but I was hoping for something more pythonic. I know about import but that's not the same. Others have already pointed out import. Its also wo

Re: [Tutor] PYTHONPATH-corrected

2009-07-01 Thread Alan Gauld
y/modules" And you can add multiple directories by separating them with colons: export PYTHONPATH="/path/to/my/modules:/path/to/more/modules:/path/ytoyet/more" HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] Python Programming exercise

2009-07-01 Thread Alan Gauld
ause if for some reason (a bug say) the loop code changes the count beyond 3 your code will loop forever... HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] window graphics

2009-07-02 Thread Alan Gauld
"David H. Burns" wrote All the graphics libraries I've seen are far to complex (and don't seem compatible with 3. See the other posts re the wisdom of using Python 3 at this stage, however What I really need to know is two things (1) how to set up a graphic window from tkinter i

[Tutor] IDLE 3.0 menu weirdness

2009-07-02 Thread Alan Gauld
I tried posting this on the IDLE list but got no replies so I've been updating my online tutorial to Python v3. I've come across a weird "feature" of IDLE 3: The menus show as a pair of up/down arrows! Clicking the arrows does nothing obvious. If you select a menu and then hit the letter o

Re: [Tutor] printing tree structure

2009-07-03 Thread Alan Gauld
printTree( ['d', [], []], ['e', [], []] ) Root: e This is the start of printTree( ['e', [], [] ] ) --Subtree: [] --Subtree: [] Now why do you think the line you highlighted is an error? -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] IDLE 3.0 menu weirdness

2009-07-03 Thread Alan Gauld
"Yash" wrote I do not observe the problem on my installation of Python 3.0.1 I don't see any arrows. Also the shortcut keywords work fine Yes the shortcuts worked ok for me too, it was just the menus that were broken. I upgraded to v3.1 and everything is fine now. Definitely odd! Th

Re: [Tutor] list comprehension problem

2009-07-03 Thread Alan Gauld
issing out the call to enumerate(): for x in d: y += x dd.append(y) Should give the same result... List Comprehensions are not always the best answer. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] fnmatch -or glob question

2009-07-04 Thread Alan Gauld
s happening and what do you experct to happen? Are you finding any files? some files? too many files? Do you get an error message? -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python

Re: [Tutor] Is my style OK in this elementary student exercise?

2009-07-04 Thread Alan Gauld
ans[key] = val return ans I'm hoping you know about the security issues around using eval with raw_input? The use can input any valid python code and it will be evaluated! For experimenting its OK but in live code it would be very risky. HTH, -- Alan Gauld Author of

Re: [Tutor] Is my style OK in this elementary student exercise?

2009-07-04 Thread Alan Gauld
rint "That's not a Python expression!" break if not isinstance(key, key_typ): print "That's not a value of type", key_typ.__name__ else: # User has provided etc... HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Poor style to use list as "array"?

2009-07-05 Thread Alan Gauld
tually I'd probably go for a class but that's another ball game entirely!) -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python Tutorials: How to create useful programs afterlearning the syntax?

2009-07-06 Thread Alan Gauld
want to moderate your expectations for your first projects. teach me how I can use everything I learned about manipulating strings, creating classes, and importing modules and how to stir it all up into something meaningful. Hopefully my case study covers all of those. -- Alan Gauld Autho

Re: [Tutor] using datetime and calculating hourly average

2009-07-07 Thread Alan Gauld
y mean a bitwise and here? You are effectively bitwise anding two boolean values which seems odd to put it mildly... vals = X[ind,1][0].T try: hr_avg = np.average(vals) except: hr_avg = np.nan X_hr.append([hr,hr_avg]) hr = hr + dt.t

Re: [Tutor] using datetime and calculating hourly average

2009-07-07 Thread Alan Gauld
where()? And of course it could all be irrelevant since as Sander pointed out you can compare datetime objects directly... -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] mac os x executable

2009-07-07 Thread Alan Gauld
"Pete Froslie" wrote I'm having trouble finding good tutorials on creating standalone executable files for mac os x.. I've been looking at 'py2app', but can't seem get a solid grasp. Any help would be greatly appreciated! My first question would be do you need to? After all with Python 2.3

Re: [Tutor] mac os x executable

2009-07-07 Thread ALAN GAULD
rlying Unix shell and the interaction between icons on the desktop and the underlying files. A book like The Missing Manual for Mac OS X or almost any other in depth Moc OS X manual should explain what you need to know. But if you are taking the trouble to learn Python you really should learn

Re: [Tutor] using datetime and calculating hourly average

2009-07-08 Thread Alan Gauld
sising or 'and'ing will make it work. --> 196 ind = np.where( (Y[:,0]>t1) and (Y[:,0] Looks like the Y[:,0] value is not compatible with the time t1 or t2. What does print Y[:,0] produce? -- Alan Gauld Author of the Learn to

Re: [Tutor] Fwd: thesaurus

2009-07-09 Thread Alan Gauld
"Angus Rodgers" wrote parsing these two sentences: Time flies like an arrow. Fruit flies like a banana. Or the translation program that translated the expression Out of sight, out of mind from English to Russian and back with the result: Invisible, lunatic Alan G.

Re: [Tutor] thesaurus

2009-07-10 Thread ALAN GAULD
> right now, but Chinese apparently has no distinct verb forms for past, > present, > future. So they rely on other words to indicate which they might mean. Chinese also has the problem of relying on intonation to distinguish between identically spelled words. We have the same in English

Re: [Tutor] thesaurus

2009-07-11 Thread ALAN GAULD
> I am having trouble with probably the most simple part: > I cannot seem to go back into the 'txt' file and replace the word I just > searched with the new word! Its not a good idea to try to read and write to the same file at the same time. The normal approach is to weither ead the file into

Re: [Tutor] thesaurus

2009-07-12 Thread Alan Gauld
ly. The first benefit of functions is in encapsulating parts of your program and providing structure which makles it easier to read but the real power of functions is in making those blocks of code available to other programs too. Read my tutorial topic on Moduules and Functions more information. -- A

Re: [Tutor] segmentation fault

2009-07-12 Thread Alan Gauld
"Rick Pasotto" wrote using daily. Suddenly when I try to run it I get a segmentation fault. I'm running debian testing so probably some recent update caused the breakage. How can I find out what's gone wrong? Have you got the core file? If so you should be able to use gdb to examine the st

Re: [Tutor] find and replace relative to an nearby search string in afile

2009-07-13 Thread Alan Gauld
if exists: update path That way you have no dependency on the number of lines and the only tricky bit is if the path comes after the name Write1 line Or if there is no path line HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ __

Re: [Tutor] Pythonify this code!

2009-07-13 Thread Alan Gauld
y = 0 x = x + 1 else: y = y + 1 Again, this is repeated code so could go in a helper function. I didn't notice anything that would be v3 specific. Also I can't comment on the algorithm since I don't really know what its doing! HTH,

Re: [Tutor] Pythonify this code!

2009-07-13 Thread ALAN GAULD
Steganography's really neat! You should look into it. > > I did a quick lookup on Wikipedia. > Basically what his code does is takes an image, and it twiddles the least significant bits > > Interestingly when I was at university the head of signal processing was into crypto stuff and was look

Re: [Tutor] Saving class instances

2009-07-13 Thread Alan Gauld
projects. For simpler programs things like Pickle and Shelve are probably the simplest and best solutions. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/m

Re: [Tutor] gtk.Notebook error

2009-07-13 Thread Alan Gauld
n I do this I get a warning : smnotebook.py:18: GtkWarning: Can't set a parent on widget which has a parent. Do you get a full stack trace or just that one lline? It always helps to see the full trace if its there. HTH, -- Alan Gauld Author of the Learn to Program web sit

Re: [Tutor] browser encoding standards?

2009-07-13 Thread Alan Gauld
from those more familiar with the vagaries of multiple encodings on the web... -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] browser encoding standards?

2009-07-13 Thread Alan Gauld
gests: Would that suffice? -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] While and for loops

2009-07-14 Thread Alan Gauld
er buts it is far less efficient and less flexible! HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Saving class instances

2009-07-14 Thread Alan Gauld
"Thomas Scrace" wrote Good to know I wasn't being totally dense. Now that I have got the pickle thing under my belt I am going to have a go at sqllite. Again, you might find the database topic ijn my tuorial a useful starting point for using SqlLite from Python...

Re: [Tutor] How to pass command line variables to this python code...

2009-07-14 Thread Alan Gauld
cessing command line args. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] objects becoming pointers

2009-07-16 Thread Alan Gauld
name = raw_input("Which name was it?") print names[name] or even: for name in names: print names[name] HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] help

2009-07-16 Thread Alan Gauld
? If so you can use the else clause of a while loop: while x > 0 and y > 0: choice = raw_input('x or y?') if choice == 'x': x = 0 else: y = 0 else: if x <= 0: print 'it was x' else: print 'it was y' HTH, -- Alan

Re: [Tutor] weather scraping with Beautiful Soup

2009-07-16 Thread Alan Gauld
o check you have the right place. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] how to join two different files

2009-07-17 Thread Alan Gauld
se it looks like you will need to process each file line by line and concatenate each string. for line1 in fileA: line2 = fileB.readline() fileC.write("%s\t%s" % line1,line2) You might need to strip the lines before writing them... -- Alan Gauld Author of the Learn to Progra

Re: [Tutor] sending to file

2009-07-17 Thread Alan Gauld
= cgi.escape(os.environ["REMOTE_ADDR"]); Time = "(time.localtime()):", time.asctime(time.localtime()) entry = name + '|' + email + '|' + address + '|' + telephone + '|' + IpAddress + '|' + Time + "\n" We'll have m

Re: [Tutor] large strings and garbage collection

2009-07-17 Thread Alan Gauld
or speed fmt = "%s" * len(biglist) s = fmt % tuple(biglist) Just some ideas... -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] python interpreter vs bat file

2009-07-18 Thread Alan Gauld
commansds or are you starting it some other way? Can you clarify please? -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

<    7   8   9   10   11   12   13   14   15   16   >