Re: [Tutor] weird lambda expression -- can someone help me understand how this works

2013-12-13 Thread Steven D'Aprano
On Sat, Dec 14, 2013 at 12:29:54PM +1000, Amit Saha wrote: > Consider this simple example: > > >>> l = lambda x: x**2 > >>> apply(l, (3,)) > 9 The built-in function apply is deprecated in Python 2 and removed in Python 3. Instead apply, you should use argument unpacking: l(*(3,)) In this case

Re: [Tutor] weird lambda expression -- can someone help me understand how this works

2013-12-13 Thread Steven D'Aprano
On Fri, Dec 13, 2013 at 09:14:12PM -0500, Michael Crawford wrote: > I found this piece of code on github > > https://gist.github.com/kljensen/5452382 > > def one_hot_dataframe(data, cols, replace=False): > """ Takes a dataframe and a list of columns that need to be encoded. > Returns

Re: [Tutor] list comprehension equivalent to map(function, list item)

2013-12-13 Thread Steven D'Aprano
On Fri, Dec 13, 2013 at 08:03:57PM -0500, Bo Morris wrote: > i have the following simple function that iterates over the list. Actually, no it doesn't. One important skill of being a programmer is precision of language. The function "add" you show below does not iterate over the list, it is th

Re: [Tutor] Thanks a bunch (was Re: Tutor Digest, Vol 118, Issue 64)

2013-12-13 Thread Steven D'Aprano
On Fri, Dec 13, 2013 at 02:24:15PM -0500, eryksun wrote: > On Fri, Dec 13, 2013 at 12:47 PM, Mark Lawrence > wrote: > > Did you really have to send an entire digest, without changing the title, > > just to send this one line? > > Gmail's composer top posts unless the text to quote is selected >

Re: [Tutor] weird lambda expression -- can someone help me understand how this works

2013-12-13 Thread Michael Crawford
It answered it. I had forgotten that you could pass functions around in python. Thanks, Mike On Dec 13, 2013, at 9:31 PM, Amit Saha wrote: > On Sat, Dec 14, 2013 at 12:29 PM, Amit Saha wrote: >> On Sat, Dec 14, 2013 at 12:14 PM, Michael Crawford wrote: >>> I found this piece of code on gith

Re: [Tutor] weird lambda expression -- can someone help me understand how this works

2013-12-13 Thread Amit Saha
On Sat, Dec 14, 2013 at 12:38 PM, Michael Crawford wrote: > Ah yes I see it. I forgot you can pass around functions in python. I would imagine, something in the apply() method, calling the 'mkdict' "function" with a value for the row parameter. -- http://echorand.me __

Re: [Tutor] weird lambda expression -- can someone help me understand how this works

2013-12-13 Thread Michael Crawford
Ah yes I see it. I forgot you can pass around functions in python. Thanks for the help, Mike On Dec 13, 2013, at 9:29 PM, Amit Saha wrote: > On Sat, Dec 14, 2013 at 12:14 PM, Michael Crawford wrote: >> I found this piece of code on github >> >> https://gist.github.com/kljensen/5452382 >>

Re: [Tutor] weird lambda expression -- can someone help me understand how this works

2013-12-13 Thread Amit Saha
On Sat, Dec 14, 2013 at 12:29 PM, Amit Saha wrote: > On Sat, Dec 14, 2013 at 12:14 PM, Michael Crawford wrote: >> I found this piece of code on github >> >> https://gist.github.com/kljensen/5452382 >> >> def one_hot_dataframe(data, cols, replace=False): >> """ Takes a dataframe and a list of

Re: [Tutor] weird lambda expression -- can someone help me understand how this works

2013-12-13 Thread Amit Saha
On Sat, Dec 14, 2013 at 12:14 PM, Michael Crawford wrote: > I found this piece of code on github > > https://gist.github.com/kljensen/5452382 > > def one_hot_dataframe(data, cols, replace=False): > """ Takes a dataframe and a list of columns that need to be encoded. > Returns a 3-tuple

Re: [Tutor] list comprehension equivalent to map(function, list item)

2013-12-13 Thread Amit Saha
On Sat, Dec 14, 2013 at 11:03 AM, Bo Morris wrote: > i have the following simple function that iterates over the list. It passes > the list item into the function and adds the numbers. What would be the > equivalent way of writing the "map" portion with list comprehension? My code > is as follows:

Re: [Tutor] list comprehension equivalent to map(function, list item)

2013-12-13 Thread Mark Lawrence
On 14/12/2013 01:03, Bo Morris wrote: i have the following simple function that iterates over the list. It passes the list item into the function and adds the numbers. What would be the equivalent way of writing the "map" portion with list comprehension? My code is as follows: def add(number):

[Tutor] weird lambda expression -- can someone help me understand how this works

2013-12-13 Thread Michael Crawford
I found this piece of code on github https://gist.github.com/kljensen/5452382 def one_hot_dataframe(data, cols, replace=False): """ Takes a dataframe and a list of columns that need to be encoded. Returns a 3-tuple comprising the data, the vectorized data, and the fitted vecto

[Tutor] list comprehension equivalent to map(function, list item)

2013-12-13 Thread Bo Morris
i have the following simple function that iterates over the list. It passes the list item into the function and adds the numbers. What would be the equivalent way of writing the "map" portion with list comprehension? My code is as follows: def add(number): print 1 + int(number) x = ['2', '4

Re: [Tutor] 'slice', etc

2013-12-13 Thread Mark Lawrence
On 07/12/2013 10:41, spir wrote: On 12/07/2013 02:45 AM, Mark Lawrence wrote: The good news is there is a memoryview in Python, see http://docs.python.org/3/library/functions.html#func-memoryview. The bad news is it doesn't work on strings. See here for the slice object http://docs.python.org/3

Re: [Tutor] Coding for a Secret Message in a Game

2013-12-13 Thread Danny Yoo
Whoops, made a small typo in the program I sent. Let me rewrite again: ### def GetFailureMessage(failure_count): """Returns a message given how many times we've seen failure.""" if failure_count <= 1: return "Try again"

Re: [Tutor] Thanks a bunch (was Re: Tutor Digest, Vol 118, Issue 64)

2013-12-13 Thread eryksun
On Fri, Dec 13, 2013 at 12:47 PM, Mark Lawrence wrote: > Did you really have to send an entire digest, without changing the title, > just to send this one line? Gmail's composer top posts unless the text to quote is selected beforehand. The user has to click on '...' to see the quoted text. Chang

Re: [Tutor] Coding for a Secret Message in a Game

2013-12-13 Thread Danny Yoo
As you've just started Python, you may not know about functions yet, but the question you're asking sounds very much like one that a function will help with. You can design functions that do a specific job: in this case, it sounds like you're asking for a function that takes the number of failures

[Tutor] Thanks a bunch (was Re: Tutor Digest, Vol 118, Issue 64)

2013-12-13 Thread Mark Lawrence
On 13/12/2013 17:40, Rishi Ganesh V wrote: Really your page is useful for me... Did you really have to send an entire digest, without changing the title, just to send this one line? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language.

Re: [Tutor] Tutor Digest, Vol 118, Issue 64

2013-12-13 Thread Rishi Ganesh V
sent the logic of game events (when this and that, then thut) > * represent the logic of game progress (they've reached this point of the > objective) > ? > > Thanks for sharing your excitement! If you go on your RPG (and even if > not), > this mailing list is here for help. You

Re: [Tutor] Using python's smtp server

2013-12-13 Thread Vincent Davis
Mark, Thanks mark, It had been about 15hr since I posted to python-list@python.organd had not seen a response so I thought I would try tutor.python.org. Well I got a response now, not that it helped, but I respond on that list. Thanks again. Vincent Davis 720-301-3003 On Fri, Dec 13, 2013 at 10:

Re: [Tutor] Using python's smtp server

2013-12-13 Thread Mark Lawrence
On 13/12/2013 16:48, Vincent Davis wrote: I have an app that generates a file one a day and would like to email it using python's SMTP server. http://docs.python.org/2/library/smtpd.html#smtpd.SMTPServer The documentation is kinda sparse and I cant seem to find any good examples. Basically what

[Tutor] Using python's smtp server

2013-12-13 Thread Vincent Davis
I have an app that generates a file one a day and would like to email it using python's SMTP server. http://docs.python.org/2/library/smtpd.html#smtpd.SMTPServer The documentation is kinda sparse and I cant seem to find any good examples. Basically what I want to do; when my app runs it would init

Re: [Tutor] Coding for a Secret Message in a Game

2013-12-13 Thread spir
On 12/13/2013 05:10 AM, Sky blaze wrote: Hi, I'm a newbie Python programmer. I was introduced to Python via the Hour of Code, and after completing all three of Grok Learning's tutorials, I was inspired to create a text-based RPG adventure. I composed this e-mail after searching for a forum for Py

Re: [Tutor] Coding for a Secret Message in a Game

2013-12-13 Thread Steven D'Aprano
On Thu, Dec 12, 2013 at 11:10:31PM -0500, Sky blaze wrote: > Here's the code I currently have so far: > print("===INSTRUCTIONS===") > input(">> ") Are you using Python 3? Is so, that's fine, but in Python 2 you should use raw_input instead. > print("When you see a \'>>\', hit Enter to advance t

Re: [Tutor] Coding for a Secret Message in a Game

2013-12-13 Thread Chris “Kwpolska” Warrick
On Fri, Dec 13, 2013 at 5:10 AM, Sky blaze wrote: > Hi, I'm a newbie Python programmer. I was introduced to Python via the Hour > of Code, and after completing all three of Grok Learning's tutorials, I was > inspired to create a text-based RPG adventure. I composed this e-mail after > searching fo

[Tutor] Coding for a Secret Message in a Game

2013-12-13 Thread Sky blaze
Hi, I'm a newbie Python programmer. I was introduced to Python via the Hour of Code, and after completing all three of Grok Learning's tutorials, I was inspired to create a text-based RPG adventure. I composed this e-mail after searching for a forum for Python, and this address showed up in one of