473,385 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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
1 31876
bvdet
2,851 Expert Mod 2GB
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

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

Similar topics

13
by: snacktime | last post by:
I need to convert a generator expression to a list expression so it will work under python 2.3. I rewrote this: for c in range(128): even_odd = (sum(bool(c & 1<<b) for b in range(8))) & 1 ...
16
by: Peter Otten | last post by:
To confuse a newbies and old hands alike, Bengt Richter wrote: > Need something more straightforward, e.g., a wrapped one-liner: > > >>> def guess(n=3): print ("You're right!", 'No more tries...
9
by: bonono | last post by:
Hi, I initially thought that generator/generator expression is cool(sort of like the lazy evaluation in Haskell) until I notice this side effect. >>>a=(x for x in range(2)) >>>list(a) ...
7
by: Laurent Pointal | last post by:
on win32] Given the following: 45 .... (<generator object at 0x00A79788>,) .... File "<stdin>", line 1 SyntaxError: invalid syntax
0
by: Maric Michaud | last post by:
I faced a strange behavior with generator expression, which seems like a bug, for both python 2.4 and 2.5 : .... a = 1, 2, 3 .... b = 1, 2, 3 .... C = list((e,f) for e in a for f...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.