• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Python 3.0 help - SOLVED

JTsyo

Lifer
I had a program that I had written a while to manipulate text files. It seems moving to Python 3.0 has changed some of the syntax. I imported the string and sys modules.

Previously I had j=string.replace(i,',',' ') which replaced , with space. After looking over the docs it seems now it should be j=i.replace(',',' '). When trying to run it with IDLE I get the error AttributeError: 'module' object has no attribute 'replace'.

Any ideas?

FYI the loop that's giving me the trouble now
Code:
   for i in data:
      #print i
      j = i.replace(',','  ')
      a = i.split(j)
      #print a

      time+=t
      newdatax.append((time,a[0]))
      newdatay.append((time,a[1]))
      newdataz.append((time,a[2]))
 
Last edited:
Not sure what I did but it got fixed. One error I did catch though was that a=i.split(j) should be a=j.split()
 
Back
Top