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

2015-03-18 Thread boB Stepp
= S[0] I tested this out with concrete examples in the interpreter, such as with a list, L: L = [item for item in range(1, 0, -1)] and trying different test values. It was blazingly fast, too! All I can say is: WOW!!! -- boB ___ Tutor maillist - Tu

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

2015-03-19 Thread boB Stepp
mimic the natural order, in so far as it is possible, in which the functions get called. Are there better ways to organize them? -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/ma

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

2015-03-23 Thread boB Stepp
irectly use those functions on a list which is > reverse-sorted, but the source is available. On my install, it's located > at: > > /usr/lib/python3.4/bisect.py And I see this is available on my oldest Python installlation, 2.4.4, too. -- boB ___

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

2015-03-23 Thread boB Stepp
oops, best of 3: 221 usec per loop > > So reverse/bisect is 50 times faster than the listcomp, and > bisect/virt is 3500 times faster than the listcomp. You present a compelling case! > I expect that a prepackaged linear interpolation function from numpy/scipy > can still do better, and also handle the corner cases correctly. To use such > a function you may have to reverse order of the values. This is not an option for me as I would not be allowed to install numpy/scipy. -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

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

2015-03-28 Thread boB Stepp
)) None >>> print(a_list) [0, 1, 2, 4, 5] >>> I expected the first print statement to return what the second one did. Apparently the first print printed a_list, then did the sort. Why is this so? -- boB ___ Tutor maillist - Tut

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

2015-03-28 Thread boB Stepp
t method returns None. And that is > printed. Ah! I did not realize this. That makes sense now. Many thanks, Cameron! boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

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

2015-03-29 Thread boB Stepp
at sorted() was an available option. I had focused on available list methods. While it does not matter if my actual lists do or do not get sorted, my intent was to just have a sorted view of the list, so your suggestion works better here and uses one less line of code. Thanks! -- boB __

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

2015-03-31 Thread boB Stepp
d the indentation that was present in the interpreter. I added spaces manually to get it appear as it did in the interpreter. Anyone know why Gmail does that to my copy and paste? -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

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

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

2015-03-31 Thread boB Stepp
code that I assume this was cut out of, keep enumerate; it's the right > tool for the job. Yeah, I simplified my actual code into the smallest snippet that I could reproduce my problem in. My actual code need the index. -- boB ___ Tutor maillis

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

2015-04-04 Thread boB Stepp
pecting the 'or' to result only in the print running without executing sys.exit(). But that is not what happens--of course. I tried substituting 'and' for 'or', but this results in only the print being run! Obviously I have a significant misunderstanding of what is

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
nterfaces. Most programmers should be familiar users of such technologies. At the center of each of those areas, though, is a hard core of programming problems. Those programs remain the theme of this book. This edition of the book is a slightly larger fish in a much larger pond. ..." HTH -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

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

2015-04-04 Thread boB Stepp
nt('Hello lambda world!'), sys.exit()) > But the OR style is established as a kind of idiom, > not just in Python but several other languages too. So this is not unusual for Python. BTW, what are some of the other languages where this type of expres

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
>>> d['n'] 'Print me!' >>> def func(d['n']): SyntaxError: invalid syntax >>> def func(d): print d['n'] >>> func(d) Print me! The plain text does not show it, but in the invalid syntax the &q

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

2015-04-06 Thread boB Stepp
icular value, not the whole dictionary, so that is how I got into the issue I asked about. Once you and Joel responded it was *obvious*. A bunch of years ago, it would have been *obvious* and I never would have asked the question in the first place. This is easy enough to correct now that I realize

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
chance of *immediately* understanding my intent, then when I have to decipher my thoughts from a "one-liner" that might occupy less space, but where its complexity has me pausing in thought to be sure I understand what I actually was trying to do. -- boB __

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

2015-04-15 Thread boB Stepp
ething*, but how do I get it to print the specific window containing the to-be-designed print button? Also, I need it to print a postscript file, not print to paper. I suspect this is another configuration setting that I need to research. As always, many th

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
jects it might be very useful. However, I should work on mastering Tkinter first, as I am sure that all of the principles I learn here will be generically useful for any GUI programming. Thanks, Alan! -- boB ___ Tutor maillist - Tutor@python.org To unsub

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

2015-04-16 Thread boB Stepp
en on one's monitor. Of course, some people have HUGE monitors! And I assume that any guidance applies equally well to methods. Am I on-track or am I getting carried away? -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or

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

2017-03-21 Thread boB Stepp
thon Code\PPC_28.py == > Traceback (most recent call last): > File "C:\Users\Rafael\Documents\01 - BIZ\PYTHON\Python > Code\PPC_28.py", line 136, in > Tesco.CreateShoppingList() > TypeError: CreateShoppingList() missing 3 required positional > argume

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! ~(:>)

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

2017-03-24 Thread boB Stepp
now has the following items:\n') >> for item_number, item in enumerate(self.shopping_list): >> print('%s. %s' % (item_number, item)) >> >> if __name__ == '__main__': >> my_shopping_list = GroceryListMaker() >> my_shopping_list.make_shopping_list() >> my_shopping_list.display_shopping_list() -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

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

2017-03-24 Thread boB Stepp
t now has the following items:\n") > for item_number, item in enumerate(self.shopping_list): > print("%s. %s" % (item_number, item)) > > if __name__ == "__main__": > my_shopping_list = GroceryListMaker() > my_shopping_list.make_shopping_li

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
;. This makes things easier for people to understand my code, breaks apart unnecessary interdependencies that would otherwise exist in "big" methods/functions, makes it easier for me to write tests for each function without having to worry about unnecessary dependencies that I will have simulate

Re: [Tutor] test

2017-03-30 Thread boB Stepp
ion and the answers. -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

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

2017-04-08 Thread boB Stepp
ng an even harder time imagining what I would want to use Enum for if I don't care about the values assigned to the names and use auto to automatically assign values. I am having a real crisis of imagination here! Anyone with some commonplace and practical applications of the enum module? TIA

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
: py3: new_pi = '3' + '.' + str(14159265358979323846264338327950288419716939) py3: len(new_pi) 46 py3: new_pi '3.14159265358979323846264338327950288419716939' since in Python 3 integers are unlimited in precision (within RAM constraints). I guess this has to be this way o

Re: [Tutor] Count for loops

2017-04-11 Thread boB Stepp
tring(), but I see no substitute for str() listed. Surely there is some way to use the decimal module to get the desired conversion to a string? I have to retire for the evening and will try to figure this out tomorrow. Cheers! boB ___ Tutor maillist

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

2017-04-15 Thread boB Stepp
that both an object instance and self.arg is getting passed to mySuperWhammyFunction(), but I am not seeing how the object instance is getting passed -- if my suspicion is indeed correct. I also am not truly understanding how this code is working within the unittest framework. Help! TIA! boB _

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
web stuff, then you might like "Test-Driven Development with Python -- Obey the Testing Goat: Using Django, Selenium, and JavaScript" by Harry J. W. Percival, c. 2014. -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change s

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

2017-04-16 Thread boB Stepp
ethods that might exist in those superclasses. Is this correct or do I have a conceptual misunderstanding? > - collect the success / failure and any outputs > > - report on the success / failure > > - produce some final summary output and set the exit code > ac

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
omething similar in unittest, so put off pytest for another day. I cannot remember now what I did. I need to go back and find that code (If I still have it.) and compare it with this Mixin approach that I started this whole thread with. Nonetheless pytest is definitely on my radar and I wil

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

2017-04-17 Thread boB Stepp
thon3 discovery6.py > found with foo_... methods > Y one > Y two > found with foo_... methods > X x > > That was easy. We have replicated something similar to the unit test > framework with very little code. > > Now you can go and find the equivalent parts in the unittest source code :) But not tonight ~(:>)) -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Tkinter and canvas question

2017-04-17 Thread boB Stepp
20,20,text="5") > > > def main(): > root = Tk() > app = Sudoku(root) > app.mainloop() > > if __name__ == '__main__': > main() > > > -- > Regards, > Phil > ___ > Tutor maillis

Re: [Tutor] Tkinter and canvas question

