Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in other languages. Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive set of standard libraries, including NumPy, SciPy, Django, PyQuery, and PyLibrary.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi All,

This is my frist python script working on... I would like to list the servers or cluster from websphere. The script contents are below...
run by cmd - wsadmin.bat -lang jython -F
Error -
WASX7209I: Connected to process "dmgr" on node dmgrNode using SOAP connector;  The type of process is: DeploymentManager
WASX7017E: Exception received while running file ""; exception information: exception from Jython:
Traceback (most recent call last):
  File "<string>", line 13, in <module>
ValueError: call stack is not deep enough

Content of the script - this example got from - C:\IBM\WebSphere\AppServer\scriptLibraries\servers\V70

# Set global constants
import sys
import java
import AdminUtilities

# Setting up Global Variable within this script
bundleName = ""
resourceBundle = AdminUtilities.getResourceBundle(bundleName)

# Retrieve scripting objects from local name space
AdminConfig = sys._getframe(1).f_locals['AdminConfig']
AdminApp = sys._getframe(1).f_locals['AdminApp']
AdminControl = sys._getframe(1).f_locals['AdminControl']
AdminTask = sys._getframe(1).f_locals['AdminTask']
Help = sys._getframe(1).f_locals['Help']    

## Example 1 List available servers with given server type and node ##
def …
Free Tool: SSL Checker
LVL 12
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

In my organization, we have a requirement where our deployment tool uses packages for distribution to servers.  A package may contain may contain artifacts such as binaries and configuration files.

I'm working on a project that require python modules to be installed on the target hosts, but I must use the deployment tool to install the modules versus using the pip tool.  Furthermore, the target hosts do not have internet access making the pip tool useless even if we're allowed to use pip.

I've found the other members in the organization packaged their modules into .pyd files.  For example, in order for the python pyodbc moduled to be installed, it was converted to a single file ending .pyd.  Google searches showed the .pyd files are nothing but DLLs for windows, and cythonize may have been used to package the pyodbc module into a DLL.  The distribution also included a .pth, which is a text file indication the path where the module should be installed on.

I'm attempting to recreate the steps that other members in my organization successfully implemented: how do I convert python modules (such as pyodbc, requets, etc) into their respective .pyd counterparts?
I'm running python (v3.4) in IBM I / AS400 (very similar to mainframes) to generate QR code dynamically to print in customer statements.
Using PyQRCode and PyPNG, I've generated QR code in PNG file. But PNG isn't supported in IBM I, neither is SVG or EPS.
Hence I need to convert PNG to JPEG or TIFF. BUT again PILLOW/numpy is not an option as there was no C/CPP in AS400 and GCC couldn't be setup properly.
So, need to convert (or generate) QR Code in JPG using only pure python libraries.

I'm very new to python and not getting clear leads on ways to
i) generate QR code in JPEG
ii) to convert PNG/SVG to JPG without PIL/PILLOW

any help?
I ran across some python code that allows continuous, live plotting of twitter stream data and sentiment rating. When the author of the code demonstrated it on Youtube, he was able to plot the twitter in a graph, and the graph updated  with each tweet. However, when I run the same code, I get one graph for each tweet and the plot points do not form a continuous line--instead the output consists of one graph, one plot point for each tweet. I would like to  get the graph to show the plotted point for all tweets in one chart in a continuous line.

BTW I am not the  only person who ran into this same problem with the code.  FYI I am currently running python 2.7,  in a Spyder 3.2.8 development environment on Mac.  I have attached the code (without access key information) and it has not been altered from the author's version. Any assistance would be greatly appreciated.

I trade options.  At present I am entering each trade into a spreadsheet .  I can manipulate each individual trade rather easily but when I want to summarize data I have to determine each piece of data I need and what cell it is in and then manually create a summary function.  

Spreadsheets are good for certain things.  Databases are good at storing data for manipulation.

I want to store my trades in a database .  I chose MySql  because it is free.  I am using OpenOffice  calc as my spreadsheet .  I want to be able to export data from MySql  to OpenOffice  Calc .

I want to be able to create forms so I can view the data in the database .  

 I want to avoid using Microsoft products because I don't want to pay the license fees.  I am the only one who will use the data so I want to keep costs low.

From looking at many web pages I gather people are using PHP or Django to display and manipulate MySql  data and create forms.  

I am willing to spend some time to study but I am not going to be an expert programmer.  I have experience using SQL server and using SQL expressions.  I have some experience programming active server pages and ADO.

I have 2 computers both running Windows 7 pro.  They are networked together.  I plan to have one computer running MySql  and the other will be a client machine.

So what I want to do is:
Export data from MySql  to OpenOffice  Calc
Create forms so I can view data in the MySql  database
Print some reports.

need python script to start,stop and check job status in jenkins
Hi: Norie has just helped me with a python question.. here is a follow up. I am having to convert some python2 programs to python3.   Now I have another bank statement that I need to reconfigure to a csv format for importing to a foxpro database. This time the bank sees fit to put commas  within the text so unless  I hunt down the stray commas my conversion to true csv falls flat. To do this  I created a list of instances where the stray commas arise , then take them out by replacing the commas with semi colons thus:

# remove extra commas in text field
input = open("santander2.csv", "r")
output = open("santander22.csv", "wb")
lines = input.readlines()
for (line) in lines:
      newcontents = re.sub(r", MANDATE","; MANDATE",line)
      newcontents1 = re.sub(r", REFERENCE",";REFERENCE",newcontents)
      newcontents2 = re.sub(r"PL,","PL;",newcontents1)
      newcontents3 = re.sub(r"PLAIN,","PLAIN;",newcontents2)
      newcontents4 = re.sub(r"GBP, ON","GBP; ON",newcontents3)
      newcontents5 = re.sub(r" COMM FIN, "," COMM FIN; ",newcontents4)
      newcontents6 = re.sub(r" TT2, "," TT2; ",newcontents5)
      newcontents7 = re.sub(r" CHARGE, "," CHARGE; ",newcontents6)
      #print  >> output,newcontents7.strip()

I have commented out the print line that worked in python2 but the new line returns the erro as shown in attached file.
Can anybody see my mistake?
Hi. I have been happily running an old python script but have just had to reinstall on new guessing I am now on Python3 rather than 2. My scripts fails at the point I strip the line.
THis is  a snippet of the python script that still works in an older version of geany:

input = open("hsbc.csv", "r")
lines = input.readlines()
output = open("hsbc1.csv", "w")
result = []
for line in lines:
            line = re.sub('[,]', '', line)
            print >> output, line.strip()

The error is noted at the 'print >> output.line.strip() line

Does anybody know how to convert the above script from Python2 to 3 so I can use it going forwards?
Thanks!... and you will guess I am no programmer!

I attach the file HSBC.csv
Hi experts,

what is the best way to handle exception in below python3 subprocess scenario please?

I execute below line in my python script.['aws', 'ec2', 'start-instances', '--instance-ids', instance , '--output', 'table'])

Open in new window

could you suggest a best way to handle exception please? try/except?

Thanks in advance
In all my Java games, I have used code like :
public static int STAR_TYPE_RED_DWARF=1
public static int STAR_TYPE_WHITE_DWARF=2
public static int STAR_TYPE_BLUE_GIANT=3
public static int STAR_TYPE_SUPER_GIANT=4
and many more game object constants

What is the best way to replicate this in python, so these constants are automatically associated with its object when writing code?
I haven't seen anything like this yet

Build your data science skills into a career
Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

My requirement is exactly matching with below post from "StackOverflow". This code snippet works perfectly for only one excel file (workbook = xlrd.open_workbook('test.xlsx')) but I have more than 100 + excel files with same Sheet name across all the excel macro files.

Can someone please modify the code, which can create multiple files with different name

import csv
import xlrd

