Re: [Tutor] Runs in IDLE with F5, but not in Windows Command Prompt

2013-04-25 Thread boB Stepp
Hi Danny, > > [The following note is Python 2.0 specific. In Python 3, input() is > semantically different, and safe.] > > If you are using Python 2.0, don't use the input() function here to > read strings. It is not safe: backing it is an implicit eval(), and > eval() is dangerous, especially f

Re: [Tutor] Runs in IDLE with F5, but not in Windows Command Prompt

2013-04-25 Thread boB Stepp
Hi Steve, > >> E:\Programs\Python\IYOCGwPy\Ch4>guess.py > > Here you are telling Windows to look up the file association for .py files. > It locates some program, and runs it with guess.py as the argument. Looking > at the result: > >> Hello! What is your name? >> boB >> Traceback (most recent cal

Re: [Tutor] Runs in IDLE with F5, but not in Windows Command Prompt

2013-04-25 Thread boB Stepp
On Thu, Apr 25, 2013 at 8:45 AM, Marc Tompkins wrote: > On Thu, Apr 25, 2013 at 5:40 AM, boB Stepp wrote: > Remember that input(), in Python 2, executes what's passed to it. If your > input is boB, then Python tries to execute the statement boB - and unless > you've

[Tutor] Helpful little book

2013-04-28 Thread boB Stepp
I have found the following book quite helpful and keep it handy: "Python Pocket Reference" by Mark Lutz, 4th ed., c. 2010. It was released at the time that 3.0 and 2.6 were the current Python versions, but tries to include what was intended for the 2.x and 3.x future releases as he knew them then

[Tutor] Long post: How to design a Python program to generate GUI elements in a proprietary scripting language.

2013-04-28 Thread boB Stepp
At work I use a commercial program for radiation therapy planning. This program has an extensive built-in, proprietary scripting language that is accessible to the user. The scripting files are all text-based. The OS that we are running the commercial software on is Solaris 10. The scripting langua

Re: [Tutor] Long post: How to design a Python program to generate GUI elements in a proprietary scripting language.

2013-04-28 Thread boB Stepp
On Sun, Apr 28, 2013 at 7:47 PM, Steven D'Aprano wrote: > On 29/04/13 06:05, boB Stepp wrote: >> >> At work I use a commercial program for radiation therapy planning. >> This program has an extensive built-in, proprietary scripting language >> that is accessible t

Re: [Tutor] Long post: How to design a Python program to generate GUI elements in a proprietary scripting language.

2013-04-28 Thread boB Stepp
On Sun, Apr 28, 2013 at 4:25 PM, Alan Gauld wrote: > > You could build a full GUI builder in Python but that will be a lot of work. > Is there room for a half way house? > I sure hope so! > I'd suggest building a Python program that reads a resource file (maybe > using the configparser module a

Re: [Tutor] Helpful little book

2013-04-29 Thread boB Stepp
On Mon, Apr 29, 2013 at 4:16 AM, Alan Gauld wrote: > On 28/04/13 20:03, boB Stepp wrote: >> >> I have found the following book quite helpful and keep it handy: >> >> "Python Pocket Reference" by Mark Lutz, 4th ed., c. 2010. >> > > I have an earlie

Re: [Tutor] Long post: How to design a Python program to generate GUI elements in a proprietary scripting language.

2013-04-29 Thread boB Stepp
Alan, I am at work now, so I will try to reply to those things I can answer quickly. Today is a full planning day, not a programming day! On Mon, Apr 29, 2013 at 4:08 AM, Alan Gauld wrote: >> my situations, it would have to result in the proper window generation >> with no tweaking. > > > Thats

Re: [Tutor] Long post: How to design a Python program to generate GUI elements in a proprietary scripting language.

2013-04-29 Thread boB Stepp
On Mon, Apr 29, 2013 at 4:08 AM, Alan Gauld wrote: > On 29/04/13 03:57, boB Stepp wrote: > [Major snip] > >> Unfortunately in most instances the window would have to be generated >> at runtime. > > > The whole window? Or just a panel within it? > If its only fo

[Tutor] New book: Data Structures and Algorithms in Python. Opinions?

2013-04-30 Thread boB Stepp
The following textbook was just released yesterday on Amazon: Data Structures and Algorithms in Python Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser March 2013, ©2013 I was wondering if anyone was familiar with the earlier "market leading" textbooks in C++ and Java with essentiall

[Tutor] Continuation of long lines of string characters

2013-04-30 Thread boB Stepp
I have been looking through PEP 8--Style Guide for Python Code. It recommends a maximum line length of 79 characters. What is the preferred way to continue on another line or lines really long print functions of string literals (Python 3)? The only thing that immediately occurs to me is to break up

Re: [Tutor] Continuation of long lines of string characters

2013-04-30 Thread boB Stepp
I was just now playing around in the interpreter trying print('Hello''world!') thinking I would get a syntax error, only to discover the kernel of what you show below... On Tue, Apr 30, 2013 at 9:28 PM, brian arb wrote: > I really like breaking my long strings like... > > And rewrite it like this

Re: [Tutor] Using graphics

2013-05-05 Thread boB Stepp
On Sun, May 5, 2013 at 6:49 AM, Stafford Baines wrote: > I have just finished Python Programming by Michael Dawson. A wonderful book > with downloadable examples. However, after many hours of frustrating attempts > I can't get the graphics to work. > I own this book, too, but I am not actively

[Tutor] Clear screen questions

2013-05-05 Thread boB Stepp
I have been playing around with my own version of a guess the number game that I wrote before looking at how the kids' book (which I am reviewing for my kids) did it. For some reason my children are fascinated by this game and keep asking me for improvements. The latest one was to implement an auto

Re: [Tutor] Clear screen questions

2013-05-05 Thread boB Stepp
On Sun, May 5, 2013 at 7:54 PM, Steven D'Aprano wrote: > On 06/05/13 10:17, boB Stepp wrote: >> [...] > > But even on Windows that will not work, if you are running under IDLE. And > unfortunately there is no official way to tell if you are running under > IDLE, or any

Re: [Tutor] Making a Primary Number List generator

2013-05-12 Thread boB Stepp
On Sun, May 12, 2013 at 6:43 AM, Dave Angel wrote: [...] > With no experience in programming other languages, you'd need a different > kind of tutorial than I sought when I was learning Python. And you > absolutely need to match your tutorial against the version of Python you're > running on your

Re: [Tutor] Random Number Game: Returns always the same number - why?

2013-05-20 Thread boB Stepp
On Mon, May 20, 2013 at 11:31 AM, Rafael Knuth wrote: > > Hello, > > I wrote a simple program, and I was expecting that I would get 100 different > random numbers. Instead, I am getting 100 times exactly the same random > number. Can anyone advise how I should alter my program? > > Thank you! >

[Tutor] Configuring Emacs for Python development?

2013-05-21 Thread boB Stepp
Okay. Since I first joined this list I have played around (as time permitted) with these editors/IDEs: PyCharm, Eclipse with PyDev, Notepad++, Emacs, IDLE, PyScripter, IdleX, Sublime Text, and possibly others. Of course, I have far from mastered any of them, but I think that I have a sense of what

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread boB Stepp
On Wed, May 22, 2013 at 7:50 AM, Steven D'Aprano wrote: > On 22/05/13 15:46, Jim Mooney wrote: >> [...] > > But don't do this in real code! In real code, the rules you should apply > are: > > > 1) never hide programming errors by catching exceptions; > > 2) errors should only be caught if you ca

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread boB Stepp
On Wed, May 22, 2013 at 8:07 AM, Steven D'Aprano wrote: > On 22/05/13 16:20, Jim Mooney wrote: >>> [...} > A very important quote from Chris Smith: > > "I find it amusing when novice programmers believe their main job is > preventing programs from crashing. ... More experienced programmers reali

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread boB Stepp
Thanks, Steve, for your last two posts. You have made things much clearer for me. On Wed, May 22, 2013 at 9:49 AM, Steven D'Aprano wrote: > On 22/05/13 23:37, boB Stepp wrote: >> >> On Wed, May 22, 2013 at 8:07 AM, Steven D'Aprano >> wrote: >>> [...

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-22 Thread boB Stepp
On Wed, May 22, 2013 at 9:45 AM, Steven D'Aprano wrote: > On 22/05/13 23:31, boB Stepp wrote: >> >> On Wed, May 22, 2013 at 7:50 AM, Steven D'Aprano >> wrote: [...] >>> 3) your job as a programmer is *not* to stop your program from raising an &g

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-23 Thread boB Stepp
On Wed, May 22, 2013 at 8:47 PM, Steven D'Aprano wrote: > On 23/05/13 02:09, boB Stepp wrote: > >> I would like to ask some general questions here. Problems can arise >> from bugs in the operating system, bugs in the programming language(s) >> being used, bugs in pack

