Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #9857

Re: os.path.isdir do not work for Foder named '2011-07-03'

Message-ID <1704833.GPiq6Xz2PA@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2011-07-19 08:15 +0200
Subject Re: os.path.isdir do not work for Foder named '2011-07-03'
Newsgroups comp.lang.python
References <0bf400a3-735c-487a-8d74-feb3b56be99b@g5g2000prn.googlegroups.com> <4e250b31$0$30001$c3e8da3$5496439d@news.astraweb.com>
Followup-To comp.lang.python

Followups directed to: comp.lang.python

Show all headers | View raw


Steven D'Aprano wrote:

> Nulpum wrote:
>> I want to make sure that folder exists.
>> 
>> '2011-07-03' is really exists. but 'os.path.isdir' say false
>> 
>> Does anyone know why?
> 
> Yes.
> 
>>>> print "logs/2011-07-03"
> logs/2011-07-03
>>>> print "logs\2011-07-03"
> logs�1-07-03
> 
> Don't use backslashes as path separators in Python. Backslashes are used
> for string escapes.

Besides that, and permission issues, ISTM that there are Unicode characters 
(at least non-ASCII characters) in the OP's path, which means they should 
declare

# encoding: utf-8

or something else fitting, and use

os.path.isdir(u"C:/Users/조창준/Desktop/logs/2011-07-03")

or something else fitting.

-- 
PointedEars

Bitte keine Kopien per E-Mail. / Please do not Cc: me.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

os.path.isdir do not work for Foder named '2011-07-03' Nulpum <changjun.cho@gmail.com> - 2011-07-18 21:25 -0700
  Re: os.path.isdir do not work for Foder named '2011-07-03' Kushal Das <kushaldas@gmail.com> - 2011-07-19 10:11 +0530
  Re: os.path.isdir do not work for Foder named '2011-07-03' Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-19 14:42 +1000
    Re: os.path.isdir do not work for Foder named '2011-07-03' Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-07-19 08:15 +0200
      Re: os.path.isdir do not work for Foder named '2011-07-03' Changjun <changjun.cho@gmail.com> - 2011-07-19 01:25 -0700
      Re: os.path.isdir do not work for Foder named '2011-07-03' Terry Reedy <tjreedy@udel.edu> - 2011-07-19 13:51 -0400
    Re: os.path.isdir do not work for Foder named '2011-07-03' Thomas Jollans <t@jollybox.de> - 2011-07-19 08:30 +0200
      Re: os.path.isdir do not work for Foder named '2011-07-03' Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-19 17:26 +1000
        Re: os.path.isdir do not work for Foder named '2011-07-03' Ethan Furman <ethan@stoneleaf.us> - 2011-07-19 07:22 -0700
    Re: os.path.isdir do not work for Foder named '2011-07-03' Nulpum <changjun.cho@gmail.com> - 2011-07-19 00:21 -0700
  Re: os.path.isdir do not work for Foder named '2011-07-03' Michael Hrivnak <mhrivnak@hrivnak.org> - 2011-07-19 00:42 -0400
  Re: os.path.isdir do not work for Foder named '2011-07-03' Rob Williscroft <rtw@rtw.me.uk> - 2011-07-19 04:56 +0000
  Re: os.path.isdir do not work for Foder named '2011-07-03' Grant Edwards <invalid@invalid.invalid> - 2011-07-19 14:21 +0000

csiph-web