eval

Eval check for DBNull doesnt work

心不动则不痛 提交于 2019-11-29 11:10:32
<%# Eval("Description") == DBNull.Value ? "empty" : "notempty"%> is showing always 'notempty' even there is null in that field in DB (type of varchar(), null) ... Tried also checking for empty string: <%# Eval("Description") == "" ? "empty" : "notempty"%> and it always displays notempty... what's wrong here?? There is a difference between DBNull.Value and null . It is possible the field is returning null . Try <%# Eval("Description") == null ? "empty" : "notempty"%> Also if the field value type is supposed to be string you could do something along the lines of.. <%# (Eval("Description") as

dynamic array names javascript

与世无争的帅哥 提交于 2019-11-29 10:56:15
I have a few arrays with like names. ArrayTop[] ArrayLeft[] ArrayRight[] ArrayWidth[] I am trying to set the name dynamically in a function and then set value. I have tried many ways of dynamically picking the right array but have not come up with a solution. function setarray(a,b,c){ eval(Array+a+[b])=c } setarray('Top',5,100) In this example i am trying to set. ArrayTop[5]=100 If you are doing this in the browser, one possible solution would be to do: function setArray(a, b, c){ window['Array' + a][b] = c; } setArray('Top', 5, 100); I would recommend that all your array's be contained in

Javascript calling eval on an object literal (with functions)

允我心安 提交于 2019-11-29 10:52:22
Disclaimer: I fully understand the risks/downsides of using eval but this is one niche case where I couldn't find any other way. In Google Apps Scripting, there still is no built-in capability to import a script as a library so many sheets can use the same code; but, there is a facility built-in where I can import text from a plaintext file. Here's the eval-ing code: var id = [The-docID-goes-here]; var code = DocsList.getFileById(id).getContentAsString(); var lib = eval(code); Logger.log(lib.fetchDate()); Here's some example code I'm using in the external file: { fetchDate: function() { var d

Why is Python's eval() rejecting this multiline string, and how can I fix it?

你离开我真会死。 提交于 2019-11-29 09:48:12
I am attempting to eval the following tab-indented string: '''for index in range(10): os.system("echo " + str(index) + "") ''' I get, "There was an error: invalid syntax , line 1" What is it complaining about? Do I need to indent to match the eval() statement, or write it to a string file or temp file and execute that, or something else? Thanks, eval evaluates stuff like 5+3 exec executes stuff like for ... >>> eval("for x in range(3):print x") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<string>", line 1 for x in range(3):print x ^ SyntaxError: invalid syntax

Why is `input` in Python 3 throwing NameError: name… is not defined

不问归期 提交于 2019-11-29 09:33:28
I have a string variable test , in Python 2.x this works fine. test = raw_input("enter the test") print test But in Python 3.x, I do: test = input("enter the test") print test with the input string sdas , and I get an error message Traceback (most recent call last): File "/home/ananiev/PycharmProjects/PigLatin/main.py", line 5, in test = input("enter the test") File "", line 1, in NameError: name 'sdas' is not defined You're running your Python 3 code with a Python 2 interpreter. If you weren't, your print statement would throw up a SyntaxError before it ever prompted you for input. The result

Is using javascript eval() safe for simple calculations in inputs?

浪子不回头ぞ 提交于 2019-11-29 09:31:30
I would like to allow user to perform simple calculations in the text inputs, so that typing 2*5 will result in 10. I'm replacing everything but digits with an empty string and then make calculation using eval(). This seems easier and probably faster then parsing it manually. It's often being said that eval() is unsafe, so I would like to hear is there any danger or drawback of using it in this situation. function (input) { value = input.value.replace(/[^-\d/*+.]/g, ''); input.value=eval(value); } That is safe, not because you are sanitizing it, but because it's all entered by the user and run

Python eval(compile(…), sandbox), globals go in sandbox unless in def, why?

淺唱寂寞╮ 提交于 2019-11-29 07:53:44
Consider the following: def test(s): globals()['a'] = s sandbox = {'test': test} py_str = 'test("Setting A")\nglobals()["b"] = "Setting B"' eval(compile(py_str, '<string>', 'exec'), sandbox) 'a' in sandbox # returns False, !What I dont want! 'b' in sandbox # returns True, What I want 'a' in globals() # returns True, !What I dont want! 'b' in globals() # returns False, What I want I'm not even sure how to ask, but I want the global scope for a function to be the environment I intend to run it in without having to compile the function during the eval. Is this possible? Thanks for any input

How to pass bind or eval arguments with the client function “OnClientClicking”

依然范特西╮ 提交于 2019-11-29 07:37:43
I meet about problem to pass arguments to the client-side event OnClientClicking . I tried to use the String.Format () function, but it does not work. Do you have an idea for a workaround to send parameter linked with OnClientClicking ? Code asp : <telerik:RadButton ID="bnt_meetingDelete" runat="server" OnClientClicking="<%# string.Format("confirmCallBackFn('{0}');",Eval("MeetingID")) %>" Image-ImageUrl="~/image/icone/delete-icon.png" Image-IsBackgroundImage="true" Width="21" Height="21" telerik:RadButton> Error IIS : Parser Error Description: An error occurred during the parsing of a resource

tensorflow : .eval() never ends

帅比萌擦擦* 提交于 2019-11-29 07:17:01
i am loading the cifar-10 data set , the methods adds the data to tensor array , so to access the data i used .eval() with session , on a normal tf constant it return the value , but on the labels and the train set which are tf array it wont 1- i am using docker tensorflow-jupyter 2- it uses python 3 3- the batch file must be added to data folder i am using the first batch [data_batch_1.bin]from this file http://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz As notebook: https://drive.google.com/open?id=0B_AFMME1kY1obkk1YmJHcjV0ODA The code[As in tensorflow site but modified to read 1 patch]

JSON.parse()与JSON.stringify()和eval()使用方法详解

不羁的心 提交于 2019-11-29 06:23:38
在和后端对接口的时候,遇到了一个问题 就是series里面数据变量进行拼接的时候,data数据里面全部是数值int类型的 但是因为某些需求需要让他进行某个数据之前的数据都为空 我试过用空字符串和undefined和null,nan都不行 后来我问了一个大神,他帮我看完以后告诉我说需要用eval进行json字符串解析,不能用JSON.parse方法 我从网上搜索了相关的方法,大家一起进行借鉴参考 来源: https://www.php.cn/js-tutorial-394185.html “JSON( JavaScript Object Notation) 是一种轻量级的数据交换格式。它基于ECMAScript的一个子集。因为采用独立于语言的文本格式,也使用了类似于C语言家族的习惯,拥有了这些特性使JSON成为理想的数据交换语言,作用是易于人阅读和编写,同时也易于机器解析和生成(一般用于提升网络传输速率)。”   今天在这里笔者想简单谈谈jquery里面的JSON.parse()和JSON.stringify()函数,顺便还会提一下原生JS里面的eval()函数 (1)JSON.parse 函数 作用:将 JavaScript 对象表示法 (JSON) 字符串 转换为对象。   语法:JSON.parse(text [, reviver]) 参数: text  必需。 一个有效的