Re: [Tutor] Presenting text in different ways by using quotes!

2013-05-23 Thread boB Stepp
On Thu, May 23, 2013 at 12:31 PM, Andrew Triplett wrote: > I am asked to present text in different ways by using quotes in strings. for > example: > [...] > I can't however seem to input the text GAME OVER in giant text as it says in > the book. Any help for this would be appreciated. > I'm taki

Re: [Tutor] Difference between types

2013-05-23 Thread boB Stepp
On Thu, May 23, 2013 at 2:57 PM, Citizen Kant wrote: > I guess I'm understanding that, in Python, if something belongs to a type, > must also be a value. > > I guess I'm understanding that the reason why 9 is considered a value, is > since it's a normal form, an element of the system that cannot b

Re: [Tutor] a little loop

2013-05-29 Thread boB Stepp
On Tue, May 28, 2013 at 9:34 PM, Steven D'Aprano wrote: > > On 28/05/13 13:54, Tim Hanson wrote: >> > > However, a word of warning: although you *can* assemble a new string > character by character like that, you should not, because it risks being very > slow. *Painfully* slow. If you want to h

Re: [Tutor] a little loop

2013-05-29 Thread boB Stepp
On Wed, May 29, 2013 at 11:07 AM, Oscar Benjamin wrote: > On 29 May 2013 16:38, boB Stepp wrote: >> On Tue, May 28, 2013 at 9:34 PM, Steven D'Aprano wrote: >>> >>> However, a word of warning: although you *can* assemble a new string >>> character by cha

