I find your example rather amusing, since it makes it sound like you want this fictional mechanic to pick his parts by the brand name, rather then by how well the part works (in description vs context)... Your analogy seems to push that the brand name would inherently give the descriptive name.... which is fine..  Personally.. I dont care if you call it a motor or anything else... a motor is a motor because of its functionality... not because "motor" itself has some great descriptive meaning. We only understand what motor means because its been the standard to describe the hunk of metal, rubber, and plastic under the hook of an automobile. now.. if I've never heard of a motor... I'd learn what it is be getting some basic understanding of its functionality... it wouldn't matter what you called it if I've never heard the word, I'd have to know what it does to understand what distiguishes it from a bicycle. The only exception is when new terminology isn't defined for an object, such as "motor-carriage"(still have that darn motor word that I dont understand without knowing atleast basic functionality) or "auto-mobile"...(so... is this a bike that peddles itself? and flying machine? a cellphone that beams me to work automagically at 9:00am? We call them cars? why? because its what people stuck with from "motor-'car'riage" after adapting to the new machine.. You want to add to the mess... A truck is defined as a tool to move items around... mentally, I think of something more like a wheel-barrel.. but wait.. wheel-barrels dont look like barrels... either way... poor naming =P
Names are nothing more then a distinguishing mark to define something that hasn't already been defined.. Humans are great because they wrap huge functional and contextual definitions to names and dont even realise it.. Think of  your own name.. if that is all I used to describe you I'd never understand what was different between you and anyone else with your name.. but when I think of "you"( aka you in context), I can list tons of stuff that makes you who you are.. Try and imagine your name if I took it completely out of context and functionality... You'd have some name more like "Brian, slacker of the eastside, teller of the great jokes, driver of the SUV, son of Marry and George, birth-father of little billy, owner of many pc's"... vs the guy that lives in another neighborhood who'd have to be named "Brian, civil servant of the eastside, impressor of women, driver of the sports car, Adopted,birth father to many across the town, owner of no pc's" if you wanted to describe someone.

Rambling aside... I was just trying to take a light hearted spin because the poor mechanic we have subjected for abuse in this debate struck me funny.

On 10/17/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
Kent Johnson wrote:
> Chris Hengge wrote:
>
>> I chose the way I used the names because to me...
>>
>> outFile = open(aFile.lower(), 'w') # Open output buffer for writing.
>> = open a file with lowercase name for writing.
>> it is implied that aFile is from the zip, since it is created in the
>> loop to read the zip..
>>
>> outFile.write(zFile.read(insideZip)) # Write the file.
>> = write what is read from inside the zip file.
>>
>
> This sub-thread seems to have turned into "let's beat on Chris for the
> way he names things" which certainly isn't what I intended. Ultimately
> it is up to the program author to use the names that he thinks
> communicate most clearly.
>
Well, yes, and it's up to the auto mechanic to use the parts he thinks
are best when he fixes your car.
However, one hopes that he has training in how to determine which parts
are the most durable, safest, etc, etc.
Similarly, while it's up to you to choose variable names, we still hope
that you know why you're choosing certain names.
> But I think the actual naming was secondary to the my main point which
> is that the value for 'insideZip' is read from the zip, if you assign to
> that name and keep it in that name the code is easier to follow because
> the value that doesn't change stays in a name that doesn't change.
>
> So using your names, it would read
>              for insideZip in zFile.namelist():
>                  for ext in ['.cap', '.hex', '.fru', '.cfg', '.sdr']:
>                      if insideZip .lower().endswith(ext):
>                          if "/" in insideZip :
>                            aFile = aFile.rsplit('/', 1)[-1]
>                          elif  "\\" in insideZip :
>                            aFile = aFile.rsplit('\\', 1)[-1]
>                          else:
>                            aFile = insideZip
>
> This way inzideZip is always the name from inside the zip, and aFile is
> always the name of the file to write.
>
I think it'd be most clear if you did something like:
ext = ['.cap','.hex','.fru','.cfg','.sdr']
for zipFile in zFile.namelist():
       if os.path.splitext(zipFile)[-1] in ext:
          outFile = os.path.split(zipFile)[-1]

but that's just me :)

I've gone back and read your code.
The problem Kent was pointing out was that your for loop was iterating
over a variable called aFile,
and you were changing this variable during the loop.  This is generally
considered Bad Practice.
That's all he meant.
I think.

HTH,
-Luke
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to