Ahhh now I see!! I actually was trying to import a file, now I know it´s just
changing the directory. Next time I´d better read the description of the tool
carefully...
Thank you so much!! You helped a lot!
--
https://mail.python.org/mailman/listinfo/python-list
On 4/1/19, grossmu...@gmail.com wrote:
>
> os.chdir('C:\\Users\\Ayla\\Documents\\Uni\\Master_Umweltingenieurwesen\\
> Study_Project\\kerschbaum_input')
> os.chdir('C:/Users/Ayla/Documents/Uni/Master_Umweltingenieurwesen/
> Study_Project/kerschbaum_input')
These
What are you actually trying to do?
os.chdir() simply changes the current working directory of your process. It
doesn't read any data or "import" or really have any affect on its own. The
current directory is the directory you ran the script from in the first
place, which is wher
Hey guys,
I´ve got a problem importing a file with os.chdir. I´ve done a lot of research
but still I can´t fix it. For any suggestions I would be so thankful!
This is what I´ve tried so far:
import os
import numpy as np
import matplotlib.pyplot as plt
os.chdir('C:\Users\Ayla\Document
On Thursday 05 July 2018 11:57:18 Mikhail V wrote:
> Steven D'Aprano wrote:
> > In Explorer and the open-file dialog of most applications, they will
> > see paths like this:
> >
> > directory\file name with spaces
> >
> > with the extension (.jpg, .pdf, .docx etc) suppressed. So by your
> > ar
Steven D'Aprano wrote:
> In Explorer and the open-file dialog of most applications, they will see
> paths like this:
>
> directory\file name with spaces
>
> with the extension (.jpg, .pdf, .docx etc) suppressed. So by your
> argument, Python needs to accept strings without quotes:
>
> open
On Thu, 05 Jul 2018 00:56:22 +0300, Mikhail V wrote:
> for the user it is most important to
> *see* and copy-paste the path string exactly as it is displayed
> everywhere else on windows.
So in Windows, you see:
dir directory\file.pdf
so in Python, we have to use exactly the same path with
Mikhail V wrote:
There is one issue that I can't write \ on the end:
r"C:\programs\util\"
But since I know it's a path and not a file, I just write without trailing \.
Indeed. There's never a need to put a backslash on the end of
a path, as long as you always use os.path functions or
equivalen
ChrisA wrote:
> Mikhail V wrote:
>> Yes, and the answer was a week ago: just put "r" before the string.
>> r"C:\programs\util"
>>
>> And it worked till now. So why should I replace backslashes with
>> forward slashes?
>> There is one issue that I can't write \ on the end:
>> r"C:\programs\util\"
On 04/07/18 21:30, Chris Angelico wrote:
On Thu, Jul 5, 2018 at 6:25 AM, Mikhail V wrote:
Joe Pfeiffer wrote:
On Windows a path is e.g.:
C:\programs\util\
So what is reasonable about using forward slashes?
It happens to me that I need to copy-paste real paths like 100 times
a day into scripts
On Thu, Jul 5, 2018 at 6:25 AM, Mikhail V wrote:
> Joe Pfeiffer wrote:
>
>>> On Windows a path is e.g.:
>>> C:\programs\util\
>>> So what is reasonable about using forward slashes?
>>> It happens to me that I need to copy-paste real paths like 100 times
>>> a day into scripts - do you propose to c
Joe Pfeiffer wrote:
>> On Windows a path is e.g.:
>> C:\programs\util\
>> So what is reasonable about using forward slashes?
>> It happens to me that I need to copy-paste real paths like 100 times
>> a day into scripts - do you propose to convert to forward slashes each time?
> That's what starte
Mikhail V writes:
> [Steven D'Aprano]
>
>> (The same applies to Unix/Linux systems too, of course.) But while you're
>> using Python to manipulate files, you should use Python rules, and that
>> is "always use forward slashes".
>>
>> Is that reasonable?
>>
>> Under what circumstances would a user
On 2018-07-03 14:06, Mikhail V wrote:
> Greg wrote:
>
>> Mikhail V wrote:
>>> s= "\"s\"" ->
>>> s= {"s"}
>>
>> But now you need to find another way to represent set literals.
>
>
> I need to find? That comment was not about (current) Python but
> rather how I think string should have been
Greg wrote:
> Mikhail V wrote:
> > s= "\"s\"" ->
> > s= {"s"}
>
> But now you need to find another way to represent set literals.
I need to find? That comment was not about (current) Python but
rather how I think string should have been from the beginning.
So you already like it and want
Mikhail V wrote:
s= "\"s\"" ->
s= {"s"}
But now you need to find another way to represent set literals.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
[Chris A]
> [Mikhail]
> > So Imo default syntax should be something like:
> >
> > S = "A:{x41}B:{x42}"
> >
> > instead of backslashes and Co.
>
> So how do you represent brace characters in a string?
\{ and \}
just kidding :-D
I would be ok with {L} and {R} - easy on eye and easy to rememb
On 2018-07-02 18:16, Richard Damon wrote:
On 7/2/18 9:20 AM, Mikhail V wrote:
[Richard Damon]
The one major issue with backslashes is that they are a special
character in string literals, so you either need to use raw literals a
remember the few cases they still act as special characters, or r
On 7/2/18 9:20 AM, Mikhail V wrote:
> [Richard Damon]
>
>> The one major issue with backslashes is that they are a special
>> character in string literals, so you either need to use raw literals a
>> remember the few cases they still act as special characters, or remember
>> to convert them to doub
On Tue, Jul 3, 2018 at 2:20 AM, Mikhail V wrote:
> [Richard Damon]
>
>> The one major issue with backslashes is that they are a special
>> character in string literals, so you either need to use raw literals a
>> remember the few cases they still act as special characters, or remember
>> to conver
[Richard Damon]
> The one major issue with backslashes is that they are a special
> character in string literals, so you either need to use raw literals a
> remember the few cases they still act as special characters, or remember
> to convert them to double back slashes, at a minimum for all the
>
Eryk,
thanks for your to-the-point in-depth posts.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
--
https://mail.python.org/mailman/listinfo/python-list
On Sun, Jul 1, 2018 at 4:30 PM, eryk sun wrote:
> On Sun, Jul 1, 2018 at 8:51 AM, Steven D'Aprano
>
>> spam/eggs
[...]
>> And how would that file be displayed in the Windows GUI file explorer?
>
> I suppose if a file system allowed forward slash in names that
> Explorer would just display it.
eryk sun wrote:
Python 2 raw strings are half-baked.
Obviously the "r" actually stand for "rare".
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On Sun, Jul 1, 2018 at 4:00 PM, Abdur-Rahmaan Janhangeer
wrote:
> one common scenario is
>
> C:\Users\
>
> where \U is taken as a unicode litteral
This one is especially annoying in Python 2, since it makes raw
unicode strings useless for common path literals. For example:
>>> ur'C:\User
On Sun, Jul 1, 2018 at 8:51 AM, Steven D'Aprano
wrote:
> On Sun, 01 Jul 2018 03:18:23 +, eryk sun wrote:
>
>> Bear in mind that forward slash is just a name character in NT.
>
> So, using Python, how could you open, write to, and then read from, a
> file with a slash in its name? Say, somethi
one common scenario is
C:\Users\
where \U is taken as a unicode litteral
Abdur-Rahmaan Janhangeer
https://github.com/Abdur-rahmaanJ
>
>
>
--
https://mail.python.org/mailman/listinfo/python-list
On 7/1/18 6:49 AM, Mikhail V wrote:
> [Steven D'Aprano]
>
>> (The same applies to Unix/Linux systems too, of course.) But while you're
>> using Python to manipulate files, you should use Python rules, and that
>> is "always use forward slashes".
>>
>> Is that reasonable?
>>
>> Under what circumstan
On Sun, Jul 1, 2018 at 8:50 AM, Steven D'Aprano
wrote:
> On Sun, 01 Jul 2018 03:18:23 +, eryk sun wrote:
>
>> The Windows API handles this, but not for a path that begins with \\?\.
>
> But what about the *Python* API? The Python open() function, and all the
> high-level os.* and os.path.* fun
[Steven D'Aprano]
> (The same applies to Unix/Linux systems too, of course.) But while you're
> using Python to manipulate files, you should use Python rules, and that
> is "always use forward slashes".
>
> Is that reasonable?
>
> Under what circumstances would a user calling open(pathname) in Pyt
On 2018-07-01 08:50:22 +, Steven D'Aprano wrote:
> On Sun, 01 Jul 2018 03:18:23 +, eryk sun wrote:
> > On Sun, Jul 1, 2018 at 1:44 AM, Steven D'Aprano
> > wrote:
> >> I guess that if the user is using a path beginning with \\?\ they may
> >> or may not need to use backslashes, but I have n
On Sun, 01 Jul 2018 03:18:23 +, eryk sun wrote:
> Bear in mind that forward slash is just a name character in NT.
So, using Python, how could you open, write to, and then read from, a
file with a slash in its name? Say, something like:
spam/eggs
in your home directory. (Is that still
On Sun, 01 Jul 2018 03:18:23 +, eryk sun wrote:
> On Sun, Jul 1, 2018 at 1:44 AM, Steven D'Aprano
> wrote:
>> On Sat, 30 Jun 2018 23:36:40 +, eryk sun wrote:
>>
>>> Only use forward slashes for legacy DOS paths passed to Windows API
>>> functions. Do not use forward slashes for paths in c
On Sun, 01 Jul 2018 02:22:41 +, eryk sun wrote:
> I use the native API a lot, so for me registry and file paths are just
> paths. It's only the Windows API that separates the two and only the
> Windows API that allows forward slash as a path separator in file paths.
Not being a Windows user,
On Sun, Jul 1, 2018 at 1:44 AM, Steven D'Aprano
wrote:
> On Sat, 30 Jun 2018 23:36:40 +, eryk sun wrote:
>
>> Only use forward slashes for legacy DOS paths passed to Windows API
>> functions. Do not use forward slashes for paths in command line
>> arguments, \\?\ prefixed paths, or registry pa
On Sun, Jul 1, 2018 at 12:43 PM, eryk sun wrote:
> On Sun, Jul 1, 2018 at 2:28 AM, Chris Angelico wrote:
>> On Sun, Jul 1, 2018 at 12:22 PM, eryk sun wrote:
So what if, internally, that's done by converting them to backslashes?
No Python program needs to care. In fact, there are other
On Sun, Jul 1, 2018 at 2:28 AM, Chris Angelico wrote:
> On Sun, Jul 1, 2018 at 12:22 PM, eryk sun wrote:
>>> So what if, internally, that's done by converting them to backslashes?
>>> No Python program needs to care. In fact, there are other conversions,
>>> too - the underlying file system is mo
On Sun, Jul 1, 2018 at 12:22 PM, eryk sun wrote:
>> So what if, internally, that's done by converting them to backslashes?
>> No Python program needs to care. In fact, there are other conversions,
>> too - the underlying file system is most likely using UTF-16 paths,
>> but your Python program nee
On Sun, Jul 1, 2018 at 1:58 AM, Chris Angelico wrote:
> On Sun, Jul 1, 2018 at 10:20 AM, eryk sun wrote:
>> On Sat, Jun 30, 2018 at 11:42 PM, Chris Angelico wrote:
>>> "Legacy" implies that it's the old standard that is now deprecated,
>>
>> I did not mean to imply that DOS paths are deprecated.
On Sun, Jul 1, 2018 at 10:20 AM, eryk sun wrote:
> On Sat, Jun 30, 2018 at 11:42 PM, Chris Angelico wrote:
>> "Legacy" implies that it's the old standard that is now deprecated,
>
> I did not mean to imply that DOS paths are deprecated. That's not what
> legacy means to me.
Unless you are Humpty
On Sat, 30 Jun 2018 23:36:40 +, eryk sun wrote:
> Only use forward slashes for legacy DOS paths passed to Windows API
> functions. Do not use forward slashes for paths in command line
> arguments, \\?\ prefixed paths, or registry paths.
I don't see why this is relevant, or at least not the "c
0
>>>> down vote
>>>> favorite
>>>>
>>>> I need to change directory to my local working directory in windows and
>>>> then open a file for processing.
>>>> Its just a 3 lines code, as below:
>>>> import csv
>>>
lines code, as below:
import csv
import os
os.chdir('D:\Projects\Initiatives\machine learning\programs\assertion')
The error is as follows:
WindowsError: [Error 123] The filename, directory name, or volume label syntax
is incorrect: 'D:\Projects\Initiatives\machine learning\progr
ange directory to my local working directory in windows and
>>> then open a file for processing.
>>> Its just a 3 lines code, as below:
>>> import csv
>>> import os
>>> os.chdir('D:\Projects\Initiatives\machine learning\programs\assertion')
>&
e for processing.
>> Its just a 3 lines code, as below:
>> import csv
>> import os
>> os.chdir('D:\Projects\Initiatives\machine learning\programs\assertion')
>> The error is as follows:
>> WindowsError: [Error 123] The filename, directory name, o
On 06/30/18 07:34, Sharan Basappa wrote:
sorry. I mean why my code worked in one case but did not in the other one.
This worked - os.chdir('D:\Projects\Initiatives\machine learning\programs')
This did not work - os.chdir('D:\Projects\Initiatives\machine
learning\programs\as
On Sat, Jun 30, 2018 at 07:34:46AM -0700, Sharan Basappa wrote:
> sorry. I mean why my code worked in one case but did not in the other one.
>
> This worked - os.chdir('D:\Projects\Initiatives\machine learning\programs')
>
> This did not work - os.chdir('D
in the first place.
>
> For that you'll have to read up on strings and escaping.
>
> https://docs.python.org/2/tutorial/introduction.html#strings
>
> Karsten
> --
> GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
sorry. I mean why my code worked in on
On Sat, Jun 30, 2018 at 05:46:59AM -0700, Sharan Basappa wrote:
> > >> The quick fix:
> > >>
> > >> put an r in front of the directory string: r'...'
> >
> > Please don't do that. It's the wrong solution -- all you are doing is
> > postponing failure. It will *seem* to work, until one day you w
failure. Chris gave you the right solution:
> use forward slashes instead of backslashes for all paths.
>
> os.chdir('D:/Projects/Initiatives/machine learning/programs')
>
>
>
>
> --
> Steven D'Aprano
> "Ever since I learned about confirmatio
will *seem* to work, until one day you will write
something like this:
directory = r'D:\directory\'
and you will get a mysterious failure. Chris gave you the right solution:
use forward slashes instead of backslashes for all paths.
os.chdir('D:/Projects/Initiatives/machin
for user input, a replace might be the solution, using / in internal code
Abdur-Rahmaan Janhangeer
https://github.com/Abdur-rahmaanJ
Use forward slashes instead of backslashes for all paths.
>
> os.chdir('D:/Projects/Initiatives/machine learning/programs')
>
&g
a 3 lines code, as below:
> > import csv
> > import os
> > os.chdir('D:\Projects\Initiatives\machine learning\programs\assertion')
> > The error is as follows:
> > WindowsError: [Error 123] The filename, directory name, or volume label
> > syntax is incorrec
On Sat, Jun 30, 2018 at 9:05 PM, Sharan Basappa
wrote:
>
> 0
> down vote
> favorite
>
> I need to change directory to my local working directory in windows and then
> open a file for processing.
> Its just a 3 lines code, as below:
> import csv
> import os
>
On Sat, Jun 30, 2018 at 04:05:22AM -0700, Sharan Basappa wrote:
> I need to change directory to my local working directory in windows and then
> open a file for processing.
> Its just a 3 lines code, as below:
> import csv
> import os
> os.chdir('D:\Projects\Initiatives\ma
0
down vote
favorite
I need to change directory to my local working directory in windows and then
open a file for processing.
Its just a 3 lines code, as below:
import csv
import os
os.chdir('D:\Projects\Initiatives\machine learning\programs\assertion')
The error is as follows:
Wi
Hello,
In order to prevent this type of problems, I alway do the following:
import path
path = something
path = os.path.normpath(path)
os.chdir(path)
This prevents a lot of problems for me.
Regards,
Henk
"Tim Golden" wrote in message
news:mailman.1646.1236751732.1174
Hendrik van Rooyen wrote:
"Tim Golden" wrote:
Well, a little bit of experimentation shows that you can
*create* paths this deep (say, with os.mkdir). But you
can't actually set the current directory to it. So the
Is this also true if you try to go there by a succession
of shorter hops of the
"Tim Golden" wrote:
> Well, a little bit of experimentation shows that you can
> *create* paths this deep (say, with os.mkdir). But you
> can't actually set the current directory to it. So the
Is this also true if you try to go there by a succession
of shorter hops of the ./next_level kind?
- H
En Wed, 11 Mar 2009 11:59:57 -0200, venutaurus...@gmail.com
escribió:
On Mar 11, 6:41 pm, Tim Golden wrote:
venutaurus...@gmail.com wrote:
> On Mar 11, 5:19 pm, Tim Golden wrote:
Well, the source for os.chdir under Windows uses the Win32
SetCurrentDirectoryW API as expected. What is
etting the exception:
Traceback (most recent call last):
File "C:\JPDump\test.py", line 29, in
renameStubs(file)
File "C:\JPDump\test.py", line 12, in renameStubs
os.chdir (path)
WindowsError: [Error 206] The filename or extension is too long: u'\\\
\?
> >>> athLevel10\DeepPathLevel11\DeepPathLevel12\DeepPathLevel13\DeepPathLevel14\
> >>> DeepPathLevel15\DeepPathLevel16\DeepPathLevel172.txt'
> >>> I am still getting the exception:
> >>> Traceback (most recent call last):
> &g
\JPDump\test.py", line 29, in
renameStubs(file)
File "C:\JPDump\test.py", line 12, in renameStubs
os.chdir (path)
WindowsError: [Error 206] The filename or extension is too long: u'\\\
\?\\C:\\TestDataSet\\DeepPaths\\DeepPathLevel01\\DeepPathLevel02\
\Deep
athLevel08\DeepPathLevel09\DeepP
> > athLevel10\DeepPathLevel11\DeepPathLevel12\DeepPathLevel13\DeepPathLevel14\
> > DeepPathLevel15\DeepPathLevel16\DeepPathLevel172.txt'
>
> > I am still getting the exception:
>
> > Traceback (most recent call last):
> > F
uot;C:\JPDump\test.py", line 12, in renameStubs
os.chdir (path)
WindowsError: [Error 206] The filename or extension is too long: u'\\\
\?\\C:\\TestDataSet\\DeepPaths\\DeepPathLevel01\\DeepPathLevel02\
\DeepPathLevel03\\DeepPathLevel04\\DeepPathLevel05\\DeepPathLevel06\
\DeepPathLevel07\\Deep
\test.py", line 29, in
renameStubs(file)
File "C:\JPDump\test.py", line 12, in renameStubs
os.chdir (path)
WindowsError: [Error 206] The filename or extension is too long: u'\\\
\?\\C:\\TestDataSet\\DeepPaths\\DeepPathLevel01\\DeepPathLevel02\
\DeepPathLevel03\\DeepPathLevel
Here is my code snippet which you will be interested in:
Indeed.
file = ur'\\?\C:\\TestDataSet\DeepPaths
\DeepPathLevel01\DeepPathLevel02\DeepPathLevel03\DeepPathLevel04\DeepPathLevel05\DeepPathLevel06\DeepPathLevel07\DeepPathLevel08\DeepPathLevel09\DeepPathLevel10\DeepPathLevel11\DeepPathLeve
>>> then supported normally by the Windows OS (>255). So I am appending "\
> >>> \?\" to do so. But when I use the path in the above fashion with
> >>> os.chdir() it is unable to recognize my folder and throwing an error:
> >>> Traceback (most rec
use the path in the above fashion with
os.chdir() it is unable to recognize my folder and throwing an error:
Traceback (most recent call last):
File "C:\JPDump\test.py", line 31, in
renameStubs(file)
File "C:\JPDump\test.py", line 15, in renameStubs
os.chdir (pa
so. But when I use the path in the above fashion with
> > os.chdir() it is unable to recognize my folder and throwing an error:
>
> > Traceback (most recent call last):
> > File "C:\JPDump\test.py", line 31, in
> > renameStubs(file)
> > File "C:\J
venutaurus...@gmail.com wrote:
Hello all,
I am writing a python script which has to access deep paths
then supported normally by the Windows OS (>255). So I am appending "\
\?\" to do so. But when I use the path in the above fashion with
os.chdir() it is unable to recogn
Hello all,
I am writing a python script which has to access deep paths
then supported normally by the Windows OS (>255). So I am appending "\
\?\" to do so. But when I use the path in the above fashion with
os.chdir() it is unable to recognize my folder and throwing an erro
reads, each call has to
be from a different directory.
Thank you,
Gabriel
I think I found what was wrong, I was using os.chDir(), and the current
directory is shared by all threads :
http://www.biais.org/blog/index.php/2007/01/23/19-python-threads-and-oschdir
http://bugs.python.org/issue136
Quoting "Martin v. Löwis" <[EMAIL PROTECTED]>:
> >> os.chdir("~/dir1")
> >
> > It is not mentioned in the documentation but I'm pretty sure os.dir()
> doesn't do
> > tilde expansion since this is usually performed by a shell.
&
>> os.chdir("~/dir1")
>
> It is not mentioned in the documentation but I'm pretty sure os.dir() doesn't
> do
> tilde expansion since this is usually performed by a shell.
>
> You should use instead:
>
> os.chdir(os.join(os.environ['HO
Quoting Maryam Saeedi <[EMAIL PROTECTED]>:
> I have a problem using os.chdir on linux. What should I do if I want to
> change to root directory? The below does not work:
>
> os.chdir("~/dir1")
It is not mentioned in the documentation but I'm pretty sure os.dir()
2008/3/7, Maryam Saeedi <[EMAIL PROTECTED]>:
>
> I have a problem using os.chdir on linux. What should I do if I want to
> change to root directory? The below does not work:
>
> os.chdir("~/dir1")
>
> Thanks
>
> --
> http://mail.python.org/mailman
I have a problem using os.chdir on linux. What should I do if I want to
change to root directory? The below does not work:
os.chdir("~/dir1")
Thanks
--
http://mail.python.org/mailman/listinfo/python-list
May 08, 2007 4:17 PM
To: python-list@python.org
Subject: Using os.popen and os.chdir together
Within a script on a *nix machine, I use os.chdir then os.popen, and it
appears to me as though the os.chdir had no effect so far as the
os.popen is concerned. Why's that? Here's what
Within a script on a *nix machine, I use os.chdir then os.popen, and it
appears to me as though the os.chdir had no effect so far as the
os.popen is concerned. Why's that? Here's what I'm doing:
>>> import os
>>> os.path.realpath( os.curdir )
'/home/j
A simple way to get all the files throughout the directory sturcture...
You may have to rewrite the "CONVERTING" part.
import os, glob
for root, dirs, files in os.walk(os.getcwd()):
for file in files:
if file.endswith(".mp3"):
print "File: " + os.path.abspath(os.path.join(
In article <[EMAIL PROTECTED]>,
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> #!/usr/bin/python
>
> from os import *
>
> chdir("/home/chainlynx/Desktop/Music")
> for artist in listdir(getcwd()):
> print "===ARTIST: "+artist
> chdir(artist)
> for album in listdir(getcw
>> for album in listdir(getcwd()):
doesn't listdir give you subdirectories AND files?
So, then if you try to: chdir(album)
If album is a file, it chokes?
Just a guess. I'm on Windows, not Linux.
rd
--
http://mail.python.org/mailman/listinfo/python-list
I have a strange problem with os.chdir... here is my script that I am
using to edit the filenames of my music library:
#!/usr/bin/python
from os import *
chdir("/home/chainlynx/Desktop/Music")
for artist in listdir(getcwd()):
print "===ARTIST: "+artist
chdir
Hi,
I do not know whether this is a Python, wxPython, Windows, or coding
question ...
I have a program that changes disk/directory using os.chdir (verified OK
with os.getcwd) then opens a file dialog box using wx.FileDialog with ""
as default dir.
I expected to be in my chdir dir
85 matches
Mail list logo