Re: [Tutor] Fraction - differing interpretations for number and string - presentation

2015-04-16 Thread Jim Mooney
> > Is this "inaccurate"? Well, in the sense that it is not the exact true > mathematical result, yes it is, but that term can be misleading if you > think of it as "a mistake". In another sense, it's not inaccurate, it is > as accurate as possible (given the limitation of only having a certain > f

Re: [Tutor] Fraction - differing interpretations for number and string - presentation

2015-04-16 Thread Jim Mooney
The whole point of the discussion is that this is *not* a presentation issue. Fraction(1.64) and Fraction("1.64") *are* two different numbers because one gets constructed from a value that is not quite 1.64. Wolfgang Maier -- So the longer numerator and denominator would, indeed, be more accurate

[Tutor] sample dictionairies

2015-04-19 Thread Jim Mooney
Where could I download Python sample dictionaries on different subjects. They're hard to type and I can only do small, limited ones to practice with. -- Jim The probability of a piano falling on my head is 50%. After it falls on my head the probability is 100%. My confidence in the piano hitting

Re: [Tutor] sample dictionairies

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

[Tutor] bin to dec conversion puzzlement

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

Re: [Tutor] sample dictionairies

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

Re: [Tutor] bin to dec conversion puzzlement

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

[Tutor] enhanced subtration in an exponent

2015-04-21 Thread Jim Mooney
Why does the compiler choke on this? It seems to me that the enhanced subtraction resolves to a legitimate integer in the exponent, but I get a syntax error: B = '11011101' sum = 0 start = len(B) for char in B: sum += int(char) * 2**(start -= 1) ## syntax error print(sum) -- Jim ___

[Tutor] calling a method directly

2015-04-21 Thread Jim Mooney
Is there any difference between these two since they give the same result, and when is the second preferred? >>> x = 'ABE' >>> x.lower() 'abe' >>> str.lower(x) 'abe' -- Jim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription o

[Tutor] name shortening in a csv module output

