473,406 Members | 2,356 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,406 software developers and data experts.

eval ? ['LBBW': checked]

You can use the exec statement (note that I set the if-condition to
1=true for the example, and I used different names for outer and inner
loop indexes):
for index in range(1,4): .... list = []
.... for inner in range(1,7):
.... if 1:
.... list.append(inner)
.... foo = "list_" + str(index) + "= list"
.... exec foo
.... list_1 [1, 2, 3, 4, 5, 6] list_2 [1, 2, 3, 4, 5, 6] dir() ['__builtins__', '__doc__', '__name__', 'foo', 'index', 'inner', 'list',
'list_1', 'list_2', 'list_3'] globals()

{'list_3': [1, 2, 3, 4, 5, 6], 'index': 3, 'list_1': [1, 2, 3, 4, 5, 6],
'list_2': [1, 2, 3, 4, 5, 6], '__builtins__': <module '__builtin__'
(built-in)>, 'list': [1, 2, 3, 4, 5, 6], 'inner': 6, '__name__':
'__main__', 'foo': 'list_3= list', '__doc__': None}

__________________

I'm trying to use eval (is the right function? ) to generate empty lists
with different names(es. list_1, list_2, list_3, ...) in a loop similar
to:

for index in range(1,4):
list=[]
for index in range(1,7):
if <condition>:
list.append(1)
foo='list_'+str(index)+'=list'
eval(foo)

I am not a programmer as you probably see from the code and I do not
even know if this is the right approach to do that in Python (I used
this structure with Matlab that I want now to dismiss ...)

Any help?
Thanks
angelo

--
http://mail.python.org/mailman/listinfo/python-list

+----------------------------------------------------------------------+
| LBBW Security Information |
+----------------------------------------------------------------------+
| - Die Nachricht war weder verschluesselt noch digital unterschrieben |
+----------------------------------------------------------------------+
Der Inhalt dieser E-Mail ist vertraulich. Falls Sie nicht der angegebene
Empfänger sind oder falls diese E-Mail irrtümlich an Sie adressiert wurde,
verständigen Sie bitte den Absender sofort und löschen Sie die E-Mail
sodann. Das unerlaubte Kopieren sowie die unbefugte Übermittlung sind nicht
gestattet. Die Sicherheit von Übermittlungen per E-Mail kann nicht
garantiert werden. Falls Sie eine Bestätigung wünschen, fordern Sie bitte
den Inhalt der E-Mail als Hardcopy an.

The contents of this e-mail are confidential. If you are not the named
addressee or if this transmission has been addressed to you in error,
please notify the sender immediately and then delete this e-mail. Any
unauthorized copying and transmission is forbidden. E-Mail transmission
cannot be guaranteed to be secure. If verification is required, please
request a hard copy version.


Jul 18 '05 #1
0 1049

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jean-Sébastien Bolduc | last post by:
Hello, I would like to associate a local namespace with a lambda function. To be more specific, here is exactly what I would want: def foo(): a = 1 f = lambda x : a*x return f
0
by: Holger Joukl | last post by:
Hi, what version of python are you using? I got the same error when invoking a customized, 2-year-old version of distutils with python 2.3.3 (instead of 1.5.2, as before). Reason is code in...
9
by: HikksNotAtHome | last post by:
This is a very simplified example of an Intranet application. But, is there an easier (or more efficient) way of getting the decimal equivalent of a fraction? The actual function gets the select...
7
by: Reply Via Newsgroup | last post by:
This might sound sad... someone requesting a disertation on the 'eval' statement... but... I've been reading someone else's post - they had a huge calander like script and a handful of folk cursed...
1
by: Chris | last post by:
I have a class method that returns a DataSet. I use bind this to my Repeater control. Inside the Repeater i have <ItemTemplate> <li><%# DataBinder.Eval(Container.DataItem, "name") %> <%#...
6
by: Dan | last post by:
I need to be able to execute a command that is defined in a string. In VBScript, I can do it with the Eval function. How can I do it in VB.Net? I need something like: Dim x As Integer...
21
by: hemant.singh | last post by:
Hello all, I am try'g to send window.location.href to the server script who will generate dynamic javascript according to the referral name comg in as param Now bcz <script language="javascript"...
3
by: idletask | last post by:
I have an SQLDataSource control, which is bound to an ASP.net 2.0 GridView control. It outputs a list of documents that a user can check in or check out of the database. In my gridview, I have...
10
by: Gordon | last post by:
I have a script that creates new objects based on the value of a form field. Basically, the code looks like this. eval ('new ' + objType.value + '(val1, val2, val3'); objType is a select with...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.