I'm not sure why I'm getting this error, I'm using str.join()
and os.path.join()
at different points in the script, is that the cause?
Using os.path.join:
from os.path import getsize, dirname, join
class Wav:
src_path = "No path"
dest_path = destination
old_name = "name.wav"
new_name = ""
def __init__(self, path):
self.src_path = path
self.old_name = os.path.split(path)
self.new_name = self.old_name
self.dest_path = join(destination, self.new_name) # error here
Here is my error:
Traceback (most recent call last):
File "call.py", line 132, in <module>
temp = Wav(temp_path)
File "call.py", line 32, in __init__
self.dest_path = join(destination, self.new_name)
File "/usr/lib/python2.7/posixpath.py", line 75, in join
if b.startswith('/'):
AttributeError: 'tuple' object has no attribute 'startswith'
Is this a conflict with str.join()
or am I not importing os.path
properly?
self.new_name
is not a string, it's a tuple, so you can't use it as the second argument tojoin
. Perhaps you meant to joindestination
with just the last element ofself.new_name
?