Re: [Tutor] Passing perimeters in dictionary values?

2009-02-24 Thread Alan Gauld
"nathan virgil" wrote I'm not familiar with lambdas yet, and I don't think this book will introduce me to them; they aren't listed in the index, anyway. lambda is just a fancy mathematical name for a simple concept - its a block of code, like the body of a function. In Python its even simp

Re: [Tutor] Passing perimeters in dictionary values?

2009-02-25 Thread Alan Gauld
"nathan virgil" wrote Whenever I try to use the talk method (which reports the mood, and doesn't take parameters), it says I gave it too many parameters. Sorry, I should have pointed out that you will need to redefine all your functions to accept a parameter. Alan G ___

Re: [Tutor] overwriting input file

2009-02-25 Thread Alan Gauld
"Bala subramanian" wrote query 1) How should i overwrite the input file I want to open 5 files one by one, do some operation on the lines and write the modified lines on the same file (overwritting). Can some please tell me how to do it. You don't really want to do that! Too risky. Better

Re: [Tutor] learning new features of python

2009-02-26 Thread Alan Gauld
"Bala subramanian" wrote Is there any website/tutorial that explains new features that are constantly getting embedded in python. The documentation for each release has a whats new document that is always worth reading. Similaraly in Alan Guald Learn to program link, he has given informat

Re: [Tutor] learning new features of python

2009-02-26 Thread ALAN GAULD
> >> Similaraly in Alan Guald Learn to program link, he has given information > >> on opening a file with file() and open() functions. > > > > And in V3 they took that back out again :-( > > ?? open() is in V3. file() is not. That's right, they have reverted to how it was in Python 1.X I changed

Re: [Tutor] Class definition...

2009-02-26 Thread Alan Gauld
"Spencer Parker" wrote I am looking for a good tutorial to walk through that really explains class definition. This has been one sticking point that always messes me up I assume from that you have been through the basic tutors like mine? Have you tried the deeper material in Dive into Pyt

Re: [Tutor] setting PYTHONPATH on mac

2009-02-27 Thread Alan Gauld
wrote how does one go about setting a PYTHON path environment variable on Mac OS X 10.4? Your subject asks about PYTHONPATH, your text asks about PATH. These are two different things. Which do you want to know about? PATH is how Unix (ie MacOS aka Darwin) finds your Python interpreter PYTHO

Re: [Tutor] re Format a file

2009-02-27 Thread Alan Gauld
"prasad rao" wrote for line in so: if len(line)<70:de.write(line+'\n') if len(line)>70: da=textwrap.fill(line,width=60) de.write(da+'\n') What happens if the line is exactly 70 characters long? I think you want an else instead of the second

Re: [Tutor] Passing perimeters in dictionary values?

2009-02-27 Thread Alan Gauld
"Richard Lovely" wrote > Sorry, I should have pointed out that you will need to redefine > all your functions to accept a parameter. Always makes me smile when (experienced) people redesign the wheel... From the docs (http://www.python.org/doc/2.6/library/functools.html): "The partial() is

Re: [Tutor] concatenating files

2009-02-27 Thread Alan Gauld
"Bala subramanian" wrote I have file1.dat,file2.dat...file 300.dat in one directory. I want to concatenate all the files in a single file (total.dat) with a string "END" separating the file contents. my total.dat should be file1.dat contents END file2.dat contents END file300.dat

Re: [Tutor] concatenating files

2009-02-27 Thread Alan Gauld
"Bala subramanian" wrote I have file1.dat,file2.dat...file 300.dat in one directory. I want to concatenate all the files in a single file (total.dat) with a string "END" separating the file contents. If you are on Linux (or other *nix variant) you may be better off using the shell... fo

Re: [Tutor] Auto Refresh

2009-02-27 Thread Alan Gauld
"Hi" wrote In my main GUI: def refresh(self, event): x = refresh_var() value = wx.StaticText(self, -1, str(x.var_rate)) Its not clear how you are positioning Static Text, I suspect you need it as a opart of your main GUI and then reference it in here and use the SetLabel() method to update

Re: [Tutor] Not Storing State

2009-02-27 Thread Alan Gauld
"Stephen Nelson-Smith" wrote I want to iterate over a bunch of lines; for line in If any line contains a certain string, I want to do something, otherwise do something else. if in line: doSomething() else: doSomethingElse() I can store state - eg line 1 - did it contain th

Re: [Tutor] new print statement + time module

2009-02-28 Thread Alan Gauld
"George Wahid" wrote Thanks for the answers. I didn't have this problem with python 2.5. I know I can use stdout instead, but I want to know what I'm doing wrong. You aren't doing anything wrong. The print function writes to sys.stdout. sys.stdout is a buffered file which means it doesn''t

Re: [Tutor] modular program

2009-03-01 Thread Alan Gauld
"Daniele" wrote I'd like to write a python program which can be easily extended by other people. Where can I find some "best practices" for writing modular programs? Try reading wikipedia. Try looking under "modular", "coupling" and "cohesion" You could also try "Frameworks" I thought abou

Re: [Tutor] Returning the IDLE Shell Window to Prompt

2009-03-01 Thread Alan Gauld
"Wayne Watson" wrote My Tkinter program can crash at this stage, and the shell window is locked from text entry, and the GUI displayed. I can kill the window by using X in the corner, and responding to a few dialogs. There must be another way. There are lots of ways to kill an errant progra

Re: [Tutor] Tutor Digest, Vol 61, Issue 3

2009-03-01 Thread Alan Gauld
"Daniele" wrote With module here I meant plug-in or extension: a piece of code written by someone else that can be easily (and automaticallly) integrated into my program. OK, To do that you need to provide an intrerface in your code that the plug-in can use. That is to say you must call a d

Re: [Tutor] [Edited] Plug-in enabled Program

2009-03-02 Thread Alan Gauld
"Daniele" wrote have is how to adapt it to multiple plugins related to the same interface. There are a few approaches. There is a design pattern (facade from memory) that allows this but you can also implement the plugin calls as a list of objects. So instead of calling theInteface.foo

Re: [Tutor] Configuration File, Tkinter, IntVars--Manufacturing Variables

2009-03-03 Thread Alan Gauld
"Wayne Watson" wrote see my post of yesterday, "Maintaining the Same Variable Type--Tkinter", went over like a lead balloon. :-) Yeah, I had no idea what you meant :-) I've heavily modified the original code to accept a config file, and set up variable to initialize the widgets, trying to

