Re: [Tutor] Fwd: Re: Need Help Modifying a wxPython GUI (scrolling display and logging)

2013-06-13 Thread Dave Angel
On 06/13/2013 10:37 AM, Matt D wrote: On 06/13/2013 08:22 AM, Dave Angel wrote: On 06/13/2013 12:18 AM, Matt D wrote: Hey, line 202: self.logfile.write('%s,'%(str(f))) d does put the comma in properly but, line 203: self.logfile.write('\n') was putting the newl

Re: [Tutor] Fwd: Re: Need Help Modifying a wxPython GUI (scrolling display and logging)

2013-06-13 Thread Dave Angel
On 06/13/2013 12:32 PM, Matt D wrote: On 06/13/2013 11:23 AM, Dave Angel wrote: On 06/13/2013 10:37 AM, Matt D wrote: On 06/13/2013 08:22 AM, Dave Angel wrote: On 06/13/2013 12:18 AM, Matt D wrote: Hey, line 202: self.logfile.write('%s,'%(str(f))) d does put th

Re: [Tutor] sound implementation problems

2013-06-13 Thread Dave Angel
On 06/13/2013 01:21 PM, jessica peters wrote: Hi I'm about 2 yrs into studying Python - started with "Hello World", and I'm working with v 2.5.1 right now. The past year I've begun trying to write my own interactive fiction. That works pretty well, but now I'm attempting to put some music i

Re: [Tutor] sound implementation problems

2013-06-13 Thread Dave Angel
On 06/13/2013 11:55 PM, Jim Mooney wrote: Alan Gauld That's a dodgy way to solve the problem since if you change IDE or run the program outside the IDE that startup script will likely get forgotten and not be used. Remember you are not expected to use an IDE for anything other than developing

Re: [Tutor] Fwd: Re: Need Help Modifying a wxPython GUI (scrolling display and logging)

2013-06-14 Thread Dave Angel
On 06/14/2013 10:48 AM, Matt D wrote: Hey, here is a snip of my code. #logger code-- # first new line #self.logfile.write('\n') # date and time #self.logfile.write('%s,'%(str(strftime("%

Re: [Tutor] Fwd: Re: Need Help Modifying a wxPython GUI (scrolling display and logging)

2013-06-14 Thread Dave Angel
On 06/14/2013 03:59 PM, Matt D wrote: On 06/14/2013 03:14 PM, Dave Angel wrote: On 06/14/2013 10:48 AM, Matt D wrote: Hey, here is a snip of my code. #logger code-- # first new line #self.logfile.write('\n') #

Re: [Tutor] sound implementation problems

2013-06-14 Thread Dave Angel
On 06/14/2013 11:43 AM, Jim Mooney wrote: On 13 June 2013 21:53, Dave Angel wrote: On 06/13/2013 11:55 PM, Jim Mooney wrote: Alan Gauld This is for my own convenience on my own machine. As a former webmaster I'm of course used to idiot-proofing anything released into the wild so

Re: [Tutor] What are these two string-formatting styles called?

2013-06-14 Thread Dave Angel
On 06/14/2013 03:09 PM, Jim Mooney wrote: Of course, the real consideration, for those thinking of programming as a career path, is whether programmers will be as obsolete at gaslighters in twenty years - or will they be doing some sort of weird meta-programming? You mean you don't write

Re: [Tutor] What are these two string-formatting styles called?

2013-06-14 Thread Dave Angel
On 06/14/2013 05:43 PM, Alan Gauld wrote: On 14/06/13 19:34, Jim Mooney wrote: I'm probably going to hear that's already been done, too ;') Not in 3D to my knowledge but visual programming for sure. One example was ObjectVision from Borland on the PC. It lacked a loop construct because it was

Re: [Tutor] What are these two string-formatting styles called?

2013-06-15 Thread Dave Angel
On 06/15/2013 06:23 AM, Dotan Cohen wrote: On Fri, Jun 14, 2013 at 7:01 PM, Jim Mooney wrote: On 14 June 2013 08:23, Dotan Cohen wrote: What are these two string-formatting styles called? '%.3f' % x '{0:.3f}'.format(x) The first one is a string Expression, using % as the overloaded operat

Re: [Tutor] Is there a programmatic use for keys() and values()

2013-06-15 Thread Dave Angel
On 06/15/2013 08:36 PM, Steven D'Aprano wrote: On 16/06/13 07:55, Alan Gauld wrote: On 15/06/13 20:54, Jim Mooney wrote: I just like to avoid typing all those odd little-finger characters. The dictionaries are the worst. I think your making it harder than it is. Just use the result as you wo

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Dave Angel
On 06/15/2013 09:30 PM, Jim Mooney wrote: ##This is puzzling me. If I check the equality of 0, None, empty string, and empty list with False, ##only zero satisfies the equality. But if I use them in a not statement, they all turn out False. ##What gives? #Using C:\Python33\python.exe on Win 7 in

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Dave Angel
On 06/15/2013 10:21 PM, Jim Mooney wrote: On 15 June 2013 19:03, Dave Angel wrote: Why such a convoluted way of expressing yourself? I was demonstrating the parallelism, but let's just take one so I can unbefuddle meself ;') *** Python 3.3.2 32 bit (Intel)] on win32. *** '&#

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Dave Angel
On 06/15/2013 11:53 PM, Jim Mooney wrote: On 15 June 2013 20:48, Joel Goldstick wrote: One and zero for True and False may seem not quite right today, I still think they should be taken out and shot ;') But my simplification plan failed. Equality always fails for different types, and 'not i

Re: [Tutor] Is there a programmatic use for keys() and values()

2013-06-15 Thread Dave Angel
On 06/16/2013 01:58 AM, Steven D'Aprano wrote: On 16/06/13 11:53, Dave Angel wrote: On 06/15/2013 08:36 PM, Steven D'Aprano wrote: for key in sorted(mydict.keys()): ... works fine. [...] The sort() method doesn't work, but sorted does. [...] for key in sorted(mydict

Re: [Tutor] What are these two string-formatting styles called?

2013-06-15 Thread Dave Angel
On 06/16/2013 01:40 AM, Dotan Cohen wrote: On Sat, Jun 15, 2013 at 2:32 PM, Dave Angel wrote: Thank you. So would it be clear if I were to say "I prefer printf-style formatting over the format method."? I'd be careful there, since method is an English word as well as a Pyth

Re: [Tutor] How to find descendants recursively?

2013-06-16 Thread Dave Angel
On 06/16/2013 01:20 PM, Timo wrote: I have a datafile which is parsed by an external library, I'm having trouble creating a hierarchical structure of the data. This is what I got so far: items = get_items() # returns a generator for item in items: print(item) children = get_children(i

Re: [Tutor] The Whole Tree

2013-06-16 Thread Dave Angel
On 06/16/2013 01:21 PM, Jim Mooney wrote: My first impression of Python was that it had dynamic types but didn't mix them. so if I was wrong on equality, is there a general rule of what different types can still be equal? Is it an inheritance thing? Several other good replies, but I'll give my

Re: [Tutor] Getting the real exception clause

