Python function that takes one compulsory argument from two choices
<p>I have a function:</p>

<pre><code>def delete(title=None, pageid=None):
    # Deletes the page given, either by its title or ID
    ...
    pass
</code></pre>

<p>However, my intention is for the function to take only one argument (either <code>title</code> OR <code>pageid</code>). For example, <code>delete(title="MyPage")</code> or <code>delete(pageid=53342)</code> are valid, while <code>delete(title="MyPage", pageid=53342)</code>, is not. Zero arguments can not be passed. How would I go about doing this?</p>

<p>There is no Python syntax that'll let you define exclusive-or arguments, no. You'd have to explicitly raise an exception is both or none are specified:</p>

<pre><code>if (title and pageid) or not (title or pageid):
    raise ValueError('Can only delete by title OR pageid')
</code></pre>

python function arguments