Re: [Tutor] Printing a list count - Help

2014-08-30 Thread boB Stepp
On Fri, Aug 29, 2014 at 2:17 PM, Derek Jenkins wrote: > Hi everybody, > > I have a list that I want to go through and finally print a total > count of particular items. In this case, I want to print the result of > how many A's and B's are in the list. > > honor_roll_count = 0 > student_grades = [

Re: [Tutor] Good Text Editor/IDE for Python

2014-09-01 Thread boB Stepp
On Sun, Aug 31, 2014 at 7:12 PM, Juan Christian wrote: > I've been using PyCharm to code in Python but it seems a bit "overpowered" > for this task, and there are some annoying bugs. I used Sublime Text 2 in > the past, but it seems to be dead now (last update was JUN/2013), so I don't > really kn

Re: [Tutor] usage difference between tabs and spaces

2014-09-09 Thread boB Stepp
On Tue, Sep 9, 2014 at 7:27 AM, Mirage Web Studio wrote: > > Hello, > > I am not an advanced programmer, but am very good with keyboard and find > using tabs for syntax and formatting very helpful. But in this list and > other python documentation i have repeatedly seen people recommending > use o

Re: [Tutor] pygame module

2014-10-04 Thread boB Stepp
On Fri, Oct 3, 2014 at 4:27 PM, Rob Ward wrote: > i downloaded the 3.4 version of python but there is no matching binary file > for pygame ive tried every 1.9.1 file and still cant import pygame would an > older version of python work > If you have windows try: http://www.lfd.uci.edu/~gohlke/pyth

[Tutor] How best to structure a plain text data file for use in program(s) and later updating with new data?

2014-10-08 Thread boB Stepp
About two years ago I wrote my most ambitious program to date, a hodge-podge collection of proprietary scripting, perl and shell files that collectively total about 20k lines of code. Amazingly it actually works and has saved my colleagues and I much time and effort. At the time I created this mess

Re: [Tutor] How best to structure a plain text data file for use in program(s) and later updating with new data?

2014-10-08 Thread boB Stepp
On Wed, Oct 8, 2014 at 10:02 AM, Joel Goldstick wrote: [...] > It looks like you have csv like data. Except you have a semicolon as > a separator. Look at the csv module. That should work for you > Joel, will the labels (like SERIAL_ROI:) cause me difficulties? I will need to strip these off

Re: [Tutor] How best to structure a plain text data file for use in program(s) and later updating with new data?

2014-10-08 Thread boB Stepp
On Wed, Oct 8, 2014 at 11:27 AM, Alan Gauld wrote: > On 08/10/14 16:47, boB Stepp wrote: > >>> It looks like you have csv like data. Except you have a semicolon as >>> a separator. Look at the csv module. That should work for you >>> >> Joel, will

Re: [Tutor] How best to structure a plain text data file for use in program(s) and later updating with new data?

2014-10-08 Thread boB Stepp
On Wed, Oct 8, 2014 at 2:19 PM, Martin A. Brown wrote: > > Good afternoon, > >>> If its not too big a task you could even convert the data >>> structure to JSON which is quite a close match to what you >>> have now and the json module will help you read/write >>> to them. Looking at some examples

[Tutor] Installing both Python 2.7 and Python 3.4 on Windows 7 Pro 64-bit: Install Python 2.7 FIRST!

2014-10-09 Thread boB Stepp
I am hoping to save other people the grief I just worked through. I wanted to run both Python 2 and 3 on my windows PC, and, after googling this topic found that with Python 3.3 or later one could easily do both. So I merrily installed Python 3.4.2 first and then Python 2.7.8. A Python 3 program th

Re: [Tutor] Installing both Python 2.7 and Python 3.4 on Windows 7 Pro 64-bit: Install Python 2.7 FIRST!

2014-10-10 Thread boB Stepp
On Fri, Oct 10, 2014 at 2:05 AM, Wolfgang Maier wrote: > On 10/10/2014 05:57 AM, boB Stepp wrote: >> >> I am hoping to save other people the grief I just worked through. I >> wanted to run both Python 2 and 3 on my windows PC, and, after >> googling this topic found th

Re: [Tutor] Installing both Python 2.7 and Python 3.4 on Windows 7 Pro 64-bit: Install Python 2.7 FIRST!

2014-10-10 Thread boB Stepp
On Fri, Oct 10, 2014 at 7:43 AM, boB Stepp wrote: > On Fri, Oct 10, 2014 at 2:05 AM, Wolfgang Maier > wrote: >> On 10/10/2014 05:57 AM, boB Stepp wrote: [...] >> >> It would help if you could share details about how you tried to run the >> Python 3 program (c

Re: [Tutor] Installing both Python 2.7 and Python 3.4 on Windows 7 Pro 64-bit: Install Python 2.7 FIRST!

2014-10-10 Thread boB Stepp
On Fri, Oct 10, 2014 at 11:54 PM, Zachary Ware wrote: > On Fri, Oct 10, 2014 at 11:34 PM, boB Stepp wrote: >> I can live with 2.7.8 being the default Python, but if I wanted to >> make 3.4.2 the default, how would I go about doing it? > > Check the output of "ftype

Re: [Tutor] Installing both Python 2.7 and Python 3.4 on Windows 7 Pro 64-bit: Install Python 2.7 FIRST!

2014-10-10 Thread boB Stepp
On Sat, Oct 11, 2014 at 12:24 AM, boB Stepp wrote: > On Fri, Oct 10, 2014 at 11:54 PM, Zachary Ware > wrote: >> On Fri, Oct 10, 2014 at 11:34 PM, boB Stepp wrote: >>> I can live with 2.7.8 being the default Python, but if I wanted to >>> make 3.4.2 the default,

[Tutor] Is there a convenient table of Python 3.4 exceptions?

2014-10-23 Thread boB Stepp
I am reading a brief intro to exception handling in Mark Summerfield's "Programming in Python 3, 2nd ed." He gives the basic syntax as: try: try_suite except exception1 as variable1: exception_suite1 ... except exceptionN as variableN: exception_suiteN My current understanding is that

Re: [Tutor] Is there a convenient table of Python 3.4 exceptions?

2014-10-24 Thread boB Stepp
On Thu, Oct 23, 2014 at 10:57 PM, Danny Yoo wrote: > > > I have so far been unable to find a list of these class/subclass names. Of > > course I can force an error to occur in the interpreter and see what comes > > up for each type of error I wish to catch. Is there such a table or list? > > > > H

Re: [Tutor] Is there a convenient table of Python 3.4 exceptions?

2014-10-24 Thread boB Stepp
On Thu, Oct 23, 2014 at 11:04 PM, Ben Finney wrote: > boB Stepp writes: > [...] > >> I have so far been unable to find a list of these class/subclass >> names. > > The standard library documentation's chapter on exceptions > https://docs.python.org/3/lib

[Tutor] How to store and use passwords?

2014-11-18 Thread boB Stepp
OS: Solaris 10. Python: 2.4.4 on the computer I will be doing my development work. 2.6.4 on the production environment. I am working on my first python program at work to automate a set of tasks that allows for the results of a radiotherapy plan to be compared to a set of constraints that the plan

Re: [Tutor] How to store and use passwords?

2014-11-18 Thread boB Stepp
On Tue, Nov 18, 2014 at 9:47 AM, Alan Gauld wrote: [...] > You can roll your own password system using the crypt module. > Get each user to create a password (or give them a default) and > encrypt it with crypt. Store the result and when they log in > compare the encrypted password with the stored

[Tutor] "Philosophical" question about string slicing from end of a string

2014-11-24 Thread boB Stepp
Python 2.7.8 Win7Pro >>> str = "0123456789" >>> str[-1] '9' >>> str[-3:-1] '78' >>> str[-3:] '789' I understand that the above is "the way it is" in Python, but I am puzzled why the designers did not choose that str[-3:-1] returns '789', especially since str[-1] returns '9'. What is the reason fo

Re: [Tutor] "Philosophical" question about string slicing from end of a string

2014-11-24 Thread boB Stepp
On Mon, Nov 24, 2014 at 12:57 PM, Zachary Ware wrote: [...] > > Have I clarified or muddied it for you? :) Clarified, I believe, if my following statements are correct: I did not consider that the behavior was symmetric with positive indices. So, index 0 is the "center" relative to which positive

Re: [Tutor] "Philosophical" question about string slicing from end of a string

2014-11-24 Thread boB Stepp
On Mon, Nov 24, 2014 at 1:06 PM, boB Stepp wrote: > On Mon, Nov 24, 2014 at 12:57 PM, Zachary Ware > wrote: > [...] >> >> Have I clarified or muddied it for you? :) > > Clarified, I believe, if my following statements are correct: I did > not consider that t