2015-04-23 Thread Jim Mooney
I'm trying the csv module. It all went well until I tried shortening a long first name I put in just to exercise things. It didn't shorten. And I also got weird first characters on the header line. What went wrong? import csv allcsv = [] with open('data.txt') as csvfile: readCSV = csv.reader(c

Re: [Tutor] name shortening in a csv module output

2015-04-23 Thread Jim Mooney
.. > Ï»¿ > > is the UTF-8 BOM (byte order mark) interpreted as Latin 1. > > If the input is UTF-8 you can get rid of the BOM with > > with open("data.txt", encoding="utf-8-sig") as csvfile: > Peter Otten I caught the bad arithmetic on name length, but where is the byte order mark coming from? My

Re: [Tutor] name shortening in a csv module output

2015-04-23 Thread Jim Mooney
> > By relying on the default when you read it, you're making an unspoken > assumption about the encoding of the file. > > -- > DaveA So is there any way to sniff the encoding, including the BOM (which appears to be used or not used randomly for utf-8), so you can then use the proper encoding, or

Re: [Tutor] name shortening in a csv module output

2015-04-24 Thread Jim Mooney
So is there any way to sniff the encoding, including the BOM (which appears to be used or not used randomly for utf-8), so you can then use the proper encoding, or do you wander in the wilderness? Pretty much guesswork. > Alan Gauld -- This all sounds suspiciously like the old browser wars I suf

[Tutor] Spongebob Pythonpants

2015-04-24 Thread Jim Mooney
I was depressed at the thought of learning unicode, then discovered Python was fun again since I can easily print any ascii art from http://www.chris.com/ascii/ with a multiline print, so long as I replace any backslash with two of them. Spongebob Squarepants was, of course, the obvious first choi

Re: [Tutor] Spongebob Pythonpants

2015-04-24 Thread Jim Mooney
You can save yourself some time and use a raw string: > print(r""" """) > > Timo > > Good point. I'll go to site-packages and change that. I import Bob to cheer myself up as I look at Unicode, which is like forcing a kid to go to Sunday school on a bright Summer day, instead of playing with P

Re: [Tutor] name shortening in a csv module output

2015-04-24 Thread Jim Mooney
> > Apparently so. It looks like utf_8-sig just ignores the sig if it is > present, and uses UTF-8 whether the signature is present or not. > > That surprises me. > > -- > Steve > > I was looking things up and although there are aliases for utf_8 (utf8 and utf-8) I see no aliases for

[Tutor] sig no matter what

2015-04-24 Thread Jim Mooney
It looks like sig works for any dash, underline combination, and is ignored if there is no BOM: >>> farf = bytes('many moons ago I sat on a rock', encoding='utf8') >>> farf b'many moons ago I sat on a rock' >>> str(farf, encoding="utf_8_sig") 'many moons ago I sat on a rock' >>> str(farf, encoding

[Tutor] Making an alias

2015-04-24 Thread Jim Mooney
Actually,. I found the aliases in Lib/encodings/aliases.py and added an alias: >>> deco = bytes("I sure hate apples.", encoding='ubom') >>> deco b'\xef\xbb\xbfI sure hate apples.' >>> Tricky, though - if you don't put a comma at the end of your alias, it breaks Python (or my Pyscripter editor, an

Re: [Tutor] Spongebob Pythonpants

2015-04-25 Thread Jim Mooney
Unicode for Idiots indeed, a Python list can always find something better than that :) > > http://www.joelonsoftware.com/articles/Unicode.html > http://nedbatchelder.com/text/unipain.html > > > Mark Lawrence > > Batcheder's looks good. I'm going through it. I tried the Unicode Consortium website a

Re: [Tutor] name shortening in a csv module output

2015-04-25 Thread Jim Mooney
> > > I wouldn't use utf-8-sig for output, however, as it puts the BOM in the > file for others to trip over. > > -- > DaveA Yeah, I found that out when I altered the aliases.py dictionary and added 'ubom' : 'utf_8_sig' as an item. Encoding didn't work out so good, but decoding was fine ;') _

Re: [Tutor] sig no matter what

2015-04-25 Thread Jim Mooney
> See 7.2.3 (aliases) and 7.2.7 (utf_8_sig) in the codecs documentation. > > https://docs.python.org/3/library/codecs.html > The docs don't mention that case is immaterial for aliases, when it usually matters in Python. The actual dictionary entries in aliases.py often differ in case from the docs

Re: [Tutor] Codec lookup, was Re: name shortening in a csv module output

2015-04-25 Thread Jim Mooney
> > Hm, who the heck uses "u8"? I'd rather go with > > >>> encodings.aliases.aliases["steven_s_preferred_encoding"] = "utf_8" > >>> "Hello".encode("--- Steven's preferred encoding ---") > b'Hello' > > ;) > Peter Otten > __ > Or normalize almost any mistyping ;'): >>> encodings.normalize_encodin

[Tutor] REPL format

2015-04-25 Thread Jim Mooney
I'm curious why, when I read and decode a binary file from the net in one fell swoop, the REPL prints it between parentheses, line by line but with no commas, like a defective tuple. I can see breaking lines visually, at \n, but if the parentheses don't mean anything I can't see including them. Or

Re: [Tutor] REPL format

2015-04-26 Thread Jim Mooney
On 25 April 2015 at 17:43, Alan Gauld wrote: > know what's going on. I seem to recall you are using Python 3, > is that correct? > > I guess I should specify from now on py3 on win xp Another question - why does the first assignment work but not the second. I can see it's a syntax error but if

Re: [Tutor] Please disable “digest mode” before participating (was: Tutor Digest, Vol 134, Issue 86)

2015-04-26 Thread Jim Mooney
On 25 April 2015 at 18:03, Ben Finney wrote: > Digest mode should only ever be used if you know for certain you will > never be responding to any message. > That brings up a great shortcut if you use gmail. If you select some text before reply that's All that is sent. Cuts way down on huge reply

[Tutor] oops - resending as plain text

2013-04-16 Thread Jim Mooney
ies') print(change) #and so forth for the rest of the prog Jim Mooney ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] How did this decimal error pop up?

2013-04-16 Thread Jim Mooney
iesAmount *#change is 5.8745, not 5.87 - how did I get this decimal error when simply subtracting an integer from what should be a #two-decimal amount? * print(twenties, ' twenties') print(change) #and so forth for the rest of the change -- *Jim Mooney If you shoo

Re: [Tutor] Tutor Digest, Vol 110, Issue 69

2013-04-16 Thread Jim Mooney
> Now that Joel Goldstick has pointed out the reason, you may wonder what to do > now. Answer? Use the decimal module: > > http://docs.python.org/2/library/decimal.html > > Although, you might prefer Doug Hellmann's introduction: > > http://pymotw.com/2/decimal/ Thanks. I was about to ask that bu

Re: [Tutor] oops - resending as plain text

2013-04-16 Thread Jim Mooney
gt;>> n = 5.87000045 >>>> print '%.2f' % n > 5.87 >>>> print '%.4f' % n > 5.8700 > > Or use round(), example: > >>>> round(n,2) > 5.87 > > In your case I would just use string formatting to

[Tutor] regex to promote Py 2 to Py 3?

2013-04-16 Thread Jim Mooney
I already tried an example I copied from something online, in Py 2, that had a ton of print statements. So I did some fast search and replace to make them Py 3 with (), since I'm using Py 3. (Except Wing 101 won't do Replace All for some reason I haven't figured out, so it's a bit tedious) So for

Re: [Tutor] regex to promote Py 2 to Py 3?

2013-04-16 Thread Jim Mooney
> Generally the 2to3 script does an OK job. If you're using Windows it's > [Python_Dir]\Tools\Scripts\2to3.py. > > http://docs.python.org/3/library/2to3 Thanks. I didn't know where to find it and thought I had to install it. I opened a command window in my Python3

Re: [Tutor] Tutor Digest, Vol 110, Issue 74

2013-04-17 Thread Jim Mooney
> The script 2to3.py is run from the system's terminal/console shell > (e.g. cmd or PowerShell on Windows), not the python shell. Yay, it worked! A decade of Windows and I'm back to the DOS Command Line ;') Well, it worked the second time.I thought I could do without the -w but nothing happened.

[Tutor] path directory backslash ending

2013-04-18 Thread Jim Mooney
ention for this. -- Jim Mooney Today is the day that would have been tomorrow if yesterday was today ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] path directory backslash ending

2013-04-18 Thread Jim Mooney
Well, under the principle of least harm, it appears that since the trailing backslash causes no harm if omitted, but sometimes does if allowed, I removed them all. But that's in win 7. Is it okay to always omit them in Linux? Python33 is itself installed with a trailing backslash, so I figured th

[Tutor] 3to2?

2013-04-20 Thread Jim Mooney
to2 script?. Or does that even makes sense since 3 has features 2 does not, although I read somewhere that many have been backported? -- *Jim Mooney Today is the day that would have been tomorrow if yesterday was today * ___ Tutor maillist - Tutor@pyt

Re: [Tutor] 3to2?

2013-04-20 Thread Jim Mooney
On 20 April 2013 12:50, eryksun wrote: > On Sat, Apr 20, 2013 at 2:32 PM, Jim Mooney > wrote: > > I was looking at google pengine for python and it only supports 2.7. I've > > installed 3 and would rather not go back > > Do you mean Google App Engine (GAE)? >

[Tutor] Time frame for Py 3 Maturity

2013-04-20 Thread Jim Mooney
l be huge inflation, I'll go broke, and have to use it more practically ;') Also, is there a good syllabus for the best way to progress in this language? One can certainly get sidetracked. -- *Jim Mooney Today is the day that would have been tomorrow if

[Tutor] Py 3 package maturity - good links

2013-04-21 Thread Jim Mooney
> On the other hand, from the perspective of "When will the *majority* of > publicly-available libraries and packages support Python 3, then the answer > is "Right now". The Python 3 Wall of Shame turned mostly green some time > ago, > and is now known as the Python 3 Wall of Superpowers: > > https

[Tutor] is there an explicit eof to test in Py 3?

