Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51358
| Date | 2013-07-27 09:44 -0400 |
|---|---|
| From | Devyn Collier Johnson <devyncjohnson@gmail.com> |
| Subject | Re: Critic my module |
| References | <mailman.5092.1374758683.3114.python-list@python.org> <51f334eb$0$29971$c3e8da3$5496439d@news.astraweb.com> <51F3C8FA.9040801@Gmail.com> <kt0ibg$3ev$1@ger.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5172.1374932681.3114.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Critic my module Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-25 09:24 -0400
Re: Critic my module Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2013-07-25 16:09 +0200
Re: Critic my module Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-26 06:59 -0400
Re: Critic my module Alister <alister.ware@ntlworld.com> - 2013-07-26 15:08 +0000
Re: Critic my module Joshua Landau <joshua@landau.ws> - 2013-07-26 18:24 +0100
Re: Critic my module Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-27 02:48 +0000
Re: Critic my module Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-27 08:56 -0400
Re: Critic my module Alister <alister.ware@ntlworld.com> - 2013-07-27 16:32 +0000
Re: Critic my module Dave Angel <davea@davea.name> - 2013-07-27 12:58 -0400
Re: Critic my module Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-27 09:19 -0400
Re: Critic my module Dave Angel <davea@davea.name> - 2013-07-27 09:35 -0400
Re: Critic my module Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-07-27 15:36 +0200
Re: Critic my module Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-27 09:44 -0400
Re: Critic my module Chris Angelico <rosuav@gmail.com> - 2013-07-27 14:37 +0100
Re: Critic my module Dave Angel <davea@davea.name> - 2013-07-27 10:33 -0400
Re: Critic my module Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-27 10:53 -0400
Re: Critic my module Chris Angelico <rosuav@gmail.com> - 2013-07-27 16:15 +0100
csiph-web