[Tutor] Is there an easy way to center the root window (Tkinter) within the display?

2014-11-26 Thread boB Stepp
Python 2.4.4 Solaris 10 I can accomplish this by getting the screen height and width and calculating pixel coordinates. But so far I have not found something equivalent to anchor = 'CENTER' that can be applied to the root window. Does such an easy attribute, method, or whatever exist in Tkinter?

[Tutor] How to change the color of the title bar of the root window in Tkinter?

2014-11-26 Thread boB Stepp
Python 2.4.4 Solaris 10 -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to change the color of the title bar of the root window in Tkinter?

2014-11-26 Thread boB Stepp
On Wed, Nov 26, 2014 at 11:25 AM, Alan Gauld wrote: > On 26/11/14 16:48, boB Stepp wrote: >> >> Python 2.4.4 >> Solaris 10 > > > I can't find anything on this and I suspect that's because > title bar colour is generally part of the user's preferre

Re: [Tutor] Is there an easy way to center the root window (Tkinter) within the display?

2014-11-26 Thread boB Stepp
On Wed, Nov 26, 2014 at 11:23 AM, Alan Gauld wrote: > On 26/11/14 16:46, boB Stepp wrote: > >> I can accomplish this by getting the screen height and width and >> calculating pixel coordinates. But so far I have not found something >> equivalent to anchor = 'CENTE

