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

2015-03-31 Thread boB Stepp
On Tue, Mar 31, 2015 at 3:42 PM, Zachary Ware wrote: > Also, not that since you aren't using the index for anything, you > don't need to use enumerate() to iterate over the list. Just do "for > item in L:". Of course, if you actually use the index in the real > code that I assume this was cut o

[Tutor] Use of "or" in a lambda expression

2015-04-04 Thread boB Stepp
Windows 7, Python 3.4.3 This code snippet is "Example 7-13" on page 383 from "Programming Python, 4th ed." by Mark Lutz : import sys from tkinter import * widget = Button(None, text='Hello event world!', command=(lambda: print('Hello lambda world!') or sys.exit())) widget

Re: [Tutor] Use of "or" in a lambda expression

2015-04-04 Thread boB Stepp
On Sat, Apr 4, 2015 at 12:34 PM, Steven D'Aprano wrote: > On Sat, Apr 04, 2015 at 11:49:08AM -0500, boB Stepp wrote: >> Windows 7, Python 3.4.3 >> >> This code snippet is "Example 7-13" on page 383 from "Programming >> Python, 4th ed." by

Re: [Tutor] Use of "or" in a lambda expression

2015-04-04 Thread boB Stepp
On Sat, Apr 4, 2015 at 12:34 PM, Steven D'Aprano wrote: > On Sat, Apr 04, 2015 at 11:49:08AM -0500, boB Stepp wrote: >> Windows 7, Python 3.4.3 >> >> This code snippet is "Example 7-13" on page 383 from "Programming >> Python, 4th ed." by

Re: [Tutor] Request review: A DSL for scraping a web page

2015-04-04 Thread boB Stepp
On Thu, Apr 2, 2015 at 2:49 PM, Albert-Jan Roskam wrote: > > - > On Thu, Apr 2, 2015 1:17 PM CEST Alan Gauld wrote: > >>On 02/04/15 12:09, Dave Angel wrote: >> >>> Ah, Jon Bentley (notice the extra 'e'). I should dig out my *Pearls >>> books, and have a trip down memor

Re: [Tutor] Use of "or" in a lambda expression

