> >To help you out. You need some sort of error checking to be sure that
> >within your given range you won't get something like a math domain
> >error.
> >
> >
> Yes, I thought that:
> try:
> #function
> exception:
> pass
Hi Ismael,
Python's keyword for exception handling is 'except'
Ismael Garrido wrote:
> [EMAIL PROTECTED] wrote:
>
>> Quoting Ismael Garrido <[EMAIL PROTECTED]>:
>>
>>
>>
>>> I am trying to make a program that will plot functions. For that,
I
>>> need
>>> to be able to get an input (the function to be plotted) and
execute it.
>>>
> >
> >
> >So you want the
I have grown to like VPython as the curve attribute really seems to do the
trick. If you get it working on a Tkinter canvas, I would like to see the
code as I haven't quite found a way to plot points on to one of those. A
simple graph function in VPython... (it isn't the whole thing, believe
me...
Jacob S. wrote:
eval() is good and it can be done using it.
I wrote a -- IMHO -- really great functiongraphing program using vpython.
If you would like to see it, just reply and say so.
Out of curiosity, I would like to see your program. There's always
something to learn (and even more so for m
I wondered when someone would ask something like this.
eval() is good and it can be done using it.
I wrote a -- IMHO -- really great functiongraphing program using vpython.
If you would like to see it, just reply and say so.
Pros and cons of calculating all first:
pro - easier to read code
con -
[EMAIL PROTECTED] wrote:
Quoting Ismael Garrido <[EMAIL PROTECTED]>:
(Newbie looking scared) That's kind of hard for me... Parsing it myself
is too complex for me. Also, I hoped Python's math would do the job for
me, so I wouldn't have to make what's already done in Python.
Writing (and understa
You can you the exec statement to execute Python code from a string. The string could be from user
input. So for example a user could input 'x*x' and you could do
>>> inp = 'x*x'
>>> func='def f(x): return ' + inp
>>> func
'def f(x): return x*x'
>>> exec func
>>> f(3)
9
Now you have f(x) def
Quoting Ismael Garrido <[EMAIL PROTECTED]>:
> (Newbie looking scared) That's kind of hard for me... Parsing it myself
> is too complex for me. Also, I hoped Python's math would do the job for
> me, so I wouldn't have to make what's already done in Python.
Writing (and understanding) grammar is p
[EMAIL PROTECTED] wrote:
Quoting Ismael Garrido <[EMAIL PROTECTED]>:
I am trying to make a program that will plot functions. For that, I need
to be able to get an input (the function to be plotted) and execute it.
>
>
>So you want the user to be able to type something like "f(x) =
sin(2*x)" and
Eep.
On Mon, 10 Jan 2005 13:04:33 +1300, Liam Clarke <[EMAIL PROTECTED]> wrote:
> I think you're looking for eval() - but that's a big security hole,
> and wouldn't handle f(x) notation overly well, unless you parse like
> John said.
>
>
> On Mon, 10 Jan 2005 12:52:24 +1300 (NZDT), [EMAIL PROTE
Quoting Ismael Garrido <[EMAIL PROTECTED]>:
> I am trying to make a program that will plot functions. For that, I need
> to be able to get an input (the function to be plotted) and execute it.
> So, my question is, how do I use the input? I have found no way to
> convert the string to some kind o
11 matches
Mail list logo