Using and Mastering Cookiecutter Transcripts
Chapter: Creating Cookiecutter templates
Lecture: Demo: Choice values

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Let's return to our attempt to making the user
0:03 enter something meaningful at a given step.
0:05 So we saw that blank values kind of indicate you should type something
0:08 but it doesn't really mean it, if you don't type it it's just empty
0:12 this required we will be able to use this at some point,
0:16 using the pre generation hook to check for that value
0:19 no, no, that's not actually a value, you should have typed in something.
0:22 But, if this is a bounded set, let's suppose that your favorite color,
0:26 you could only have like the basic colors, cyan, green, yellow, red and so on.
0:30 Well, if that's the case, we can make them pick one of them, like so,
0:35 we come over here and within quotes, we could put stuff
0:38 so let's say red, blue, green, yellow, cyan, white and black,
0:45 I don't know if that covers it, but that seems
0:48 like some of the basic console colors that we can use,
0:51 this is just a what is called a choice variable.
0:53 Now, those of you who know Python, this is actually a Python list, right here,
0:58 but really just a list in basic plain text here, of what the choices are.
1:05 Now if we run this, again, it's going to be a little bit different,
1:08 my project name will be with some choices, like this, creator,
1:15 now I have to enter something for now, I can test this later,
1:18 when we get to the hooks, look at this, boom, select a favorite color,
1:21 now there is still a default, it's still going to give me red if I just hit enter,
1:25 but I do love yellow, so let's go with yellow, now,
1:29 if we open up the with, let's see what we got.
1:32 Over here in colors, check that out, we have yellow right there,
1:36 alright, and that came from our choice variable
1:39 so here is a way to make the user sort of choose from a constraint set,
1:44 so it's in one sense a default value, and it's pretty good,
1:48 if you've got a bounded small set of things to pick from,
1:51 I totally recommend this, it's very user friendly,
1:54 but if you have an entirely open end of things like this that has to be answered,
1:58 like what is your name, well there is not really a list for that,
2:01 so we are going to have to check that in some other way.