Re: [Tutor] Configuration File, Tkinter, IntVars--Manufacturing Variables

2009-03-03 Thread Alan Gauld
"Wayne Watson" wrote BTW, the Quit function is original but doesn't kill the window when Quit is used. Does that include running from the command console? Is this another IDLE/Tkinter issue maybe? Alan G. ___ Tutor maillist - Tutor@python.

Re: [Tutor] Configuration File, Tkinter, IntVars--Manufacturing Variables

2009-03-03 Thread Alan Gauld
destroy() took care of it, but I wonder what advantage there was to Quit()? destroy destroys the widget, quit exits the main loop. destroying the top level widget usually causes the mainloop; to die too so the end result is the same (provided you have no non-modal dialogs open?). HTH, Ala

Re: [Tutor] Configuration File, Tkinter, IntVars--Manufacturing Variables

2009-03-03 Thread Alan Gauld
"Wayne Watson" wrote Comments? class IntVar_GUI: I just noticed the name of the class. This kind of implies that you are intending writing GUIs for each data type? That shouldn't be necessary since the inputs will be strings in each case. You only need to call the appropriate conversion

Re: [Tutor] Configuration File, Tkinter, IntVars--Manufacturing Variables

2009-03-03 Thread Alan Gauld
"Wayne Watson" wrote Note though the use of control variables like IntVar, etc. FWIW. Personally I never use those "convenience" features of Tk. I prefer to explicitly set and get them myself. Alan G ___ Tutor maillist - Tutor@python.org http

Re: [Tutor] What is this [] construction?

2009-03-03 Thread Alan Gauld
"Andre Engels" wrote What is this: d = [ int(x) for x in s.split(":") ] That's called list comprehension. The notation [f(x) for x in A if p(x)] means: Form a list in the following way: For Wayne's benefit... You will also find a similar construction in parens called a generator expressio

Re: [Tutor] Configuration File, Tkinter, IntVars--Manufacturing Variables

2009-03-04 Thread Alan Gauld
"Wayne Watson" wrote One starts it by double clicking on the py file. And just to be clear, it exits OK when you run it that way? I would expect so since that's the normal way to run a Tkinter program. IDLE is only intended to be a development tool not a runtime program. Nope. I just t

Re: [Tutor] Configuration File, Tkinter, IntVars--Manufacturing Variables

2009-03-04 Thread Alan Gauld
"Wayne Watson" wrote There's another way? Sure, just create normal Entry widgets and capture the input string and convert/assign it as you would a string captured from raw_input() in a console. No magic required. Its slightly more code but I find the auto assignment of values to variab

Re: [Tutor] Code documentation

2009-03-04 Thread Alan Gauld
"Carlos Daniel Ruvalcaba Valenzuela" wrote which approach should I take on documentation (API docs) for a python library I have been working on, there is currently code docstrings, docstrings are the minimum since they show up on help() docstrings with some markup (epydoc, etc), or extern

Re: [Tutor] What is this [] construction?

2009-03-04 Thread Alan Gauld
"Kent Johnson" wrote In Python v3 list comprehensions and generator expressions have been "merged" in that putting a GE inside [] has the same effect as a LC. I think you mean this (from http://docs.python.org/3.0/whatsnew/3.0.html): Yeah, that's what I was thinking about but my memory p

Re: [Tutor] Configuration File, Tkinter, IntVars--Manufacturing Variables

2009-03-04 Thread Alan Gauld
"Wayne Watson" wrote I'm not sure what normal is. Do you have an example, Is this what you have in mind ? =start from Tkinter import * master = Tk() e = Entry(master) e.pack() e.focus_set() def callback(): print e.get() b = Butto

Re: [Tutor] wxPython vs PyQt

2009-03-04 Thread Alan Gauld
"Neven Gorsic" wrote I read also that none of them are even near as good as Delphi or VB. Is it really so? I had a look around various GUII building tools for wxPython but none of them were near Delphi/VB standard. I've never used pyQT or even vanilla Qt so the idea of learning yet another G

Re: [Tutor] wxPython vs PyQt

2009-03-04 Thread Alan Gauld
"Kent Johnson" wrote I've heard good things about Dabo, never tried it myself though. http://dabodev.com/ I looked at Dabo but decided not to try it since it was yet another framework. Although it's based on wxPython they have layered their own widgets on top which is what the GUI Builder

Re: [Tutor] A Simple Tkinter Control Program--Slight Problem

2009-03-05 Thread Alan Gauld
"Wayne Watson" wrote Here's what I think the author meant in discussing a control variable sample program. from Tkinter import * v=StringVar() e = Entry(master, textvariable=v) AG >> No master defined... you need AG >> mas

Re: [Tutor] Designing Tools/books

2009-03-05 Thread Alan Gauld
"amit sethi" wrote problem only seems to come during documentation but i believe this will be a pain when i do this professionally.So my question is please guide me to good internet resources ,books and tools that talk about design especially with python in mind. I don't know of any that

Re: [Tutor] Misunderstanding the Entry Widget

2009-03-06 Thread Alan Gauld
"Wayne Watson" wrote Apparently Entry does not have a callback. Thats the magic of Control Variables. They automatically get populated when the user enters data into the Entry widget. But since Entry widgets are usually part if a form and there will be several of them its more useful to

Re: [Tutor] Misunderstanding the Entry Widget

2009-03-07 Thread Alan Gauld
"Wayne Watson" wrote > Can you easily construct a simple example where they are absolutely necessary, or at least provide a situation where they are necessary? I don't think you can. They are a convenience feature not a necessity. But the same can be said of standard dialogs, message boxe

Re: [Tutor] print problem python

2009-03-07 Thread Alan Gauld
"mustafa akkoc" wrote i start learning pyton language i want to print some thing but when i type : print "hello world" but it give an error like this SyntaxError: invalid syntax (, line 1) i am using python shell version 3.0.1 If you are new to programming as well as Pyton I recommend yo

Re: [Tutor] could someone explain why this happens to me.

2009-03-07 Thread Alan Gauld
"Emad Nawfal (عماد نوفل)" wrote As a linguist, I would love to know what the difference between these things are: The differences are the same whether you are a linguist or not :-) (and yes I know my reading is incorrect grammaticallly but I couldn't resist it!) mycopy = original[:] Re

Re: [Tutor] Misunderstanding the Entry Widget

2009-03-08 Thread Alan Gauld
"Wayne Watson" wrote Signature.htmlAnother thought occurred to me about this situation. Suppose I have a dialog with two Entry objects in a dialog object called TwoEntries: entry1 = Entry(master, width=10).grid(row=4, column=1) entry2 = Entry(master, width=10).grid(row=5, column=1) and

Re: [Tutor] Misunderstanding the Entry Widget

2009-03-08 Thread Alan Gauld
"Wayne Watson" wrote Yep, when I bowed of programming long ago, I had Ousterhout's (something like that) book, and finally sold it on Amazom 5 years ago It was a good book in its day but is now well overdue an update. The book I'd recommend getting is Tcl/Tk in a Nutshell from O'Reilly Its

Re: [Tutor] Misunderstanding the Entry Widget

2009-03-08 Thread Alan Gauld
"Alan Gauld" wrote Yep, when I bowed of programming long ago, I had Ousterhout's It was a good book in its day but is now well overdue an update. And lo and behold, listed on Amazon is the 2nd edition due in August 2009! How's that for service :-) BTW I also notice

