Re: [Tutor] trouble with if

2007-10-25 Thread Aditya Lal
I think you need to use "raw_input" instead of "input". input "eval" the input expression while "raw_input" just stores it. I find the module help very handy when I am in doubt. >>> print raw_input.__doc__ raw_input([prompt]) -> string Read a string from standard input. The trailing newline is s

Re: [Tutor] trouble with if

2007-10-25 Thread Bryan Fodness
I cannot get this to work either. woffaxis = 7 if woffaxis != 0: woaf_pos = input("What is Wedge Direction (N/A, Lateral, Towards Heal, Towards Toe)?") if woaf_pos == 'Towards Toe': woffaxis = woffaxis elif woaf_pos == 'Towards Heal': woffaxis = (woffaxis * -1) else: woffaxis

[Tutor] about Tix

2007-10-25 Thread linda.s
I run the following code in Python 2.5 and got the error (when I do "import Tix", no error). Traceback (most recent call last): File "2.py", line 54, in tkRoot = Tix.Tk( ) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk/Tix.py", line 210, in __init__ self

Re: [Tutor] Using dictionary to find the mode of a list

2007-10-25 Thread Alan Gauld
"Conor Leister" <[EMAIL PROTECTED]> wrote > Here's the code I have that gathers the data and sorts it. My first question is why are you writing a bubble sort routine for your list? In almost every conceivable case the built-in sort method will be faster. > be able to get the mode of a using a d

Re: [Tutor] calling a variable name

2007-10-25 Thread Ricardo Aráoz
Kent Johnson wrote: > Dave Kuhlman wrote: >> On Tue, Oct 23, 2007 at 10:10:24PM -0400, Kent Johnson wrote: >> >> [snip] >> >>> Perhaps I was a bit hasty. >>> >>> Lists are implemented as arrays of references. I believe they are >>> - amortized O(1) for append - occasionally the list must be realloc

Re: [Tutor] How to implement function like this?

2007-10-25 Thread Ricardo Aráoz
Kent Johnson wrote: > Ricardo Aráoz wrote: >> Yinghe Chen wrote: >>> Hello gurus, >>> >>> I have a question, a function like below, it is implemented by me, :) >>> >>> def funcA(tarray): >>>a = [2,3,4] >>> if len(tarray) >=3: >>> return a[0],a[1], a[2] >>> elif

[Tutor] Using dictionary to find the mode of a list

2007-10-25 Thread Conor Leister
I'm just trying to get the mode of a list. Here's the code I have that gathers the data and sorts it. i just need to be able to get the mode of a using a dictionary and i can't seem to figure out anything. i'm completely lost. this code works fine, i just need to add to it and i'm not great with d

Re: [Tutor] rounding to the nearest 0.5

2007-10-25 Thread Eric Brunson
Bryan Fodness wrote: > > Is there a built-in function that will round to the nearest 0.5? Not that I know of, but "round( 2 * n ) / 2" will give you what you're looking for. > > > _

[Tutor] rounding to the nearest 0.5

2007-10-25 Thread Bryan Fodness
Is there a built-in function that will round to the nearest 0.5? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Looking for suggestions for improving chessTimer.py code

2007-10-25 Thread Dick Moores
Please give me constructive criticism of Thanks, Dick ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] underlying C/C++ object has been deleted

2007-10-25 Thread Lawrence Shafer
Here's the whole code. Any help appreciated! http://shaferlabs.pastebin.com/m32c82193 Also I was thinking I could set the progressbar to 64% like this. self.progressBar.setProperty("value",QtCore.QVariant(64)) but it doesn't work. (AttributeError: progressBar) I think it has something to do with

Re: [Tutor] urllib2 and cookies

2007-10-25 Thread Kent Johnson
Michael Meier wrote: > Hi > > ASPN has a very verbose example of cookielib usage at > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302930 There is a writeup of this recipe here: http://www.voidspace.org.uk/python/articles/cookielib.shtml This is way more complicated than you need, tho

Re: [Tutor] Looking to improve my stopWatch.py

2007-10-25 Thread Kent Johnson
Dick Moores wrote: > I've also seen things like this: > >>> a = [] > >>> if not a: > ... print 'a is empty' > ... > a is empty > >>> > > Isn't this preferable?: > >>> a = [] > >>> if a == []: > ... print 'a is empty' > ... > a is empty I like the simplicity and consistency of if

Re: [Tutor] urllib2 and cookies

2007-10-25 Thread Michael Meier
Hi ASPN has a very verbose example of cookielib usage at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302930 Many things are very OS, especially Windows, specific. You can surely phase out the relevant parts :) Probably the solution with cookielib is the easiest way to go. Cookielib is

Re: [Tutor] Looking to improve my stopWatch.py

2007-10-25 Thread Dick Moores
At 12:17 AM 10/25/2007, Alan Gauld wrote: >"Dick Moores" <[EMAIL PROTECTED]> wrote > > > > Tim Peters ("Explicit is better than implicit"), isn't "if > > lapTimeFlag == > > > True" preferable? > > > >if (lapTimeFlag == True) == True: > > > > Well, how about "Readability counts"? > >Thats the

Re: [Tutor] where is the function from

2007-10-25 Thread Alan Gauld
"linda.s" <[EMAIL PROTECTED]> wrote > How can I know where a function such as abc is from (from which > module)? abc > Look at your import statements. Provided you have nbeen using recommended practice you will have used from module import name1,name2,... or just import module. If th

Re: [Tutor] underlying C/C++ object has been deleted

2007-10-25 Thread Alan Gauld
"Lawrence Shafer" <[EMAIL PROTECTED]> wrote > files from QT Designer. I am getting the error below and do not > understand what's going on. Neither do I but try debugging it to find out which object causes the error > File "atf.py", line 56, in open >if self.isUntitled and self.textBrowser

Re: [Tutor] Looking to improve my stopWatch.py

2007-10-25 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote > > Tim Peters ("Explicit is better than implicit"), isn't "if > lapTimeFlag == > > True" preferable? > >if (lapTimeFlag == True) == True: > > Well, how about "Readability counts"? Thats the point. By calling the variable a "Flag" you are implying t

Re: [Tutor] Looking to improve my stopWatch.py

2007-10-25 Thread Alan Gauld
"bhaaluu" <[EMAIL PROTECTED]> wrote > I had absolutely no clue what mscrt was. The MicroSoftVisualCRunTime library. help ("curses") > > Whew! > There's quite a bit in that one! Yep its a full "Gui" toolkit for text based terminals. Fortunately you only need a couple of functions. Check

[Tutor] urllib2 and cookies

2007-10-25 Thread SwartMumba snake
I want to read the html source off a site but the site requires cookies. What code must I use to handle my cookies, instead of me typing them out? NB I want to use urllib2 to open the site, not urllib. I am currently using python 2.5 This is what I have done so far, but I do not want to type out