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? -
class Problem:
-
def __init__(self, h0, r, R, dt, T):
-
self.h0 = h0
-
self.r = r
-
-
#(and so on)
-
-
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!
1 31876 bvdet 2,851
Expert Mod 2GB
You have a misplaced parenthesis. It should look like this: - problems = [Problem(h_0, r, R, T, float(dt)) for dt in sys.argv[1:]]
Sign in to post your reply or Sign up for a free account.
Similar topics
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
...
|
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...
|
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)
...
|
by: Laurent Pointal |
last post by:
on win32]
Given the following:
45
....
(<generator object at 0x00A79788>,)
....
File "<stdin>", line 1
SyntaxError: invalid syntax
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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$) {
}
...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |