Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Variables Python variables     - Android realize RippleEffect water (Programming)

- Eclipse remove all comments and code spaces (Linux)

- Build Golang development environment configuration on Ubuntu 14.04 (Linux)

- Nodejs complete installation instructions for Express (Linux)

- Linux users should be aware that should the 7 ls command unique skills (Linux)

- RHEL / CentOS / Fedora Install Nagios 4.0.1 (Linux)

- Terminal multiplexing tool tmux use (Linux)

- Teach you how to synchronize Microsoft OneDrive in Linux (Linux)

- CentOS 6.6 running level (Linux)

- OpenStack image production in the CentOS 6.2 (Linux)

- Python format string (Programming)

- Realization of Linux operating system illegal IP censorship (Linux)

- How do I cancel (almost) any operations in Git, (Linux)

- CentOS 7.0 Automatic installation CD-ROM production Comments (Linux)

- CentOS yum source as the default setting methods in DVD (Linux)

- Ubuntu achieve initialization iptables (Linux)

- Storm how to assign tasks and load balancing (Programming)

- shell script: the number of characters in the text to print no more than 6 words (Programming)

- Java Cookie Comments (Programming)

- Ceph performance optimization summary (v0.94) (Server)

 
         
  Variables Python variables
     
  Add Date : 2018-11-21      
         
         
         
  Recently wrote a program process of variables encountered a Python variable is the value of a variable, or variable, and then I want to take the final value, thanks to the great google, wrote this article under record. First on the code:

#! / Usr / bin / env python
# Encoding = utf-8

import inspect
import ConfigParser

confPath = "/ home / linuxidc / config / config"

def modify_config (domain_name, app_type, port, if_api, vip, svn, svnver, yfb_ip, cron_ip, hosts, hostname, if_cas_oa, if_session, if_nginx, check_apps_dir, health_check):
    if vip is None:
        vip = ""
    if yfb_ip is None:
        yfb_ip = ""
    if cron_ip is None:
        cron_ip = ""
    if hosts is None:
        hosts = ""
    if if_cas_oa is None:
        if_cas_oa = ""
    if if_session is None:
        if_session = ""
    # Updates the specified section, the value of the option
    conf = ConfigParser.ConfigParser ()
    conf.read (confPath)
    ### Inspect.getargspec this role is to take the function's parameter list
    arg_list = inspect.getargspec (modify_config) .args
    ### Following the second argument conf.set I just want to take arg value, and the third would like to take arg parameter value of a variable value, because the value of arg is itself a function of the parameters modify_config
    for arg in arg_list:
        conf.set ( "online", arg, locals (). get (arg))
    conf.write (open (confPath, "w"))

if __name__ == '__main__':
    domain_name = "www.linuxidc.com"
    app_type = "osp"
    port = "8081"
    if_api = "1"
    vip = "192.168.0.1"
    svn = "https://svn.tools.linuxidc.com/svn/"
    svnver = "24562"
    yfb_ip = "192.168.0.1"
    cron_ip = "192.168.0.2"
    hosts = "www.linuxidc.com"
    hostname = "JD-linuxidc-COM"
    if_cas_oa = "0"
    if_session = "mcs2"
    if_nginx = "1"
    check_apps_dir = "0"
    health_check = "_health_check"
    modify_config (domain_name, app_type, port, if_api, vip, svn, svnver, yfb_ip, cron_ip, hosts, hostname, if_cas_oa, if_session, if_nginx, check_apps_dir, health_check)
     
         
         
         
  More:      
 
- C # function (Programming)
- Android Send HTTP POST requests (Programming)
- Oracle archive log full cause abnormal slow database performance (Database)
- Why you should choose Python Programming (Programming)
- Archlinux installation tutorial (Linux)
- Ant command-line compiler Android project (Programming)
- tespeed - test speed of Python tools (Linux)
- Ubuntu 15.04 / 14.04 install Ubuntu After Install 2.6 (Linux)
- How to find the available network adapter on Ubuntu (Linux)
- CentOS 6.4 (64bit) install Python 2.7.5 (Linux)
- Create the best introductory tutorial REST API (Linux)
- To install Samba server on CentOS 6.6 (Server)
- When Linux Detailed time zone and common function of time (Linux)
- tcpdump Linux system security tools (Linux)
- To install Python-Pip and Fabric under CentOS / Ubuntu (Linux)
- 10046 trace only open for a particular SQL statement (Database)
- Java string concatenation techniques (StringBuilder tips) (Programming)
- CentOS 6.5 installation using a data recovery software extundelete (Linux)
- RHEL5 stalled due to power service error system can not start (Linux)
- MySQL how to export files with the date format (Database)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.