In article ,
Tim Chase wrote:
>On 08/18/10 21:47, Steven D'Aprano wrote:
>>
>> Frankly, I think the OP doesn't really know what he wants, other than
>> premature optimization. It's amazing how popular that is :)
>
>You see, the trick to prematurely optimizing is to have a good
>algorithm for pre
On 08/18/10 21:47, Steven D'Aprano wrote:
Frankly, I think the OP doesn't really know what he wants, other than
premature optimization. It's amazing how popular that is :)
You see, the trick to prematurely optimizing is to have a good
algorithm for prematurely optimizing...the real question th
On Wed, 18 Aug 2010 16:03:58 +0200, Frederic Rentsch wrote:
> On Mon, 2010-08-16 at 23:17 +, Steven D'Aprano wrote:
>> On Mon, 16 Aug 2010 20:40:52 +0200, Frederic Rentsch wrote:
>>
>> > How about
>> >
>> [obj for obj in dataList if obj.number == 100]
>> >
>> > That should create a lis
On Mon, 2010-08-16 at 23:17 +, Steven D'Aprano wrote:
> On Mon, 16 Aug 2010 20:40:52 +0200, Frederic Rentsch wrote:
>
> > How about
> >
> [obj for obj in dataList if obj.number == 100]
> >
> > That should create a list of all objects whose .number is 100. No need
> > to cycle through a
On Mon, 16 Aug 2010 20:40:52 +0200, Frederic Rentsch wrote:
> How about
>
[obj for obj in dataList if obj.number == 100]
>
> That should create a list of all objects whose .number is 100. No need
> to cycle through a loop.
What do you think the list comprehension does, if not cycle throug
On Sun, 2010-08-15 at 15:14 +0200, Peter Otten wrote:
> ChrisChia wrote:
>
> > dataList = [a, b, c, ...]
> > where a, b, c are objects of a Class X.
> > In Class X, it contains self.name and self.number
> >
> > If i wish to test whether a number (let's say 100) appears in one of
> > the object, a
On Sun, 15 Aug 2010 05:47:04 -0700, ChrisChia wrote:
> dataList = [a, b, c, ...]
> where a, b, c are objects of a Class X. In Class X, it contains
> self.name and self.number
>
> If i wish to test whether a number (let's say 100) appears in one of the
> object, and return that object,
> is that o
ChrisChia wrote:
dataList = [a, b, c, ...]
where a, b, c are objects of a Class X.
In Class X, it contains self.name and self.number
If i wish to test whether a number (let's say 100) appears in one of
the object, and return that object,
is that only fast way of solving this problem without iter
ChrisChia wrote:
> dataList = [a, b, c, ...]
> where a, b, c are objects of a Class X.
> In Class X, it contains self.name and self.number
>
> If i wish to test whether a number (let's say 100) appears in one of
> the object, and return that object,
> is that only fast way of solving this problem
On Jul 31, 2:51 pm, Alexnb <[EMAIL PROTECTED]> wrote:
> Lets say we have this list:
>
> funlist = ['a', 'b', 'c']
>
> and lets say I do this:
>
> if funlist[4]:
> print funlist[4]
>
> I will get the exception "list index out of range"
>
> How can I test if the list item is empty without getting
Alexnb:
> How can I test if the list item is empty without getting that exception?
In Python such list cell isn't empty, it's absent. So you can use
len(somelist) to see how much long the list is before accessing its
items. Often you can iterate on the list with a for, so you don't need
to care of
"mohan" wrote:
> At the end I had to close down my entire python compiler. I am using
> Python compiler with following specs in Windows XP OS.
>
> Pythonwin - Python IDE and GUI Framework for Windows.
> PythonWin 2.2.1 (#34, Feb 25 2003, 11:29:09) [MSC 32 bit (Intel)] on
> win32.
> Portions Copyri
Tom wrote:
> Peter Hansen wrote:
>> Where do you think those double quotation marks came from? What
>> happens if you try the following instead of using the variables you
>> were trying to use?
>>
>> os.rename("e:\\music\\Joni Mitchell\\ogg-8",
>> "e:\\music.ogg\\Joni Mitchell\\ogg-8")
>>
>
Peter Hansen wrote:
> Tom wrote:
>
>>Drive E: is removable, so I was careful to verify that that was a factor
>>in the problem.
>>
>>Yes, I can do the same renaming, with the same drive, at the command line.
>>
>>I think I put the emphasis in the wrong place in my question. This
>>isn't really
Tom wrote:
> Drive E: is removable, so I was careful to verify that that was a factor
> in the problem.
>
> Yes, I can do the same renaming, with the same drive, at the command line.
>
> I think I put the emphasis in the wrong place in my question. This
> isn't really about os.rename(). It is
Yes, I am sure about those things.
I've tried shutil.move and got the same result.
Forward slash? I'll give that a try and report back here if it works.
Thanks,
Tom.
Larry Bates wrote:
> Are you sure the source directory exists and you
> have rights to rename it? Because the rename works
> for
Peter Hansen wrote:
> Tom wrote:
>
>>I'm having a problem using a path with spaces as a parameter to
>>os.rename() in a program on WinXP.
>>
>>This works fine at the command line (where the folder "c:\aa bb" exists)
>>
>> > os.rename( "c\aa bb", "c:\cc dd" );
>> >
>>
>>But, I can't get it to work
Tom wrote:
> I'm having a problem using a path with spaces as a parameter to
> os.rename() in a program on WinXP.
>
> This works fine at the command line (where the folder "c:\aa bb" exists)
>
> > os.rename( "c\aa bb", "c:\cc dd" );
> >
>
> But, I can't get it to work in my program, eg.
>
>
Are you sure the source directory exists and you
have rights to rename it? Because the rename works
for me.
But you may want to look at shutil.move and/or
use forward slashes (they work under Windows)
-Larry Bates
Tom wrote:
> I'm having a problem using a path with spaces as a parameter to
> o
Thank you all for your replies. The repr() solution wasn't exactly what
I was looking for, as I wasn't planning on eval()ing it, but the
(en|de)code solution was exactly what I was looking for. An extended
thanks to Jp for informing me of the version compatibility :)
Have a GREAT day :)
-Wes
--
On 24 Jul 2005 18:14:13 -0700, ncf <[EMAIL PROTECTED]> wrote:
>I know I've seen this somewhere before, but does anyone know what the
>function to escape a string is? (i.e., encoding newline to "\n" and a
>chr(254) to "\xfe") (and visa-versa)
>
>Thanks for helping my ignorance :P
Python 2.4.1 (
ncf wrote:
> I know I've seen this somewhere before, but does anyone know what the
> function to escape a string is? (i.e., encoding newline to "\n" and a
> chr(254) to "\xfe") (and visa-versa)
In [1]: s = "foo\n\xfe"
In [2]: s.encode("string_escape")
Out[2]: 'foo\\n\\xfe'
In [3]: repr(s)[1:-1]
"ncf" <[EMAIL PROTECTED]> writes:
> I know I've seen this somewhere before, but does anyone know what the
> function to escape a string is? (i.e., encoding newline to "\n" and a
> chr(254) to "\xfe") (and visa-versa)
repr(s)
--
http://mail.python.org/mailman/listinfo/python-list
By any chance are you speaking about the function "repr" ?
Cyril
On 24 Jul 2005 18:14:13 -0700, ncf <[EMAIL PROTECTED]> wrote:
I know I've seen this somewhere before, but does anyone know what thefunction to escape a string is? (i.e., encoding newline to "\n" and achr(254) to "\xfe") (and visa-vers
24 matches
Mail list logo