Questions tagged [eval]

eval is a function that allows a programmer to execute arbitrary code written in the same language, from a string variable within a code.

Filter by
Sorted by
Tagged with
0 votes
1 answer
16 views

Apply different calculations by row in r

I am trying to calculate results per each row in a data frame Data frame I have tried the following results$index<-noquote(results$Expr) results$index<-parse(text=results$index) results$index<...
-3 votes
1 answer
44 views

c# does not recognize eval if

Data binding methods such as Eval(), XPath() and Bind() can only be used in a data-limited control context. Explanation: An unhandled exception occurred while executing the current web request. Please ...
Enes Şahin's user avatar
0 votes
0 answers
52 views

Using bash eval on a complex single-quoted string

I have programmatically constructed a string that I want to pass to eval in bash. This is the string: finalcommand='for user in $(aws iam list-users --output text --profile myprofile --region us-...
Eric Tork's user avatar
0 votes
0 answers
28 views

python 3 syntax error while evaluating import line [duplicate]

Working on getting seriously into python3. While trying to eval(generated_code) to parse arguments I get an unexpected syntax error during the eval. Iv'e whittled down the code to a simpler failure ...
Gilbert's user avatar
  • 3,740
-4 votes
1 answer
28 views

How to take a byte value input in python or also in python IDLE? [closed]

During learning 'built-in-functions' in python, we are familiar with print() and eval() these two methods, now my doubt is we can take input or pass arguments in eval() as a string. When I wanted to ...
S Majumder's user avatar
0 votes
1 answer
22 views

Plot is not defined when using it in eval()

I have a notebook project that uses React and ObservablePlot and react-monaco there's an IDE on my App that : takes the User Code ( Observable Code ) like this Plot.lineY(props.data, { x: "Date&...
Hamid Kamyab's user avatar
2 votes
5 answers
49 views

What's the difference between (mymacro arg) and (eval (myfunc (quote arg)))

The way I 'see' macros in Lisp is the following: whenever I see a macro call (mymacro arg1 arg2 ... argn), I assume it is the same as (eval (myfun (quote arg1) (quote arg2) ... (quote argn))), where ...
TragicSink's user avatar
0 votes
0 answers
20 views

Why setenv fails when set works find in tcsh

Following setenv works in tcsh script but fails weirdly with eval in tcsh. I have 2 simple files with the following content > head *.tcsh ==> set.tcsh <== set intVar = 10 set strVar = a ==&...
Krishna's user avatar
  • 964
0 votes
0 answers
22 views

Use GitHub libraries on Google App Script - Can´t access

I want to connect some libraries from GitHub to my project on Google App Script. But I have no solution for that. I´m trying the function below => function GH_libraries() { var url = 'https://...
William Belini's user avatar
0 votes
1 answer
23 views

How to execute the eval function with a modified window object

I make a call to eval in my code, and I have a reference to an iframe's window object. Is there any way to execute eval (or something that achieves the same) but have the window object set to the ...
Bobson Tobson's user avatar
0 votes
0 answers
35 views

How to import angular library dynamically without rebuilding of angular app

I have simple angular app + angular library. I want to build an angular app without usage of this library, but later on I want to add an import programmatically using bash scripts. In general I want ...
Yuriy Gyerts's user avatar
  • 1,511
0 votes
1 answer
35 views

how to evaluate textInput inside a Shiny Module as arguments

I am working on a Shiny app that serves as an interface for the gtsummary package. One of the features I've added is the ability to apply functions like add_p() to the generated tables, and it's ...
Jojostack's user avatar
  • 181
-6 votes
3 answers
321 views

I can use random to get a random value from a range. How do I make math evaluator that does opposite and also has access to math modules?

I want to build a math evaluator for a private use (no security limitations when doing eval operations) that can give me possible outcomes of mathematical statements. Assume random() here refers to ...
Machinexa's user avatar
  • 452
0 votes
2 answers
73 views

Unexpected behavior in eval in php < 7.4

The following code: <?php function e($m, $n) { return eval( 'return new class() { // '. str_repeat('a', $m). ' public function test() { return &...
Alexandar Popov's user avatar
0 votes
1 answer
42 views

Why pandas.eval() string comparison returns False

Could someone explain me why this simple piece of code returns False? That's probably pretty simple, but I don't understand why it behaves like that: import pandas as pd eval_string = '"abc"...
Ekaitz's user avatar
  • 3
0 votes
2 answers
61 views

Add entry to array of objects using array of indexes

I have the following scenario: I have an array of objects (TreeItems) which could contain nested arrays. And I have another Array with indexes. Now I would like to change the TreeItems array using the ...
bbasmer's user avatar
  • 137
0 votes
3 answers
35 views

Creating new instance of the same class as an existing instance, without using eval()

I have an instance sampleInstance of an unknown class and I need to create a second instance of the same class. Here's what I am doing right now: I look up the class name with sampleInstance....
socebic's user avatar
  • 33
1 vote
3 answers
88 views

How to pass an argument to a script by ref in bash

Please notice that I'm talking about passing arguments by-ref to a script, not to a function. I already checked here and here and they discuss about passing arguments using functions. What I want is ...
Adriano_Pinaffo's user avatar
1 vote
1 answer
27 views

Using eval() with a variable and getting a syntax error

I am trying to find the average of numbers in a file using a while loop. I'm using readline() to get the numbers from the file and assign them to a variable, and this results in them being read as ...
Akua Pipim's user avatar
0 votes
0 answers
21 views

Error in eval(expr; p): PDF parsing failure

I don´t understand the error itself and what I need to change in the code. Even if I only run the first part (minutes), the error "Error in eval(expr; p): PDF parsing failure" comes up. ...
lena_mllr's user avatar
0 votes
1 answer
42 views

VBA Eval Function in C#

im trying to rewrite some VBA code in C#. The VBA function takes a string like "4 > 2 AND 10 <> 62" or "'False' = 'False' AND 6 <> 7" or "'True' = 'False' ...
Nick's user avatar
  • 11
1 vote
2 answers
55 views

\n in print statements in eval() functions not working

I am working on a project in python, and have encountered an error. When I try to run this code: eval("print(\"\n\")"), it doesn't work and gives me an error: 'SyntaxError: EOL ...
Pickles6855's user avatar
1 vote
2 answers
43 views

Non-standard evaluation: any benefits for *programming* (not interactive R)?

I do not understand the cost-benefit of NSE (non-standard evaluation) in R for programming. I can see why NSE may be useful for interactive R, but for programming -- i.e. writing reusable scripts and ...
jessexknight's user avatar
0 votes
1 answer
24 views

Calling eval with dynamically defined variables in scope

I want to be able to dynamically define variables (i.e x = 1, y = 2 - but where the user defines the names x and y, and may have a "z") - and have them be in scope when executing javascript ...
Max Hudson's user avatar
  • 9,971
2 votes
0 answers
55 views

Evaluate TypeScript from string; throw type errors [closed]

(This question is a dupe: see here) In this question we've already discussed how to run/evaluate a string representing TypeScript code, and the solution looks like: import { transpile } from '...
Gershom Maes's user avatar
  • 7,469
0 votes
1 answer
45 views

safely using python eval on non-arbitrary code

I would like to create a simple yaml workflow that works as metadata in a yaml environment as below. The user will create these and submit them, mostly to organize a modest number of tasks (such as ...
Eli S's user avatar
  • 1,379
0 votes
1 answer
43 views

Letting users add logic to be run with eval to a web app

I'm working on a webapp that lets you build tools in the browser to be used by others. So, for example, someone might make a calculator app with custom buttons that take user input, process it in a ...
Max Hudson's user avatar
  • 9,971
0 votes
0 answers
33 views

Is it possible to convert a Function object to a byte array in dart?

I have a dart class which contains a Function member variable (which is different for each instance of the class). I need to store instances of this class in a database (such as ObjectBox), but in ...
jstovold's user avatar
0 votes
1 answer
43 views

Non-standard evaluation through *ellipsis* argument using the `subset` function within a second function

My goal is to transfer the subset argument to the subset function within a second function. I am able to make it work (first example below), but not when using the ellipsis to pass a named argument. # ...
rempsyc's user avatar
  • 825
-1 votes
1 answer
41 views

make list of const and its value using for loop js

I want to generate these line of codes by using for loop const clientAppProcessFlowIds = (listItem.clientAppProcessFlowId===null)?listItem.clientAppProcessFlowId='empty':String(listItem....
Sobhan Shekar's user avatar
0 votes
2 answers
34 views

Checking if values in multiple fields are null relative to each other?

So I am using the eval function to perform operations on various fields. I wish to continue using eval. Consider the expression result = fieldA + feildB My problem is however that if there is a null ...
Solrac's user avatar
  • 47
0 votes
0 answers
32 views

Is there a way to pause eval() after each executed statement?

Is there a way to pause pause the eval() function in javascript after each statement that was executed within eval()? Or is there something like like a virtual machine in javascript, that I can ...
inane's user avatar
  • 41
0 votes
2 answers
62 views

Can't use trig functions in eval syntax in Python

Below is my code: import math x = eval("math.sin(x)", {'x':2}) print(x) You know what I mean. It won't give my desired output. I just want to allow the user input a algebraic expression ...
Ronald Rosete's user avatar
0 votes
0 answers
54 views

'self' is not defined when calling eval list comprehension with if statement in Python 3.7.5

I encountered a problem while using eval() to evaluate a list comprehension with an if statement in Python 3.7.5. The issue occurred within the following class foo, which contains two methods: exe ...
ENN Kim's user avatar
  • 11
1 vote
1 answer
39 views

Is using `eval()` in a self-contained server-side environment for user-provided JavaScript code secure?

I'm developing an application that assists developers in designing their REST API tests. As part of this tool, I'm considering adding a feature that allows users to write their own JavaScript code to ...
PeiSong's user avatar
  • 871
0 votes
1 answer
35 views

Local bindings for Racket's eval function

I am implementing a genetic programming application in which arithmetic expressions, containing safe-div and safe-sqrt, are dynamically generated by a function (as lists). To calculate the fitness of ...
slago's user avatar
  • 5,025
0 votes
0 answers
55 views

Validating AST using Babel to use eval safely on User Input Code

We have a NodeJS Application where a User can input Javascript code. The JS code needs to be run in the same environment using eval. Now, as it has been recommended almost everywhere to avoid using ...
Ankur Thakur's user avatar
0 votes
2 answers
67 views

Error in parse(text = expression) : <text>:2:1: unexpected ','

Solutions to prior similar questions 1 and 2 do not work. f_letter <- 'a' l_letter <- 'c' sep <- c(':', ',') to <- 1 and <- 2 expression <- noquote(c(which(letters == f_letter), ...
Krantz's user avatar
  • 1,434
0 votes
1 answer
195 views

eval() class is not defined when imported?

I'm trying to write a simple replacer/reviver combination that lets me serialize and deserialize ES6 classes properly (I need to deserialize them as ES6 classes, not Objects) for a TypeScript project ...
micka190's user avatar
  • 752
1 vote
1 answer
59 views

Use comparison operator in a variable in tcl if statement

I would like to use the comparison operator like == >= and so in in a variable as shown in the following example. I can not get it to work as intended a i bet I use the eval statement wrong here. ...
Lumpi's user avatar
  • 2,731
0 votes
0 answers
7 views

I'm looking for the syntax for using Eval with a hyperlink

I have a hyperlink in a repeater: <asp:HyperLink ID="hl_User" runat="server" NavigateUrl='<%# Eval("CheckoutID",...
Mike225's user avatar
  • 11
1 vote
3 answers
71 views

Dot sourcing a command string with additional arguments

I need to execute an external command from PowerShell as a string. Is it possible to run an external command (ping in this example) with parameters via dot-sourcing or something similar? Or do you ...
Per's user avatar
  • 13
0 votes
2 answers
132 views

Lit-Element - How to render template from an external text?

I have a string which I receive from an external service which contains the HTML template with some expressions which need to be dynamically evaluated by the render function. How can this be done with ...
megloff's user avatar
  • 1,410
1 vote
2 answers
57 views

Converting string column into formula

I'm trying to convert strings from a column into formulas and output the result based on values I specify. For example: Compo <- c("FE56", "FE58", "FE61", "YI68&...
Tagli94's user avatar
  • 19
0 votes
0 answers
61 views

String with literal_eval

can someone help me here? what is going on? why the string without(key=name) the spaces work and the string with(key=caption) the spaces fail? import ast a = {'caption': 'A silhouette of two wine ...
Shon Otmazgin's user avatar
0 votes
1 answer
146 views

"zsh: file name too long:" when trying to run eval command

I am trying run some integration tests on my linux. As part of the setup we spawn the service on a local server and run the integration test against that. Before running the integration test we ...
iammrmehul's user avatar
0 votes
0 answers
23 views

PHP: Evaluate class constant string as code (syntax question) [duplicate]

Defining a trait I want to write a method which gets the content of a class constant if it exists and is an array, return an empty error otherwise. Just not easy to figure out how to evaluate this ...
Blackbam's user avatar
  • 17.6k
2 votes
1 answer
378 views

Playwright locator.evaluateAll how to return map filled using nodes forEach

I want to grab properties of all <custom-tag> nodes and the innerText of a node-child either of type <custom-text> or of type <custom-number> A simplified version in the devtools is ...
surfmuggle's user avatar
  • 5,587
0 votes
1 answer
129 views

I don't see why bash eval command does not work as expected? [duplicate]

Ubuntu 22.04.2 LTS GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu) My Task I want to test in a generic way if var is set and not empty. The script #!/bin/bash set -e set -u set -o pipefail ...
paulh00's user avatar
1 vote
1 answer
31 views

Restructuring dynamically-loaded scripts within JavaScript program to avoid eval

This might be a bit of a specific problem (research project), but I'm looking for a good way to make this program significantly "safer" than it currently is. The goal is to accept arbitrary ...
erik's user avatar
  • 3,810

1
2 3 4 5
98