2013-06-16 Thread Dave Angel
On 06/16/2013 04:26 PM, Jim Mooney wrote: '''I'm using general Exception to print out what the exception is until I learn them, but it will print out "[Errno 2] No such file or directory" in this case, when the real exception I'd need to use in an except clause is FileNotFoundError. How do I get

Re: [Tutor] Getting the real exception clause

2013-06-16 Thread Dave Angel
On 06/16/2013 08:04 PM, Jim Mooney wrote: On 16 June 2013 16:41, Dave Angel wrote: But if you have some other reason to do it your way, then just look at the type of err. print( type(err), err) Yes, that's what I was looking for. It's just a learning tool to see the exceptions w

Re: [Tutor] Need help appending data to a logfile

2013-06-17 Thread Dave Angel
On 06/17/2013 01:36 PM, Matt D wrote: Hey, I wrote some simple code to write data to a logfile and it works pretty well (thanks guys). Now my problem is that every time i run the program the old logfile.txt is overwritten. I need to be able to stop and start the program without overwriting, or

Re: [Tutor] Need help appending data to a logfile

2013-06-17 Thread Dave Angel
On 06/17/2013 05:17 PM, Jim Mooney wrote: On 17 June 2013 11:30, Peter Otten <__pete...@web.de> wrote: The help() function in the interactive interpreter is a good tool hunt for help on features of functions and classes. For example: I tripped on Python help a couple of times, since I'm used

Re: [Tutor] Need help appending data to a logfile

2013-06-17 Thread Dave Angel
. Well, although I would like to see my name in lights, I didn't discover it, Dave did, so that would be dishonest ;') http://bugs.python.org/issue18249 filed at 8:55 pm -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe

Re: [Tutor] unstring

2013-06-18 Thread Dave Angel
On 06/18/2013 09:41 PM, Jim Mooney wrote: Is there a way to unstring something? That is str(object) will give me a string, but what if I want the original object back, for some purpose, without a lot of foofaraw? In general, definitely not. A class can define just about anything in its __str

Re: [Tutor] EXE Problem

2013-06-19 Thread Dave Angel
On 06/19/2013 02:50 AM, Jack Little wrote: I compiled a program in python, but the second I open it, there is a flash of the error, but then the cmd window closes. It compiles when you run it, so it's not clear what extra step you're describing here. Quite a bit of missing information here

Re: [Tutor] EXE Problem

2013-06-19 Thread Dave Angel
On 06/19/2013 06:58 PM, Alan Gauld wrote: On 19/06/13 17:41, Jim Mooney wrote: you should use forward slashes. I have no idea why Bill Gates thought backslashes were kewl Because MS DOS was copying CP/M which didn't have directory paths (it was used with 180K floppy disks that stored everythi

Re: [Tutor] EXE Problem

2013-06-19 Thread Dave Angel
On 06/19/2013 06:58 PM, Alan Gauld wrote: On 19/06/13 17:41, Jim Mooney wrote: you should use forward slashes. I have no idea why Bill Gates thought backslashes were kewl Because MS DOS was copying CP/M which didn't have directory paths (it was used with 180K floppy disks that stored everythi

Re: [Tutor] Data persistence problem

2013-06-21 Thread Dave Angel
On 06/21/2013 02:21 AM, Arijit Ukil wrote: I have following random number generation function def rand_int (): rand_num = int(math.ceil (random.random()*1000)) return rand_num I like to make the value of rand_num (return of rand_int) static/ unchanged after first call even if it is ca

Re: [Tutor] How convert an int to a string

2013-06-22 Thread Dave Angel
On 06/22/2013 05:01 PM, Jim Byrnes wrote: I need to convert a series of digits like 060713 to a string so I can make it look like a date 06-07-13. Where is this series of digits coming from? Is it in the source code, or in a file, or coming from the user, or what? If it's in source code, a

Re: [Tutor] How convert an int to a string

2013-06-22 Thread Dave Angel
On 06/22/2013 07:03 PM, Jim Byrnes wrote: On 06/22/2013 05:10 PM, David Rock wrote: * Jim Byrnes [2013-06-22 16:01]: I need to convert a series of digits like 060713 to a string so I can make it look like a date 06-07-13. >>> a = 060713 >>> a[:2] Traceback (most recent call last): Fil

Re: [Tutor] random.choice() problem

2013-06-23 Thread Dave Angel
On 06/23/2013 02:18 AM, Jack Little wrote: I am trying to use random.choice for a text based game. I am using windows 7, 64-bit python. Here is my code: def lvl2(): print "COMMANDER: Who should you train with?" trn=random.choice(1,2) if trn==1: lvl2_1() print "S

Re: [Tutor] How convert an int to a string

2013-06-23 Thread Dave Angel
On 06/23/2013 12:43 PM, Jim Byrnes wrote: On 06/22/2013 06:24 PM, Dave Angel wrote: On 06/22/2013 07:03 PM, Jim Byrnes wrote: On 06/22/2013 05:10 PM, David Rock wrote: * Jim Byrnes [2013-06-22 16:01]: I need to convert a series of digits like 060713 to a string so I can make it look like a

Re: [Tutor] Need help appending data to a logfile

2013-06-23 Thread Dave Angel
On 06/17/2013 02:20 PM, Lukáš Němec wrote: Or even better, use python moto, dont re-invent the wheel, so use built in library logging, read the docs for it, or if you want, I can send you some examples how to work it, it takes some time to figure out properly... But what he's doing has

Re: [Tutor] Function Return Values (or References)

2013-06-24 Thread Dave Angel
On 06/24/2013 04:12 AM, John Steedman wrote: Hi Tutors, I'm confused by the following possible contradiction. Would someone please explain or point me to the right docs. FACT 1 "Variables in python hold references to objects." http://en.wikipedia.org/wiki/Python_syntax_and_semantics FACT 2

Re: [Tutor] Need help appending data to a logfile

2013-06-24 Thread Dave Angel
On 06/24/2013 05:39 PM, Matt D wrote: But what he's doing has nothing to do with logging. He's just using that word. Right, I'm not doing a debugging thing. Just trying to create a log of data that has been passed into the display of this program. Since I started trying to use the array t

Re: [Tutor] mistaken about splitting expressions over lines

2013-06-24 Thread Dave Angel
On 06/24/2013 09:48 PM, Jim Mooney wrote: For some reason I took the impression that you could split expressions over lines. However, this works: word = 'spam' new_word = word + 'eggs' print(word) But this is a syntax error: word = 'spam' new_word = word + 'eggs' print(word) That's easy to

Re: [Tutor] While problem

2013-06-26 Thread Dave Angel
On 06/26/2013 08:32 PM, Jack Little wrote: I have a small problem with the while function.It prints an odd variable What variable is that? that has nothing to do with the function. It prints "Squad One!". Here is my code for the 3 def's that have something to do with the while function.

Re: [Tutor] True to False and Other things!

2013-06-27 Thread Dave Angel
On 06/27/2013 09:27 AM, Jack Little wrote: In my game, I am trying to make it so when the enemy's health equals 0, the player advances. I used a while statement and a true or false variable. When the enemy health is less than or equal to 0, the program exits the while statement. It does not wo

Re: [Tutor] Need help appending data to a logfile

2013-06-27 Thread Dave Angel
On 06/27/2013 10:55 AM, Matt D wrote: On 06/27/2013 10:36 AM, Matt D wrote: You asked about a "save-as" feature. Why isn't that as simple as copying the current contents of the saved csv file? Or do you not know how you would go about copying? Hi. So I have the logger working, meaning t

Re: [Tutor] Need help appending data to a logfile

2013-06-27 Thread Dave Angel
On 06/27/2013 12:33 PM, Matt D wrote: I forgot to mention i have the 'with open(mypath, "a") as f: commented out because it was making an indentation error that i could not fix. It was indented, and should not have been. The extra indentation FOLLOWS the with statement, it's not correc

Re: [Tutor] Need help appending data to a logfile

2013-06-27 Thread Dave Angel
On 06/27/2013 05:09 PM, Matt D wrote: On 06/27/2013 12:54 PM, Dave Angel wrote: On 06/27/2013 12:33 PM, Matt D wrote: I forgot to mention i have the 'with open(mypath, "a") as f: commented out because it was making an indentation error that i could not fix. It wa

Re: [Tutor] unwanted 'zero' ending

2013-06-27 Thread Dave Angel
On 06/27/2013 07:39 PM, Jim Mooney wrote: On 27 June 2013 05:38, Steven D'Aprano wrote: Unit tests are great, but the learning curve is rather steep. I recommend that you start with doctests. I tried a simple one and it worked, but a puzzlement. Does it Only test what you've hard-coded? P

Re: [Tutor] unwanted 'zero' ending

2013-06-27 Thread Dave Angel
On 06/27/2013 09:32 PM, Jim Mooney wrote: On 27 June 2013 17:05, Dave Angel Nope. it is limited to the tests you write. And those tests are necessarily fairly simple. Hmm, so it seems a lot of trouble for a few hardcoded tests I could run myself from the IDE interpreter window. NO

Re: [Tutor] Need help appending data to a logfile

2013-06-28 Thread Dave Angel
On 06/28/2013 07:27 AM, Matt D wrote: As for the shutil.copy() function, how complex can it be? It takes two file names, source and destination. It does not need a with statement since it wants strings, not file handles. You might get into trouble on some OS's with the source file already o

Re: [Tutor] multiple function returns

2013-06-28 Thread Dave Angel
On 06/28/2013 12:06 PM, Jim Mooney wrote: def foo(x): ... if x: ... return True ... return False I'll leave it to you to work out why that works. It's very handy! Hey, it saves typing an "else" and as you know, I'm the Lazy Typist. My program to make dicts, lists, etc from a

Re: [Tutor] Need help appending data to a logfile

2013-06-28 Thread Dave Angel
On 06/28/2013 08:04 PM, Alan Gauld wrote: On 28/06/13 22:25, Matt D wrote: Python UI. I have a thread that waits on new data and when it comes in it gets displayed in TextCtrl fields. every time this happens my logger puts those values into a text file one row at a time. this how i open and

Re: [Tutor] Robot Radio in a linux Raspberry Pi

2013-06-29 Thread Dave Angel
On 06/29/2013 12:32 AM, Kirk Bailey wrote: ok, some months back I wrote about the program I wrote to perform the office of being a robot radio station in my windows desktop PC. well, I got it done and posted the program FOR WINDOWS on this list, and shut up. Then I got interested in the Raspberr

Re: [Tutor] Need help appending data to a logfile

2013-06-29 Thread Dave Angel
On 06/29/2013 08:26 AM, Matt D wrote: Matt probably read somewhere about an interface like tempfile.TemporaryFile where the file has no explicit name, and will be deleted from disk, and the space reused as soon as it is closed. I don't believe he's using such an interface, however. Yes

Re: [Tutor] Self and class functions

2013-06-29 Thread Dave Angel
On 06/29/2013 06:36 PM, Phil wrote: Thank you for reading this. You should be telling us some things. I'll guess for you: You're using Python 3.3 with Qt for a gui, and Linux 12.04 for an OS. I'm attempting to access the GUI widgets. The buttonClicked slot does what I want but I'd like to

Re: [Tutor] Need help appending data to a logfile

2013-06-29 Thread Dave Angel
On 06/29/2013 09:38 PM, Steven D'Aprano wrote: I haven't read this entire thread, but the bits I have read lead me to think that Matt has tangled himself up in a total confused mess. It's *not this hard* to write status messages to a log file, the log module does all the work. Can anyone w

Re: [Tutor] Self and class functions

2013-06-29 Thread Dave Angel
On 06/30/2013 12:10 AM, Phil wrote: On 30/06/13 11:41, Dave Angel wrote: Thank you Dave, Matthew and Steven for taking the time to reply. All hints are greatly appreciated. I'm attempting to access the GUI widgets. The buttonClicked slot does what I want but I'd like to access t

Re: [Tutor] Test Question

2013-07-01 Thread Dave Angel
On 07/01/2013 05:58 AM, John Steedman wrote: Good morning all, A question that I am unsure about. I THINK I have the basics, but I am not sure and remain curious. 1. What does this mean? if my_object in my_sequence: ... We can be sure what 'if' and 'in' mean, but not the other two items.

Re: [Tutor] How to remove from mailing list when server access blocked?

2013-07-01 Thread Dave Angel
On 07/01/2013 12:26 PM, jhame...@medford.k12.ma.us wrote: Hello, Can anyone tell me how to remove myself from this mailing list? When I click on unsubscribe my browser displays a message that I can not access the unsubscribe url or server because my IP is on a blacklist at Spamhaus. I am writing

Re: [Tutor] Boosts

2013-07-01 Thread Dave Angel
On 07/01/2013 04:41 PM, Jack Little wrote: In my concept, when the player buys a boost, their karma (a global) is multiplied by 25% when added to. How would I do this? Making a changeable global is almost certainly a mistake. But to multiply by 25%, you simply divide by 4. karma /= 4 --

Re: [Tutor] memory consumption

2013-07-03 Thread Dave Angel
On 07/03/2013 02:17 PM, Andre' Walker-Loud wrote: Hi All, I wrote some code that is running out of memory. And you know this how? What OS are you using, and specifically how is it telling you that you've run out of memory? And while you're at it, what version of Python? And are the OS and

Re: [Tutor] Cleaning up output

2013-07-03 Thread Dave Angel
On 07/03/2013 03:51 PM, bja...@jamesgang.dyndns.org wrote: I've written my first program to take a given directory and look in all directories below it for duplicate files (duplicate being defined as having the same MD5 hash, which I know isn't a perfect solution, but for what I'm doing is good e

Re: [Tutor] Saving Progress

2013-07-04 Thread Dave Angel
On 06/27/2013 11:16 AM, Jack Little wrote: Is there a way to save a players progress in a game using python without any modules Jack If you organize the game in such a way that a relatively few variables holds the state, then you can write those variables to a file, and when restarting the

Re: [Tutor] please return flys in ointment

2013-07-06 Thread Dave Angel
On 07/06/2013 05:38 PM, Jim Mooney wrote: I reworked my numbers_to_name program so I can actually follow the logic. Since I think the best way to learn is to follow something through to completion, I'll put it online so I learn how to do that. But naturally, lest I look dumb, I'd appreciate criti

Re: [Tutor] please return flys in ointment

2013-07-06 Thread Dave Angel
On 07/06/2013 06:34 PM, Dave Angel wrote: On 07/06/2013 05:38 PM, Jim Mooney wrote: I reworked my numbers_to_name program so I can actually follow the logic. Since I think the best way to learn is to follow something through to completion, I'll put it online so I learn how to do that

Re: [Tutor] please return flys in ointment

2013-07-06 Thread Dave Angel
On 07/06/2013 09:18 PM, Jim Mooney wrote: On 6 July 2013 18:01, ALAN GAULD wrote: If its structured use a parser for preference. (HTML, XML or pyparser etc for proprietary type stuff Ah, I see - don't bother with a parser unless you have a lot of structure. BTW, I extracted the main funct

Re: [Tutor] please return flys in ointment

2013-07-06 Thread Dave Angel
On 07/06/2013 10:40 PM, Jim Mooney wrote: On 6 July 2013 19:09, Dave Angel wrote: If you'd like, I'll post my full version, changed as little as possible from That would be helpful. The corrections are already four times the size of the program, and at least thr

Re: [Tutor] please return flys in ointment

2013-07-06 Thread Dave Angel
On 07/07/2013 01:30 AM, Dave Angel wrote: On 07/06/2013 10:40 PM, Jim Mooney wrote: On 6 July 2013 19:09, Dave Angel wrote: If you'd like, I'll post my full version, changed as little as possible from That would be helpful. The corrections are already four time

Re: [Tutor] please return flys in ointment

2013-07-07 Thread Dave Angel
On 07/07/2013 02:47 AM, Jim Mooney wrote: On 6 July 2013 22:52, Dave Angel wrote: The other author does not use hyphens or commas in the words. He ends each string with a blank. And he neglected to handle zero. He also is buggy beyond a nonillion-1. I found yet another implementation

Re: [Tutor] Combat Error

2013-07-07 Thread Dave Angel
On 07/07/2013 06:40 PM, Jack Little wrote: When the player of my game fire his/her cannon, it is supposed to get rid of some of the enemy's health. It does not. I have no clue what the error is, so I need help. Here is the Python Shell output: fire cannon 1 Fired! Enemy health= 75 They fired

Re: [Tutor] please return flys in ointment

2013-07-08 Thread Dave Angel
On 07/08/2013 01:57 PM, Jim Mooney wrote: On 8 July 2013 00:12, Steven D'Apranocatching ArithmeticError further on), please use a custom exception Well, an Arithmetic Error was better than bubbling up to a totally general one. I'm not sure how do custom error code. Short example, please ;')

Re: [Tutor] custom error classes: how many of them does one need?

2013-07-08 Thread Dave Angel
On 07/08/2013 04:51 PM, Albert-Jan Roskam wrote: haha, I hadn't even noticed the 'speling eror'. I was just thinking 'what the heck is a desert spoon'? ;-) "A dessert spoon is a spoon designed specifically for eating dessert and sometimes used for soup or cereals." On the other hand,

Re: [Tutor] converting string to text

2013-07-10 Thread Dave Angel
On 06/28/2013 07:08 PM, grub...@roadrunner.com wrote: I don't get why this doesn't work. Its a very small program to read in a group of numbers. I've attached the the python file and my test file. The test file just contains one line. The error I get is that it can't convert the string to a fl

Re: [Tutor] Difference between max(one, two) and max((one, two))

2013-07-10 Thread Dave Angel
On 07/05/2013 02:37 PM, Amandeep Behl wrote: and why with sum(one, two) we get an error whereas not with sum((one, two)) ? When replying to a message, your new text should go AFTER the quote. Putting it first is called top-posting, and it's a Microsoft-introduced abomination that's not compa

Re: [Tutor] Help Please

2013-07-10 Thread Dave Angel
On 07/05/2013 05:10 PM, Ashley Fowler wrote: This is what I have so far. Can anyone make suggestions or tell me what I need to correct? * * First thing to correct is the notion that you're due an instant answer. You get frustrated after 3 minutes, and post a new messa

Re: [Tutor] learning nested functions

2013-07-10 Thread Dave Angel
On 07/08/2013 02:26 AM, Tim Hanson wrote: In the first Lutz book, I am learning about nested functions. Here's the book's example demonstrating global scope: def f1(): x=88 def f2(): print(x) f2() f1() 88 But that's not global scope, it's

Re: [Tutor] What's going on in this Python code from Programming Collective Intelligence?

2013-07-10 Thread Dave Angel
On 07/06/2013 11:18 PM, bluepresley wrote: I'm reading the book Programming Collective Intelligence by Toby Segaran. I'm having a lot of difficulty understanding the some of the code from chapter four (the code for this chapter is available online at https://github.com/cataska/programming-collect

Re: [Tutor] New Python 3.3.2 Install Fails to Start-Up

2013-07-10 Thread Dave Angel
On 07/08/2013 01:43 AM, Nathan Schlaffer wrote: Dear Tutor, I have a Windows 7 Laptop. I installed Python Version 3.3.2 this morning and it worked fine. Then I tried to run a program someone else wrote (see below), and Python closed. What's that mean? HOW did you try to run the other program?

Re: [Tutor] Finding more efficient ways

2013-07-10 Thread Dave Angel
On 07/09/2013 04:04 PM, HRK wrote: Hello, I'm pretty new to Python so while I can make some basic stuff work, it doesn't look particularly pretty. I wanted to find better ways to solve the following two problems (the current code works, but is clunky.) Any tips or help appreciated. Thanks!

Re: [Tutor] syntax error when attempting simple urllib.request.urlopen item

2013-07-10 Thread Dave Angel
On 07/09/2013 04:00 PM, Paul Smith wrote: Tutor- Ok newbie to coding here attempting to build controlled web scraper and have followed several books-tutorials and am failing at step one. This is the 3.3.1 code I am trying to run.. === import urllib.request htmltext = urllib.request.urlopen("ht

Re: [Tutor] importing into a function

2013-07-10 Thread Dave Angel
On 07/10/2013 03:02 PM, Jim Mooney wrote: Boy, is the list busy. Python must have been mentioned on USA today, or something ;') Anyway, I was reading the datamodel, and it mentioned imported modules going out of scope, which seemed odd, since I thought they were global and never went out, or am

Re: [Tutor] Problems understanding code output

2013-07-10 Thread Dave Angel
On 07/10/2013 05:05 PM, s...@luo.to wrote: def printMax(a, b): if a > b: print(a, 'is maximum') elif a == b: print(a, 'is equal to', b) else: print(b, 'is maximum') printMax(3, 4) # directly give literal values x = 5 y = 7 printMax(x, y) # give variables as arg

Re: [Tutor] importing into a function

2013-07-10 Thread Dave Angel
On 07/10/2013 05:16 PM, eryksun wrote: On Wed, Jul 10, 2013 at 3:57 PM, Dave Angel wrote: Sure enough it did. The question is - does importing into a function ever make sense? It occurred to me that if you usefrom module import * , putting it in a function Can't be done. Locals

Re: [Tutor] multiple assignments when reading a file

2013-07-10 Thread Dave Angel
On 07/10/2013 11:24 PM, Sivaram Neelakantan wrote: I'm aware of var1, var2 = lines.split() kind of assignments How do I get to do x1..xn = lines.split() instead of typing out n var names? Is there some pythonic way to map all the data fields automagically given a starter var? I have data

Re: [Tutor] multiple assignments when reading a file

2013-07-11 Thread Dave Angel
On 07/11/2013 08:18 AM, Sivaram Neelakantan wrote: Thanks for the detailed explanation below. I've replied below. On Thu, Jul 11 2013,Dave Angel wrote: third choice? Put them in a list. Whaddya know, they already are. So just assign a name to that list. Referencing them is n

Re: [Tutor] passing values to a callback

2013-07-13 Thread Dave Angel
On 07/13/2013 01:48 PM, Alan Gauld wrote: On 13/07/13 16:08, Brett Wunderlich wrote: commanded by a Button. Once the button is pressed the values in the fields should result in a calculation - the values should all be numeric You'll need to convert between strings and numbers, the GUI display

Re: [Tutor] A slight bug in IDLE

2013-07-13 Thread Dave Angel
On 07/13/2013 02:29 PM, Jim Mooney wrote: Steven D'Aprano No, actually, it's the opposite of a gotcha. If a module expects to use truncated division, and *fails* to "from __future__ import division", that's what it needs to get. If your import would change what the other module sees, then you c

Re: [Tutor] A slight bug in IDLE

2013-07-13 Thread Dave Angel
On 07/13/2013 07:29 PM, Jim Mooney wrote: Dave Angel You still don't understand. If you write a module and I import it, then other imports BY ME don't affect your module. Whether it's a __future__ one or not. My import affects my global namespace, not yours. My compile-time

Re: [Tutor] A slight bug in IDLE

2013-07-13 Thread Dave Angel
On 07/13/2013 07:45 PM, Dave Angel wrote: On 07/13/2013 07:29 PM, Jim Mooney wrote: Dave Angel Where I got confused is I'm importing a module with a manual input, then renaming the input function to a generator function in my program , so I can bypass manual input and feed the m

Re: [Tutor] A slight bug in IDLE

2013-07-13 Thread Dave Angel
On 07/14/2013 12:37 AM, Jim Mooney wrote: On 13 July 2013 20:03, Steven D'Aprano wrote: I don't understand that last sentence. Ah, I can be marvelously unclear. I keep forgetting telepathy only works on my home planet ;') You still have done nothing to explain the "last sentence." You

Re: [Tutor] A slight bug in IDLE

2013-07-13 Thread Dave Angel
On 07/14/2013 01:02 AM, Jim Mooney wrote: On 13 July 2013 21:41, eryksun wrote: A lot of new packages support versions 2.6+, which have the "with" statement enabled. So, since I'm using 2.7 I don't need generators or with? Then all I'm using to be 3.3ish, would be: from __future__ import

Re: [Tutor] A slight bug in IDLE

2013-07-14 Thread Dave Angel
On 07/14/2013 04:27 AM, Jim Mooney wrote: On 13 July 2013 22:16, Dave Angel wrote: That's monkey-patching. You're reaching inside the module and modifying it. That's interesting. I saw that phrase and wondered what it was. Now I know ;') Actually, I did refactor the

Re: [Tutor] A slight bug in IDLE

2013-07-14 Thread Dave Angel
On 07/14/2013 03:28 PM, Jim Mooney wrote: On 13 July 2013 22:25, Dave Angel wrote: try: input = raw_input except NameError as e: pass try: range = xrange except NameError as e: pass == Couldn't I just shorten that to: if int(sys.version[0]) < 3:

Re: [Tutor] Deleted dictionary length not reporting

2013-07-16 Thread Dave Angel
On 07/16/2013 09:48 PM, Jim Mooney wrote: This is puzzling me. I have a folder with about 125 movie sound clips, like "I'll be back," blues brothers theme, oompa-loompas, etc. I play seven random ones on windows startup, which works fine. But just so I don't repeat a clip, I delete it from the di

Re: [Tutor] What all technologies should a python developer know?

2013-07-17 Thread Dave Angel
On 07/17/2013 08:00 AM, Tim Golden wrote: On 17/07/2013 12:13, Karan Goel wrote: So I want to be good at python (web) development. What all technologies do I need to know? Git. Linux. Django. webapp2. Heroku? What else? How proficient should I be in each? You don't *need* any of those specifi

Re: [Tutor] What all technologies should a python developer know?

2013-07-17 Thread Dave Angel
On 07/17/2013 11:09 AM, wolfrage8...@gmail.com wrote: On Wed, Jul 17, 2013 at 8:42 AM, Dave Angel wrote: I could continue, randomly attacking other aspects of a development environment. The point is that there are traps everywhere, and beautiful symmetries everywhere. Learn how to

Re: [Tutor] Problems understanding code output

2013-07-18 Thread Dave Angel
On 07/10/2013 05:05 PM, s...@luo.to wrote: This is going a little over my head, please advice, what am I missing in here? While you're watching, we could also point out that you posted a message in html format. There were actually two messages inside there, and many people will see the

Re: [Tutor] suggestions for splitting file based on date

2013-07-19 Thread Dave Angel
On 07/19/2013 04:00 PM, Peter Otten wrote: Sivaram Neelakantan wrote: I've got some stock indices data that I plan to plot using matplotlib. The data is simply date, idx_close_value and my plan is to plot the last 30 day, 90, 180 day & all time graphs of the indices. a) I can do the date compu

Re: [Tutor] suggestions for splitting file based on date

2013-07-20 Thread Dave Angel
On 07/20/2013 01:00 AM, Sivaram Neelakantan wrote: On Sat, Jul 20 2013,Dave Angel wrote: These are small,fixed line extracts. Once you determine the offset in the file for those 180, 90, and 30 day points, it's a simple matter to just seek to one such spot and process al

Re: [Tutor] 3 Dimensional Dictionaries

2013-07-20 Thread Dave Angel
On 07/20/2013 06:17 AM, Sunil Tech wrote: Hi Everyone, I have a list of dictionaries like world = [{'continent':'Asia','continent_code':1,'ocean':'Pacific','country':'India','country_code':1,'state':'Kerala', 'state_pin':51}, {'continent':'Asia','continent_code':1,'ocean':'Pacific','coun

Re: [Tutor] slashes in paths

2013-07-20 Thread Dave Angel
On 07/20/2013 08:24 PM, Steve Willoughby wrote: On 20-Jul-2013, at 16:37, Jim Mooney wrote: If only Bill Gates hadn't chosen '\', which is awkward to type and hard to make compatible - but I think he figured his wonderful DOS would be a Unix-killer, reign supreme, and there would be no compati

Re: [Tutor] close, but no cigar

2013-07-22 Thread Dave Angel
On 07/22/2013 02:27 PM, Jim Mooney wrote: Okay, I'm getting there, but this should be translating A umlaut to an old DOS box character, according to my ASCII table, but instead it's print small 'u': def main(): zark = '' for x in "ÀÄÄÄ": print(unichr(ord(u'x')-3), end=' ') re

Re: [Tutor] unichr not working as expected

2013-07-23 Thread Dave Angel
On 07/23/2013 02:10 AM, Jim Mooney wrote: On 22 July 2013 21:00, Steven D'Aprano wrote: (By the way, you're very naughty. The code you show *cannot possibly generate the error you claim it generates*. Bad Jim, no biscuit!) I know. I need a personal github. git is free, and is usually ins

Re: [Tutor] unichr not working as expected

2013-07-23 Thread Dave Angel
On 07/23/2013 10:28 AM, Steven D'Aprano wrote: On 24/07/13 00:14, Dave Angel wrote: On 07/23/2013 02:10 AM, Jim Mooney wrote: On 22 July 2013 21:00, Steven D'Aprano wrote: (By the way, you're very naughty. The code you show *cannot possibly generate the error you claim it

Re: [Tutor] 2d rotation gives unexpected results.

2013-07-23 Thread Dave Angel
On 07/23/2013 08:27 AM, enmce wrote: Hello! This is my first post, nice to meet you all! I`m biology student from Russia, trying to learn python to perform some simple simulations. Hello, and welcome. However, please don't post identical messages on tutor and python-list. The response you g

Re: [Tutor] unichr not working as expected

2013-07-23 Thread Dave Angel
On 07/23/2013 03:20 PM, Alan Gauld wrote: On 23/07/13 18:41, wolfrage8...@gmail.com wrote: Although I can not say for sure. It appears to me, they are trying to do a better job at merging from distributed branches Thanks for the memory jog. Yes i remember reading an interview with linus when

<    12   13   14   15   16   17   18   19   20   21   >