2017-04-17 Thread boB Stepp
.create_text(20,20,text="5") > > > def main(): > root = Tk() > app = Sudoku(root) > app.mainloop() > > if __name__ == '__main__': > main() > > > -- > Regards, > Phil > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Tkinter layout question

2017-04-19 Thread boB Stepp
for you in your use case, but perhaps it is something to think about. In the Grayson book he has lots of examples of achieving very precise spacing and placement of widgets, etc. Just some thoughts. Perhaps they might inspire a creative thought or two. Of course one of the

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

2017-04-22 Thread boB Stepp
= And this also works well. Seeing as this approach has fewer lines of code and reads clearly, what advantages would the class wrapper approach have? The only thing that is occurring to me in my current sleepy state is that the class wrapper is m

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

2017-04-24 Thread boB Stepp
riable=checked_radiobutton, value=language).pack(anchor='w') checked_radiobutton.set('') tk.Button(root, text='Status', command=status).pack(fill='x') root.mainloop() I wish

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
ve not > discovered how to remove the '' marks. How do I achieve that? I probably don't understand what you are really trying to do, but {1, 2, 3} - {int('1')} does the obvious. But I am guessing that this is not what you want. Perhaps you can provide more context, or pe

Re: [Tutor] Sets question

2017-04-26 Thread boB Stepp
ox, which looks like {1} (no > '' marks). If I then turn this number into a set then the result is {'1'}. > > num = self.entry_grid[row][col].get() I would think that it is here that you would want to do the string-to-int

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

2017-04-26 Thread boB Stepp
g suggests these are inherited from differences in handling input in the C language, though I could not locate a Python example where there is a need for one or the other. Are there any relevant Python examples? -- boB ___ Tutor maillist - Tutor@python.o

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
Python you are using and your operating system. Hopefully someone here might be able to assist you with your issues. -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

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

2017-04-30 Thread boB Stepp
to go. Finally, when you need to actually use the extracted string resembling a float, you will have to convert that string using the float() function. Hope that something above is helpful! Cheers! -- boB ___ Tutor maillist - Tutor@python.org To unsu

Re: [Tutor] Python Bind DNS Zone config

2017-05-03 Thread boB Stepp
gt; > What i was thinking of doing is having a place holder of {} in place of > where i want the domain to be inserted into but i dont know how to > structure the syntax of a zone file in a function within Have you looked into string formatting? See: https://docs.python.org/3/tutorial/inp

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

2017-05-14 Thread boB Stepp
; 'calibre-ebook-viewer': 'libprs500'} > self.open_and_move() > > def open_it(self): > subprocess.call([self.program]) I'm not very familiar with using the subprocess module yet, but when the above call to "subprocess.call([self.program])" occurs, isn't subprocess.call() expecting a list like ['ebook-viewer', '/home/jfb ...'] ? Hope I am not off-track here. boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

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

2017-05-16 Thread boB Stepp
Would this be a case for a global function dictionary (Which I could also use to check for valid functions.) or perhaps a class which only exists to have this function dictionary? TIA! -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

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
t be written as: if Month == "January" or Month == "1": PlaceHolder = 0 The way you wrote it is interpreted as: if (Month == "January") or ("1"): PlaceHolder = 0 Hopefully you will see why you got the result you obtained. -- boB __

Re: [Tutor] Python __del__ method

2017-07-11 Thread boB Stepp
obot("Jenkins") Jenkins has been created! py3: z = x py3: z <__main__.Robot object at 0x02002160> py3: x <__main__.Robot object at 0x02002160> py3: del x py3: del z py3: del y Jenkins has been destroyed! py3: x Traceback (most recent call last): File "", line 1, in NameError: name 'x' is not defined py3: z Traceback (most recent call last): File "", line 1, in NameError: name 'z' is not defined py3: _ <__main__.Robot object at 0x02002160> py3: x = 1 py3: _ <__main__.Robot object at 0x02002160> py3: x Tik-Tok has been destroyed! 1 -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python __del__ method

2017-07-11 Thread boB Stepp
but you can't count on it. > I am assuming that when the OP ran his code from a file, that upon the script's completion, both object instances were garbage collected. Surely upon program completion, everything _is_ garbage collected? > I confess I don't fully understand the re

Re: [Tutor] basic decorator question

2017-07-26 Thread boB Stepp
ions, then I would be DRY-er by taking this approach -- I would need only one decorator function and could then use it decorate as many other functions as it made sense to do so. So some guidance, please, on what types of problems this approach is useful for? TIA! -- boB _

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

2017-08-01 Thread boB Stepp
at brings up an answer (Yet.). TIA! -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

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

2017-08-01 Thread boB Stepp
>^ > SyntaxError: invalid syntax I gather from this example that "/" is *not* a syntactical element, but is instead meant to augment natural English explanation. Anyway, thanks very much Steve and Ben! -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

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
t looking. If this does not help then you need to resend your message with your full code and full traceback unless someone else has better oracle abilities... ~(:>)) -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Unorderable types

2017-08-04 Thread boB Stepp
lt;' not supported between instances of 'str' and 'int' I am running Python 3.6.1 on Windows 7 64-bit. Off-list Howard told me that he is running Python 3.5 on Windo

Re: [Tutor] unorderable types

2017-08-06 Thread boB Stepp
ion will handle that for us. Also, with the print function if items to be printed are listed as separate arguments, that is, separated by commas, the default behavior of print is to insert a single space in the place of each comma. Inside your while loop you could use &quo

Re: [Tutor] unorderable types

2017-08-06 Thread boB Stepp
ge as such a person probably does not need a lot of repetitive examples. I might do a more detailed review later once I finish the book to see if my initial impression holds up. But so far I wish it were the first Python book I ever picked up! -- boB ___

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
instance objects)." So what I am understanding is that I only need use the @staticmethod decorator if I am using Python versions 2.4 through 2.7 (new-style classes). Is my understanding correct? TIA! -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

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

2017-08-07 Thread boB Stepp
I feel like I have gazed into a crystal clear pool, apparently shallow, with many interesting objects (Pun intended!) on the pool floor. Interested in these beautiful things, I jump in to grab one for close-up study only to find that the pool is much, ... , much deeper (> 1 boB-height) than

[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

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
look up the appropriate code points to type it here!) filled in technical points that Ned alluded to, but did not explicitly cover. The two together complemented each other nicely. I was only vaguely aware of the Python 2 surprises until these two videos

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
hich makes using a > BOM redundant. For example, strings in the Windows registry use > UTF-16LE, without a BOM. Are there Windows bobby-traps that I need to watch out for because of this? I already know that the code pages that cmd.exe uses have caused me some grief in displaying (or not

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

2017-08-08 Thread boB Stepp
at I have not had to consciously think in bits, octal or hex in quite a few years. Oh, well. You were quite nice in pointing out my grave mental lapses! Red-faced! boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription optio

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
both RAM and files? No funny business anywhere? Except perhaps in my Windows 7 cmd.exe and PowerShell, but that's not Python's fault. Which makes me wonder, what is my editor's default encoding/decoding? I will have to investigate! Cheers! -- boB

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
=== Instead of doc strings in the test code, I have used comments based on something I read online. The point of doing this was so the doc strings would _not_ show up in the test run output. Is this worthwhile advice to follow? I'm looking forwar

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
e trickiest, > but most common, bits of OOP - object persistence... Would you expand on this in SQLite terms? > You might even find yourself writing some class methods! ;-) Nah. I might expand my array of constants, and test a few more ... ~(:>)) -- boB ___

Re: [Tutor] pygame not working

2017-08-16 Thread boB Stepp
in the terminal window. The other is are you sure that your program is running with the version of Python you think it is? If you installed a later version of Python 2 yourself you may in fact be running an older version of Python 2 with your program, the one sup

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: > > Y

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 min

Re: [Tutor] When to use classes

2017-08-20 Thread boB Stepp
e which maximizes code reuse instead of thinking in terms of classic specialization. And the children are in charge, not the parents! Interesting stuff! -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

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

2017-08-25 Thread boB Stepp
et the '-m' to be used? And is there an easier way to accomplish my objective? If I cannot work this out, then I will be forced to do: py2> import os py2> current_usr = os.popen('who -m') This should not be a security issue for me as no user input is involved. But I woul

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

<    14   15   16   17   18   19   20   21   >