On Wed, Jan 30, 2013 at 12:56 PM, iMath wrote:
> 在 2013年1月29日星期二UTC+8下午9时33分26秒,Steven D'Aprano写道:
>> iMath wrote: > why [os.path.join(r'E:\Python', name) for name in []] returns
>> [] ? Because you are iterating over an empty list, []. That list
>> comprehension is the equivalent of: result = [
在 2013年1月29日星期二UTC+8下午9时33分26秒,Steven D'Aprano写道:
> iMath wrote: > why [os.path.join(r'E:\Python', name) for name in []] returns
> [] ? Because you are iterating over an empty list, []. That list
> comprehension is the equivalent of: result = [] for name in []:
> result.append( os.path.join(r'E:
On 01/29/2013 08:21 AM, iMath wrote:
why [os.path.join(r'E:\Python', name) for name in []] returns [] ?
please explain it in detail !
[ os.path.join(r'E:\Python', name) for name in [] ]
It'd be nice if you would explain what part of it bothers you. Do you
know what a list comprehension is?
iMath wrote:
> why [os.path.join(r'E:\Python', name) for name in []] returns [] ?
Because you are iterating over an empty list, [].
That list comprehension is the equivalent of:
result = []
for name in []:
result.append( os.path.join(r'E:\Python', name) )
Since you iterate over an empty
- Original Message -
> why [os.path.join(r'E:\Python', name) for name in []] returns [] ?
> please explain it in detail !
> --
> http://mail.python.org/mailman/listinfo/python-list
>
You're mapping an empty list.
"for name in []"
JM
-- IMPORTANT NOTICE:
The contents of this email an
On Wed, Jan 30, 2013 at 12:21 AM, iMath wrote:
> why [os.path.join(r'E:\Python', name) for name in []] returns [] ?
> please explain it in detail !
That's a list comprehension. If you're familiar with functional
programming, it's like a map operation. Since the input list (near the
end of the com
On Thu, 2011-02-03 at 17:57 -0600, Thomas L. Shinnick wrote:
> At 05:33 PM 2/3/2011, Westley Martínez wrote:
>
> > On Thu, 2011-02-03 at 23:11 +, Steven D'Aprano wrote:
> >
> > > On Thu, 03 Feb 2011
> > > 07:58:55 -0800, Ethan Furman wrote:
> > > > Steven D'Aprano wrote:
> > > [snip]
> > >
At 05:33 PM 2/3/2011, Westley Martínez wrote:
On Thu, 2011-02-03 at 23:11 +, Steven D'Aprano wrote:
On Thu, 03 Feb 2011 07:58:55 -0800, Ethan Furman wrote:
> Steven D'Aprano wrote:
[snip]
Yes. Is there a problem? All those paths should be usable from Windows.
If you find it ugly to see path
On Thu, 2011-02-03 at 23:11 +, Steven D'Aprano wrote:
> On Thu, 03 Feb 2011 07:58:55 -0800, Ethan Furman wrote:
>
> > Steven D'Aprano wrote:
> >> BTW, Windows accepts / as well as \ as a path separator. You will have
> >> far fewer headaches if you use that.
> >
> > Just because Windows acce
On Thu, 03 Feb 2011 07:58:55 -0800, Ethan Furman wrote:
> Steven D'Aprano wrote:
>> BTW, Windows accepts / as well as \ as a path separator. You will have
>> far fewer headaches if you use that.
>
> Just because Windows accepts / doesn't make it a good idea...
No. Windows accepting slashes as th
Steven D'Aprano wrote:
BTW, Windows accepts / as well as \ as a path separator. You will have
far fewer headaches if you use that.
Just because Windows accepts / doesn't make it a good idea...
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
(Intel)] on win32
Type "help",
'C:\\Users\\me\\Documents\\..\\Pictures\\images\\my.jpg' is a valid
path. .. means parent, not 'go back a directory'. But you should really
be trying this:
p1 = os.environ['HOMEPATH']
p2 = os.path.join(p1, 'Pictures', 'images', 'my.jpg')
On Wed, 2011-02-02 at 20:46 -0800, harryos wrote:
> In win
On Thu, 03 Feb 2011 06:31:49 +, Steven D'Aprano wrote:
> On Wed, 02 Feb 2011 20:46:12 -0800, harryos wrote:
>
>> In windows ,I tried this
>>
>> p1 = "C:\Users\me\Documents"
>> p2 = "..\Pictures\images\my.jpg"
Don't do this; backslash is significant within Python string literals. If
want to
On Wed, 02 Feb 2011 20:46:12 -0800, harryos wrote:
> In windows ,I tried this
>
> p1 = "C:\Users\me\Documents"
> p2 = "..\Pictures\images\my.jpg"
>
> print os.path.join(p1,p2)
> This gives
> 'C:\\Users\\me\\Documents\\..\\Pictures\\images\\my.jpg'
>
> I expected I would get
> 'C:\\Users\\me\\Pi
On Wed, Feb 2, 2011 at 8:46 PM, harryos wrote:
> In windows ,I tried this
>
> p1 = "C:\Users\me\Documents"
> p2 = "..\Pictures\images\my.jpg"
>
> print os.path.join(p1,p2)
> This gives
> 'C:\\Users\\me\\Documents\\..\\Pictures\\images\\my.jpg'
>
> I expected I would get
> 'C:\\Users\\me\\Pictures\
Ethan Furman wrote:
Following closely on the heels of the whole sum()ing strings debate, I
think I found an error -- at least, it's not documented to behave this
way...
def uncompress_job(job_num,
save_path='z:\\old_jobs',
restore_path='z:\\orders'):
d
Elliot Peele <[EMAIL PROTECTED]> wrote:
>On Tue, 2007-05-01 at 19:27 -0700, 7stud wrote:
>> On May 1, 7:36 pm, Elliot Peele <[EMAIL PROTECTED]> wrote:
>> > Why does os.path.join('/foo', '/bar') return '/bar' rather than
>> > '/foo/bar'? That just seems rather counter intuitive.
>> >
>> > Elliot
>>
On May 2, 12:36 am, Ant <[EMAIL PROTECTED]> wrote:
> On May 2, 8:03 am, [EMAIL PROTECTED] wrote:
>
> > On May 1, 11:10 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
> ...
> > > I think it's a bug, but because it should raise TypeError instead.
> > > The right usage is os.path.join(*pathparts)
> ...
>
On May 2, 8:03 am, [EMAIL PROTECTED] wrote:
> On May 1, 11:10 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
...
> > I think it's a bug, but because it should raise TypeError instead.
> > The right usage is os.path.join(*pathparts)
...
> Wow. What exactly is that * operator doing? Is it only used in
En Wed, 02 May 2007 04:03:56 -0300, <[EMAIL PROTECTED]> escribió:
> On May 1, 11:10 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
> wrote:
>> The right usage is os.path.join(*pathparts)
>
> Wow. What exactly is that * operator doing? Is it only used in
> passing args to functions? Does it just e
On May 1, 11:10 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Wed, 02 May 2007 02:31:43 -0300, <[EMAIL PROTECTED]> escribió:
>
> > A better question is why this doesn't work.
>
> pathparts = ["/foo", "bar"]
> os.path.join(pathparts)
> > ['/foo', 'bar']
>
> > This should return a
En Wed, 02 May 2007 02:31:43 -0300, <[EMAIL PROTECTED]> escribió:
> A better question is why this doesn't work.
>
pathparts = ["/foo", "bar"]
os.path.join(pathparts)
> ['/foo', 'bar']
>
> This should return a string in my opinion.
I think it's a bug, but because it should raise TypeErro
En Wed, 02 May 2007 01:23:45 -0300, Elliot Peele <[EMAIL PROTECTED]>
escribió:
> On Tue, 2007-05-01 at 19:27 -0700, 7stud wrote:
>> On May 1, 7:36 pm, Elliot Peele <[EMAIL PROTECTED]> wrote:
>> > Why does os.path.join('/foo', '/bar') return '/bar' rather than
>> > '/foo/bar'? That just seems rat
On May 1, 9:23 pm, Elliot Peele <[EMAIL PROTECTED]> wrote:
> On Tue, 2007-05-01 at 19:27 -0700, 7stud wrote:
> > On May 1, 7:36 pm, Elliot Peele <[EMAIL PROTECTED]> wrote:
> > > Why does os.path.join('/foo', '/bar') return '/bar' rather than
> > > '/foo/bar'? That just seems rather counter intuitiv
On Tue, 2007-05-01 at 19:27 -0700, 7stud wrote:
> On May 1, 7:36 pm, Elliot Peele <[EMAIL PROTECTED]> wrote:
> > Why does os.path.join('/foo', '/bar') return '/bar' rather than
> > '/foo/bar'? That just seems rather counter intuitive.
> >
> > Elliot
>
> join( path1[, path2[, ...]])
> Join one or m
On Tue, 2007-05-01 at 21:26 -0500, Michael Bentley wrote:
> On May 1, 2007, at 8:36 PM, Elliot Peele wrote:
>
> > Why does os.path.join('/foo', '/bar') return '/bar' rather than
> > '/foo/bar'? That just seems rather counter intuitive.
>
> It's the leading slash in '/bar'. os.path.join('/foo', '
On May 1, 7:36 pm, Elliot Peele <[EMAIL PROTECTED]> wrote:
> Why does os.path.join('/foo', '/bar') return '/bar' rather than
> '/foo/bar'? That just seems rather counter intuitive.
>
> Elliot
join( path1[, path2[, ...]])
Join one or more path components intelligently. If any component is an
abso
On May 1, 2007, at 8:36 PM, Elliot Peele wrote:
> Why does os.path.join('/foo', '/bar') return '/bar' rather than
> '/foo/bar'? That just seems rather counter intuitive.
It's the leading slash in '/bar'. os.path.join('/foo', 'bar')
returns '/foo/bar'.
--
http://mail.python.org/mailman/listi
Wow, sorry I sent that a little too fast. I just had to remove the \\
before the graphics. Thus this did work:
os.path.join('C:\\Documents and
Settings\\Gregory','graphics\\knight\\been hit e0001.bmp')
-Greg
On 1/27/06, Gregory Piñero <[EMAIL PROTECTED]> wrote:
> Would someone mind explaining
29 matches
Mail list logo