On 07/27/2013 09:35 AM, Dave Angel wrote:
On 07/27/2013 09:19 AM, Devyn Collier Johnson wrote:
<SNIP>
About the aliases, I have tried setting pwd() as an alias for
"os.getcwd()", but I cannot type "pwd()" and get the desired output.
Instead, I must type "pwd". I tested this in Guake running Python3.3.
>>> os.getcwd()
'/home/collier'
>>> pwd = os.getcwd()
>>> pwd()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object is not callable
>>> pwd
'/home/collier'
>>> pwd() = os.getcwd()
File "<stdin>", line 1
SyntaxError: can't assign to function call
How could I make pwd() work?
Don't call getcwd() when making the alias. You want it to be called
when USING the alias.
pwd = os.getcwd #creates the alias
pwd() #runs the alias
Thanks! It works!
>>> pwd = os.getcwd
>>> pwd()
'/home/collier'
Mahalo, Dave!
DCJ
--
http://mail.python.org/mailman/listinfo/python-list