So I have the following code
base = "INSERT INTO " + table + " ("
lineCount = 0
tableFieldNames = dataArray['titleRow']
**for titleRow as tableFieldNames:**
if some_list[-1] == titleRow:
base = base + titleRow
else:
base = base + titleRow + ","
base = base + ") VALUES "
where the bolded part gives an error "Invalid Syntax" and pypex's eclipse plugin gives a bit more verbose "Excepted:in" for the bolded text. What is throwing me is what that refers too. I've included a : at the end of the for loop declaration, and the array that it refers too is valid. Plus I have a for loop after this block of code that gives no such strange error.
Has anyone ran into such a thing, and found a way to resolve it (and even to make the parse errors more verbose?)
It should be for titleRow in tableFieldNames: (in, not as).
Related
I am trying to create a macro on Fiji (ImageJ). I cannot find how to introduce a user input. I want to sum a stack with z project. Each sum is the result of 10 stacks. But the start is not the same. It varies between 1 and 11. So it would be fine when the user choose a startpoint. when the file is saved, the filename should contain the start and endpoint. So I know some weeks later which stacks I used. Thanks for some hints!
imageTitle=getTitle();
path = "D:/test/";
first = Dialog.getChoice();
// first = 8;
last = first+9;
selectWindow(imageTitle);
run("Z Project...", "start=first stop=last projection=[Sum Slices]");
run("Red");
saveAs("Tiff", path+"SUM_"+imageTitle+"("+first+last+")";
I get the error message:
"No dialog created with Dialog.create() in line 3:
first = Dialog.getChoice> () ;
When I didnt choose the start I get the error message:
" ')' expected in line 9:
saveAs ( "Tiff" , path + "SUM_" + imageTitle + "(" + first + last + ")" <;>
Below is the function
def lldp(client1):
stdin, stdout, stderr = client1.exec_command('show lldp neighbor interface' + " " + q[0] + " " + '| match add')
z = stdout.read()
A = z.split()
A = A[9]
print A
if A == ':':
sys.exit()
return
Variable A will be assigned with some value and when i call this function into another script like below
lldp(client1)
I am getting below error.
NameError: name ‘A’ is not defined.
Tried defining as global A inside function still on luck
Tried return A still no luck.
I am able to figure out.
return A missing in function and in script A = lldp() is missing.
working now.
Suppose I have a URI parameter with value, which contains plus signs (+) and other special chars.
When I execute URI::setQueryParameters and then URI::getQueryParameters, the resulted value is not the same as the original one - all special chars are fine, except the plus sign.
Could you, please, advice what is the conventional way to do this?
Workaround: explicitly invoke URI::encode with reserved containing plus sign. But this doesn't seem to be right, it really looks like a workaround.
Anyway, if this is the correct way to achieve this, what symbols should I include in reserved, if I want to avoid such surprises in the future?
Other observations: URI::decode has a parameter named plusAsSpace (defaulted to false), but this does not help. URI::getQueryParameters replaces + with (space) before calling URI::decode.
Here's a sample code:
const std::string value_with_plus_signs = "value+with+plus+signs";
Poco::URI::QueryParameters out_params;
out_params.push_back(std::make_pair("param", value_with_plus_signs));
Poco::URI uri("path");
uri.setQueryParameters(out_params);
const auto in_params = uri.getQueryParameters();
std::cout << "Expected: '" << value_with_plus_signs << "', received: '"
<< in_params.front().second << "'" << std::endl;
output: Expected: 'value+with+plus+signs', received: 'value with plus signs'
It seems this was fixed in Poco (notice that '+' is added to the symbols that are encoded by default):
https://github.com/pocoproject/poco/issues/1260
https://github.com/pocoproject/poco/commit/c32e683b6c00950ddfce817dfe8f3fc0b6846455
I tested your code with poco 1.7.9p2 and I got the correct results.
I would like to ask about the if else expression in ireport jasper report. May I know is it possible to have multiple or more parameter in the if else statement?
(($P{endDate}.isEmpty()==true || $P{endDate}.equals(""))? "" :
" createDate>='" + $P{startDate} +"'" && " createDate<='" + $P{endDate} +"'")
Based on the code above, there are not allowed me to use "&&". It prompt out syntax error.
Besides that, May I know any solution to solve it? Thank you very much.
I'm assuming it's a query expression your trying to write. You probably would have to do something as follows:
Create a parameter for your dataset. This parameter should not be "prompted" and lets call it DATE_LIMIT_EXPRESSION. You should then set its default value as your expression. For example (if I a get what you meant), this could be your default expression:
"1" +
(($P{startDate}.isEmpty() == false) ? (" AND createDate >= " + $P{startDate}) : "") +
(($P{stopDate}.isEmpty() == false) ? (" AND stopDate <= " + $P{stopDate}) : "")
Now, your dataset query should be something like:
select
...
where $P!{DATE_LIMIT_EXPRESSION}
Just notice the "$P!" syntax. You can find more information about this in the Jasper Reports' documentation.
I am using a for loop for getting data from the user in command prompt using python 2.7. Then storing the data in a text file in certain format. I am looking for a method to get the data from the user and store it in a list and use it where required.
for Input_Number in range(Number_Of_Inputs):
Input_Number = Input_Number+1
GUI_Parameter = str(raw_input("Please enter input parameter " + str(Input_Number) + " :"))
GUI_Parameter_Name = str(raw_input("Enter the GUI name for the parameter " + str(Input_Number) + " :"))
Store_GUI_Parameter(Opened_File, GUI_Parameter, GUI_Parameter_Name)
I would like to use this data to store it in a specific location in a text file according to required syntax. The above code stores the data in the text file. But the problem is it doesn't store it at the required place.
def Store_GUI_Parameter(Opened_File, GUI_Parameter, GUI_Parameter_Name):
GUI_Description = "| " + '"'+ GUI_Parameter_Name + '"' + " |$" + GUI_Parameter.title() + " |"
Write_Data(Opened_File, GUI_Description)
print "GUI parameters written to NDF file"
return
The data storage is done using the above function...
I tried this, but unfortunately this also is not working
GUI_Parameter= []
GUI_Parameter_Name = []
for Input_Number in range(Number_Of_Inputs):
Input_Number = Input_Number+1
GUI_Parameter[Input_Number] = str(raw_input("Please enter input parameter " + str(Input_Number) + " :"))
GUI_Parameter_Name[Input_Number] = str(raw_input("Enter the GUI name for the parameter " + str(Input_Number) + " :"))
Using it outside the loop in the same function...
GUI_Description(Opened_File, GUI_Parameter_Name[Input_Number], GUI_Parameter[Input_Number])
The function implementation:
def GUI_Description(Opened_File, GUI_Parameter_Name[Input_Number], GUI_Parameter[Input_Number]):
Iteration = 0
while Iteration < Input_Number:
Iteration += 1
GUI_Description = "| " + '"'+ GUI_Parameter_Name[Input_Number] + '"' + " |$" + GUI_Parameter[Input_Number].title() + " |"
Write_Data(Opened_File, GUI_Description)
print "GUI parameters written to NDF file"
return
But it shows syntax error at the def GUI_Description
C:\Users\padmanab\Desktop>python CtoN.py File "CtoN.py", line 173
def GUI_Description(Opened_File, GUI_Parameter_Name[Input_Number], GUI_Parameter[Input_Number]):
^ SyntaxError: invalid syntax
The syntax error in the function GUI_Description is caused by your input arguments. 'GUI_Parameter_Name[Input_Number]' is not a valid input argument. Since your function requires both 'GUI_Parameter_Name' and 'Input_Number' they should be separate input arguments. The code snippet below would solve this syntax error:
def GUI_Description(Opened_File, Input_Number, GUI_Parameter_Name, GUI_Parameter):
...
The code below will give an 'index out of range' error since the lists 'GUI_Parameter' and 'GUI_Parameter_Name' have zero length.
GUI_Parameter= []
GUI_Parameter_Name = []
Number_Of_Inputs = 1
for Input_Number in range(Number_Of_Inputs):
Input_Number = Input_Number+1
GUI_Parameter[Input_Number] = str(raw_input("Please enter input parameter " + str(Input_Number) + " :"))
GUI_Parameter_Name[Input_Number] = str(raw_input("Enter the GUI name for the parameter " + str(Input_Number) + " :"))
If you want to add items to the arrays you should append them:
GUI_Parameter.append(raw_input())