Re: [Tutor] Copying [was Re: What's in a name?]

2014-01-03 Thread Keith Winston
Thanks for all this. I ended up using newdict = dict(olddict), which seemed to work fine. I hadn't heard about the copy module until now. I had heard about deep/shallow copies, though in this particular example (all int dicts), I don't think there's a difference...? On Sat, Jan 4, 2014 at 12:50

Re: [Tutor] What's in a name?

2014-01-03 Thread Steven D'Aprano
On Sat, Jan 04, 2014 at 12:32:19AM -0500, Keith Winston wrote: > On Fri, Jan 3, 2014 at 11:59 PM, Steven D'Aprano wrote: > > > thelist = vars()[name] > > > I see: vars() certainly looks less dangerous than eval(), but I'm guessing > that's still smelly code? I hadn't known about vars() or I proba

Re: [Tutor] Copying [was Re: What's in a name?]

2014-01-03 Thread Mark Lawrence
On 04/01/2014 05:44, Steven D'Aprano wrote: On Fri, Jan 03, 2014 at 01:53:42PM -0500, Keith Winston wrote: That's what I meant to do: make a copy when I wrote chute_nums = chutes. So I should have passed chute_nums to summarize_game, but it still wouldn't work (because it's not a copy). Pytho

Re: [Tutor] What's in a name?

2014-01-03 Thread Steven D'Aprano
On Sat, Jan 04, 2014 at 03:59:19PM +1100, Steven D'Aprano wrote: > - eval is dangerous. The number one cause of software vulnerabilities > (i.e. bugs which can be used by viruses and malware) today is code > ejection, which is a fancy way of saying "somebody screwed up with > eval or the e

[Tutor] Copying [was Re: What's in a name?]

2014-01-03 Thread Steven D'Aprano
On Fri, Jan 03, 2014 at 01:53:42PM -0500, Keith Winston wrote: > That's what I meant to do: make a copy when I wrote chute_nums = chutes. So > I should have passed chute_nums to summarize_game, but it still wouldn't > work (because it's not a copy). Python never makes a copy of objects when you p

Re: [Tutor] Fwd: What's in a name?

2014-01-03 Thread Steven D'Aprano
On Fri, Jan 03, 2014 at 01:55:29AM -0500, Keith Winston wrote: [...] > I want to iterate through a bunch of lists, subsequently printing both list > members (via indexing, for example) and the name of the list I'm on. Why? What does this gain you? Now, it's true that when *debugging code*, being

Re: [Tutor] What's in a name?

2014-01-03 Thread Keith Winston
On Fri, Jan 3, 2014 at 11:59 PM, Steven D'Aprano wrote: > thelist = vars()[name] I see: vars() certainly looks less dangerous than eval(), but I'm guessing that's still smelly code? I hadn't known about vars() or I probably would have used it. -- Keith

Re: [Tutor] What's in a name?

2014-01-03 Thread Steven D'Aprano
On Fri, Jan 03, 2014 at 12:29:34AM -0500, Keith Winston wrote: > Hmm, maybe I stumbled upon at least one approach, turning the problem > around. Make it something like: > > for i in ["alist", "blist", "clist"] > i[3] = "okey dokey " > print(eval(i)[3], i) > > Of course I've been staring a

Re: [Tutor] simple arg problem

2014-01-03 Thread Keith Winston
Hi Steven, tarray = CandL_Array(100) Yes, that's definitely better. I'll make that change. Thanks, makes sense. I'd already posted my "finished" version, so I probably won't repost with this small change right now. Keith ___ Tutor maillist - Tutor@py

[Tutor] More or less final Chutes & Ladders

2014-01-03 Thread Keith Winston
Here is what I think will be about the final version of C and L. I rearranged it quite a bit (into 2 classes), fixed a bug or two, and generally cleaned it up a bit. I haven't really polished it, but hopefully it will be less difficult to read... which is to say, if anyone wants to go through it AG

Re: [Tutor] simple arg problem

2014-01-03 Thread Steven D'Aprano
On Fri, Jan 03, 2014 at 09:56:25PM -0500, Keith Winston wrote: > gmail is driving me crazy. Anyway, every time I run it with: > > if __name__ == "__main__": > tarray = CandL_Array > tarray.populate(100) > > I get an error > > Traceback (most recent call last): > File "/home/keithwins/D

Re: [Tutor] python, speed, game programming

2014-01-03 Thread Keith Winston
On Fri, Jan 3, 2014 at 11:14 PM, Mark Lawrence wrote: > On 03/01/2014 21:41, Keith Winston wrote: > >> -- >> Keith >> >> > Frankly I think you're lining up to jump fences when you're actually > riding on the flat :) > Fair enough, but I am thinking of the next project as a long-term dabbling: ho

Re: [Tutor] python, speed, game programming

2014-01-03 Thread Mark Lawrence
On 03/01/2014 21:41, Keith Winston wrote: -- Keith Frankly I think you're lining up to jump fences when you're actually riding on the flat :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence _

Re: [Tutor] simple arg problem

2014-01-03 Thread Keith Winston
Ah, more briefly: parens. Wow, okay then. Thanks. On Fri, Jan 3, 2014 at 10:14 PM, eryksun wrote: > On Fri, Jan 3, 2014 at 9:56 PM, Keith Winston wrote: > > > > if __name__ == "__main__": > > tarray = CandL_Array > > tarray.populate(100) > > > > I get an error > > > > Traceback (most r

Re: [Tutor] simple arg problem

2014-01-03 Thread eryksun
On Fri, Jan 3, 2014 at 9:56 PM, Keith Winston wrote: > > if __name__ == "__main__": > tarray = CandL_Array > tarray.populate(100) > > I get an error > > Traceback (most recent call last): > File "/home/keithwins/Dropbox/Python/CandL8.py", line 127, in > tarray.populate(100) > TypeEr

Re: [Tutor] simple arg problem

2014-01-03 Thread Keith Winston
gmail is driving me crazy. Anyway, every time I run it with: if __name__ == "__main__": tarray = CandL_Array tarray.populate(100) I get an error Traceback (most recent call last): File "/home/keithwins/Dropbox/Python/CandL8.py", line 127, in tarray.populate(100) TypeError: populat

[Tutor] simple arg problem

2014-01-03 Thread Keith Winston
I'm trying to rewrite/reshuffle my Chutes & Ladders code, which I generally find more confusing than writing anew. Anyway, I've got a method that seems like it calls for one argument but... def populate(self, gamecount1): """populate candl_array with a set of games""" (method of a ne

Re: [Tutor] python, speed, game programming

2014-01-03 Thread Keith Winston
Truth in advertising: I just realized a Core I7 only benchmarks about 10x faster than a Core 2 Duo, using Passmark. Wow, something like 6 years newer and only 10 times? Anyway, I'd STILL expect to see some of that in the program performance, though maybe once I get it ironed out it will be a little

Re: [Tutor] python, speed, game programming

2014-01-03 Thread Keith Winston
Just to be clear, what I'm asking this typing tutor to do is vastly more than normal, albeit still not seemingly very much. In most programs, they give you a sentence or paragraph to type, and then time how long it takes. I'm talking about timing every keypress, and modifying the text stream based

Re: [Tutor] python, speed, game programming

2014-01-03 Thread Alan Gauld
On 03/01/14 21:53, Keith Winston wrote: Ladders!). It is a typing tutor, I am inclined to use it to learn Dvorak but I would expect it easily adapted to QWERTY or anything else. ... My concern is with speed. This will have to keep up with (somewhat arbitrarily) fast typing, Lets see. The spee

Re: [Tutor] idle problem

2014-01-03 Thread Alan Gauld
On 03/01/14 19:35, I. Alejandro Fleischer wrote: Sudenly Im having troubles opening files with the idle editor. When I open a file it appears in blank, and can not close it anymore. How are you opening it? How do you run IDLE? How do you open a file? What does the 'blank' window display as a

Re: [Tutor] python problems on android

2014-01-03 Thread Danny Yoo
Hi Roger, Check whether or not you are running Python 3 or Python 2. I strongly suspect you should be using 3, but have run it as a Python 2 program by accident. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http

[Tutor] python problems on android

2014-01-03 Thread Roger
Hi. I wrote a few python programs and had them running on my phone up to last september. Haven't had time to work on them again till now. Only now, they... don't work ! Not sure why and its very frustrating. one of the errors is in response to an input request like this g = input ("type h to use

Re: [Tutor] idle problem

2014-01-03 Thread Kodiak Firesmith
Hello Alejandro! Try running idle via a terminal and see if it's throwing out any error information. (-d switch for dubug) I've moved on to a mix between PyCharm and Vim depending on how big of a "project" I'm working on, but I still have idle installed so I can probably help a bit more if there

Re: [Tutor] python problems on android

2014-01-03 Thread Devin Jeanpierre
On Fri, Jan 3, 2014 at 4:26 PM, wrote: > Thanks Dave. Your email doesn't appear to be in response to anything. I think your email client is broken, and you should switch to a different one. -- Devin ___ Tutor maillist - Tutor@python.org To unsubscri

Re: [Tutor] What's in a name?

2014-01-03 Thread Keith Winston
Thanks Walter, I think I've got the lay of the land roughly, but my grasp is still light and imperfect. I'm pretty confident I shouldn't be doing anything like what you're describing for the level of coding I'm doing, but it's interesting to see the approach. Keith On Fri, Jan 3, 2014 at 6:56 P

Re: [Tutor] python, speed, game programming

2014-01-03 Thread Keith Winston
Okay, thanks, I'll probably be proceeding over the next few weeks, as I finish up my Chutes & Ladders project... I think I have to do a bit more code/manual reading in proportion to my coding for a bit, also. Thanks for the insights. K On Fri, Jan 3, 2014 at 6:12 PM, spir wrote: > On 01/03/201

[Tutor] python problems on android

2014-01-03 Thread blechnum
Thanks Dave. I was using 3.2.2 and uninstalled it earlier as it was giving me strange messages. Just reinstalled to remind myself what these were. here goes, WARNING: linker: libpython3.2m.so has text relocations this is wasting memory and is a security risk. Please fix the warning messag

Re: [Tutor] What's in a name?

2014-01-03 Thread Walter Prins
Hi, The code in my last post got line wrapped which will break if directly tried out. To avoid possible confusion I paste a version below with shorter lines which should avoid the problem: import gc, itertools def names_of(obj): """Try to find the names associated to a given object."""

Re: [Tutor] What's in a name?

2014-01-03 Thread Walter Prins
Hi Keith, On 3 January 2014 20:03, Keith Winston wrote: >> So the answer to your question is just to print the string. >> The real challenge, as we have discovered, is how to access >> the list that is named by the string. And the usual way to >> map strings to objects is via a dictionary not by

Re: [Tutor] python, speed, game programming

2014-01-03 Thread spir
On 01/03/2014 10:53 PM, Keith Winston wrote: My concern is with speed. This will have to keep up with (somewhat arbitrarily) fast typing, while doing background processing, with a GUI of course. I wouldn't even bother. Try & see, you may be surprised. There are several factors at play: * The c

Re: [Tutor] python problems on android

2014-01-03 Thread Dave Angel
On Fri, 03 Jan 2014 22:18:00 +, blech...@fireflyuk.net wrote: one of the errors is in response to an input request like this g = input ("type h to use last settings ") stops the program with this File , line1, in NameError: name 'h' is not defined after I entered h Looks to

[Tutor] python problems on android

2014-01-03 Thread blechnum
Hi. I wrote a few python programs and had them running on my phone up to last september. Haven't had time to work on them again till now. Only now, they... don't work ! Not sure why and its very frustrating. one of the errors is in response to an input request like this g = input ("type h to

Re: [Tutor] python, speed, game programming

2014-01-03 Thread Devin Jeanpierre
On Fri, Jan 3, 2014 at 1:53 PM, Keith Winston wrote: > I am gearing up for the next project (yeah, an eventual end to Chutes & > Ladders!). It is a typing tutor, I am inclined to use it to learn Dvorak but > I would expect it easily adapted to QWERTY or anything else. > [snip] > > I hope Python is

Re: [Tutor] python, speed, game programming

2014-01-03 Thread Keith Winston
Just to be clear: this is equal parts learning Python project, prototype tutorial software project, OOP practice, and the beginning of a more general inquiry into learning styles/paradigms/parameters... I'm (slowly) writing some of these ideas up in a separate doc. On Fri, Jan 3, 2014 at 4:53 PM,

Re: [Tutor] python, speed, game programming

2014-01-03 Thread Keith Winston
Shoot, sorry for the empty message. Here's what I was going to say: I am gearing up for the next project (yeah, an eventual end to Chutes & Ladders!). It is a typing tutor, I am inclined to use it to learn Dvorak but I would expect it easily adapted to QWERTY or anything else. The basic idea is b

[Tutor] python, speed, game programming

2014-01-03 Thread Keith Winston
-- Keith ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] What's in a name?

2014-01-03 Thread Keith Winston
On Fri, Jan 3, 2014 at 6:41 AM, Alan Gauld wrote: > This is off topic but a couple of points about the OOP stuff... > > thanks Alan, this was helpful. > "If I'm iterating a variable through a series of list names, > for future processing, I would like to print the name of the > list the variabl

Re: [Tutor] idle problem

2014-01-03 Thread eryksun
On Fri, Jan 3, 2014 at 2:35 PM, I. Alejandro Fleischer wrote: > > Sudenly Im having troubles opening files with the idle editor. When I open a > file it appears in blank, and can not close it anymore. > > My OS is ubuntu 13.10 (64 bits) and my python version is 2.7.5. Maybe something is wrong wit

[Tutor] idle problem

2014-01-03 Thread I. Alejandro Fleischer
Hello to everyone, Sudenly Im having troubles opening files with the idle editor. When I open a file it appears in blank, and can not close it anymore. My OS is ubuntu 13.10 (64 bits) and my python version is 2.7.5. Regards, Igor ___ Tutor maillist -

Re: [Tutor] What's in a name?

2014-01-03 Thread Keith Winston
On Fri, Jan 3, 2014 at 9:03 AM, spir wrote: > On 01/03/2014 12:41 PM, Alan Gauld wrote: > >> >> return [step, self.move_count, self.num_chutes, >>> self.num_ladders, self.chutes_list, self.ladders_list] >>> >> >> In OOP you rarely have to return attributes. And since step >> is passed i

Re: [Tutor] What's in a name?

2014-01-03 Thread Keith Winston
On Fri, Jan 3, 2014 at 4:50 AM, Danny Yoo wrote: > Quick thing. Please look at the following small program: > > # > d1 = {1 : 'one'} > d2 = d1 > d2[2] = 'two' > print(d1) > print(d2) > # > > Predict what this prints out. Write your prediction on a piece of paper.

Re: [Tutor] ValueError: could not convert string to float: '13,2'

2014-01-03 Thread eryksun
On Fri, Jan 3, 2014 at 11:53 AM, emile wrote: > On 12/31/2013 12:56 PM, Mark Lawrence wrote: >> >> import locale >> >> # Set to users preferred locale: >> locale.setlocale(locale.LC_ALL, '') >> # Or a specific locale: >> locale.setlocale(locale.LC_NUMERIC, "en_DK.UTF-8") >> print(locale.atof("3,14

Re: [Tutor] ValueError: could not convert string to float: '13,2'

2014-01-03 Thread emile
On 12/31/2013 12:56 PM, Mark Lawrence wrote: import locale # Set to users preferred locale: locale.setlocale(locale.LC_ALL, '') # Or a specific locale: locale.setlocale(locale.LC_NUMERIC, "en_DK.UTF-8") print(locale.atof("3,14")) This is a good solution, but be aware that it could impact othe

Re: [Tutor] Mastering the fundamentals

2014-01-03 Thread spir
On 01/03/2014 09:30 AM, Christian Alexander wrote: Hello Tutorians, I've just recently acquired "Learning Python", and I must state that it is a fairly thorough book. However it seems as if I am learning at a very slow pace, so my question is, as far as setting a goal to master the basics, wher

Re: [Tutor] What's in a name?

2014-01-03 Thread spir
On 01/03/2014 12:41 PM, Alan Gauld wrote: return [step, self.move_count, self.num_chutes, self.num_ladders, self.chutes_list, self.ladders_list] In OOP you rarely have to return attributes. And since step is passed in as an argument the caller already knows [it]. So I don't think you

Re: [Tutor] sqlite3 import problem

2014-01-03 Thread Alan Gauld
On 03/01/14 13:36, Mark Lawrence wrote: File "/usr/local/lib/python3.3/sqlite3/dbapi2.py", line 26, in from _sqlite3 import * ImportError: No module named '_sqlite3' As a matter of interest why do you have the underscore in front of sqlite3? Is that deliberate? You surprise me Alan,

Re: [Tutor] Mastering the fundamentals

2014-01-03 Thread Al-Sahaf, Ahmed H.
Hi Christian, You can start with Google Python Class https://developers.google.com/edu/python/ Best regards, Ahmed On Jan 3, 2014 1:29 PM, "Christian Alexander" < christian.h.alexan...@gmail.com> wrote: > Hello Tutorians, > > I've just recently acquired "Learning Python", and I must state that

Re: [Tutor] sqlite3 import problem

2014-01-03 Thread Mark Lawrence
On 03/01/2014 10:36, Alan Gauld wrote: On 03/01/14 02:17, Matthew Ngaha wrote: im having problems importing sqlite3 on ubuntu python3. File "/usr/local/lib/python3.3/sqlite3/__init__.py", line 23, in from sqlite3.dbapi2 import * File "/usr/local/lib/python3.3/sqlite3/dbapi2.py", lin

Re: [Tutor] sqlite3 import problem

2014-01-03 Thread Matthew Ngaha
On Fri, Jan 3, 2014 at 10:36 AM, Alan Gauld wrote: > On 03/01/14 02:17, Matthew Ngaha wrote: >> >> im having problems importing sqlite3 on ubuntu python3. >> >>File "/usr/local/lib/python3.3/sqlite3/__init__.py", line 23, in >> >> from sqlite3.dbapi2 import * >>File "/usr/local/lib/p

Re: [Tutor] Mastering the fundamentals

2014-01-03 Thread Alan Gauld
On 03/01/14 08:30, Christian Alexander wrote: I've just recently acquired "Learning Python", and I must state that it is a fairly thorough book. However it seems as if I am learning at a very slow pace, so my question is, as far as setting a goal to master the basics, where should I be within a

Re: [Tutor] What's in a name?

2014-01-03 Thread Alan Gauld
On 03/01/14 08:37, Keith Winston wrote: Below you will find the full current version of my Chutes or Snakes & Ladders game. I tried to reorganize it into a more OOP structure, This is off topic but a couple of points about the OOP stuff... Its normal style to name classes with a capital letter

Re: [Tutor] sqlite3 import problem

2014-01-03 Thread Alan Gauld
On 03/01/14 02:17, Matthew Ngaha wrote: im having problems importing sqlite3 on ubuntu python3. File "/usr/local/lib/python3.3/sqlite3/__init__.py", line 23, in from sqlite3.dbapi2 import * File "/usr/local/lib/python3.3/sqlite3/dbapi2.py", line 26, in from _sqlite3 import * Im

[Tutor] Mastering the fundamentals

2014-01-03 Thread Christian Alexander
Hello Tutorians, I've just recently acquired "Learning Python", and I must state that it is a fairly thorough book. However it seems as if I am learning at a very slow pace, so my question is, as far as setting a goal to master the basics, where should I be within a years time? Assuming I spend

Re: [Tutor] What's in a name?

2014-01-03 Thread Danny Yoo
Quick thing. Please look at the following small program: # d1 = {1 : 'one'} d2 = d1 d2[2] = 'two' print(d1) print(d2) # Predict what this prints out. Write your prediction on a piece of paper. Then run the program. Does it match what you wrote? If not, start a

Re: [Tutor] What's in a name?

2014-01-03 Thread Danny Yoo
> it works fine, but if I run it after I've loaded it (by candl(100) at the > prompt, for example), it is way off: something isn't being reset, and I'm > sure it'd be obvious to someone, It's due to global variable mutation. Note that summarize_game() mutates game_nums, which is either chutes or

Re: [Tutor] Fwd: What's in a name?

2014-01-03 Thread Asokan Pichai
On Fri, Jan 03, 2014 at 02:45:04AM -0500, Keith Winston wrote: > And to beat that poor horse in the same example, my current way of doing > that would be: > > for alist in "lista", "listb": > print(alist, eval(alist)) Since you know both pieces, namely the name of the entity "alist" and its

Re: [Tutor] What's in a name?

2014-01-03 Thread Keith Winston
On Fri, Jan 3, 2014 at 2:42 AM, Danny Yoo wrote: > > I hope you don't take offense. But I actually do not understand > print_candl_info(). I thought I did! But then I realized I was > deluding myself. I don't not understand it after all, and that's > after staring at it for more than about th

Re: [Tutor] What's in a name?

2014-01-03 Thread Keith Winston
Below you will find the full current version of my Chutes or Snakes & Ladders game. I tried to reorganize it into a more OOP structure, and I think I started succeeding, and then something might have gone wrong. There is also something somewhat seriously wrong with it: if I run it as __main__, it w