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

2009-03-17 Thread wesley chun
> I think the intent of 2to3 is that you maintain the > Python 2.6 version and automatically create the Python 3 version from > it. So there is only one source file. At least one person found this > practical, for a large codebase (well, he says it "mostly works"): > http://wiki.python.org/moin/Por

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

2009-03-17 Thread Wayne Watson
Title: Signature.html Working with Tkinter is like trying to dig through fossils. So much out there is old or incomplete. It's like the Tk species went extinct. The trail seems to end in 2005. I think I read it's not quite dead, and a newer looking is coming. Alan Gauld wrote: "Wayne Watson"

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

2009-03-17 Thread Wayne Watson
Title: Signature.html Not at all. I took Grayson's example as it stood. However, as it might have been noted above, he was working with Pmw, so the code may be a false impression of how it works in Tkinter. This gave the same results: root = Tk() dialog = DialogPrototype(root) root.mainloop()

Re: [Tutor] Checking Entry Values in Tkinter Widgets

2009-03-17 Thread Wayne Watson
As I thought this over, while on a long walk, apply might not be the place. That is, if pressing OK gets you to apply and the code discovers how do you get back to the dialog. I think you may have answered that below with the validation code. Alan Gauld wrote: "Wayne Watson" wrote Yes,

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

2009-03-17 Thread John Fouhy
2009/3/18 Wayne Watson : > Not at all. I took Grayson's example as it stood. However, as it might have > been noted above, he was working with Pmw, so the code may be a false > impression of how it works in Tkinter. > > This gave the same results: > root = Tk() > dialog = DialogPrototype(root) > ro

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

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] 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 John Fouhy
2009/3/18 Wayne Watson : > 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 > what looks like the same error messages(below). Maybe focus needs to be > established. I'm really using this code to de

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

2009-03-17 Thread Wayne Watson
Title: Signature.html 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 what looks like the same error messages(below). Maybe focus needs to be established. I'm really using this code to design a

Re: [Tutor] Checking Entry Values in Tkinter Widgets

2009-03-17 Thread Wayne Watson
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. The code spends quite a few lines setting things up to pass back. I'

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] Python and Tkinter Programming by Grayson--New Version?

2009-03-17 Thread Chris Fuller
What sets Pmw apart is the framework it provides for the creation of your own megawidgets. It handles labels, forwards options from the constructor to the constructors of the subcomponents, forwards method calls (say your megawidget is descended from a Frame, but the main feature is a Scale wid

Re: [Tutor] (no subject)

2009-03-17 Thread David
Alan Gauld wrote: Combine the two hints so far to improve it, then look even more closely at range() to see how to do the decreasing lengths. Thanks for the tips, I have been trying to figure it out also. I did get it after about 3 hours :) -david -- Powered by Gentoo GNU/LINUX htt

Re: [Tutor] sets module equivalent with Python 2.6

2009-03-17 Thread wesley chun
On Tue, Mar 17, 2009 at 2:34 PM, PyProg PyProg wrote: > > I want to use an equivalent of sets module with Python 2.6 ... but > sets module is deprecated on 2.6 version. it is deprecated only because sets have been rolled into Python proper starting in 2.4. replace sets.Set() with set(), and there

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

[Tutor] sets module equivalent with Python 2.6

2009-03-17 Thread PyProg PyProg
Hello all, I want to use an equivalent of sets module with Python 2.6 ... but sets module is deprecated on 2.6 version. In fact I want to make that but with Python 2.6: >>> toto_1 = [0, 1, 2, 3, 4] >>> toto_2 = [1, 127, 4, 7, 12] >>> >>> import sets >>> a = sets.Set(toto_1) >>> b = sets.Set(toto

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 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 Chris Fuller
This is a super book for beginners who are new to GUI programming. Tkinter is easy to use, and comes included with Python. Serious programmers will probably want something faster, better looking, and with nicer features, but they can be tricky to figure out and install. I still prefer Tkinte

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] 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] 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] combining Python 2.x and Python 3

2009-03-17 Thread Kent Johnson
On Tue, Mar 17, 2009 at 3:54 PM, wesley chun wrote: >> I would like to change it so that it can be run under both Python 3 and >> Python 2.x. > > everyone who has responded so far are telling about converting your > piece of code from Python 2 to Python 3, for example, using the "2to3" > tool tha

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] (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] Personal: Fwd: Re: Paython as a career

