0
votes
1answer
29 views

Calling variables in a send_email call in Python

I'm trying to make it so that the body of the text of the email includes a lot of variables I declared earlier in a class: title_text = ' Has Been Ordered' title = instance.product ...
-1
votes
3answers
42 views

append integer to beginning of list in python

I have an integer and a list. I would like to make a new list of them beginning with the variable and ending with the list. Writing a + list I get errors. The compiler handles a as integer, thus I ...
0
votes
1answer
23 views

In SPSS Python essentials, can I get the value of an SPSS variable returned to Python for further use?

I have a database where each case holds info about handwritten digits, eg: Digit1Seq : when in the sequence of 12 digits the "1" was drawn Digit1Ht: the height of the digit "1" Digit1Width: its ...
0
votes
1answer
29 views

BeautifulSoup. Find and replace all instances of a word with one from my list

I have a dictionary. The key is animals. The value is a list of different animals. The size of the list and what the animals are will change with each application use. For each animal in the list I ...
0
votes
0answers
30 views

Why wont my python thread react to global variables

This code is to start and stop multiple copies of various different thread types. I will preface this with saying I tried using pipes to control the threads but keep getting random memory errors to do ...
0
votes
2answers
53 views

Understanding Python variables assignment [duplicate]

If I execute this code: a = [1,2,3] b = a b.remove(2) print(a,b) What I expect to see is: [1,2,3] [1,3] But this is what I really get: [1,3] [1,3] Why calling b.remove(2) also affects a? What ...
0
votes
1answer
9 views

Scope to be used for editting Python Variables' syntax in Default Color Scheme's .tmTheme file

I think there are more sophisticated ways to do change syntax highlighting, which I am unable to follow very at this time. Hence I tried, what I thought was a simpler way i.e. by modifying one of the ...
0
votes
2answers
16 views

Python 3 Include Custom File with Variables

How to include external config file with variables and use them in python script ? Python Variables File: (auth.txt) Username = 'username_here' Password = 'password_here' Python Script (test.py) ...
1
vote
1answer
31 views

Python 3 Print Variables

Is there a better way to print set of variable in python3 ? In PHP I useally did something like this: echo "http://$username:$password@$server:$port" But in python 3 it looks very ugly and longer to ...
2
votes
1answer
45 views

Jinja2 and Flask: Pass variable into parent template without passing it into children

Let's say I have a base template with a header in it, and the content of that header needs to be passed into the template. <header> You are logged in as {{ name }} </header> This base ...
0
votes
1answer
44 views

Pass variables from one script to another and save to file every X minute(s)

I have spent hours pouring through other questions and have not been able to find a solution to my problem. I have a program that calls my python script with an argument at certain events. Basically ...
2
votes
3answers
45 views

Using a text file to receive a string for a variable in Python, without defining it

I have a text file in which there are several variables. Most of them are used in a Bash script of mine, but I'd like to use the same text file for my Python script. For the lines that are not ...
2
votes
2answers
64 views

Defining variables in a for loop

I'm trying to define k variables looking like x1, x2, ...xn, where each is a list (each list has 5 elements). meaning: something like this: for i in [1..100]: "x" + str(i) = [ i + ...
1
vote
1answer
24 views

How to deal with global parameters in a scientific Python script

I am writing a piece of scientific software in Python which comprises both a Poisson equation solver (using the Newton method) on a rectangular mesh, and a particle-in-cell code. I've written the ...
0
votes
2answers
32 views

how to create nicer variable interface in python class

I want a variable to do more than just be set when I set it. and the interface to be as clean as possible. short: what I'd want: # have class with a variable that I can access: print myInstance.var ...
0
votes
1answer
32 views

How to streamline this script

I have this script and it does work it has 2 separate processes that spawn listener threads to kill the process when kill is sent to the listener via a pipe. from multiprocessing import Process, ...
3
votes
6answers
94 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 ...
2
votes
5answers
96 views

How to create an unknown amount of variables in python

I am making a program that reads a spread sheet. For each column, my program creates a list of all the values in each row of that column. To decide how many lists I need, I have the variable ...
0
votes
1answer
28 views

Referencing a RegEx Variable

I'm using python to loop through a large list of self reported locations to try to match them to their home states. The RegEx expression I'm using is: /^"[^\s]+,\s*([a-zA-Z]{2})"$/ Basically, I'm ...
2
votes
1answer
48 views

Using Python in vimscript: How to export a value from a python script back to vim?

I'm struggling with Python in vim. I still haven't found out how I can import a value from a python script (in a vim function) back to vim p.e. function! myvimscript() python << endpython ...
0
votes
5answers
59 views

python: how to evaluate items in a list

This is probably pretty simple, but I have a list with strings that also correspond to variable names: listname = ['name1', 'name2," ... ] name1 = "somestring" name2 = "some other string" What I'd ...
0
votes
2answers
26 views

Python Error: local variable referenced before assignment

Here is my code: import time GLO = time.time() def Test(): print GLO temp = time.time(); print temp GLO = temp Test() Traceback (most recent call last): File "test.py", line ...
-2
votes
1answer
56 views

python replace records in variable [closed]

I have: x = "abcdefghi", and I want to replace record from that variable with another record. for example: x = "abcdefghi" x.replace(x[1], x[1+2]), and I want to do a such thing to all records in ...
-4
votes
1answer
38 views

Python UnbounLocalError : local variable “xxx” referenced before assignment

it's a merge-sort algorithm in python def MERGE_SORT(A, p, r): if p < r: q = int((p+r)/2) MERGE_SORT(A, p, q) MERGE_SORT(A, q+1, r) MERGE(A, p, q, r) def MERGE(A, p, q, ...
0
votes
2answers
28 views

Python - pass members of global variable to function, still make changes

I have the following code: USERS = None class User(object): name = "" jobs = [] def __init__(self, name, jobs): self.name = name self.jobs = jobs def main(): ...
3
votes
1answer
39 views

Can I get a list of the variables that reference an other in Python 2.7?

Imagine I have: X = [0,1] Y = X Z = Y Is there a function like referenced_by(X) that returns something like ['Y', 'Z']? And a function like points_to(Y) that returns 'X'? I know there is is to ...
0
votes
3answers
34 views

Function variable scope in python

let's say we have two functions: def ftpConnect(): ftp = FTP('server') ftp.login() ftp.cwd('/path') def getFileList(): ftpConnect() files = ftp.nlst() print(files) If I ...
0
votes
1answer
31 views

Multiple input of same variable in a line Python

I am trying to create a loop for python to create a variable of different input values. I want to input 3 different words into the name variable. This is my code: name = raw_input("What is your ...
0
votes
1answer
35 views

python/bash variable expansion in for loop for json array

Here is my problem. I have the following bash snippet: #!/bin/bash R1=$(cat $HRESULTPATH/KEYLIST.OUT|grep "$KEYCHAIN") H1=$(echo $R1|tr -d [[:space:]]) O1=$(echo $H1|tr -d '\"') S1=$(echo ...
0
votes
1answer
34 views

UnboundLocalError: local variable 'player' referenced before assignment

I was trying to do some code when I spotted this error. I first define the player class with a name a param1 and param2. When I run the game function and i try to create an instance of the player ...

1 2 3 4 5 29
15 30 50 per page