Re: [Tutor] Is there an easy way to center the root window (Tkinter) within the display?

2014-11-26 Thread boB Stepp
On Wed, Nov 26, 2014 at 11:50 AM, Alan Gauld wrote: > On 26/11/14 17:44, boB Stepp wrote: > [...] > So they can't read email, write reports, browse web sites? > And what if the OS or sysadmin is also trying to catch their eye - maybe > because the server is going down and

Re: [Tutor] How to change the color of the title bar of the root window in Tkinter?

2014-11-26 Thread boB Stepp
On Wed, Nov 26, 2014 at 11:58 AM, Alan Gauld wrote: > On 26/11/14 17:39, boB Stepp wrote: > [...] >> The application I am attempting to write will show up in the >> foreground of our planning software. This planning software has its >> own color scheme, which all

[Tutor] Question about why a list variable is apparently global.

2014-11-26 Thread boB Stepp
Python 2.4.4 Solaris 10 #!/usr/bin/env python from Tkinter import * def printLabel(): print "Button number ", var.get(), " was pressed." print "You selected this option:", l[var.get() - 1][0] root = Tk() root.title("ROI List Creator") root.geometry(newGeometry='225x230+900+300') root.tk

Re: [Tutor] Question about why a list variable is apparently global.

2014-11-26 Thread boB Stepp
On Wed, Nov 26, 2014 at 6:20 PM, Steven D'Aprano wrote: > On Wed, Nov 26, 2014 at 05:23:40PM -0600, boB Stepp wrote: [...] >> First question: How can the printLabel() function see the list >> variable, l, defined outside of this function? I thought that >> functions on

Re: [Tutor] Question about why a list variable is apparently global.

2014-11-27 Thread boB Stepp
On Thu, Nov 27, 2014 at 4:51 AM, Alan Gauld wrote: > On 27/11/14 04:18, boB Stepp wrote: [...] >> So any variables lower in the program are accessible to those above it? > > > No. > Its not whether they are defined above or below each other its the level of > inden

Re: [Tutor] Question about why a list variable is apparently global.

2014-11-27 Thread boB Stepp
On Thu, Nov 27, 2014 at 4:56 AM, Steven D'Aprano wrote: > On Wed, Nov 26, 2014 at 10:18:55PM -0600, boB Stepp wrote: > >> So any variables lower in the program are accessible to those above it? > > No, that can't be the explanation. Think of this: > > b = a + 1

Re: [Tutor] Question about why a list variable is apparently global.

2014-11-27 Thread boB Stepp
On Thu, Nov 27, 2014 at 9:33 AM, Steven D'Aprano wrote: > On Thu, Nov 27, 2014 at 09:00:48AM -0600, boB Stepp wrote: [...] > But there is a subtlety that you may not expect: > > py> class Tricky: > ... print(x) > ... x = "inner" > ... print(x

Re: [Tutor] Is there an easy way to center the root window (Tkinter) within the display?

2014-11-27 Thread boB Stepp
On Thu, Nov 27, 2014 at 9:58 AM, Steven D'Aprano wrote: > On Wed, Nov 26, 2014 at 12:25:23PM -0600, boB Stepp wrote: > >> As I am the only person in our >> group with any programming knowledge (weak though it is), this means I >> usually wind up trying to solve issue

Re: [Tutor] Is there an easy way to center the root window (Tkinter) within the display?

2014-11-27 Thread boB Stepp
On Nov 27, 2014 1:27 PM, "Dave Angel" wrote: > > On 11/27/2014 11:39 AM, boB Stepp wrote: >> >> On Thu, Nov 27, 2014 at 9:58 AM, Steven D'Aprano wrote: > > > > You say you're using some 3rd party package to do the heavy lifting. But you also s

Re: [Tutor] Learning to program, not code. [LONG RESPONSE!]

2014-12-19 Thread boB Stepp
On Thu, Dec 18, 2014 at 8:09 PM, Brandon Dorsey wrote: > > Hello All, > > Programming has always been a passion of mine, however, I'm frequently > frustrated at > > simple fact that I've been learning python for 8 months, and I have yet to > start, and finish, a simple > > project. I find difficu

