John Salerno escribió:
> Alexis Roda wrote:
>>
>> > The
>> > try block seems nicer because it doesn't have such an ugly-looking
>> check
>> > to make.
>>
>
> Why do you think that this try block is preferred over what I have (if I
> were to stick with the try block)?
My example has nothing t
Alexis Roda wrote:
> John Salerno escribió:
>> 2. Between the if block or the try block, which is more Pythonic?
>
> Since the command line argument is optional I don't think it should be
> considered and exceptional condition if it's missing, so the "if" block
> looks better to me. No idea if
Roel Schroeven wrote:
> But watch out with leading backslashes, as in
>
> subdirs = [r'\cgi-bin', r'\images', r'\styles']
>
> os.path.join will assume they are meant to be absolute paths, and will
> discard all previous components:
>
> >>> os.path.join('base', 'subdomain', r'\images')
> '\\im
John Salerno schreef:
> John Salerno wrote:
>> Dave Jones wrote:
>>> Hi John!
>>>
>>> About the path and the \'s, take a look at the os.path.join function.
>>> The function is smart enough to add the correct slash when joining
>>> directories.
>>>
>>> Dave
>> Interesting, thanks! I was reading abou
Dave Jones schreef:
> Hi John!
>
> About the path and the \'s, take a look at the os.path.join function.
> The function is smart enough to add the correct slash when joining
> directories.
But watch out with leading backslashes, as in
subdirs = [r'\cgi-bin', r'\images', r'\styles']
os.path.join
John Salerno escribió:
> 2. Between the if block or the try block, which is more Pythonic?
Since the command line argument is optional I don't think it should be
considered and exceptional condition if it's missing, so the "if" block
looks better to me. No idea if this is more pythonic.
> The
John Salerno wrote:
> Dave Jones wrote:
>> Hi John!
>>
>> About the path and the \'s, take a look at the os.path.join function.
>> The function is smart enough to add the correct slash when joining
>> directories.
>>
>> Dave
>
> Interesting, thanks! I was reading about the normcase() function, but
Dave Jones wrote:
> Hi John!
>
> About the path and the \'s, take a look at the os.path.join function.
> The function is smart enough to add the correct slash when joining
> directories.
>
> Dave
Interesting, thanks! I was reading about the normcase() function, but
your suggestion might be bett
Hi John!
About the path and the \'s, take a look at the os.path.join function.
The function is smart enough to add the correct slash when joining
directories.
Dave
--
http://mail.python.org/mailman/listinfo/python-list
# Create new subdomain directory (with subdirectories) in my 1and1 folder
import os
import sys
subdirs = [r'\cgi-bin', r'\images', r'\styles']
#if len(sys.argv) == 1:
# subdomain = raw_input('Enter subdomain name: ')
#else:
# subdomain = sys.argv[1]
try:
subdomain = sys.argv[1]
except
10 matches
Mail list logo