Search Results

Search found 15187 results on 608 pages for 'boost python'.

Page 81/608 | < Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >

  • Clear command line output from Python [Eclipse]

    - by Tomas Lycken
    I'm using Eclipse for writing Python, and I want to be able to easily clear the screen. I've seen this question, and tried (among other things suggested there) the following solution import os def clear(): os.system('cls' if os.name == 'nt' else 'clear') but it doesn't entirely solve my problem. Instead of clearing the screen, the routine prints a small square (as if wanting to print an unknown character) to the command output window in Eclipse. Typing cls in the command line works perfectly fine, as does running a Python script with the above code from command line. But how can I make it look nice in Eclipse as well?

    Read the article

  • Allowing threads from python after calling a blocking i/o code in a python extension generated using

    - by SS
    I have written a python extension wrapping an existing C++ library live555 (wrapping RTSP client interface to be specific) in SWIG. The extension works when it is operated in a single thread, but as soon as I call the event loop function of the library, python interpreter never gets the control back. So if I create a scheduled task using threading.Timer right before calling the event loop, that task never gets executed once event loop starts. To fix this issue, I added Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS macros manually in the SWIG auto generated wrapper cxx file around every doEventLoop() function call. But now, I want to do the same (i.e. allow threads) when SWIG generates the code itself and not to change any code manually. Has anyone done something similar in SWIG? P.S. - I would also consider switching to any other framework (like SIP) to get this working. I selected SWIG over any other technology is because writing SWIG interface was really very easy and I just had to include the existing header files.

    Read the article

  • How to save big "database-like" class in python

    - by Rafal
    Hi there, I'm doing a project with reasonalby big DataBase. It's not a probper DB file, but a class with format as follows: DataBase.Nodes.Data=[[] for i in range(1,1000)] f.e. this DataBase is all together something like few thousands rows. Fisrt question - is the way I'm doing efficient, or is it better to use SQL, or any other "proper" DB, which I've never used actually. And the main question - I'd like to save my DataBase class with all record, and then re-open it with Python in another session. Is that possible, what tool should I use? cPickle - it seems to be only for strings, any other? In matlab there's very useful functionality named save workspace - it saves all Your variables to a file that You can open at another session - this would be vary useful in python!

    Read the article

  • Converting excel files to python to frequency

    - by Jacob
    Essentially I've got an excel files with voltage in the first column, and time in the second. I want to find the period of the voltages, as it returns a graph of voltage in y axis and time in x axis with a periodicity, looking similar to a sine function. To find the frequency I have uploaded my excel file to python as I think this will make it easier- there may be something I've missed that will simplify this. So far in python I have: import xlrd import numpy as N import numpy.fft as F import matplotlib.pyplot as P wb = xlrd.open_workbook('temp7.xls') #LOADING EXCEL FILE wb.sheet_names() sh = wb.sheet_by_index(0) first_column = sh.col_values(1) #VALUES FROM EXCEL second_column = sh.col_values(2) #VALUES FROM EXCEL Now how do I find the frequency from this? Huge thanks to anyone who can help! Jacob

    Read the article

  • running pdb from within pdb

    - by Andrew Farrell
    I'm debugging an script that I'm writing and the result of executing a statement from pdb does not make sense so my natural reaction is to try to trace it with pdb. To paraphrase: Yo dawg, I like python, so can you put my pdb in my pdb so I can debug while I debug?

    Read the article

  • Binomial test in Python

    - by Morlock
    I need to do a binomial test in Python that allows calculation for 'n' numbers of the order of 10000. I have implemented a quick binomial_test function using scipy.misc.comb, however, it is pretty much limited around n = 1000, I guess because it reaches the biggest representable number while computing factorials or the combinatorial itself. Here is my function: from scipy.misc import comb def binomial_test(n, k): """Calculate binomial probability """ p = comb(n, k) * 0.5**k * 0.5**(n-k) return p How could I use a native python (or numpy, scipy...) function in order to calculate that binomial probability? If possible, I need scipy 0.7.2 compatible code. Many thanks!

    Read the article

  • Python KMeans clustering words

    - by sadawd
    Dear Everyone I am interested to perform kmeans clustering on a list of words with the distance measure being Leveshtein. 1) I know there are a lot of frameworks out there, including scipy and orange that has a kmeans implementation. However they all require some sort of vector as the data which doesn't really fit me. 2) I need a good clustering implementation. I looked at python-clustering and realize that it doesn't a) return the sum of all the distance to each centroid, and b) it doesn't have any sort of iteration limit or cut off which ensures the quality of the clustering. python-clustering and the clustering algorithm on daniweb doesn't really work for me. Can someone find me a good lib? Google hasn't been my friend

    Read the article

  • Debugging segfault on swig/python/c++

    - by Pradyot
    I am trying to figure out what the best way to debug a segault with swig/python/c++. A core file is being generated. I have a basic MessageFactory(defined in c++ that provides a simple interface to accept a few strings as input and return a string as output). This interface is then specified in a .i file. swig is used to generate Wrapper.cpp as well as a MessageFactory.py from the .i file. This along with supporting files is compiled into a dynamic lib. The point of failure , is when the MessageFactory is instantiated within python code. Any suggestions on how I can go about debugging this? I've tried running the script within pdb, what I know from that is import on the generated MessageFactory.py is whats causing the seg-fault.

    Read the article

  • Google App Engine Python: get image upload size server-side

    - by goggin13
    I am building a Google App Engine App that lets users upload images; I have everything working fine, but I am struggling to find a way to ensure that the user does not upload an image too large (because I am resizing the images, so this crashes my python script). When a user uploads a large image, I get this error RequestTooLargeError: The request to API call images.Transform() was too large. I know that there is a size limitation on what GAE allows for it's image API, I am just trying to find a way to deal with this server side; something along the lines of if (image is too large): inform user else: proceed I haven't had any luck finding the right python code to do this; can anyone help me out?

    Read the article

  • Python: create a function to modify a list by reference not value

    - by Jonathan
    Hey all- I'm doing some performance-critical Python work and want to create a function that removes a few elements from a list if they meet certain criteria. I'd rather not create any copies of the list because it's filled with a lot of really large objects. Functionality I want to implement: def listCleanup(listOfElements): i = 0 for element in listOfElements: if(element.meetsCriteria()): del(listOfElements[i]) i += 1 return listOfElements myList = range(10000) myList = listCleanup(listOfElements) I'm not familiar with the low-level workings of Python. Is myList being passed by value or by reference? How can I make this faster? Is it possible to somehow extend the list class and implement listCleanup() within that? myList = range(10000) myList.listCleanup() Thanks- Jonathan

    Read the article

  • Port C's fread(&struct,....) to Python

    - by user287669
    Hey, I'm really struggling with this one. I'am trying to port a small piece of someone else's code to Python and this is what I have: typedef struct { uint8_t Y[LUMA_HEIGHT][LUMA_WIDTH]; uint8_t Cb[CHROMA_HEIGHT][CHROMA_WIDTH]; uint8_t Cr[CHROMA_HEIGHT][CHROMA_WIDTH]; } __attribute__((__packed__)) frame_t; frame_t frame; while (! feof(stdin)) { fread(&frame, 1, sizeof(frame), stdin); // DO SOME STUFF } Later I need to access the data like so: frame.Y[x][y] So I made a Class 'frame' in Python and inserted the corresponding variables(frame.Y, frame.Cb, frame.Cr). I have tried to sequentially map the data from Y[0][0] to Cr[MAX][MAX], even printed out the C struct in action but didn't manage to wrap my head around the method used to put the data in there. I've been struggling overnight with this and have to get back to the army tonight, so any immediate help is very welcome and appreciated. Thanks

    Read the article

  • MS Analysis Services OLAP API for Python

    - by Kaloyan Todorov
    I am looking for a way to connect to a MS Analysis Services OLAP cube, run MDX queries, and pull the results into Python. In other words, exactly what Excel does. Is there a solution in Python that would let me do that? Someone with a similar question going pointed to Django's ORM. As much as I like the framework, this is not what I am looking for. I am also not looking for a way to pull rows and aggregate them -- that's what Analysis Services is for in the first place. Ideas? Thanks.

    Read the article

  • Cleanest way to run/debug python programs in windows

    - by YGA
    Python for Windows by default comes with IDLE, which is the barest-bones IDE I've ever encountered. For editing files, I'll stick to emacs, thank you very much. However, I want to run programs in some other shell than the crappy windows command prompt, which can't be widened to more than 80 characters. IDLE lets me run programs in it if I open the file, then hit F5 (to go Run- Run Module). I would rather like to just "run" the command, rather than going through the rigmarole of closing the emacs file, loading the IDLE file, etc. A scan of google and the IDLE docs doesn't seem to give much help about using IDLE's shell but not it's IDE. Any advice from the stack overflow guys? Ideally I'd either like advice on running programs using IDLE's shell advice on other ways to run python programs in windows outside of IDLE or "cmd". Thanks, /YGA

    Read the article

  • trying to use code_swarm but Im having some python scripting problems

    - by theprojectabot
    I am having issues running this: link-mbp:codeswarm-0.1 benb$ python convert_logs/convert_logs.py -perforce-path Traceback (most recent call last): File “convert_logs/convert_logs.py”, line 408, in main() File “convert_logs/convert_logs.py”, line 350, in main files = run_marshal(’p4 -G describe -s “‘ + changelist['change'] + ‘”‘) KeyError: ‘change’ link-mbp:codeswarm-0.1 benb$ I am trying to use code_swarm from this link http://blog.perforce.com/blog/?p=780&cpage=1#comment-965 to visualize my codebase changes. if I run p4 changes everything shows correct but the code in this python script doesnt seem to process correctly... if I run p4 describe on a a changelist number it correctly reports ideas?

    Read the article

  • How to embed a Python interpreter in a PyQT widget

    - by Mathias
    I want to be able to bring up an interactive python terminal from my python application. Some, but not all, variables in my program needs to be exposed to the interpreter. Currently I use a sub-classed and modified QPlainTextEdit and route all "commands" there to eval or exec, and keep track of a separate namespace in a dict. However there got to be a more elegant and robust way! How? Here is an example doing just what I want, but it is with IPython and pyGTK... http://ipython.scipy.org/moin/Cookbook/EmbeddingInGTK

    Read the article

  • Python subprocess: callback when cmd exits

    - by Anon
    Hi, I'm currently launching a programme using subprocess.Popen(cmd, shell=TRUE) I'm fairly new to Python, but it 'feels' like there ought to be some api that lets me do something similar to: subprocess.Popen(cmd, shell=TRUE, postexec_fn=function_to_call_on_exit) I am doing this so that function_to_call_on_exit can do something based on knowing that the cmd has exited (for example keeping count of the number of external processes currently running) I assume that I could fairly trivially wrap subprocess in a class that combined threading with the Popen.wait() method, but as I've not done threading in Python yet and it seems like this might be common enough for an API to exist, I thought I'd try and find one first. Thanks in advance :)

    Read the article

  • python Illegal instruction on AIX5.2

    - by Charlie Epps
    hi,everyone: I run my python script functions like this: read from a text file, and store the data as dict. But when in the loop, an Illegal instruction occurs. why this happens? the psu-code is : d={} datafile=open('a.txt') # a big text file for line in datafile: line=line.rstrip('\n') for token in line.split(): print("Parsing line %d." % token[0]) d[(int(token[0]))]=token[1:] then the message is like this: Parsing line 1. Parsing line 2. ............ Parsing line 1065 Illegal instruction what's the problem? my platform is python 2.6.2 on AIX 5.2. please help me, thanks!

    Read the article

  • Parsing JSON file with Python -> google map api

    - by Hannes
    Hi all, I am trying to get started with JSON in Python, but it seems that I misunderstand something in the JSON concept. I followed the google api example, which works fine. But when I change the code to a lower level in the JSON response (as shown below, where I try to get access to the location), I get the following error message for code below: Traceback (most recent call last): File "geoCode.py", line 11, in test = json.dumps([s['location'] for s in jsonResponse['results']], indent=3) KeyError: 'location' How can I get access to lower information level in the JSON file in python? Do I have to go to a higher level and search the result string? That seems very weird to me? Here is the code I have tried to run: import urllib, json URL2 = "http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false" googleResponse = urllib.urlopen(URL2); jsonResponse = json.loads(googleResponse.read()) test = json.dumps([s['location'] for s in jsonResponse['results']], indent=3) print test Thank you for your responses.

    Read the article

  • Python Closures Example Code

    - by user336527
    I am learning Python using "Dive Into Python 3" book. I like it, but I don't understand the example used to introduce Closures in Section 6.5. I mean, I see how it works, and I think it's really cool. But I don't see any real benefit: it seems to me the same result could be achieved by simply reading in the rules file line by line in a loop, and doing search / replace for each line read. Could someone help me to: either understand why using closures in this example improves the code (e.g., easier to maintain, extend, reuse, or debug?) or suggest a source of some other real-life code examples where closures really shine? Thank you!

    Read the article

< Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >