Skip to content

Instantly share code, notes, and snippets.

@rothgar
Created September 28, 2014 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rothgar/c614d61e23f6258e6939 to your computer and use it in GitHub Desktop.
Save rothgar/c614d61e23f6258e6939 to your computer and use it in GitHub Desktop.
Python unicode attribute error
If I curl for a github gist I get
$ curl https://api.github.com/gists/cecfbd74597cc35a6018
{
"url": "https://api.github.com/gists/cecfbd74597cc35a6018",
"forks_url": "https://api.github.com/gists/cecfbd74597cc35a6018/forks",
"commits_url": "https://api.github.com/gists/cecfbd74597cc35a6018/commits",
"id": "cecfbd74597cc35a6018",
"git_pull_url": "https://gist.github.com/cecfbd74597cc35a6018.git",
"git_push_url": "https://gist.github.com/cecfbd74597cc35a6018.git",
"html_url": "https://gist.github.com/cecfbd74597cc35a6018",
"files": {
"install-tmux": {
"filename": "install-tmux",
"type": "text/plain",
"language": null,
"raw_url": "https://gist.githubusercontent.com/rothgar/cecfbd74597cc35a6018/raw/c9ebb46ee33c4faa29dc404b9bf5fd911e21e809/install-tmux"
,
"size": 747,
"truncated": false,
"content": "# Install tmux on Centos release 6.5\n\n# install deps\nyum install gcc kernel-devel make ncurses-devel\n\n# DOWNLOAD SOUR
CES FOR LIBEVENT AND MAKE AND INSTALL\ncurl -OL https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz\ntar -xvzf libe
vent-2.0.21-stable.tar.gz\ncd libevent-2.0.21-stable\n./configure --prefix=/usr/local\nmake\nsudo make install\n\n# DOWNLOAD SOURCES FOR TMU
X AND MAKE AND INSTALL\ncurl -OL http://downloads.sourceforge.net/tmux/tmux-1.9a.tar.gz\ntar -xvzf tmux-1.9a.tar.gz\ncd tmux-1.9a\nLDFLAGS=\
"-L/usr/local/lib -Wl,-rpath=/usr/local/lib\" ./configure --prefix=/usr/local\nmake\nsudo make install\n\n# pkill tmux\n# close your termina
l window (flushes cached tmux executable)\n# open new shell and check tmux version\ntmux -V"
}
},
"public": true,
...
But when I try to show the contents with python I get this error.
1 for gist in a.get_gists():
2 for file in gist.files:
----> 3 print file.content
AttributeError: 'unicode' object has no attribute 'content'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment