Re: [Tutor] eval use (directly by interpreter vs with in a script)

2014-11-02 Thread Danny Yoo
> I use exec to jump to another program within the > same directory, such as: > > execfile("BloodPressure02Sorting.py") > > and let the program terminate there. Should I do > it differently or are you talking about a different > horse? This is related. Rather than use execfile, you may want to c

[Tutor] Some shameless self promotion

2014-11-02 Thread Alan Gauld
For anyone who might be interested http://www.amazon.com/Python-Projects-Laura-Cassell/dp/111890866X A book aimed at those who have just finished their first python tutorial and are wondering what to do next... I promise not to mention it every post, honest :-) PS. Disclaimer: I had nothing

Re: [Tutor] Invalid syntax issue

2014-11-02 Thread Alan Gauld
On 02/11/14 23:55, Kody Fergerson wrote: worried about you all having it. When I try to check it or run it it comes up with "invalid syntax" and highlights the first "@" symbol. The code is as follows... TO = kody.was...@gmail.com GMAIL_USER = kody.was...@gmail.co

Re: [Tutor] all right students, what do we learn

2014-11-02 Thread Alan Gauld
On 02/11/14 21:49, Dave Angel wrote: But it doesn't. print() returns None, which is false. Oops, of course it does! I got confused by looking in the interpreter which, of course, printed out the string but I mistook it for a return value! So in fact Clayton's code never executes the exec()

[Tutor] Invalid syntax issue

2014-11-02 Thread Kody Fergerson
Hello, I am trying to use a code from Adafruit to have Python send an email when triggered by my Arduino. I'm a novice to programming so it"s somewhat hard for me. I used the code copied verbaticm only changing my email and password, the email in there is a temporary one so I'm not worried about y

Re: [Tutor] all right students, what do we learn

2014-11-02 Thread Dave Angel
On 11/02/2014 03:05 PM, Clayton Kirkwood wrote: -Original Message- From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On Behalf Of Alan Gauld Sent: Sunday, November 02, 2014 1:04 AM To: tutor@python.org Subject: Re: [Tutor] all right students, what do we learn On 02/11/1

Re: [Tutor] eval use (directly by interpreter vs with in a script)

2014-11-02 Thread Dave Angel
On 11/02/2014 03:01 PM, Alex Kleider wrote: I'm puzzled by the following behaviour: The following works as I expect: alex@x301:~/Python$ python3 Python 3.4.0 (default, Apr 11 2014, 13:05:18) [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information. code = """\

Re: [Tutor] eval use (directly by interpreter vs with in a script)

2014-11-02 Thread eryksun
On Sun, Nov 2, 2014 at 3:07 PM, Peter Otten <__pete...@web.de> wrote: > Inside a function there is no direct way to get access to the local > namespace used by exec(). Indeed, exec() can't create new function locals, or even update the values of existing function locals. Another option for indire

Re: [Tutor] eval use (directly by interpreter vs with in a script)

2014-11-02 Thread Alex Kleider
On 2014-11-02 13:49, Danny Yoo wrote: Are you just exploring the features of Python, or is there a particular task you're trying to solve with eval or exec()? Perhaps you can accomplish the same goal in another way? Thank you and also Peter for your help. The answer to your question is "'yes

Re: [Tutor] eval use (directly by interpreter vs with in a script)

2014-11-02 Thread Ken G.
On 11/02/2014 04:49 PM, Danny Yoo wrote: Hi Alex, Just as a side note, someone has probably already told you something like this, but: I would strongly recommend not to use Python's eval() or exec(). Those language features are dangerous. Every eval() or exec() is a possible vector for injec

Re: [Tutor] all right students, what do we learn

2014-11-02 Thread Alan Gauld
On 02/11/14 20:05, Clayton Kirkwood wrote: out that python doesn't seem to like an assignment in the overall if clause - error. Correct, the if statement requires an expression (specifically a boolean expression). And assignments are not expressions. My thinking was that I was making a Boole

Re: [Tutor] eval use (directly by interpreter vs with in a script)

2014-11-02 Thread Danny Yoo
Hi Alex, Just as a side note, someone has probably already told you something like this, but: I would strongly recommend not to use Python's eval() or exec(). Those language features are dangerous. Every eval() or exec() is a possible vector for injection attacks. This week's injection attack

Re: [Tutor] eval use (directly by interpreter vs with in a script)

2014-11-02 Thread Peter Otten
Alex Kleider wrote: > I'm puzzled by the following behaviour: > > The following works as I expect: > > alex@x301:~/Python$ python3 > Python 3.4.0 (default, Apr 11 2014, 13:05:18) > [GCC 4.8.2] on linux > Type "help", "copyright", "credits" or "license" for more information. code = """\ > ..

Re: [Tutor] all right students, what do we learn

2014-11-02 Thread Clayton Kirkwood
>-Original Message- >From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On >Behalf Of Dave Angel >Sent: Sunday, November 02, 2014 1:18 AM >To: tutor@python.org >Subject: Re: [Tutor] all right students, what do we learn > >On 11/02/2014 01:43 AM, Clayton Kirkwood wrote: >> To

[Tutor] eval use (directly by interpreter vs with in a script)

2014-11-02 Thread Alex Kleider
I'm puzzled by the following behaviour: The following works as I expect: alex@x301:~/Python$ python3 Python 3.4.0 (default, Apr 11 2014, 13:05:18) [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information. code = """\ ... s1 = 'first' ... s2 = 'second' ... """

Re: [Tutor] all right students, what do we learn

2014-11-02 Thread Clayton Kirkwood
>-Original Message- >From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On >Behalf Of Alan Gauld >Sent: Sunday, November 02, 2014 1:04 AM >To: tutor@python.org >Subject: Re: [Tutor] all right students, what do we learn > >On 02/11/14 05:43, Clayton Kirkwood wrote: > >> So I

Re: [Tutor] all right students, what do we learn

2014-11-02 Thread Dave Angel
On 11/02/2014 01:43 AM, Clayton Kirkwood wrote: To prove that a little knowledge is a little stupid or something to that effect: #for key in key_list: #print(key) #if key not in key_list0: #print("Error:", key, "not available, start again") #get_ne

Re: [Tutor] all right students, what do we learn

2014-11-02 Thread Alan Gauld
On 02/11/14 05:43, Clayton Kirkwood wrote: So I head down the path of all sorts of variations of the following. And I mean all sorts. Instead of [reenter, key_columns] I used a single list. Instead of the exec(‘reenter = True’) I used a simple reenter=True (and an eval and compile which I don’t