0

I am trying to set a path in Python to a folder, but I can't seem to get (PATH) to work. It works when I write out the path. Any ideas?

PATH = "data/dogscats"
sz = 224 
print(PATH)
#!dir /b "data/dogscats" <---- THIS WORKS
!dir /b (PATH)  <------ THIS DOESN'T

data/dogscats

FILE NOT FOUND

3
  • Ba Bam That was it Thanks Commented May 26, 2018 at 19:06
  • What was it? If your question is solved, it would be awesome if you could document that here, so that others can learn from it as well. See stackoverflow.com/help/someone-answers Commented May 26, 2018 at 23:42
  • @jotaen, I speculated about a possible answer in a comment. After Joe confirmed that it worked, I edited the question title and tags to to add IPython and moved my comment to an answer. Commented May 27, 2018 at 1:36

1 Answer 1

1

!dir /b "$PATH" should do what you want, or use an expression such as !dir /b {'"%s"' % PATH}. See the IPython reference for more information. Note that because the path uses forward slash as a separator, it has to be quoted in Windows CMD in order to disambiguate the separator from a "/" option.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.