Re: [Tutor] How to close a Tkinter window from a different thread?

2015-04-20 Thread Alan Gauld
On 20/04/15 04:34, boB Stepp wrote: So, how do I: 1) Check for the existence of an already open window from a previous running of the script? 2) If such a window exists, how do I close it from the new script execution? And, then, of course generate a new instance of the information window. I w

Re: [Tutor] sample dictionairies

2015-04-20 Thread Jim Mooney
For randomly generating data which look like addresses, I use: > http://www.generatedata.com/ > > While it has 'export to programming language' as a feature, Python isn't > one of the supported languages. Which is fine. It can export into comma > separated values, and writing a Python program to

[Tutor] Life Grid Implementation

2015-04-20 Thread niy mor
Is my code completing the assignment??? I need some *guidance* on completing my assignment. My Assignment: A sparse life grid is used to store and represent the area in the game of Life that contains organisms. The grid contains a rectangular grouping of cells divided into an infinite number of ro

Re: [Tutor] sample dictionairies

2015-04-20 Thread Alan Gauld
On 20/04/15 04:49, Jim Mooney wrote: Come to think of it, since I used | as a delimiter, what happens if you generate a CSV file from data that already has commas in the text? The CSV format covers that eventuality: You put quotes around the item with the comma. And if there are already quot

Re: [Tutor] Life Grid Implementation

2015-04-20 Thread Ben Finney
niy mor writes: > Is my code completing the assignment??? Does it meet the requirements when you (and other people) run the code? > I need some *guidance* on completing my assignment. Can you be specific about what you don't understand? If you don't understand the requirements, that is best d

Re: [Tutor] Life Grid Implementation

2015-04-20 Thread Alan Gauld
On 20/04/15 01:36, niy mor wrote: Is my code completing the assignment??? No. I need some *guidance* on completing my assignment. Try running your code. Then fix the errors. If you can't fix them come back to us and ask for help, including the error message and a description of what happene

Re: [Tutor] sample dictionairies

2015-04-20 Thread Mark Lawrence
On 20/04/2015 04:49, Jim Mooney wrote: For randomly generating data which look like addresses, I use: http://www.generatedata.com/ While it has 'export to programming language' as a feature, Python isn't one of the supported languages. Which is fine. It can export into comma separated values

Re: [Tutor] How to close a Tkinter window from a different thread?

2015-04-20 Thread boB Stepp
On Mon, Apr 20, 2015 at 2:10 AM, Alan Gauld wrote: > On 20/04/15 04:34, boB Stepp wrote: > >> So, how do I: >> 1) Check for the existence of an already open window from a previous >> running of the script? >> 2) If such a window exists, how do I close it from the new script >> execution? And, then

[Tutor] bin to dec conversion puzzlement

2015-04-20 Thread Jim Mooney
I can't seem to get my head around this 'simple' book example of binary-to-decimal conversion, which goes from left to right: B = '11011101' I = 0 while B: I = I * 2 + int(B[0]) B = B[1:] print(I) >>> 221 My thought was to go from right to left, multiplying digits by successive powers of

Re: [Tutor] How to close a Tkinter window from a different thread?

2015-04-20 Thread Laura Creighton
In a message of Mon, 20 Apr 2015 08:10:38 +0100, Alan Gauld writes: >Trying to manipulate GUIs via the windowing system should always >be a last resort, it is very hard to get right. And the hardness increases exponentially if you want to be portable across different operating systems. Laura __

Re: [Tutor] sample dictionairies

2015-04-20 Thread Jim Mooney
> Which is why you should use the csv module to work with csv files, > it knows how to deal with these various exceptional cases. > -- > Alan G > I should have known to simply try importing csv. Must-remember-batteries-included ;') -- Jim ___ Tutor mai

Re: [Tutor] OT: Is there a good book that covers the history/evolution of software? [Inspired by the thread: lists, name semantics]

