Python with statement is broken.

I am using the default python install which is version 2.5.1. According to the python documentation, support for the following syntax was added in version 2.5 but it does not work on the default apple python install.
with open('filename') as f:
for line in f:
print line
This is supposed to open to automate opening and closing of the file. However the with statement doesnt work and I get a syntax error.
Is this normal or is my python installation broken? If it is normal is there any way to get this syntax enabled?
Message was edited by: keeler1

You need to read the rest of the documentation as support for that keyword is not enabled on versions prior to 2.6 unless you specifically ask for it.
from _future_ import with_statement

Similar Messages

  • Problem Using Multiple With Statements

    I'm having a problem using multiple WITH statements. Oracle seems to be expecting a SELECT statement after the first one. I need two in order to reference stuff from the second one in another query.
    Here's my code:
    <code>
    WITH calculate_terms AS (SELECT robinst_current_term_code,
    CASE
    WHEN robinst_current_term_code LIKE '%60' THEN robinst_current_term_code - '40'
    WHEN robinst_current_term_code LIKE '%20' THEN robinst_current_term_code - '100'
    END first_term,
    CASE
    WHEN robinst_current_term_code LIKE '%60' THEN robinst_current_term_code - '100'
    WHEN robinst_current_term_code LIKE '%20' THEN robinst_current_term_code - '160'
    END second_term
    FROM robinst
    WHERE robinst_aidy_code = :aidy)
    /*Use terms from calculate_terms to generate attendance periods*/
    WITH gen_attn_terms AS
    SELECT
    CASE
    WHEN first_term LIKE '%60' THEN 'Fall '||substr(first_term,0,4)
    WHEN first_term LIKE '%20' THEN 'Spring '||substr(first_term,0,4)
    END first_attn_period,
    CASE
    WHEN second_term LIKE '%60' THEN 'Fall '||substr(second_term,0,4)
    WHEN second_term LIKE '%20' THEN 'Spring '||substr(second_term,0,4)
    END second_attn_period
    FROM calculate_terms
    SELECT *
    FROM gen_attn_terms
    <code>
    I get ORA-00928: missing SELECT keyword error. What could be the problem?

    You can just separate them with a comma:
    WITH calculate_terms AS (SELECT robinst_current_term_code,
    CASE
    WHEN robinst_current_term_code LIKE '%60' THEN robinst_current_term_code - '40'
    WHEN robinst_current_term_code LIKE '%20' THEN robinst_current_term_code - '100'
    END first_term,
    CASE
    WHEN robinst_current_term_code LIKE '%60' THEN robinst_current_term_code - '100'
    WHEN robinst_current_term_code LIKE '%20' THEN robinst_current_term_code - '160'
    END second_term
    FROM robinst
    WHERE robinst_aidy_code = :aidy),
    /*Use terms from calculate_terms to generate attendance periods*/
    gen_attn_terms AS
    SELECT
    CASE
    WHEN first_term LIKE '%60' THEN 'Fall '||substr(first_term,0,4)
    WHEN first_term LIKE '%20' THEN 'Spring '||substr(first_term,0,4)
    END first_attn_period,
    CASE
    WHEN second_term LIKE '%60' THEN 'Fall '||substr(second_term,0,4)
    WHEN second_term LIKE '%20' THEN 'Spring '||substr(second_term,0,4)
    END second_attn_period
    FROM calculate_terms
    )Not tested because there are no scripts.

  • What causes all my emails with embedded media to always be downloaded with the media broken or removed? How do I solve it?

    Whenever people send me emails with embedded videos or pictures, the email always comes in without the media. It will have just the empty box outline where it supposed to be with a tiny broken page icon in the top left-hand corner.
    I can't seem to find the cause and the solution and this has been happening for a few years already. Does it have anything to do with my account still being POP and not IMAP? What are the possible reasons and their solutions? Please help, thank you.

    I am not an expert in this area, but I think I might know what is going on. There is a difference between an 'embedded' picture and an 'attached' picture.
    An embedded picture has a link to the actual picture. If the link is to a site which is not accessible (such as the sender's own computer) then you will get a broken link.
    An attached picture is the actual picture file (.jpg, etc.) so you can always view it. If you check 'Display Attachments Inline', then when you scroll down through the email, the attachments will show up.
    So, bottom line: If the sender embeds a picture, it needs to link to a publicly accessible URL. Otherwise, it needs to be attached.

  • Info about "with" statement..

    Hi everybody,
    I have seen too many threads using with statements in sql...
    The general syntax is :
    SQL> with t as
    ( select ...... from .....
    union
    select ...... from .....
    )...... 'test' from t;
    What is this and where can I found info about this......????
    I use Ora 10g.
    Thanks ,
    Simon

    Or, to put it in basic terms.....
    When you want to test something and you need a sample set of data to use, rather than create a table and populate it with a whole load of inserts (or insert select) you can just specify a "With <name> as select...." clause before your query. This also means that you don't have to drop the table again when you're done testing.
    Long winded way...
    create table t as (select 1 id from dual union select 2 from dual union select 3 from dual);
    select * from t;
    drop table t;Simple way...
    with t as (select 1 id from dual union select 2 from dual union select 3 from dual)
    select * from t;The sample data is only in existence for the duration of the query, and it saves all of us here on the forums who answer peoples questions from creating loads of tables on our databases temporarily.
    ;)

  • Firefox was my default, it went to boxes with statements,now it will not load,

    Firefox stopped working yesterday for no reason, when I open the default page, all I get is 9 oblong boxes stacked one on top of the other with statements and a search button for each one, but nothing happens, which means I cannot access my computer via firefox.

    Thanks for the input, but it still didn't work. I tried resetting, then I reinstalled the Photobucket App. It asked me to sign in, but when I attempt to go to "My Albums" at the bottom of the page, it just freezes when it says "Loading Albums". Just like it did before.
    At least the camera still works. I'm about ready to take a picture of a target, set it up about 50 feet away and use this **** thing for the one thing it's good for, catching a bullet.
    What really ****** me off was when I wanted to speak to a live Apple employee for help. $19 for help fixing what is obviously a problem with their "update"?!?! I'm totally convinced that Apple could care less about their customers. Sure, some people are not experiencing problems with iOS6, but from the posts here searching for help, it's clear Apple totally dropped the ball on this one.
    Thanks Apple.

  • SM59 check responds with state init/busy

    We have a Java application running under Websphere that frequently respond with state init/bus.
    If we start SM59 it takes ages and it ends up with an error that the registered server program is in state init/busy.
    From time to time the connection is restored and available, but most of the time the Jco application is NOT available.
    Output from SM59
    Connect                        Connection error
    Errordetails                   Error when opening an RFC connection
    Errordetails                   ERROR: timeout during allocate of registered progam
    Errordetails                   LOCATION: SAP-Gateway on host UNIX01 / sapgw00
    Errordetails                   DETAIL: TP server01 init/busy for more than 60 sec
    Errordetails                  COMPONENT: SAP-Gateway
    Errordetails                  COUNTER: 76281
    Errordetails                  MODULE: gwr3cpic.c
    Errordetails                  LINE: 1937
    Errordetails                  RETURN CODE: 677
    Errordetails                  SUBRC: 0
    Errordetails                  RELEASE: 700
    Errordetails                  TIME: Fri Apr 16 11:54:49 2010
    Errordetails                  VERSIE: 2
    What could be the issue?
    Edited by: W. van Veen on Apr 16, 2010 12:25 PM

    Hi William,
    the error timeout during allocate of registered progam <em>can</em> show up if the connection is currently busy (used by another process). So this might be a performance issue, if you have for example only one instance of the server registered, yet calls executed on the server take quite a while. So my first recommendation would be to check if this scenario is applicable. If yes, consider registering the server multiple times in SAP (if supported by your application) and also make sure to configure the outbound scheduler properly so that you don't flood the server with too many RFC calls at the same time.
    If we start SM59 it takes ages and it ends up with an error that the registered server program is in state init/busy.
    I suspect that you it's not the startup that takes long, but you're referring to the connection test from SM59. So if my comments above don't help, at least it sounds like you can reproduce the problem. Thus I'd try the RFC trace generation scenario as described nicely in OSS note [878860 - RFC tracing for ABAP-to-external communication|https://service.sap.com/sap/support/notes/878860]. This might produce some more info that helps you in figuring out the actual cause of the issue...
    Cheers, harald

  • Issue with stat() and symbolic links

    Has anyone experienced the following issue with stat() ?
    #include <stdio.h>
    #include <string.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <unistd.h>
    int main( int argc, char **argv )
    struct stat buf;
    if( argc < 2 )
    return 0;
    char *link = strdup( argv[1] );
    if( stat( link, &buf ) == -1 ) {
    puts( "Error" );
    return 1;
    if( ( S_IFLNK & buf.st_mode ) == S_IFLNK )
    puts( "Is link" );
    else
    puts( "Not link" );
    return 0;
    If you compile and run the above code (or similar code), you would expect it to report that the given argument is a symbolic link when indeed the argument is a symbolic link; though, instead of the expected happening, the following happens as shown below:
    $ gcc -o islink islink.c
    $ ln -s /tmp link
    $ ./islink link
    Not link
    $
    Is anyone else experiencing this? My filesystem is ext4. The same error happens when using the S_ISLNK() macro.

    man 3p lstat
    DESCRIPTION
           The lstat() function shall be equivalent to stat(),  except  when  path
           refers  to  a symbolic link. In that case lstat() shall return informa‐
           tion about the link, while stat() shall return  information  about  the
           file the link references.

  • Connection with sapinst get broken: Netweaver 2004 on aix machine

    Hi
    I am installing Netweaver 2004 on aix machine.
    Java instance
    database : maxdb
    When I run sapinst , connection with it get broken in between.
    Warnings and errors are as follows:
    Current (soft) resource limit stacksize should be unlimited but it is 33554432. This may cause core dumps. Stop the installation set the limit to unlimited and start again.
    WARNING    2007-05-08 13:19:56 [sapinst.cpp:124]
               CSapInst::initMessaging()
    Current (soft) resource limit stacksize should be unlimited but it is 33554432. This may cause core dumps. Stop the installation set the limit to unlimited and start again.
    Current (soft) resource limit datasize should be unlimited but it is 134217728. This may cause core dumps. Stop the installation set the limit to unlimited and start again.
    WARNING    2007-05-08 13:19:56 [sapinst.cpp:139]
               CSapInst::initMessaging()
    Current (soft) resource limit datasize should be unlimited but it is 134217728. This may cause core dumps. Stop the installation set the limit to unlimited and start again.
    <b>iauxsysex.c:317: child /tmp/sapinst_exe.631026.1178648293/sapinst (pid 753700) has crashed. Executable directory is /tmp/sapinst_exe.631026.1178648293. Contact Support.
    iaextract.c:885: child has signaled an exec error. Keeping directory /tmp/sapinst_exe.631026.1178648293</b>
    What is the solution for this?

    "Current (soft) <b>resource limit stacksize should be unlimited</b> but it is 33554432. This may cause core dumps. Stop the installation set the limit to unlimited and start again."
    -> plz check your root values using SMITTY -> Security & Users -> Users -> Change/Show  Characteristics of a User -> insert 'root' -> check parameter 'Soft STACK size' -> value should be '-1' (minus one)
    GreetZ, AH

  • [svn:fx-trunk] 12786: Fixed bug with state property value assignments.

    Revision: 12786
    Revision: 12786
    Author:   [email protected]
    Date:     2009-12-10 07:35:43 -0800 (Thu, 10 Dec 2009)
    Log Message:
    Fixed bug with state property value assignments. SetProperty pseudonym values (width/explicitWidth, height/explicitHeight) were not getting set correctly, causing values to be incorrectly assigned to 0 in some cases.
    QE notes: -
    Doc notes: -
    Bugs: sdk-24446
    Reviewer: Corey
    Tests run: checkintests, Mustella tests/States, tests/mx/states
    Is noteworthy for integration: Yes (fix requested by tools)
    Ticket Links:
        http://bugs.adobe.com/jira/browse/sdk-24446
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/framework/src/mx/states/SetProperty.as

    Add this to the end of your nav p CSS selector at Line 209 of your HTML file, after 'background-repeat...':
    margin-bottom: -2px;
    Your nav p will then look like this:
    nav p {
              font-size: 90%;
              font-weight: bold;
              color: #FFC;
              background-color: #090;
              text-align: right;
              padding-top: 5px;
              padding-right: 20px;
              padding-bottom: 5px;
              border-bottom-width: 2px;
              border-bottom-style: solid;
              border-bottom-color: #060;
              background-image: url(images/background.png);
              background-repeat: repeat-x;
              margin-bottom: -2px;

  • With statement

    can explain with statement syntax and its use related to performance

    see its syntax
    WITH
    subquery_name
    AS
    (the aggregation SQL statement)
    SELECT
    (query naming subquery_name);
    also see these 2 examples
    WITH
    sum_sales AS
    ( select /*+ materialize */
    sum(quantity) all_sales from stores ),
    number_stores AS
    ( select /*+ materialize */
    count(*) nbr_stores from stores ),
    sales_by_store AS
    ( select /*+ materialize */
    store_name, sum(quantity) store_sales from
    store natural join sales )
    SELECT
    store_name
    FROM
    store,
    sum_sales,
    number_stores,
    sales_by_store
    where
    store_sales > (all_sales / nbr_stores);
    WITH recursiveBOM
    (assembly_id, assembly_name, parent_assembly) AS
    (SELECT parent.assembly_id,
    parent.assembly_name,
    parent.parent_assembly
    FROM bill_of_materials parent
    WHERE parent.assembly_id=100
    UNION ALL
    SELECT child.assembly_id,
    child.assembly_name,
    child.parent_assembly
    FROM recursiveBOM parent, bill_of_materials child
    WHERE child.parent_assembly = parent.assembly_id)
    SELECT assembly_id, parent_assembly, assembly_name
    FROM recursiveBOM;
    Why to use it:
    Oracle SQL can run faster when complex subqueries are replaced with global temporary tables. Starting in Oracle9i release 2, there was an incorporation of a subquery factoring utility implemented the SQL-99 WITH clause. The WITH clause is a tool for materializing subqueries to save Oracle from having to recompute them multiple times.
    Regards

  • MultiDPIBitmapSource with states

    Hi All,
    What's the proper way to use the MultiDPIBitmapSource class with state changes:
    I'm making a simple button skin that just uses an image and changes the image source based on state. The following code doesn't capture state. The image will stay in the normal position and never capture the over or down events and swap to the proper source. This seems possible, or autocomplete in Flash Builder lies. What am I doing wrong here?
    Example:
    {code}
    <?xml version="1.0" encoding="utf-8"?>
    <s:SparkSkin name="myButtonSkin"
                 xmlns:fx="http://ns.adobe.com/mxml/2009"
                 xmlns:s="library://ns.adobe.com/flex/spark"
                 xmlns:fb="http://ns.adobe.com/flashbuilder/2009">
        <s:states>
            <s:State name="up" />
            <s:State name="over" />
            <s:State name="down" />
            <s:State name="disabled" />
        </s:states>
        <fx:Metadata>
            <![CDATA[
            [HostComponent("spark.components.Button")]
            ]]>
        </fx:Metadata>   
        <s:BitmapImage>
            <s:source>
                <s:MultiDPIBitmapSource
                    source160dpi="/assets/images/icon160.png"
                    source240dpi="/assets/images/icon240.png"
                    source320dpi="/assets/images/icon320.png"
                    source160dpi.over="/assets/images/icon160over.png"
                    source240dpi.over="/assets/images/icon240over.png"
                    source320dpi.over="/assets/images/icon320over.png"
                    source160dpi.down="/assets/images/icon160down.png"
                    source240dpi.down="/assets/images/icon240down.png"
                    source320dpi.down="/assets/images/icon320down.png"/>
            </s:source>
        </s:BitmapImage>
    </s:SparkSkin>
    {code}

    I've found what I was doing wrong. Here's the solution:
    <s:source>
                <s:MultiDPIBitmapSource
                    source160dpi="/assets/images/icon160.png"
                    source240dpi="/assets/images/icon240.png"
                    source320dpi="/assets/images/icon320.png"/>
    </s:source>
    <s:source.over>
                 <s:MultiDPIBitmapSource
                    source160dpi="/assets/images/icon160over.png"
                    source240dpi="/assets/images/icon240over.png"
                    source320dpi="/assets/images/icon320over.png"/>
    </s:source.over>
    etc... So the source tag actually takes the state not, the MultiDPIBitmapSource.

  • [svn] 4070: Addressing backwards compatibility issue with states.

    Revision: 4070
    Author: [email protected]
    Date: 2008-11-11 13:13:43 -0800 (Tue, 11 Nov 2008)
    Log Message:
    Addressing backwards compatibility issue with states.
    QE Notes: None
    Doc Notes: None
    Bugs: SDK-17395
    Reviewer: Peter F.
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-17395
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/Grammar.jj

    Revision: 4070
    Author: [email protected]
    Date: 2008-11-11 13:13:43 -0800 (Tue, 11 Nov 2008)
    Log Message:
    Addressing backwards compatibility issue with states.
    QE Notes: None
    Doc Notes: None
    Bugs: SDK-17395
    Reviewer: Peter F.
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-17395
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/Grammar.jj

  • Bug in with-statement?

    According to the docs, the scope chain used by the with
    statement to resolve identifiers is: innermost with-statement
    -&gt; outermost with-statement -&gt; activation object
    -&gt; etc. If this would be true, the following code should
    output &quot;propOfMyObject&quot;:
    Code:
    var foo:String = &quot;propOfActivationObject&quot;;
    var myObject:Object =
    {foo:&quot;propOfMyObject&quot;};
    with (myObject) {
    trace(foo); //outputs:
    &quot;propOfActivationObject&quot;
    But it doesn't. Instead the local variable is shadowing the
    property in myObject. It seems like the scope chain rather is:
    activation object -&gt; innermost with-statement -&gt;
    outermost with-statement -&gt; etc. Which means either the docs
    or the with statement is incorrect. Am I right?

    Query is fine... worked on it [url https://forums.oracle.com/forums/message.jspa?messageID=10902901#10902901]elsewhere first ;-)
    with data as (Select 4 qty from dual)
    select round(100/qty*(level-1)) perc, round(100/qty*(level-1)) c
    from data
    connect by level <= qty +1
    PERC                   C                     
    0                      0                     
    25                     25                    
    50                     50                    
    75                     75                    
    100                    100

  • Impossible to unlock iphone if the device I synced with is now broken?????

    I have a locked iPhone and the laptop I originally set it up with is now broken and has no Internet access. I can't work out how to restore my phone to unlock it, I have tried using an iPad or MacBook but says I can't do that until the phone is unlocked as it is not the original device I synced with.

    Not sure what the problem is here.  Have you forgotten your unlock code? Are you trying to restore your phone from iTunes?  Just trying to get some details here.
    And if your laptop is broken does that mean that you cannot turn your laptop on?  Or just no internet access?
    If the laptop still works without internet you should be able to start iTunes and connect the phone to it using the sync cable.
    Please give us some more details.

  • Adaptor with State information

    Hi
    We are in the process of migrating legacy system to ESB architecture and would like to get your input in how to deal with state information.
    Current system has one system (A) that takes input from another system (S) and outputs to many nodes of system (C).
    S --> B ---> N number of C
    System C is high load, read-only, parallel system (totally independent of each other). System A's job is to provide a buffer between System S, so only relevant changes will trickle to System C, hence removing any unnecessary processing/load to potentially hundreds of nodes of System C. System S is a repository of all the data, superset of what System C needs.
    We are trying to re-architect system A to be an ESB adaptor that reads from System S and exports data to System C (The transport mechanism between system A and C are not to be changed. We will continue to use existing file distribution mechanism. And this isn't the issue; I am only mentioning it here for completeness.)
    Question is, how would you create this adaptor that would know the state of System C (i.e. know what data has been already pushed out via file distribution) and compute relevant delta from the incoming changes from System S? As in the legacy system, this adaptor MUST provide only the deltas to System C, so to not create any unnecessary processing.
    In the legacy architecture, System A had a DB that mirrored the data pushed out to System C. But now the proposal is to get rid of this DB and some how compute the same delta.
    Other than using in-memory DB, what other ways are there? Does Oracle SOA Suite provide something to deal with this?
    Thanks in advance,
    JY

    Hi
    We are in the process of migrating legacy system to ESB architecture and would like to get your input in how to deal with state information.
    Current system has one system (A) that takes input from another system (S) and outputs to many nodes of system (C).
    S --> B ---> N number of C
    System C is high load, read-only, parallel system (totally independent of each other). System A's job is to provide a buffer between System S, so only relevant changes will trickle to System C, hence removing any unnecessary processing/load to potentially hundreds of nodes of System C. System S is a repository of all the data, superset of what System C needs.
    We are trying to re-architect system A to be an ESB adaptor that reads from System S and exports data to System C (The transport mechanism between system A and C are not to be changed. We will continue to use existing file distribution mechanism. And this isn't the issue; I am only mentioning it here for completeness.)
    Question is, how would you create this adaptor that would know the state of System C (i.e. know what data has been already pushed out via file distribution) and compute relevant delta from the incoming changes from System S? As in the legacy system, this adaptor MUST provide only the deltas to System C, so to not create any unnecessary processing.
    In the legacy architecture, System A had a DB that mirrored the data pushed out to System C. But now the proposal is to get rid of this DB and some how compute the same delta.
    Other than using in-memory DB, what other ways are there? Does Oracle SOA Suite provide something to deal with this?
    Thanks in advance,
    JY

Maybe you are looking for

  • ITunes error: Please wait while windows configures iTunes

    Hello, since I changed my Win XP account to limited, I can't start my iTunes without getting the following error message: iTunes error: Please wait while windows configures iTunes It gathers information and then prompts me to restart. If I restart, i

  • Doubt regarding File Content Conversion. File- RFC

    Hi Experts,     My scenario is File -> XI -> RFC, I am able to update the records in R3 when i get a fixed length file with a single record. RFC can process one record at a time (its 1 to 1 , its not 1 to unbounded), May i know what are the changes t

  • New update on iPad and updating app error.

    Yesterday I ran the new 7.3 something, no issues.  Today I am trying to update the apps that are required and I keep getting error message .....update error retry or cancel.  I have retried and retried, powered off and retried, deleted one app and tr

  • Full file path in firefox

    Output of input type=file.... <input type="file" name="frm_filepath" value="" size="100"> In IE frm_filepath : C:\mappingfiles\2006\map.txt In firefox frm_filepath : map.txt How can i get full path and file name in firefox like IE?.

  • Crystal Reports Query

    Gurus,     I have an assignment of creating a report, in which I have to show the output of a single column (forgein currency payment) in multiple column currency example dollar in dollar column, euro in euro column, Rupees in rupees column etc and a