Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 98165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:08:38+00:00 2026-05-11T00:08:38+00:00

When I pass the options in the program (a computational biology experiment) I usually

  • 0

When I pass the options in the program (a computational biology experiment) I usually pass them through a .py file.
So I have this .py file that reads like:

starting_length=9 starting_cell_size=1000 LengthofExperiments=5000000 

Then I execute the file and get the data. Since the program is all on my machine and no one else has access to it, it is secure in a trivial way.
I can also write a similar file very easily:

def writeoptions(directory):     options=''     options+='starting_length=%s%s'%(starting_length,os.linesep)     options+='starting_cell_size=%s%s'%(starting_cell_size,os.linesep)     options+='LengthofExperiments=%s%s'%(LengthofExperiments,os.linesep) ...     open('%s%soptions.py'%(directory,os.sep),'w').write(options) 

I want to pass a function as one of the parameters:

starting_length=9 starting_cell_size=1000 LengthofExperiments=5000000  def pippo(a,b):     return a+b functionoperator=pippo 

And of course in the real experiment the function pippo will be much more complex. And different from experiment to experiment.

But what I am unable to do is to write the function automatically. In short I don’t know how to generalise the writeoptions function to keep on writing the options, if one of the options is a function. I could of course copy the original file, but this is inelegant, inefficient (because it contains a lot of extra options that are not being used), and generally does not solve the question.

How do you get python to write down the code of a function, as it writes down the value of a variable?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T00:08:38+00:00Added an answer on May 11, 2026 at 12:08 am
     vinko@mithril$ more a.py  def foo(a):   print a  vinko@mithril$ more b.py  import a import inspect  a.foo(89) print inspect.getsource(a.foo)  vinko@mithril$ python b.py 89 def foo(a):   print a  
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using boost::program_options and want to pass domain-like options to my program. Such
I have a completely non-interactive python program that takes some command-line options and input
I have a GNU C++ program and a python script that need to pass
i have written this python program. whenever i run the script using parameters like
I have a program like this: it compiles files in memory and then executes
I am using boost::program_options like this: namespace po = boost::program_options; po::options_description desc(Options); desc.add_options() (help,?,
when using gprof: $ gprof options [executable-file [profile-data-files...]] [> outfile] if you have options
I have a method that has a few pointers as parameters. This method can
I have a running program that uses glVertexPointer, glNormalPointer etc to draw a large
I would like to pass the noconstant option from a wrapper program to an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.