Python Forum
call a function from other functions ...
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
call a function from other functions ...
hello all ...

im writing a code to check the system if it linux or windows and do so if expressions after checking the system ....

this is my code :

import os
import sys

import zipfile

q = os.getenv("APPDATA")
d = os.getenv("userprofile")

def systemtype():
    lo = sys.platform
    if lo == "win32":

    elif lo == "linux2":


def unzipfiles():
    if os.path.isdir(q+"/d"):
        zip_ref = zipfile.ZipFile(q + "\", 'r')


i need to call the function systemtype() from the unzipfiles() if the system = windows then extract all files from to C:\Users\root\AppData\Roaming\d ... if the system is linux extract all files from to /tmp ....

how i can do that ?
Functions that print are mainly useful for the final user of your code, but not so for the rest of your program. Useful functions don't print something, they return something. For example they can return a boolean value
def system_is_windows():
    return sys.platform in ('win32', 'windows')

def system_is_linux():
    return sys.platform.startswith('linux')

def unzipfiles():
    if system_is_windows():
    elif system_is_linux():
        raise NotImplementedError('Function unzipfiles() is not yet implemented on this OS')
By the way, use python 3!
thank u very much @Gribouillis
works <3

Possibly Related Threads…
Thread Author Replies Views Last Post
  function call at defined system time? Holon 5 248 Oct-06-2020, 03:58 PM
Last Post: snippsat
  How to call/read function for all elements in my list in python johnny_sav1992 1 255 Jul-27-2020, 04:19 PM
Last Post: buran
  module to store functions/variables and how to call them? mstichler 3 350 Jun-03-2020, 06:49 PM
Last Post: mstichler
  Python: Call function with variabele? Ending in error. efclem 5 396 Apr-22-2020, 02:35 PM
Last Post: buran
  Run a timer when a functions starts to see how long the function takes to complete Pedroski55 2 394 Apr-19-2020, 06:28 AM
Last Post: Pedroski55
  How to mock an object that is created during function call? Schlangenversteher 0 380 Jan-31-2020, 01:36 PM
Last Post: Schlangenversteher
  Is there a way to search for function call? mtran 2 376 Jan-14-2020, 02:07 AM
Last Post: mtran
  what would you call the input for the parameter(s) of a function you have defined? rix 3 484 Dec-16-2019, 12:04 AM
Last Post: rix
  Call to a print in a defined function leodavinci1990 1 427 Nov-20-2019, 01:45 AM
Last Post: ichabod801
  How can I call a c++ function using python HWDev 1 477 Oct-22-2019, 06:19 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020