Support: 1-800-961-4454
Sales Chat

Got Python Questions? Ask Our Experts In The Rackspace Community


EDITOR’S NOTE: Update: We got some great feedback about the first AMA with Jesse, so we’re moving the discussion space for Alex’s AMA from the Community to – that way it will be easier to follow the conversation and replies. In addition, we’re tightening up the timeframe – the AMA will happen on Tuesday ONLY, and not Tuesday through Thursday as originally planned. Finally, some of the other devs who work with Alex will be lending a helping hand, so there will be plenty of developer experience on tap for everyone! Hope to see you all there next Tuesday!

We know technical questions come up from time to time; questions that may require a pretty in-depth response. That’s why next week we’re launching a new Ask-Me-Anything three-day event series in partnership with the Rackspace Community. It’s your opportunity to ask ANY development question you like and solicit feedback from Rackspace experts and others in the field. Ok, maybe not any development question: for this series of virtual events we’re focusing mainly on Python.

At Rackspace, we are fortunate to have the best and brightest in the Python community keeping us at the cutting edge, and they want to share some of their expertise and experience with our Community members!

Each month, a Racker Python expert will open a post for questions and reply to every (reasonable!) question asked on that post, over the course of three days. Technical questions might require some additional sourcing, so we encourage you to check back often on the post and your question.

Mark your calendars for August 6 through August 8 and join us for the first session with Jesse Noller. We have Alex Gaynor and Ed Leafe lined up to participate in the months following. We hope you can benefit from the conversations over the next few months.

Python Ask-Me-Anything

  • August 6, 7 & 8Jesse Noller: Jesse is actively involved in the Python Software Foundation and organizing PyCon. Learn more about him on his blog or follow him on Twitter @jessenoller
  • September 3Alex Gaynor: Alex has worked for Rackspace as a software engineer on the Developer Relations Group since May. In his free time he works on many open source software projects, such as Django and PyPy, and serves on the board of directors of the Python Software Foundation. He grew up in Chicago and now lives in San Francisco. Follow him on Twitter @alex_gaynor.
  • October (date TBD)Ed Leafe: Ed has been a developer for over 20 years, and is one of the original developers involved with OpenStack. After leaving the Microsoft world over a decade ago, he has been primarily a Python developer, and has spoken at several US PyCons. He has worked with Rackspace for the past five years (and he also throws a mean Frisbee). Follow him on Twitter @EdLeafe.

No RSVP is required for these events. Simply show up, post your question and watch the conversation take off. Join us again in September and October as the guests change each month. Hope to see you in the Community!

About the Author

This is a post written and contributed by Pat Reynolds.

