Well, I've tried both and can't produce what I was doing with the for
construct.
With a listpl = ['a', 'b', 'c', 'd'] of the path components I'm
trying to add justified non repeated path elements, say pl[2] and pl
[3] to csvline so that csvline would end up '"",'*x plus '"c","d",'
>>> pl
Lee Cullens wrote:
> On Jun 4, 2005, at 6:54 PM, Kent Johnson wrote:
>> dlst = os.listdir(pname)
>> if len(dlst):
>> for dlf in dlst:
>>
>> There is no need for the if(dlst); if the list is empty the iteration
>> will do nothing. You can write this as
>> for dlf in os.listdir(pn
On Jun 4, 2005, at 9:32 PM, Javier Ruere wrote:
> Lee Cullens wrote:
>
>> The initial os.walk() approach I tried is simple in concept:
>>
>> pgo = os.walk(base_directory)
>> for xnode in pgo:
>>
>>
>> but I ended up with much more processing in having to sort the rows
>> and then blank repeat
Thanks for the critique Kent
On Jun 4, 2005, at 6:54 PM, Kent Johnson wrote:
> Lee Cullens wrote:
>
>
>> Pythonese/Efficiency/Generalese critique please
>>
>> I'm new to Python and as an exercise created a little utility module.
>> I'm learning from the O'Reilly books and updating that understan
Lee Cullens wrote:
> The initial os.walk() approach I tried is simple in concept:
>
> pgo = os.walk(base_directory)
> for xnode in pgo:
>
>
> but I ended up with much more processing in having to sort the rows
> and then blank repeated cells, than the recursive listdir approach
> which ga
Kent Johnson wrote:
> dlst = os.listdir(pname)
> if len(dlst):
> for dlf in dlst:
>
> There is no need for the if(dlst); if the list is empty the iteration will do
> nothing. You can write this as
> for dlf in os.listdir(pname):
Though it is quite distant, there is an else s
Kent Johnson wrote:
> Javier Ruere wrote:
>
>>for i in range(alvl, clvl):
>> csvline = csvline + '"' + pl[i] + '",'
>>
>>should be replaced by something like the following:
>>
>>cvsline += '"' + pl[alvl:clvl].join('",')
>
>
> or maybe more like this:
> cvsline += '"' + '",'.join(pl[alvl:clvl
Javier Ruere wrote:
> for i in range(alvl, clvl):
> csvline = csvline + '"' + pl[i] + '",'
>
> should be replaced by something like the following:
>
> cvsline += '"' + pl[alvl:clvl].join('",')
or maybe more like this:
cvsline += '"' + '",'.join(pl[alvl:clvl]) + '",'
though if alvl == clvl
Lee Cullens wrote:
> Pythonese/Efficiency/Generalese critique please
>
> I'm new to Python and as an exercise created a little utility module.
> I'm learning from the O'Reilly books and updating that understanding
> from the 2.4 documentation.
>
> I would appreciate any comments you see fit
Sorry about the double post. I sent with the wrong from address so I
resent with the correct address and before I could cancel the first
the moderator had let it through :~)
Lee C
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailm
Thank you for the critique Javier.
You made some good points that I will play with before moving on.
Beyond that, I intentionally neglected error checking in this
exercise as you may have surmised. Checking input arguments and
handling access restrictions gracefully would indeed be important
Thank you for the critique Javier.
You made some good points that I will play with before moving on.
Beyond that, I intentionally neglected error checking in this
exercise as you may have surmised. Checking input arguments and
handling access restrictions gracefully would indeed be important
On Fri, 3 Jun 2005, Xiaoxia Xu wrote:
> I tried to use a Python library module random() to generate some noise
> to my data. But the interpreter gave me an error message saying
> NameError: name 'random' is not defined. I thought this error is
> because I don't have the pertinent library includ
Don't forget to call : import random
try:
import random
print random.randint(2,8)
print random.random()
good luck
pujo
On 6/4/05, Xiaoxia Xu <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I tried to use a Python library module random() to generate some
> noise to my data. But the interpreter gave me
Hello,
I tried to use a Python library module random() to generate some
noise to my data. But the interpreter gave me an error
message saying NameError: name 'random' is not defined.
I thought this error is because I don't have the pertinent
library included. Could anyone tell me how can I ge
Lee Cullens wrote:
> Pythonese/Efficiency/Generalese critique please
>
> The utility produces a csv file of a specified directory tree for import
> to a spreadsheet application. My first attempt employed os.walk(), but
> I found converting the results of such more troublesome than the
> recurs
Aaron Elbaz wrote:
> Hi again :),
>
> My goal is to store an image file with lots of information relating to
> the image and the file it was extracted from, persistantly. Pickle seems
> like a really easy way to do this. So I'm wondering, is it possible to
> serialize
> things like images into a
Hi again :),
My goal is to store an image file with lots of information relating to
the image and the file it was extracted from, persistantly. Pickle seems
like a really easy way to do this. So I'm wondering, is it possible to serialize
things like images into a pickle? How do I do it? If not,
On 6/3/05, Cedric BRINER <[EMAIL PROTECTED]> wrote:
hi,How
can I know if a script is launched interactively or not because I'd
like to make a script verbose or not depending if it is executed as
interactive or not.eg.If I invoke it in a shell.. then it can be verboseIf it is launched from a crontab
Pythonese/Efficiency/Generalese critique pleaseI'm new to Python and as an exercise created a little utility module. I'm learning from the O'Reilly books and updating that understanding from the 2.4 documentation. The utility produces a csv file of a specified directory tree for import to a sprea
20 matches
Mail list logo