2013-04-21 Thread Jim Mooney
m javascript which has a cluster of rules for that. Yes, I know the easy way is a for loop, which automatically breaks on eof, but at times I want to use a while loop and break out of it explicitly on eof. But I can't seem to find an explicit eof marker in python. Is there one? -- Jim Mooney

[Tutor] multiple versions of python on windows?

2013-04-21 Thread Jim Mooney
My plan for starting on Py 3 may need some adjustment. I doiwnloaded an irc client that needs Py 2.6 and I think Plone wants 2.7. Is it possible to install multiple versions of python on the same machine or will windows choke? -- Jim Mooney Today is the day that would have been tomorrow if

Re: [Tutor] multiple versions of python on windows?

2013-04-21 Thread Jim Mooney
obably a Wing discuss question, but I'm burned out on joining discussion groups to ask one question, since otherwise Wing is very easy to grasp. -- Jim Mooney Today is the day that would have been tomorrow if yesterday was today ___ Tutor mailli

[Tutor] Why is my list index going out of range

2013-04-22 Thread Jim Mooney
ment, and I still got the line 5 error: primeList = [1] numList = list(range(2,101)) for e in numList: for f in primeList: if numList[e] % primeList[f] != 0: #list index out of range primeList.append(numList[e]) print(primeList) -- Jim Mooney The Real Reason Things Keep Going Wrong:

[Tutor] changing list element in loop

2013-04-27 Thread Jim Mooney
Why isn't 'e' changing to 'pP here when the vowel list is mutable: vowelList = list('aeiouy') for x in vowelList: if x == 'e': x = 'P' print(vowelList) #result: ['a', 'e', 'i', 'o', 'u

Re: [Tutor] changing list element in loop

2013-04-27 Thread Jim Mooney
On 27 April 2013 02:55, Amit Saha wrote: > On Sat, Apr 27, 2013 at 7:49 PM, Jim Mooney wrote: >> Why isn't 'e' changing to 'pP here when the vowel list is mutable: >> >> vowelList = list('aeiouy') >> >> for x in vowelList: >>

[Tutor] Why isn't iteritems() working when items() does?

2013-04-27 Thread Jim Mooney
#x27;:'Desdemona'} dickList = dick.items() for role, name in dickList: print(role, name) #The above works, but using iteritems() in place of items doesn't dickList2 = dick.iteritems() for role, name in dickList2: print(role, name) #error: builtins.AttributeError: 'dict

Re: [Tutor] Tutor Digest, Vol 110, Issue 117

2013-04-28 Thread Jim Mooney
> In py3.x, iteritems was replaced by .items() Interesting, since iteritems was in my book, which was "updated" for Py33. I guess the moral is you shouldn't trust an author 100% ;') I must admit, iteritems did seem awkward and annoying so I'm glad it's dropped. Jim __

[Tutor] changing char list to int list isn't working

2013-05-03 Thread Jim Mooney
= int(num) print(listOfNumChars) # result of 455 entered is ['4', '5', '5'] -- Jim Mooney “For anything that matters, the timing is never quite right, the resources are always a little short, and the people who affec

[Tutor] stumped by what looks like recursive list comprehension

2013-05-05 Thread Jim Mooney
. Could someone show this in normal, indented 'for' loops so I can see what 'for' goes where and how it works. I figure if I figure this one one I'll really comprehend list comprehension. # find nonprimes up to 50, then filter out what's left as primes noprimes = [j

[Tutor] exit message

2013-05-05 Thread Jim Mooney
to exit for some normal reason and don't want the message? Or is a program always supposed to end in some normal way without an exit. Or is there a different, more graceful way to end a program when you want? -- Jim Mooney “For anything that matters, the timing is never quite right, the reso

Re: [Tutor] exit message

2013-05-05 Thread Jim Mooney
> Something like this? > >>> import sys while 1: > ... sys.exit('Exiting from Infinite Loop') > ... > Exiting from Infinite Loop I still get a traceback message from the console. I just want a clean exit without that. I have a feeling I'm thinking about something the wrong way ;') Traceb

Re: [Tutor] Tutor Digest, Vol 111, Issue 11