Pat is a community manager for Rackspace, He's been a Racker since 2004, and he's been in San Antonio since 2007 - a long way from home, which for Pat is Ireland. His main goal in the Community is to get great content out to its members. He is a gadget geek, who has a fascination with Android and social media in general. When he's not having his brain exploded by trying to keep up with the latest advances in science, he's either reading fantasy fiction or out and about Enlightening Ingress portals.

  • Rahul

    Here I m passing dictionary as command line argument to python script

    >python {“doctype”:”Address”,”address_title”:”Mr.Machha”,”address_line1″:”Vijayanagar”,”city”:”BangLORE”,”phone”:”012345678″}

    And in my python script( I m getting

    data= sys.argv[1]
    print data
    # {doctype:Address,address_title:Mr.Machha,address_line1:Vijayanagar,city:BangLORE,phone:012345678}

    Here I m not getting dictionary as I m passing ie


    How to get dictionary as mentioned above in my script?

  • Shubham Sharma

    why am is getting this error in my program?

    what is thew eror in this:

    Traceback (most recent call last):

    File “F:/coding/python/python programming for absolute beginners/chapter 4/The Jumble”, line 9, in


    AttributeError: ‘str’ object has no attribute ‘randrange’

    import random

    print”tttThe Jumble Game”

    print”In this program you will be given a jumble word and you have to guess that word”









    print(“The jumble word is”,random)

  • ramnath

    hi this is ramnath reddy . i am using rexster server with Titan cassandra. and all are installed in my local host. me configure my rexster.xml to create a specific graph.



    and i want to add edges and vertices’s to that my new graph . i wrote below code to add
    `from bulbs.rexster import Graph, Config
    config = Config(‘http://localhost:8182/graphs/emptygraph’)
    g = Graph(config)`

    but i am getting error ……if i add below data that will effect to default graph only ….. that code not showing any effect on empgraph …… what i have to do to add a data to my newly created empgraph ?

    from bulbs.rexster import Graph
    config = Config(‘http://localhost:8182/graphs/empgraph’)
    g = Graph()
    class inser_class():
    po = g.vertices.create(name=”po”)
    pr = g.vertices.create(name=”pr”)
    tanuja = g.vertices.create(name=”tanuja”)
    g.edges.create(pr, “knows”, tanuja)

    • Rose Coste

      Hi, this blog posting announces the schedule for several ask-me-anything sessions with python experts in 2013. For continuing discussion in 2015, you’re more likely to find developers to talk with in the Rackspace Community at

      I hope this helps.

      —rose coste
      Information Developer

  • bnm

    i am new to python and i am facing this problem

    i have two text files

    suppose my file1 is








    file 2 is








    and i want to check each value of file1 with all values of file2

    if there is a mismatch it will print the respective value of file1

    means my o/p will





    i have tried with this codes but didnt get output


    #print f2



    for l2 in f2:


    for j in range(len(i)-1):



    with open(“mismatchid1.txt”, “a”) as myFile:

    myFile.write(‘%5s %8sn’ % (i[index],vals[2]))

  • John howland

    I have created an instance tux from class Penguin() in the MainHandler class. The Penguin class has a public attribute named wingspan. How do I print tux’s wingspan to the console from within the MainHandler class?

  • Balaji

    The below code track the face from input video captured from webcam, but the code tracks the face only once. How to modify the below code to track the face continuously when the face keep on moving?
    import cv
    import numpy
    import time
    class Camera(object):
    def __init__(self, camera = 0): = cv.CaptureFromCAM(camera)
    if not
    raise Exception(“Camera not accessible.”)

    def get_frame(self):
    frame = None
    while not frame:
    frame = cv.QueryFrame(

    return frame

    def get_fps(self):
    fps = cv.GetCaptureProperty(, cv.CV_CAP_PROP_FPS)
    return fps if fps != -1 else 30.0

    def get_size(self):
    w = int(cv.GetCaptureProperty(, cv.CV_CAP_PROP_FRAME_WIDTH))
    h = int(cv.GetCaptureProperty(, cv.CV_CAP_PROP_FRAME_HEIGHT))
    return (w,h)

    class FaceDetector(object):

    def __init__(self, width, height, cascade_file=”haarcascade_frontalface_alt.xml”):
    # Load the cascade
    self.cascade = cv.Load(cascade_file)
    # Storage for the algorithm to use = cv.CreateMemStorage()
    # A grayscale buffer to copy images for processing into
    self.gray = cv.CreateImage((width, height), 8, 1)

    def get_faces(self, image):
    # Convert the image to grayscale and normalise
    cv.CvtColor(image, self.gray, cv.CV_BGR2GRAY)
    cv.EqualizeHist(self.gray, self.gray)
    # Detect faces
    return cv.HaarDetectObjects(self.gray, self.cascade,,
    scale_factor = 1.3,
    min_neighbors = 2,
    flags = cv.CV_HAAR_DO_CANNY_PRUNING,
    min_size = (40,40))

    def get_best_face(self, image):
    return max(self.get_faces(image),
    key = (lambda f: f[1]))
    except ValueError:
    return None

    class FaceTracker(object):

    def __init__(self, frame, face_position,
    fh_x = 0.5, fh_y = 0.13,
    fh_w = 0.25, fh_h = 0.15):
    A motion tracker that can track a face. Note: This class
    simply provides the interface but doesn’t actually track the face as it
    @param frame The first frame containing the face
    @param face_position The position of the face in the frame
    @param fh_x The x-position on the face of the center of the forehead
    @param fh_y The y-position on the face of the center of the forehead
    @param fh_w The width, relative to the face, of the forehead
    @param fh_h The height, relative to the face, of the forehead
    self.face_position = face_position
    self.fh_x = fh_x
    self.fh_y = fh_y
    self.fh_w = fh_w
    self.fh_h = fh_h

    def update(self, time, frame, face_position = None):
    Add a new frame. Will override the face position if specified.
    self.face_position = face_position or self.face_position

    def get_face(self):
    return self.face_position

    class Annotator(object):
    THIN = 1 # Thin line width
    COLOUR_FACE = (0,255,255)

    def __init__(self):
    Can annotate various features onto frames.
    # Setup fonts
    self.small_font = self._get_font(0.5,Annotator.THIN)
    # Text colour
    self.face = (0,0,1,1)

    def _get_font(self, size=1, weight=1, italic=0):
    return cv.InitFont(cv.CV_FONT_HERSHEY_SIMPLEX,
    size, size, italic, weight)

    def set_face(self, face):
    self.face = tuple(map(int, face))

    def metrics(self):
    _,y,_,_ = map(int, self.face)
    return (y)

    def draw_face(self, frame):
    x,y,w,h = self.face

    c = Annotator.COLOUR_FACE
    cv.Rectangle(frame, (int(x),int(y)), (int(x+w),int(y+h)), c, Annotator.THIN)

    class Program(object):

    def __init__(self,
    webcam = 0,
    window_title = “output”): = Camera(webcam)
    self.face_detector = FaceDetector(*
    self.face_tracker = None
    self.annotator = Annotator()
    self.window = window_title


    self.show_face = True

    def find_face(self, frame):
    # Try and find a face
    face = self.face_detector.get_best_face(frame)
    if face is not None:
    # Track the new face
    self.face_tracker = FaceTracker(frame, face[0])

    def update(self):
    Mainloop body. Returns True unless termination requested.
    frame =
    frame_time = time.time()
    if self.face_tracker is None:
    # No face known
    # Track the face
    self.face_tracker.update(frame_time, frame)

    # Draw the OSD
    if self.show_face:
    # Display the (possibly annotated) frame
    cv.ShowImage(self.window, frame)
    # Handle keypresses
    key = cv.WaitKey(10) & 255
    if key == 27: # Escape
    # Exit
    return False

    return True

    def run(self):

    while self.update():

    if __name__==”__main__”:

  • bogdi

    I’ve added the question on stackoverflow. Would be thankful if you could look over it.

  • goodluck


    i want to print the string as ‘%h’ %r “%t” %s %d
    i tried using print(”’…….
    ‘%h’ %r “%t” %s %d
    ”’. %())

    i stucked here pls help me out

Racker Powered
©2015 Rackspace, US Inc.