473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

What do _ast Load | Store | Del | AugLoad | AugStore | Param mean?

In the _ast module Attribute, Subscript, Name, List, Tuple all have an
expr_context associated with them which is defined as:

expr_context = Load | Store | Del | AugLoad | AugStore | Param

I have no idea what they mean, and what's the difference between them.
I'm porting _ast to IronPython and this is the only part I've had
difficulty understanding. The only clue I've found is that all these
expressions are unique in that they can occur in assignment context.

Any insights at all?

Thanks,
-Dan
Oct 11 '08 #1
2 2918
On Oct 11, 12:57*pm, Eloff <dan.el...@gmail.comwrote:
In the _ast module Attribute, Subscript, Name, List, Tuple all have an
expr_context associated with them which is defined as:

expr_context = Load | Store | Del | AugLoad | AugStore | Param

I have no idea what they mean, and what's the difference between them.
I'm porting _ast to IronPython and this is the only part I've had
difficulty understanding. The only clue I've found is that all these
expressions are unique in that they can occur in assignment context.

Any insights at all?
They refer to how the expression is used in its context. You can cross
AugLoad and AugStore off because they are not used by the current
implementation. I hope this code examples will explain the rest:

Load:
a = 2
Module(body=[Assign(targets=[Name(id='a', ctx=Store())],
value=Num(n=2))])

Store:
print a
Module(body=[Print(dest=None, values=[Name(id='a', ctx=Load())],
nl=True)])

Del:
del a
Module(body=[Delete(targets=[Name(id='a', ctx=Del())])])

Param:
def f(a): pass
Module(body=[FunctionDef(name='f', args=arguments(args=[Name(id='a',
ctx=Param())], vararg=None, kwarg=None, defaults=[]), body=[Pass()],
decorator_list=[])])

I hope that helps!
>
Thanks,
-Dan
Oct 12 '08 #2
On Oct 11, 9:22*pm, Benjamin <musiccomposit...@gmail.comwrote:
Load:
a = 2
Module(body=[Assign(targets=[Name(id='a', ctx=Store())],
value=Num(n=2))])

Store:
print a
Module(body=[Print(dest=None, values=[Name(id='a', ctx=Load())],
nl=True)])

Del:
del a
Module(body=[Delete(targets=[Name(id='a', ctx=Del())])])

Param:
def f(a): pass
Module(body=[FunctionDef(name='f', args=arguments(args=[Name(id='a',
ctx=Param())], vararg=None, kwarg=None, defaults=[]), body=[Pass()],
decorator_list=[])])

I hope that helps!
Very much! Thank you for such a clear explanation!

Cheers,
-Dan

Oct 12 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: F. Da Costa | last post by:
Hi, Does anybody know why IE5+ does *not* honour array objects (like a table) across a session? Example: Frame A contains a var tableVar which is set via form Frame B (on init) using...
2
by: Sandman | last post by:
Just looking for suggestion on how to do this in my Web application. The goal is to keep track of what a user has and hasn't read and present him or her with new material I am currently doing...
1
by: Rafaela K. Azinhal | last post by:
Hi, I'm a newbie and have a question: I have following PivotTable object in a HTML page <html> <body> <object class='ptdrillthrough' classid="clsid:0002E552-0000-0000-C000-000000000046"...
53
by: Deniz Bahar | last post by:
I know the basic definition of a sequence point (point where all side effects guaranteed to be finished), but I am confused about this statement: "Between the previous and next sequence point an...
5
by: garyusenet | last post by:
I understand that Point is an object used for storing co-ordinates, such as mouse location. I can't figure out what the e's do in the above example can someone explain please. Thanks, Gary.
0
by: harshad | last post by:
Dear All,Here I am facing problem to store image.I am trying to store byte array(image) in to session variable so at time of update I will got that byte array and I do my update. here i am given...
2
by: franck | last post by:
Dear all, I'm experimenting with new ast module. I'd like to have pieces of code that can generate AugLoad and AugStore AST nodes. Indeed, I actually do not know what they correspond to. ...
2
by: pankajsingh5k | last post by:
Dear All, Please help me... I had read an article to lazy load a tab in a tabcontainer using an update panel on http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.