Re: [Tutor] Lambda?? Whaaaaat?

2012-08-31 Thread Alan Gauld
On 31/08/12 05:43, Steven D'Aprano wrote: Where does the name come from? Lambda is the Greek letter L, and for reasons I don't know, it is the traditional name used for functions in some of the more abstract areas of computer science. More specifically it is the name of a branch of mathematics

Re: [Tutor] Scheme

2012-08-31 Thread Alan Gauld
On 31/08/12 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/3)π

Re: [Tutor] Printing list in a Column

2012-08-31 Thread Alan Gauld
On 31/08/12 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) First you need to convert the string that your user types into

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

2012-08-31 Thread Mark Lawrence
On 31/08/2012 04:27, William R. Wing (Bill Wing) wrote: How about - for item in iter(list): ….print item Overengineering? :) A list is an iterator. -Bill ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http

[Tutor] checking input parameters

2012-08-31 Thread Bala subramanian
Friends, I use the following way to check for the input parameters. I would like to know if there is a any better way to show or describe the script usage. So when the user just runs it without any input params., the program shd not execute but just shows the documentation. from sys import argv if

Re: [Tutor] Scheme

2012-08-31 Thread Mark Lawrence
On 31/08/2012 08:55, Alan Gauld wrote: Now just translate that into Scheme :-) HTH Anyone know of an application to automate Python to Scheme translation? :) -- Cheers. Mark Lawrence. ___ Tutor maillist - Tutor@python.org To unsubscribe or cha

Re: [Tutor] Scheme

2012-08-31 Thread Kal Sze
That's left as an exercise to the reader. On Friday, August 31, 2012, Mark Lawrence wrote: > On 31/08/2012 08:55, Alan Gauld wrote: > >> >> Now just translate that into Scheme :-) >> >> HTH >> >> > Anyone know of an application to automate Python to Scheme translation? :) > > -- > Cheers. > > Mar

Re: [Tutor] checking input parameters

2012-08-31 Thread Peter Otten
Bala subramanian wrote: > I use the following way to check for the input parameters. I would > like to know if there is a any better way to show or describe the > script usage. So when the user just runs it without any input params., > the program shd not execute but just shows the documentation.

Re: [Tutor] Scheme

2012-08-31 Thread Mark Lawrence
On 31/08/2012 09:44, Kal Sze wrote: That's left as an exercise to the reader. On Friday, August 31, 2012, Mark Lawrence wrote: On 31/08/2012 08:55, Alan Gauld wrote: Now just translate that into Scheme :-) HTH Anyone know of an application to automate Python to Scheme translation? :) -

Re: [Tutor] Scheme

2012-08-31 Thread Steven D'Aprano
On 31/08/12 19:13, Mark Lawrence wrote: [...] Please don't top post. And Mark, please trim your replies. Bottom posting without trimming is just as annoying as top posting without trimming. (Among other things, your post ended up containing THREE copies of the mailing list footer.) -- Steve

Re: [Tutor] Scheme

2012-08-31 Thread Mark Lawrence
On 31/08/2012 12:51, Steven D'Aprano wrote: On 31/08/12 19:13, Mark Lawrence wrote: [...] Please don't top post. And Mark, please trim your replies. Bottom posting without trimming is just as annoying as top posting without trimming. (Among other things, your post ended up containing THREE co

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

2012-08-31 Thread Prasad, Ramit
Please always respond to the list. And avoid top posting. > -Original Message- > From: Abhishek Pratap [mailto:abhishek@gmail.com] > Sent: Thursday, August 30, 2012 5:47 PM > To: Prasad, Ramit > Subject: Re: [Tutor] using multiprocessing efficiently to process large data > file > > Hi

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

2012-08-31 Thread William R. Wing (Bill Wing)
On Aug 31, 2012, at 4:31 AM, Mark Lawrence wrote: > On 31/08/2012 04:27, William R. Wing (Bill Wing) wrote: >> >> How about - >> > for item in iter(list): > ….print item > > Overengineering? :) A list is an iterator. > Right you are - should have been: for item in list: print it

[Tutor] Problem caused by installing 2.7.3

2012-08-31 Thread Richard D. Moores
MS Windows 7 Home Premium 64-bit SP1 I've been using 3.x for a long time, but the other day I thought it would also be good to have the latest version of 2.x available. So I downloaded it and installed it. I have some useful (to me) scripts that I use frequently, that I call with Windows shortcut

[Tutor] Using a calling program to change Python script arguments

2012-08-31 Thread Ray Jones
As an aid to learning Python, I am currently in the process of converting my Bash scripts into Python scripts. Through the years, as I have accumulated a variety of sites, I have been maintaining a half dozen or so Bash scripts that basically do the same thing: log me into a streaming video site an

Re: [Tutor] Problem caused by installing 2.7.3

2012-08-31 Thread eryksun
On Fri, Aug 31, 2012 at 12:49 PM, Richard D. Moores wrote: > > MS Windows 7 Home Premium 64-bit SP1 > > I have some useful (to me) scripts that I use frequently, that I call > with Windows shortcut keys. They used to open in a nice cmd.exe window > I'd configured to my liking. Now I find that they

Re: [Tutor] Using a calling program to change Python script arguments

2012-08-31 Thread Alan Gauld
On 31/08/12 18:05, Ray Jones wrote: script and have it parse. Is there another method for one Python script to call/import/execute a Python script and integrate the name space so that the variables in each of the calling scripts would be directly usable by the Python module/child process/whateve

Re: [Tutor] Using a calling program to change Python script arguments

2012-08-31 Thread Ray Jones
On 08/31/2012 02:19 PM, Alan Gauld wrote: > On 31/08/12 18:05, Ray Jones wrote: > >> script and have it parse. Is there another method for one Python script >> to call/import/execute a Python script and integrate the name space so >> that the variables in each of the calling scripts would be direct

[Tutor] Power of Two Function

2012-08-31 Thread Lazar
Hello, I'm fairly new to Python and still learning. Can someone please explain to me in what way the following function checks if a number is a power of two? Basically, the second line of code is what I can't really grasp: def is_power2(num): return num != 0 and ((num & (num - 1)) == 0)

Re: [Tutor] Problem caused by installing 2.7.3

2012-08-31 Thread Richard D. Moores
On Fri, Aug 31, 2012 at 10:57 AM, eryksun wrote: > On Fri, Aug 31, 2012 at 12:49 PM, Richard D. Moores > wrote: > https://bitbucket.org/vinay.sajip/pylauncher > https://bitbucket.org/vinay.sajip/pylauncher/raw/tip/Doc/launcher.rst Thank you! You solved my problem. Dick __

Re: [Tutor] Power of Two Function

2012-08-31 Thread Visar Zejnullahu
2^n in binary is 10...0 (with n 0s), and 2^n - 1 is 11...1 (with n 1s). So if you do bitwise and (&) to 2^n and 2^n-1 you get all 0s. That's why you check if (num & (num - 1)) == 0. Visar Zejnullahu On Sat, Sep 1, 2012 at 12:54 AM, Lazar wrote: > Hello, > > I'm fairly new to Python and still l

Re: [Tutor] Power of Two Function

2012-08-31 Thread Visar Zejnullahu
http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2 You have many useful bit hacks here. Visar Zejnullahu On Sat, Sep 1, 2012 at 1:17 AM, Visar Zejnullahu wrote: > 2^n in binary is 10...0 (with n 0s), and 2^n - 1 is 11...1 (with n 1s). So > if you do bitwise and (&) to 2^n

Re: [Tutor] Power of Two Function

2012-08-31 Thread bob gailer
On 8/31/2012 6:54 PM, Lazar wrote: Hello, I'm fairly new to Python and still learning. Can someone please explain to me in what way the following function checks if a number is a power of two? Basically, the second line of code is what I can't really grasp: def is_power2(num): return n

Re: [Tutor] Power of Two Function

2012-08-31 Thread Lazar
Visar and Bob, Thank you for your detailed explanations, I appreciate your help. Kind regards, Lazar ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Problem caused by installing 2.7.3

2012-08-31 Thread Mark Lawrence
On 01/09/2012 00:16, Richard D. Moores wrote: On Fri, Aug 31, 2012 at 10:57 AM, eryksun wrote: On Fri, Aug 31, 2012 at 12:49 PM, Richard D. Moores wrote: https://bitbucket.org/vinay.sajip/pylauncher https://bitbucket.org/vinay.sajip/pylauncher/raw/tip/Doc/launcher.rst Thank you! You so

Re: [Tutor] Power of Two Function

2012-08-31 Thread Alan Gauld
On 31/08/12 23:54, Lazar wrote: Can someone please explain to me in what way the following function checks if a number is a power of two? Basically, the second line of code is what I can't really grasp: def is_power2(num): return num != 0 and ((num & (num - 1)) == 0) In binary any po

Re: [Tutor] Using a calling program to change Python script arguments

2012-08-31 Thread Alan Gauld
On 31/08/12 22:51, Ray Jones wrote: Okay. Now I must figure out how to create the module and have my calling script look in the right place ;) Creating a module is just a matter of creating a standard python file #! /bin/python# you don't even really

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

