title: Python using sort with function gives TypeError: date_compare() missing 1 required positional argument: error
body: <p>I am completely new to Python so please excuse my lack of knowledge.  I am writing a script to create AWS EC2 snapshots and then delete any older snapshots specified in the script.  I took some code from other scripts which appear to have been written in an older Python version (I am using 3.3.2).  </p>
  
  <pre><code>#Built with Python 3.3.2
  import boto.ec2
  from boto.ec2.connection import EC2Connection
  from boto.ec2.regioninfo import RegionInfo
  from boto.ec2.snapshot import Snapshot
  from datetime import datetime
  import sys
  
  aws_access_key = str(input("AWS Access Key: "))
  aws_secret_key = str(input("AWS Secret Key: "))
  regionname = str(input("AWS Region Name: "))
  regionendpoint = str(input("AWS Region Endpoint: "))
  region = RegionInfo(name=regionname, endpoint=regionendpoint)
  conn = EC2Connection(aws_access_key_id = aws_access_key, aws_secret_access_key = aws_secret_key, region = region)
  print (conn)
  
  volumes = conn.get_all_volumes()
  print ("%s" % repr(volumes))
  
  vol_id = str(input("Enter Volume ID to snapshot: "))
  keep = int(input("Enter number of snapshots to keep:  "))
  volume = volumes[0]
  description = str(input("Enter volume snapshot description: "))
  
  
  if volume.create_snapshot(description):
      print ('Snapshot created with description: %s' % description)
  
  snapshots = volume.snapshots()
  print (snapshots)
  
  def date_compare(snap1, snap2):
      if snap1.start_time &lt; snap2.start_time:
          return -1
      elif snap1.start_time == snap2.start_time:
          return 0
      return 1
  
  snapshots.sort(key=date_compare)
  delta = len(snapshots) - keep
  for i in range(delta):
      print ('Deleting snapshot ') + snapshots[i].description
      snapshots[i].delete()
  </code></pre>
  
  <p>When using sort to order the snapshots I am calling a function to compare dates to work out which is the newest and oldest snapshots.  When snapshots.sort(key=date_compare) runs I get the following error:</p>
  
  <pre><code>    snapshots.sort(key=date_compare)
  TypeError: date_compare() missing 1 required positional argument: 'snap2'
  </code></pre>
  
  <p>Pretty sure I am doing something very basic wrong but would really appreciate some help to get this working.  Thanks!</p>