Re: [Tutor] Should a beginner learn Python 3.x

2009-11-15 Thread wesley chun
>> Should I advise him to >> stick with 2.6 for a bit, since most of the material out  there will >> be for 2.x?  Or since he's learning from scratch, should he jump >> straight to 3.x  In which case what can you recommend for him to work >> through - I must stress he has absolutely no clue at all

[Tutor] I love python / you guys :)

2009-11-15 Thread Stefan Lesicnik
hi, Although not a question, i just want to tell you guys how awesome you are! I am not a programmer, i can do a bit of bash. I have never officially learnt programming, but numerous times looked at some perl, c, java and never really gotten past the beginning stages of it. That all changed when

Re: [Tutor] Writing code while tired, counterproductive?

2009-11-15 Thread OkaMthembo
>From first-hand experience, i would concur :) A refreshed mind will perform much better than an over-exerted one. On Sat, Nov 14, 2009 at 8:57 PM, Alan Gauld wrote: > > "Modulok" wrote > > Does anyone else find, writing code while tired to be counterproductive? >> > > Yes. Doing anything that

Re: [Tutor] Unexpected iterator

2009-11-15 Thread spir
Le Sun, 15 Nov 2009 19:23:33 -, "Alan Gauld" s'exprima ainsi: > What does 'unpack' mean? I've seen a few Python errors about packing > and unpacking. What does it mean? Unpacking is rarely needed. It matches some kind of problems. Imagine you parse "codes" each made of name-sep-number. T

Re: [Tutor] Iterable Understanding

2009-11-15 Thread Dave Angel
Marc Tompkins wrote: On Sun, Nov 15, 2009 at 4:11 PM, Stephen Nelson-Smith wrote: import gzip from heapq import heappush, heappop, merge Is this a preferred method, rather than just 'import heapq'? It has a couple of advantages: - convenience: if you "import heapq", then to

Re: [Tutor] Iterable Understanding

2009-11-15 Thread Kent Johnson
On Sun, Nov 15, 2009 at 8:57 PM, Marc Tompkins wrote: > On Sun, Nov 15, 2009 at 4:11 PM, Stephen Nelson-Smith > wrote: >> >> > import gzip >> > from heapq import heappush, heappop, merge >> >> Is this a preferred method, rather than just 'import heapq'? >> > It has a couple of advantages: ... > -

Re: [Tutor] Find Integer co-ordinates lying on a circle

2009-11-15 Thread Shashwat Anand
regarding Integer co-ordinates within a circle got a nice link : http://mathworld.wolfram.com/GausssCircleProblem.html ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Find Integer co-ordinates lying on a circle

2009-11-15 Thread Shashwat Anand
@DaveA: thanks for pointing it out. For a origin-centre circle x**2 + y**2 = r**2, I assumed r to be integer, however it was r**2 which was integer. A mistake on my part. On Mon, Nov 16, 2009 at 6:41 AM, Dave Angel wrote: > spir wrote: > >> Le Sun, 15 Nov 2009 09:11:16 +0530, >> Shashwat Anand

Re: [Tutor] getting python 3 to run from the command line (version2)

2009-11-15 Thread Mark Tolonen
Forgive the top-posting, but when in Rome... Running 'chcp' at the command line will show the default code page. Judging from the OP's name it is probably an Arabic version of Windows. Since Python 2.6 works it probably is falling back to something besides cp720. Try: import sys print

Re: [Tutor] Iterable Understanding

2009-11-15 Thread Marc Tompkins
On Sun, Nov 15, 2009 at 4:11 PM, Stephen Nelson-Smith wrote: > > import gzip > > from heapq import heappush, heappop, merge > > Is this a preferred method, rather than just 'import heapq'? > > It has a couple of advantages: - convenience: if you "import heapq", then to do a push you need to type

Re: [Tutor] Find Integer co-ordinates lying on a circle

