[Numpy-discussion] How to use user input as equation directly
Ryan May
rmay31 at gmail.com
Thu Oct 27 17:26:28 EDT 2016
On Thu, Oct 27, 2016 at 1:58 PM, djxvillain <djxvillain at gmail.com> wrote:
> Hello all,
>
> I am an electrical engineer and new to numpy. I need the ability to take
> in
> user input, and use that input as a variable. For example:
>
> t = input('enter t: ')
> x = input('enter x: ')
>
> I need the user to be able to enter something like x =
> 2*np.sin(2*np.pi*44100*t+np.pi/2) and it be the same as if they just typed
> it in the .py file. There's no clean way to cast or evaluate it that I've
> found.
>
Are you aware of Python's eval function:
https://docs.python.org/3/library/functions.html#eval
?
Ryan
--
Ryan May
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20161027/148e973f/attachment.html>
More information about the NumPy-Discussion
mailing list