Re: [Tutor] help with data insert into Access table

2014-01-29 Thread Keith Winston
On Wed, Jan 29, 2014 at 3:03 PM, Mark Lawrence wrote: > Nothing to do with tuples. Tools such as syntax checkers or MkI eyeballs > come in useful here. Although such tools probably won't pick up the > incorrect spelling of "harboUr" :) Alas, now I'm more confused. I don't see any mispellings in

Re: [Tutor] help with data insert into Access table

2014-01-29 Thread Keith Winston
On Wed, Jan 29, 2014 at 12:11 PM, Mark Lawrence wrote: > I think it's worth pointing out that there is a difference here between the > OP's 'Site Name's Harbor.JPG' and Peter's "Site Name's Harbor.JPG". Left as > homework for the newbies :) I'll bite. But are you just referring to the tuple iss

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread Keith Winston
On Sat, Jan 25, 2014 at 5:09 PM, Oscar Benjamin wrote: > Perhaps it would be better though to point at this: round(D('0.123456'), 3) > Decimal('0.123') I think you are right. I didn't even think of round(). I think we have confounded two issues in this thread, the internal representation/acc

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread Keith Winston
Also, just to be clear: I'd suggest floats because decimal requires importing a module and using the non-built-in features thereof, especially if you're going to do something like decimal.getcontext().prec (even that doesn't set precision AFTER the decimal point... only total precision). My point b

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread Keith Winston
On Sat, Jan 25, 2014 at 3:57 AM, spir wrote: > Note: AFAIK most financial software use integers for this reason and to > avoid (or control) rounding errors. I don't think this is true (no flame intended, hopefully you know I'm forever in your debt Denis): there's a famous scam where insiders at a

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread Keith Winston
On Sat, Jan 25, 2014 at 3:57 AM, spir wrote: >> .009 to the price, so that people do not have to type the full amount. >> Example, 3.49 /gallon would return 3.499 /gallon. >> >> This is what I have tried and the results of it. >> >> def gas_price(price): >> price == raw_input("What is the pr

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Keith Winston
On Fri, Jan 24, 2014 at 4:50 AM, Steven D'Aprano wrote: > Python does not use a search path for the open() function, only for > imports. With open(), it uses a simple rule: > > - absolute paths will look only in that exact location; > > - relative paths are always relative to the current working d

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Keith Winston
I should have mentioned, the other possibility is that the file does not, in fact, exist, but I assume you put it out there somewhere? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/l

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Keith Winston
The file would appear to not be on your search path, that is, in any directory in which Python is expecting to find it. Either move it to a directory on your path, or change your path to include it's location. The easiest way to find out what your path is, that I know, is import sys sys.path Good

Re: [Tutor] iter class

2014-01-23 Thread Keith Winston
On Thu, Jan 23, 2014 at 7:05 AM, eryksun wrote: > Generally you'll make `__iter__` a generator, so you don't have to > worry about implementing `__next__`. Also, the built-in function > `next` was added in 2.6, so you don't have to worry about the method > name difference between 2.x and 3.x, eith

Re: [Tutor] iter class

2014-01-23 Thread Keith Winston
On Thu, Jan 23, 2014 at 1:36 PM, Devin Jeanpierre wrote: > Again, nothing was incorrect about the example. Every iterator has > this "problem". Hmmm. Well, here's what he actually said about that example, since I don't think I've explained correctly: * With iterators, one thing to watch out

Re: [Tutor] iter class

2014-01-23 Thread Keith Winston
On Thu, Jan 23, 2014 at 7:05 AM, eryksun wrote: > Generally you'll make `__iter__` a generator, so you don't have to > worry about implementing `__next__`. Also, the built-in function > `next` was added in 2.6, so you don't have to worry about the method > name difference between 2.x and 3.x, eith

Re: [Tutor] iter class

2014-01-23 Thread Keith Winston
On Thu, Jan 23, 2014 at 3:09 AM, Peter Otten <__pete...@web.de> wrote: > But why not install Python 2.7 on your machine, too? That would allow you > run the examples as is. Y'know, it's funny, but I have 2.7 installed. But since I was almost certain it was a 2to3 kind of problem, I wanted to figur

Re: [Tutor] iter class

2014-01-23 Thread Keith Winston
On Thu, Jan 23, 2014 at 5:56 AM, spir wrote: > Yes, but that way others learn as well :-) And many people prefere learning > via human interaction then dealing with arid texts Well, you caught me. I do run out of steam just plowing through lessons & such: it really helps to have actual humans to

Re: [Tutor] iter class

2014-01-22 Thread Keith Winston
On Thu, Jan 23, 2014 at 12:21 AM, Devin Jeanpierre wrote: > in Python 3, it should be __next__, not next. Ah! That's it! Thanks!!! > I'd suggest staying away from any old blog posts and articles, unless > you'd care to learn Python 2.x instead of 3.x. ;) Yeah, but this is a REALLY GOOD resource

[Tutor] iter class

2014-01-22 Thread Keith Winston
I'm working my way through some of the examples in http://ivory.idyll.org/articles/advanced-swc/#list-comprehensions And tried this one: >>> class MyTrickyIter: ... def __init__(self, thelist): ... self.thelist = thelist ... self.index = -1 ... ... def __iter__(self): ... retu

Re: [Tutor] Stuck on Challenge in Google Python Class

2014-01-22 Thread Keith Winston
On Wed, Jan 22, 2014 at 6:40 AM, Alan Gauld wrote: >> else: >>return ' ' > > > Notice that this return will throw you out of the function so > you don't process any more strings. You might like to look > at 'continue' as an alternative. You actually don't need to do anything with thi

Re: [Tutor] How to print certain elements

2014-01-21 Thread Keith Winston
If you are playing around at the Python prompt (the >>>), which you really should be to get the hang of this stuff, you might notice that the bracket indexing that you and everyone is talking about works both on strings (Y) and on lists (X: in this case, a list of strings). They may not behave the

Re: [Tutor] string indexing

2014-01-19 Thread Keith Winston
On Sun, Jan 19, 2014 at 3:50 PM, Alan Gauld wrote: >> How would Python know whether you want find for gettext, mmap, str, >> xml.etree.ElementTree.Element or xml.etree.ElementTree.ElementTree? > > > Absolutely, but a newbie doesn't even guess that more than one find would > exist. Or even that the

Re: [Tutor] string indexing

2014-01-19 Thread Keith Winston
On Sun, Jan 19, 2014 at 11:33 AM, Alan Gauld wrote: help(''.find) > Help on built-in function find: Erm, getting what you want from help can be work. Help(find) # doesn't work at all. What Alan did above was create an empty string, by using two single quotes next to each other ('', not t

[Tutor] Python as Teaching Language

2014-01-19 Thread Keith Winston
On Sun, Jan 19, 2014 at 11:55 AM, Alan Gauld wrote: > It has reached the point that I'm back to looking for a new teaching > language. In Python 3 the decision has clearly been made to focus on > supporting Python's role as a professional software engineering language > at the expense of being a s

Re: [Tutor] iterators

2014-01-19 Thread Keith Winston
On Sun, Jan 19, 2014 at 2:02 PM, Oscar Benjamin wrote: > I think that's just an editing mistake. If you replace the word "iterator" > with "construct" then it makes sense: We have seen that the for statement is > such a construct. Fair enough. Thanks. But I think that it underlines the ease with

Re: [Tutor] iterators

2014-01-19 Thread Keith Winston
Well, as usual thanks for all this, it's really great. I'd worked out that it was a distinction between iterators and iterables, though I'm going to Oscar's description a few more times: most of it made sense, but there are subtleties. For example, this from the Python 3.3 tutorial: We say such a

Re: [Tutor] iterators

2014-01-18 Thread Keith Winston
On Sat, Jan 18, 2014 at 2:19 PM, eryksun wrote: > `xrange` and 3.x `range` aren't iterators. They're sequences. A > sequence implements `__len__` and `__getitem__`, which can be used to > implement an iterator, reversed iterator, and the `in` operator (i.e. > `__contains__`). I'm so glad you said

Re: [Tutor] iterators

2014-01-18 Thread Keith Winston
On Sat, Jan 18, 2014 at 4:22 AM, Chris “Kwpolska” Warrick wrote: > Here is a poor man’s pure-python re-implementation of `for`: > https://gist.github.com/Kwpolska/8488091 This will be very handy the next time I run out of for's, or have a surplus of while's. Fairly common. Seriously though, than

[Tutor] iterators

2014-01-18 Thread Keith Winston
I don't really get iterators. I saw an interesting example on Stackoverflow, something like with open('workfile', 'r') as f: for a, b, c in zip(f, f, f): And this iterated through a, b, c assigned to 3 consecutive lines of the file as it iterates through the file. I can sort of pretend t

Re: [Tutor] lambdas, generators, and the like

2014-01-16 Thread Keith Winston
On Thu, Jan 16, 2014 at 5:44 AM, spir wrote: > This, in addition to the requirement of uniqueness which as you say is > probably best met using a set (after filter). This may lead to you chosing > to store, even if otherwise not truely necessary. An question is: what kind > of data are combination

Re: [Tutor] Tutor Digest, Vol 115, Issue 28

2014-01-16 Thread Keith Winston
On Wed, Jan 15, 2014 at 6:12 AM, Steven D'Aprano wrote: > You're selling youself short. From what I've seen of you on this list, > you might be a beginner, but you've got the right sort of inquiring mind > to go far as a programmer. Thanks Steven, I've abruptly gotten clear how much work I have a

Re: [Tutor] another better way to do this ?

2014-01-13 Thread Keith Winston
s*** just got real. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] another better way to do this ?

2014-01-13 Thread Keith Winston
Yikes, Peter, that's scary. Wow. On Mon, Jan 13, 2014 at 1:22 PM, Peter Otten <__pete...@web.de> wrote: > Peter Otten wrote: > >> Emile van Sebille wrote: >> >>> On 01/12/2014 12:21 PM, Peter Otten wrote: >>> >>> test("axbxc", "abc") True >>> test("abbxc", "abc") False

Re: [Tutor] Euler Spoiler

2014-01-13 Thread Keith Winston
Ah, I got through it. Yes, I started down this path, but didn't dot the i's. Thanks. I'm going to do some more reading on dynamic programming... Keith On Mon, Jan 13, 2014 at 12:51 PM, Keith Winston wrote: > Danny, thanks for that exposition. I don't have time to absorb

Re: [Tutor] another better way to do this ?

2014-01-13 Thread Keith Winston
On Mon, Jan 13, 2014 at 1:14 AM, Roelof Wobben wrote: > I have read all comments and im a little bit confused. > About which script are we talkimng about. I have seen a lot. I am talking about the script/approach I posted. Others have posted other scripts. Hopefully you have the capacity, with w

Re: [Tutor] Euler Spoiler

2014-01-13 Thread Keith Winston
Danny, thanks for that exposition. I don't have time to absorb it yet,though I will attempt to soon, but I wanted to thank you for your effort in the meantime. Keith ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: h

Re: [Tutor] Euler Spoiler

2014-01-12 Thread Keith Winston
Thanks everyone, things to chew on. I'll look at the other itertools functions mentioned. I did solve Proj. Euler 15 & 18 (and it's corresponding 67), one more elegantly than the other, and I have given some thought to how to break this one down, but haven't figured it out yet. I think I might not

[Tutor] Euler Spoiler

2014-01-12 Thread Keith Winston
I'm working through some of the Project Euler problems, and the following might spoil one of the problems, so perhaps you don't want to read further... The problem relates to finding all possible combinations of coins that equal a given total. I'm basically brute-forcing it, which is probably not

Re: [Tutor] another better way to do this ?

2014-01-12 Thread Keith Winston
On Sun, Jan 12, 2014 at 2:22 PM, Keith Winston wrote: > There's another approach, I think, that's quite easy if order IS important. Alas, there's one further problem with my script, relating to testing multiple sequential letters in product... but I'm not going to say m

Re: [Tutor] another better way to do this ?

