Question About Creating Lists

S

Scott

I'm sorry if most of my question's seem "petty", but as I've said before, I
need to know the petty just because I need to know.

This question is more along the lines of just having you guys either agree
or disgree with me, and if disagreeing to give the reasoning behind it, to
further my understanding of lists.

Am I safe in assuming that if the list your building contains number's it
will be written as follows:

But the minute you throw in something that's not a number it has to be
written as:
my_list = [1, 2, 3, 4, 'five']
my_list
[1, 2, 3, 4, 'five']

Unless five was defined, then it could be written as:
five = 5
my_list = [1, 2, 3, 4, five]
my_list
[1, 2, 3, 4, 5]


Is this the correct way of thinking? Or am I, by thinking this is the case,
crippling myself in my potential as a programmer
 
7

7stud

I'm sorry if most of my question's seem "petty", but as I've said before, I
need to know the petty just because I need to know.

This question is more along the lines of just having you guys either agree
or disgree with me, and if disagreeing to give the reasoning behind it, to
further my understanding of lists.

Please forgo the psychological self analysis from your future posts.

Am I safe in assuming that if the list your building contains number's it
will be written as follows:
my_list = [1, 2, 3, 4, 5]

But the minute you throw in something that's not a number it has to be
written as:
my_list = [1, 2, 3, 4, 'five']
my_list

[1, 2, 3, 4, 'five']

Unless five was defined, then it could be written as:
five = 5
my_list = [1, 2, 3, 4, five]
my_list

[1, 2, 3, 4, 5]

Is this the correct way of thinking? Or am I, by thinking this is the case,
crippling myself in my potential as a programmer

I don't think your question has anything to do with lists. Maybe this
will help: there is a distinction between what are called "literals"
and "variables". A variable is created like this:


num = 10

num is a variable. It's called a variable because it's value can
"vary":

num = 20


On the other hand the value 10 cannot vary, so it is not a variable.
What is it? It's called a "literal". Here are some examples of
literals:

10 --- integer literal
3.5 --- float literal
"hello" --- string literal

Literals are the values you can assign to variables. Finally, any
name without quotes around it is variable and it refers to a value
which python will substitute in place of that name(that doesn't apply
to python keywords like if, while, etc.)
 
S

Scott

Please forgo the psychological self analysis from your future posts.

Unfortunately I can't, that's how I am, love it or leave it. But if your
going to be condescending about it, please leave your future replies in your
outbox. Now don't take that as I don't appreciate your reply. I just don't
appreciate the tone of that statement. I wouldn't say something about your
pseudonym possibly making up for some personal deficiency only because it
wouldn't be right. Email etiquette is a beautiful thing.

And I'm sorry if you didn't mean it that way, but that's the way it read.
I don't think your question has anything to do with lists. Maybe this
will help: there is a distinction between what are called "literals"
and "variables".

My question was in fact about lists and their proper "syntax" (I'm guessing
that's the right word). Basically all I was asking was if I had the idea
down or not, which was meant to be implied when I wrote: Am I safe in
assuming....

Maybe I didn't write it the exact way to get the response I needed, and if
it read differently I'm sorry. But that's all I was asking.
 
J

James Stroud

Scott said:
Unfortunately I can't, that's how I am, love it or leave it. But if your
going to be condescending about it, please leave your future replies in your
outbox. Now don't take that as I don't appreciate your reply. I just don't
appreciate the tone of that statement. I wouldn't say something about your
pseudonym possibly making up for some personal deficiency only because it
wouldn't be right. Email etiquette is a beautiful thing.

And I'm sorry if you didn't mean it that way, but that's the way it read.




My question was in fact about lists and their proper "syntax" (I'm guessing
that's the right word). Basically all I was asking was if I had the idea
down or not, which was meant to be implied when I wrote: Am I safe in
assuming....

Maybe I didn't write it the exact way to get the response I needed, and if
it read differently I'm sorry. But that's all I was asking.

7stud probably meant that you don't need to apologize for asking
questions. The only stupid question is the one that goes unasked.

Also, I'm guessing that his (or her?) name is a reference to a card game
he (or she?) likes particularly.

James
 
S

Steve Holden

Scott said:
Unfortunately I can't, that's how I am, love it or leave it. But if your
going to be condescending about it, please leave your future replies in your
outbox. Now don't take that as I don't appreciate your reply. I just don't
appreciate the tone of that statement. I wouldn't say something about your
pseudonym possibly making up for some personal deficiency only because it
wouldn't be right. Email etiquette is a beautiful thing.
And that's a really sideways way to take a swipe at someone while
pretending to be too high-minded to do it (plus see James's comments
about other possible explanations). If you kiddies would take this fight
out into the playground perhaps the rest of the class can continue.

It *would* be helpful if you "just asked the question". You said in your
original post that "... I need to know the petty just because I need to
know", but that's an abuse of the word need unless you suffer from a
quite unusual psychological compulsion.

Another psychological compulsion, of course, is the inability to ignore
the irrelevant in other people's posts. The two apparently don't combine
well.
And I'm sorry if you didn't mean it that way, but that's the way it read.
To you. Get over it, this is Usenet. You will experience worse if you
stick at it long enough.
My question was in fact about lists and their proper "syntax" (I'm guessing
that's the right word). Basically all I was asking was if I had the idea
down or not, which was meant to be implied when I wrote: Am I safe in
assuming....

Maybe I didn't write it the exact way to get the response I needed, and if
it read differently I'm sorry. But that's all I was asking.
You can't really separate the syntax of lists from the syntax of the
rest of Python. Maybe you didn't mean syntax, it's hard to know. There
are, as has been pointed out, names and values. Names are references to
values. So after you say

five = 5

the following conditions are true:

[1, 2, 3, 4, 5] == [1, 2, 3, 4, five]
[1, 2, 3, 4, 'five'] != [1, 2, 3, 4, five]

Then execute

five = 'five'

and the truth value of both conditions flips, so the first is false and
the second is true.

The value referenced by the name five changes as new values are assigned
(in Python we tend to prefer to say "bound", to remind us that names are
really references) to it. The values represented by the literals 5 and
'five' will never change.

regards
Steve
 
S

Scott

And that's a really sideways way to take a swipe at someone while
pretending to be too high-minded to do it (plus see James's comments about
other possible explanations). If you kiddies would take this fight out
into the playground perhaps the rest of the class can continue.

It wasn't meant as a swipe, it was an example of what he did turned around.
There was no fight, at least on my end. What happened was I was confronted
something that I didn't appreciate it, and I made it known, just as most
people would if it happened face to face.
It *would* be helpful if you "just asked the question". You said in your
original post that "... I need to know the petty just because I need to
know", but that's an abuse of the word need unless you suffer from a quite
unusual psychological compulsion.

I see the point to getting to the point (lol). Most people don't worry about
my ramblings, and I've found that if they aren't included I get a 1-2 line
answer. That 1-2 line answer, while fine for most, just WILL not help me. It
actually makes it worse. I have a compulsion for knowledge that pass' far
beyond what most people would call healthy. So much so that I take
medications I'm not about to list here. If I attempt to learn something and
don't understand it, my entire mindset is taken over by my desire. I CAN NOT
sleep, eat, or function "normally" until I KNOW even the mundane. I hate
using the following example, but it helps some people understand how my mind
thinks. Have you ever seen a crack addict walking down the street (or on
tv) and their thoroughly searching the ground for the crack that they
dropped (that they never really had)? Take that and substitute crack for
knowledge and you'll have me. SO now you see why I start my posts the way I
do.
To you. Get over it, this is Usenet. You will experience worse if you
stick at it long enough.

I've already come to this understanding just as most who frequent any type
of "community" online, what with all the internet tough guys who frequent
most forums. That's in no way a knock at 7stud just an observation of most
troublemakers. But just because we all know its there, doesn't make it
acceptable, nor does it mean anyone should have to tolerate it just because
they chose to hop online. When someone makes it known a certain thing
bothers them, the polite thing to do would be to stop. I bet if I TYPED IN
CAPS LOCKS FOR EVERYTHING I WROTE, someone, if not everyone, would say
something. Its the same idea with what I did.

There are plenty of ways to stop this kind of treatment online, and if more
people knew that all they had to do was make a call to thier ISP, or to the
local police department with even just a pseudonym, that kind of treatment
would become less acceptable. I deal with these types of reports every day
at work. Fines can be impossed no matter where the harrasser is, and
depending on the context can actually involve jail time. Of course this
actual issue is very petty, and all that is/should be needed, was my
addressing the fact that it was not polite. That should of been the end of
it, and it seems to have been.

Believe it or not the problem lies with the people getting harrased, not the
harrasser. They believe nothing will be done and so they don't try, and
then they come to accept it. How wrong they are.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top