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

[('01', ['name abc', 'age 32', 'address addr123']), ('02', ['name def', 'age 22', 'address addr456'])]

   I want this list to be written in CSV file in below format. Some time list may contain more values.So no hard codings.
    Expected output in csv in table format
    id    name   age   address
    01   abc     32     addr123
    02   def     22     addr456
On Demand Webinar: Networking for the Cloud Era
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

I have below python script
response = ''
ascii_map = 'abcdefghijklmnopqrstuvwxyz012345'
for j in range(7):
    response += ascii_map[(int('3996146930') >> (5*j)) & 31]
print response

Open in new window

I give output as below

Open in new window


I have a OID as below

Open in new window

I would like to know how can I convert it to it's name using python? I do not want to make any network or localhost call.

this OID is mapped to one of the VSERVER's Name in NetScaler.
Hi all!

I wrote a little python code to continously check if the user is active and, if not, lock the computer screen.

This works well.

I've then decided to use a small systray icon to enable / disable the endless loop that is checking for user activity but it seems like showing the systray icon is an endless loop itself.

Therefore if I run my current code:

# Instructions
# Pair your phone to your pc's bluetooth as first step
# Then scroll down and customize the locker's parameters before running
# the script. Simply search for "Customize me" to make your life easier :)
# 1st parameter is your phone name (in my case 'G4') and 2nd is maximum
# number of seconds that the user is not active before the screen
# is autolocked

# Importing classes
from autolocker_class import *
from systray_icon_class import *

# Customize me!
locker = ScreenLock('G4', 10)

# Minimal self test. You'll need a bunch of ICO files in the current working
# directory in order for this to work...
if __name__ == '__main__':
    hover_text = "IPAutolocker"
    bluetooth_icon = 'Checked.ico'
    def autolocker_on(sysTrayIcon):
        locker.is_autolocker_enabled = True
        print "Autolocker enabled"
    def autolocker_off(sysTrayIcon):
        locker.is_autolocker_enabled = False
        print "Autolocker disabled"
    def bluetooth_on(sysTrayIcon):
        is_bluetooth_on = True
        print "Bluetooth enabled"
    def bluetooth_off(sysTrayIcon):
        is_bluetooth_on = 

Open in new window


I am expected to propose the EDIFACT solution for a company that starts from scratch (regarding EDIFACT).

Communication via OFTP2 ready to be used (on Linux)

The only thing that is already decided and ready to be used is the OFTP2 communication (on Linux machine, OS4X by c-works if it matters, ODETTE ID assigned).

This way, message splitting or even parsing can use UNIX-based tools. Anyway...

MS SQL and procession on Microsoft Server

... the original message (before parsing) will also be saved on Microsoft based server (as a blob in the SQL table).

The database and the Enterprise applications is running on a different computer -- Microsoft Windows Server, MS SQL Server.

First messages to be processed

The Delivery schedule message (DELFOR) and Despatch advice message (DESADV) are the first one to be received. I am aware of versions of the EDIFACT messages (about two releases each year).

I am aware of X12 being the predecessor of EDIFACT, of the other standards like Tradacom, VDA, ... and the consequences of having tools for transformation of the messages. However, the decision was made to use the pure UN/EDIFACT only.

Differences based on a partner decisions

I am partly aware of (future) problems with _the same kind of message from a different …

I am using Jupiter to write a read csv line.

So far,I wrote>>

(1)      import pandas as pd
(2)      pd.read_csv('C:/Users/USER1/Documents/Exports/ItemStatus.csv', sep=',')

but its giving me error. See text file. What I need to change to make this work…
Below code works perfectly now I want to provide ObjectType(ObjectIdentity()) as a variable which will be constructed as a list of OID

from pysnmp.hlapi import *

