Python not creating a new clean instance?
<p>So I'm creating a list of leaving flights in an array to iterate over in a later application. </p>

<p>I'm getting the information out of a long long html. </p>

<p>The xpathes check out and everything other is fine. I have a major wrapping object called FlightLegs. And a minor inner object called Flights. </p>

<p>The structure is simple. Every FlightLegs has a DATE on which the flights are leaving and THREE flights which are leaving on different TIMES ON that single DATE.</p>

<p>So like you have a date: 28/03/2012 and three flights which leave on : 8:10, 14:30, 20:00.</p>

<p>Simple enough.</p>

<p>So I have two nested loops. First, loops over FlightLegs. Sets DATE... then loops over the Flights in that Leg. And adds them to the array of Flights. Then ads the FlightLegs into a list. And begins a new. </p>

<p>Here is the code:</p>

<pre><code>#Looping thourght the flight legs.
for flightLeg in flightLegs:

    #. is needed in the xpath so it matches items only in this flight leg.
    fleg = FlightLeg()
    fleg.Date = str(flightLeg.xpath(".//input[@name='departDate1']")[0].get('value'))
    innerFlights =  flightLeg.xpath(".//div[@class='flights_flight']")
    counter = 0
    #Getting the three flights in the flight leg leaving at 8 - 14 - 20.
    for flight in innerFlights:
        fl = Flight()
        fl.FlightPrice = str(flight.xpath(".//span[@class='flights_price']")[0].text)
        fl.FlightDepartureTime = str(flight.xpath(".//span[@class='flights_departuretime']")[0].text)
        fl.FlightArrivalTime = str(flight.xpath(".//span[@class='flights_arrivaltime']")[0].text)
        fl.FlightNumber = str(flight.xpath(".//span[@class='flights_flightnumber']")[0].text)
        fl.FlightDepAirport = str(flight.xpath(".//span[@class='flights_departureairport']")[0].text)

        fleg.Flights.append(fl)
        print "Lengts of inner flights: " + str(len(fleg.Flights))
        counter += 1
        print "Lengts of inner counter: " + str(counter)

    flightList.append(fleg)
</code></pre>

<p>Now the problem with this is that the flight legs Array in the inner flight is actually increasing over 3. Up until the last flight 600. It seems that no new object is created durring the loop... so what could cause this?</p>

<p>EDIT:</p>

<p>FlightLeg is:</p>

<pre><code>class FlightLeg:
    Flight = []
    Date = ""
</code></pre>

<p>Flight is:</p>

<pre><code>class Flight:
    FlightPrice = ""
    FlightDepartureTime = ""
    .
    .
    .
</code></pre>

<p>Btw.. I'm new to Python of course. I'm just learning. But now that read DSM-s comment, it might be that it is static after all. I thought variables will be public and instance by default.</p>

<p>How I would access them is not important. The important part is the counter. ;-)</p>

<p>I would access them through a foreach for example. </p>