Re: [Tutor] while loop problem

2009-03-08 Thread Alan Gauld
"mustafa akkoc" wrote hello i have syntax problem in this program #!/usr/bin/python # Filename: while.py number = 23 running = True while running : guess= input('Enter an integer : ') # it give a syntax error this line can you me ? Always post the full text of error messages please. It h

Re: [Tutor] Misunderstanding the Entry Widget

2009-03-08 Thread Alan Gauld
"Alan Gauld" wrote I think Tkinter needs an update too, there seem to be quite a few new Tk widgets that are not available in Tkinter... or is it just that they are not documented? I must have a poke around in v2.5... I spoke too soon, its just the documentation needs an update

Re: [Tutor] UNSUBSCRIPTABLE?

2009-03-09 Thread Alan Gauld
"WM." wrote Well, Mr. Wilkins takes the biscuit. He found where I did not enter a pair of parens.() But do you understand *why* you got the error and what it was telling you? Pyton's error message told you exactly what you had done wrong although you may not have quite understood it. But do

Re: [Tutor] probelm pyhton shell doesnt open help please

2009-03-09 Thread Alan Gauld
"mustafa akkoc" wrote it gives this message socket error This used to happen in older versions of IDLE. What version of Python are you using? If possible upgrade to v2.5 or later. If not you probably need to tweak your firewall settings to open a particular port - but I can't recall whic

Re: [Tutor] Long list error

2009-03-09 Thread Alan Gauld
"William Stephens" wrote I was working on a sieve of eratosthenes and ran into an error I don't understand. >>> size = 100 >>> l = [0,1]*(size/2) OverflowError: cannot fit 'long' into an index-sized integer Is there a type or something that I can do to prevent this error? The prob

Re: [Tutor] problem with an anagram program

2009-03-09 Thread Alan Gauld
"jessica cruz" wrote I just started learning python an I'm currently working on this program. The purpose of this program is to read a string of letters from user input and print out all the words which are anagrams of the input string. Where you define an anagram to be a word that is in

Re: [Tutor] i can only write one line of code on python shell helpplease ?

2009-03-09 Thread Alan Gauld
"mustafa akkoc" wrote - In python shell , i can only write one line of code when I go to next line this sign appears >>> how can write the code like in script mode and run You can't. Shell mode means you are entering code directly into the interpreter so it executes the code line by li

Re: [Tutor] Newby Linux Program review + help with regular expressions

2009-03-09 Thread Alan Gauld
"David" wrote and compare with others, ask for help etc. Am I using the subrocess module too much because I am comfortable with the commands? Should I just write this type of program in bash. Personally I'd use bash for this kind of thing. If you wanted to post process the report then I'd u

Re: [Tutor] Tutor Digest, Vol 61, Issue 32

2009-03-09 Thread Alan Gauld
"WM." wrote From: "Alan Gauld" Pyton's error message told you exactly what you had done wrong although you may not have quite understood it. But do you now see what the error message was telling you when it said: ... Can you understand it clearly enough that when

Re: [Tutor] memory error

2009-03-10 Thread Alan Gauld
"Harris, Sarah L" wrote fname=filter(isfile, glob.glob('*.zip')) for fname in fname: This will confuse things. fname starts off as a list of files and then becomes a single filename inside the loop. It's never a good idea to duplicate variable names like that. It also means that after th

Re: [Tutor] Binary to Decimal conversion

