Python shows error on line 15 that i cant fix

boB Stepp robertvstepp at gmail.com
Sat Sep 21 14:45:47 EDT 2019


On Sat, Sep 21, 2019 at 1:01 PM Dave Martin <dschwartz0705 at gmail.com> wrote:
>
> On Saturday, September 21, 2019 at 1:33:12 PM UTC-4, Terry Reedy wrote:
> > On 9/21/2019 11:53 AM, Dave Martin wrote:
[...]
> > > #get the combined data and load the fits files
> > >
> > > fits_filename="Gaia_DR2/gaiadr2_100pc.fits"
> > > df=pd.DataFrame()
> > > with fits.open(fits_filename) as data:
> > > df=pd.DataFrame(data[1].data)
> >
> > A 'with' statement is a compound statement.  It must be followed by a
> > 'suite', which usually consists of an indented block of statements.
> > This is line 17 from the first non-blank line you posted.
[...]

> Can you provide an example of how to use the suite feature. Thank you.

Dave, you seem to have some expectation that you should be given the
answer.  That is not how help is given in this forum.  You are
expected to be doing the needed to work before being helped further.
You have been referred to the tutorial multiple times.  Please read
it!  Indentation is so fundamental to structuring Python code that it
is clear that you need grounding in Python fundamentals.  Otherwise
you are essentially Easter-egging through a code sample that you have
no true understanding of.

If you must continue to Easter-egg Python instead of reading the
tutorial (or something equivalent) then check the section of the
tutorial on files.  You will find examples of the use of "with" there.


-- 
boB



More information about the Python-list mailing list