2012-08-31 Thread Steven D'Aprano
On 31/08/12 18:31, Mark Lawrence wrote: On 31/08/2012 04:27, William R. Wing (Bill Wing) wrote: How about - for item in iter(list): ….print item Overengineering? :) A list is an iterator. Technically, no it isn't, it is an "iterable" or a "sequence" but not an iterator. py> mylist = [1,

Re: [Tutor] Using a calling program to change Python script arguments

2012-08-31 Thread Ray Jones
On 08/31/2012 04:58 PM, Alan Gauld wrote: > > Creating a module is just a matter of creating a standard python file > > > #! /bin/python# you don't even really need a shebang for modules! > myVar = 66 > < end of myvar.py --> > > import myvar > print

[Tutor] List all possible 10digit number

2012-08-31 Thread Scurvy Scott
First of all thank you guys for all your help. The manual is really no substitute for having things explained in laymans terms as opposed to a technical manual. My question is this- I've been trying for a month to generate a list of all possible 10 digit numbers. I've googled, looked on stackov

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

2012-08-31 Thread eryksun
On Fri, Aug 31, 2012 at 8:20 PM, Steven D'Aprano wrote: > > Sequence > The generalisation of lists, tuples and strings. Any object that has > a known length where individual items can be retrieved with the > __getitem__ method called sequentially: obj[0], obj[1], obj[2], ... To expand on th

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dave Angel
On 08/31/2012 09:08 PM, Scurvy Scott wrote: > First of all thank you guys for all your help. The manual is really no > substitute for having things explained in laymans terms as opposed to a > technical manual. > > My question is this- I've been trying for a month to generate a list of all > pos

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread eryksun
On Fri, Aug 31, 2012 at 9:08 PM, Scurvy Scott wrote: > > My question is this- I've been trying for a month to generate a list of > all possible 10 digit numbers. I've googled, looked on stackoverflow, > experimented with itertools, In itertools, look at count() and islice(). An alternative to isl

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dave Angel
On 08/31/2012 10:14 PM, Scurvy Scott wrote: > Thanks for the reply. This isn't an assignment per se as I'm just learning > python for my own sake- not in classes or school or what have you. As I said > I'm pretty new to python picking up whatever I can and generators are > something that I haven

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dave Angel
On 08/31/2012 10:38 PM, Scurvy Scott wrote: > Now I've got > > A = 10 > I = raw_input("file name> ") > TheFile = open(I, 'w') > > TheFile.truncate > def allten(a): > while a < 99: > a = + 1 > TheFile.write(a) > allten(a) > > The result is: > Open file 'file.t

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dwight Hutto
Dear Scurvy, I don't know if this has been suggested yet, but I just broke the larger list of 10 digit nums into segments, and at the end of the loop, kept the previous last num in the segment as the beginning of the next range() that goes through the same amount of ints in each segmentation of

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread eryksun
On Sat, Sep 1, 2012 at 12:29 AM, Scurvy Scott wrote: > > The while loop works for simply printing. Now I'm trying to save to a file > > I = 10 > Boogers = raw_input("file") > Baseball = open(Boogers) As ASCII, that's 11 bytes per number times 9 billion numbers. That's approximately 92 GiB

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dwight Hutto
You can also watch this happen by uncommenting print on line 8: def iterToHighNum(increment,high_ num): end_point = 0 a = [i for i in range(0,increment)] while (end_point != high_num) == True: for integer in a: if integer != high_num: print "no matc

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dwight Hutto
I mean line 7. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dwight Hutto
It might be a little buggy, but I'm in a rush, so it has a flaw in it. But I think you get the point I'm trying to make. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dwight Hutto
Here's the better function fixed with a return statement I forgot, but might not be as quick as the pre-built functions already shown: def iterToHighNum(increment,high_num): end_point = 0 a = [i for i in range(0,increment)] while (end_point != high_num) == True: for integer in

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dave Angel
On 09/01/2012 01:46 AM, Dwight Hutto wrote: > Here's the better function fixed with a return statement I forgot, but > might not be as quick as the pre-built functions already shown: > > def iterToHighNum(increment,high_num): > end_point = 0 > a = [i for i in range(0,increment)] > while

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dwight Hutto
I could comment this better. We have a function, iterToHighNum, that takes two parameters: increment and high_num. increment is how long the list of numbers being added to the old increment list of ints, to create a shorter int list that maintains the sequential count, looking for the high number

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dwight Hutto
I'm not sure what the point of any of that is; you're making a simple > problem complex. If you're wanting to accomplish the task without using > any of the itertools stuff, why not just: > > > current = 10**9 > lim = 10**10 > while current < lim: > print current #or write to file, or wha