2013-05-06 Thread Jim Mooney
> I believe that traceback is a bug in IDLE, which I think has been > fixed for the next release (or is being chased, one of the two). Ah, that clears it up. I've been using IDLE and Wing. Both have the traceback so I guess Wing uses some IDLE code. But I tried it in the command shell, which I hav

[Tutor] PyScripter header?

2013-05-08 Thread Jim Mooney
I'm trying PyScripter instead of Wing 101. It works fine and has a lot more PyLearner features than Wing 101 (at the same price ;'), such as popups showing the parameters for methods, profiler, lint, programmable snippets, etc. It also lets you choose your Python version and finds the right one, wh

Re: [Tutor] Tutor Digest, Vol 111, Issue 19

2013-05-09 Thread Jim Mooney
> Given that your main() question ;c) has been answered, you might also > want to give Spyder a try before switching. Thanks - I'll try that if it's not overkill for a basic learning tool, or has a ton of dependencies I have to install, or isn't up to Py3.3. PyScripter had an odd bug. Whenever I

[Tutor] bad name in module

2013-05-09 Thread Jim Mooney
eger, Corky - try again: ") randomList = [] for c in range(0,listLength): randNum = random.randint(0,maxNumberSize) randomList.append(randNum) return randomList -- Jim Mooney “For anything that matters, the timing is never quite right, the resources are always

Re: [Tutor] Tutor Digest, Vol 111, Issue 24

2013-05-10 Thread Jim Mooney
> As with any other module you need to specify the module when using its > contents: > > newRandomList = makeRandomList.createRandomList() > > BTW. A better name for the module is probably just randomlist > > HTH > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ Ah

Re: [Tutor] Tutor Digest, Vol 111, Issue 24

2013-05-10 Thread Jim Mooney
>> BTW, does your "better name" mean that camelCaps are discouraged in >> Python? > > No, although most Python modules are all lowercase. But I really meant that > your module should be for more than just making lists, it should eventually > have all the functions needed to manage the list. > > Eve

[Tutor] range efficiency

2013-05-10 Thread Jim Mooney
figure this myself once I get an editor I like with a profiler, but I'm still trying editors and don't want to spend all my time on them. So far I'm in between too simple, overkill, or buggy. And I don't want anything that uses Java. I'm allergic to Java ;') -- Jim

[Tutor] variable in format string throwing error

2013-05-13 Thread Jim Mooney
I'm trying variable substitution in a format string that looks like one that works, but I get an error. What am I doing wrong? tks x = 40 s = 'John flew to the {0:-^{x}} yesterday' print(s.format('moon', x)) Error is builtins.KeyError: 'x' -- Jim ___

[Tutor] Bugs came home

2013-05-15 Thread Jim Mooney
h to each Py. So my bad on the reported PyScripter bugs ;') -- Jim Mooney ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Pygraphics crashed

2013-05-15 Thread Jim Mooney
e them? And are they all in the same place? -- Jim Mooney ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Can't install latest PIL

2013-05-15 Thread Jim Mooney
w what I have to put in the registry. -- Jim Mooney “For anything that matters, the timing is never quite right, the resources are always a little short, and the people who affect the outcome are always ambivalent.” ___ Tutor maillist - Tutor@python.o

Re: [Tutor] Can't install latest PIL

