Re: [Tutor] Tutor Digest, Vol 118, Issue 53

2013-12-12 Thread Keith Winston
e: > > Remember that each time mult() is called it creates > > its own mini-world of variables independent of the > > previous calls. > > That, is a key point. > > Denis > > > -- > > Message: 5 > Date: Wed, 11 Dec 2013 13:37:11 + > From: Mark Lawrence > To: tutor@python.org > Subject: Re: [Tutor] formatting datetime.timedelta to "HH:MM:SS" > Message-ID: > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > On 11/12/2013 13:12, Jignesh Sutar wrote: > > print str(exe_time).split('.')[0] > > Sorry, I guess my question was why I can't use something similar to > > below on exe_time (of type datetime.timedelta)? Rather than doing string > > manipulation on decimals or colons to extract the same. > > > > now = datetime.now() > > print now.hour > > print now.minute > > print now.year > > > > Old style > > print('%02d:%02d:%04d' % (now.hour, now.minute, now.year)) > > New style > > print('{}:{}:{}'.format(now.hour, now.minute, now.year)) > > Sorry I can never remember the formatting types to go between {} so look > for them around here > http://docs.python.org/3/library/string.html#formatstrings > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence > > > > -- > > Subject: Digest Footer > > ___ > Tutor maillist - Tutor@python.org > https://mail.python.org/mailman/listinfo/tutor > > > -- > > End of Tutor Digest, Vol 118, Issue 53 > ** > -- Keith Winston Director, Earth Sun Energy Systems 301-980-6325 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

[Tutor] Superb exemplar

2013-12-12 Thread Keith Winston
On Thu, Dec 12, 2013 at 5:00 AM, wrote: > That was a superb example of how not to post, don't change the subject > line and send the whole digest instead of the part that you're replying > to, no thanks. > You are certainly welcome. I blame gmail. Seriously, though, sorry. I was castigated priva

Re: [Tutor] Tutor Digest, Vol 118, Issue 62

2013-12-14 Thread Keith Winston
> > Message: 6 > Date: Thu, 12 Dec 2013 23:10:31 -0500 > From: Sky blaze > To: tutor@python.org > Subject: [Tutor] Coding for a Secret Message in a Game > > it'd be amusing to have the message change after the player types something > other than "start" at least 10 times. I've attempted numerous

Re: [Tutor] Tutor Digest, Vol 118, Issue 75

2013-12-15 Thread Keith Winston
On Sun, Dec 15, 2013 at 10:40 AM, wrote: > Are you saying that it can't do list comprehensions, recursive functions > and floating point arithmetic correctly? > My understanding is that the answer here is essentially yes: that quantum computing requires a different approach to the problem, and

[Tutor] Saving files in Python, IDE's & editors

2013-12-18 Thread Keith Winston
On Tue, Dec 17, 2013 at 7:26 PM, wrote: > What else do I need to do to make this version of Python an actually > usable programming environment? > > Chris Acreman > Chris, I'm also a noob, but I would recommend you install/use an IDE, such as IDLE which comes free with all (I think) Python insta

[Tutor] Pedantry

2013-12-19 Thread Keith Winston
On Thu, Dec 19, 2013 at 6:00 AM, wrote: > Correction: no practical way to discourage pedants from correcting anyone > has been found yet. Your statement has no effect (at best). > Correction: small positive effects might occur, but complete elimination of pedantry is unlikely. Negative effects a

Re: [Tutor] Tutor Digest, Vol 118, Issue 95

2013-12-20 Thread Keith Winston
On Thu, Dec 19, 2013 at 5:58 PM, wrote: > > So... is there any way to go back up to the previous line and correct the > > syntax? As it is now we are starting the entire file over. It's really > > cumbersome. Is it supposed to be this way? > I notice "Python for Kids" uses Python 3.2, and (p.

[Tutor] menu-libre broken?

2013-12-20 Thread Keith Winston
I did this sequence of commands: sudo add-apt-repository ppa:menulibre-dev/devel sudo apt-get update sudo apt-get install menulibre But at the end of the update I got: W: Failed to fetch http://ppa.launchpad.net/menulibre-dev/devel/ubuntu/dists/saucy/main/source/Sources 404 Not Found W: Failed

