def print_categories(parent_category_name=None):
 proxy = T411Proxy()
 proxy.set_credential()
 with Session() as session:
  if (parent_category_name is None):
   categories = proxy.main_categories(session=session)
  else:
   categories = proxy.find_categories(parent_category_name, session=session)
  formatting_main = u'%-30s %-5s %-5s'
  formatting_sub = u'     %-25s %-5s %-5s'
  console((formatting_main % (u'Category name', u'PID', u'ID')))
  for category in categories:
   console((formatting_main % (category.name, category.parent_id, category.id)))
   for sub_category in category.sub_categories:
    console((formatting_sub % (sub_category.name, sub_category.parent_id, sub_category.id)))

def print_categories ( parent_category_name = None ) : proxy = T411Proxy ( ) proxy . set_credential ( ) with Session ( ) as session : if ( parent_category_name is None ) : categories = proxy . main_categories ( session = session ) else : categories = proxy . find_categories ( parent_category_name , session = session ) formatting_main = u'%-30s %-5s %-5s' formatting_sub = u'     %-25s %-5s %-5s' console ( ( formatting_main % ( u'Category name' , u'PID' , u'ID' ) ) ) for category in categories : console ( ( formatting_main % ( category . name , category . parent_id , category . id ) ) ) for sub_category in category . sub_categories : console ( ( formatting_sub % ( sub_category . name , sub_category . parent_id , sub_category . id ) ) )
print category and its sub-categories .