>> > 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
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
> 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
> 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.
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
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
"
__
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
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
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_
>
>
>
> 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
Сергій 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
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
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
Сергій 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
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
Сергій 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(
--- ÁÕàÓöÙ <[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
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
18 matches
Mail list logo