2013-05-16 Thread Jim Mooney
Make sure you have the correct architecture. The builds from PythonWare are 32-bit. Christoph Gohlke has 64-bit builds here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil == Okay, I installed the 64 bit for Py 2.7, it installed, I see PIL directory in Site-Packages. (Actually, it's the Pillow f

Re: [Tutor] Pygraphics crashed

2013-05-16 Thread Jim Mooney
How do I install PIL with easy-install? I used that once but forget how. I seem to recall reading it installs a version that is Py native and doesn't choke on your OS. Or did I read that wrong? Jim On 16 May 2013 02:44, eryksun wrote: > On Thu, May 16, 2013 at 2:06 AM, Jim Moone

Re: [Tutor] Pygraphics crashed

2013-05-16 Thread Jim Mooney
> By the way, do you mind if I ask why you're using PyGraphics? It's > only meant to be used for education (and even there, AFAIK the only > users are the University of Toronto (and even there, I think they > stopped using it because they switched to Python 3 for Coursera and > didn't care enough t

Re: [Tutor] Can't install latest PIL

2013-05-16 Thread Jim Mooney
On 16 May 2013 16:11, James Reynolds wrote: > You may want to consider pillow. Oil hasn't been maintained in some time. Actually, I installed Pillow. But then I deleted everything and started over with 32 bit. I got greedy figuring I'd get the fastest Py with 64 bit, but there are too many kludge

Re: [Tutor] Can't install latest PIL

2013-05-17 Thread Jim Mooney
> If you see a syntax error, that means your code could not be compiled. > Python's parser doesn't grok "import image from pil". In natural > language we have the freedom to swap the order of clauses, but > programming languages are generally more rigid. The correct order is > "from pil import imag

[Tutor] WAMP stack

2013-05-18 Thread Jim Mooney
d and test it? (Assume I know nothing about Django other than it's a Py CMS, since I don't ;') Jim Mooney "Since True * True * True == True, what I tell you three times is true." --The Hunting of the Snark ___ Tutor maillist - T

[Tutor] creating import directories

2013-05-18 Thread Jim Mooney
I get "no module named bagofries" Is there some reason I can put a program right under Lib and it imports, which it does but not a directory? Also, I noticed Wing 101 is sometimes creating a same-named pyc program alongside my py program, but I don't see an option to do that. --

Re: [Tutor] Tutor Digest, Vol 111, Issue 61

2013-05-19 Thread Jim Mooney
> 1) The directory must be somewhere that Python will see it, no different from > a single file module. That means, in the current directory, or your > PYTHONPATH. Since Python on Win 7 can already find modules in Lib (and in site-packages, under Lib) can I assume that it will find any director

[Tutor] from import works but I'm flubbing a package import

2013-05-19 Thread Jim Mooney
bark' I'm doing the from statement right but what am I doing wrong with just importing the whole module and chaining out bark (for bark.py) and the function or data following? Using Py27 and Win 7 -- Jim Mooney There is no such thing as a failed experiment ___

Re: [Tutor] Tutor Digest, Vol 111, Issue 68

2013-05-20 Thread Jim Mooney
> > import random > > > > Count = 0 > > > > Random_Number = random.randint(1, 100) > > > > while Count <= 100: > > print (Random_Number) > > > > Count = Count + 1 > > There are a few issues here: > * variable names should be lower case > * for this case it's best to use for loop with ran

[Tutor] still clarifying imorting

2013-05-20 Thread Jim Mooney
with that is import media, without qualifying it with pygraphics, as in import pygraphics.media Why don't I have to drill down for media.py as I do with jimlib? -- Jim Mooney "And as he walked along he carried some things in his small sack. Some were useless and some were not. But t

[Tutor] nose error

2013-05-21 Thread Jim Mooney
I'm trying a nose test on a simple prog. Once I got past the huge traceback in Wing that made me think nose didn't work I realized the prog tested okay. But I noticed at the end of the traceback nose says this: "c:\Python27\Lib\site-packages\nose-1.3.0-py2.7.egg\nose\core.py", line 200, in runTest

[Tutor] still nosing around

2013-05-21 Thread Jim Mooney
unmodule() nose result: Ran 0 tests in 0.000s OK -- Jim Mooney "When I got to high school I realized my name would always present problems." --Dick Hertz ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Tutor Digest, Vol 111, Issue 72

2013-05-21 Thread Jim Mooney
> Do you ever bother to investigate anything before posing a question? Actually, I did notice that tests were zero, but the book I am using does not mention needing the word 'test' as part of the regex. There is only so much time in a day and so many books I can buy (and not all comprehensive, app

[Tutor] try..except - what about that ton of **Error statements?

2013-05-21 Thread Jim Mooney
have an asymptotic learning curve, so I go off on a lot of confused tangents, but I find it makes things go a lot faster after a certain point.) -- Jim Mooney "When I got to high school I realized my name would always present problems.&quo

Re: [Tutor] try..except - what about that ton of **Error statements?

2013-05-21 Thread Jim Mooney
> Keep the try block small. For example if it's for a call to > open(filename, "r") the only possible errors (assuming correct syntax) > are NameError for using an undefined variable and IOError for > specifying a file which doesnt exist. Thanks. Since I'm new at this the error lists I saw just ha

Re: [Tutor] Tutor Digest, Vol 111, Issue 72

2013-05-22 Thread Jim Mooney
> Please don't reply to digests. Each message has a Message-ID, and > replies have an IN-REPLY-TO field that references the ID of the > previous message in the thread. By replying to the digest your message > has no meaningful Subject, and even if you change the Subject field, > it still won't be t

[Tutor] To error statement or not to error statement

2013-05-22 Thread Jim Mooney
>> "I find it amusing when novice programmers believe their main job is >> preventing programs from crashing. ... More experienced programmers realize >> that correct code is great, code that crashes could use improvement, but >> incorrect code that doesn't crash is a horrible nightmare." Then am

Re: [Tutor] Fwd: Available characters

2013-05-22 Thread Jim Mooney
> The unicodedata module provides access to the Unicode database that Python > uses: > > http://docs.python.org/2/library/unicodedata#unicodedata.unidata_version That was really useful for another reason. After I checked and saw it was in DLLs, I investigated the other Python DLLs - which had her

[Tutor] keyboard interrupt

2013-05-22 Thread Jim Mooney
omething simple I'm missing? import winsound try: for freq in range(100,32000,100): winsound.Beep(freq, 1000) except KeyboardInterrupt: pass -- Jim Mooney ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscr

Re: [Tutor] keyboard interrupt

2013-05-22 Thread Jim Mooney
> I've not used it myself, but I believe the KeyboadInterrupt is only > generated by one _specific_ keypress. You mentioned that you pressed a key > - did you try Control-C? Actually, I did, using Win 7 - and I put exit() in place of pass. I tried ctrl-c, ctrl-x, esc, and del. Windows doesn't see

Re: [Tutor] keyboard interrupt

2013-05-22 Thread Jim Mooney
On 22 May 2013 13:24, Jim Mooney wrote: >> I've not used it myself, but I believe the KeyboadInterrupt is only >> generated by one _specific_ keypress. You mentioned that you pressed a key >> - did you try Control-C? > > Actually, I did, using Win 7 - and I put exit(

Re: [Tutor] keyboard interrupt

2013-05-22 Thread Jim Mooney
On 22 May 2013 15:05, eryksun wrote: > On Wed, May 22, 2013 at 4:30 PM, Jim Mooney wrote: >> >> Figured it out. Ctrl-C only works in the Windows Command window, not >> in an editor. > > Which IDE? Wing. But not being able to abort out of a Windows program is a feat

Re: [Tutor] keyboard interrupt

2013-05-22 Thread Jim Mooney
> What do you mean "doesn't do anything" ? It certainly terminates the loop, > which was the intent. Provided of course that something else isn't trapping > the Ctrl-C first. It doesn't in Windows proper, using Wing 101. It does exit in the Windows command console. For some reason I forgot ctrl-

Re: [Tutor] keyboard interrupt

2013-05-23 Thread Jim Mooney
winsound.Beep(freq, 1000) except KeyboardInterrupt: print 'last frequency heard was', freq - 100 exit(0) -- Jim Mooney ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] making a random list, then naming it

2013-05-23 Thread Jim Mooney
rlist.append(random.randint(0,maxval)) listlenmax = 'list' + '_' + str(length) + '_' + str(maxval) # just the name of a string, not the data name I want #just printing the below as a test - they'll be removed when the import works print

Re: [Tutor] making a random list, then naming it

2013-05-24 Thread Jim Mooney
> The short answer is that Python is not designed to be able to do such a > thing. You're advised instead to make a dictionary, where the key is the > name you generate I was probably unclear what I wanted to do. Basically, enter a string of number pairs of lengths and maxvals to create and prin

Re: [Tutor] making a random list, then naming it

2013-05-24 Thread Jim Mooney
On 24 May 2013 18:10, Dave Angel wrote: > Is lists[(3,8)] really so much harder to type than > list_3_8 ? > You have a point. I hate underlines - my finger always misses them. Keyboards were not designed for programming ;') Anyway, I just thought I'd try exec, but it's giving me fits putt

[Tutor] why can you swap an immutable tuple?

2013-05-25 Thread Jim Mooney
(8,5) # So how am I swapping elements of a tuple when a tuple is immutable? #t rying so change a tuple since I just did it testit[1] = 14 #program crashes - *TypeError: 'tuple' object does not support item assignment *so the tuple I just changed is indeed immutable -- Jim Mooney &

Re: [Tutor] why can you swap an immutable tuple?

2013-05-25 Thread Jim Mooney
On 25 May 2013 18:34, David wrote: > On 26/05/2013, Jim Mooney wrote: > > I thought tuples were immutable but it seems you can swap them, so I'm > > confused: > > > > a,b = 5,8 > > I think your confusion might arise from not understanding that the >

Re: [Tutor] why can you swap an immutable tuple?

2013-05-25 Thread Jim Mooney
On 25 May 2013 19:38, Steven D'Aprano wrote: > On 26/05/13 05:23, Mark Lawrence wrote: > > On the right hand side, 5,8 creates a tuple, which is then immediately > unpacked to two individual values. You can see this by disassembling the > code. In 2.7, you get this: > > py> from dis import dis

[Tutor] got text switched

2013-05-25 Thread Jim Mooney
Oops, Gmail switched me back to rich text. My apologies. Back to plain ;') I wish I could automate the mode, per-recipient, since I do need rich text for some things. The way gmail defaults seems to change from month to month. -- Jim Mooney ___

Re: [Tutor] making a string

2013-05-25 Thread Jim Mooney
eficient. However, the 4th edition I of Lutz that I got only goes up to Py 2.6. As a general question - is there any Big difference between 2.6 and 2.7 (the Py version I'm using) that I should look out for so I don't get tripped up? Jim Mooney

Re: [Tutor] making a string

2013-05-26 Thread Jim Mooney
ile for multi line statements since the example I saw was a single line, compiled a small multi-line routine nicely, and realized I had just compiled a bad syntax error. I was trying to iterate an integer. Good to know that compile doesn't check syntax, since I erroneous

Re: [Tutor] keyboard interrupt

2013-05-26 Thread Jim Mooney
On 26 May 2013 15:33, Marc Tompkins wrote: > On Sun, May 26, 2013 at 6:17 AM, eryksun wrote: StackOverflow may be good but I just had an unpleasant experience wanting to add New .py file to my Windows context menu. The first advice I saw was missing a backslash and had me adding the string to th

Re: [Tutor] making a string

2013-05-26 Thread Jim Mooney
On 26 May 2013 17:20, Steven D'Aprano wrote: > On 27/05/13 07:40, Jim Mooney wrote: > >> Good to know that compile doesn't check syntax, since I erroneously >> thought it did. > > > compile does check syntax. I'm unclear on something. The code below

Re: [Tutor] making a string

2013-05-26 Thread Jim Mooney
On 26 May 2013 17:38, eryksun wrote: > On Sun, May 26, 2013 at 8:20 PM, Steven D'Aprano wrote: >> On 27/05/13 07:40, Jim Mooney wrote: >> >>> Good to know that compile doesn't check syntax, since I erroneously >>> thought it did. >> >>

Re: [Tutor] keyboard interrupt

2013-05-26 Thread Jim Mooney
se could possibly cause a registry crash. It just didn't work since a backslash in the path to windows\shellnew was missing, probably due to typing too fast. -- Jim Mooney There are those who see. Those who see when they are shown. And those who do not see.

[Tutor] bytecode primer, and avoiding a monster download

2013-05-27 Thread Jim Mooney
install Visual Studio (Express, of course ;'). I'm on a very slow connection, right now. Is there any alternative to downloading this monster 600 Mb ISO just to install a package, or am I doomed to getting Visual Studio? -- Jim Mooney Atlantis Anyone? http://www.pnas.org/content/early/2013/

  1   2   3   >