473,396 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Variables.

I wrote this, It's a bit lame though

I = "Allen"
me = "Allen"
my = "Allen's"

print \
"""
%s woke up early in the morning. But, it was unusal by %s. %s pillow
was with %s. %s didn't want to wake up But, %s tried my best and woke up.
it was so amazing!""" % (I,me,my,me,I,I)

raw_input("\n\\t\t\t- The End -")

But it looks like this...

Allen woke up early in the morning. But, it was unusal by Allen.
Allen's pillow
was with Allen. Allen didn't want to wake up But, Allen tried my best and woke up.
it was so amazing

- The End -

HELP plz
Jul 18 '05 #1
9 1204
On 15 Feb 2005 04:29:26 -0800, rumours say that ad**********@hotmail.com
(administrata) might have written:
I wrote this, It's a bit lame though

I = "Allen"
me = "Allen"
my = "Allen's"

print \
"""
%s woke up early in the morning. But, it was unusal by %s. %s pillow
was with %s. %s didn't want to wake up But, %s tried my best and woke up.
it was so amazing!""" % (I,me,my,me,I,I)

raw_input("\n\\t\t\t- The End -")

But it looks like this...

Allen woke up early in the morning. But, it was unusal by Allen.
Allen's pillow
was with Allen. Allen didn't want to wake up But, Allen tried my best and woke up.
it was so amazing

- The End -
It looks exactly how it should, based on what you gave it.

Try the following changes:
I = "Allen"
me = "Allen"
my = "Allen's"
to

xyzzy = "I"
footy = "me"
spike = "my"

and then change the last line of the triple-quoted string:
it was so amazing!""" % (I,me,my,me,I,I)
to

it was so amazing!""" % (xyzzy,footy,spike,footy,xyzzy,xyzzy)

Let us know what you expect to print after these changes.
HELP plz


By all means --what's the problem exactly?
--
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...
Jul 18 '05 #2
On Tue, 15 Feb 2005 04:30:30 -0800 (PST), administrata
<ad**********@hotmail.com> wrote:
I wrote this, It's a bit lame though

I = "Allen"
me = "Allen"
my = "Allen's"

print \
"""
%s woke up early in the morning. But, it was unusal by %s. %s pillow
was with %s. %s didn't want to wake up But, %s tried my best and woke up.
it was so amazing!""" % (I,me,my,me,I,I)
One thing that you might want to do is to use a dictionary to provide
the values, like so:

my_values = {"I": "Simon", "me": "Simon", "my": "Simon's"}

print """%(I)s woke up early in the morning. But, it was unusal by
%(me)s. %(my)s pillow
was with %(me)s. %(I)s didn't want to wake up But, %(I)s tried my best
and woke up.
It was so amazing!""" % my_values
raw_input("\n\\t\t\t- The End -")

But it looks like this...

Allen woke up early in the morning. But, it was unusal by Allen.
Allen's pillow
was with Allen. Allen didn't want to wake up But, Allen tried my best and woke up.
it was so amazing

- The End -


What did you *expect* it to do?

--
Cheers,
Simon B,
si***@brunningonline.net,
http://www.brunningonline.net/simon/blog/
Jul 18 '05 #3
administrata wrote:
I wrote this, It's a bit lame though
(snip code - see other answers in this thread)
raw_input("\n\\t\t\t- The End -")
Why on earth are you using raw_input() here ?

HELP plz


No one can help you if you don't explain your problem. We are not
psychic enough to read your mind !-)

(and please : avoid SCREAMING and l33t speak too...)

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Jul 18 '05 #4
bruno modulix wrote:
administrata wrote:
I wrote this, It's a bit lame though

(snip code - see other answers in this thread)
raw_input("\n\\t\t\t- The End -")

Why on earth are you using raw_input() here ?


This is a fairly common idiom, on Windows at least. If running a
console app from Explorer, the console will close as soon as the app
terminates. Using raw_input() at the end of the app means that it
won't close until the user hits Enter.
HELP plz


No one can help you if you don't explain your problem. We are not
psychic enough to read your mind !-)


Indeed -- it looks like this worked perfectly to me, so the issue is
in what's expected. :)

Jeff Shannon
Technician/Programmer
Credit International

Jul 18 '05 #5
Jeff Shannon a écrit :
bruno modulix wrote:
administrata wrote:
I wrote this, It's a bit lame though
(snip code - see other answers in this thread)
raw_input("\n\\t\t\t- The End -")


Why on earth are you using raw_input() here ?

This is a fairly common idiom, on Windows at least.


Windows only, I guess...
If running a
console app from Explorer, the console will close as soon as the app
terminates. Using raw_input() at the end of the app means that it won't
close until the user hits Enter.


So why dont you just open the console before running the app, then ?-)

Bruno
Jul 18 '05 #6
Bruno Desthuilliers wrote:
Jeff Shannon a écrit :
If running a console app from Explorer, the console will close as soon
as the app terminates. Using raw_input() at the end of the app means
that it won't close until the user hits Enter.


So why dont you just open the console before running the app, then ?-)


Well, *I* generally do. ;) But for those with relatively little
computing experience that *hasn't* been through the Windows GUI, the
thought of opening a console isn't necessarily an obvious one.
(Modern versions of Windows seem to try to hide the console as much as
they can....)

Jeff Shannon
Technician/Programmer
Credit International

Jul 18 '05 #7
sry, I mean the problem is... about lining

it doesn't look like this...

Allen woke up early in the morning. But, it was unusal by Allen.
Allen's pillow was with Allen. Allen didn't want to wake up But, Allen
tried my best and woke up. it was so amazing
Jul 18 '05 #8
administrata wrote:
sry, I mean the problem is... about lining

it doesn't look like this...

Allen woke up early in the morning. But, it was unusal by Allen.
Allen's pillow was with Allen. Allen didn't want to wake up But, Allen
tried my best and woke up. it was so amazing


In the future, please follow the advice given on this page:

http://www.catb.org/~esr/faqs/smart-questions.html

Also, consider joining the tutor mailing list.

http://mail.python.org/mailman/listinfo/tutor

For this problem, see the textwrap module in the standard library.

http://docs.python.org/lib/module-textwrap.html

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
Jul 18 '05 #9
On Wednesday 16 February 2005 03:34 am, administrata wrote:
sry, I mean the problem is... about lining

it doesn't look like this...

Allen woke up early in the morning. But, it was unusal by Allen.
Allen's pillow was with Allen. Allen didn't want to wake up But, Allen
tried my best and woke up. it was so amazing
--
http://mail.python.org/mailman/listinfo/python-list


In a triple-quoted string, newlines are significant.

Compare:

my_text1 = """ .... first line of text
.... second line of text
.... third line of text
.... """
my_text2 = ("first line of text " .... "second line of text "
.... "third line of text")
print my_text1
first line of text
second line of text
third line of text
print my_text2 first line of text second line of text third line of text


Note that strings that appear together without punctuation are concatenated
*before* byte-compiling, whereas using "+" creates code to concatenated the
strings. This will rarely matter, but it means that the idiom above is completely
equivalent to a long string on a single line, which is probably what you wanted.

You need the parentheses to tell Python that the expression is not complete,
so it won't throw a syntax error when you go to the next line.

There are also more sophisticated ways of processing text, of course -- study the
"textwrap" module, for example.

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks http://www.anansispaceworks.com

Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Hal Vaughan | last post by:
First, I am aware of both SwingUtilities.invokeLater(), and of using Thread to create a new thread.  These are part of the problem. I want to have something running in the background, while the...
4
by: Torsten Bronger | last post by:
Hallöchen! I have a file that looks a little bit like a C header file with a long list of variables (actually constants) definitions, e.g. VI_ATTR_TIMO = 0x54378 .... Actually I need this...
1
by: mark4asp | last post by:
What are the best methods for using global constants and variables? I've noticed that many people put all global constants in a file and include that file on every page. This is the best way of...
5
by: Ross A. Finlayson | last post by:
Hi, I'm scratching together an Access database. The development box is Office 95, the deployment box Office 2003. So anyways I am griping about forms and global variables. Say for example...
7
by: Michael | last post by:
Hi newsgroup, as the subject indicates I am looking for an advice using global variables. I am not if this problem is more about style then C. If its wrong in thi group, sorry. So I have a...
9
by: CDMAPoster | last post by:
About a year ago there was a thread about the use of global variables in A97: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157 Best Practices by Kang...
7
by: misha | last post by:
Hello. I was wandering if someone could explain to me (or point to some manual) the process of mapping the addresses of host variables by DB2. Especially I would like to know when DB2 decides to...
5
by: Sandman | last post by:
I dont think I understand them. I've read the section on scope in the manual inside out. I'm running PHP 5.2.0 Here is the code I'm working on: //include_me.php <?php $MYVAR = array(); global...
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
4
by: icarus | last post by:
global_vars.py has the global variables set_var.py changes one of the values on the global variables (don't close it or terminate) get_var.py retrieves the recently value changed (triggered right...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.