473,383 Members | 1,837 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,383 software developers and data experts.

Class object creation on the fly

26
Hello all,

Lets say I have a class and I have stored the number of objects in a file.

The problem i am facing is that how to create the dynamic number of class objects seeing that I don't know their number and thus can't create directly using

object_name=class_name(arguments)

Can lambda function be used here????

Thanxx a lot !!!
May 22 '10 #1
2 3095
bvdet
2,851 Expert Mod 2GB
Do you mean instances? You can store instances dynamically in a list. Example:
Expand|Select|Wrap|Line Numbers
  1. >>> class Test(object):
  2. ...     def __init__(self):
  3. ...         pass
  4. ...     
  5. >>> number = 10
  6. >>> instance_list = []
  7. >>> for i in range(number):
  8. ...     instance_list.append(Test())
  9. ...     
  10. >>> 
May 22 '10 #2
nk28
26
Thanxx a lot...........

I was looking for this only..... :)
May 22 '10 #3

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

Similar topics

7
by: Richard | last post by:
Hi all, I am looking for some help on understanding the overhead associated with object creation in Java. I am writing an application where I have written a class to encapsulate some text...
2
by: Krzysztof Stachlewski | last post by:
I tried to run the following piece of code: Python 2.3.4 (#53, May 25 2004, 21:17:02) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> o = object() >>> o.a...
0
by: pavana | last post by:
Hi, I have a class with a constructor which does some socket initialisation. I need to call the constructor before the dll is loaded. For this, I do something like this in the code (written in...
106
by: A | last post by:
Hi, I have always been taught to use an inialization list for initialising data members of a class. I realize that initialsizing primitives and pointers use an inialization list is exactly the...
7
by: Naren | last post by:
Hello All, I am confused on the object creation. Is it the constructor or something else? When constrcutor is called , Is space allocated for the object alraedy and only intialisation to...
2
by: Hugo Wetterberg | last post by:
Hi all, Is there any way to intercept an object creation and supply another object? As when using proxy objects in remoting. The scenario is that i have a class B that extends A, when new A() is...
3
by: Balaji Kannan | last post by:
Hi, In dot net during component development i have used some member variables in the class file. Inside the class i have used the member declaration and the instant handling in the following...
8
by: Anthony Munter | last post by:
I have a web application with impersonate=”true” in Web.config and on my own logon page I allow the user to either - specify a userid/password for the app to impersonate when calling legacy...
4
by: shaanxxx | last post by:
how can we restrict object creation on heap ? soln1: overload new any other way to do this ?
0
by: fiona | last post by:
Reading, Berkshire, UK 05 June 2007 - Crainiate Software make details available of the release of Objecto Framework 2.0, an upgrade to their enterprise business component framework, designed to...
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...

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.