Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8021291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:56:10+00:00 2026-06-04T21:56:10+00:00

I’m using arcpy to get all the polylines of a shape file. SearchCursor returns

  • 0

I’m using arcpy to get all the polylines of a shape file. SearchCursor returns a cursor so that I can iterate over all the features of shape file. Problem is I want to save all the objects returned by cursor for later use.

import arcpy
from arcpy import env

env.workspace = r"C:\GIS Data\GIS data"

desc = arcpy.Describe("River.shp")
shapefieldname = desc.ShapeFieldName

rows = arcpy.SearchCursor("River.shp")

featureList = ()

for row in rows:
    feat = row.getValue(shapefieldname)

    featureList = featureList + (feat, )

    print "%i %i" % (featureList[-1].firstPoint.X, featureList[-1].firstPoint.Y)
    print "%i %i" % (featureList[-1].lastPoint.X, featureList[-1].lastPoint.Y)

    print

print "---------------------------------------------------------------"

for feat in featureList:
    print "%i %i" % (feat.firstPoint.X, feat.firstPoint.Y)
    print "%i %i" % (feat.lastPoint.X, feat.lastPoint.Y)
    print

Tuple supposed to contain all the objects returned by cursor. But it has only the last elements repeated size of tuple number of times.

3610930 2135882 3611593 2134453

3611806 2134981 3611593 2134453

3614160 2136164 3617432 2131734

3611593 2134453 3617432 2131734

3617432 2131734 3620568 2127591

3620568 2127591 3620785 2127423

3617980 2126657 3620568 2127591

3616768 2129454 3617948 2126649

3617948 2126649 3617980 2126657

3615102 2128889 3617587 2126510

3617587 2126510 3617948 2126649

3617624 2126416 3617980 2126657

3613129 2128176 3615155 2125617

3615155 2125617 3617587 2126510

3615086 2125515 3615155 2125617


3615086 2125515 3615155 2125617

3615086 2125515 3615155 2125617

3615086 2125515 3615155 2125617

3615086 2125515 3615155 2125617

3615086 2125515 3615155 2125617

3615086 2125515 3615155 2125617

3615086 2125515 3615155 2125617

3615086 2125515 3615155 2125617

3615086 2125515 3615155 2125617

3615086 2125515 3615155 2125617

3615086 2125515 3615155 2125617

3615086 2125515 3615155 2125617

3615086 2125515 3615155 2125617

3615086 2125515 3615155 2125617

3615086 2125515 3615155 2125617

At first, I’ve tried this using list. Same output was also found for list when I’ve used ‘append()’ method. As tuple is immutable data structure, how can + overwrites all the previous elements of tuple. Although this code is written for arcpy, but I guess the problem isn’t arcgis specific.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:56:11+00:00Added an answer on June 4, 2026 at 9:56 pm

    What this suggests is that row.getValue() keeps returning references to the same object, which it keeps updating in place.

    To verify, try printing id(feat), id(feat.firstPoint) and id(feat.lastPoint) in the first loop, and see whether any of the ids remain the same between iterations. If any of them do, that’s your problem.

    As tuple is immutable data structure, how can + overwrites all the previous elements of tuple.

    It doesn’t. Tuple is immutable in the sense that you can’t add or remove elements from it without creating a new tuple. You also can’t change the value of a tuple element. However, if that element is a reference to a mutable object, you are free to modify the object itself. This is what I suspect is happening here: you have multiple references to the same object; when you modify one, they all appear to change.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I am using parse_ini_file to read the contents of a file however it is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.