g = getCmd(SnmpEngine(),
           UdpTransportTarget(('', 161)),

for x in next(g)[3]:
    print x

Open in new window

I have a list of OID as below and somehow I want to put that in getCmd method as a variable
mibs = ['', '']

Open in new window

so basically I have a dynamic list of OID (minimum 3 and maximum 9 ) and I want to supple them as a variable in above code so that in ONE SNMP call I will get output of all the OIDs. Is there a way I can do it? Thanks!
i want to use winpcap lib in python, but prompt :

Traceback (most recent call last):
  File "D:\1_AutoTest\7_Pyhon\1_Code\Winpcap\src\", line 12, in <module>
    import sysloglib
ImportError: No module named sysloglib
I want to be data analyst.
but i don't know, what should i learn first?

what are basic capabilities  should i have ?
Back when C# came out; I did not know how to pronouns this combination of C and a # (sharp).  Talking to a  developer, he chuckled when I said "C pound."
And now, when "reading" about generic decorators; it is not written as to  how to pronouns these;
*args, **kwargs
Might any one have the phonetics /fəˈnediks/ on these two decorators;
*args, **kwargs

Free Tool: SSL Checker
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.

I'm currently trying to create a script that will search for specific data in an excel document and print out a range of cells.

For example, it would search for "color" in column A. If "color" was found in A4 it would print out the data in A4, B4, C4, D4, etc.

import openpyxl
wb = openpyxl.load_workbook('example.xlsx')
sheet = wb.get_sheet_by_name('Sheet1')

for rowOfCellObjects in sheet['A1':'C3']:
    for cellObj in rowOfCellObjects:
        print(cellObj.coordinate, cellObj.value)

Open in new window

This is the only code I have so far which is an excerpt from Al Sweigart. “Automate the Boring Stuff with Python: Practical Programming for Total Beginners.” iBooks. and the only thing it does is search for specific cell addresses and prints those.

Is this a feasible project? I'm very new to Python so I don't fully grasp its limitations.

Any help would be appreciated!
*I was tasked with writing a script (suggested in python but can be anything that the Crontab will work with) but my programming skills are definitely lacking. In the past week I have been researching and trying to learn as much as I can and below is what I came up with but I could use some help from the EE community. Thanks!

I am trying to write a script in python that will run on our Crontab of our Linux VM server. The script is supposed to recursively go through all the files on the remote server directory and download the specified file type (.csv in this case) and then promptly delete whatever files successfully download from the server. I have the following code using pysftp but I am open to using other modules such as paramiko or lftp if it's easier. It just needs to be able to be run as a Cron job in our Crontab on the linux server.

Below is my current code but it isn't work in terms of remotepath, localpath. I tried to tell it to download the file to a certain path but it's not going there. Also I don't know the command to remove the files it downloaded only. In other words files might already be on the local server and if so they should NOT download so that means the file wouldn't be removed from the remote server (if it doesnt download it shouldn't get removed).

For security purposes I have removed the server info. I did create a public/private key for ssh but unsure of how to implement it into my code.

import pysftp
import sys
import glob


Open in new window

I have a txt file containing data in following format:

abc 123 456
cde 45 32
efg 322 654
abc 445 856
cde 65 21
efg 147 384
abc 815 078
efg 843 286
and so on. How can transpose it into following format using Python:

abc 123 456 cde 45 32 efg 322 654
abc 445 856 cde 65 21 efg 147 348
abc 815 078 efg 843 286
Also, in case cde/efg is missing after abc, it should insert blank spaces instead, since it is a fixed width file.
One more thing , abc will always be present, sometimes row starting with cde or efg will not be there .
I've recently decided to try and develop a script that will allow me to search for a specific word or value in a row and copy all of the data in the corresponding column, but it's proven to be too much for myself as I'm very new to Python.

If I could figure out how to search for cells within excel using Python I could go from there, but I haven't found any good resources to teach myself that skill.

Any help would be greatly appreciated.
hi All,

kindly help me to write a shell or python script to delete the weblogic files. The files are rotated but need to be deleted which are 30 days old. the find command doesn't delete the files because the number of files are huge.

below is the  .logs format of the weblogic servers


Hello All,

I am new to python and coding overall. I am trying to make sense out of a particular line in the code below. This code will be used to see the files in my recycle bin. In  the second line, what are "curr, dirs, files"? are those fields, arguments of os.walk() function? I have noticed that if I change for instance "curr" for any other name, and change that parameter in the "path" line, the program still works. I am actually a little confused.

import os
rootrec = "C:\\$Recycle.Bin"
for curr, dirs, files in os.walk():
    for f in files:
        path = "%s/%s" % (curr,f)

Any clarification will be helpful!
I am looking to replace the value between two spaces in a string with a backslash. Can someone assist with the syntax.

E.G. I want

RED 123456789 White

to become


Hello all,

I am new to Python and I have a couple of questions regarding the code below. I am currently going through a lesson that shows you how to replay packets using scapy. In my try block on the code below, what does "frame[Ether].src" and "frame[IP].src" where did I get these variables from?
Is ".src" a module? what is "[Ether]" and [IP]?

I hope you guys can clarify.

Thank you!

from scapy.all import *
from scapy.utils import rdpcap

src_mac = "08:00:27:ae:6f:d7"
dst_mac = "08:00:27:87:57:be"
src_ip = ""
dst_ip = ""

frames = rdpcap("/root/pcaps/ping_traffic.pcap")
for frame in frames:
        frame[Ether].src = src_mac
        frame[Ether].dst = dst_mac

        if IP in frame:
            frame[IP].src = src_ip
            frame[IP].dst = dst_ip

    except Exception as e:
I have a python script that will construct a list of futures contracts for a specified symbol, exchange, and year window.  The script will download pricing information from Quandl for each contract in the strip.  This script works properly.

import pandas as pd
from pandas import ExcelWriter
import quandl

symbol = 'ES'
exchange = 'CME/'

start_year = 2015
end_year = 2016

#Constructs a list of futures contract codes for a particular symbol
#and timeframe.
futures = []
months = 'HMUZ'
for y in range(start_year, end_year+1):
    for m in months:
        futures.append("%s%s%s%s" % (exchange, symbol, m, y))

#Download the data from Quandl.
for f in futures:
    quandl.ApiConfig.api_key = "xxxx"  
    data = quandl.get(str(f))
    data = data.drop(data.columns[[3, 4, 7]], axis=1)

I have another python script that will create a continuous futures contract from 2 consecutive contracts in the futures strip.  It uses the perpetual method; identifying the roll date as the first day where volume of the far contract exceeds volume of near contract, and then adjusts the prices of the previous 4 sessions to roll date by weighting the near and far contracts in increments/decrements of 20%.  This script works properly.

import pandas as pd
from pandas import ExcelWriter
import quandl

#Get quandl futures data
quandl.ApiConfig.api_key = "xxxx"    
contract_near = quandl.get("CME/ESH2015")
contract_far = quandl.get("CME/ESM2015")

#Drop the columns …
Free Tool: Path Explorer
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

I am new to python, Now am trying to update a cell with hyperlink which refer to another cell sheet. i have tryed with below code but while click the cell its showing error with "Cannot open the specified file". Could you any one can help on this ?

from win32com.client import Dispatch
excel = Dispatch('Excel.Application')
book = excel.Workbooks.Open("Location.xls")
sheet = book.Worksheets(1)
cell_location = sheet.Cells(2,2)
cell_destination = book.Worksheets(2).Cells(1,3)
sheet.Hyperlinks.Add(Anchor=cell_location, Address=cell_destination)
I have a list (named bob) and I want to reverse the order of the list without reversing the whole list.  So, for example my bob list would be [Bob, Mom, Dad, Kelsey] and I want to reverse it to read [boB, moM, daD, yesleK] instead of [yesleK, daD, moM, boB].  

I know I have to iterate through each line and add the extracted line in from of the accumulating string, but I’m not sure how to set up the FOR loop to do so.  How would I do that?
I had this question after viewing linux crontab output.

Hi everyone,
right now I am manually running this script to start a python app. I would like to do this @ reboot.

cd /home/ec2-user/console

python 8090 cloud& <<this runs fine

I tried to create a small bash script ,but cant seem to make it run @ reboot time

cd /home/ec2-user/console
python 8090 cloud&

crontab -e

@reboot sh $HOME/ <<dosnt work

the script runs when executed manually but not @ reboot

Hi Experts,

 I am looking  for a data science project(using python) with complete source code and documentation , please help me with the same and will appreciate your help in this regard.  

There are x students and y tents placed randomly on a field of dimensions 1000 by 1000 (including(0,0,)). A tent can only house up to 10 students. As a curfew is in place, all students have to find a place in the tents. I have to assign students to tents such that the number of steps walked by the students will be miNimized. Students can only move horizontally and vertically, so if their location is (0,0) and the tent's location is (10,10) then they must walk 20 steps to reach the tent.
The location of the tents will be stored in a file called tents.csv, and the location of the students stored in a file called students.csv.  
The program should read the locations of each and output the results in a file named output.csv where:
- the first row contains the number of total steps walked
- from the second row, each row contains [student ID, tent ID, steps walked, student x location, student y location, tent x location, tent y location]

The program should be able to execute any range of values as defined in the problem definition.

P/s: anyone who know how to solve please please please help me...this is the project that can decide my future......ㅠㅠㅠ
This code does 3 things:
1. Gets a list of ticker symbols
2. Gets pricing information from Google finance
3. Inserts the pricing information into a MySQL table

The code runs without returning any errors.  However, the MySQL table is not populated with the information.  The following is returned:
Empty DataFrame
Columns: [open_price high_price, low_price, close_price]
Index: []

I can't figure out why. Advice is needed and appreciated, thank you.


import datetime as dt
import MySQLdb as mdb
import as web

# Obtain a database connection to the MySQL instance
db_host = 'localhost'
db_user = 'xxx'
db_pass = 'xxxxx'
db_name = 'securities_master'
conn = mdb.connect(db_host, db_user, db_pass, db_name)

#Obtains a list of the ticker symbols in the database.
cur = conn.cursor()
cur.execute("SELECT id, ticker FROM symbol")
data = cur.fetchmany(10)    

#Get daily historic data from google
start_date = dt.datetime(2005, 2, 1)
end_date = dt.datetime(2005, 2, 28)          
for d in data:
        gf_data = web.DataReader(str(d[1]), "google", start_date, end_date)
    # Create the time now
    now = dt.datetime.utcnow()
    #Create dictionary for db
    pricing_info = {
        'symbol_id': d[1],
        'price_date': now,
        'created_date': now,
        'last_updated_date': now,
        'open_price': gf_data['Open'],
        'high_price': …


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.