2009-03-17 Thread Jeff Johnson
Malcolm: I have four sticky XML / flat files downloaded from a web site that is converted into four text files and then synchronized into one file. Due to the web interface I moved it from VFP to Python. It was easier, cleaner and very fast. I run it from the VFP RUN command. I have been u

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

2009-03-17 Thread Wayne Watson
Title: Signature.html Ah, very subtle. Thanks. That worked, but I got shelled by: Program output (22, 33 are what I entered): apply 22 33 Traceback (most recent call last):   File "C:/Sandia_Meteors/Sentinel_Development/Development_Sentuser-Utilities/sentuser/NewSentDlg.py", line 35, in     d

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] 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] (no subject)

2009-03-17 Thread Kent Johnson
On Tue, Mar 17, 2009 at 3:16 PM, Jared White wrote: > howmany = int(raw_input('How many lines ')) > rhowmany = howmany > strout = '*' > while howmany > 0: >     print strout >     strout += '*' >     howmany -= 1 Another hint: learn how to use the range() function and for loops: In [1]: for i i

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

2009-03-17 Thread wesley chun
> I would like to change it so that it can be run under both Python 3 and > Python 2.x. everyone who has responded so far are telling about converting your piece of code from Python 2 to Python 3, for example, using the "2to3" tool that comes with Python 2.6+: http://docs.python.org/library/2to3.

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

2009-03-17 Thread Martin Walsh
Wayne Watson wrote: > The program below is derived from an example in Grayson for showing how > one might a dialog for entering passwords. The structure seems just like > the original, down to the use of self, Label and Entry plus . Yet the > print "here" statement produces: > here None > I'm

Re: [Tutor] (no subject)

2009-03-17 Thread W W
On Tue, Mar 17, 2009 at 2:16 PM, Jared White wrote: > This is what i have so far an this is not what i want it to do > "NO this isnt homework" i am trying to learn this myself > > #!/usr/bin/env python > # > #Author: J White > #Python 2.5.2 > # > howmany = int(raw_input('How many lines ')

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

2009-03-17 Thread Wayne Watson
Title: Signature.html The program below is derived from an example in Grayson for showing how one might a dialog for entering passwords. The structure seems just like the original, down to the use of self, Label and Entry plus . Yet the print "here" statement produces:     here None I'm missin

[Tutor] (no subject)

2009-03-17 Thread Jared White
This is what i have so far an this is not what i want it to do "NO this isnt homework" i am trying to learn this myself #!/usr/bin/env python # #Author: J White #Python 2.5.2 # howmany = int(raw_input('How many lines ')) rhowmany = howmany strout = '*' while howmany > 0: print strout

Re: [Tutor] Paython as a career

2009-03-17 Thread Jeff Johnson
Lukes answer is an excellent one! I would add that you can find language popularity here: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html I am moving to Python from Visual FoxPro. I have been programming all of my adult career. I have used Cobol, RPG, Basic, FoxPro and Python

Re: [Tutor] Paython as a career

2009-03-17 Thread Dave Kuhlman
On Tue, Mar 17, 2009 at 10:46:59AM +0100, spir wrote: [snip] > Python is much more prominent in the free software/open-source > world -- than for commercial software. You may think the reason > is that free developpers can choose ;-) Free software rarely pays > back in terms of money. I'd like t

Re: [Tutor] Gtk time control and Glade

2009-03-17 Thread Robert Berman
Thank you Chris, that will certainly get me started. Robert Chris Fuller wrote: Make your own. You can have empty containers in glade that you fill in at runtime, or you could create the interface in glade, perhaps a couple of ComboBoxes. I would leave an empty container and create a reusabl

Re: [Tutor] Gtk time control and Glade

2009-03-17 Thread Chris Fuller
Make your own. You can have empty containers in glade that you fill in at runtime, or you could create the interface in glade, perhaps a couple of ComboBoxes. I would leave an empty container and create a reusable widget descended from gtk.HBox that implements validation or anything else that

[Tutor] Checking Entry Values in Tkinter Widgets

2009-03-17 Thread Wayne Watson
Title: Signature.html The program I'm modifying uses something of a primitive way to check the validity of values entered into widgets on a larger dialog. It uses try-except after the user has pressed OK and departed from the dialog. Isn't this supposed to be done in the apply method for the di

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

2009-03-17 Thread A.T.Hofkamp
OkaMthembo wrote: Doesn't backslash also escape the newline? Thought i saw something to that effect in the tutorial. It does, but only inside the .py file. It has no effect when you run the program. Its purpose is to allow you to break long lines, for example if long_function_name(a) == long

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

2009-03-17 Thread OkaMthembo
Apparently there's a tool to convert older Python code to Python 3 compatibility - is this what you want? Must be somewhere in the cheese shop - sorry i cannot recall the name, or where exactly i saw the discussion. Lloyd On Tue, Mar 17, 2009 at 1:33 PM, Andre Engels wrote: > I have an open sou

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

2009-03-17 Thread Wayne Watson
Title: Signature.html I've poked around at the pieces of the book in Subject, which are on the web--two chapters. It was published in 2000, first ed. It looks quite good, and certainly is big, 680 or so pages. He sells a digital version. It uses Pmw, which I barely no more than how to spell it.

Re: [Tutor] (no subject)

2009-03-17 Thread OkaMthembo
Doesn't backslash also escape the newline? Thought i saw something to that effect in the tutorial. Lloyd On Tue, Mar 17, 2009 at 4:33 PM, Daniele wrote: > > From: dukelx2...@gmail.com > > To: tutor@python.org > > Honestly I'm doing tutorials, I'm not in school. I am trying to learn it > for my

Re: [Tutor] (no subject)

2009-03-17 Thread Daniele
> From: dukelx2...@gmail.com > To: tu...@python.org > Honestly I'm doing tutorials, I'm not in school.  I am trying to learn it for > my own sake. > I got the *'s to come up but they are not forming the way I would like it to. >  So that why I was asking for help. I suppose the trick here is to

Re: [Tutor] Modifying Grayson's Example 5_14

2009-03-17 Thread Martin Walsh
> Martin Walsh wrote: >> Wayne Watson wrote: >> >> >> >>> it. It works pretty well, but puts up a a few probably top level >>> windows that are blank. How do I get around them, and is there anything >>> >> >> >> >> >>> root = Tk() >>> >> >> Try adding this, >> >> root.withdraw() >> >> >>

[Tutor] Gtk time control and Glade

2009-03-17 Thread Robert Berman
I am writing a Blood-Glucose Analysis application for Diabetics. I am using Python 2.5 under Ubuntu 8.10 and Glade 3.4.5. Manually recorded test results require a calendar control for the date of the test (no problem) and a timer control for the time of the test(big problem). While Glade certa

Re: [Tutor] (no subject)

2009-03-17 Thread Luke Paireepinart
As a policy we don't give answers to homework questions. However, if you have tried this and you are stuck, we'd be happy to help with any specific questions you have about your implementation. On Tue, Mar 17, 2009 at 6:00 AM, wrote: > Would anyone know how to Write an application that displays

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

2009-03-17 Thread Kent Johnson
On Tue, Mar 17, 2009 at 8:59 AM, Kent Johnson wrote: > There are quite a few porting anecdotes in blogs, etc. Some googling > should turn them up. Google "python 3 porting" for lots of resources. Kent ___ Tutor maillist - Tutor@python.org http://mail

Re: [Tutor] (no subject)

2009-03-17 Thread Kent Johnson
On Tue, Mar 17, 2009 at 9:03 AM, wrote: > Honestly I'm doing tutorials, I'm not in school.  I am trying to learn it for > my own sake. > > I got the *'s to come up but they are not forming the way I would like it to. >  So that why I was asking for help. OK, then show us the code you have and

[Tutor] (no subject)

2009-03-17 Thread dukelx2005
Honestly I'm doing tutorials, I'm not in school. I am trying to learn it for my own sake. I got the *'s to come up but they are not forming the way I would like it to. So that why I was asking for help. This isn't a homework assignment. I'm just going thu tutorials which are not helping me

Re: [Tutor] memory error files over 100MB

2009-03-17 Thread Kent Johnson
On Tue, Mar 17, 2009 at 6:34 AM, A.T.Hofkamp wrote: >> http://personalpages.tds.net/~kent37/kk/00012.html > > Nice web-page! Thanks! > You can do the above statements also iteratively of course > > for i in ... >  s = read() >  # write s > > but since the loop does nothing with either s or read

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

2009-03-17 Thread Kent Johnson
On Tue, Mar 17, 2009 at 7:33 AM, 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. Two questions for that: > * is there a place where I can fin

Re: [Tutor] (no subject)

2009-03-17 Thread Kent Johnson
On Tue, Mar 17, 2009 at 6:56 AM, Jared White wrote: > Would anyone know how to Write an application that displays the following > patterns separately, one below the other. Yes. How about if you try? Presumably this is homework. What have you learned that might be helpful here? Kent _

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

2009-03-17 Thread Kent Johnson
On Tue, Mar 17, 2009 at 7:01 AM, spir wrote: > Is there a list.replace builtin I cannot find? Or a workaround? Just assign directly to list elements. To replace s1 with s2 in l: for i, x in enumerate(l): if x == s1: l[i] = s2 > Also: How would perform string.swap(s1, s2) in the following

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

2009-03-17 Thread A.T.Hofkamp
Hello Denis, spir wrote: Is there a list.replace builtin I cannot find? Or a workaround? You didn't find it because it does not exist. You should do something like [f(x) for x in old_lst] where f(x) implements the replacement. Also: How would perform string.swap(s1, s2) in the following c

[Tutor] combining Python 2.x and Python 3

2009-03-17 Thread Andre Engels
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. Two questions for that: * is there a place where I can find an overview of what to do to make such a change? * is there

Re: [Tutor] (no subject)

2009-03-17 Thread Tim Golden
Michael Connors wrote: So the extent of your effort is "Would anyone know how to Ctrl+c". That deserves an award. I think you meant ctrl-v, but good point, nonetheless :) (Took me a moment, because I thought you were referring to a KeyboardInterrupt-type ctrl-c!) TJG

[Tutor] (no subject)

2009-03-17 Thread dukelx2005
Would anyone know how to Write an application that displays the following patterns separately, one below the other. Use for or while loops to generate the patterns. All asterisks (*) should be printed by a single statement of print( '*' ); which causes the asterisks to print side by side. A stat

Re: [Tutor] (no subject)

2009-03-17 Thread Michael Connors
So the extent of your effort is "Would anyone know how to Ctrl+c". That deserves an award. 2009/3/17 Jared White > Would anyone know how to Write an application that displays the following > patterns separately, one below the other. Use for or while loops to generate > the patterns. All asterisk

[Tutor] list.replace -- string.swap

2009-03-17 Thread spir
Is there a list.replace builtin I cannot find? Or a workaround? 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) will fail because any char can be part of s. * Either s

[Tutor] (no subject)

2009-03-17 Thread Jared White
Would anyone know how to Write an application that displays the following patterns separately, one below the other. Use for or while loops to generate the patterns. All asterisks (*) should be printed by a single statement of print( '*' ); which causes the asterisks to print side by side. A stateme

Re: [Tutor] Paython as a career

2009-03-17 Thread Rajkumar. B
Luke, You have explained it beautifully ! Thanks & Regards Rajkumar. B On Tue, 17 Mar 2009 02:17:44 -0700 OkaMthembo wrote > Luke, i think you gave a more balanced answer :) > > On Tue, Mar 17, 2009 at 10:45 AM, Luke Paireepinart > wrote: > You should not choose a specific

Re: [Tutor] memory error files over 100MB

2009-03-17 Thread A.T.Hofkamp
Kent Johnson wrote: On Mon, Mar 16, 2009 at 12:30 PM, A.T.Hofkamp wrote: I don't know what code is executed in an assignment exactly, but **possibly**, first the 'read()' is executed (thus loading a very big string into memory), before assigning the value to the variable (which releases the pr

[Tutor] Making exe Python file - standalone executable file

2009-03-17 Thread Neven Goršić
Hi! 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 (too bad that it is not part of standard Python distribution). I have no experience with wxPython and PyQT. Do they have their ow

Re: [Tutor] Paython as a career

2009-03-17 Thread spir
Le Tue, 17 Mar 2009 03:45:36 -0500, Luke Paireepinart s'exprima ainsi: > If you're really asking us which language has the largest job market, Python > is definitely not the answer to that question? Can you find jobs in > Python? Sure, if you are determined and you look hard enough. But as far

Re: [Tutor] Paython as a career

2009-03-17 Thread OkaMthembo
Luke, i think you gave a more balanced answer :) On Tue, Mar 17, 2009 at 10:45 AM, Luke Paireepinart wrote: > You should not choose a specific programming language and start a career in > it. If you want a career in programming you need to learn a great deal > about computer science (the theory)

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] Paython as a career

2009-03-17 Thread Luke Paireepinart
You should not choose a specific programming language and start a career in it. If you want a career in programming you need to learn a great deal about computer science (the theory). One of the things you will learn in your studies is that programming languages are just the tools, and you levera