Tagged Questions
1
vote
2answers
81 views
Function with excessive arguments - Python
,I am currently creating a genetic fuzzy learning system and it's corresponding training simulation environment-> this collection of functions and classes is controlled by a master script where the ...
-3
votes
1answer
66 views
two dictionaries, making a list
Alright so this is a bit complicated. I have a function that accepts two dictionary parameters created via txt files that have already been returned in other functions. The countries parameter has a ...
0
votes
1answer
40 views
Passing in Global Variables in Python
I am a somewhat experienced Java programmer who is re-implemting some code in Python, as I am just learning the language. The issue that I am having is that a method is returning nothing when I pass ...
1
vote
3answers
30 views
arguments for subsequent call of function in python
Hi I am new to python. Can someone explain how the below two pieces of code give different outputs? Does the function gets defined each time it is called?
def f(a, L=[]):
L.append(a)
...
3
votes
6answers
83 views
Function changes list values and not variable values in Python
Let's take a simple code:
y = [1,2,3]
def plusOne(y):
for x in range(len(y)):
y[x] += 1
return y
print plusOne(y), y
a = 2
def plusOne2(a):
a += 1
return a
print ...
0
votes
1answer
31 views
Python function returns None (all trivial solutions checked and they do not work)
Now, I have written a binary search for Python (version 2.7). Sometimes, it works just fine, but at other times it returns None although the searched value is in the array. I have tried every trivial ...
3
votes
1answer
18 views
Tkinter button command with different arguments
I'm trying to create a few buttons (with a for) like so:
def a(self, name):
print name
users = {"Test":"127.0.0.0", "Test2":"128.0.0.0"}
row = 1
for name in users:
user_button = ...
-6
votes
5answers
128 views
How can I keep track of equivalent functions in different programming languages?
Right now, I'm trying to find a way to keep track of equivalent functions in different programming languages, so that I can find out which function in one language is equivalent to the same function ...
0
votes
2answers
62 views
The Python assignment operator, function definitions, and variable definitions
Well... I was having a terrible time getting part of my code working, but I rearranged things and it suddenly started working correctly. Not sure what I did to be honest, so I guess that will be the ...
0
votes
1answer
18 views
Using imported modules within an imported function
I have a script which runs as a standalone program, however I'd like to be able to use it as a callable function as well. Currently when i try and run it from another script, i get errors saying that ...
2
votes
1answer
27 views
Python binary search function from OCW
I have a question regarding the Python binary search algorithm as presented in the following MIT OCW lecture:
...
2
votes
6answers
68 views
Trying to make a python dictionary from a file but I keep getting errors like 'too many values to unpack'
I have a text file saved in notepad but moved into my python folder that has a three letter acronym for a country on the left and then about four or five spaces to the right it has the country that ...
0
votes
3answers
130 views
Multiple Value Return Pattern in Python (not tuple, list, dict, or object solutions)
There were several discussions on "returning multiple values in Python", e.g.
1,
2.
This is not the "multiple-value-return" pattern I'm trying to find here.
No matter what you use (tuple, list, ...
0
votes
3answers
39 views
Python - How to allow the use of a function in different modules?
I have 2 scripts.
Main.py
Update.py
I have a function in Main.py which basically does the following:
def log(message):
print(message)
os.system("echo " + message + " >> /logfile.txt")
...
0
votes
3answers
74 views
how do i fix a “NameError: name 'thing' is not defined” when calling a function ?
i am learning python from code academy, and i'm trying to complete their review assignment.
I am supposed to define a function, and then set up a if/else loop to check the type of input i get, and ...