473,386 Members | 1,745 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,386 software developers and data experts.

Retaining an object

Hello, I have a function which takes a program name, and I'm using
os.popen() to open that program via the syntax: os.popen('pidof var_name',
'r'), but as you know var_name is not expanded within single quotes, I
tried using double quotes, and such, but no luck. I was looking for a way
to have var_name expanded without getting a syntax error by ommiting the
surrounding quotes. I need to use a variable, it's the argument to a
function.

--
A wise man knows he knows nothing.

Aug 10 '05 #1
2 1111
gry
sysfault wrote:
Hello, I have a function which takes a program name, and I'm using
os.popen() to open that program via the syntax: os.popen('pidof var_name',
'r'), but as you know var_name is not expanded within single quotes, I
tried using double quotes, and such, but no luck. I was looking for a way
to have var_name expanded without getting a syntax error by ommiting the
surrounding quotes. I need to use a variable, it's the argument to a
function.


Use the string format operator "%":

var_name='magick'
os.popen('pidof %s' % var_name, 'r')

this results in running:
pidof magick

You should really read through the Python tutorial to get basic stuff
like this:

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

Aug 10 '05 #2
sysfault wrote:
I'm using os.popen() to open that program via the syntax:
os.popen('pidof var_name', 'r'), but as you know var_name is not
expanded within single quotes,


os.popen('pidof %s' % var_name, 'r')
Aug 10 '05 #3

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

Similar topics

2
by: Steven T. Hatton | last post by:
I believe the answer is that the language doesn't support the ability to retain a reference to a std::indirect_array<>, and would be illadvised to try, but I figure I'll ask just to be sure. What...
19
by: jeff | last post by:
how do you convert form byte to Int32 while retaining the binary value of the byte array
1
by: noor | last post by:
Hi I have been working since 2 days to device a method to export sql table into csv format. I have tried using bcp with format option to keep the column names but I'm unable to transfer the file...
2
by: John Kraft | last post by:
I'm attempting to use the context.user object. In my login code, I add an identity to the context.user. I can use the debugger to watch it stuff the identity into the context.user object, but...
5
by: RJ | last post by:
I tried using the Application object to store data in some variables, which would be globally accessible within the web service application code. On subsequent web method calls, the Application...
0
by: loga123 | last post by:
Hi All, I am very new to .net and trying to develop a small application. I am using asp .net 2.0. I have a table control (server) in my code that has header row like this. <asp:Table...
5
by: jung_h_park | last post by:
From: jung_h_park@yahoo.com Newsgroups: microsoft.public.dotnet.framework.aspnet Subject: Dropdown List not retaining its SelectedValue Date: Mon, 26 Jun 2006 21:02:57 -0700 Hello, My...
4
by: triffid | last post by:
Hi, The problem I'm having is that I need to retain Javascript variables across multiple page refreshes. The obvious solution is cookies. However AFAIK, these are always sent to the server in...
3
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
Hi, Trouble in retaining values of dropdownlist, textboxes, and other controls when dropdownlist selectedindexchanged event is triggered, the controls are inside a user control and this user...
2
by: s4lin | last post by:
problem is pagination not retaining data field i have form with general data field, and i need to select some option which is store in database, so i open another page with retrieving data from...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.