[Tutor] class variables

2013-12-20 Thread Keith Winston
I am a little confused about class variables: I feel like I've repeatedly seen statements like this: There is only one copy of the class variable and when any one object makes a change to a class variable, that change will be seen by all the other instances. Object variables are owned by each indi

[Tutor] Linux vs. Python

2013-12-20 Thread Keith Winston
On Fri, Dec 20, 2013 at 6:00 AM, wrote: > This looks more like an Ubuntu issue than a Python one? > Did you mean to send it to the tutor list? > Oops. Sorry -- Keith ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription optio

Re: [Tutor] Tutor Digest, Vol 118, Issue 99

2013-12-21 Thread Keith Winston
On Sat, Dec 21, 2013 at 2:14 AM, wrote: > I don't like the terms "class variable" and "instance variable". In the > Python community, these are usually called class and instance attributes > rather than variables or members. > Hey Steven, that was a very generous explanation. Thanks! Very clear.

[Tutor] The Charms of Gmail

2013-12-21 Thread Keith Winston
On Sat, Dec 21, 2013 at 6:00 AM, wrote: > I'm unsure as to what the subject line has in common with class and > instance variables, would you care to explain it please. > I'm sorry Mark, I'm stuck with using gmail where I have to remember to delete the (essentially invisible) included text of t

[Tutor] Global namespace/dictionary

2013-12-21 Thread Keith Winston
On Sat, Dec 21, 2013 at 12:56 PM, wrote: > py> x = 23 > py> d = globals() > py> d['x'] > 23 > py> d['x'] = 42 > py> x > 42 > Well this is sort of fascinating, but a bit confusing: I was playing with this, and it seems like the global dictionary includes not just the name but the entire contents

[Tutor] print in py3

2013-12-22 Thread Keith Winston
I've been playing with afterhoursprogramming python tutorial, and I was going to write a question about myExample = {'someItem': 2, 'otherItem': 20} for a in myExample: print (a, myExample[a]) print (a) returning ('someItem', 2) someItem ('otherItem', 20) otherItem Which is to say, why

[Tutor] Stats packages in Mint 16

2013-12-22 Thread Keith Winston
I want to play with some stats, but I am having trouble installing numpy on mint 16 Petra/Saucy. Is there some way to do it, or some alternative, or do I not know what I'm talking about (largely true in this case)? -- Keith ___ Tutor maillist - Tutor@

[Tutor] Chutes & Ladders

2013-12-22 Thread Keith Winston
I've put together my first small program. It's a simulation of the game Chutes & Ladders. It plays the game and amasses an array of ([multicount] [gamecount]) size, and then crunches simple stats on the average moves, chutes, and ladders for all games in each high-level (multi) pass. Hopefully the

[Tutor] The Charms of Gmail

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 3:55 AM, wrote: > I'm no expert, but would a (semi-)decent email client help? > I do email on a lot of different computers, but I am going to look into options. Meanwhile, I'm going to redouble my efforts to be conscientious. -- Keith __

[Tutor] Stuck on Error

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 3:55 AM, wrote: > import random > > for i in range(1): > RN1 = random.randint(1,75) > As noted before, these "for i in range(1)" statements are pointless: iteration over a range of 1 is no iteration at all. This is exactly equivalent to simply saying RN1 = random

[Tutor] Stats packages in Mint 16

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 10:09 AM, wrote: > What did you try? I don't have Mint 16, but I'd expect that > > $ sudo apt-get install python3-numpy > > will work. > Well how about that. I looked all over the web, all over scipy, and somehow this was never suggested. I'm still learning about reposito

[Tutor] print in py3

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 6:00 AM, wrote: > But in Python 2, the parentheses aren't part of the function call, > because print isn't a function. So what do the brackets do? They are > used for *grouping* terms together. > > In the first line, the brackets group variable a, comma, myExample[a] > tog

[Tutor] Global namespace/dictionary

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 6:00 AM, wrote: > They have to live somewhere. -- Keith ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

[Tutor] Stats packages in Mint 16

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 6:00 AM, wrote: > As an alternative to numpy, or possibly as well as numpy, you might like > to try the statistics library which will appear in Python 3.4. As the > author of that library, I would be very, very grateful for bug reports > or other feedback. > I now remembe

[Tutor] Global namespace/dictionary

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 6:00 AM, wrote: > They have to live somewhere. Don't we all. Thanks, this helped clarify, I'll experiment more... -- Keith ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.p

[Tutor] The Charms of Gmail

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 6:00 AM, wrote: > The problem is that you're responding to the digest. Change your > subscription to receive individual messages. Create a filter that > automatically puts the tutor list emails under a particular label > OMG, so obvious. I actually had to reply to several

Re: [Tutor] The Charms of Gmail

2013-12-22 Thread Keith Winston
The way I was doing this before, I had to retype the subject line, and I think that broke threading. Hopefully it will be fixed now that I ditched digests. I don't know what you mean, nik, about (including layer 8!)? [research] Never mind, I get it. But I can't get layer 8 buy-in, too many dispara

Re: [Tutor] Chutes & Ladders

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 3:04 PM, wrote: > To sum it up: I like what you have, my hints are all about very minor > points > :) > Peter, that's a bunch of great suggestions, I knew there were a lot of places to streamline, make more readable, and probably make faster. Thank you. I find that if I

Re: [Tutor] Chutes & Ladders

2013-12-23 Thread Keith Winston
On Sun, Dec 22, 2013 at 3:04 PM, wrote: > > games = [p1.gameset(gamecount) for _ in range(multicount)] So Peter gave me a list of suggesttions, all of which I've incorporated and gotten running, and it's been instructive. But in my haste I included the line above, cut & pasted from his suggest

Re: [Tutor] Fwd: Re: How to post: Was Re: The Charms of Gmail

2013-12-23 Thread Keith Winston
Yikes, as the progenitor of the antecedent of this screed... I'm sorry! I have found, by and large, this to be a very helpful list, there's no question it has kept me moving forward at times that I might not have in python. Lots of generosity and knowledge. And when someone suggested a way of doing

Re: [Tutor] Generator next()

2013-12-27 Thread Keith Winston
e from the web page above (in Firefox in Linux 16 XFCE) and paste it into the IDLE New File window, it cleans out all the white space, which is slightly suboptimal for Python! Any suggestions? On Fri, Dec 27, 2013 at 1:14 PM, Keith Winston wrote: > I am beginning to think about decorators, generato

[Tutor] Generator next()

2013-12-27 Thread Keith Winston
I am beginning to think about decorators, generators, and the like. I'm starting from zero. I've read a few PEPs, and looked at some code, and maybe things are starting to sink in, though I don't really have enough framework to hang it all on. It'll come. Anyway, I was trying to run some timing cod

Re: [Tutor] Generator next()

2013-12-28 Thread Keith Winston
On Sat, Dec 28, 2013 at 4:45 AM, Steven D'Aprano wrote: > That's my idea of an instrumented function :-) > > Feel free to ask for a explanation of how it works. > Hey Steve or anyone: That seems like a very clean timer function, and while I have it working I only understand it caricaturistically

Re: [Tutor] Generator next()

2013-12-29 Thread Keith Winston
Wow Steven, this is great.I'll be brief I'm on a phone > def f(x): > print("Inside the outer function x =", x) > def g(y): # a function nested inside another function > print("Inside the inner function x =", x) > print("Inside the inner function y =", y) > return x

Re: [Tutor] Generator next()

2013-12-29 Thread Keith Winston
This is all really quite awesome, though I'm sure it'll be a while before these are really available tools for me. I think I get(a bit more than) the basic concept. Thanks! > is a short-cut for this: > > def spam(n): > return "spam"*n > > spam = decorator(spam) > > > This may be a lot to diges

Re: [Tutor] Generator next()

