Re: [Tutor] create 1000 000 variables

2006-07-16 Thread Danny Yoo
>> > In fact I want to create a list of variables from the list of strings >> > >> > Example: ['var1', 'var2', 'var3'] - list of strings >> >> Do you know about "dictionaries" yet? > Yes. I know about dictionaries. Hello, Can you show us an example of the kind of dictionary usage you've us

Re: [Tutor] create 1000 000 variables

2006-07-16 Thread Kent Johnson
Michael P. Reilly wrote: > Good. But one VERY important point to note is that that you are not working > with "variables" here. You are working with members of a class instance. > This is a very different beast. You could just use getattr(), setattr() and > delattr() for these. > > But continuin

Re: [Tutor] create 1000 000 variables

2006-07-16 Thread Сергій
> In fact I want to create a list of variables from the list of strings>> Example: ['var1', 'var2', 'var3'] - list of strings Ok, let's stop for the moment.Do you know about "dictionaries" yet?  If not, we should point this out to you, because they solve the problem you describe.     Yes. I kno

Re: [Tutor] create 1000 000 variables

2006-07-15 Thread Danny Yoo
> In fact I want to create a list of variables from the list of strings > > Example: ['var1', 'var2', 'var3'] - list of strings Ok, let's stop for the moment. Do you know about "dictionaries" yet? If not, we should point this out to you, because they solve the problem you describe.

Re: [Tutor] create 1000 000 variables

2006-07-15 Thread Michael P. Reilly
Good.  But one VERY important point to note is that that you are not working with "variables" here.  You are working with members of a class instance.  This is a very different beast.  You could just use getattr(), setattr() and delattr() for these. But continuing... you might want to think about t

Re: [Tutor] create 1000 000 variables

2006-07-15 Thread Сергій
And I don't like this "BAD CODE1" and "BAD CODE2" How to rewrite bad codes???   about "BAD CODE2" - I've fount a good solution (or it seems to me to be good :) ):   " tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] for i in tags: Show_step(i) for j in getattr(parser, i):  print j "   __

Re: [Tutor] create 1000 000 variables

2006-07-15 Thread Сергій
But again, like others have suggested, you should rethink your problem and your solution before starting down your path.  What are you really capturing?   Rethink problem... I try to use sgmllib - get all info tagged in "h1"... "h6" I've created file lister.py:   "from sgmllib import SGMLParser

Re: [Tutor] create 1000 000 variables

2006-07-15 Thread Michael P. Reilly
On 7/14/06, Сергій <[EMAIL PROTECTED]> wrote: suppose I need to create 1000 000 variables var_1, var_2, var_100   how to do this using for? (something like for i in range(100): ___var_ You should think about not creating variables like this, it is bad programming and continuing to use

Re: [Tutor] create 1000 000 variables

2006-07-15 Thread Dave Kuhlman
On Fri, Jul 14, 2006 at 09:25:57PM -0400, Etienne Robillard wrote: > > --- ÁÕàÓöÙ <[EMAIL PROTECTED]> wrote: > > > suppose I need to create 1000 000 variables > > var_1, var_2, var_100 > > > > how to do this using for? > > (something like > > for i in range(100): > > ___var_ > > >

Re: [Tutor] create 1000 000 variables

2006-07-15 Thread Alan Gauld
> In fact I want to create a list of variables from the list of strings> > Example: ['var1', 'var2', 'var3'] - list of strings> And I need to create variables var1, var2, var3 named as strings in the> list, and:> var1 == 'var1'> var2 == 'var2'> var3 == 'var3'> > How to do this using only

Re: [Tutor] create 1000 000 variables

2006-07-15 Thread Kent Johnson
Сергій wrote: > In fact I want to create a list of variables from the list of strings > Example: ['var1', 'var2', 'var3'] - list of strings > And I need to create variables var1, var2, var3 named as strings in > the list, and: > var1 == 'var1' > var2 == 'var2' > var3 == 'var3' > How to do this

Re: [Tutor] create 1000 000 variables

2006-07-15 Thread Kent Johnson
Fabrizio Milo aka misto wrote: > Hi! > I don't know why you want to do that but actually it is possibble. > > for i in xrange(1): > ...exec( 'var_%s = "var_%s"' %(i,i), locals() ) > > var_100 > 'var_100' It is possible but it's unlikely that it i

Re: [Tutor] create 1000 000 variables

2006-07-15 Thread Fabrizio Milo aka misto
Hi! I don't know why you want to do that but actually it is possibble. >>>for i in xrange(1): ...exec( 'var_%s = "var_%s"' %(i,i), locals() ) >>>var_100 'var_100' Regards. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/l

Re: [Tutor] create 1000 000 variables

2006-07-15 Thread Luke Paireepinart
Сергій wrote: > In fact I want to create a list of variables from the list of strings > > Example: ['var1', 'var2', 'var3'] - list of strings > And I need to create variables var1, var2, var3 named as strings in > the list, and: > var1 == 'var1' > var2 == 'var2' > var3 == 'var3' > > How to

Re: [Tutor] create 1000 000 variables

2006-07-15 Thread Сергій
In fact I want to create a list of variables from the list of strings   Example: ['var1', 'var2', 'var3'] - list of strings And I need to create variables var1, var2, var3 named as strings in the list, and: var1 == 'var1' var2 == 'var2' var3 == 'var3'   How to do this using only my list and "f

Re: [Tutor] create 1000 000 variables

2006-07-14 Thread Kent Johnson
Сергій wrote: > suppose I need to create 1000 000 variables > var_1, var_2, var_100 > how to do this using for? > (something like > for i in range(100): > ___var_ Rather than creating 100 variables, create a list with 100 values. data = [] for i in range(100): data.append(

Re: [Tutor] create 1000 000 variables

2006-07-14 Thread Etienne Robillard
--- ÁÕàÓöÙ <[EMAIL PROTECTED]> wrote: > suppose I need to create 1000 000 variables > var_1, var_2, var_100 > > how to do this using for? > (something like > for i in range(100): > ___var_ How would you consider NOT creating 100,000 variables ?? Answer that question and you shoul

[Tutor] create 1000 000 variables

2006-07-14 Thread Сергій
suppose I need to create 1000 000 variables var_1, var_2, var_100   how to do this using for? (something like for i in range(100): ___var_ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor