print("hello")
hello
import pywikibot
test_site = pywikibot.Site('test', 'wikipedia')
test_page = pywikibot.Page(test_site, 'user_talk:cmglee')
test_page.exists()
True
print(test_page.)
[[test:User talk:Cmglee]]
test_page.text += 'Hello world'; test_page.save()
Page [[test:User talk:Cmglee]] saved
for (k,v) in test_page: print(k)

TypeErrorTraceback (most recent call last)
<ipython-input-15-885f8e85d307> in <module>()
----> 1 for (k,v) in test_page: print(k)

TypeError: 'Page' object is not iterable
@interact_manual
def write_page(name='user_talk:cmglee', text=''):
    p = pywikibot.Page(test, name)
    p.text = text
    p.save()

NameErrorTraceback (most recent call last)
<ipython-input-17-7e23e74bdec5> in <module>()
----> 1 @interact_manual
      2 def write_page(name='user_talk:cmglee', text=''):
      3     p = pywikibot.Page(test, name)
      4     p.text = text
      5     p.save()

NameError: name 'interact_manual' is not defined
site = pywikibot.Site('wikidata', 'wikidata')
repo = site.data_repository()
item = pywikibot.ItemPage(repo, 'Q43049')
item.getCreator()
WARNING: /srv/paws/lib/python3.4/site-packages/ipykernel/__main__.py:1: DeprecationWarning: pywikibot.page.BasePage.getCreator is deprecated; use oldest_revision instead.
  if __name__ == '__main__':

('MerlIwBot', '2012-11-13T11:54:01Z')
item_dict = item.get()
item_dict.keys()
dict_keys(['labels', 'sitelinks', 'descriptions', 'claims', 'aliases'])
dir(item)
['__class__',
 '__delattr__',
 '__dict__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__gt__',
 '__hash__',
 '__init__',
 '__le__',
 '__lt__',
 '__module__',
 '__ne__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__unicode__',
 '__weakref__',
 '_cache_attrs',
 '_cmpkey',
 '_content',
 '_contentmodel',
 '_cosmetic_changes_hook',
 '_defined_by',
 '_diff_to',
 '_getInternals',
 '_get_parsed_page',
 '_isredir',
 '_latest_cached_revision',
 '_link',
 '_namespace',
 '_namespace_obj',
 '_normalizeData',
 '_normalizeLanguages',
 '_pageid',
 '_revid',
 '_revisions',
 '_save',
 '_timestamp',
 'addClaim',
 'aliases',
 'applicable_protections',
 'aslink',
 'autoFormat',
 'backlinks',
 'botMayEdit',
 'canBeEdited',
 'categories',
 'change_category',
 'claims',
 'clear_cache',
 'content_model',
 'contributingUsers',
 'contributors',
 'coordinates',
 'data_item',
 'data_repository',
 'defaultsort',
 'delete',
 'depth',
 'descriptions',
 'editAliases',
 'editDescriptions',
 'editEntity',
 'editLabels',
 'editTime',
 'embeddedin',
 'encoding',
 'exists',
 'expand_text',
 'extlinks',
 'fromPage',
 'fullVersionHistory',
 'full_url',
 'get',
 'getCategoryRedirectTarget',
 'getCreator',
 'getDeletedRevision',
 'getID',
 'getLatestEditors',
 'getMovedTarget',
 'getOldVersion',
 'getRedirectTarget',
 'getReferences',
 'getRestrictions',
 'getSitelink',
 'getTemplates',
 'getVersionHistory',
 'getVersionHistoryTable',
 'getdbName',
 'id',
 'image_repository',
 'imagelinks',
 'interwiki',
 'isAutoTitle',
 'isCategory',
 'isCategoryRedirect',
 'isDisambig',
 'isEmpty',
 'isFlowPage',
 'isImage',
 'isIpEdit',
 'isRedirectPage',
 'isStaticRedirect',
 'isTalkPage',
 'is_flow_page',
 'iterlanglinks',
 'iterlinks',
 'itertemplates',
 'labels',
 'langlinks',
 'lastNonBotUser',
 'latestRevision',
 'latest_revision',
 'latest_revision_id',
 'linkedPages',
 'loadDeletedRevisions',
 'markDeletedRevision',
 'mergeInto',
 'move',
 'moved_target',
 'namespace',
 'oldest_revision',
 'pageAPInfo',
 'permalink',
 'preloadText',
 'previousRevision',
 'previous_revision_id',
 'properties',
 'protect',
 'protection',
 'purge',
 'put',
 'put_async',
 'removeClaims',
 'removeImage',
 'removeSitelink',
 'removeSitelinks',
 'replaceImage',
 'repo',
 'revision_count',
 'revisions',
 'save',
 'section',
 'sectionFreeTitle',
 'setSitelink',
 'setSitelinks',
 'set_redirect_target',
 'site',
 'sitelinks',
 'templates',
 'text',
 'title',
 'titleForFilename',
 'titleWithoutNamespace',
 'toJSON',
 'toggleTalkPage',
 'touch',
 'undelete',
 'urlname',
 'userName',
 'version',
 'watch']
claim = item_dict['claims']['P31'][0]
claim.toJSON()
{'id': 'Q43049$05D1485E-D9DE-4E8A-8D12-59E238C7A2B2',
 'mainsnak': {'datatype': 'wikibase-item',
  'datavalue': {'type': 'wikibase-entityid',
   'value': {'entity-type': 'item', 'numeric-id': 3266850}},
  'property': 'P31',
  'snaktype': 'value'},
 'rank': 'normal',
 'type': 'statement'}