Hi Luke,
> Is there a way to preserve the readability of the code and have
> printed text from indented blocks, say, nested conditionals, appear
> flush at left, not printed exactly where I've written them in the
> script?
you can use the textwrap module for this.
>>> from textwrap import dedent
On Thu, 24 Feb 2005 14:23:28 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Bill Mill wrote:
> >>class foo:
> >>def bar(self):
> >
> >
> > Sorry, I forgot that if it's in the module, you should declare prompt1
> > as global by using "global prompt1" right here.
> >
> >
> >>print promp
> > > > I'm writing a simple game (run in command line) in which narrative
> > > > text is printed in response to a user's decisions. The problem I'm
> > > > running into is that triple quotes used in an indented block
> > > > preserves the indentation when it prints.
[text cut]
> > > Why not j
Bill Mill wrote:
class foo:
def bar(self):
Sorry, I forgot that if it's in the module, you should declare prompt1
as global by using "global prompt1" right here.
print prompt1 % (var1, var2, var3)
No, you only need the global statement if you want to assign to a global variable. Read-on
Execllent.
Many Thanks,
Luke
On Thu, 24 Feb 2005 13:15:41 -0500, Bill Mill <[EMAIL PROTECTED]> wrote:
> On Thu, 24 Feb 2005 13:14:13 -0500, Bill Mill <[EMAIL PROTECTED]> wrote:
> > On Thu, 24 Feb 2005 10:02:44 -0800, Luke Jordan <[EMAIL PROTECTED]> wrote:
> > > Hi all,
> > >
>
On Thu, 24 Feb 2005 13:14:13 -0500, Bill Mill <[EMAIL PROTECTED]> wrote:
> On Thu, 24 Feb 2005 10:02:44 -0800, Luke Jordan <[EMAIL PROTECTED]> wrote:
> > Hi all,
> >
> > I've tried a lot of experimenting and searching through various
> > tutorials, and I haven't been able to come up with a solution
On Thu, 24 Feb 2005 10:02:44 -0800, Luke Jordan <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I've tried a lot of experimenting and searching through various
> tutorials, and I haven't been able to come up with a solution to this,
> ostensibly simple, problem.
>
> I'm writing a simple game (run in com
Hi all,
I've tried a lot of experimenting and searching through various
tutorials, and I haven't been able to come up with a solution to this,
ostensibly simple, problem.
I'm writing a simple game (run in command line) in which narrative
text is printed in response to a user's decisions. The prob