473,386 Members | 1,743 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.

how to pass a function value to another function...?related to kind of error

in this when i am trying to pass the value of new_proj()that is y to the function translate..where test_file=new_proj() its not pass the address to it ...pls tell me the way how to pass it..thanks for the help


Expand|Select|Wrap|Line Numbers
  1. def new_proj():
  2.     x= (r"C:\Documents and Settings\KSR\Desktop\%s")%name_entry.get() 
  3.     if not os.path.exists(x): os.makedirs(x)
  4.     shutil.copy2('C:\Documents and Settings\KSR\Desktop\god.cmd',x)
  5.     y = x+'\god.cmd'
  6.     print x
  7.     return y
  8.  
  9.     def replace_words(text, word_dic):
  10.         rc = re.compile('|'.join(map(re.escape, word_dic)))
  11.         def translate(match):
  12.             return word_dic[match.group(0)]
  13.             return rc.sub(translate, text)
  14.  
  15.             test_file = new_proj()
  16.  
  17.             fin = open(test_file, "r")
  18.             str2 = fin.read()
  19.             fin.close()
  20.  
  21.             word_dic = {
  22.                         'virtex1': 'virtex5',
  23.                         'ff676': 'jhjak'}
  24.  
  25.             str3 = replace_words(str2, word_dic)
  26.  
  27.             fout = open(test_file, "w")
  28.             fout.write(str3)
  29.             fout.close()     
Mar 28 '13 #1
5 1414
Rabbit
12,516 Expert Mod 8TB
Your function definitions need to be on the same indentation level. Also, no code is going to run because it consists only of function definitions.
Mar 28 '13 #2
sir can be more specific ...lyk by doing the edit where i need to make....coz i am facing the problem from a long tym....i am kind of new to programmng nd confusing me a lot...
Mar 30 '13 #3
Rabbit
12,516 Expert Mod 8TB
Python relies heavily on leading white space. I would review the those rules. But in essence the problem is this:

This is wrong.
Expand|Select|Wrap|Line Numbers
  1. def someFunction():
  2.    do something
  3.  
  4.    def otherFunction():
  5.       do something else
  6.  
This is right.
Expand|Select|Wrap|Line Numbers
  1. def someFunction():
  2.    do something
  3.  
  4. def otherFunction():
  5.    do something else
  6.  
Mar 31 '13 #4
its never been the issue but can you tell me how to pass the value of function new_proj....Y to the other function ....the test_file....or with some similar example ....that will be gr8
Apr 2 '13 #5
Rabbit
12,516 Expert Mod 8TB
First you need to fix your white space issues per my original response.
Apr 2 '13 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Satish Chimakurthi | last post by:
Hi all, My question is surely a basic one, but somehow, I am not able to figure it out. I have a python file "satish.py" as follows: *satish.py* def main(): y()
1
by: Foxy Kav | last post by:
Hi everyone, im a first year UNI student doing a programming subject and im stuck on how to get rid of my global variables, char stringarray and char emptystring. I was wondering if anyone could...
39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
2
by: Edlueze | last post by:
Greetings: I have two functions and I would like to pass the ParamArray gathered from one function to the other function. For the purposes of this post, let's say that they are calculating...
4
by: Pushkar Pradhan | last post by:
I want a function to execute another function, which I pass to it, sometimes it may be mm_6r6c_6r6c, mm_2r2c_2r2c, ... etc. thus this style. double exec_basecase(void (*func)(double *a, double...
3
by: manmit.walia | last post by:
Hi, I have a small question...Is there a way to do a postback to the same page and pass a value to a function OnClick? Example: void GetCityName(string c) { string city = c; }
1
denizvb
by: denizvb | last post by:
Hai programmers, Do you know How to write a function inside another function in c
1
by: krishnasamy | last post by:
Hi, I am retrieving the image from DLL through vc++ dll. Actually Image is retrieving in Callback function of main function. When I writing that image file inside of the Callback function then...
3
by: jbanas | last post by:
In MS Access i have a function that is calculating the distance between two locations using the latitude and longitudes for two points assuming the earth is flat and the lat and long are...
4
by: soni2926 | last post by:
hi, is it possible to pass a function into another function as a parameter? Say i have these: function SaveMe(text) {...} function SaveMeNow(text) {...}
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
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.