2013-12-29 Thread Keith Winston
Hah,I must understand,I read it that way! > > Oops, sorry a typo crept into this. That last line ought to be > "return g(23)". Sorry for any confusion. > > > > -- > Steven > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription

Re: [Tutor] same python script now running much slower

2013-12-30 Thread Keith Winston
It seems likely that mentioning what version of Python you're running it on might help in trouble-shooting... if you can run it on a subsection of your data, get it down to a workable amount of time (as in, minutes) and then put timers on the various sections to try to see what's taking so long. My

[Tutor] lists of lists: more Chutes & Ladders!

2013-12-30 Thread Keith Winston
I resolved a problem I was having with lists, but I don't understand how! I caught my code inadvertently resetting/zeroing two lists TWICE at the invocation of the game method, and it was leading to all the (gamechutes & gameladders) lists returned by that method being zeroed out except the final t

Re: [Tutor] lists of lists: more Chutes & Ladders!

2013-12-30 Thread Keith Winston
Never mind, I figured out that the slice assignment is emptying the previous lists, before the .reset() statements are creating new lists that I then populate and pass on. It makes sense. On Tue, Dec 31, 2013 at 12:59 AM, Keith Winston wrote: > I resolved a problem I was having with li

Re: [Tutor] lists of lists: more Chutes & Ladders!

2013-12-31 Thread Keith Winston
Thanks Denis, I found out about the iter builtin last night, a few hours after I'd coded/posted that. Oops. Thanks for your other comments, I am clearer now about the distinction of creating a new, empty list vs. clearing the same list out, and the subsequent implications on other symbols bound to

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

2013-12-31 Thread Keith Winston
Playing with this, a list comprehension is perfect: fnumlist = [float(num.replace(",", ".")) for num in snumlist] ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

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

2013-12-31 Thread Keith Winston
Hi PierreD, I think if you iterate over your strings with something like this, it will do what you want, if I understand correctly (snum is your string number, like "123,321"): fnum = float(snum.replace(",", ".") keith: rank beginner, take everything with a grain of salt!

[Tutor] Shelve & immutable objects

2013-12-31 Thread Keith Winston
I'm working my way slowly through Programming Python by Mark Lutz, and as an example of data persistence, he uses this example: -- Keith ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mail

Re: [Tutor] Shelve & immutable objects

2013-12-31 Thread Keith Winston
So sorry, I hit return: here's the example: import shelve db = shelve.open('class-shelve') sue = db['sue'] sue.giveRaise(.25) db['sue'] = sue tom = db['tom'] tom.giveRaise(.20) db['tom'] = tom db.close() Is it possible to dispense with the assignment/reassignment and just use (open shelve) db[

Re: [Tutor] Shelve & immutable objects

2014-01-01 Thread Keith Winston
Thanks Danny, I don't understand the re-persisted part, but I'll look into it. I realized I hadn't done enough homework to justify a question right after I sent the first half of that one! Happy New Year! ___ Tutor maillist - Tutor@python.org To unsubsc

Re: [Tutor] Shelve & immutable objects

2014-01-02 Thread Keith Winston
Thanks for all this Eryksun (and Mark!), but... I don't understand why you brought gdbm in? Is it something underlying shelve, or a better approach, or something else? That last part really puts me in a pickle, and I don't understand why. Separately, I'm also curious about how to process big files

[Tutor] What's in a name?

2014-01-02 Thread Keith Winston
I've got the beginner's version of a question I think Denis asked recently... 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 variable is set to in a given moment... i.e. for i in [alist, blist, clist] i[3] = "o

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

2014-01-02 Thread Keith Winston
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 at this for a while, but as soon as I post I find a way... this is my first use

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

2014-01-02 Thread Keith Winston
Shoot: I sent this response directly to Mark, without even trimming. Here it is to the list... Hi Mark: sorry for unclarity. I am probably going to make a hash of explaining this, but here goes: I want to iterate a variable across a list of objects, and print both the outputs (wrong word) of sai

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

2014-01-02 Thread Keith Winston
Danny: I appreciate your point, but these are just for little code loops, nothing I need to hold on to, like the snippet above: I'm just trying to wrap a few things into one loop, which gives me flexibility about expanding/contracting the stats, for example, that I print (by changing the range list

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

2014-01-02 Thread Keith Winston
Mark wrote: You enjoy making life difficult for yourself :) You've assigned strings to the name func, just assign the functions themselves? Like. > > for func in max, min: > print(func.__name__, func(range(5))) > > Output. > > max 4 > min 0 > > I wouldn't say I enjoy making life difficult fo

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

2014-01-02 Thread Keith Winston
I spoke about iterating through a bunch of lists in my last post, but in fact I'm iterating through a bunch of dicts in the example I gave. Sorry. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.o

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

2014-01-02 Thread Keith Winston
OMG, another one to Mark and not the list. I'll see if there's something I can adjust in email... On Fri, Jan 3, 2014 at 2:23 AM, Mark Lawrence wrote: > > lista = list(range(5)) > listb = list(reversed(range(5))) > for alist in lista, listb: > print(alist.__class__.__name__, alist) > > list [

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

2014-01-02 Thread Keith Winston
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)) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.pytho

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

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
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] 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 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

[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] 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

Re: [Tutor] python, speed, game programming

2014-01-03 Thread Keith Winston
53 PM, Keith Winston wrote: > 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 i

Re: [Tutor] python, speed, game programming

2014-01-03 Thread Keith Winston
gt; 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

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
ream based on that. The thing that put me on edge was noticing that my simple Chutes & Ladders game doesn't go ANY faster on a machine that benchmarks perhaps 1000 times faster than another... Keith On Fri, Jan 3, 2014 at 8:17 PM, Alan Gauld wrote: > On 03/01/14 21:53, Keith Winst

Re: [Tutor] python, speed, game programming

2014-01-03 Thread Keith Winston
be a little sleeker... Keith On Fri, Jan 3, 2014 at 8:38 PM, Keith Winston wrote: > 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 th

[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] simple arg problem

2014-01-03 Thread Keith Winston
7;ve been staring at it for hours. This is going to be embarrassing... On Fri, Jan 3, 2014 at 9:53 PM, Keith Winston wrote: > 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 s

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) > >

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 thi

[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 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

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] Copying [was Re: What's in a name?]

2014-01-03 Thread Keith Winston
, 2014 at 12:50 AM, Mark Lawrence wrote: > 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 >>&

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

2014-01-04 Thread Keith Winston
Still, this has been an informative conversation. On Sat, Jan 4, 2014 at 12:56 AM, Steven D'Aprano wrote: > 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()

Re: [Tutor] python problems on android

2014-01-04 Thread Keith Winston
Perhaps you could include the script? On Sat, Jan 4, 2014 at 5:47 AM, wrote: > > > Ok. Will try and explain the problem. > I wrote a script in python and found I could use it on my android phone > with SL4a. > It was really useful. > Haven't used it for a few months. > A few days ago I decided

Re: [Tutor] More or less final Chutes & Ladders

2014-01-04 Thread Keith Winston
Thanks Alan & Denis: Alan, the improvement you suggested had already been made, and adopted. Good catch. Denis: alas, there are chutes and ladders dicts, but I guess your chutes & ladders lists are local to the results class... Your suggestion is quite shocking to me, I wouldn't have thought of cr

Re: [Tutor] python problems on android

2014-01-04 Thread Keith Winston
Well, I probably can't help you, I haven't installed SL4 (yet), and am a Python beginner myself anyway. I imagine others might be more prepared to help you with a copy of the script. However: something about the way you are responding to this thread keeps breaking it, so you end up starting a new

Re: [Tutor] More or less final Chutes & Ladders

2014-01-04 Thread Keith Winston
Thanks again Denis, I might just have to ruminate on this, but I am definitely having an allergic reaction. I understand that Python doesn't have composite objects, but neither does it dislallow my list of lists of ints and lists... which is, I imagine, very space efficient. I think what you are i

Re: [Tutor] python, speed, game programming

2014-01-04 Thread Keith Winston
Hi Danny, no, I don't think there's any disk access, and the memory of the two machines is rather different: one is 4 Gb or so, the other 9 changing to 12 any day... but I think I haven't been rigorous enough to justify a great deal more attention here. I am convinced that I should just keep develo

Re: [Tutor] More or less final Chutes & Ladders

2014-01-04 Thread Keith Winston
Thanks all, interesting. I'll play more with tuples, I haven't knowingly used them at all... Keith ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] More or less final Chutes & Ladders

