Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Raw Input Question

Reply
Thread Tools

Raw Input Question

 
 
hokiegal99
Guest
Posts: n/a
 
      08-27-2003
How can I pass the content of one varible into raw_input? See below for
what I'm trying to do:

XXX = raw_input("1. Enter the string that you'd like to find: ")
y = raw_input("2. Enter the string that you'd like to replace XXX with: ")

I'm trying to pass x into y. I tried the "Enter the string that you'd
like to replace", XXX, "with:" approach, but Pyhton told me that I could
only pass 1 argument, no more.

Thanks!!!

 
Reply With Quote
 
 
 
 
mackstann
Guest
Posts: n/a
 
      08-27-2003
On Tue, Aug 26, 2003 at 10:33:36PM -0400, hokiegal99 wrote:
> How can I pass the content of one varible into raw_input? See below for
> what I'm trying to do:
>
> XXX = raw_input("1. Enter the string that you'd like to find: ")
> y = raw_input("2. Enter the string that you'd like to replace XXX with: ")
>
> I'm trying to pass x into y. I tried the "Enter the string that you'd
> like to replace", XXX, "with:" approach, but Pyhton told me that I could
> only pass 1 argument, no more.


Ah, you are confusing print's behavior for general string concatenation.
I believe what you want to do is:

y = raw_input("2. Enter the string that you'd like to replace "+XXX+" with:")

or

y = raw_input("2. Enter the string that you'd like to replace %s with:" % XXX)

--
m a c k s t a n n mack @ incise.org http://incise.org
As the poet said, "Only God can make a tree" -- probably because it's
so hard to figure out how to get the bark on.
-- Woody Allen

 
Reply With Quote
 
 
 
 
Erik Max Francis
Guest
Posts: n/a
 
      08-27-2003
hokiegal99 wrote:

> How can I pass the content of one varible into raw_input? See below
> for
> what I'm trying to do:
>
> XXX = raw_input("1. Enter the string that you'd like to find: ")
> y = raw_input("2. Enter the string that you'd like to replace XXX
> with: ")
>
> I'm trying to pass x into y. I tried the "Enter the string that you'd
> like to replace", XXX, "with:" approach, but Pyhton told me that I
> could
> only pass 1 argument, no more.


raw_input takes a string, and a string like any other. You can build
the string yourself:

"Enter the string to replace " + XXX + " with:"

or

"Enter the string to replace %s with:" % XXX

--
Erik Max Francis && http://www.velocityreviews.com/forums/(E-Mail Removed) && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ There never was a good war or a bad peace.
\__/ Benjamin Franklin
 
Reply With Quote
 
hokiegal99
Guest
Posts: n/a
 
      08-27-2003
This one makes more sense to me so I used it, it works great:

"Enter the string to replace %s with:" % XXX

Thank you for your help!!!


Erik Max Francis wrote:
> hokiegal99 wrote:
>
>
>>How can I pass the content of one varible into raw_input? See below
>>for
>>what I'm trying to do:
>>
>>XXX = raw_input("1. Enter the string that you'd like to find: ")
>>y = raw_input("2. Enter the string that you'd like to replace XXX
>>with: ")
>>
>>I'm trying to pass x into y. I tried the "Enter the string that you'd
>>like to replace", XXX, "with:" approach, but Pyhton told me that I
>>could
>>only pass 1 argument, no more.

>
>
> raw_input takes a string, and a string like any other. You can build
> the string yourself:
>
> "Enter the string to replace " + XXX + " with:"
>
> or
>
> "Enter the string to replace %s with:" % XXX
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Canon 7D S-RAW/M-RAW Question Paul Furman Digital Photography 4 09-15-2009 09:02 PM
Re: Canon 7D S-RAW/M-RAW Question John McWilliams Digital Photography 2 09-04-2009 10:32 PM
Re: Canon 7D S-RAW/M-RAW Question Arun Digital Photography 0 09-03-2009 03:53 AM
How raw is RAW format? Editor www.nutritionsoftware.org Digital Photography 4 12-22-2003 07:33 PM
RE: Raw Input Question Tony Meyer Python 1 08-27-2003 03:13 AM



Advertisments