2014-01-12 Thread Keith Winston
On Sun, Jan 12, 2014 at 2:38 PM, Keith Winston wrote: > Sigh and this line needs to read (if it's going to do what I said): As Alan pointed out, the examples provided do NOT account for order, so if one uses my (corrected) algorithm, you get different results from the examples. Wit

Re: [Tutor] another better way to do this ?

2014-01-12 Thread Keith Winston
On Sun, Jan 12, 2014 at 2:22 PM, Keith Winston wrote: > if test: Sigh and this line needs to read (if it's going to do what I said): if test != -1: -- Keith ___ Tutor maillist - Tutor@python.org To unsubscribe o

Re: [Tutor] another better way to do this ?

2014-01-12 Thread Keith Winston
OOps, I never used the "success" boolean in my code, but forgot to remove it. Sorry. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] another better way to do this ?

2014-01-12 Thread Keith Winston
On Sun, Jan 12, 2014 at 7:44 AM, Alan Gauld wrote: > OK< So there is nothing here about the orders being the same. > That makes it much easier. There's another approach, I think, that's quite easy if order IS important. Iterate through the letters of product, find() them initially from the begi

Re: [Tutor] lambdas, generators, and the like

2014-01-12 Thread Keith Winston
every time I run it... I'm generating a LOT of combinations. On Sun, Jan 12, 2014 at 9:33 AM, Dave Angel wrote: > Keith Winston Wrote in message: >> I've got this line: >> >> for k in range(len(tcombo)): >> tcombo_ep.append(list(combinations(tcombo, k+1

Re: [Tutor] lambdas, generators, and the like

2014-01-12 Thread Keith Winston
On Sun, Jan 12, 2014 at 4:19 AM, Alan Gauld wrote: > lambdas are just a shortcut for single expression functions. > You never need them, they just tidy up the code a bit by > avoiding lots of use-once short functions. Thanks, I figured out how to iterate the combinations function. I'll play with

[Tutor] lambdas, generators, and the like

2014-01-12 Thread Keith Winston
I've got this line: for k in range(len(tcombo)): tcombo_ep.append(list(combinations(tcombo, k+1))) generating every possible length combination of tcombo. I then test them, and throw most of them away. I need to do this differently, it gets way too big (crashes my computer). I'm going to pla

Re: [Tutor] Tutor Digest, Vol 115, Issue 28

2014-01-11 Thread Keith Winston
On Sat, Jan 11, 2014 at 7:37 PM, Alan Gauld wrote: > In other words, think about the design of your code don't > just type randomly. I prefer the "million monkeys at a million typewriters" approach to coding... But then, it's all I've tried... -- Keith ___

Re: [Tutor] Python Question

2014-01-10 Thread Keith Winston
Amy, judging from Danny's replies, you may be emailing him and not the list. If you want others to help, or to report on your progress, you'll need to make sure the tutor email is in your reply to: Often, people prefer you to respond to the list, if there isn't something particularly personal in y

Re: [Tutor] Python Question

2014-01-10 Thread Keith Winston
Amy, be aware that there are slightly different versions of Python floating around, and the example Dayo gave you uses a slightly different print statement (no parens) than the example you provided (which probably indicates that your Python requires them). Good luck, you're on your way! Keith ___

Re: [Tutor] Python Question

2014-01-10 Thread Keith Winston
Amy, you may want to get a little clearer on the difference between defining a function, and calling one. The definition is sort of a generic process, it's when you are calling it that you really fill in the blanks, and the function does what it's designed for (whether you like it or not!). You mi

Re: [Tutor] recursion depth

2014-01-09 Thread Keith Winston
On Thu, Jan 9, 2014 at 5:41 AM, Steven D'Aprano wrote: > > Keith, if you are able, and would be so kind, you'll help solve this > issue for Dave if you configure your mail client to turn so-called "rich > text" or formatted text off, at least for this mailing list. Well, hopefully this is plain t

Re: [Tutor] garbage collecting

2014-01-08 Thread Keith Winston
On Thu, Jan 9, 2014 at 12:27 AM, eryksun wrote: > The old float freelist was the same design as the one for 2.x int > (PyInt, not PyLong), which grows without bound. The design also > allocates objects in 1 KiB blocks (approx. size). glibc's malloc will > use the heap for a block that's this smal

Re: [Tutor] recursion depth

2014-01-08 Thread Keith Winston
On Wed, Jan 8, 2014 at 6:16 PM, Dave Angel wrote: > I can't see the bodies of any of your messages (are you perchance posting > in html? ), but I think there's a good chance you're abusing recursion and > therefore hitting the limit much sooner than necessary. I've seen some code > samples here

Re: [Tutor] recursion depth

2014-01-08 Thread Keith Winston
On Wed, Jan 8, 2014 at 5:15 PM, spir wrote: > Funny and useful exercise in recursion: write a func that builds str and > repr expressions of any object, whatever its attributes, inductively. Eg > with > Hmm, can't say I get the joke. I haven't really played with repr, though I think I understand

Re: [Tutor] recursion depth

2014-01-08 Thread Keith Winston
On Wed, Jan 8, 2014 at 4:23 PM, eryksun wrote: > You can create a worker thread with a larger stack using the threading > module. On Windows the upper limit is 256 MiB, so give this a try: > quite excellent, mwahaha... another shovel to help me excavate out the bottom of my hole... I'll play wi

Re: [Tutor] recursion depth

2014-01-08 Thread Keith Winston
On Wed, Jan 8, 2014 at 3:42 PM, Emile van Sebille wrote: > > Without seeing your code it's hard to be specific, but it's obvious you'll > need to rethink your approach. :) Yes, it's clear I need to do the bulk of it without recusion, I haven't really thought about how to do that. I may or may

Re: [Tutor] garbage collecting

2014-01-08 Thread Keith Winston
On Wed, Jan 8, 2014 at 3:30 PM, Oscar Benjamin wrote: > The garbage collector has nothing to do with the memory usage of immutable > types like ints. There are deallocated instantly when the last reference > you hold is cleared (in CPython). So if you run out of memory because of > them then it is

[Tutor] recursion depth

2014-01-08 Thread Keith Winston
I've been playing with recursion, it's very satisfying. However, it appears that even if I sys.setrecursionlimit(10), it blows up at about 24,000 (appears to reset IDLE). I guess there must be a lot of overhead with recursion, if only 24k times are killing my memory? I'm playing with a challe

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

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

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

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

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

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

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

  1   2   >