Re: python syntax

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

urm, for some reason mail cut off my last half of the message. Anyway, in order 
to answer your question, they are public variables, and thus can be accessed 
from outside of the class. But assuming they were private in another language 
such as c++, you can still access them from within a method of that class.
On Dec 27, 2009, at 1:15 PM, Tyler Littlefield wrote:

> Python doesn't distinguish between public and private scope. YOu can just as 
> easly alter myclass.myvar as you can edit self.var from within a method of 
> myclass.
> On Dec 27, 2009, at 1:07 PM, Alex Hall wrote:
> 
>> So are they public then?
>> 
>> 
>> Have a great day,
>> Alex
>> New email address: mehgcap@xxxxxxxxx
>> ----- Original Message ----- From: "Tyler Littlefield" <tyler@xxxxxxxxxxxxx>
>> To: <programmingblind@xxxxxxxxxxxxx>
>> Sent: Sunday, December 27, 2009 15:01
>> Subject: Re: python syntax
>> 
>> 
>> that does change the vars in the class, but it doesn't set up anything 
>> really. it's just manipulating class variables.
>> On Dec 27, 2009, at 12:32 PM, Alex Hall wrote:
>> 
>>> Okay about the underlines being syntax, but what do you mean the vars are 
>>> in conditionals?
>>> 
>>> self._client.session_key = result['session_key']
>>> self._client.uid = result['uid']
>>> self._client.secret = result.get('secret')
>>> 
>>> What happens with these vars? The statement after these is a return, and 
>>> the def ends, so I am not sure what these are. Are they public? For 
>>> example, could I call this method and use
>>> getSession._client.session_key
>>> and use that as a var? I guess I mean, is this sort of like a constructor 
>>> in java, setting up some public vars?
>>> 
>>> 
>>> 
>>> 
>>> Have a great day,
>>> Alex
>>> New email address: mehgcap@xxxxxxxxx
>>> ----- Original Message ----- From: "Tyler Littlefield" <tyler@xxxxxxxxxxxxx>
>>> To: <programmingblind@xxxxxxxxxxxxx>
>>> Sent: Sunday, December 27, 2009 14:24
>>> Subject: Re: python syntax
>>> 
>>> 
>>> the _ is just the variable syntax. the vars that it extracts or uses rather 
>>> are just in conditionals from what I remember of the code.
>>> On Dec 27, 2009, at 12:02 PM, Alex Hall wrote:
>>> 
>>>> I know basic python, having written a program in it for a class about 3 
>>>> months ago, but this stuff is more advanced than what I learned. Is there 
>>>> something that covers these:
>>>> 
>>>> 1. Why put an underline after the self keyword?
>>>> 2. The method in my email returned one variable, yet it also had several 
>>>> vars which it extracted from somewhere. It did not return them, though, so 
>>>> why make them at all?
>>>> 3. I have read about super, and I understand that it is a way of basically 
>>>> grabbing a passing bit of information, modifying it, then sening it on its 
>>>> way. I cannot understand this in practice, though, in the places where I 
>>>> have seen it.
>>>> 
>>>> 
>>>> Have a great day,
>>>> Alex
>>>> New email address: mehgcap@xxxxxxxxx
>>>> ----- Original Message ----- From: "Tyler Littlefield" 
>>>> <tyler@xxxxxxxxxxxxx>
>>>> To: <programmingblind@xxxxxxxxxxxxx>
>>>> Sent: Sunday, December 27, 2009 13:50
>>>> Subject: Re: python syntax
>>>> 
>>>> 
>>>> 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
>>>> 
>>>> __________
>>>> 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
>>> 
>>> __________
>>> 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
>> 
>> __________
>> 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

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

Other related posts: