Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8200893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:36:38+00:00 2026-06-07T06:36:38+00:00

This is my second post, I apologize if I do something incorrectly – I

  • 0

This is my second post, I apologize if I do something incorrectly – I will try to be as concise as possible.

I did some searching, and most escapes have to deal with embedded JSON strings – my problem is actually with opening the file itself.

At present, I’m trying to make my code as generic as possible, so I’m using:

file = open(os.path.expanduser(r'~/Desktop/Austin/Tweets/10_7_2012_12/09-Tweets.txt'), 'r')

The issue is that when the interpreter sees this code, it sees the “/” in the file name, and I think it’s trying to go down another directory. I confirmed this by removing the “/” in the file name and typing:

file = open(os.path.expanduser(r'~/Desktop/Austin/Tweets/10_7_2012_1209-Tweets.txt'), 'r')

And it loaded just fine.

The problem with doing that for all of these files is that I have several hundred files containing several thousand tweets, and it’s a little impractical.

So my question is this:
Is there a way in which to load files with forward slashes in their file name?

I saw many ways to load files with the search button, but none including how to deal with a forward slash in the name… I’ve tried:

file = open(os.path.expanduser('~/Desktop/Austin/Tweets/10_7_2012_12\/09-Tweets.txt'), 'r')

and

file = open(os.path.expanduser('~/Desktop/Austin/Tweets/10_7_2012_12//09-Tweets.txt'), 'r')

All to no avail.

An explanation as to how Python handles forward slashes would be welcome, if anyone cares to teach a naive undergraduate.

I’m using a Mac OSX on Leopard. I’m running a web crawler that’s communicating with the Twitter Streaming API; the slashes in the names are a result of saving them with a “/” to designate the date.

SOLUTION:
You can use forward slashes in filenames on Mac OSX.
From the filesystem’s perspective, the / is actually a colon, and it gets translated to a / in Finder.

Kindall’s explanation below:
It’s necessary for the Carbon layer, which uses the standard Mac filename separators, colons. Slashes have historically been allowed in Mac filenames going back to 1984. Mac users also expect to see colons, not slashes, as pathname separators in the GUI (or at least they did in 2001, when this behavior was instituted).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:36:39+00:00Added an answer on June 7, 2026 at 6:36 am

    I’m assuming you’re using a Unix-like OS, and my understanding is that forward slashes aren’t allowed in filenames in such systems. What do you see if you ls in ~/Desktop/Austin/Tweets/?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, a thank you in advance. Second, this is my first post so apologies
UPDATE: First problem solved, second one described at the bottom of this post. UPDATE2:
Ok, I need something like this: datediff(second, date_one, date_two) < 1 dates are stored
I'm using jQuery. This is my second post to make my old question more
I appologize for this lengthy post. I have made it as small as possible
Unfortunately, this is my second post in as many days. So the application worked
Not sure what is the problem , this the second post looking for the
This is my second post on SO, as well as my second post on
This is my second post about hibernate. Since I started using hibernate it has
I think this is my second post regarding Adaptive HTML/CSS layout. I got a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.