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 6976267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:28:28+00:00 2026-05-27T17:28:28+00:00

I found this tutorial in A Byte of Python, but do not understand it:

  • 0

I found this tutorial in A Byte of Python, but do not understand it:

import os
import time

source = [r'C:\Users\Desktop\Stuff']

target_dir = 'C:\Users\Backup'

target = target_dir + time.strftime('%Y%m%d%H%M%S') + '.zip'

zip_command = 'zip -qr "%s" %s' % (target, ' '.join(source))

if os.system(zip_command) == 0:
    print 'Successful backup to', target
else:
    print 'Backup failed!'

After checking help(os) I do not understand why os.system(zip_command) would ever be zero. .system() does not return a Boolean, does it?

thanks.

  • 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-27T17:28:29+00:00Added an answer on May 27, 2026 at 5:28 pm

    help(os.system) says:

    system(...)
        system(command) -> exit_status
    
        Execute the command (a string) in a subshell.
    

    So, it executes the command you pass as a parameter and returns the exit_status of that command.

    When a program returns 0 as result, it means it was executed succesfully and if it returns anything else, it probably means there was an error somewhere.

    So in this line:

    if os.system(zip_command) == 0:
    

    you are actually asking: if the command line was executed succesfully then … else …

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

Sidebar

Related Questions

I found this tutorial on using WIA in c++, but I don't understand how
I found this tutorial about ffmpeg the thing i do not get is how
Im trying to understand what a functor is, i found this tutorial/example: http://en.wikibooks.org/wiki/Haskell/Solutions/Applicative_Functors data
I found this tutorial about Activex component but I am getting an error under
I found this tutorial on how getting Idle time of the user Idle Time
I'm trying to understand how the quaternion rotations work, I found this mini tutorial
I am looking for a good introduction to Python namespaces. I found this tutorial
I found this tutorial that explains what I want to do using html but
I found this tutorial on regular expressions and while I intuitively understand what "greedy",
I found this tutorial at tizag.com. But It is for displaying entries from different

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.