Python Forum
Is this use of exec pythonic?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is this use of exec pythonic?
#2
can you elaborate what you want to achieve, because this looks very much like XYproblem. I guess you try to create a name dynamically and that is really bad idea. But the exec snippet is even worse
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Is this use of exec pythonic? - by psolar - Feb-07-2020, 12:13 PM
RE: Is this use of exec pythonic? - by buran - Feb-07-2020, 12:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to avoid exec(), globals(), locals(), eval() paul18fr 10 5,067 Apr-21-2021, 05:53 PM
Last Post: snippsat
  exec in a function paul18fr 6 3,396 Apr-19-2021, 11:10 AM
Last Post: paul18fr
  exec + subprocess = UnboundLocalError paul18fr 6 3,534 Feb-04-2021, 06:27 AM
Last Post: Gribouillis
  exec() in class, NameError niski1996 6 3,992 Apr-20-2020, 07:14 PM
Last Post: niski1996
  which is "better" (or more Pythonic)? Skaperen 2 2,062 Feb-01-2020, 03:10 PM
Last Post: Skaperen
  which is "better" (or more Pythonic)? Skaperen 7 3,241 Feb-01-2020, 03:51 AM
Last Post: Skaperen
  problem using exec to save local variables dkarl 0 1,804 Dec-01-2019, 08:52 AM
Last Post: dkarl
  which is "better" (or more Pythonic)? Skaperen 8 3,346 Nov-16-2019, 06:46 PM
Last Post: Skaperen
  which is more Pythonic? Skaperen 5 2,864 Jul-16-2019, 01:00 AM
Last Post: Skaperen
  common code, def a function vs exec() a string Skaperen 7 3,378 May-27-2019, 10:13 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020