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

  • SEARCH
  • Home
  • 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 6760487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:04:12+00:00 2026-05-26T14:04:12+00:00

I got some code that i did 3 years ago under python 2.5 or

  • 0

I got some code that i did 3 years ago under python 2.5 or so. It was working properly back then It was something like this :

try:
   if os.path.exists(os.path.join(TRACES.log_file_path, TRACES.log_file_name)):
      os.remove(os.path.join(TRACES.log_file_path, TRACES.log_file_name))
except IOError , e:
   print (str(e))

Now, under 3.2, this piece of code is not working for windows. I get the following error : Invalid syntax

To resolve the problem, i changed the “,” for “as” to have the following :

try:
  if os.path.exists(os.path.join(TRACES.log_file_path, TRACES.log_file_name)):
    os.remove(os.path.join(TRACES.log_file_path, TRACES.log_file_name))
except IOError as e:
  print (str(e))

I was happy, but couple minutes later, i realized that the code was not working into a cygwin prompt, the compiler didn’t like the “as”, i had to switch back to a comma!

I would like to know what is the exact syntax of try except? I would like to have the same syntax for windows, unix and mac os

Thank you

  • 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-05-26T14:04:12+00:00Added an answer on May 26, 2026 at 2:04 pm

    The operating system shouldn’t make a difference to Python syntax. Most likely, your cygwin installation includes a Python 2.5. (Confirm this by just typing ‘python’ in your cygwin prompt and checking the banner.)

    Note that ‘a cygwin prompt’ is not Unix.

    If you must, install Python 3 under Cygwin.

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

Sidebar

Related Questions

I've got some code that looks like this: using (DBDataContext dc = new DBDataContext(ConnectionString))
Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)
We've got some code that uses LoadLibrary and GetProcAddress to implement a plugin architecture
I've got some code that uses the Component Categories manager to load all of
I've got some code that will generically get all Controls in a form and
I've got some code that was at the bottom of a php file that
I've got some code that lies in a browser, and wrote C++ plugins for
I've got some code that runs all lovely on SQL Server 2008, however I'm
I got some legacy code that has this: <?PHP if(isset($_GET['pagina'])==homepage) { ?> HtmlCode1 <?php
I've got some (C#) code that relies on today's date to correctly calculate things

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.