Critic my module
Devyn Collier Johnson
devyncjohnson at gmail.com
Sat Jul 27 15:44:24 CEST 2013
On 07/27/2013 09:35 AM, Dave Angel wrote:
> On 07/27/2013 09:19 AM, Devyn Collier Johnson wrote:
>> 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()
>> >>> pwd = os.getcwd()
>> >>> pwd()
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> TypeError: 'str' object is not callable
>> >>> pwd
>> >>> 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
More information about the Python-list