2015-04-20 Thread Laura Creighton
Newman, W., Sproull, R. (1979), Principles of Interactive Computer Graphics, Mcgraw-Hill College, ISBN 0-07-046338-7 is a very good read. It is understandably dated, but then it was history that you were looking for. And the book has 2 parts -- a history of the computer architectures we had (in

Re: [Tutor] sample dictionairies

2015-04-20 Thread Laura Creighton
In a message of Sun, 19 Apr 2015 20:49:27 -0700, Jim Mooney writes: >Come to think of it, since I used | as a delimiter, what happens if you >generate a CSV file from data that already has commas in the text? > >-- >Jim In Sweden, and lots of other places, we do numbers differently. This is One

Re: [Tutor] Life Grid Implementation

2015-04-20 Thread niyana morgan
I don't understand how to do this. I attempted with my code and hoped a tutor could help me with this On Apr 20, 2015 3:31 AM, "Ben Finney" wrote: > niy mor writes: > > > Is my code completing the assignment??? > > Does it meet the requirements when you (and other people) run the code? > > > I n

[Tutor] Please Help to build an addon for Anki

2015-04-20 Thread Mahesh Chiramure
Hi I liked the addon "Picture-flasher" written for anki very much and I was wondering if the same thing could be done with mp3 and/or flac files. Means I am looking for an addon that chooses a random mp3 and/or flac file from a directory provided by me (to the addon as we have to provide in "Pictu

Re: [Tutor] bin to dec conversion puzzlement

2015-04-20 Thread Marc Tompkins
On Apr 20, 2015 6:56 AM, "Jim Mooney" wrote: > > I can't seem to get my head around this 'simple' book example of > binary-to-decimal conversion, which goes from left to right: > > B = '11011101' > I = 0 > while B: > I = I * 2 + int(B[0]) > B = B[1:] > > print(I) > >>> 221 > > My thought w

Re: [Tutor] bin to dec conversion puzzlement

2015-04-20 Thread Oscar Benjamin
On 20 April 2015 at 08:44, Jim Mooney wrote: > I can't seem to get my head around this 'simple' book example of > binary-to-decimal conversion, which goes from left to right: > > B = '11011101' > I = 0 > while B: > I = I * 2 + int(B[0]) > B = B[1:] Follow through the loop and see what ha

[Tutor] introspection

2015-04-20 Thread Alex Kleider
Does python provide the introspective ability to retrieve the name to which an object is bound? For example: $ python3 Python 3.4.0 (default, Apr 11 2014, 13:05:18) [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information. a = 69 print("Identifier <{}> is bound

Re: [Tutor] introspection

2015-04-20 Thread Joel Goldstick
On Mon, Apr 20, 2015 at 11:24 AM, Alex Kleider wrote: > Does python provide the introspective ability to retrieve the name to which > an object is bound? > > For example: > $ python3 > Python 3.4.0 (default, Apr 11 2014, 13:05:18) > [GCC 4.8.2] on linux > Type "help", "copyright", "credits" or "li

Re: [Tutor] Life Grid Implementation

2015-04-20 Thread Alan Gauld
On 20/04/15 13:59, niyana morgan wrote: I don't understand how to do this. I attempted with my code and hoped a tutor could help me with this Always write code that runs. Then fix the mistakes as they happen. That way you only have a few lines of code to look at. Your code is far too big and in

Re: [Tutor] bin to dec conversion puzzlement

2015-04-20 Thread Alan Gauld
On 20/04/15 08:44, Jim Mooney wrote: I can't seem to get my head around this 'simple' book example of binary-to-decimal conversion, which goes from left to right: B = '11011101' I = 0 while B: I = I * 2 + int(B[0]) B = B[1:] ... Both methods work but I just can't see how the first on

Re: [Tutor] Please Help to build an addon for Anki

2015-04-20 Thread Alan Gauld
On 20/04/15 09:54, Mahesh Chiramure wrote: I liked the addon "Picture-flasher" written for anki very much and I was wondering if the same thing could be done with mp3 and/or flac files. Probably, but I (and probably most of the list) have no idea what anki is or what the addon does. This is a

Re: [Tutor] introspection

2015-04-20 Thread Alex Kleider
On 2015-04-20 09:15, Joel Goldstick wrote: On Mon, Apr 20, 2015 at 11:24 AM, Alex Kleider wrote: Does python provide the introspective ability to retrieve the name to which an object is bound? For example: $ python3 Python 3.4.0 (default, Apr 11 2014, 13:05:18) [GCC 4.8.2] on linux Type "help

Re: [Tutor] bin to dec conversion puzzlement

2015-04-20 Thread Alex Kleider
On 2015-04-20 09:21, Alan Gauld wrote: On 20/04/15 08:44, Jim Mooney wrote: I can't seem to get my head around this 'simple' book example of binary-to-decimal conversion, which goes from left to right: B = '11011101' I = 0 while B: I = I * 2 + int(B[0]) B = B[1:] ... Both methods wo

Re: [Tutor] bin to dec conversion puzzlement

2015-04-20 Thread eryksun
On Mon, Apr 20, 2015 at 11:21 AM, Alan Gauld wrote: >> >> B = '11011101' >> I = 0 >> while B: >> I = I * 2 + int(B[0]) >> B = B[1:] > >> Both methods work but I just can't see how the first one does. > > The key is that the result gets multiplied by 2 each time > so for an N bit number t

Re: [Tutor] bin to dec conversion puzzlement

2015-04-20 Thread Alan Gauld
On 20/04/15 17:58, Alex Kleider wrote: The key is that the result gets multiplied by 2 each time so for an N bit number the leftmost digit winds up being effectively 2**N, which is what you want. Shouldn't that be 2**(N-1)? Yes, sorry. -- Alan G Author of the Learn to Program web site http

Re: [Tutor] introspection

2015-04-20 Thread Steven D'Aprano
On Mon, Apr 20, 2015 at 08:24:42AM -0700, Alex Kleider wrote: > Does python provide the introspective ability to retrieve the name to > which an object is bound? Short answer: no. Slightly longer answer: it *may* be possible if you dig deep into the debugger API that you might find something wh

Re: [Tutor] introspection

2015-04-20 Thread Alan Gauld
On 20/04/15 17:55, Alex Kleider wrote: locals() {'a': 3, 'c': 3, 'b': 6, '__builtins__': , '__package__': None, '__name__': '__main__', '__doc__': None} Showing my desired use case might make my question more understandable: def debug(var_name): if args["--debug"]: print("Ident

Re: [Tutor] introspection

2015-04-20 Thread Peter Otten
Alex Kleider wrote: > On 2015-04-20 09:15, Joel Goldstick wrote: >> On Mon, Apr 20, 2015 at 11:24 AM, Alex Kleider >> wrote: >>> Does python provide the introspective ability to retrieve the name to >>> which >>> an object is bound? >>> >>> For example: >>> $ python3 >>> Python 3.4.0 (default, A

[Tutor] Is it possible to "backport" the datetime module of Python 3.3 to Python 3.2?

2015-04-20 Thread Albert-Jan Roskam
Hi, My Raspberry Pi 2 comes with Python 3.2 (and 2.7). I run some code that uses the datetime module but I get an error: "AttributeError: 'datetime.datetime' object has no attribute 'timestamp'". On https://docs.python.org/3/whatsnew/3.3.html I see: "New datetime.datetime.timestamp() method: R

Re: [Tutor] sample dictionairies

2015-04-20 Thread Ben Finney
Jim Mooney writes: > I should have known to simply try importing csv. Better: You should now know to refer to the documentation https://docs.python.org/3/library/>. -- \ “Speech is conveniently located midway between thought and | `\action, where it often substitutes for bo

Re: [Tutor] introspection

2015-04-20 Thread Ben Finney
Alex Kleider writes: > Does python provide the introspective ability to retrieve the name to > which an object is bound? Objects aren't bound to names. So, no. The binding from a reference (a name is a reference) to objects is one-way. See this excellent presentation from PyCon US 2015 by Ned

Re: [Tutor] bin to dec conversion puzzlement

2015-04-20 Thread Ben Finney
Jim Mooney writes: > I can't seem to get my head around this 'simple' book example of > binary-to-decimal conversion, which goes from left to right: > > B = '11011101' > I = 0 > while B: > I = I * 2 + int(B[0]) > B = B[1:] > > print(I) > >>> 221 That is, IMO, a needlessly confusing way t

Re: [Tutor] bin to dec conversion puzzlement

2015-04-20 Thread Jim Mooney
The key is that the result gets multiplied by 2 each time > so for an N bit number the leftmost digit winds up being > effectively 2**N, which is what you want. > > Alan G Ah, the light dawns once it was restated. It would be even simpler if you could multiply each element of the binary numbe

Re: [Tutor] bin to dec conversion puzzlement

2015-04-20 Thread Dave Angel
On 04/20/2015 04:15 PM, Jim Mooney wrote: The key is that the result gets multiplied by 2 each time so for an N bit number the leftmost digit winds up being effectively 2**N, which is what you want. Alan G Ah, the light dawns once it was restated. It would be even simpler if you could

Re: [Tutor] How to close a Tkinter window from a different thread?

2015-04-20 Thread boB Stepp
On Mon, Apr 20, 2015 at 2:10 AM, Alan Gauld wrote: > On 20/04/15 04:34, boB Stepp wrote: > >> So, how do I: >> 1) Check for the existence of an already open window from a previous >> running of the script? >> 2) If such a window exists, how do I close it from the new script >> execution? And, then

Re: [Tutor] introspection

2015-04-20 Thread Alex Kleider
On 2015-04-20 13:24, Ben Finney wrote: Alex Kleider writes: Does python provide the introspective ability to retrieve the name to which an object is bound? Objects aren't bound to names. So, no. The binding from a reference (a name is a reference) to objects is one-way. See this excellent

Re: [Tutor] introspection

2015-04-20 Thread Danny Yoo
What's supposed to happen in this situation? ## class Person(object): def __init__(self): pass j = Person() john = j jack = j ## What single name should we get back from the single Person object here? "j", "joh