[Tutor] Fwd: Re: Learning to program, not code. [LONG RESPONSE!]

2014-12-21 Thread boB Stepp
It appears that Michael only sent this to me when I think he meant to send it to the list... -- Forwarded message -- From: "Michael Shiloh" Date: Dec 21, 2014 7:25 PM Subject: Re: [Tutor] Learning to program, not code. [LONG RESPONSE!] To: "boB Stepp" Cc: &g

Re: [Tutor] Could you look over my code?

2015-01-04 Thread boB Stepp
On Sun, Jan 4, 2015 at 8:39 PM, Steven D'Aprano wrote: [...] > >> 2. Have a look at this code fro the book and tell me what to improve >> (This is a program where it says game over, and it waits for the user >> to press the enter key to quit: >> >> print(“Game Over”) >> input(“\n\nPress the enter

[Tutor] Does the Python way of doing things have a definite preference for the structure and content of program file header comments?

2015-01-22 Thread boB Stepp
And will this vary depending on whether a version control system is being used or not? Or is the use of a version control system considered to be highly recommended (if not mandatory)? -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or cha

Re: [Tutor] Does the Python way of doing things have a definite preference for the structure and content of program file header comments?

2015-01-22 Thread boB Stepp
On Thu, Jan 22, 2015 at 5:25 PM, Ben Finney wrote: > boB Stepp writes: > >> And […] > > Could you write a message body that asks the question? (The Subject > field isn't part of the message body.) Does the Python way of doing things have a definite preference for th

Re: [Tutor] Does the Python way of doing things have a definite preference for the structure and content of program file header comments?

2015-01-22 Thread boB Stepp
On Thu, Jan 22, 2015 at 5:45 PM, Steven D'Aprano wrote: > On Thu, Jan 22, 2015 at 03:17:58PM -0600, boB Stepp hid the following > question in the subject line: > > "Does the Python way of doing things have a definite preference for the > structure and content of pro

Re: [Tutor] Why is it not working?

2015-02-04 Thread boB Stepp
On Wed, Feb 4, 2015 at 6:12 PM, Antonio Zagheni wrote: > Hi there, > > I am a begginer in python and I'm trying to learn something about Tkinter. > > I did a game (the code is below) using Tkinter were two players have to fill > a row, a column or a diagonal with either 'X' or 'O'. > When it happ

[Tutor] How to easily recover the current index when using Python-style for loops?

2015-02-05 Thread boB Stepp
Python 2.4.4, Solaris 10. a_list = [item1, item2, item3] for item in a_list: print 'Item number', ???, 'is:', item Is there an easy, clever, Pythonic way (other than setting up a counter) to replace ??? with the current index of item in a_list? -- boB ___

Re: [Tutor] How to easily recover the current index when using Python-style for loops?

2015-02-05 Thread boB Stepp
On Thu, Feb 5, 2015 at 11:45 AM, Zachary Ware wrote: > On Thu, Feb 5, 2015 at 11:30 AM, boB Stepp wrote: >> Python 2.4.4, Solaris 10. >> >> a_list = [item1, item2, item3] >> for item in a_list: >> print 'Item number', ???, 'is:', item >

Re: [Tutor] How to easily recover the current index when using Python-style for loops?

2015-02-05 Thread boB Stepp
On Thu, Feb 5, 2015 at 11:48 AM, Alan Gauld wrote: > On 05/02/15 17:30, boB Stepp wrote: >> >> Python 2.4.4, Solaris 10. >> >> a_list = [item1, item2, item3] >> for item in a_list: >> print 'Item number', ???, 'is:', item >> &

Re: [Tutor] How to easily recover the current index when using Python-style for loops?

2015-02-05 Thread boB Stepp
On Thu, Feb 5, 2015 at 12:25 PM, Mark Lawrence wrote: > > We're now at 3.4 with 3.5 close to its first alpha release, so any > particular reason that even 2.6 doesn't seem relevant to you? No axe to > grind, just plain old fashioned curiosity :) > We are not allowed to install or upgrade software

[Tutor] How to pass varying number of arguments to functions called by a dictionary?

2015-02-11 Thread boB Stepp
Python 2.4.4, Solaris 10 I have a file of functions. Based on what is read in a data file, different functions in the file of functions will need to be called. I have been trying to make the following approach work, so far unsuccessfully as, in general, each function may have a different number of

Re: [Tutor] How to pass varying number of arguments to functions called by a dictionary?

2015-02-11 Thread boB Stepp
On Wed, Feb 11, 2015 at 8:44 AM, eryksun wrote: > On Wed, Feb 11, 2015 at 7:27 AM, boB Stepp wrote: >> >> pass_args = {'a': (x1, x2, x3), 'b': (y1, y2), 'c': (z)} >> call_fcn[key_letter](key_letter) >> >> But ran into the syntax e

Re: [Tutor] How to pass varying number of arguments to functions called by a dictionary?