workbook = xlrd.open_workbook('test.xlsm')
for sheet in workbook.sheets():
    if == "Sheet_name_from_xlsm_file":
        with open('{}.csv'.format(, 'w') as f:
            writer = csv.writer(f)
            for row in range(sheet.nrows):
                out = []
                for cell in sheet.row_values(row):

Open in new window

Suppose I have 2 text files

Name, Age


Using Python 3, I’d like to produce a file like this.


The NA value is because A’s school is not in the second file and D’s age is not in the first file.
Hi Experts,
Would like to achieve below using python function. Could anyone help please

1. Python script (a function/def) to accept an argument. E.g. Instance_id1 or Instance_id2 or Instance_id3.
2.  Script to locate relevant instance section in the ini file. (sample file below).
3. Get always_on_start_time, always_on_finish_time, and current system time.
4. Then identify current time is not within start/finish time.
3.  If within, start/finish time, return true, else false.

We will have to further execute few more task based on above return string.

Thanks in advance.

Sample ini file



Open in new window

I want to get input from a user in order to pass it as a listlike set of integers for iloc, but cannot get the list into a working form like [1,3,4,5] for example.


In the above code, I want to specify column indexes from user input instead of hard coding the numbers in.  Please advise.
I'm attempting to create a dataset where an email list is enriched with the person's metadata such as department, manager, state, etc.  Data set A has a field of email addresses.  Data set B also has  field of email addresses along with multiple rows of metadata for the person.  As illustrated in the attached image, there may be missing values in some records, but not missing in other records.  Supposing that the attached data set is for a John Smith, how can I produce a final report where John Smith has values for each metadata field.  I need to do this in Python and the metadata should come from the latest data record first and then iterate over the other other records if values are missing.  Another point to make is that the metadata field names may change, so it's better that we refer to them by their index value.
I am new to the Python programming language, and I am working my way through a tutorial on object-oriented programming in Python.  The purpose of the lesson is to learn the important topic of inheritance of classes.  (Here's a shoutout to Derek, who is hosting this excellent tutorial:

Having created a class called Animal, I then create a new class called Dog, based on Animal.  The program is giving me the error that the Dog class does not recognize the variables inherited from the super class Animal.  Following is my code, and this is my error: "AttributeError: 'Dog' object has no attribute '_Dog__Name'", which comes within Dog.toString() (lines 67-68).   My assumption is that the class definition, "class Dog(Animal):", defines Dog as inheriting attributes from Animal, and Derek's code worked when ran as written here.  Is there something I'm missing?

import random
import sys
import os

#Object-oriented programming
class Animal:
    __Name = None
    __Height = 0
    __Weight = 0
    __Sound = 0

    def set_name(self, name):
        self.__Name = name

    def get_name(self):
        return self.__Name

    def set_height(self, height):
        self.__Height = height

    def get_height(self):
        return self.__Height

    def set_weight(self, weight):
        self.__Weight = weight

    def get_weight(self):
        return self.__Weight

    def set_sound(self, sound):
        self.__Sound = sound


Open in new window

Factors that will drive Python growth in 2018

Python was the fastest growing programming language in 2017. Although Python has been around quite a while, the recent growth factors many aspects. One of the major aspects is the rise of data science, data mining and machine learning.

I am trying to read from a file and input the values from the file into my class. However, it is only taking the last line. How can I get it to do all of the lines in the file, which is five?

Text File :

[code]dataFile = open('apartmentData.txt')
for line in dataFile:
    lineData = line.split(',')
    apt1 = int(lineData[0])
    rent1 = float(lineData[1])
    rooms1 = float(lineData[2])
    baths1 = float(lineData[3])
apt_1= Apartments.Apartments(apt1,rent1,rooms1,baths1)
apt_2= Apartments.Apartments(apt1,rent1,rooms1,baths1)
apt_3= Apartments.Apartments(apt1,rent1,rooms1,baths1)
apt_4= Apartments.Apartments(apt1,rent1,rooms1,baths1)
apt_5= Apartments.Apartments(apt1,rent1,rooms1,baths1)


Open in new window

235        1375.0     3.0        2.0      
235        1375.0     3.0        2.0      
235        1375.0     3.0        2.0      
235        1375.0     3.0        2.0      
235        1375.0     3.0        2.0  

desired output:
231        1200.0     1.0        1.0      
232        1250.0     2.0        1.0      
233        1300.0     2.0        1.5      
234        1350.0     2.0        2.0      
235        1375.0     3.0        2.0  [/code]
Hi! The purpose of the program is to get the user to enter in there criteria for an apartment, and have all of the apartments that meet that criteria print out. However, my code only works to find the first apartment that meets the criteria and doesn't continue moving through the list. Any ideas on how to make this work while keeping my apartments class objects?

class Apartments(object):
    def __init__(self,aptNum, rent, rooms, bath):
            self.aptNum = aptNum
   = rent
            self.rooms = rooms
            self.bath = bath
    def getApt(self):
        return '{:<10} {:<10} {:<10} {:<10}'.format(self.aptNum,,self.rooms,self.bath)

Open in new window

import Apartments

apt_1= Apartments.Apartments(111,1000,1,1)
apt_2= Apartments.Apartments(112,2000,2,1)
apt_3= Apartments.Apartments(113,2500,2,2)
apt_4= Apartments.Apartments(114,3000,3,2)
apt_5= Apartments.Apartments(115,3500,3,3)


while True:
    rentInput=input('Enter maximum amount of rent: ')
    roomInput=input('Enter minimum number of bedrooms: ')
    bathInput=input('Enter minimum number of baths: ')
        val = int(rentInput)
        val2 = int(roomInput)
        val3 = int(bathInput)
        if val < 0:  
            print("Sorry, input must be a positive integer, try again")
        if val2 < 0:  
            print("Sorry, input must be a positive integer, try again")

Open in new window

Free Tool: Site Down Detector
LVL 12
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

My Python RTS server reboot from my finished Java one needs some clarifications.

The example networking code at this Python page doesn't work, when it clearly should, code below


The line with bind() is where it raises exceptions and it's baffling me! - cut and paste!
My code that won't compile is...
import socket, sys

if __name__ == "__main__":



        # Create a TCP/IP socket
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        # Bind the socket to the port
        server_address = ('localhost', port_num)
        print ('starting up on %s port %s', server_address)


Open in new window

Did I miss a step in pyCharm settings?

Stumped on this exercise."Create a class named Apartment that holds an apartment number, number of bedrooms, number of baths, and rent amount.  Create a constructor that accepts values for each of the data fields.  Also, create a get method for each field.  Write an application that creates at least five Apartment objects (The data to create the Apartment objects will come from a file).  Then prompt the user to enter a minimum number of bedrooms required, a minimum number of baths required, and a maximum rent the user is willing to pay.  Display data for all the Apartment objects that meet the user’s criteria or an appropriate message if no such apartments are available." Here is my bare bones attempt. Any tips or examples of a similar scenario ?
    import sys
    #random text file with apartment information in it separated by a comma
    import Apartments
    apartmentData = open('apartments.txt')
    apartmentLines = apartmentData.readlines()
    for line in apartmentLines:
        lineData = line.split(',')
    bedrooms=input('Enter minimum number of bedrooms: ')
    baths=input('Enter minimum number of baths: ')
    rent=input('Enter maximum amount of rent: ')
    #below different py file 

Open in new window

Hi developers!
I am a software engineering student. I am now working on a project for my internship. I am receiving large JSON files with certain API ( I am working on JIRA's data ). Now I am working with python on those JSON files and getting pieces of information I need for my project. The problem is that what I am getting is so large and I need a lot of time to get everything I want. Is there a solution to accelerate the retrieval?
I have 5 Quiries which will pull the data from the oracle database and show the results

Now I am planning to work on a project like as below

1. JAVA program to use the Quries and pull those information and
2. Write into a spreadsheet with individual sheet names and
3. Finally send out an mail to the team with the link where I have copied the sheets.

Please share your thoughts

Hello, I am a newbie in Python, and I am wondering how to import a dataset(csv file) to my Anaconda. Thanks in advance~
I am new to the Python program, and I am using a YouTube video, showing me how to download the program.  The instructor requests that I download PyCharm, which I did.  The problem, however, is that he uses a Mac version of the program, while I am using a PC version of the program.  The Apple menu shows a menu called "Preferences" option, which I don't see anywhere on any of the menus I have available on my PC.  Once there, the teacher requests that I change several settings, none of which do I see, since I don't see "Preferences".  These settings seem critical, and I am wondering if they exist elsewhere, in a more obscure menu I am not noticing.  

I have an attachment that shows the two environments: the Apple view from a screenshot in the video, and the PC view shows the menu items I have available on my desktop.  Hope this is a simple fix.  Thank you, ~ Peter Ferber
Windows program does not reveal "Preferences".


Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in other languages. Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive set of standard libraries, including NumPy, SciPy, Django, PyQuery, and PyLibrary.