Search Results

Search found 14486 results on 580 pages for 'python idle'.

Page 99/580 | < Previous Page | 95 96 97 98 99 100 101 102 103 104 105 106  | Next Page >

  • [Embedded Python] Invoking a method on an object

    - by jmucchiello
    Given a PyObject* pointing to a python object, how do I invoke one of the object methods? The documentation never gives an example of this: PyObject* obj = .... PyObject* args = Py_BuildValue("(s)", "An arg"); PyObject* method = PyWHATGOESHERE(obj, "foo"); PyObject* ret = PyWHATGOESHERE(obj, method, args); if (!ret) { // check error... } This would be the equivalent of >>> ret = obj.foo("An arg")

    Read the article

  • traverse a binary decison tree using python?

    - by kaushik
    how to traverse a binary decision tree using python language. given a tree,i want know how can we travesre from root to required leaf the feature of the required leaf are given in an dictionary form assume and have to traverse from root to leaf answering the questions at each node with the details given in feature list.. the decision tree node has format ((question)(left tree)(right tree)) while traversing it should answer question at each node and an choose left or right and traverse till leaf?

    Read the article

  • Good practice of using list of function in Python

    - by riskio
    I am pretty new to python and I discovered by myself that I can create a list of function and call with a for loop. example: def a(args): print "A" def b(args): print "B" def c(args): print "C " + str(args) functions = [a,b,c] for i in functions: i(1) So, my question is: is there any good practice or elegant way to use list of functions and what is a good use of all this? (do have a particular name the "list of functions"?) thank you

    Read the article

  • Session handling in python / django

    - by Gaurav
    I am creating an application that lets users login using Google, Facebook and the website's native login. The site is being built in Python / Django. What would be the best way to handle login, session management and user authentication? I do not want to use the in-built Django user management. I am using Django very sparingly(URLs, templates)

    Read the article

  • How to print source code lines in python logger

    - by anon
    Is there some relatively simple way to programmatically include source code lines to python logger report. For example... import logging def main(): something_is_not_right = True logging.basicConfig(level=logging.DEBUG, format=('%(filename)s: ' '%(levelname)s: ' '%(funcName)s(): ' '%(lineno)d:\t' '%(message)s') ) if something_is_not_right == True: logging.debug('some way to get previous line of source code here?') So that output would look like this. example.py: DEBUG: main(): 14: if something_is_not_right == True:

    Read the article

  • Limiting the size of a python dictionary

    - by anthony
    I'd like to work with a dict in python, but limit the number of key/value pairs to X. In other words, if the dict is currently storing X key/value pairs and I perform an insertion, I would like one of the existing pairs to be dropped. It would be nice if it was the least recently inserted/accesses key but that's not completely necessary. If this exists in the standard library please save me some time and point it out!

    Read the article

  • Built in python hash() function

    - by sm1
    Windows XP, Python 2.5: hash('http://stackoverflow.com') Result: 1934711907 Google App Engine (http://shell.appspot.com/): hash('http://stackoverflow.com') Result: -5768830964305142685 Why is that? How can I have a hash function which will give me same results across different platforms (Windows, Linux, Mac)?

    Read the article

  • Python PLY zero or more occurrences of a parsing item

    - by None
    I am using Python with PLY to parse LISP-like S-Expressions and when parsing a function call there can be zero or more arguments. How can I put this into the yacc code. This is my function so far: def p_EXPR(p): '''EXPR : NUMBER | STRING | LPAREN funcname [EXPR] RPAREN''' if len(p) == 2: p[0] = p[1] else: p[0] = ("Call", p[2], p[3:-1]) I need to replace "[EXPR]" with something that allows zero or more EXPR's. How can I do this?

    Read the article

  • Python + PyQt program freezes

    - by DSblizzard
    I wrote PyQt application. After it's start I close it (GUI), but timer don't stops and Python sometimes freezes. Only thing to unfreeze it - Ctrl-C, after which following message appears: Traceback (most recent call last): File "", line 262, in timerEvent KeyboardInterrupt timer don't stops again, and CPython works very slowly. How to avoid this problem?

    Read the article

  • installing a package with xml based configuration in python

    - by saminny
    Hi, I am planning to write a generic python module for installing a package. This script should retrieve the module from a remote machine or locally and install it on a given host and user. However, there needs to be changes made to the package files based on the host, user and given environment. My approach is to use XML to describe changes to be made to package files based on environment. It will first extract the package to the user directory and then using an xml configuration file, it should replace the file values in the package directory. The xml would look something like this: <package version="1.3.3"> <environment type="prod"> <file dir="d1/d2" name="f1"> <var id="RECV_HOST" value="santo"> <var id="RECV_PORT" value="RECV_PORT_SERVICE" type="service"> <var id="JEPL_SERVICE_NAME" value="val_omgact"> </file> <var dir="d4/d3/s2" name="f2"> <var id="PRECISION" value="true"> <var id="SEND_STATUS_CODE" value="323"> <var id="JEPL_SERVICE_NAME" value="val_omgact"> </file> </environment> <environment type="qa"> <file dir="d1/d2" name="f1"> <var id="RECV_HOST" value="test"> <var id="RECV_PORT" value="1444"> <var id="JEPL_SERVICE_NAME" value="val_tsdd"> </file> <file dir="d4/d3/s2" name="f2"> <var id="PRECISION" value="false"> <var id="SEND_STATUS_CODE" value="323"> <var id="JEPL_SERVICE_NAME" value="val_dsd"> </file> </environment> </package> What are your thoughts on this approach? Is there an existing python module, package or script that I could use for this purpose since this seems fairly generic and can be used for any installation. Thanks! Sam

    Read the article

  • Restrictons of Python compared to Ruby: lambda's

    - by Shyam
    Hi, I was going over some pages from WikiVS, that I quote from: because lambdas in Python are restricted to expressions and cannot contain statements I would like to know what would be a good example (or more) where this restriction would be, preferably compared to the Ruby language. Thank you for your answers, comments and feedback!

    Read the article

  • In google app engine, how to iterate through form fields (python, wsgiref.handlers)

    - by MarcoB
    Using python and wsgiref.handlers, I can get a single variable from a form with self.handler.request.get(var_name), but how do I iterate through all form variables, be they from GET and POST? Is it something like this? for field in self.handler.request.fields: value = self.handler.request.get(field) Again, it should include both fields included in the POST and fields from the query string, as in a GET request. Thanks in advance folks...

    Read the article

  • [python] parsing a string based on specified identifiers

    - by jml
    Let's say that I have the following text: in = "one aaa two bbbb three cccc" I would like to parse this into a group of variables that contain notworking = ["one", "two", "three"] v1,v2,v3 = in.split(notworking) I know that the example above won't work, but is there some utility in python that would allow me to use this sort of approach? I know what the identifiers will be in advance, so I would think that there has got to be a way to do this... Thanks for any help, jml

    Read the article

  • [python] traversing an object tree

    - by jml
    Hi there, I'm trying to find information on different ways to traverse an object tree in python. I don't know much about the language in general yet, so any suggestions/techniques would be welcome. Thanks so much jml

    Read the article

  • doing arithmetic upto two significant figures in Python?

    - by user248237
    I have two floats in Python that I'd like to subtract, i.e. v1 = float(value1) v2 = float(value2) diff = v1 - v2 I want "diff" to be computed upto two significant figures, that is compute it using %.2f of v1 and %.2f of v2. How can I do this? I know how to print v1 and v2 up to two decimals, but not how to do arithmetic like that. thanks.

    Read the article

< Previous Page | 95 96 97 98 99 100 101 102 103 104 105 106  | Next Page >