2015-02-11 Thread boB Stepp
On Wed, Feb 11, 2015 at 8:45 AM, Dave Angel wrote: > On 02/11/2015 08:27 AM, boB Stepp wrote: [...] > > Sure, it's viable, but the best approach depends on your goal (use case), > and your restrictions. Are these functions really totally unrelated to each > other? You not

Re: [Tutor] How to pass varying number of arguments to functions called by a dictionary?

2015-02-11 Thread boB Stepp
On Wed, Feb 11, 2015 at 10:58 AM, Dave Angel wrote: > On 02/11/2015 10:29 AM, boB Stepp wrote: >> >> On Wed, Feb 11, 2015 at 8:45 AM, Dave Angel wrote: >>> >>> On 02/11/2015 08:27 AM, boB Stepp wrote: [...] >>> In each case, there are probably better

[Tutor] What are *appropriate* uses for exec() and eval() ?

2015-02-16 Thread boB Stepp
I have heard periodically about the potential evils of using exec() and eval(), including today, on this list. I gather that the first requirement for safely using these functions is that the passed argument MUST be from a trusted source. So what would be examples where the use of these functions

[Tutor] Potential problem with Game Over 2.0 problem in "Python Programming for the Absolute Beginner, 3rd Ed."

2015-02-17 Thread boB Stepp
x27;t want to say too much for those working through this book, but the essence of the issue is illustrated by the following: Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:16:31) [MSC v.1600 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more inform

Re: [Tutor] Potential problem with Game Over 2.0 problem in "Python Programming for the Absolute Beginner, 3rd Ed."

2015-02-17 Thread boB Stepp
did, you leave no spaces between the last backslash and the EOL termination characters, then the problem behavior occurs. Actually, I realize I have a question: If I do the following in the Win7 command line Python interpreter: Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:16:31) [MSC v.1600 64

Re: [Tutor] Potential problem with Game Over 2.0 problem in "Python Programming for the Absolute Beginner, 3rd Ed."

2015-02-17 Thread boB Stepp
On Tue, Feb 17, 2015 at 1:47 PM, Dave Angel wrote: > On 02/17/2015 02:12 PM, boB Stepp wrote: > > See > https://docs.python.org/3.4/reference/lexical_analysis.html#string-and-bytes-literals >> >> >> At this point in the text he is not talking about raw literal strin

Re: [Tutor] Potential problem with Game Over 2.0 problem in "Python Programming for the Absolute Beginner, 3rd Ed."

2015-02-17 Thread boB Stepp
On Tue, Feb 17, 2015 at 3:05 PM, boB Stepp wrote: > This seems to be the case. On a related note, I wanted to copy and > paste the author's source code, showing how he generated the large, > "Game Over", but my Gmail keeps collapsing the white space, making the > res

Re: [Tutor] Potential problem with Game Over 2.0 problem in "Python Programming for the Absolute Beginner, 3rd Ed."

2015-02-17 Thread boB Stepp
On Tue, Feb 17, 2015 at 3:34 PM, Joel Goldstick wrote: > On Tue, Feb 17, 2015 at 4:05 PM, boB Stepp wrote: >> On Tue, Feb 17, 2015 at 1:47 PM, Dave Angel wrote: >>> On 02/17/2015 02:12 PM, boB Stepp wrote: >> This seems to be the case. On a related note, I wanted

[Tutor] OT: Preferred email client for sending plain text programming code snippets

2015-02-17 Thread boB Stepp
Hopefully this is not a touchy subject like Emacs vs. Vim. ~(:>)) My home PC uses Win7-64bit. I currently use Chrome, Gmail and have a Nexus 5 phone. The nice thing about all of this is that all of my information usually seamlessly syncs. That is nice! But I am getting increasingly frustrated with

Re: [Tutor] mySQL and Python

2015-02-18 Thread boB Stepp
On Wed, Feb 18, 2015 at 9:24 AM, James Chapman wrote: > One of my pet hates about this list... "This is a tutor list, your question > is out of scope". Sure there might be better places to seek answers, and > sure maybe the first responder doesn't know the answer, but that's not a > reason to resp

[Tutor] Strengths & weaknesses of Python lists compared to "old school" arrays [Was "Fixed Vector Array"]

2015-03-04 Thread boB Stepp
On Wed, Mar 4, 2015 at 12:04 PM, Alan Gauld wrote: > On 04/03/15 15:40, niyanax...@gmail.com wrote: >> >> Need help trying to implement insert, remove, indexof, and reverse >> functions. >> >> I tried to do them but am not sure if it is correct. I am struggling with >> arrays. > > > I;m not sure w

Re: [Tutor] Python 3 - bugs or installation problem

2015-03-04 Thread boB Stepp
On Wed, Mar 4, 2015 at 7:53 PM, Phil wrote: > I hope this is not another embarrassingly obvious answer to a simple > question. > > Python 3, under Kubuntu. > > xrange() fails whereas range() is accepted. Could this be an installation > problem? > etc This may fall into the obvious answer. ~(:>))

