Re: [Tutor] string formatting (%s)

2006-04-16 Thread Alan Gauld
> Can I use string formatting in my own functions, or is it stuck with > builtins? No, you can use it too. > It doesn't make much sense for me, but I don't understand the following > error: > In [2]: def printd(arg): > ...: print('>>> %s') % arg The format operator needs to be with the

Re: [Tutor] string formatting (%s)

2006-04-15 Thread Danny Yoo
> The parenthesization you had earlier forced Python into printing out > your template before it had an opportunity to plug arg into it. You > need to do the interpolation first. Gaaah. Brain freeze. I was pointing at the wrong code. *grin* I meant to look at the other statement that you h

Re: [Tutor] string formatting (%s)

2006-04-15 Thread Danny Yoo
On Sat, 15 Apr 2006, Tiago Saboga wrote: > Can I use string formatting in my own functions, or is it stuck with builtins? > It doesn't make much sense for me, but I don't understand the following > error: > > In [1]: var = 456 > > In [2]: def printd(arg): > ...: print('>>> %s') % arg > .

[Tutor] string formatting (%s)

2006-04-15 Thread Tiago Saboga
Can I use string formatting in my own functions, or is it stuck with builtins? It doesn't make much sense for me, but I don't understand the following error: In [1]: var = 456 In [2]: def printd(arg): ...: print('>>> %s') % arg ...: In [3]: printd(var) >>> 456 In [4]: printd('Variab