Re: [Tutor] Tutor Digest, Vol 102, Issue 98

2012-08-30 Thread Dwight Hutto
I think the OP is about to get the point, that there are usually several workarounds that people have found on their way to designing a function, or using built-ins(not that we don't use built-ins to create those workarounds). But you have to always remember to reference the docs, google. the help

Re: [Tutor] Lambda?? Whaaaaat?

2012-08-30 Thread Steven D'Aprano
On 31/08/12 13:39, Scurvy Scott wrote: I'm fairly new to python having recently completed LPTHW. While randomly reading stack overflow I've run into "lambda" but haven't seen an explanation of what that is, how it works, etc. Would anyone care to point me in the right direction? Lambda is just

Re: [Tutor] Tutor Digest, Vol 102, Issue 98

2012-08-30 Thread William R. Wing (Bill Wing)
> On Aug 30, 2012, at 8:15 PM, tutor-requ...@python.org wrote: > >> Message: 6 >> Date: Fri, 31 Aug 2012 00:15:41 + >> From: Ashley Fowler >> To: "tutor@python.org" >> Subject: [Tutor] Printing a list as a column >> Message-ID: >> >> <6962c976ae76ac4298cbf6fd6d0c63561f37c...@bl2prd071

Re: [Tutor] Lambda?? Whaaaaat?

2012-08-30 Thread Dave Angel
On 08/30/2012 11:39 PM, Scurvy Scott wrote: > I'm fairly new to python having recently completed LPTHW. While randomly > reading stack overflow I've run into "lambda" but haven't seen an explanation > of what that is, how it works, etc. > Would anyone care to point me in the right direction? lam

Re: [Tutor] Lambda?? Whaaaaat?

2012-08-30 Thread Dwight Hutto
Hey Scott, Always refer to google and the python docs first. from http://docs.python.org/tutorial/controlflow.html#lambda-forms 4.7.5. Lambda Forms By popular demand, a few features commonly found in functional programming languages like Lisp have been added to Python. With the lambda

[Tutor] Lambda?? Whaaaaat?

2012-08-30 Thread Scurvy Scott
I'm fairly new to python having recently completed LPTHW. While randomly reading stack overflow I've run into "lambda" but haven't seen an explanation of what that is, how it works, etc. Would anyone care to point me in the right direction? Thanks in advance Scott __

Re: [Tutor] Scheme

2012-08-30 Thread Ashley Fowler
yes From: tutor-bounces+afowler2=broncos.uncfsu@python.org [tutor-bounces+afowler2=broncos.uncfsu@python.org] on behalf of Mark Lawrence [breamore...@yahoo.co.uk] Sent: Friday, August 31, 2012 1:32 AM To: tutor@python.org Subject: Re: [Tutor] Schem

Re: [Tutor] Scheme

2012-08-30 Thread Mark Lawrence
On 31/08/2012 00:32, Ashley Fowler wrote: This is a problem using the Scheme programming...Can anybody help me with this problem? 2. Write a procedure (sphere r) that takes the radius of a sphere as the value of its input parameter and returns the volume of that sphere given by the formula: (4

Re: [Tutor] Scheme

2012-08-30 Thread Ashley Fowler
Understood. Disregard this problem. From: tutor-bounces+afowler2=broncos.uncfsu@python.org [tutor-bounces+afowler2=broncos.uncfsu@python.org] on behalf of Kal Sze [swordan...@gmail.com] Sent: Friday, August 31, 2012 1:32 AM To: tutor@python.org Subject: Re

Re: [Tutor] Scheme

2012-08-30 Thread Kal Sze
And this looks like a homework problem, too. It is against etiquette to just ask for the solution to homework on ANY forum, message board, or mailing list. Since it's been given to you as homework, you're supposed to give it enough thoughts, and (hopefully) come up with your solution. Even when y

Re: [Tutor] Why begin a function name with an underscore

2012-08-30 Thread Steven D'Aprano
On 31/08/12 06:57, eryksun wrote: On Thu, Aug 30, 2012 at 2:07 PM, Peter Otten<__pete...@web.de> wrote: Allowing floats for a primality test is a can of worms anyway. You will inevitably run out of significant digits: Allowing floats can also lead to type errors for operations that require a

Re: [Tutor] Printing list in a Column

2012-08-30 Thread Mark Lawrence
On 31/08/2012 02:12, Ashley Fowler wrote: Can anyone help me edit this code below to return the list in the form of a column instead of a row? def printList(): list1 = input("Insert a list") list = [list1] print (list) ___ Tutor

Re: [Tutor] Scheme

2012-08-30 Thread Steven D'Aprano
On 31/08/12 09:32, Ashley Fowler wrote: This is a problem using the Scheme programming...Can anybody help me with this problem? Probably, but not likely to be anyone here. Have you considered asking on a Lisp or Scheme mailing list or discussion forum? -- Steven

[Tutor] Scheme

2012-08-30 Thread Ashley Fowler
This is a problem using the Scheme programming...Can anybody help me with this problem? 2. Write a procedure (sphere r) that takes the radius of a sphere as the value of its input parameter and returns the volume of that sphere given by the formula: (4/3)π(r^3). Use (require scheme/math) or (req

[Tutor] Printing list in a Column

2012-08-30 Thread Ashley Fowler
Can anyone help me edit this code below to return the list in the form of a column instead of a row? def printList(): list1 = input("Insert a list") list = [list1] print (list) ___ Tutor maillist - Tutor@python.org To unsubscribe or ch

Re: [Tutor] Printing a list as a column

2012-08-30 Thread Mark Lawrence
On 31/08/2012 01:15, Ashley Fowler wrote: Does anyone know how to print a list in a form of a column instead of a row? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tuto

Re: [Tutor] Tutor Digest, Vol 102, Issue 98

2012-08-30 Thread Don Jennings
On Aug 30, 2012, at 8:15 PM, tutor-requ...@python.org wrote: > Message: 6 > Date: Fri, 31 Aug 2012 00:15:41 + > From: Ashley Fowler > To: "tutor@python.org" > Subject: [Tutor] Printing a list as a column > Message-ID: > > <6962c976ae76ac4298cbf6fd6d0c63561f37c...@bl2prd0710mb363.namp

[Tutor] Printing a list as a column

2012-08-30 Thread Ashley Fowler
Does anyone know how to print a list in a form of a column instead of a row? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] using multiprocessing efficiently to process large data file

2012-08-30 Thread Alan Gauld
On 30/08/12 23:19, Abhishek Pratap wrote: I am wondering how can I go about reading data from this at a faster pace and then farm out the jobs to worker function using multiprocessing module. I can think of two ways. 1. split the split and read it in parallel(dint work well for me ) primarily

Re: [Tutor] using multiprocessing efficiently to process large data file

2012-08-30 Thread Prasad, Ramit
> I have a with few million lines. I want to process each block of 8 > lines and from my estimate my job is not IO bound. In other words it > takes a lot more time to do the computation than it would take for > simply reading the file. > > I am wondering how can I go about reading data from this a

[Tutor] using multiprocessing efficiently to process large data file

2012-08-30 Thread Abhishek Pratap
Hi Guys I have a with few million lines. I want to process each block of 8 lines and from my estimate my job is not IO bound. In other words it takes a lot more time to do the computation than it would take for simply reading the file. I am wondering how can I go about reading data from this at a

Re: [Tutor] Why begin a function name with an underscore

2012-08-30 Thread eryksun
On Thu, Aug 30, 2012 at 2:07 PM, Peter Otten <__pete...@web.de> wrote: > > Allowing floats for a primality test is a can of worms anyway. You will > inevitably run out of significant digits: Allowing floats can also lead to type errors for operations that require an integral type, but at least the

Re: [Tutor] Why begin a function name with an underscore

2012-08-30 Thread Steven D'Aprano
On 31/08/12 04:07, Peter Otten wrote: Allowing floats for a primality test is a can of worms anyway. You will inevitably run out of significant digits: [snip] Yes, I had more or less come to the same conclusion earlier. The problem is that although sufficiently large floats are all integer-va

Re: [Tutor] Why begin a function name with an underscore

2012-08-30 Thread Peter Otten
Steven D'Aprano wrote: > On 28/08/12 19:02, Peter Otten wrote: >> Personally, I'm a big fan of ducktyping, so I would probably remove the >> check completely and live with the consequences: >> > >>> pyprimes._validate_int = lambda x: None > >>> pyprimes.isprime_naive(8.5) >> True >> >> g

Re: [Tutor] understanding pydoc try

2012-08-30 Thread Alan Gauld
On 30/08/12 17:21, John Maclean wrote: My main issue is that I am a sysadmin and not a programmer. I am aware of pydoc but not of BNF. So I was a bit taken aback when I saw the BNF syntax. It was obvious to me that syntax of the try statements were not python syntax but had no clue how to parse

Re: [Tutor] understanding pydoc try

2012-08-30 Thread John Maclean
On 08/30/2012 05:15 PM, Alan Gauld wrote: On 30/08/12 15:43, John Maclean wrote: Thanks. This is a heck of a lot more clearer to me! BNF, huh? Another set TLA that I don't need to know ;-) Actually, BNF is one of those useful skills for any programmer because almost every language is 'formal

Re: [Tutor] understanding pydoc try

2012-08-30 Thread Alan Gauld
On 30/08/12 15:43, John Maclean wrote: Thanks. This is a heck of a lot more clearer to me! BNF, huh? Another set TLA that I don't need to know ;-) Actually, BNF is one of those useful skills for any programmer because almost every language is 'formally' described using it - at least since th

Re: [Tutor] understanding pydoc try

2012-08-30 Thread Dave Angel
On 08/30/2012 11:26 AM, Steve Willoughby wrote: > On 30-Aug-12 08:22, Dave Angel wrote: >> On 08/30/2012 10:43 AM, John Maclean wrote: >>> On 08/30/2012 03:05 PM, Dave Angel wrote: >>> >>> Thanks. This is a heck of a lot more clearer to me! BNF, huh? Another >>> set TLA that I don't need

Re: [Tutor] understanding pydoc try

2012-08-30 Thread Steve Willoughby
On 30-Aug-12 08:22, Dave Angel wrote: On 08/30/2012 10:43 AM, John Maclean wrote: On 08/30/2012 03:05 PM, Dave Angel wrote: Thanks. This is a heck of a lot more clearer to me! BNF, huh? Another set TLA that I don't need to know ;-) I learned BNF in about 1972. I've used about 35 languag

Re: [Tutor] understanding pydoc try

2012-08-30 Thread Dave Angel
On 08/30/2012 10:43 AM, John Maclean wrote: > On 08/30/2012 03:05 PM, Dave Angel wrote: >> >> > > Thanks. This is a heck of a lot more clearer to me! BNF, huh? Another > set TLA that I don't need to know ;-) > I learned BNF in about 1972. I've used about 35 languages since (not counting hobby on

Re: [Tutor] understanding pydoc try

2012-08-30 Thread John Maclean
On 08/30/2012 03:05 PM, Dave Angel wrote: On 08/30/2012 09:30 AM, John Maclean wrote: What does the first line from `pydoc try` actually mean? This does not look like the syntax that one is supposed to use. try_stmt ::= try1_stmt | try2_stmt You're looking at the first of three BNF statement

Re: [Tutor] understanding pydoc try

2012-08-30 Thread Steven D'Aprano
On 30/08/12 23:30, John Maclean wrote: What does the first line from `pydoc try` actually mean? This does not look like the syntax that one is supposed to use. try_stmt ::= try1_stmt | try2_stmt That's a description of the Python grammar in some variation of Backus-Naur Form. In English, it

Re: [Tutor] understanding pydoc try

2012-08-30 Thread Dave Angel
On 08/30/2012 09:30 AM, John Maclean wrote: > What does the first line from `pydoc try` actually mean? This does not > look like the syntax that one is supposed to use. > > try_stmt ::= try1_stmt | try2_stmt > You're looking at the first of three BNF statements. BNF (Backus Naur Form, or somethin

Re: [Tutor] understanding pydoc try

2012-08-30 Thread Michael Janßen
On 30 August 2012 15:30, John Maclean wrote: > What does the first line from `pydoc try` actually mean? This does not > look like the syntax that one is supposed to use. > > try_stmt ::= try1_stmt | try2_stmt > looks like part of the python language reference. It goes a little further and expla

[Tutor] understanding pydoc try

2012-08-30 Thread John Maclean
What does the first line from `pydoc try` actually mean? This does not look like the syntax that one is supposed to use. try_stmt ::= try1_stmt | try2_stmt I can write simple statements as shown below, but I want to actually understand what I am doing. try: import io print("import

Re: [Tutor] Why begin a function name with an underscore

2012-08-30 Thread eryksun
On Thu, Aug 30, 2012 at 4:44 AM, Peter Otten <__pete...@web.de> wrote: > sum(["a", "b", "c"], "") > Traceback (most recent call last): > File "", line 1, in > TypeError: sum() can't sum strings [use ''.join(seq) instead] > > gives me the creeps even though it'd never occur to me to actually

Re: [Tutor] Why begin a function name with an underscore

2012-08-30 Thread Peter Otten
Steven D'Aprano wrote: > On 28/08/12 20:00, Peter Otten wrote: > [...] >> The differences to _validate_int() are subtle: >> > class S(str): >> ... def __eq__(self, other): return True >> ... def __ne__(self, other): return False >> ... def __add__(self, other): return self >> ... >