Re: [Tutor] Strengths & weaknesses of Python lists compared to "old school" arrays [Was "Fixed Vector Array"]

2015-03-05 Thread boB Stepp
Thank you very much Alan and Steve for your detailed answers. You have clarified many things and sent me off searching for more information on variant records, tagged and untagged unions, sparse arrays, linked lists, how memory allocation is affected by these topics and some other items. And I wo

Re: [Tutor] Idle - ImportError: No module named numpy

2015-03-06 Thread boB Stepp
On Fri, Mar 6, 2015 at 12:27 PM, Markos wrote: > Hi, > > I'm beginning to study the numpy. > > When I open a terminal (Debian Squeeze) and run the python interpreter the > command "import numpy as np" run without errors. > > But when I run the same command on idle3 the following error appears. > >

Re: [Tutor] print string using triple quote

2015-03-17 Thread boB Stepp
On Mon, Mar 16, 2015 at 11:13 PM, Nick Nguyen wrote: > > Hi, > I use python 3.4.3. > I'm using print function with triple quote, as I understand all the character > will be printed as exactly within the triple quote, even with the backslash > character. However as you see in the RESULT printout,

[Tutor] List comprehensions to search a list--amazing!

2015-03-18 Thread boB Stepp
I hope extolling the beauty and power of Python on this list is allowed, because I have had a large "WOW!!!" moment tonight. I had a problem I was working on at work this afternoon. I have a list of ~ 10,000 floating point numbers, which run from largest to smallest. There are duplicates scattered

[Tutor] What is the best approach to organizing the order of functions in a module?

2015-03-19 Thread boB Stepp
I'm still working in the procedural paradigm of programming. Hopefully I will find time for OOP soon. But in some of my modules-in-progress,my collection of functions has gotten large enough that I feel I need to bring some sort of order to their positioning. Currently my best thought is to mimic t

Re: [Tutor] List comprehensions to search a list--amazing!

2015-03-23 Thread boB Stepp
On Thu, Mar 19, 2015 at 12:10 AM, Dave Angel wrote: > The catch to a list comprehension is it has to visit all the elements, while > a binary search would visit log-base-2 of them. So instead of 1 > elements, you'd be searching about 14 items. I suspected as much, but had not verified this.

Re: [Tutor] List comprehensions to search a list--amazing!

2015-03-23 Thread boB Stepp
On Thu, Mar 19, 2015 at 4:52 AM, Peter Otten <__pete...@web.de> wrote: > Dave Angel wrote: [...] > By the way, if you were to use a plain old loop the expected speedup over > the listcomp would be 2. You can break out of the loop when you have found > the gap, after iterating over one half of the

[Tutor] Why does print(a_list.sort()) return None?

2015-03-28 Thread boB Stepp
I am puzzled by the following: Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. >>> a_list = [5, 0, 2, 4, 1] >>> print(a_list.sort()) None >>> print(a_list) [0, 1, 2, 4, 5] >>> I expecte

Re: [Tutor] Why does print(a_list.sort()) return None?

2015-03-28 Thread boB Stepp
On Sun, Mar 29, 2015 at 1:00 AM, Cameron Simpson wrote: > The former print: > > print(a_list.sort()) > > is printing the result of "a_list.sort()". > > Like most Python functions that operate on something (i.e. .sort, which > sorts the list in place), the .sort method returns None. And that is >

Re: [Tutor] Why does print(a_list.sort()) return None?

2015-03-29 Thread boB Stepp
On Sun, Mar 29, 2015 at 2:53 AM, Alan Gauld wrote: > On 29/03/15 07:00, Cameron Simpson wrote: > >> print(a_list.sort()) >> >> is printing the result of "a_list.sort()". >> >> Like most Python functions that operate on something (i.e. .sort, which >> sorts the list in place), the .sort method re

[Tutor] Unexpected results using enumerate() and .split()

2015-03-31 Thread boB Stepp
The following behavior has me stumped: Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> L = ['#ROI:roi_0', '#TXT:text_0', '#1:one^two^three'] >>> for i, item in enumerate(L): subitems = i

Re: [Tutor] Unexpected results using enumerate() and .split()

2015-03-31 Thread boB Stepp
On Tue, Mar 31, 2015 at 3:28 PM, Zachary Ware wrote: > On Tue, Mar 31, 2015 at 3:23 PM, boB Stepp wrote: >> The following behavior has me stumped: >> >> Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit >> (Intel)] on win32 >> Type "copyrig

Re: [Tutor] Unexpected results using enumerate() and .split()

2015-03-31 Thread boB Stepp
On Tue, Mar 31, 2015 at 3:32 PM, Dave Angel wrote: > On 03/31/2015 04:23 PM, boB Stepp wrote: >> >> The following behavior has me stumped: >> >> Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit >> (Intel)] on win32 >> Type "copyright&quo

<    1   2   3   4   5   6   7   >