473,769 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[NooB] a Variable in multiple quotes...

Is it possible?

I tried...
I = "John"
print \
"""
I used to love pizza"""
Error occurs!!!

But, I don't know how to fix... HELP

thx 4 reading.
Jul 18 '05 #1
7 1750
It's OK for me
@-salutations
--
Michel Claveau
Jul 18 '05 #2
administrata wrote:
Is it possible?

I tried...

I = "John"
print \
"""
I used to love pizza"""
Error occurs!!!


No error occurs; it prints "I used to love pizza", as would be expected.

Oh: from the subject line, I'm guessing that you want it to say "John
used to love pizza" instead? In that case, try doing this:

I = "John"
print "%s used to love pizza" % I
Jul 18 '05 #3
administrata wrote:
Is it possible?

I tried...
I = "John"
print \
"""
I used to love pizza"""
Error occurs!!!

But, I don't know how to fix... HELP

thx 4 reading.


Point 0: It helps if you post a copy of what the actual screen display
looked like, instead of just saying "Error occurs!!!".

It helps in that people are more likely to be bothered helping you,
instead of just writing you off as clueless and unclueable -- and as
you have chosen to try Python, you can't be utterly beyond redemption
:-)

Point 1: So, which error? Let's guess:

You got something like this:

! print \
! ^
!SyntaxError: invalid token

If so, that is very likely because you had one or more spaces after the
\. Backslash means line-continuation only if it is the LAST character
in the line.

If not, see point 0.

Point 2: so-called multiple quotes: this is nothing to do with your
problem. The different ways of quoting differ only in what characters
like other quotes and newlines can appear inside the quotes.
'I am John' is """I am John""" True

Point 3: To print using what you call variables:
I = 'John'
print I, 'used to ...' John used to ... print '%s used to ...' % I John used to ... I = 'Fred'
print '%s used to ...' % I Fred used to ... print I, 'used to ...' Fred used to ...
Point 4: How far through the Python tutorial have you progressed?

Point 5: If some bright spark suggests something like the following,
ignore them until you are up to speed on points[:5]:
print '%(I)s used to ...' % locals()

Fred used to ...

Point 6: If you don't understand the meaning of [:5], refer to point 4.

HTH,

John

Jul 18 '05 #4
You know, it's really not necessary for you to put "[NooB]" in the subject
of your posts. This is a fairly friendly group and they will answer even
newbie questions amicably. But if you want an even kinder, gentler place to
ask questions as a newbie (not a noob), I suggest the Tutor mailing list:

http://mail.python.org/mailman/listinfo/tutor
--
Michael Hoffman
Jul 18 '05 #5
Michael Hoffman wrote:
This is a fairly friendly group and they will answer even
newbie questions amicably.


Albeit with the occasional pointed comment about not at least skimming the
tutorial when it covers the question asked ;)

Cheers,
Nick.

--
Nick Coghlan | nc******@email. com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net
Jul 18 '05 #6
Leif K-Brooks <eu*****@ecritt ers.biz> wrote in message news:<37******* ******@individu al.net>...
administrata wrote:
Is it possible?

I tried...

I = "John"
print \
"""
I used to love pizza"""
Error occurs!!!


No error occurs; it prints "I used to love pizza", as would be expected.

Oh: from the subject line, I'm guessing that you want it to say "John
used to love pizza" instead? In that case, try doing this:

I = "John"
print "%s used to love pizza" % I


How can I do it with several variables?

About 10 or more...

HELP plz :)
Jul 18 '05 #7
"administra ta" wrote:
Oh: from the subject line, I'm guessing that you want it to say "John
used to love pizza" instead? In that case, try doing this:

I = "John"
print "%s used to love pizza" % I


How can I do it with several variables?

About 10 or more...


two:

print I, "used to love", J

or

print "%s used to love %s" % (I, J)

three:

print I, "used to", J, K
print "%s used to %s %s" % (I, J, K)

five:

print I, J, "to", K, L, M
print "%s %s to %s %s %s" % (I, J, K, L, M)

(you get the idea)

for more on this, and some variations, read the "fancier output
formatting" chapter in the tutorial again:

http://docs.python.org/tut/node9.html

(you've read the tutorial before, right?)

</F>

Jul 18 '05 #8

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

Similar topics

6
1688
by: Igorati | last post by:
Ok, this is what I have so far: #This program will ask for a user to imput numbers. The numbers will then be calculated #to find the statistical mean, mode, and median. Finallly the user will be asked #if he would like to print out the answers. list = a = 1 print 'Enter numbers to add to the list. (Enter 0 to quit.)'
10
2136
by: Matt Hollingsworth | last post by:
Hello, Very new to python, so a noob question. When I've written stuff in JavaScript or MEL in the past, I've always adopted the variable naming convention of using a $ as the first character (no, I don't use perl, never have). Not possible in python. What are some good options that people commonly use so that they can easily and quickly identify variable with just a glance? When I was writing stuff in SoftImage XSI/JScript, many of...
5
1748
by: Tony Vasquez | last post by:
Hi fellas. I have a problem. I am trying ot get a popup window to appear in the center of the screen, both vertically and horozontally. I am trying to display a large version of an image in this window... but the image size varies. I now have to know the size of the image before I can center it properly. So, this is the code I am using. fnFullView = function () { var _mediumLargeImage = new Image(); _mediumLargeImage.src =...
7
4297
by: Richard Hollenbeck | last post by:
Help! I don't know why this isn't working: Private Sub Combo9_Change() Dim UsersCourseSelection As String UsersCourseSelection = Me("Combo9").Value Combo13.Visible = True 'the following SQL thing is all on one line in the actual code.
9
3181
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I want to be able to draw lines in a picturebox based upon certain data points I have received. I dragged a picturebox from the toolbar onto my form, but after having gone through the help files, looking online and trying a variety of things, I...
27
10126
by: user | last post by:
Have require file with several query stings in it. Depending on user input one of strings is selected. Everything going along smoothly until I wanted to also input a variable in string. If I put string in program works ok, but, if I use string from require file I can not seem to insert string. $cccb_id is sting..... to be inserted into $query4 and changes depending on user input.
8
1584
by: hiro | last post by:
Hi there, I'm very new to python, the problem I need to solve is whats the "best/ simplest/cleanest" way to read in multiple files (ascii), do stuff to them, and write them out(ascii). -- import os filePath = ('O:/spam/eggs/')
6
1634
by: Lang Murphy | last post by:
I'm baaaaack... some of you answered a question I had last week. Only problem is: I'm a dope who doesn't understand most of what y'all posted. Raw noob when it comes to .Net and C#. So I'm going to be more specific... All I need to do at the moment is figure out how to replace our usage of .ini files as configuration files for our small, utility type apps. I'm not looking to use XML as a data stream or anything like that. Not right now,...
3
1405
by: waltvw | last post by:
I'm trying to set up a value for a control on the report and part of the path should be a variable, since I have multiple objects like that. So when I try to put a variable I'm getting the "Compile Error: Syntax Error" message and don't know how to handle it. Reports!rptFlgTest!"& strFieldName &" = -1 I've tried to put single quotes around double ones as well as not to use any; or not to use ampersands while having either single quotes or...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9994
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7409
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5299
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3959
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.