variables

Not Recognizing Loop Variable in Python

核能气质少年 提交于 2020-01-05 22:57:02
问题 I am trying to delete 38 lines of text after coming across a certain phrase in a .txt file in Python, while still printing the rest of the text. The code I currently have is with open('text_file.txt','r') as f: lines = f.readlines() for line in lines: if "certain_phrase" in line: for num in range(38): del line else: print(line,end='') However, I keep getting the following error: Traceback (most recent call last): File "C:\<location of file>\python_program.py", line 6, in <module> del line

python can't return a variable but can print

随声附和 提交于 2020-01-05 21:26:53
问题 So I'm encountering a weird problem. def findFourPlus(itemCount, seq, goal): goalDifference = float("inf") closestPartial = [] hello = subset_sum(itemCount, seq, goal, goalDifference, closestPartial, partial=[]) return hello #doesn't return value from subset_sum() def subset_sum(itemCount, seq, goal, goalDifference, closestPartial, partial): s = sum(partial) # check if the partial sum is equals to target if(len(partial) == itemCount): if s == goal: print("FOUND YAA") return partial #right now

Magento CMS Page/Static Blocks - How to display store name?

北战南征 提交于 2020-01-05 12:16:23
问题 I have number of Magento CMS pages and static blocks which use the variable {{store url=""}} to display the store url address in some text depending which store is being viewed. I would like to also display the store name. Is there an equivalent which would display the store name, something like {{store name=""}}? ({{store name=""}} doesn't work btw) I don't have access to the .php files so would like to know if this is possible without access. If not, then I can request changes to the .php,

extjs How to get a grid

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-05 11:01:54
问题 In Designer I set my grid name to equal MyGrid On clicking the button addRecord is called, it fails where rows is attemting to get an undefined grid. How do I define this MyGrid so that it references the grid within the panel? Ext.define('MyApp.view.MyPanel', { extend: 'MyApp.view.ui.MyPanel', initComponent: function() { var me = this; me.callParent(arguments); var button = me.down('button[text=Submit]'); button.on('click', me.onSubmitBtnClick, me); }, addRecord: function(myRecordArray) { var

Changing hard coded path to variable in MS SQL

亡梦爱人 提交于 2020-01-05 10:30:11
问题 Im using the following code and all works correctly DECLARE @Directory varchar(100) SELECT @Directory = 'c:\XML\' DECLARE @FileExist int DECLARE @FileName varchar(500),@DeleteCommand varchar(1000),@FullFileName varchar(500), @SQLFullFileName varchar(500) DECLARE @X XML SELECT @X = CONVERT(xml,[ICECAT-interface],2) FROM OPENROWSET(BULK 'C:\XML\1382.xml',SINGLE_BLOB) AS Import([ICECAT-interface]) select P1.X.value('@ID', 'int') as ProductID, P2.X.value('@ID', 'int') as ProductID from @X.nodes('

Getting Details from one Dynamic Page to Another - Re-Post

懵懂的女人 提交于 2020-01-05 10:27:18
问题 After some wrestling with almost every line of code written for the JoomShopping component I beleive I have found what should be the answer to all my woes. When activating the "Buy" button in the shopping list and once clicked on it uses the following link syntax in order to post a Product to the Checkout Cart: index.php/cart/add?category_id=2&product_id=12&quantity=4 Where 2 is the Category ID and 12 is the Product ID etc ... This was solved by V.Vachev, but I thought it prudent to post all

Not able to access object sub class's variable? (Java / Android)

為{幸葍}努か 提交于 2020-01-05 10:16:17
问题 I've got a custom class called 'Quad' which creates a textured quad to use as a sprite in my 2D OpenGL ES 2.0 game. public class Quad(){ //Quad creation stuff here } Then I have a separate subclass (i.e. in a different file - not an innerclass) public class hero extends Quad(){ //Variables relating specifically to this character int heroX = 0; int heroY = 0; } I create my object like so: Quad hero = new Hero(); However, if I attempt to access the 'heroX' and 'heroY' variables, I get nothing..

How to convert Javascript Anonymous Function to Java maybe with switch?

拈花ヽ惹草 提交于 2020-01-05 08:59:09
问题 Here is the javascript code below with a few anonymous inner functions linked to it seems 2 array indexes for each switch, they seem to return some value too, but I have no idea where they are returning to the memoryReadJumpCompile() function or both those array index's. Most likely they are reuturning to the actual array indexes and by the function name Compile it seems that everytime you call any of those array indexes they will re-evaluate the function linked to them with some new result

jquery getting GET variables from javascript file

我与影子孤独终老i 提交于 2020-01-05 08:53:09
问题 I have a link, and when a user clicks it, it pushes a javascript file onto the page. in addition to that, it adds on parameters to the javascript src example: <script type="text/javascript" src="javascripfile.js?r=some%values&u=more&values"> This isn't getting passed through URL on browser. I was wondering how I would get these parameters inside javascriptfile.js? javascriptfile.js : (function(){ //how to get r value, u value? }()); Thanks for your help! 回答1: Please try this: http://jsfiddle

Bash variable concatenation fails inside loop

一笑奈何 提交于 2020-01-05 08:52:53
问题 Given the following statements: ac_reg_ids="-1" #Starting value (mysql) | while read ac_reg_id; do echo "$ac_reg_id" #variable is a result of a mysql query. Echoes a number. ac_reg_ids="$ac_reg_ids, $ac_reg_id" #concatenate a comma and $ac_reg_id, fails. done echo "ac_reg_ids: $ac_reg_ids" #echoes -1 Now according to this answer: https://stackoverflow.com/a/4181721/1313143 Concatenation should work. Why doesn't it, though? What's different within the loop? Just in case it could matter: > bash