LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-18-2011, 06:19 PM   #1
linuxuser111
LQ Newbie
 
Registered: Mar 2011
Posts: 2

Rep: Reputation: 0
Python - string to omit the single quotes (')


After I assign a string to a variable, I know that the print function will remove the single quotes around the value, but is there a way to assign a variable without the quotes around the value?

for example:

a = open('/usr/lib', 'r+')
b = f.read()
c = x.replace('.xx','yy')
d = ?

c returns the value with quotes around it
print c returns the value without the quotes

Is there a way to assign a new variable (d) which will equal c without the quotes? I need a new variable which has the quotes omitted because from there the script will take the value of the last variable (which is a path to a file), and tar up that file. It won't recognize the path to the file if the value has quotes around it.
If not, what's an alternative?

Last edited by linuxuser111; 03-18-2011 at 06:20 PM.
 
Old 03-18-2011, 06:42 PM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: Slackware
Posts: 8,379

Rep: Reputation: 3421Reputation: 3421Reputation: 3421Reputation: 3421Reputation: 3421Reputation: 3421Reputation: 3421Reputation: 3421Reputation: 3421Reputation: 3421Reputation: 3421
Yes.

Code:
d = c
You are confused about what Python is doing. Therefore, please read this:

http://docs.python.org/tutorial/inputoutput.html

Entering "c" in the interpreter prints out the result of repr(c). Entering "print c" in the interpreter prints out the result of str(c).

Last edited by dugan; 03-18-2011 at 06:43 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
X: Unable to open display '' (two single quotes) tgp1994 Debian 7 06-12-2010 12:12 AM
xargs removes single quotes after awk Poki Linux - Newbie 4 06-26-2009 09:25 AM
Variables within single quotes are not evaluated? Akhran Linux - Newbie 1 03-10-2006 08:32 PM
Using single quotes vs double quotes in PHP strings vharishankar Programming 6 07-11-2005 11:41 AM
replacing single quotes in file names adenardo Linux - General 2 05-27-2005 11:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration