On 2015-10-14 11:29, Danny Yoo wrote:
##
def make_ask(f, l, p):
d = {'Enter your first name: ' : f,
'Enter your last name: ' : l,
'Your mobile phone #: ' : p}
return d.get
##
This is an example of a 'closure' is it not?
Y
Alex Kleider wrote:
> On 2015-10-14 12:27, Peter Otten wrote:
>> Alex Kleider wrote:
>>
>>> On 2015-10-13 14:44, Alex Kleider wrote:
On 2015-10-13 12:11, Danny Yoo wrote:
> ##
> def make_ask(f, l, p):
> d = {'Enter your first name: ' : f,
>
On 2015-10-14 12:27, Peter Otten wrote:
Alex Kleider wrote:
On 2015-10-13 14:44, Alex Kleider wrote:
On 2015-10-13 12:11, Danny Yoo wrote:
##
def make_ask(f, l, p):
d = {'Enter your first name: ' : f,
'Enter your last name: ' : l,
'Your mobile p
Alex Kleider wrote:
> On 2015-10-13 14:44, Alex Kleider wrote:
>> On 2015-10-13 12:11, Danny Yoo wrote:
>>
>>
>>> ##
>>> def make_ask(f, l, p):
>>> d = {'Enter your first name: ' : f,
>>>'Enter your last name: ' : l,
>>>'Your mobile phone #: ' : p}
On 2015-10-14 11:29, Danny Yoo wrote:
##
def make_ask(f, l, p):
d = {'Enter your first name: ' : f,
'Enter your last name: ' : l,
'Your mobile phone #: ' : p}
return d.get
##
This is an example of a 'closure' is it not?
Y
>>> ##
>>> def make_ask(f, l, p):
>>> d = {'Enter your first name: ' : f,
>>>'Enter your last name: ' : l,
>>>'Your mobile phone #: ' : p}
>>> return d.get
>>> ##
>
>
> This is an example of a 'closure' is it not?
Yes, though
On 2015-10-13 14:44, Alex Kleider wrote:
On 2015-10-13 12:11, Danny Yoo wrote:
##
def make_ask(f, l, p):
d = {'Enter your first name: ' : f,
'Enter your last name: ' : l,
'Your mobile phone #: ' : p}
return d.get
##
This i
On Tue, Oct 13, 2015 at 2:44 PM, Alex Kleider wrote:
> On 2015-10-13 12:11, Danny Yoo wrote:
>
>
>> ##
>> def make_ask(f, l, p):
>> d = {'Enter your first name: ' : f,
>>'Enter your last name: ' : l,
>>'Your mobile phone #: ' : p}
>> return d.get
On 2015-10-13 12:11, Danny Yoo wrote:
##
def make_ask(f, l, p):
d = {'Enter your first name: ' : f,
'Enter your last name: ' : l,
'Your mobile phone #: ' : p}
return d.get
##
This last line got my attention ("a dict has no
On Sat, Oct 10, 2015 at 5:41 PM, Alex Kleider wrote:
> """
> I'm trying to follow a test driven development paradigm (using
> unittest) but can't figure out how to test functions that collect
> info from the command line such as the following.
> """
> # collect.py
> def collect_data():
> ret =
On Mon, Oct 12, 2015 at 10:37:51AM -0700, Alex Kleider wrote:
> Any comments about when/if to use 'if src != None:' vs 'if src is not
> None:'?
> (or 'if src == None:' vs 'if src is None:')
Short answer: always compare to None using `is` or `is not`.
Long answer:
If you want to check for src b
Alex Kleider writes:
> Any comments about when/if to use 'if src != None:' vs 'if src is not
> None:'?
Express your intention in the code.
If you want to express “is this value the ‘None’ singleton?”, compare
identity with ‘is’/‘is not’. (This is what you almost always mean when
comparing to ‘N
On 2015-10-11 14:52, Cameron Simpson wrote:
Minor remark: I would write "if src is not None:". In principle the
empty string is also "falsey" like None, making your plain "if src:"
slightly unreliable. Be precise!
'precise' is good!
Any comments about when/if to use 'if src != None:' vs 'if s
On 11Oct2015 09:29, Alex Kleider wrote:
On 2015-10-10 18:10, Cameron Simpson wrote:
However, you'r eusing input(), which unconditionally uses stdin and
stdout. In that circumstance I'd consider this:
[... temporarily replace stdin and stdout with test data ...]
Yes indeed, and thank you f
Alex Kleider wrote:
> It'll take more studying on my part before I'll be able to implement
> Ben's suggestion.
I find Ben's example instructive, but when you're just starting you might
prefer a simpler approach:
import unittest
from unittest import mock
import collect
class TestCollectData(u
On 2015-10-10 18:10, Cameron Simpson wrote:
On 10Oct2015 17:41, Alex Kleider wrote:
I'm tOn 2015-10-10 18:10, Cameron Simpson wrote:
On 10Oct2015 17:41, Alex Kleider wrote:
I'm trying to follow a test driven development paradigm (using
unittest) but can't figu
On 10Oct2015 17:41, Alex Kleider wrote:
I'm trying to follow a test driven development paradigm (using
unittest) but can't figure out how to test functions that collect
info from the command line such as the following.
Aside: I'd say "the standard input" , not "the command line"; to me the lat
Alex Kleider writes:
> """
> I'm trying to follow a test driven development paradigm (using
> unittest) but can't figure out how to test functions that collect
> info from the command line such as the following.
> """
> # collect.py
> def collect_data():
> ret = {}
> ret['first'] = input(
"""
I'm trying to follow a test driven development paradigm (using
unittest) but can't figure out how to test functions that collect
info from the command line such as the following.
"""
# collect.py
def collect_data():
ret = {}
ret['first'] = input("Enter your first name: ")
ret['last
19 matches
Mail list logo