FAQ Database Discussion Community


R convert character to dataframe column name and then replace values in a column

r,eval,assign
I was able to get content of the column pointed by character variable b. But i want to make column emp 0. How could i do that? emp=c(1,2,30) abc=data.frame(emp) b="emp" #below line gives content of column emp eval(parse(text=paste("abc$", b, sep = ""))) #how can i replace each value in column...

Eval Inside Of Funtion Results In Error, While Outside It Does Not

python,eval
I wrote a small python script that takes in descriptions of simple impedance networks and calculates the effective impedance. The code is pastebined here. The code, as is, runs correctly, but if you sub in the commented out lines that are below them, which simply moves the eval to the...

is there a way to avoid eval() to accomplish dynamic dispatch of a function specified in a list in python

python,eval
I have a list as defined here: header_fields = [ ['delim',0,4,'strip()'], ['qual',4,5,None], ['NLS_CODE',6,25,'strip()'], ['source_system_id',26,45,'strip()'], ['extract_name',46,65,'strip()'], ['extract_serial_number',66,85,'strip()'], ['file_counter',86,88,"lstrip('0')"], ['total_file_count',89,91,'strip()'], ['extract_run_date_time',92,126,'strip()'], ['from_date',127,161,'strip()'], ['thru_date',162,196,'strip()'], ['number_of_rows',197,216,'strip()'], ['data_recons1',217,246,'strip()'],...

Custom directive: How evaluate bindings with dynamic HTML

javascript,angularjs,angularjs-directive,eval
Setup: Very simplified HTML: <td ng-repeat="col in cols"> <div ng-bind-html="col.safeHTML"></div> </td> JS controller: $scope.cols = [ { field : 'logo', displayName : 'Logo', cellTemplate: '<div style="color:red">{{col}}</div>' }, { field : 'color', displayName : 'Color', cellTemplate: '<div style="color:green">{{col}}</div> } ]; JS link directive link function: for (var i = 0, j...

How can I create an array assignment from HEREDOC text using PHP?

php,arrays,eval,variable-assignment,heredoc
I have a list of strings I need to convert into an array assignment eg lets say I have a set of lines like this: ctools_export_ui_list_form masquerade_block_1 switchtheme_switch_form backup_migrate_ui_manual_backup_load_profile_form backup_migrate_ui_manual_backup_form I need to create a variable assignment like this: $conf['journal_form_ids'] = array( 'ctools_export_ui_list_form' => 0, 'masquerade_block_1' => 0, 'switchtheme_switch_form' =>...

Is this eval() in python safe?

python,eval,code-injection
consider this code: from re import sub input = request.POST['input'] sub_pattern = {'1':"sub('pattern1','txt1',input)", '2':"sub('pattern2','txt2',input)", } eval(sub_pattern['1']) is there code-injection in this code? can you provide POC on this code injection?...

Using Javascript's eval() on HTML Text

javascript,html,eval
I am toying around with some basic constructs in HTML and Javascript (i.e., I am a HTML/Javascript n00b), and there is a feature I simply cannot seem to implement properly. In a nutshell, I'd like to grab text from the body of an HTML page and evaluate it using Javascript...

Can an inserted