By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,941 Members | 1,766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,941 IT Pros & Developers. It's quick & easy.

why this error?

P: n/a
Hi,
I'm not sure why I can't concatenate dirname() with basename().

Traceback (most recent call last):
File "showDir.py", line 50, in ?
print 'somthing new...', os.path.join(os.path.dirname(os.getcwd)) +
os.path.basename(os.getcwd())
File "/usr/lib/python2.3/posixpath.py", line 119, in dirname
return split(p)[0]
File "/usr/lib/python2.3/posixpath.py", line 77, in split
i = p.rfind('/') + 1
AttributeError: 'builtin_function_or_method' object has no attribute
'rfind'
Thanks,
Wayne
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Le Wed, 16 Mar 2005 17:53:57 -0500, spencer a écrit :
Hi,
I'm not sure why I can't concatenate dirname() with basename().

Traceback (most recent call last):
File "showDir.py", line 50, in ?
print 'somthing new...', os.path.join(os.path.dirname(os.getcwd)) +
os.path.basename(os.getcwd()) The problem is here : os.path.join() take at least one parameter, but it
is silly to use it with only one. Replace the « + » by a comma. File "/usr/lib/python2.3/posixpath.py", line 119, in dirname
return split(p)[0]
File "/usr/lib/python2.3/posixpath.py", line 77, in split
i = p.rfind('/') + 1
AttributeError: 'builtin_function_or_method' object has no attribute
'rfind'
Thanks,
Wayne

Jul 18 '05 #2

P: n/a
spencer wrote:
Hi,
I'm not sure why I can't concatenate dirname() with basename().

Traceback (most recent call last):
File "showDir.py", line 50, in ?
print 'somthing new...', os.path.join(os.path.dirname(os.getcwd)) +
os.path.basename(os.getcwd())
File "/usr/lib/python2.3/posixpath.py", line 119, in dirname
return split(p)[0]
File "/usr/lib/python2.3/posixpath.py", line 77, in split
i = p.rfind('/') + 1


Several errors:

- os.getcwd is the _function_, you need to call them os.getcwd(), as you do
in the second call to it.

- the join is supposed to work on a list of arguments, like this:

os.path.join("a", "b", "c")

will yield

a/b/c

But you concatenate two strings using +, and thus have only one argument at
all, which can't be joined as it is only one...
--
Regards,

Diez B. Roggisch
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.