undefined variable while playing with dates and functions
<p>You could call me an extreme newbie, I have a course at school for which I need to be able, sort of, to solve problems using python. All so far have worked, but the last one (just a small part really) wont give in.</p>

<p>The first 4 functions work fine (2 arguments each, a birthday (bday) and a random date (today)). They determine whether or not the random date is a birthday/unbirthday/hundredday/sameweekday, returning True or False if so or not, respectively. First line of every function is the following, rest of the script doesn't matter much.</p>

<pre><code>def birthday(bday, today):

def unbirthday(bday, today):

def hundredday(bday, today):

def sameweekday(bday, today):
</code></pre>

<p>Again, these work fine. </p>

<p>The last function has to return all dates, between a certain start and end date, on which one of the above variations of birthdays match. First argument is again bday, the next is start (by default bday, this is the asshole), third is end (by default today) and the fourth is birthday (by default the actual birthday).</p>

<pre><code>def birthdays(bday, start=bday, end=date.today(), birthday=birthday):
</code></pre>

<p>its the start=bday that won't work, stating that this bday is undefined. Rest of the script doesn't matter as I don't get so far.</p>

<p>(I import datetime in the beginning of script and all first functions work fine using its tools)</p>

<p>One solution would be to default start=None, and then in the function body have:</p>

<pre><code>if start is None:
    start = bday
</code></pre>

<p>which should give you the behaviour you want.</p>

python function date