2009-11-15 Thread Dave Angel
spir wrote: Le Sun, 15 Nov 2009 09:11:16 +0530, Shashwat Anand s'exprima ainsi: No, I'm trying to find all integer co-ordinates which lies on a circle. Say for a circle of radius 5 the co-ordinates are [(5, 0), (0, 5), (-5, 0), (0, -5), (3, 4), (4,3), (3, -4), (4, -3), (-3, 4), (-4

Re: [Tutor] Iterable Understanding

2009-11-15 Thread Stephen Nelson-Smith
Hi Marty, Thanks for a very lucid reply! > Well, you haven't described the unreliable behavior of unix sort so I > can only guess, but I assume you know about the --month-sort (-M) flag? Nope - but I can look it up. The problem I have is that the source logs are rotated at 0400 hrs, so I need t

Re: [Tutor] Unexpected iterator

2009-11-15 Thread Alan Gauld
"Stephen Nelson-Smith" wrote To upack your variables a and b you need an iterable object on the right side, which returns you exactly 2 variables What does 'unpack' mean? I've seen a few Python errors about packing and unpacking. What does it mean? It has a coup[le of uses, the one being

[Tutor] Fw: getting python 3 to run from the command line (version 2)

2009-11-15 Thread ALAN GAULD
Forwarding to the tutor list with cut n paste sessions. It looks to me like the code page issue somebody else referred to is the problem but the behaviour seems a bit extreme, I'd have thought it might have chosen a default value or something... But I'm not sure what causes it to select cp720

Re: [Tutor] Find Integer co-ordinates lying on a circle

2009-11-15 Thread spir
Le Sun, 15 Nov 2009 09:11:16 +0530, Shashwat Anand s'exprima ainsi: > > No, I'm trying to find all integer co-ordinates which lies on a circle. > Say for a circle of radius 5 the co-ordinates are [(5, 0), (0, 5), (-5, 0), > (0, -5), (3, 4), (4,3), (3, -4), (4, -3), (-3, > 4), (-4, 3), (-3, -4),

Re: [Tutor] Should a beginner learn Python 3.x

2009-11-15 Thread spir
Le Sat, 14 Nov 2009 20:49:52 +, Stephen Nelson-Smith s'exprima ainsi: > My brother in law is learning python. He's downloaded 3.1 for > Windows, and is having a play. It's already confused him that print > "hello world" gives a syntax error > > He's an absolute beginner with no program

Re: [Tutor] Should a beginner learn Python 3.x

2009-11-15 Thread wesley chun
>> i get asked this question a lot, esp. when it pertains to my book, >> "Core Python Programming." which should i learn? is your book >> obsolete? etc. i basically tell them that even though they are >> backwards-incompatible, it's not like Python 2 and 3 are so >> different that you wouldn't

Re: [Tutor] Iterable Understanding

2009-11-15 Thread Martin Walsh
Stephen Nelson-Smith wrote: >> It's unclear from your previous posts (to me at least) -- are the >> individual log files already sorted, in chronological order? > > Sorry if I didn't make this clear. No they're not. They are *nearly* > sorted - ie they're out by a few seconds, every so often, bu

Re: [Tutor] Unexpected iterator

2009-11-15 Thread Alan Plum
On So, 2009-11-15 at 15:12 +, Stephen Nelson-Smith wrote: > > To upack your variables a and b you need an iterable object on the right > > side, which returns you exactly 2 variables > > What does 'unpack' mean? I've seen a few Python errors about packing > and unpacking. What does it mean?

Re: [Tutor] Unexpected iterator

2009-11-15 Thread Stephen Nelson-Smith
> To upack your variables a and b you need an iterable object on the right > side, which returns you exactly 2 variables What does 'unpack' mean? I've seen a few Python errors about packing and unpacking. What does it mean? S. ___ Tutor maillist - T

Re: [Tutor] nul file in Windows

2009-11-15 Thread Dave Angel
Timo List wrote: For my program I disable the py2exe log feature by routing output to the nul-file. Code: if win32 and py2exe: sys.stdout = open("nul", "w") sys.stderr = open("nul", "w") This always worked fine. Today, I received an email from a user with the fo

Re: [Tutor] nul file in Windows

2009-11-15 Thread Wayne Werner
On Sun, Nov 15, 2009 at 6:39 AM, Timo List wrote: > For my program I disable the py2exe log feature by routing output to the > nul-file. > Code: > > if win32 and py2exe: > sys.stdout = open("nul", "w") > sys.stderr = open("nul", "w") > > This always worked fine. >

Re: [Tutor] parsing XML into a python dictionary

2009-11-15 Thread Stefan Behnel
Christopher Spears, 14.11.2009 19:47: > Thanks! I have a lot of XML files at work that users search through. I > want to parse the XML into a python dictionary and then read the dictionary > into a database that users can use to search through the thousands of files. I think "database" is the righ

Re: [Tutor] OT: Writing code while tired, counterproductive?

2009-11-15 Thread spir
Le Sat, 14 Nov 2009 10:43:47 -0700, Modulok s'exprima ainsi: > List, > > This is kind off topic, but: > > Does anyone else find, writing code while tired to be counterproductive? > > It just seems like when I push myself to stay up late finishing a > project, I sorely regret it the following d

[Tutor] nul file in Windows

2009-11-15 Thread Timo List
For my program I disable the py2exe log feature by routing output to the nul-file. Code: if win32 and py2exe: sys.stdout = open("nul", "w") sys.stderr = open("nul", "w") This always worked fine. Today, I received an email from a user with the following error: IOEr

Re: [Tutor] Iterable Understanding

2009-11-15 Thread Stephen Nelson-Smith
Hi Martin, Thanks for a very detailed response. I'm about to head out, so I can't put your ideas into practice yet, or get down to studying for a while. However, I had one thing I felt I should respond to. > It's unclear from your previous posts (to me at least) -- are the > individual log file

Re: [Tutor] Find Integer co-ordinates lying on a circle

2009-11-15 Thread Gerard Flanagan
Shashwat Anand wrote: > How to find all possible integer co-ordinates lying on a circle of given radius 'r'. > If given the upper bound of 'r', I want to calculate all given co-ordinates lying for 0 <= r <= n > > Let's say the upper bound of radius is 5 > All possible results are: > radius 'r'

Re: [Tutor] opening a file directly from memory

2009-11-15 Thread Dave Angel
mj...@iol.pt wrote: da...@ieee.org wrote: (You forgot to send this message to the list, so I'm forwarding it) mj...@iol.pt wrote: da...@ieee.org wrote: mj...@iol.pt wrote: I'm wondering if I must save a file to memory before opening it. By opening I mean displaying it to the user. I have

Re: [Tutor] Iterable Understanding

2009-11-15 Thread Martin Walsh
Stephen Nelson-Smith wrote: > I think I'm having a major understanding failure. Perhaps this will help ... http://www.learningpython.com/2009/02/23/iterators-iterables-and-generators-oh-my/ > So in essence this: > > logs = [ LogFile( "/home/stephen/qa/ded1353/quick_log.gz", "04/Nov/2009" ), >

Re: [Tutor] opening a file directly from memory

2009-11-15 Thread Alan Gauld
wrote You forgot to answer the question. You say "The OS knows how to open". Does *your* *program* know what program is needed, to open this particular binary data? Yes. My program knows. A database column stores the complete file name (including extension), and I can be certain the app