2009-03-10 Thread Alan Gauld
"A.T.Hofkamp" wrote If you reverse the computation, it gets even simpler: binstr = raw_input("Please enter a binary number: ") decnum = 0 for i in binstr: decnum = decnum * 2 + int(i) But if we are allowed to use int() it is easier still: decnum = int(raw_input("Please enter a binar

Re: [Tutor] memory error files over 100MB

2009-03-10 Thread Alan Gauld
"Harris, Sarah L" wrote However I still have a memory error when I try to run it on three or more files that are over 100 MB? And this surprises you? :-) How much memory do you have free on your computer when you run this? newFile.write(zf.read(zfilename)) Remember you are re

Re: [Tutor] memory error files over 100MB

2009-03-10 Thread Alan Gauld
"Sander Sweers" wrote out again in a single operation, that will use twice the space of the uncompressed files - plus some extra for overhead. Question, Do you mean the file in the zipfile (zfilename) or the whole zipfile (zf)? I would expect zf.read(zfilename) to only read the requested

Re: [Tutor] How can I extract a specific sublist from a nested list?

2009-03-11 Thread Alan Gauld
"Emad Nawfal (عماد نوفل)" wrote How can I extract a specific sublist (??) from a nested list, Just extract eaach item using indexing. So first extract the sublist, then from the sublist extract the item. if I want to extract the sublist ["ADJ", "good"], or the bigger sublist ["NP",["DET", "T

Re: [Tutor] reading lists from a text file

2009-03-12 Thread Alan Gauld
"Emad Nawfal (عماد نوفل)" wrote If there is a text file that has a list or number of lists in it, is there is a way to read the lists in the file as lists, and not as a string. Sample file attached. Not that I know of. If you made the file include assignments to variables or one big list

Re: [Tutor] Sorting large numbers of co-ordinate pairs

2009-03-12 Thread Alan Gauld
"Dinesh B Vadhia" wrote Have a large number (> 1bn) of integer co-ordinates (i, j). I want to create (j, i) with j ordered and i unordered ie. I've tried the dictionary route and it works perfectly for small set of co-ordinate pairs but not for large sets as it hits memory capacity. One

Re: [Tutor] Simple User Entry Verification

2009-03-14 Thread Alan Gauld
"Ian Egland" wrote Newbie here who can't figure out why this doesn't work: It worked perfectly for me. But then, maybe I expected it to do something different to what you expected? When posting please tell us what you expected to happen, what actually happened plus any error messages (in ful

Re: [Tutor] How to only give the user so much time to enter response?

2009-03-15 Thread Alan Gauld
"james carnell" wrote Trying to use Timer in console based game that gives the user so much time to act. Thats quite tricky in standard console mode. If you were on Linux (or MacOS?) you could use curses and I think it would be easier there. But on XP I think you may have to get into the

Re: [Tutor] Need Assistants with Python Please

2009-03-15 Thread Alan Gauld
"Jared White" wrote So far ive come up with this code. But it seems not to be working, Can someone please help me figure out what ive done wrong def main (): print "The program converts Miles Per Gallon (US) to Liters Per 100 Kilometer." kilometers = input ("What is the Miles Per Ga

Re: [Tutor] Help With Rock, Paper Scissor Game

2009-03-16 Thread Alan Gauld
"Brendy Siguenza" wrote This is the template that we are suppose to use while doing the program, I am a beginner to this programming language and really have no clue what I am doing We don;t do homework problems for you but we can try to point you in the right direction. First off, it loo

Re: [Tutor] way of dictating leading zeros

2009-03-16 Thread Alan Gauld
"Patrick" wrote Is there an easy way to dictate how many digits a number will occupy that also allows for leading zeros? Andre showed you the way to do this using "String Formatting". Search for that phrase in the docs for al lot more info. If you are considering using Python v3 then that st

Re: [Tutor] Paython as a career

2009-03-17 Thread Alan Gauld
"Hussain Ali" wrote 1) Where does python stand as compared to other programming languages? That depends on how you measure it. On functionality? On popularity? On number of active projects on Sourceforge? How do you measure "standing"? 2) What is the future for python? I don't have psy

Re: [Tutor] Making exe Python file - standalone executable file

2009-03-17 Thread Alan Gauld
"Neven Gorsic" wrote Py2exe i standard way (up to my knowledge) of making standalone executable Python file in order to distribute your program to others who don't have Python installed It is one of several ways to do that for those who believe that it is more advantageousd that simply packag

Re: [Tutor] escaping newline (was: (no subject))

2009-03-17 Thread Alan Gauld
"A.T.Hofkamp" wrote Some people like the following layout if long_function_name(a) == long_function_name(b) and \ long_function_name(c) == long_function_name(d) and \ long_function_name(e) == long_function_name(f): # do something if all three equalities hold I prefer to use paren

Re: [Tutor] (no subject)

2009-03-17 Thread Alan Gauld
"Jared White" wrote howmany = int(raw_input('How many lines ')) rhowmany = howmany what does rhowmany do? strout = '*' while howmany > 0: print strout strout += '*' howmany -= 1 Combine the two hints so far to improve it, then look even more closely at range() to see how to do

Re: [Tutor] list.replace -- string.swap

2009-03-17 Thread Alan Gauld
"spir" wrote Is there a list.replace builtin I cannot find? Or a workaround? myList[x] = newValue Or is that too obvious? Also: How would perform string.swap(s1, s2) in the following cases: * There is no secure 'temp' char, meaning that s.replace(s1,temp).replace(s2,s1).replace(temp,s2)

Re: [Tutor] combining Python 2.x and Python 3

2009-03-17 Thread Alan Gauld
"Andre Engels" wrote I have an open source project I have done some work on, which is programmed in Python 2.3-2.6. I would like to change it so that it can be run under both Python 3 and Python 2.x. That will be tricky. I think you can pretty much make Python 3 code that can run under v2.

Re: [Tutor] Python and Tkinter Programming by Grayson--New Version?

2009-03-17 Thread Alan Gauld
"Wayne Watson" wrote I've poked around at the pieces of the book in Subject, which are on the web It was published in 2000, first ed. It looks quite good, and certainly is big, About a third of it is reference material. Not a bad thing, I use it a lot, but other sources have the same stuff.

Re: [Tutor] Checking Entry Values in Tkinter Widgets

2009-03-17 Thread Alan Gauld
"Wayne Watson" wrote The program I'm modifying uses something of a primitive way to check the validity of values entered into widgets on a larger dialog. You can bind events to the individual entry widgets to check values when you navigate away from the widget. Or even on each keypress... .

Re: [Tutor] Fun with Label and Entry--Why NoneType?

2009-03-17 Thread Alan Gauld
"Wayne Watson" wrote Yet the print "here" statement produces: here None I'm missing something. The NoneType causes the print of the self.lat to fail with get(). self.long=Entry(master, width=12).grid(row=0, column=3) The placement methods(pack, grod etc) all return None. You m

Re: [Tutor] Python and Tkinter Programming by Grayson--New Version?

2009-03-17 Thread Alan Gauld
"Chris Fuller" wrote easy to use, and comes included with Python. Serious programmers will probably want something faster, better looking, and with nicer features, The next versions of Python/Tkinter will apparently be based on the new widget set of Tk which has native look n feel on eac

Re: [Tutor] Fun with Label and Entry--Why NoneType?

2009-03-17 Thread Alan Gauld
"Wayne Watson" wrote got shelled by: dialog = DialogPrototype(root) TclError: window ".60529560" was deleted before its visibility changed Thats the result of withdraw I think Try reversing the calls: root = Tk() dialog = DialogPrototype(root) root.withdraw() That way the withdraw

Re: [Tutor] Python and Tkinter Programming by Grayson--New Version?

2009-03-17 Thread Alan Gauld
"Chris Fuller" wrote What sets Pmw apart is the framework it provides for the creation of your own megawidgets. I can't comment on the PMW framework and I haven't tried it in Python Tix but the Tcl documents claim Tix does a similar thing. Certainly insofar as it provides a framework for cr

Re: [Tutor] Checking Entry Values in Tkinter Widgets

2009-03-17 Thread Alan Gauld
"Wayne Watson" wrote Yes, apply is invoked when I click OK. apply has one statement, and returns to the caller, which then checks the validity (try-except) of values passed back to it. It seems like apply should do all the try-except work instead. Yes, I'd agree that is how it should work.

Re: [Tutor] Fun with Label and Entry--Why NoneType?

2009-03-17 Thread Alan Gauld
"Wayne Watson" wrote Unfortunately, that takes me back to the original situation. That is, the blank window appears along with the dialog window. OK Try this version: # Derived from Grayson 5_14.py from Tkinter import * from tkSimpleDialog import Dialog class DialogPrototype(Dialog):

Re: [Tutor] Fun with Label and Entry--Why NoneType?

2009-03-17 Thread Alan Gauld
"John Fouhy" wrote Unfortunately, that takes me back to the original situation. That is, the blank window appears along with the dialog window. It also ends badly with I didn't notice any call to root.mainloop() in your original code. Are you calling mainloop() anywhere? I noticed that to

[Tutor] Fw: list.replace -- string.swap

2009-03-18 Thread ALAN GAULD
Forwarding to list > From: spir > To: Alan Gauld > Sent: Wednesday, 18 March, 2009 8:41:39 AM > Subject: Re: [Tutor] list.replace -- string.swap > > Le Tue, 17 Mar 2009 20:46:06 -0000, > "Alan Gauld" s'exprima ainsi: > > "spir" wrote &

Re: [Tutor] Python and Tkinter Programming by Grayson--New Version?

2009-03-18 Thread ALAN GAULD
e to: gmane.comp.python.tkinter Or on the web at: http://dir.gmane.org/gmane.comp.python.tkinter or go to http://mail.python.org/mailman/listinfo/tkinter-discuss to sign up for the emails. HTH, Alan Gauld Author of the Learn To Program website http://www.alan-g.

Re: [Tutor] Fun with Label and Entry--Why NoneType?

2009-03-18 Thread ALAN GAULD
> That change got the same result. Maybe this will make it all clearer. > When the prompt appears, there is a small window showing on the > screen, 2x2", Yes, that's the root window that Python expects you to put your GUI into. The master that you pas to your GUI wFrames. It didn't show for me

Re: [Tutor] Executing a C Program from RH Linux in Python for Win

2009-03-18 Thread Alan Gauld
"Wayne Watson" wrote The Subject contains the interest here. Can it be done? A C program is compiled into a binary executable complete with link loader. The executable is not portable across operating systems (nor hardware architectures in most cases) I think it this case it requires execu

Re: [Tutor] Fw: list.replace -- string.swap

2009-03-18 Thread ALAN GAULD
It wasn't my question :-) Forwarding to list... Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ - Original Message > From: Ricardo Aráoz > Subject: Re: [Tutor] Fw: list.replace -- string.swap > > > >>>> Also: How woul

Re: [Tutor] Python and Tkinter Programming by Grayson--New Version?

2009-03-18 Thread Alan Gauld
"Wayne Watson" wrote As I wander around the internet trying to get info from Lundh, New Mexico, and other sites, I wonder if, in particular New Mexico is not using the "new" Tkinter. How would I know? Nobody is using the new version yet, it's targetted for 3.1 and 2.7 - both are the "next" r

Re: [Tutor] Playing with CENTER, Grid, Labels and Entry

2009-03-18 Thread Alan Gauld
"Wayne Watson" wrote I'm using Grid. It's gone pretty well, but I'd like to make it "prettier". For that Frame is usually your friend. Create your widgets inside frames and then pack or grid the Frames. You can then use a combination of padding, filling and anchoring etc in both way you inse

Re: [Tutor] Executing a C Program from RH Linux in Python for Win

2009-03-19 Thread Alan Gauld
"Wayne Watson" wrote If you can execute a C program compiled on a Linux with SWIG, then that's what I'm looking for. Nope, you need the suprocess module not SWIG. What SWIG does (fairly easily!) is allow you to build a wrapper around your C program that python can import and call the C fun

Re: [Tutor] Executing a C Program from RH Linux in Python for Win

2009-03-19 Thread ALAN GAULD
> likely will allow the user to enter the 12 or so parameters > on the command line, and execute the program as though > I had entered it at a Linux prompt. OK, In that case you only need the call() convenience function from the subprocess module. Capture the arguments in your GUI and build t

Re: [Tutor] Tkinter Geometry Management and Other Basics

2009-03-19 Thread Alan Gauld
"Wayne Watson" wrote As I understand it, there are three geometry managers: Grids, Pack and Place. Only the first two are of interest. Yes and a new Form one coming in the next Tk release... Is it possible to mix them? I don't think so, Yes but not in a single Frame. But my normal appro

Re: [Tutor] Executing a C Program from RH Linux in Python for Win

2009-03-20 Thread Alan Gauld
"Wayne Watson" wrote What is meant by "The arguments are the same as for the Popen constructor.", in Convenience Functions? In fact, what is such a function? It means that there is a function which takes the same arguments as the __init__() method of the Popen class. They are convenience f

Re: [Tutor] Tkinter Geometry Management and Other Basics

2009-03-20 Thread Alan Gauld
"Wayne Watson" wrote I really don't want to spend weeks learning Tk/Tcl. You shouldn't need to. The Tk documentation is very easy to transfer to Tkinter: Here is a sample from the official reference docs for Label (found at: http://www.tcl.tk/man/tcl8.5/TkCmd/contents.htm): STANDARD

Re: [Tutor] Tkinter Geometry Management and Other Basics

2009-03-20 Thread Alan Gauld
"Alan Gauld" wrote It really is quite easy. Too few Tkinter programmer shy away from the Tcl/Tk sites because they think they need to know Tcl. Ahem, that should have said too *many* of course not too few Sorry, Alan G ___

Re: [Tutor] Distributing MySQL with my application

2009-03-21 Thread Alan Gauld
"Lauren Snyder" wrote I have written an application in python that uses a MySQL database. I want to distribute this application to many users so I created an executable 1. Is it possible to bundle the database into my application? It may be possible but it is unusual. Normally the databas

Re: [Tutor] Opening a cmd.exe

2009-03-22 Thread Alan Gauld
"Sigga Sig" wrote I am writing a code that is supoesed to act as routers and i need to open a different cmd window for each one of them with it's name and so on. I do not know how to implement in mi Python cod a sentece that opens such a cmd. I know how to open a cmd.exe bud not with specif

Re: [Tutor] Opening a cmd.exe

2009-03-22 Thread Alan Gauld
"Mark Tolonen" wrote Does this do what you want? It creates a new cmd window titled "Dir", then executes some commands. import os os.system('start cmd /c title Dir ^&^& dir ^&^& pause') It didn't do quite what I expected, but it made me look at the help for start, which says: ==

Re: [Tutor] Inspiration/examples

2009-03-22 Thread Alan Gauld
"Mathias Andersson" wrote Im currently trying to learn how to use python. But my only problem seems to be at what to make? I have a list of ideas in my tutor appendix References, Books and Projects Also there is the Python Challenge "adventure game" And finally the Useless Python site h

Re: [Tutor] Syntax error

2009-03-23 Thread Alan Gauld
"John Jenkinson" wrote I am trying to write a program that displays the string expression "Game Over", in a console window that remains open. print "Game Over" raw input("\n\nPress the enter key to exit.") I dont understand what is supposed to happen if the code were to be correct. Would a

Re: [Tutor] no output

2009-03-23 Thread Alan Gauld
"John Jenkinson" wrote My Code: # Game Over - Version 2.0 # Demonstrates the use of quotes in strings print "Program 'Game Over' 2.0" raw_input("\n\nPress the enter key to exit.") shell's response: >>> RESTART See my re

Re: [Tutor] returning values from function.

2009-03-23 Thread Alan Gauld
"Bala subramanian" wrote I wrote the following code to create two different list. One containing data points of all clusters and another containing list of individual cluster data points. The script is as follows. data=[] # list of all data points all=[ [] for value in range(int(argv[2])) ]

Re: [Tutor] (no subject)

2009-03-23 Thread Alan Gauld
"Jared White" wrote Help If u can please i got this code to work for the top half You were already given a couple of hints on how to maker this easier but you seem to have ignored both of them Look again at using a for loop and the range() function. Then look at printing a string usin

Re: [Tutor] library for files information

2009-03-23 Thread Alan Gauld
"Shining Wisdom" wrote Hi, i want to write a script that copy file from a folder on my hdd to a usb thumb drive based on the time the file was created. Just need help to find which library to google... You don't need much. The os.path module will give you the creation time. The time module

Re: [Tutor] Distributing MySQL with my application

2009-03-23 Thread Alan Gauld
"Lauren Snyder" wrote 1. how do I create a database that is not in users localhost? Currently I just use MySQL's "create [database]" command after I connect using MySQLdb.connect The connect string should include the machine/port information. Alan mentioned something about "Do you not use

Re: [Tutor] text editor and debugger for python

2009-03-24 Thread Alan Gauld
"Bala subramanian" wrote I do the scripting in Linux. I use vi editor to code. It is not very convenient for me. Can you tell us what is not convenient? That would heklp us recommend other editors. There are dozens to choose from and vi(or vim) is one of the most powerful around, so if y

<    4   5   6   7   8   9   10   11   12   13   >