I get what you are trying to say.. but I'm looking at the code after changing names, and I think it makes more sense in the code my way because of the following lines..outFile = open(aFile.lower(), 'w')#open 'afile' named with lowercase to 'w'rite
outFile.write(zFile.read(insideZip))#write what you
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
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
>
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..
>
> ou
Comment on #2 I am hearing that from basically everyone here... But as I just wrote in another reply, descriptional names dont work for me.. I like functional names... So, using 'more concise' (meaning descriptional) do not help me, and haven't helped me in the last few years I've written code
On Mon, 16 Oct 2006, Chris Hengge wrote:
> Have you even read my code to see if you find it cryptic? I'm starting
> to beleive people just read the one comment on possibly using better
> naming conventions and assumed I had picked completely irrelivent names.
Hi Chris,
Sometimes one of us (o
Yes, I read your code, as well as this entire thread. All I'm saying is
that:
#1) I'm not complaining about your naming conventions.
#2) It would be easier *on you* in the long run if you use more concise
names.
#3) Code how you are comfortable coding...just don't expect "aFile" to
fly in a
Chris Hengge wrote:
> Have you even read my code to see if you find it cryptic? I'm starting
> to beleive people just read the one comment on possibly using better
> naming conventions and assumed I had picked completely irrelivent names.
Well, Chris, what can I say? We're busy people and we ge
Have you even read my code to see if you find it cryptic? I'm starting to beleive people just read the one comment on possibly using better naming conventions and assumed I had picked completely irrelivent names.
On 10/16/06, Jonathon Sisson <[EMAIL PROTECTED]> wrote:
Chris Hengge wrote:> I chose
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..
>
> ou
[quote]and I didn't read your code[/quote]How's that supposed to help? =D
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Chris Hengge wrote:
> I didn't come up with those variable names willy nilly...
I know :)
I just wanted to make it clear that your statement 'that's what comments
are for' wasn't really a good way to look at it.
If you have to write a comment because your usage of variables, or
something else you
I didn't come up with those variable names willy nilly... I chose them because they reflect their functionality.. Which to me, is much more important then anything else... if I go back and look at code months later.. I have an easier time remember names based on functionality, and less of an easy t
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..
>
> outF
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)) # Writ
Chris Hengge wrote:
> Here is my solution, completed with (I think) all your suggestions...
>
> #
> def extractZip(filePathName):
> """
> This method recieves the zip file name for decompression, placing the
> cont
Using one of the things you suggested...> if "/" in afile:> aZipFile = afile.rsplit('/', 1)[-1] # Split file> based on criteria.> outfile = open(aZipFile, 'w') # Open output buffer
> for writing.> outfile.write(zfile.read(a
Excellent suggestions! I'll see how many of them I can impliment.Part of my project 'criteria' is that someone that doesn't know python (or possibly programming) should be able to follow my work to add a new system to the list. Right now I've got it setup so it only takes 3 steps. The reason for th
Chris Hengge wrote:
> I like this little snip of code from your suggestion, and I may
> incorporate it...
>
> for ext in ['.cap', '.hex', '.fru', '.cfg']:
> if aFile.lower().endswith(ext):
> return True
>
> Just for sake of sharing.. here is my entire method..
Hopefully for
The code in my last email that I stated worked, is doing exactly what I want (perhaps there is a better method, but this is working)The slash detection is for the subdirectories located inside of a zip file. The name list for a file located inside a zipped folder shows up as folder/file.ext in wind
Chris Hengge wrote:
> After getting some sleep and looking at my code, I think I was just to
> tired to work through that problem =P
>
> Here is my fully working and tested code..
> Thanks to you all for your assistance!
>
> if "/" in afile:
> aZipFile = afile.rsplit('/', 1)[-1] # Split file
After getting some sleep and looking at my code, I think I was just to tired to work through that problem =PHere is my fully working and tested code..Thanks to you all for your assistance!if "/" in afile:
aZipFile = afile.rsplit('/', 1)[-1] # Split file based on criteria. outfile = open(aZi
Chris Hengge wrote:
> I was using afile.split("/"), but I'm not sure how to impliment it...
Did you see my hint below? Is there something you don't understand about it?
Kent
>
> if "/" in afile: (for some reason I can't add 'or "\" in afile' on this
> line)
> outfile = open(afil
Chris Hengge wrote:
> I must have not been clear.. I have a zip file with folders inside..
> When I extract it.. I dont want the folder structure, just the files..
>
> using split doesn't seem to help in this situation.. unless I'm not
> putting the results in the right spot..
Can you show us wh
I must have not been clear.. I have a zip file with folders inside.. When I extract it.. I dont want the folder structure, just the files.. using split doesn't seem to help in this situation.. unless I'm not putting the results in the right spot..
Thanks again though. On 10/15/06, Luke Paireepinar
On 10/14/06, Chris Hengge <[EMAIL PROTECTED]> wrote:
Guess nobody has had a chance to point me in the write direction on this problem yet?Thats ok, I've gotten a ton of other code written, and I'll come back to this tricky part later.This particular project I've been working on to automate some of
Guess nobody has had a chance to point me in the write direction on this problem yet?Thats ok, I've gotten a ton of other code written, and I'll come back to this tricky part later.This particular project I've been working on to automate some of my job at work has been an excellent learning experie
Correction... The first comment I just realised I needed "\\" to make it work.. so that issue is gone.. On 10/14/06, Chris Hengge <
[EMAIL PROTECTED]> wrote:I was using afile.split("/"), but I'm not sure how to impliment it...
if "/" in afile: (for some reason I can't add 'or "\" in afile' on this
I was using afile.split("/"), but I'm not sure how to impliment it... if "/" in afile: (for some reason I can't add 'or "\" in afile' on this line) outfile = open(afile, 'w') # Open output buffer for writing. (to open the file, I can't split here)
outfile.write(zfile.
Chris Hengge wrote:
> Ok, last problem with this whole shebang...
>
> When I write the file from the zip, if it is in a subfolder, it will
> error..
> The code below will detect if the file in contained inside a directory
> in the zip, but I just want it to write it like it wasn't.
> Another wor
Ok, last problem with this whole shebang...When I write the file from the zip, if it is in a subfolder, it will error.. The code below will detect if the file in contained inside a directory in the zip, but I just want it to write it like it wasn't.
Another wordsZipfile.zip looks like thisfile.extf
Got that working now, thanks. I've been using activepythons release, and they dont have 2.5 prepared yet. Guess I should just upgrade without them?On 10/14/06,
Kent Johnson <[EMAIL PROTECTED]> wrote:Chris Hengge wrote:
> Oops I get an error using that code..>> if filename.endswith('.cap','
Chris Hengge wrote:
> Oops I get an error using that code..
>
> if filename.endswith('.cap','.fru','.hex') or
> filename.endswith('.sdr', '.cfg'):
> TypeError: slice indices must be integers or None
With Python 2.5 you can do this with a tuple argument. You need an extra
set of parenthe
Oops I get an error using that code.. if filename.endswith('.cap','.fru','.hex') or filename.endswith('.sdr', '.cfg'):TypeError: slice indices must be integers or None
On 10/14/06, Bill Burns <[EMAIL PROTECTED]> wrote:
Chris Hengge wrote:> First question..>> This is the code that I have:> f
Bill Burns wrote:
> Maybe take a look at 'endswith':
>
> Example:
> for filename in zfile.namelist():
> if filename.endswith('.exe') or filename.endswith('.txt'):
> # do something with filename
In Python 2.5 endswith() can take a tuple of strings to try:
if filename.endswith(('.e
Excellent suggestion! Thanks!I have a question... is endswith() case sensitive?On 10/14/06, Bill Burns <
[EMAIL PROTECTED]> wrote:Chris Hengge wrote:> First question..
>> This is the code that I have:> for filename in zfile.namelist():> outfile = open(filename, 'w')> outfile.write(z
Chris Hengge wrote:
> First question..
>
> This is the code that I have:
> for filename in zfile.namelist():
> outfile = open(filename, 'w')
> outfile.write(zfile.read(filename))
> outfile.close()
>
> Is there a way to say :
> for filename in zfile.namelist() contains '.tx
> Is there a way to say :
> for filename in zfile.namelist() contains '.txt, .exe':
Hi Chris,
Yes. It sounds like you want to filter zfile.namelist() and restrict the
entries to those with particular extensions. Try a "list comprehension"
to filter for those interesting filenames:
for fil
First question..This is the code that I have:for filename in zfile.namelist(): outfile = open(filename, 'w') outfile.write(zfile.read(filename)) outfile.close()Is there a way to say :
for filename in zfile.namelist() contains '.txt, .exe': outfile = open(filename, 'w')
39 matches
Mail list logo