2014-01-05 Thread Keith Winston
On Sun, Jan 5, 2014 at 2:52 AM, Mark Lawrence wrote: > Homework for you :) Write a line of code that creates a list of say 3 or > 4 integers, then write a line that creates a tuple with the same integers. > Use the dis module to compare the byte code that the two lines of code > produce. The di

Re: [Tutor] Fwd: arrangement of datafile

2014-01-05 Thread Keith Winston
Hi Amrita, I'm just a beginner but I notice that, after the first two entries on each line (i.e. 10,ALA), the rest might fit nicely into a dict, like this {H: 8.388, HB1: 1.389, ...}. That would give you a lot of flexibility in getting at the values later. It would be easy enough to replace the "="

Re: [Tutor] Fwd: arrangement of datafile

2014-01-05 Thread Keith Winston
d to be wrong but I think it might point in the right direction. I think I made this a little more complicated than it needs to be, but I have to run right now. Maybe this is helpful. Good luck! Actually, I think shift needs to be a class... but that's just my nascent OOP comment. Keith

Re: [Tutor] Fwd: arrangement of datafile

2014-01-05 Thread Keith Winston
Amrita, on a closer read of your very first post I (think I) see you already successfully read your data into a series of dicts (mylist in your example), so if you still want the output you posted in the first post, then you can do some version of the loops that I described. That said, I'm sure Ste

Re: [Tutor] Fwd: arrangement of datafile

2014-01-06 Thread Keith Winston
Hi Amrita: I tried to figure out, for kicks, how to do what I THINK is what you're trying to do... I've never even opened a .txt file in Python before, so you can take all this with a big grain of salt... Anyway, if you take your example of your original database: 1 GLY HA2=3.7850 HA3=3.9130 2 SER

Re: [Tutor] Fwd: arrangement of datafile

2014-01-06 Thread Keith Winston
oops, I see Steven pointed out a much cleaner approach. Oh well. Shock & surprise ;) Keith On Mon, Jan 6, 2014 at 3:27 AM, Keith Winston wrote: > Hi Amrita: I tried to figure out, for kicks, how to do what I THINK is > what you're trying to do... I've never even opened a

Re: [Tutor] Fwd: arrangement of datafile

2014-01-06 Thread Keith Winston
Amrita, it doesn't seem like the code you are providing is the code you are running. I wonder if you are running it all at the Python command line or something, and have to type it in every time? You should put it in a file, and save & run that file, and then cut and paste it directly into your em

Re: [Tutor] OverflowError: cannot fit 'long' into an index-sized integer

2014-01-07 Thread Keith Winston
I had heard of Project Euler long ago, but completely forgotten it. It looks fun!! Thanks for reminding me of it. Keith On Tue, Jan 7, 2014 at 5:58 AM, eryksun wrote: > On Tue, Jan 7, 2014 at 4:49 AM, Jorge L. wrote: > > > > When i test that script against 600851475143 I get the following err

Re: [Tutor] OverflowError: cannot fit 'long' into an index-sized integer

2014-01-07 Thread Keith Winston
I think your approach is fine, you might need to fine tune your algorithm. hint below. if you want it: is_p doesn't need to be nearly as big as you specify. There are a couple other minor problems. ___ Tutor maillist - Tutor@python.org To un

Re: [Tutor] OverflowError: cannot fit 'long' into an index-sized integer

2014-01-07 Thread Keith Winston
um, I used his code, slightly fine-tuned it, and got the solution in .35 seconds (running time, not fine-tuning time ;). On my dinky old notebook. So I'm inclined to believe it is possible... Though perhaps my sense of what "fine-tuning" entails doesn't mesh with yours... spoiler alert, more be

Re: [Tutor] OverflowError: cannot fit 'long' into an index-sized integer

2014-01-07 Thread Keith Winston
In fact, I just used it to solve a number 3 orders of magnitude larger than 600851475143, the number from prob 3. It took 12s. I hardly dare go further than that... I'm not arguing that there's a big list being built in there... Oops, I dared. 5 orders of magnitude bigger crashes my machine. Oops

Re: [Tutor] OverflowError: cannot fit 'long' into an index-sized integer

2014-01-07 Thread Keith Winston
Hey Danny, I think you could use the same sqrt(n) on your algorithm to reduce the search space. I think you could also increment n += 2 to skip even numbers, the simplest of sieves. I think the sieve concept is based on the idea that adding is much less intensive than dividing, so creating the si

Re: [Tutor] OverflowError: cannot fit 'long' into an index-sized integer

2014-01-07 Thread Keith Winston
On Tue, Jan 7, 2014 at 5:45 PM, Keith Winston wrote: > Hey Danny, > > I think you could use the same sqrt(n) on your algorithm to reduce the > search space. I think you could also increment n += 2 to skip even numbers, > the simplest of sieves. > > I think the sieve concept

Re: [Tutor] OverflowError: cannot fit 'long' into an index-sized integer

2014-01-07 Thread Keith Winston
Sorry for the blank message. I was just going to say that I fixed my version of Eratosthenes' algorithm, but Danny's is still faster in all cases. Also, Jorge: I hope it's obvious that I'm kidding around, I wouldn't want you to feel uncomfortable with asking your questions just because I'm being

Re: [Tutor] OverflowError: cannot fit 'long' into an index-sized integer

2014-01-07 Thread Keith Winston
Alan Gauld wrote: > On 07/01/14 21:22, Keith Winston wrote: > > Note that his code doesn't really (need to) create a sieve of >> Eratosthenes all the way to n, but only to sqrt(n). It then tests for >> divisibility. >> > > I'm not sure what you mean her

Re: [Tutor] OverflowError: cannot fit 'long' into an index-sized integer

2014-01-07 Thread Keith Winston
Hey Steven, That's a cool primes module, I'm going to look that over more carefully. I can see that you've thought through this stuff before ;) And yeah, I'd like to see your Stopwatch code... I haven't looked at "with" yet, that's interesting. As usual, I don't totally get it... Keith _

Re: [Tutor] OverflowError: cannot fit 'long' into an index-sized integer

2014-01-07 Thread Keith Winston
I'm also happy to note that the sieve I adapted from Jorge generates a list of primes the same length as yours, which would seem to imply it's correct, and in 33s, though since it's timed by a different mechanism that may not mean anything... On Tue, Jan 7, 2014 at 10:36 PM, Keith

[Tutor] garbage collecting

2014-01-07 Thread Keith Winston
Iirc, Python periodically cleans memory of bits & pieces that are no longer being used. I periodically do something stupid -- I mean experimental -- and end up with a semi-locked up system. Sometimes it comes back, sometimes everything after that point runs very slowly, etc. I just saw where I cou

Re: [Tutor] garbage collecting

2014-01-08 Thread Keith Winston
well, fair enough. Generally, the issue involves instances when Python will come back, but it might take several minutes or much longer. And weird behaviour ensues: like timers I put on the program don't actually time the amount of time it's busy (by a very, very large margin). Also, often several

Re: [Tutor] OverflowError: cannot fit 'long' into an index-sized integer

2014-01-08 Thread Keith Winston
Yes, I did read the context manager stuff, but I can only absorb a bit of it, I just don't have the background. It's getting better though. Plus I think most things will come only after I play with them, and I haven't really played much with wrappers, decorators and the like. Which is fine, the yea

Re: [Tutor] garbage collecting

2014-01-08 Thread Keith Winston
Well, thanks everyone. I get the picture. And there's nothing subtle going on here: I'm playing around, trying to factor million-digit numbers and the like. No biggie, this was interesting. ___ Tutor maillist - Tutor@python.org To unsubscribe or change

  1   2   >