2015-04-04 Thread boB Stepp
On Sat, Apr 4, 2015 at 3:35 PM, Alan Gauld wrote: > He could have done it in various other ways too: > > eg. > lambda : all(print('Hello lambda world!'), sys.exit() ) Is this what you meant? Because print will always return False. Or did you actually mean: lambda: any(print('Hello lambda world!'

Re: [Tutor] Use of "or" in a lambda expression

2015-04-04 Thread boB Stepp
On Sat, Apr 4, 2015 at 6:55 PM, Alan Gauld wrote: > On 04/04/15 22:57, boB Stepp wrote: >> >> On Sat, Apr 4, 2015 at 3:35 PM, Alan Gauld >> wrote: >>> >>> He could have done it in various other ways too: >>> >>> eg. >>> lambda

Re: [Tutor] Use of "or" in a lambda expression

2015-04-05 Thread boB Stepp
On Sun, Apr 5, 2015 at 3:06 AM, Alan Gauld wrote: > On 05/04/15 04:45, boB Stepp wrote: > >>>>> He could have done it in various other ways too: >>>>> >>>>> eg. >>>>> lambda : all(print('Hello lambda world!'), sys.ex

[Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-06 Thread boB Stepp
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. >>> d = {'n': 'Print me!'} >>> d {'n': 'Print me!'} >>> d['n'] 'Print me!' >>> def func(d['n']): SyntaxError: invalid syntax >>> def func(d): p

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-06 Thread boB Stepp
Thanks, Joel! Thanks, Dave! On Mon, Apr 6, 2015 at 11:31 AM, Dave Angel wrote: [...] > Now, it's possible that what you're trying to do is something that can be > accomplished some other way. So please elaborate on your purpose in using > the syntax you did. Or supply a small program that sho

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-07 Thread boB Stepp
On Mon, Apr 6, 2015 at 12:54 PM, Dave Angel wrote: > On 04/06/2015 12:43 PM, boB Stepp wrote: > >> >> I was breaking down longer functions into smaller ones. Along the way >> I noticed I was passing an entire dictionary from one function to >> another. I only neede

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-07 Thread boB Stepp
On Mon, Apr 6, 2015 at 2:42 PM, Dave Angel wrote: > On 04/06/2015 03:20 PM, Emile van Sebille wrote: >> >> On 4/6/2015 7:54 AM, boB Stepp wrote: >>> [...] >> >> Maybe this form helps: >> >> Python 2.7.6 (default, Mar 22 2014, 22:59:56) >

Re: [Tutor] still breaking chains

2015-04-12 Thread boB Stepp
On Sun, Apr 12, 2015 at 6:47 PM, Ben Finney wrote: [...] > One important principle to follow is to write your statements to be very > simple, so that when something goes wrong it is as easy as possible to > read the statement and understand what it *actually* says. +1! This principle I have fou

[Tutor] How to get a Tkinter window to print a color copy of itself as a .pdf file?

2015-04-15 Thread boB Stepp
Solaris 10, Python 2.4.4 I have very little experience with issuing print commands using a Unix environment. Despite this, I wish to design a Tkinter window with a "Print" button, which, when clicked, would create a copy of the contents of the window as a .pdf file. GhostScript is available on my

Re: [Tutor] How to get a Tkinter window to print a color copy of itself as a .pdf file?

2015-04-15 Thread boB Stepp
On Wed, Apr 15, 2015 at 8:29 AM, Steven D'Aprano wrote: > On Wed, Apr 15, 2015 at 07:55:28AM -0500, boB Stepp wrote: >> Solaris 10, Python 2.4.4 >> >> I have very little experience with issuing print commands using a Unix >> environment. Despite this, I wish t

Re: [Tutor] How to get a Tkinter window to print a color copy of itself as a .pdf file?

2015-04-15 Thread boB Stepp
On Wed, Apr 15, 2015 at 8:50 AM, Zachary Ware wrote: > > On Apr 15, 2015 9:38 AM, "boB Stepp" wrote: >> Perhaps I am being foolish! But I do have my reasons, which, in this >> case, is I wanted to take advantage of the pack and grid geometry >> managers

Re: [Tutor] How to get a Tkinter window to print a color copy of itself as a .pdf file?

2015-04-15 Thread boB Stepp
On Wed, Apr 15, 2015 at 10:39 AM, Peter Otten <__pete...@web.de> wrote: > boB Stepp wrote: > >> Solaris 10, Python 2.4.4 [...] > > I'm on linux and surprisingly > > subprocess.call(["import", "-window", window_title, postscript_file]) >

Re: [Tutor] How to get a Tkinter window to print a color copy of itself as a .pdf file?

2015-04-15 Thread boB Stepp
On Wed, Apr 15, 2015 at 11:13 AM, Alan Gauld wrote: [...] > Your problem is that Tkinter does not really support the concept > of printing to hard copy. Other GUI frameworks (like WxPython) > do this much better. So anything you do will be a bit of a kluge. > There are some valid reasons for thi

[Tutor] How (not!) lengthy should functions be?

2015-04-16 Thread boB Stepp
As I go through my current coding project(s) I find myself breaking functions down into other functions, especially when I see see (unnecessarily) duplicated code fragments. I understand this to be regarded as good practice. However, I am wondering if I am carrying things too far? For instance I ha

Re: [Tutor] Using Class Properly - early beginner question

2017-03-21 Thread boB Stepp
On Tue, Mar 21, 2017 at 12:20 PM, Rafael Knuth wrote: > > While writing the parent class, I ran into the following issue: > How do I properly declare a variable that takes user input? > Do I write methods in the same fashion like in a regular function? > And how do I call that class properly? Wh

Re: [Tutor] Using Class Properly - early beginner question

2017-03-22 Thread boB Stepp
On Wed, Mar 22, 2017 at 7:30 AM, Rafael Knuth wrote: > thanks for your feedback! @boB > ...(it does what it's > supposed to do, but not sure if a pro would write it same way I did). I'll leave it to others to evaluate your function which I snipped as I am not a pro! ~(:>)) > > Besides that, I w

Re: [Tutor] Using Class Properly - early beginner question

2017-03-24 Thread boB Stepp
I'm forwarding this to Tutor. Please respond to the whole group and not just me personally, so you can have access to the experts as well as allowing all of us learners the opportunity to learn more. I can't respond now, but will try to do so later. On Fri, Mar 24, 2017 at 6:51 AM, Rafael Knuth

Re: [Tutor] Using Class Properly - early beginner question

2017-03-24 Thread boB Stepp
I'm forwarding this to Tutor. Please respond to the whole group and not just me personally, so you can have access to the experts as well as allowing all of us learners the opportunity to learn more. On Fri, Mar 24, 2017 at 9:05 AM, Rafael Knuth wrote: > I have another question :) > I noticed th

Re: [Tutor] Using Class Properly - early beginner question

2017-03-24 Thread boB Stepp
On Fri, Mar 24, 2017 at 6:51 AM, Rafael Knuth wrote: > Thank you so much for your help. > I have a question: When creating an instance of GroceryListMaker, you are > using: > > if __name__ == "__main__": > > What is that specifically for? > I tested your code and both worked, with and without > i

Re: [Tutor] Using Class Properly - early beginner question

2017-03-24 Thread boB Stepp
On Fri, Mar 24, 2017 at 9:05 AM, Rafael Knuth wrote: > I have another question :) > I noticed that you split your class into three methods: > > def __init__(self): > # initialize instances of class > > def make_shopping_list(self): > # input > > def display_shopping_list(self): > # output > > I wa

Re: [Tutor] test

2017-03-30 Thread boB Stepp
On Thu, Mar 30, 2017 at 4:11 PM, bruce wrote: > sent a question earlier.. and got a reply saying it was in the > moderation process??? You've made it through the process. See the bottom of https://mail.python.org/pipermail/tutor/2017-March/thread.html to see your original question and the answ

[Tutor] What would be good use cases for the enum module?

2017-04-08 Thread boB Stepp
After reading some discussion on the Python main list about the enum module and some suggested changes, I thought I would read the docs on it at https://docs.python.org/3/library/enum.html?highlight=enum#module-enum Most of the mechanics of using it, Enum in particular, seem understandable to me,

Re: [Tutor] What would be good use cases for the enum module?

2017-04-09 Thread boB Stepp
On Sat, Apr 8, 2017 at 11:13 PM, Steven D'Aprano wrote: > On Sat, Apr 08, 2017 at 10:00:21PM -0500, boB Stepp wrote: >> After reading some discussion on the Python main list about the enum >> module and some suggested changes, I thought I would read the docs on >> it at

Re: [Tutor] Count for loops

2017-04-11 Thread boB Stepp
On Tue, Apr 11, 2017 at 2:18 PM, Marc Tompkins wrote: > On Tue, Apr 11, 2017 at 9:48 AM, Rafael Knuth > wrote: > >> I tested this approach, and I noticed one weird thing: >> >> Pi_Number = str(3.14159265358979323846264338327950288419716939) >> Pi_Number = "3" + Pi_Number[2:] Minor note: If the

Re: [Tutor] Count for loops

2017-04-11 Thread boB Stepp
On Tue, Apr 11, 2017 at 3:43 PM, Alan Gauld via Tutor wrote: > On 11/04/17 19:44, Mats Wichmann wrote: > >> import decimal >> >> Pi_Number = >> str(decimal.Decimal(3.14159265358979323846264338327950288419716939)) >> > > Unfortunately that doesn't work either: > " " + str(decimal.Decimal( >

[Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-15 Thread boB Stepp
In the section https://docs.python.org/3/library/test.html#writing-unit-tests-for-the-test-package I have been trying to make sense of the given pointer and code snippet: Try to maximize code reuse. On occasion, tests will vary by something as small as what type of input is used. Minimize code

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-16 Thread boB Stepp
On Sat, Apr 15, 2017 at 6:31 PM, Alan Gauld via Tutor wrote: > On 16/04/17 00:17, boB Stepp wrote: > >> -- >> #!/usr/bin/env python3 >> >> def mySuperWhammyFunction(any_input): >&

Re: [Tutor] understanding code testing

2017-04-16 Thread boB Stepp
On Sat, Apr 15, 2017 at 9:33 AM, Rafael Knuth wrote: > can anyone point me to good learning resources on this subject? > (python 3) I have been liking "Testing Python -- Applying Unit Testing, TDD, BDD, and Acceptance Testing" by David Sale, c. 2014. If you are into developing web stuff, then yo

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-16 Thread boB Stepp
Thank you very much Martin; you filled in a lot of details. I had an overall understanding of what unittest does, but you have now enhanced that understanding substantially. I'm still iffy on how the mixin class gets its test method called when this class does not subclass from unittest.TestCase,

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-16 Thread boB Stepp
OK, between Alan and Martin I think that I see how to make the code snippet actually test a *function* as the snippet seems to suggest. Recollect that my original question(s) started: On Sat, Apr 15, 2017 at 6:17 PM, boB Stepp wrote: > In the section > > https://docs.python.org/

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-17 Thread boB Stepp
On Sun, Apr 16, 2017 at 11:50 PM, Mats Wichmann wrote: > > You got me thinking as well, as I don't much care for unittest, at least > partly because it forces you to use classes even when it doesn't feel > all that natural. I have looked into pytest multiple times, but have decided to stick with

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-17 Thread boB Stepp
Ah, Peter, if only I could achieve your understanding and mastery! On Mon, Apr 17, 2017 at 3:37 AM, Peter Otten <__pete...@web.de> wrote: > Perhaps it becomes clearer if we build our own class discovery / method > runner system. Given T as the baseclass for classes that provide foo_...() > method

Re: [Tutor] Tkinter and canvas question

2017-04-17 Thread boB Stepp
On Mon, Apr 17, 2017 at 6:13 PM, Phil wrote: > Thank you for reading this. > > How do I reference the_canvas from my solve() method? Despite hours of > searching I haven't been able to solve this or find a similar example. All > that I've gained is a headache. > > Exception in Tkinter callback >

Re: [Tutor] Tkinter and canvas question

2017-04-17 Thread boB Stepp
Sorry for the unnecessary post with no response -- inadvertent click on "Send" button which was too near Gmail's "..." button to expand content. On Mon, Apr 17, 2017 at 6:13 PM, Phil wrote: > Thank you for reading this. > > How do I reference the_canvas from my solve() method? Despite hours of >

Re: [Tutor] Tkinter layout question

2017-04-19 Thread boB Stepp
I don't know (now) how to solve your challenges below. But if I were trying to figure this out, I would try to find more complex tkinter example applications that contain some of the issues I'd be interested in. Then I would dig into the code, find the relevant pieces, and then start playing with

[Tutor] Button command arguments: Using class to wrap function call versus using lambda in tkinter

2017-04-22 Thread boB Stepp
Phil's recent postings have motivated me to try studying tkinter more systematically starting today, so I have been looking over available web resources. Playing around with the code in one such resource, I was looking at a section entitled "Arguments to Callbacks" towards the bottom of the page a

[Tutor] How to display radiobutton window with no buttons selected?

2017-04-24 Thread boB Stepp
Win7-64bit, Python 3.6.1 When I run the following code, the radiobutton window initially displays with *all* buttons apparently selected. However, when the "Status" button is clicked on, the status is as expected, an empty string for the checked_radiobutton StringVar(). =

Re: [Tutor] How to display radiobutton window with no buttons selected?

2017-04-25 Thread boB Stepp
On Tue, Apr 25, 2017 at 2:01 AM, Peter Otten <__pete...@web.de> wrote: > boB Stepp wrote: > >> Win7-64bit, Python 3.6.1 >> >> When I run the following code, the radiobutton window initially >> displays with *all* buttons apparently selected. However, when the &

Re: [Tutor] Sets question

2017-04-26 Thread boB Stepp
On Wed, Apr 26, 2017 at 7:33 PM, Phil wrote: > Another question I'm afraid. > > If I want to remove 1 from a set then this is the answer: > > set([1,2,3]) - set([1]) > > I had this method working perfectly until I made a change to cure another bug. > > So, I have a set represented in the debugger

Re: [Tutor] Sets question

2017-04-26 Thread boB Stepp
On Wed, Apr 26, 2017 at 8:34 PM, Phil wrote: > On Wed, 26 Apr 2017 18:56:40 -0600 > Mats Wichmann wrote: > >> On 04/26/2017 06:33 PM, Phil wrote: >> > Another question I'm afraid. >> > >> > If I want to remove 1 from a set then this is the answer: >> > >> > set([1,2,3]) - set([1]) >> > >> > I had

[Tutor] Difference between %f and %F string formatting?

2017-04-26 Thread boB Stepp
My Google-fu must be weak tonight. I cannot find any discernible difference between '%f' % and '%F' % . Is there any or do they duplicate functionality? If the latter, why are there two ways of doing the same thing? I had a similar question for %d and %i, but googling suggests these are inheri

Re: [Tutor] Difference between %f and %F string formatting?

2017-04-26 Thread boB Stepp
On Wed, Apr 26, 2017 at 9:19 PM, Tim Peters wrote: > [boB Stepp ] >> My Google-fu must be weak tonight. > > Look here: > > https://en.wikipedia.org/wiki/Printf_format_string Thanks. From the %d versus %i links I found, I should have pursued the C history more diligently

Re: [Tutor] Thread Object integration with GPIO

2017-04-29 Thread boB Stepp
On Sat, Apr 29, 2017 at 1:26 PM, Marc Eymard wrote: > Hello there, > Attached the script I have come up with, which keeps returning multiple > run time errors whenever I try to fix it. > I believe there are multiple issues, but at least it gives an idea of > what I currently want to achieve and h

Re: [Tutor] Python 3.6 Extract Floating Point Data from a Text File

2017-04-30 Thread boB Stepp
Hello Stephen! On Sun, Apr 30, 2017 at 5:09 AM, Stephen P. Molnar wrote: > > I am using the Spyder v-3.1.2 IDE and porting a FORTRAN program that I wrote > about 20 years ago to Python Unfortunately, I am very much a novice in > Python . > > I would have managed to extract input data from anothe

Re: [Tutor] Python Bind DNS Zone config

2017-05-03 Thread boB Stepp
Hello Nathan! On Wed, May 3, 2017 at 4:40 AM, Nathan D'Elboux wrote: > > What i am trying to do is have the below syntax somehow stored into a block > of strings exactly in this syntax. I dont know what data type i should be > trying to store this as, a string obviously but how would i preserve

Re: [Tutor] No file or directory error using subprocess and Popen

2017-05-14 Thread boB Stepp
On Sun, May 14, 2017 at 10:57 PM, Jim wrote: > I am running this on Mint 18. > This is the third script I have written to open and position windows in > workspaces. The first two work, but trying to open ebook-viewe r (calibre) > with a specific book produces the following error. > If I run the sa

[Tutor] Given a string, call a function of that name

2017-05-16 Thread boB Stepp
My son (Now 13 years old.) is merrily programming away in Python 3 (Of course!) and has many projects he is working on. Today he resumed work on his efforts to create a natural language parser, which he hopes will enable people to type in commands to a DnD-like game using natural English. An ambi

Re: [Tutor] Given a string, call a function of that name

2017-05-17 Thread boB Stepp
On Wed, May 17, 2017 at 1:42 AM, Peter Otten <__pete...@web.de> wrote: > boB Stepp wrote: >> Oh, and I suppose I should ask for a critique of the code as written >> for appropriate Python style, proper targeted function use, etc. I am >> always eager to learn! > &g

Re: [Tutor] Problem with if statements and else statements

2017-05-27 Thread boB Stepp
Hello Jalen! On Sat, May 27, 2017 at 4:19 PM, Jalen Barr wrote: > > In this code it always changes the PlaceHolder to 0 no matter what Month is > set to > > Month ="September" > > if Month == "January" or "1": > PlaceHolder = 0 This must be written as: if Month == "January" or Month == "1":

Re: [Tutor] Python __del__ method

2017-07-11 Thread boB Stepp
On Tue, Jul 11, 2017 at 7:13 PM, eryk sun wrote: > On Wed, Jul 12, 2017 at 12:07 AM, eryk sun wrote: >> On Tue, Jul 11, 2017 at 2:47 PM, Jia Yue Kee >> wrote: >>> >>> Case 2: If I were to run the code in "Interactive Mode", the following >>> output will be obtained: >>> >> x = Robot("Tik-T

Re: [Tutor] Python __del__ method

2017-07-11 Thread boB Stepp
On Tue, Jul 11, 2017 at 7:24 PM, Alan Gauld via Tutor wrote: > On 11/07/17 15:47, Jia Yue Kee wrote: >> I am new to Python and I came across the Python __del__ method > > The __del__() method is a bit of an oddity and often not > used in industrial strength Python code. > >> if __name__ == "__main

Re: [Tutor] basic decorator question

2017-07-26 Thread boB Stepp
On Mon, Jul 24, 2017 at 11:01 AM, Steven D'Aprano wrote: > > There's more to decorators than that, but hopefully that will > demonstrate some of the basic concepts. Feel free to ask any more > questions on the mailing list, and we will answer if we can. > I hope I can ask questions, too! ~(:>))

[Tutor] What is meaning of "/" in "pow(x, y, z=None, /)"?

2017-08-01 Thread boB Stepp
I had typed help(pow) in the interpreter and got: py3: help(pow) Help on built-in function pow in module builtins: pow(x, y, z=None, /) Equivalent to x**y (with two arguments) or x**y % z (with three arguments) Some types, such as ints, are able to use a more efficient algorithm when

Re: [Tutor] What is meaning of "/" in "pow(x, y, z=None, /)"?

2017-08-01 Thread boB Stepp
On Tue, Aug 1, 2017 at 8:25 PM, Ben Finney wrote: > Steven D'Aprano writes: > >> Its quite new. Up until recently, the documentation didn't distinguish >> between function parameters which can take optional keywords and those >> that can't. > > Where does the documentation describe this distincti

Re: [Tutor] What is meaning of "/" in "pow(x, y, z=None, /)"?

2017-08-02 Thread boB Stepp
On Wed, Aug 2, 2017 at 1:59 AM, eryk sun wrote: > On Wed, Aug 2, 2017 at 1:06 AM, boB Stepp wrote: >> A quick scan of some of my Python books does not turn up the use of >> "/" as a function argument. I have a nagging feeling I've read about >> this somewhe

Re: [Tutor] (no subject)

2017-08-03 Thread boB Stepp
Greetings Howard! On Thu, Aug 3, 2017 at 3:27 PM, Howard Lawrence <1019sh...@gmail.com> wrote: > hi ! i am newbie to coding love it but need help with problems which i > searched but poor results this is the error: typeError unorderable types: > int() the code in short, number=random.randint(1,20)

Re: [Tutor] Unorderable types

2017-08-04 Thread boB Stepp
On Fri, Aug 4, 2017 at 8:44 PM, Cameron Simpson wrote: > [ Back onto the tutor list. - Cameron ] > > On 04Aug2017 09:12, Howard Lawrence <1019sh...@gmail.com> wrote: >> >> This is the code from tutorial > > > Thank you. > >> import random >> guessesTaken =0 >> >> print ('hello what is your name')

Re: [Tutor] unorderable types

2017-08-06 Thread boB Stepp
On Sat, Aug 5, 2017 at 1:28 PM, Howard Lawrence <1019sh...@gmail.com> wrote: > # this is a guess number game. > import random > > guessesTaken = 0 > > print('hello! What is your name?') > myName = input() > > number = random.randint(1, 20) > print('Well, ' + myName + ', i am thinking of a number be

Re: [Tutor] unorderable types

2017-08-06 Thread boB Stepp
On Sun, Aug 6, 2017 at 1:23 PM, Mats Wichmann wrote: > Meanwhile, it is worth pointing out that while: (as with other python > loops) can take an else: clause, which is executed if the loop runs to > completion and was not exited via break. That means you could ALSO > write (this is pseudo-code

Re: [Tutor] unorderable types

2017-08-06 Thread boB Stepp
Curses! I screwed up my later insertion. I should have written in my footnote: On Sun, Aug 6, 2017 at 3:20 PM, boB Stepp wrote: > [1] An exception is "Beginning Python -- From Novice to Professional, > 3rd ed." by Magnus Lie Hetland, c. 2017. I recently acquired this > b

[Tutor] Difference(s) betweenPython 3 static methods with and without @staticmethod?

2017-08-06 Thread boB Stepp
I am looking more deeply into the subject of decorators for a bit (So I can thoroughly digest Steve's information in the thread "basic decorator question".) and have been first looking at static and class methods. As a start, I have tried the following: ===

Re: [Tutor] Difference(s) betweenPython 3 static methods with and without @staticmethod?

2017-08-07 Thread boB Stepp
it appeared. And alas! I don't know how to swim! On Mon, Aug 7, 2017 at 8:36 AM, Steven D'Aprano wrote: > On Sun, Aug 06, 2017 at 06:35:10PM -0500, boB Stepp wrote: > >> py3: class MyClass: >> ... def my_method(): >> ... print('This is my

[Tutor] How does len() compute length of a string in UTF-8, 16, and 32?

2017-08-07 Thread boB Stepp
py3: s = 'Hello!' py3: len(s.encode("UTF-8")) 6 py3: len(s.encode("UTF-16")) 14 py3: len(s.encode("UTF-32")) 28 How is len() getting these values? And I am sure it will turn out not to be a coincidence that 2 * (6 + 1) = 14 and 4 * (6 + 1) = 28. Hmm ... -- boB _

Re: [Tutor] How does len() compute length of a string in UTF-8, 16, and 32?

2017-08-08 Thread boB Stepp
On Mon, Aug 7, 2017 at 10:01 PM, Ben Finney wrote: > boB Stepp writes: > >> How is len() getting these values? > > By asking the objects themselves to report their length. You are > creating different objects with different content:: > > >>> s = 'H

Re: [Tutor] How does len() compute length of a string in UTF-8, 16, and 32?

2017-08-08 Thread boB Stepp
On Mon, Aug 7, 2017 at 10:04 PM, Zachary Ware wrote: > Next, take a dive into the wonderful* world of Unicode: > > https://nedbatchelder.com/text/unipain.html > https://www.youtube.com/watch?v=7m5JA3XaZ4k > > Hope this helps, Thanks, Zach, this actually clarifies things considerably. I just fin

Re: [Tutor] How does len() compute length of a string in UTF-8, 16, and 32?

2017-08-08 Thread boB Stepp
On Mon, Aug 7, 2017 at 10:20 PM, Cameron Simpson wrote: > On 07Aug2017 21:44, boB Stepp wrote: >> >> py3: s = 'Hello!' >> py3: len(s.encode("UTF-8")) >> 6 >> py3: len(s.encode("UTF-16")) >> 14 >> py3: len(s.encode("

Re: [Tutor] How does len() compute length of a string in UTF-8, 16, and 32?

2017-08-08 Thread boB Stepp
On Mon, Aug 7, 2017 at 11:30 PM, eryk sun wrote: > On Tue, Aug 8, 2017 at 3:20 AM, Cameron Simpson wrote: >> >> As you note, the 16 and 32 forms are (6 + 1) times 2 or 4 respectively. This >> is because each encoding has a leading byte order marker to indicate the big >> endianness or little endi

Re: [Tutor] How does len() compute length of a string in UTF-8, 16, and 32?

2017-08-08 Thread boB Stepp
On Tue, Aug 8, 2017 at 10:29 PM, Mats Wichmann wrote: > eh? the bytes are ff fe h 0 > 0xff is not literally four bytes, its the hex repr of an 8bit quantity with > all bits on ARG! (space inserted for visual clarity) truly is ff in hex. Again ARGH!!! All I can say is that I have

Re: [Tutor] How does len() compute length of a string in UTF-8, 16, and 32?

2017-08-08 Thread boB Stepp
On Tue, Aug 8, 2017 at 10:17 PM, boB Stepp wrote: > On Mon, Aug 7, 2017 at 10:01 PM, Ben Finney > wrote: >> boB Stepp writes: >> >>> How is len() getting these values? >> > > It is translating the Unicode code points into bits patterned by the >

Re: [Tutor] Difference(s) betweenPython 3 static methods with and without @staticmethod?

2017-08-08 Thread boB Stepp
On Tue, Aug 8, 2017 at 2:39 AM, Alan Gauld via Tutor wrote: > On 08/08/17 02:22, boB Stepp wrote: [snip lots of good stuff] I am coming to the conclusion I need to code a substantial, challenging project using OOP techniques, instead of just the toy programs I have been playing around with

Re: [Tutor] How does len() compute length of a string in UTF-8, 16, and 32?

2017-08-10 Thread boB Stepp
On Thu, Aug 10, 2017 at 8:01 AM, Steven D'Aprano wrote: > > Another **Must Read** resource for unicode is: > > The Absolute Minimum Every Software Developer Absolutely Positively Must > Know About Unicode (No Excuses!) > > https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-softwa

Re: [Tutor] How does len() compute length of a string in UTF-8, 16, and 32?

2017-08-10 Thread boB Stepp
On Thu, Aug 10, 2017 at 8:40 PM, boB Stepp wrote: > On Thu, Aug 10, 2017 at 8:01 AM, Steven D'Aprano wrote: >> Python 3 makes Unicode about as easy as it can get. To include a unicode >> string in your source code, you just need to ensure your editor saves >> the file

[Tutor] Long post: Request comments on starting code and test code on chess rating project.

2017-08-12 Thread boB Stepp
I mentioned in one of the recent threads that I started that it is probably time for me to attempt a substantial project using the OO paradigm. I have had no coursework or training in OOP other than my recent self-studies. Everything (Other than toy practice examples.) I have coded to date has be

Re: [Tutor] Long post: Request comments on starting code and test code on chess rating project.

2017-08-13 Thread boB Stepp
It is rather late here, so I won't get to the links until much later today, but ... On Sun, Aug 13, 2017 at 1:42 AM, Steven D'Aprano wrote: > I haven't had a chance to read the entire post in detail, but one thing > which stands out: > > On Sun, Aug 13, 2017 at 12:22:

Re: [Tutor] Long post: Request comments on starting code and test code on chess rating project.

2017-08-13 Thread boB Stepp
Based upon the feedback thus far (Many thanks!) I think that perhaps I should expand on my design thoughts as I have already stubbed my big toe at the very start! On Sun, Aug 13, 2017 at 12:22 AM, boB Stepp wrote: > The intent of this project is more than just calculate chess rati

Re: [Tutor] Long post: Request comments on starting code and test code on chess rating project.

2017-08-13 Thread boB Stepp
On Sun, Aug 13, 2017 at 3:52 AM, Peter Otten <__pete...@web.de> wrote: > boB Stepp wrote: >> I am only at the very beginning of coding this class. I have not >> added any methods yet. Currently I am adding class constants that >> will be used in this class' m

Re: [Tutor] Long post: Request comments on starting code and test code on chess rating project.

2017-08-13 Thread boB Stepp
On Sun, Aug 13, 2017 at 5:49 PM, Alan Gauld via Tutor wrote: > On 13/08/17 21:15, boB Stepp wrote: > > I return to the point I made about focusing on the > objects not the functionality. > >> It is not very well-written in my opinion. But anyway ... The basic formula &g

Re: [Tutor] Long post: Request comments on starting code and test code on chess rating project.

2017-08-15 Thread boB Stepp
On Tue, Aug 15, 2017 at 12:29 PM, Alan Gauld via Tutor wrote: > On 15/08/17 15:09, Neil Cerutti wrote: > >>> There are a variety of reports that I would like to be able to >>> print to screen or paper. Things such as a "Top x List" of >>> rated players, full rating list sorted from highest rating

Re: [Tutor] pygame not working

2017-08-16 Thread boB Stepp
On Wed, Aug 16, 2017 at 11:33 AM, Quantz Jeremy wrote: > I’m not sure if I should be asking here about this, but on my Mac computer, > Pygame keeps crashing on me. I have Python 2.7.13 (I can’t use Python 3 > because I’m learning from and online course and he’s using Python 2.7.13. > Unless you

Re: [Tutor] When to use classes

2017-08-18 Thread boB Stepp
On Fri, Aug 18, 2017 at 9:56 PM, Steven D'Aprano wrote: > Mostly for Bob, but also for anyone else interested: I guess I'm the "Bob" being referred to. > When To Use Classes > > http://kentsjohnson.com/stories/00014.html > > > He says: > > You may have several functions that use the same sta

Re: [Tutor] When to use classes

2017-08-19 Thread boB Stepp
On Sat, Aug 19, 2017 at 3:07 AM, Alan Gauld via Tutor wrote: > On 19/08/17 08:52, Alan Gauld via Tutor wrote: > > Following up my own post - a sure sign of failure to communicate :-( > >> On 19/08/17 05:26, boB Stepp wrote: >> >>> related methods needs to share

Re: [Tutor] When to use classes

2017-08-19 Thread boB Stepp
On Sat, Aug 19, 2017 at 4:04 AM, Peter Otten <__pete...@web.de> wrote: > Steven D'Aprano wrote: > >> Mostly for Bob, but also for anyone else interested: >> >> When To Use Classes >> >> http://kentsjohnson.com/stories/00014.html > > Just a minor nit, but you don't even need a custom function for th

Re: [Tutor] When to use classes

2017-08-20 Thread boB Stepp
On Sat, Aug 19, 2017 at 8:08 PM, Steven D'Aprano wrote: > The Art of Subclassing > > http://www.youtube.com/watch?v=miGolgp9xq8 > > If its the one which starts off with him talking about his newly born > child, it is the one. This is indeed the "one"! > The traditional viewpoint of inheritance

[Tutor] How to use subprocess module to get current logged in user?

2017-08-25 Thread boB Stepp
SunOS 5.10, Python 2.4/2.6 I ask forgiveness in advance as I cannot copy and paste into an email what I am doing on this system. So I will have to manually type things, introducing the usual possibility of typos. My objective: Determine who the currently logged in user is and determine if that

Re: [Tutor] How to use subprocess module to get current logged in user?

2017-08-25 Thread boB Stepp
On Fri, Aug 25, 2017 at 8:33 PM, Steven D'Aprano wrote: > On Fri, Aug 25, 2017 at 07:13:12PM -0500, boB Stepp wrote: > >> My objective: Determine who the currently logged in user is > > py> import os > py> os.getlogin() > 'steve' Sweet! Much b

[Tutor] Best way to get root project directory in module search path

2017-08-26 Thread boB Stepp
SunOS 5.10, Python 2.4/2.6. Again, please forgive any typos as I am having to manually enter everything. I must confess that even though I've asked about similar topics in the past, I still don't think I'm fully "getting it". I have a project structure where I am developing various programs, som

Re: [Tutor] How to use subprocess module to get current logged in user?

2017-08-26 Thread boB Stepp
Thanks Alan (and Mats)! It appears there are many ways to skin this cat! On Sat, Aug 26, 2017 at 2:21 AM, Alan Gauld via Tutor wrote: > >> My objective: Determine who the currently logged in user is and >> determine if that user is in my list of users that I have authorized >> to use my program

Re: [Tutor] Best way to get root project directory in module search path

2017-08-27 Thread boB Stepp
On Sun, Aug 27, 2017 at 2:13 AM, Cameron Simpson wrote: > On 26Aug2017 21:27, boB Stepp wrote: >> >> I have a project structure where I am developing various programs, >> some in Pinnacle HotScript language, some in Perl, some in Python, >> some shell scripts. For t

Re: [Tutor] Best way to get root project directory in module search path

2017-08-28 Thread boB Stepp
On Sun, Aug 27, 2017 at 6:03 PM, Cameron Simpson wrote: > On 27Aug2017 14:27, boB Stepp wrote: >> >> On Sun, Aug 27, 2017 at 2:13 AM, Cameron Simpson wrote: >>> >>> On 26Aug2017 21:27, boB Stepp wrote: >>> The trouble with this specific approach

Re: [Tutor] New to Python

2017-09-07 Thread boB Stepp
Welcome to Tutor! On Thu, Sep 7, 2017 at 8:14 AM, Vikram Singh wrote: > I've been learning Python from Google For Education > . A little help will be > appreciated regarding the right way and right tutorials to learn Python > from. Thanks in advance. Th

Re: [Tutor] Help

2017-09-07 Thread boB Stepp
Greetings Edmundo! On Thu, Sep 7, 2017 at 1:35 PM, Peter Otten <__pete...@web.de> wrote: > edmundo pierre via Tutor wrote: > >> >> I am trying to write a code that asks an User to Enter a decimal number, >> the my program should separate the number in two parts like this: 1 >> cae:Enter a number:

[Tutor] How is database creation normally handled?

2017-09-09 Thread boB Stepp
While reading about SQL, SQLite and the Python module sqlite3, it appears that I could (1) have a program check for the existence of the program's database, and if not found, create it, make the tables, etc.; or, (2) create the database separately and include it with the program. What are the pros

[Tutor] Standard module sqlite3 or APSW?

2017-09-09 Thread boB Stepp
First, if I have not misinterpreted anything, the subject header is perhaps better written as "pysqlite or APSW?" As far as I can tell from reading the documentation at https://docs.python.org/3/library/sqlite3.html , the module sqlite3 is in actuality using the pysqlite project. So if all of thi

Re: [Tutor] beginning to code

2017-09-10 Thread boB Stepp
Hello kerbi! On Sun, Sep 10, 2017 at 6:32 AM, Elmar Klein wrote: > Hi there, > > im starting to learn how to code (bougt me the "automate the boring stuff > with phyton" book). > > And im not going anywhere with a code sample using the "continue" statement. > > The code i should try is as followi

[Tutor] How to write database-agnostic python code? (Is this even possible?)

2017-09-12 Thread boB Stepp
As I continue to read about SQL, one thing jumps out: There are many differences between how SQL statements are implemented among the different database products. Even for relatively simple, straightforward things like field concatenation. One DB might use "||" as the operator. Another uses "+"

<    1   2   3   4   5   6   7   >