By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,760 Members | 1,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,760 IT Pros & Developers. It's quick & easy.

SyntaxError: Generator expression must be parenthesized if not sole argument.

P: 1
Hi!

I'm working on a class for a ODE solver, and get a syntax error after the list comprehension for the end of the snippet. I can't seem to find a intuitive better way to write the list - does anyone see what the error is?
Expand|Select|Wrap|Line Numbers
  1. class Problem: 
  2.     def __init__(self, h0, r, R, dt, T):
  3.     self.h0 = h0
  4.     self.r = r
  5.  
  6.  #(and so on)
  7.  
  8. problems = [Problem(h_0, r, R, T, float(dt) for dt in sys.argv[1:])]
>>>SyntaxError: Generator expression must be parenthesized if not sole argument.

Thanks!
Nov 13 '13 #1
Share this Question
Share on Google+
1 Reply

bvdet
Expert Mod 2.5K+
P: 2,851
You have a misplaced parenthesis. It should look like this:
Expand|Select|Wrap|Line Numbers
  1. problems = [Problem(h_0, r, R, T, float(dt)) for dt in sys.argv[1:]]
Nov 13 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.