Re: python syntax

  • From: Tyler Littlefield <tyler@xxxxxxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Sun, 27 Dec 2009 11:50:08 -0700

Alix,
I'm going to recommend you read the python tutorial. Just jumping in from 
knowing another language will not work. The ideas are the same, but the 
keywords are different. Go read up on classes, self is fully explained there. 
Adding a method is as easy as just appending it in the class, making sure that 
it's indented correctly.

On Dec 27, 2009, at 11:37 AM, Alex Hall wrote:

> Hi all,
> I am really trying to better understand Python, but I am lost here. I have a 
> file called pyfacebook, and it is a python wrapper for the facebook api. I am 
> trying to add a ocuple of my own methods to this file, the new stream 
> methods. I want all these methods in one class, so I created said class. Now, 
> though, I am not sure how to put my methods into my class. The file contains 
> something called an IDL, which seems to be a dictionary of methods? The other 
> problem I have is getting some necessary information for connecting to 
> facebook in the first place. Most of it can be gotten through methods already 
> in place, but I am not sure how to call one such method because it has a lot 
> of use of the word 'self' and I am unable to figure out just what it returns. 
> I have pasted this funciton below. If you understand it, could you please 
> explain it!!?? Thanks.
> 
>   def getSession(self):
>       """Facebook API call. See 
> http://developers.facebook.com/documentation.php?v=1.0&method=auth.getSession""";
>       args = {}
>       try:
>           args['auth_token'] = self._client.auth_token
>       except AttributeError:
>           raise RuntimeError('Client does not have auth_token set.')
>       result = self._client('%s.getSession' % self._name, args)
>       self._client.session_key = result['session_key']
>       self._client.uid = result['uid']
>       self._client.secret = result.get('secret')
>       self._client.session_key_expires = result['expires']
>       return result
> 
> 
> Have a great day,
> Alex
> New email address: mehgcap@xxxxxxxxx 
> __________
> View the list's information and change your settings at 
> //www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

Other related posts: