Q_CreationDate stringlengths 23 23 | Title stringlengths 11 149 | Question stringlengths 25 6.53k | Answer stringlengths 15 5.1k | Score float64 -1 1.2 | Is_accepted bool 2
classes | N_answers int64 1 17 | Q_Id int64 0 6.76k |
|---|---|---|---|---|---|---|---|
2013-02-18 17:57:26.907 | how will Python DB-API read json format data into an existing database? | If we have a json format data file which stores all of our database data content, such as table name, row, and column, etc content, how can we use DB-API object to insert/update/delete data from json file into database, such as sqlite, mysql, etc. Or please share if you have better idea to handle it. People said it is... | There's no magic way, you'll have to write a Python program to load your JSON data in a database. SQLAlchemy is a good tool to make it easier. | 0.386912 | false | 1 | 2,394 |
2013-02-19 00:35:14.380 | How to disable Google App Engine python SDK import hook? | I am playing around with local deployment of GAE python SDK. The code that I am trying to run contains many external libraries which are not part of GAE import whitelist. I want to disable the import restrictions and let GAE app import any locally installed module.
After walking through the code, I figured out that th... | Easiest thing is to modify google/appengine/tools/dev_appserver_import_hook.py and add the module you want to the whitelist.
This will allow you to import whatever you want.
Now there's a good reason that the imports are restricted in the development server. The restricted imports match what's available on the product... | 0 | false | 1 | 2,395 |
2013-02-19 13:47:13.817 | event handling iron python | If there are lets say 4 buttons, all with the same Click event, how can I find out which button was pressed?
if the event looks like this def Button_Click(self, sender, e): I'm sure I can compare sender to my buttons somehow. But how? | Well, I've never used IronPython so I don't know how much help this will be, but what I usually do when trying to figure out these things in regular python is to print type(sender) , print sender and print dir(sender) to console(or output to a file if you don't have a console available).
This should help you figure out... | 1.2 | true | 1 | 2,396 |
2013-02-19 14:42:12.760 | ipdb requires Ctrl+D for processing command | I am debugging my Python scripts with ipdb. Somehow I have the problem, that after entering a command, for instance n, s, c, b etc. I have to press Ctrl+D two times in order for ipdb to process the command and proceed.
Any idea what causes this and how I can turn it off? | This is the thing: Ctrl+D does not kill programs, it cuts waiting halfway through. When you press Ctrl+D, you interrupt the process' read() call that's waiting for input.
Ctrl+D
Most programs will abort when they read 0 bytes as input. If you Ctrl+D before entering anything, you'll be sending 0 bytes down the input pip... | 0.201295 | false | 1 | 2,397 |
2013-02-20 05:03:30.643 | Python abstract classes - how to discourage instantiation? | I come from a C# background where the language has some built in "protect the developer" features. I understand that Python takes the "we're all adults here" approach and puts responsibility on the developer to code thoughtfully and carefully.
That said, Python suggests conventions like a leading underscore for privat... | I just name my abstract classes with the prefix 'Abstract'. E.g. AbstractDevice, AbstractPacket, etc.
It's about as easy and to the point as it comes. If others choose to go ahead and instantiate and/or use a class that starts with the word 'Abstract', then they either know what they're doing or there was no hope for t... | 0.201295 | false | 3 | 2,398 |
2013-02-20 05:03:30.643 | Python abstract classes - how to discourage instantiation? | I come from a C# background where the language has some built in "protect the developer" features. I understand that Python takes the "we're all adults here" approach and puts responsibility on the developer to code thoughtfully and carefully.
That said, Python suggests conventions like a leading underscore for privat... | To enforce things is possible, but rather unpythonic. When I came to Python after many years of C++ programming I also tried to do the same, I suppose, most of people try doing so if they have an experience in more classical languages. Metaclasses would do the job, but anyway Python checks very few things at compilatio... | 0 | false | 3 | 2,398 |
2013-02-20 05:03:30.643 | Python abstract classes - how to discourage instantiation? | I come from a C# background where the language has some built in "protect the developer" features. I understand that Python takes the "we're all adults here" approach and puts responsibility on the developer to code thoughtfully and carefully.
That said, Python suggests conventions like a leading underscore for privat... | Create your 'abstract' class and raise NotImplementedError() in the abstract methods.
It won't stop people using the class and, in true duck-typing fashion, it will let you know if you neglect to implement the abstract method. | 0.201295 | false | 3 | 2,398 |
2013-02-21 05:08:06.700 | Wrapping in Notepad++ | I know the Python coding standard has a limit of 78 characters per line. I am working in Notepad++ and
how do I set it so it wraps after 78 characters? | To apply the WordWrap, just goo to view in the Menu bar and check the WordWrap option. | 0 | false | 1 | 2,399 |
2013-02-21 21:37:34.480 | opening a usb device in python -- what is the path in winXP? | I'm trying to access a usb device through python but I'm unsure how to find the path to it.
The example I'm going from is:
pipe = open('/dev/input/js0','r')
In which case this is either a mac or linux path. I don't know how to find the path for windows.
Could someone steer me in the proper direction? I've sifted throug... | "Everything is a file" is one of the core ideas of Unix. Windows does not share this philosophy and, as far as I know, doesn't provide an equivalent interface. You're going to have to find a different way.
The first way would to be to continue handling everything at a low level & have your code use a different code p... | 0 | false | 2 | 2,400 |
2013-02-21 21:37:34.480 | opening a usb device in python -- what is the path in winXP? | I'm trying to access a usb device through python but I'm unsure how to find the path to it.
The example I'm going from is:
pipe = open('/dev/input/js0','r')
In which case this is either a mac or linux path. I don't know how to find the path for windows.
Could someone steer me in the proper direction? I've sifted throug... | The default USB path on windows is D:\. So, if we have a text document named mydoc.txt, which is in the folder myData the appropriate path is D:\myData\mydoc.txt | 0 | false | 2 | 2,400 |
2013-02-22 13:01:40.437 | how to get username and domain of windows logged in client using python code? | when user logs in to his desktop windows os authenticates him against Active Directory Server.
so Whenever he accesses a web page he should not be thrown a login page for entering his userid or password.Instead, his userid and domain need to be captured from his desktop and passed to the web server.(let him enter pas... | What you want to do is called Single sign on (SSO) and it's much easier to implement on actual web server than Django.
So, you should check how to do SSO on Apache/Nginx/whateverYouAreUsing, then the web server will forward the authenticated username to your django app. | 0 | false | 1 | 2,401 |
2013-02-22 18:59:40.693 | What module to use for calling user-defined functions in parallel | I've written an irc bot that runs some commands when told so, the commands are predefined python functions that will be called on the server where the bot is running.
I have to call those functions without knowing exactly what they'll do
(more I/O or something computationally expensive, nothing harmful since I review t... | There is no definitive answer to your question: it really depends what the functions do, how often they are called and what level of parallelism you need.
The threading and multiprocessing modules work in radically different ways.
threading implements native threads within the Python interpreter: fairly inexpensive to ... | 0.386912 | false | 1 | 2,402 |
2013-02-22 19:33:00.947 | Converting postgresql timestamp to JavaScript timestamp in Python | I have a postgre database with a timestamp column and I have a REST service in Python that executes a query in the database and returns data to a JavaScript front-end to plot a graph using flot.
Now the problem I have is that flot can automatically handle the date using JavaScript's TIMESTAMP, but I don't know how to c... | You can't send a Python or Javascript "datetime" object over JSON. JSON only accepts more basic data types like Strings, Ints, and Floats.
The way I usually do it is send it as text, using Python's datetime.isoformat() then parse it on the Javascript side. | 0.545705 | false | 1 | 2,403 |
2013-02-23 03:43:20.860 | Integrating tests written in Python and tests in C# in one solid solution | What I'm trying to do is to combine two approaches, two frameworks into one solid scope, process ...
I have a bunch of tests in python with self-written TestRunner over proboscis library which gave me a good way to write my own Test Result implementation (in which I'm using jinja). This framework is now a solid thing.... | I don't know if you can fit them in one runner or process. I'm also not that familiar with Python. It seems to me that the Python written tests are more on a high level though. Acceptance tests or integration tests or whatever you want to call them. And the NUnit ones are unit test level. Therefore I would suggest that... | 0.386912 | false | 1 | 2,404 |
2013-02-24 07:33:52.130 | Skype4Py Check If Group Chat | is there a way to check if a chat is a group chat? Or at least to find out how many users there are in a group.
Like by checking for the user number, if it is 2, then it is obviously 1-1 (Single), but if it as anything else, it would be a group chat. | The Type property of the chat object will be either chatTypeDialog or chatTypeMultiChat with the latter being a group chat. You can safely ignore the other legacy enumeration values. | 0 | false | 1 | 2,405 |
2013-02-24 18:27:57.470 | Multiple permissions in view_config decorator? | I am configuring access control for a web application based on the Pyramid framework. I am setting up permissions for my view callables using the @view_config decorator. I have two permissions, namely 'read' and 'write'. Now, I want certain views to require both permissions. I was unable to figure out how to do this wi... | Make a readwrite permission. Each view gets one and only one permission but each principal can be mapped to many permissions. | 1.2 | true | 1 | 2,406 |
2013-02-24 20:27:08.360 | PyEphem: can I calculate Sun's altitude from azimuth | I am using PyEphem to calculate the location of the Sun in the sky at various times.
I have an Observer point (happens to be at Stonehenge) and can use PyEphem to calculate sunrise, sunset, and the altitude angle and azimuth (degrees from N) for the Sun at any hour of the day. Brilliant, no problem.
However, what I rea... | Without knowing the details of the internal calculations that PyEphem is doing I don't know how easy or difficult it would be to invert those calculations to give the result you want.
With regards to the "sneaking up on it" option however, you could pick two starting times (eg sunrise and noon) where the azimuth is kn... | 0 | false | 1 | 2,407 |
2013-02-24 22:15:43.187 | How can I determine sensible thread number in python? | I am writing a simple script which should do big amount of checks. Every check is independent so I decided to put it into multiple threads. However I don't know how fast will be machine on which the script will be set. I've already found quite nice util to check basic parameters of the target machine but I am wondering... | Threads for the purpose of speed in python is not a terribly good idea, particularly for cpu bound operations. The GIL sees off any potential performance improvements from multiple CPU's (the # of which is the theoretical limit of your speed increase from threading - though in practice YMMV).
For truly independent "che... | 0.265586 | false | 1 | 2,408 |
2013-02-24 22:52:23.303 | Python grabbing pages source with PHP in it | I know how to grab a sources HTML but not PHP is it possible with the built in functions? | PHP scripts are run server-side and produce a HTML document (among other things). You will never see the PHP source of a HTML document when requesting a website, hence there is no way for Python to grab it either. This isn't even Python-related. | 0 | false | 1 | 2,409 |
2013-02-25 03:16:12.530 | how to do with a request which needs to take a long time to run? | I'm using Django to develop a classifier service, and user can build a model using api like http://localhost/api/buildmodel, however, because building a model takes a long time, maybe 2 hours, and I'm using web page to show the result of building a model. How to design my Django program to return immediately and do som... | One way to do it is to create a row in a persistent database (or a redis key/value pair) for the task which says if it is running or finished. Have the code set the value to be running when the task starts and done when the task completes. Then have an AJAX call do a GET lookup on a URL that sends the status for the ta... | 0 | false | 1 | 2,410 |
2013-02-25 16:51:42.383 | Passing file path argument to a CherryPy | In CherryPy how do you pass an argument like file path (i.e. /abc/def/ghi) through a URL? I want to do something like http://...../filepath="abc/def/ghi". Thanks. | Well, .../a/b/x=y is the wrong way to send a value regardless of whether it is a file name or not. The correct way would be .../a/b?x=y
or .../a/b/?x=y which would make x a standard query parameter and cherrypy would treat it as such. Thereafter whether there were slashes in the value of x or not would be moot. They ... | 0 | false | 1 | 2,411 |
2013-02-25 20:44:11.000 | PYGAME - Edit colours of an image (makes white red at 255,0,0) without numerical python? | I'm making a simple game, whereby I want my characters quite customizable. I want my characters to be able to be fully edited in colours, for example, if a player wants their character to have cyan skin, they just put into the sliders, or what I choose to use, "0,255,255", or purple "255,0,255", or something random "25... | I assume by image you mean pygame.Surface. You have several options:
pygame.Surface.set_at(...)
Use a palettized surface. Then change the palette. Based on your use case, this is actually probably what I'd suggest.
Use the pygame.PixelArray PyGame module. I don't think it requires NumPy.
Just use NumPy. It's real... | 0 | false | 1 | 2,412 |
2013-02-26 16:06:40.710 | Can you read variable data of an already running Python Script from its DMP file in Windows? | I have a Python program that had some kind of error that prevents it from saving my data. The program is still running, but I cannot save anything. Unfortunately, I really need to save this data and there seems to be no other way to access it.
Does the DMP file created for the process through the task manager contain t... | Does it contain some or all of the current execution state of your program? Yes. Is it in a form that you could easily extract the information in the user-level format you are probably looking for from it? Probably not. It will dump the state of the entire Python interpreter, including the data as represented in me... | 1.2 | true | 1 | 2,413 |
2013-02-26 23:55:05.617 | How to setup a web app which can handle local data without uploading the data? Use python | I have a small python program to help my colleagues to analyse some tsv data. The data is not big, usually below 20MB. I developed the GUI with PyQT. I want to change this desktop program to a web app so my colleagues don't have to upgrade the program every time I change it or fix a bug. They can just go to a website a... | If I get your point correctly, you want
Web connection, so your python program updated on server, client get it before using it.
Data store on local to avoid upload big file.
You can write a python program to check a server location to get your latest program if needed. You need a url / server file for program versio... | 0 | false | 3 | 2,414 |
2013-02-26 23:55:05.617 | How to setup a web app which can handle local data without uploading the data? Use python | I have a small python program to help my colleagues to analyse some tsv data. The data is not big, usually below 20MB. I developed the GUI with PyQT. I want to change this desktop program to a web app so my colleagues don't have to upgrade the program every time I change it or fix a bug. They can just go to a website a... | No, you cannot run Python code in a web browser.[1] You'd have to port the core of your application to JavaScript to do it all locally.
Just do the upload. 20MB isn't all that much data, and if it's stored on the server then they can all look at each others' results, too.
[1] There are some tools that try to transpi... | 0.135221 | false | 3 | 2,414 |
2013-02-26 23:55:05.617 | How to setup a web app which can handle local data without uploading the data? Use python | I have a small python program to help my colleagues to analyse some tsv data. The data is not big, usually below 20MB. I developed the GUI with PyQT. I want to change this desktop program to a web app so my colleagues don't have to upgrade the program every time I change it or fix a bug. They can just go to a website a... | The whole point of a web application is that the GUI is written in HTML, CSS, and JavaScript, not Python. However, it talks to a web service, which can be written in Python.
For a well-written desktop app, the transition should be pretty easy. If you've already got a clean separation between the GUI part and the engine... | 1.2 | true | 3 | 2,414 |
2013-02-27 04:13:37.733 | Is it a bad idea to use a PNG image's filename to store the info on how to process it? | I am making a little game app that allows users to load up textures manually. One such example would be a standard deck of 52 cards.
Would it be bad to store the processing info as:
Card_79x123_53_53.png
Upon getting the filename from a file dialog, I would split the underscores to get the following info:
ObjectType :... | Is there a reason why this is a bad idea or should I keep toying with it?
This is essentially like encoding file type by file extension. The only bad thing about encoding file metadata in the filename is it's quite limited in space. You can encode much richer metadata if you used proper PNG metadata field or in a sepa... | 0 | false | 2 | 2,415 |
2013-02-27 04:13:37.733 | Is it a bad idea to use a PNG image's filename to store the info on how to process it? | I am making a little game app that allows users to load up textures manually. One such example would be a standard deck of 52 cards.
Would it be bad to store the processing info as:
Card_79x123_53_53.png
Upon getting the filename from a file dialog, I would split the underscores to get the following info:
ObjectType :... | Probably it would be better to ask user about how to process image explicitly either by adding extra controls into file dialog, or by showing another dialog after file dialog is submitted. In this case information taken from file name could be used as hints to preliminary fill these extra controls with values, but use... | 1.2 | true | 2 | 2,415 |
2013-02-27 05:56:30.407 | python paramiko module socket.error, errno 10060 | It seems the socket connection through paramiko (v1.10.0) is not stable.
I have two computers. The python code is on the PC one. The connection sometime is successful and sometime is not (Same code). When the PC paramiko code fails (socket.error, 10060), I use my Mac via terminal ssh login the server and everything is... | Try switching off Windows firewall. It's a network error, it should not be because of SSH key problems.
Error Code 10060: Connection timeout
Background: The gateway could not receive a timely response from the website you are trying to access. This might indicate that the network is congested, or that the website is ex... | 0.386912 | false | 1 | 2,416 |
2013-02-27 20:13:45.577 | How to check if I'm running in a shell (have a terminal) in Python? | I have a Python script that normally runs out of cron. Sometimes, I want to run it myself in a (Unix) shell, and if so, have it write its output to the terminal instead of writing to a log file.
What is the pythonic way of determining if a script is running out of cron or in an interactive shell (I mean bash, ksh, etc... | If you really need to check this, Pavel Anossov's answer is the way to do it, and it's pretty much the same as your initial guess.
But do you really need to check this? Why not just write a Python script that writes to stdout and/or stderr, and your cron job can just redirect to log files?
Or, even better, use the logg... | 0.386912 | false | 1 | 2,417 |
2013-02-28 11:20:41.370 | Compass not working with pyScss 1.1.5 | I am with Python 2.7, pyScss 1.15 and Compass 0.12.2, but Compass dosn't work, could someone give an advise how to make it work? | You don't need compass with pyScss. Just run "python pyScss -mscss" to watch your workingdir for changes and compile the .scss (or .sass) to .css. | 0 | false | 1 | 2,418 |
2013-03-02 06:07:15.727 | How to get image position in Pygame | I am coding for a mouse drag and drop effect on images. Meanwhile, I want to take record of the upper-left point of image each time I dragged and dropped it, are there any ways to get it? | If you derive your classes from pygame.sprite.Sprite , you can get the position by guy.rect. Depending on if you want center, or toplef, or the full rect:
guy.rect.topleft or guy.rect.center or guy.rect | 0.201295 | false | 2 | 2,419 |
2013-03-02 06:07:15.727 | How to get image position in Pygame | I am coding for a mouse drag and drop effect on images. Meanwhile, I want to take record of the upper-left point of image each time I dragged and dropped it, are there any ways to get it? | What methods are you using to draw the images? It's hard to answer this question without that.
If you aren't already doing this, you could use a class to hold data about your image, such as position and geometry. | 0.201295 | false | 2 | 2,419 |
2013-03-02 09:21:18.977 | Heroku Python App - CSS Not Loading On IPhone Only | First question posted to Stack Overflow but have spent many hours reading answers here :).
I'm creating a Heroku Python app and am using responsive design media queries in my css. I deploy my app to Heroku and visit myherokuapp.herokuapp.com. Website looks fine on laptop browser...responsive design elements working as... | Bug found. It was a very, very obscure rendering issue with the text-indent css attribute that only seemed to affect the iPhone 5.
Additionally, if you ever need to debug Google Chrome for iPhone, clearing the cache won't do anything if you don't delete the app from the multitasking menu too (the bar that comes up whe... | 0 | false | 1 | 2,420 |
2013-03-02 23:24:13.410 | How does boost::python work?Any ideas about the realisation details? | I'm a newbie to boost and one of its libraries which I can't understand it is Boost.Python. Can anyone explain me in details how does this interoperability achieved?In the documentation there only a few words about metaprogramming.
P.S. I tried to look code but because of my lack of C++ knowledge I didn't understand pr... | There are two ways to interoperate:
1) from a "Python process", call functions written in C++.
Python already has a system to load dlls, they're called "extension modules". Boost.Python can compile your source to produce one. Basically you write a little wrapper to declare a function callable from Python, and the "meta... | 1.2 | true | 1 | 2,421 |
2013-03-03 15:42:46.797 | When using python and selenium how to find the presence of an element based on id and value | I am trying to find the presence of an element by finding the length of the jquery.
How can we capture the length of a webelement in a variable, so that I can check the value of the variable to make decision.
Or is there any other way to accomplish the same result. I am using python, selenium webdriver and JQuery. Than... | We can Use this Funda
If driver.findElements(By.id(id)).size() > 0 Then
Element Present;
Else
Element Not Present
Same Applies for Value.
Please Let me know is my Funda OK or NOT. | 0 | false | 1 | 2,422 |
2013-03-04 18:00:31.140 | Why does setuptools need to write bytecode? | If you try to run virtualenv with the environmental variable PYTHONDONTWRITEBYTECODE=true set, it gives this error:
The PYTHONDONTWRITEBYTECODE environment variable is not compatible with setuptools. Either use --distribute or unset PYTHONDONTWRITEBYTECODE.
Why does setuptools require the ability to write bytecode?
I d... | Use a recent version of virtualenv and you will not see this error. | 0.386912 | false | 1 | 2,423 |
2013-03-04 20:25:33.807 | How to start app without navigating to its directory | I've looked around for an answer to this, but i don't know how to phrase it in a way that google will understand.
I'm trying to learn Python, and i've installed it on my machine. However, when i just type "python" in cmd.exe, the python app is not found/launched.
I have to manually go to the directory in which python.e... | http://stackoverflow.com/questions/7054424/python-not-recognised-as-a-command
Add python to your environment path. You should then be able to use it anywhere. | 1.2 | true | 1 | 2,424 |
2013-03-05 10:13:15.943 | Get instance of an running Python program | Suppose a python program is running. Say the object of an Class in that program can give you some stats. So if i have to develop a web UI to display the stats, how do i get the instance of that class which is running[as an separate desktop app] and display the stats in web, which I would be using web2py or django. | You can't (easily) "get an instance of a running program" from outside. You can certainly instrument your program so that it communicates its statistics somehow, eg via a socket, or as an even lower-tech solution you could get it to store the relevant data periodically in a file on disk or in a database, which your web... | 0.386912 | false | 1 | 2,425 |
2013-03-05 10:29:18.290 | How do I update/upgrade pip itself from inside my virtual environment? | I'm able to update pip-managed packages, but how do I update pip itself? According to pip --version, I currently have pip 1.1 installed in my virtualenv and I want to update to the latest version.
What's the command for that? Do I need to use distribute or is there a native pip or virtualenv command? I've already trie... | While updating pip in virtual env use full path in python command
Envirnments folder struture
myenv\scripts\python
h:\folderName\myenv\scripts\python -m pip install --upgrade pip | 0 | false | 3 | 2,426 |
2013-03-05 10:29:18.290 | How do I update/upgrade pip itself from inside my virtual environment? | I'm able to update pip-managed packages, but how do I update pip itself? According to pip --version, I currently have pip 1.1 installed in my virtualenv and I want to update to the latest version.
What's the command for that? Do I need to use distribute or is there a native pip or virtualenv command? I've already trie... | for windows,
go to command prompt
and use this command
python -m pip install -–upgrade pip
Dont forget to restart the editor,to avoid any error
you can check the version of the pip by
pip --version
if you want to install any particular version of pip , for example version 18.1 then use this command,
python -m pip inst... | 0.141024 | false | 3 | 2,426 |
2013-03-05 10:29:18.290 | How do I update/upgrade pip itself from inside my virtual environment? | I'm able to update pip-managed packages, but how do I update pip itself? According to pip --version, I currently have pip 1.1 installed in my virtualenv and I want to update to the latest version.
What's the command for that? Do I need to use distribute or is there a native pip or virtualenv command? I've already trie... | I had installed Python in C:\Python\Python36 so I went to the Windows command prompt and typed "cd C:\Python\Python36 to get to the right directory. Then entered the "python -m install --upgrade pip" all good! | 0 | false | 3 | 2,426 |
2013-03-06 02:07:38.567 | Serve Static Pages from S3 using Django | I'm planning to build a Django app to generate and later server static pages (probably stored on S3). When users visit a url like mysite.com/static-pages/12345 the static file in my S3 bucket named 12345.html should be served. That static file might be the static html page of a blog page my site has generated for the u... | You can just create index.html inside /static-pages/12345/ folder and it will be served. | 0 | false | 1 | 2,427 |
2013-03-06 23:45:29.180 | Controlling the distribution of tests with py.test xdist | I have several thousand tests that I want to run in parallel. The tests are all compiled binaries that give a return code of 0 or non-zero (on failure). Some unknown subsets of them try to use the same resources (files, ports, etc). Each test assumes that it is running independently and just reports a failure if a reso... | I am not sure if this would help. But if you know ahead of time how you want to divide up your tests, instead of having pytest distribute your tests, you could use your continuous integration server to call a different run of pytest for each different machine. Using -k or -m to select a subset of tests, or simply speci... | 0 | false | 1 | 2,428 |
2013-03-07 04:39:44.887 | how to call python script in kettle | I have a problem in kettle connecting python. In kettle, I only find the js script module.
Does kettle support python directly? I mean, can I call a python script in kettle without using js or others?
By the way, I want to move data from Oracle to Mongo regularly. I choose to use python to implement the transformation.... | It doesnt support it directly from what I've seen.
However there is a mongodb input step. And a lot of work has been done on it recently ( and still ongoing.
So given there is a mongodb input step, if you're using an ETL tool already then why would you want to make it execute a python script to do the job?? | 1.2 | true | 1 | 2,429 |
2013-03-07 21:41:13.973 | Django Static Setup | I've looked through countless answers and questions trying to find a single definitive guide or way to do this, but it seems that everyone has a different way. Can someone please just explain to me how to serve static files in templates?
Assuming I've just created a brand new project with Django 1.4, what all do I need... | Put your static files into <app>/static or add an absolute path to STATICFILES_DIRS
Configure your web server (you should not serve static files with Django) to serve files in STATIC_ROOT
Point STATIC_URL to the base URL the web server serves
Run ./manage.py collectstatic
Be sure to use RequestContext in your render ca... | 1.2 | true | 2 | 2,430 |
2013-03-07 21:41:13.973 | Django Static Setup | I've looked through countless answers and questions trying to find a single definitive guide or way to do this, but it seems that everyone has a different way. Can someone please just explain to me how to serve static files in templates?
Assuming I've just created a brand new project with Django 1.4, what all do I need... | The created project should have a static folder. Put all resources (images, ...) in there.
Then, in your HTML template, you can reference STATIC_ROOT and add the resource path (relative to the static folder) | 0 | false | 2 | 2,430 |
2013-03-07 21:42:28.883 | creating arabic corpus | I'm doing the sentiment analysis for the Arabic language , I want to creat my own corpus , to do that , I collect 300 status from facebook and I classify them into positive and negative , now I want to do the tokenization of these status , in order to obain a list of words , and hen generate unigrams and bigrams, trigr... | Well, I think that rapidminer is very interesting and can handle this task. It contains several operators dealing with text mining. Also, it allows the creation of new operators with high fluency. | 0 | false | 1 | 2,431 |
2013-03-08 15:21:14.563 | Wait until a Jenkins build is complete | I am using Python 2.7 and Jenkins.
I am writing some code in Python that will perform a checkin and wait/poll for Jenkins job to be complete. I would like some thoughts on around how I achieve it.
Python function to create a check-in in Perforce-> This can be easily done as P4 has CLI
Python code to detect when a buil... | You can query the last build timestamp to determine if the build finished. Compare it to what it was just before you triggered the build, and see when it changes. To get the timestamp, add /lastBuild/buildTimestamp to your job URL
As a matter of fact, in your Jenkins, add /lastBuild/api/ to any Job, and you will see a ... | 1.2 | true | 1 | 2,432 |
2013-03-08 23:01:11.130 | In homebrew how do I change the python3 symlink to only "python" | I want to install python using homebrew and I noticed there are 2 different formulas for it, one for python 2.x and another for 3.x. The first symlinks "python" and the other uses "python3". so I ran brew install python3.
I really only care about using python 3 so I would like the default command to be "python" instea... | As mentioned this is not the best idea. However, the simplest thing to do when necessary is run python3 in terminal. If you need to run something for python3 then run python3 | 0.081452 | false | 2 | 2,433 |
2013-03-08 23:01:11.130 | In homebrew how do I change the python3 symlink to only "python" | I want to install python using homebrew and I noticed there are 2 different formulas for it, one for python 2.x and another for 3.x. The first symlinks "python" and the other uses "python3". so I ran brew install python3.
I really only care about using python 3 so I would like the default command to be "python" instea... | You definitely do not want to do this! You may only care about Python 3, but many people write code that expects python to symlink to Python 2. Changing this can seriously mess your system up. | 0.573727 | false | 2 | 2,433 |
2013-03-08 23:15:02.527 | How to get the list of error numbers (Errno) for an Exception type in python? | For a specific Exception type (let's say for IOError), how can i extract the complete list of Errnos and descriptions like this:
Errno 2: No such file or directory
Errno 122: Disk quota exceeded
... | look for errno.h on your system. | 0.3154 | false | 2 | 2,434 |
2013-03-08 23:15:02.527 | How to get the list of error numbers (Errno) for an Exception type in python? | For a specific Exception type (let's say for IOError), how can i extract the complete list of Errnos and descriptions like this:
Errno 2: No such file or directory
Errno 122: Disk quota exceeded
... | I fear those come straight from the standard C library, so you'll have to look it up in your system documentation. (GLibC, Microsoft, UNIX…) | 0.454054 | false | 2 | 2,434 |
2013-03-11 00:01:31.953 | How can I efficiently get all divisors of X within a range if I have X's prime factorization? | So I have algorithms (easily searchable on the net) for prime factorization and divisor acquisition but I don't know how to scale it to finding those divisors within a range. For example all divisors of 100 between 23 and 49 (arbitrary). But also something efficient so I can scale this to big numbers in larger ranges. ... | As Malvolio was (indirectly) going about, I personal wouldn't find a use for prime factorization if you want to find factors in a range, I would start at int t = (int)(sqrt(n)) and then decremnt until1. t is a factor2. Complete util t or t/n range has been REACHED(a flag) and then (both) has left the range
Or if your r... | 0 | false | 1 | 2,435 |
2013-03-11 18:28:31.390 | Multi developer environment python and sqlalchemy | I'm currently exploring using python to develop my server-side implementation. I've decided to use SQLAlchemy for database stuff.
What I'm not currently to sure about is how it should be set up so that more than one developer can work on the project. For the code it is not a problem but how do I handle the database mod... | Make sure you have a python programs or programs to fill databases with test data from scratch. It allows each developer to work from different starting points, but also test with the same environment. | 0 | false | 1 | 2,436 |
2013-03-11 19:27:05.157 | how to use the tun/tap python module (pytun) to create a p2p tunnel? | I need to make a simple p2p vpn app, after a lot of searches I found a tun/tap module for python called PYTUN that is used to make a tunnel. How can I use this module to create a tunnel between 2 remote peers?
All the attached doc only show how to make the tunnel interface on your local computer and config it, but it d... | pytun is not sufficient for this. It serves to connect your Python application to a system network interface. In effect, you become responsible for implementing that system network interface.
If you want traffic that is routed over that network interface to traverse an actual network, then it is the job of your Pytho... | 0 | false | 1 | 2,437 |
2013-03-12 03:59:07.337 | python 3.3 on sublime text 2 windows 7 | I am running windows 7 32 bit and i am using sublime text 2 I want to know how can I change the default python in ST2 to the python 3.3 I down loaded. Any help would be great thanks. | You need to change the Sublime build system for Python. Copy the Python.sublime-build file from the Packages/Python folder to the Packages/User folder. In the file in the User folder, change the cmd option from python to c:/python33/python (where your Python 3.3 executable is located). | 0 | false | 1 | 2,438 |
2013-03-12 17:11:35.633 | Default working directory for Python IDLE? | Is there a configuration file where I can set its default working directory? It currently defaults to my home directory, but I want to set it to another directory when it starts. I know I can do "import os" followed by "os.chdir("")" but that's kind of troublesome. It'd be great if there is a conf file that I can edit ... | It can change depending on where you installed Python. Open up IDLE, import os, then call os.getcwd() and that should tell you exactly where your IDLE is working on. | 0 | false | 3 | 2,439 |
2013-03-12 17:11:35.633 | Default working directory for Python IDLE? | Is there a configuration file where I can set its default working directory? It currently defaults to my home directory, but I want to set it to another directory when it starts. I know I can do "import os" followed by "os.chdir("")" but that's kind of troublesome. It'd be great if there is a conf file that I can edit ... | Here's a way to reset IDLE's default working directory for MacOS if you launch Idle as an application by double-clicking it. You need a different solution if you launch Idle from a command line in Terminal. This solution is a permanent fix. You don't have to rechange the directory everytime you launch IDLE. I wish ... | 0 | false | 3 | 2,439 |
2013-03-12 17:11:35.633 | Default working directory for Python IDLE? | Is there a configuration file where I can set its default working directory? It currently defaults to my home directory, but I want to set it to another directory when it starts. I know I can do "import os" followed by "os.chdir("")" but that's kind of troublesome. It'd be great if there is a conf file that I can edit ... | This ought to be the number one answer. I have been playing around this for an hour or more and nothing worked. Paul explains this perfectly. It's just like the PATH statement in Windows. I successfully imported a module by appending my personal "PythonModules" path/dir on my Mac (starting at "/users/etc") using a ... | -0.04532 | false | 3 | 2,439 |
2013-03-12 19:07:09.843 | python - saving numpy array to a file (smallest size possible) | Right now I have a python program building a fairly large 2D numpy array and saving it as a tab delimited text file using numpy.savetxt. The numpy array contains only floats. I then read the file in one row at a time in a separate C++ program.
What I would like to do is find a way to accomplish this same task, changi... | numpy.ndarray.tofile and numpy.fromfile are useful for direct binary output/input from python. std::ostream::write std::istream::read are useful for binary output/input in c++.
You should be careful about endianess if the data are transferred from one machine to another. | 0.081452 | false | 3 | 2,440 |
2013-03-12 19:07:09.843 | python - saving numpy array to a file (smallest size possible) | Right now I have a python program building a fairly large 2D numpy array and saving it as a tab delimited text file using numpy.savetxt. The numpy array contains only floats. I then read the file in one row at a time in a separate C++ program.
What I would like to do is find a way to accomplish this same task, changi... | If you don't mind installing additional packages (for both python and c++), you can use [BSON][1] (Binary JSON). | 0 | false | 3 | 2,440 |
2013-03-12 19:07:09.843 | python - saving numpy array to a file (smallest size possible) | Right now I have a python program building a fairly large 2D numpy array and saving it as a tab delimited text file using numpy.savetxt. The numpy array contains only floats. I then read the file in one row at a time in a separate C++ program.
What I would like to do is find a way to accomplish this same task, changi... | Use the an hdf5 file, they are really simple to use through h5py and you can use set compression a flag. Note that hdf5 has also a c++ interface. | 0.081452 | false | 3 | 2,440 |
2013-03-12 21:20:10.110 | how to add different base templates for different languages of same page in django cms | How can i add different base templates for different languages of same page in django cms?
I am trying to set a page and show it in different languages. And for all the languages, i need to use a different base template.
I am completely new django cms. Please help. | You need to create different page trees per language.
Every page has only one template. Use {% trans %} and {% blocktrans %} for translating string in it. Or {% if request.LANGUAGE == "en" %}.
If the templates really differ that much: don't add other languages to pages... but create different page trees with only one l... | 0.995055 | false | 1 | 2,441 |
2013-03-13 09:15:18.697 | How should Amazon SQS be used? Import / Process Scenario | I want to co-ordinate telling Server B to start a process from Server A, and then when its complete, run an import script on Server A. I'm having a hard time working out how I should be using SQS correctly in this scenario.
Server A: Main Dedicated Server
Server B: Cloud Process Server
Server A sends message to SQS vi... | Well... SQS doesn't not support message routing, in order to assign message to server A or B that why one of the available solutions: create SNS topics "server a" and "server b". These topics should put messages to SQS, which your application will pull. Also it possible to implement web hook - the subscriber on SNS eve... | 0.135221 | false | 3 | 2,442 |
2013-03-13 09:15:18.697 | How should Amazon SQS be used? Import / Process Scenario | I want to co-ordinate telling Server B to start a process from Server A, and then when its complete, run an import script on Server A. I'm having a hard time working out how I should be using SQS correctly in this scenario.
Server A: Main Dedicated Server
Server B: Cloud Process Server
Server A sends message to SQS vi... | I'm almost sorry that Amazon offers SQS as a service. It is not a "simple queue", and probably not the best choice in your case. Specifically:
it has abysmal performance in low volume messaging (some messages will take 90 seconds to arrive)
message order is not preserved
it is fond of delivering messages more than o... | 0.386912 | false | 3 | 2,442 |
2013-03-13 09:15:18.697 | How should Amazon SQS be used? Import / Process Scenario | I want to co-ordinate telling Server B to start a process from Server A, and then when its complete, run an import script on Server A. I'm having a hard time working out how I should be using SQS correctly in this scenario.
Server A: Main Dedicated Server
Server B: Cloud Process Server
Server A sends message to SQS vi... | What you laid out will work in theory, but I am moved away from putting messages directly into queues, and instead put those messages in to SNS topics, and then subscribe the queues to the topics to get them there - gives you more flexibility to change things down the road without every touching the code or the servers... | 1.2 | true | 3 | 2,442 |
2013-03-13 09:20:40.410 | Restrict execution of Python files only to server (prevent access from browser) | I have two Python files that I want to prevent anyone from executing unless it's from the server itself. The files implement a function that increases an amount of money to a user. What I need is to make this file not public to the web, so that if someone tries to call this file, the file would refuse this request, unl... | .htaccess, chmod or you could use a key defined by yourself... You have several possibilies.
Edit: Anyway, if the file only contains a function. Nobody can use it from an external http request, unless you actually call it in this file: function(); | 0 | false | 1 | 2,443 |
2013-03-13 15:04:02.583 | Extract type string with Clang bindings | I am writing a python script(using python clang bindings) that parses C headers and extracts info about functions: name, return types, argument types.
I have no problem with extracting function name, but I can't find a way to convert a clang.cindex.Type to C type string. (e.g. clang.cindex.TypeKind.UINT to unsigned int... | For RECORD, the function get_declaration() points to the declaration of the type (a union, enum, struct, or typedef); getting the spelling of the node returns its name. (Obviously, take care between differentiating the TYPEDEF_DECL vs. the underlying declaration kind.)
For FUNCTIONPROTO, you have to use a combination o... | 1.2 | true | 1 | 2,444 |
2013-03-13 18:10:30.303 | Windows "open with" python py2exe application | I wonder how the Windows "Open file with..." feature works. Or rather, how would do if I write a program in python, compile a executable with py2exe and then want to be able to open certain files in that program by right-clicking and choose it in "Open with".
Is the file simply passed as an argument, like "CMD>C:/myapp... | Yep, the path to the file gets passed in as an argument and can be accessed via sys.argv[1]. | 0.201295 | false | 1 | 2,445 |
2013-03-13 21:40:32.373 | Performance differences between python from package and python compiled from source | I would like to know if there are any documented performance differences between a Python interpreter that I can install from an rpm (or using yum) and a Python interpreter compiled from sources (with a priori well set flags for compilations).
I am using a Redhat 6.3 machine as Django/Apache/Mod_WSGI production server... | If you compile with the exact same flags that were used to compile the RPM version, you will get a binary that's exactly as fast. And you can get those flags by looking at the RPM's spec file.
However, you can sometimes do better than the pre-built version. For example, you can let the compiler optimize for your specif... | 1.2 | true | 1 | 2,446 |
2013-03-14 11:41:03.660 | cannot import name LOOKUP_SEP | I'm using django and I'm trying to set up django-roa but when i'm trying to start my webserver I have this error cannot import name LOOKUP_SEP
If I remove django_roa from my INSTALLEDS_APP it's okay but I want django-roa working and I don't know how resolve this problem.
And I don't know what kind of detail I can tell... | I downgraded from 1.5.2 to 1.4.0 and my app started working again. Via pip:
pip install django==1.4
Hope that helps. | 0 | false | 2 | 2,447 |
2013-03-14 11:41:03.660 | cannot import name LOOKUP_SEP | I'm using django and I'm trying to set up django-roa but when i'm trying to start my webserver I have this error cannot import name LOOKUP_SEP
If I remove django_roa from my INSTALLEDS_APP it's okay but I want django-roa working and I don't know how resolve this problem.
And I don't know what kind of detail I can tell... | django_roa is not yet compatible with django 1.5. I'm afraid it only works with django 1.3. | 1.2 | true | 2 | 2,447 |
2013-03-15 22:13:21.490 | python - simpledb - how to shard/chunk a big string into several <1kb values? | I've been reading up on SimpleDB and one downfall (for me) is the 1kb max per attribute limit. I do a lot of RSS feed processing and I was hoping to store feed data in SimpleDB (articles) and from what I've read the best way to do this is to shard the article across several attributes. The typical article is < 30kb of ... | I opted to go with storing large text documents in Amazon S3 (retrieval seems to be quick), I'll be implementing an EC2 instance for caching the documents with S3 as a failover. | 1.2 | true | 1 | 2,448 |
2013-03-17 01:39:58.693 | Complicated Excel Issue with Google API and Python | So I know how to download Excel files from Google Drive in .csv format. However, since .csv files do not support multiple sheets, I have developed a system in a for loop to add the '&grid=tab_number' to the file download url so that I can download each sheet as its own .csv file. The problem I have run into is finding ... | Ended up just downloading with xlrd and using that. Thanks for the link Rob. | 1.2 | true | 1 | 2,449 |
2013-03-18 04:31:42.940 | Is it possible to create Python-based Application in Xcode or equivalent? | So I have a lot of python scripts that I have written for my work but no one in my lab knows how to use Python so I wanted to be able to generate a simple Mac App where you can 'Browse' for a file on your computer and type in the name of the file that you want to save . . . everything else will be processed by the appl... | Open Automator
Choose "Application"
Drag a "Run Shell Script" onto the workflow panel
Choose "/usr/bin/python" as the shell. Paste in your script, and select Pass Input: "to stdin"
Or, choose bash as the shell, and simply have the automator script run your Python script with Pass Input "as arguments" selected on the to... | 1.2 | true | 1 | 2,450 |
2013-03-18 19:47:37.437 | Build package for OSX when on Windows (Python 3.3, tkinter) | Given that the code has been written indepdently of platform, how do I build a package for MAC OS when I am on Windows and the package has been successfully built there? I can use python setup.py bdist_msi on windows, but not python setup.py bdist_dmg, since I am not on MAC. What to do about that?
Python 3.3, tkinter, ... | I am pretty sure OSX build tools (XCode et. al.) exist only on Apple platforms and there is no business rationale why Apple would have ported them to Windows.
So the probable answer is "buy Mac". | 0 | false | 1 | 2,451 |
2013-03-18 22:06:10.420 | How to run python in different directory? | I am doing maintenance for a python code. Python is installed in /usr/bin, the code installed in /aaa, a python 2.5 installed under /aaa/python2.5. Each time I run Python, it use /usr/bin one. How to make it run /aaa/python2.5?
Also when I run Python -v; import bbb; bbb.__file__; it will automatically show it use bbb ... | Do /aaa/python2.5 python_code.py. If you use Python 2.5 more often, consider changing the $PATH variable to make Python 2.5 the default. | 0.135221 | false | 1 | 2,452 |
2013-03-19 06:59:32.800 | Have Emacs edit Python docstrings using rst-mode | How to I get Emacs to use rst-mode inside of docstrings in Python files? I vaguely remember that different modes within certain regions of a file is possible, but I don't remember how it's done. | As far as for edit-purposes, narrowing to docstring and activating rst-mode should be the way to go.
python-mode el provides py--docstring-p, which might be easily adapted for python.el
Than binding the whole thing to some idle-timer, would do the narrowing/switching.
Remains some expression which toggles-off rst-mode ... | 0 | false | 1 | 2,453 |
2013-03-20 07:33:29.780 | AppEngine 1.7.6 and Django 1.4.2 release | AppEngine 1.7.6 has promoted Django 1.4.2 to GA.
I wonder how and if people this are using The reason for my question is that Django-nonrel seems to be stuck on Django 1.3 and there are no signs of an updated realease.
What I would like to use from Djano are controllers, views and especially form validations. | The django library built into GAE is straight up normal django that has an SQL ORM. So you can use this with Cloud SQL but not the HRD.
django-nonrel is up to 1.4.5 according to the messages on the newsgroup. The documentation, unfortunately, is sorely behind. | 0 | false | 1 | 2,454 |
2013-03-20 12:50:06.960 | Counting words in python | Can anyone tell me how to count the number of times a word appears in a dictionary. Iv already read a file into the terminal into a list. would I need to put the list into a dictionary or start put reading the file into the terminal into a dictionary and not a list? the file is a log file if that matters... | You should look into collections.Counter. Your question is a bit unclear. | 0.496174 | false | 1 | 2,455 |
2013-03-20 16:35:33.737 | How do I access different python module versions? | so I am working on a shared computer. It is a workhorse for computations across the department. The problem we have run into is controlling versions of imported modules. Take for example Biopython. Some people have requirements of an older version of biopython - 1.58. And yet others have requirements for the latest bio... | I'm not sure if it's possible to change the active installed versions of a given module. Given my understanding of how imports and site-packages work, I'm leaning towards no.
Have you considered using virtualenv though ?
With virtualenv, you could create multiple shared environments -- one for biopython 1.58 , another... | 0.386912 | false | 1 | 2,456 |
2013-03-20 20:42:25.023 | Move data from Raspberry pi to a synology diskstation to present in a webpage | I'm looking for ideas, on how to display sensor data in a webpage, hosted by a Synology Diskstation, where the data comes from sensors connected to a Raspberry pi. This is going to be implemented in Python.
I have put together the sensors, and have these connected to the Raspberry. I have also the Python code, so I can... | I'm not experiment on this topic but what I would do is setup a database in between (on the Synology rather than on the Raspberry Pi). Let's call your Synology server, and Raspberry Pi a sensor client.
I would host a database on the server, and push the from the sensor client. The data would be pushed either using an A... | 0.386912 | false | 1 | 2,457 |
2013-03-23 20:19:52.263 | Is there really no event based wysiwyg Gui builder for python/jython etc | I am searching for month now and growing quite frustrated.
I just love python.
So after doing a lot of console based stuff I wanted to do some graphical UIs as well.
I am aware of most of the frameworks (wxpython, glade, tk etc).
But: I do not want to write the code for the GUI itself per hand! Declaring every element... | See Glade, particularly in use with the libglade Python bindings. | 0 | false | 1 | 2,458 |
2013-03-23 22:45:33.077 | How to use NZ Loader (Netezza Loader) through Python Script? | I have a huge csv file which contains millions of records and I want to load it into Netezza DB using python script I have tried simple insert query but it is very very slow.
Can point me some example python script or some idea how can I do the same?
Thank you | You need to get the nzcli installed on the machine that you want to run nzload from - your sysadmin should be able to put it on your unix/linux application server. There's a detailed process to setting it all up, caching the passwords, etc - the sysadmin should be able to do that to.
Once it is set up, you can create N... | 0 | false | 2 | 2,459 |
2013-03-23 22:45:33.077 | How to use NZ Loader (Netezza Loader) through Python Script? | I have a huge csv file which contains millions of records and I want to load it into Netezza DB using python script I have tried simple insert query but it is very very slow.
Can point me some example python script or some idea how can I do the same?
Thank you | you can use nz_load4 to load the data,This is the support utility /nz/support/contrib/bin
the syntax is same like nzload,by default nz_load4 will load the data using 4 thread and you can go upto 32 thread by using -tread option
for more details use nz_load4 -h
This will create the log files based on the number of thr... | 0.135221 | false | 2 | 2,459 |
2013-03-25 06:49:51.933 | Modifying a running script | I'm using python scripts to execute simple but long measurements. I as wondering if (and how) it's possible to edit a running script.
An example:
Let's assume I made an error in the last lines of a running script.These lines have not yet been executed. Now I'd like to fix it without restarting the script. What should ... | I am afraid there's no easy way to arbitrarily modify a running Python script.
One approach is to test the script on a small amount of data first. This way you'll reduce the likelihood of discovering bugs when running on the actual, large, dataset.
Another possibility is to make the script periodically save its state t... | 0 | false | 1 | 2,460 |
2013-03-25 22:01:07.000 | Matching Month and Year In Python with datetime | I'm working on a blog using Django and I'm trying to use get() to retrieve the post from my database with a certain post_title and post_date. I'm using datetime for the post_date, and although I can use post_date = date(year, month, day) to fetch a post made on that specific day, I don't know how to get it to ignore th... | What you're looking for is probably coverd by post_date__year=year and post_date__month=month in django.
Nevertheless all this seems a little bit werid for get parameters. Do you have any constraint at database level that forbids you from putting there two posts with the same title in the same month of given year? | 0.201295 | false | 2 | 2,461 |
2013-03-25 22:01:07.000 | Matching Month and Year In Python with datetime | I'm working on a blog using Django and I'm trying to use get() to retrieve the post from my database with a certain post_title and post_date. I'm using datetime for the post_date, and although I can use post_date = date(year, month, day) to fetch a post made on that specific day, I don't know how to get it to ignore th... | you could use post_date__year and post_date__month | 1.2 | true | 2 | 2,461 |
2013-03-26 11:27:35.883 | GAE: Data is lost after dev server restart | I'm running App Engine with Python 2.7 on OS X. Once I stop the development server all data in the data store is lost. Same thing happens when I try to deploy my app. What might cause this behaviour and how to fix it? | This is answered, but to explain a little further - the local datastore, by default writes to the temporary file system on your computer. By default, the temporary file is emptied any time you restart the computer, hence your datastore is emptied. If you don't restart your computer, your datastore should remain. | 0.386912 | false | 1 | 2,462 |
2013-03-26 19:02:31.150 | How is waiting for I/O or waiting for a lock to be released implemented? | I'm curious. I've been programming in Python for years. When I run a command that blocks on I/O (whether it's a hard-disk read or a network request), or blocks while waiting on a lock to be released, how is that implemented? How does the thread know when to reacquire the GIL and start running again?
I wonder whether th... | There is no need to repeatedly check for either I/O completion or for lock release.
An I/O completion, signaled by a hardware interrupt to a driver, or a lock release as signaled by a software interrupt from another thread, will make threads waiting on those operations ready 'immediately', and quite possibly running, a... | 0 | false | 1 | 2,463 |
2013-03-27 08:43:39.130 | A way to "pipe" gnu screen output to a running python process? | I'm developing a small piece of software, that is able to control (start, stop, restart and so on - with gnu screen) every possible gameserver (which have a command line) and includes a tiny standalone webserver with a complete webinterface (you can access the gnu screen from there, like if you're attached to it) on li... | You can use syslog or even better you can configure it to send all logs to a database! | 0 | false | 2 | 2,464 |
2013-03-27 08:43:39.130 | A way to "pipe" gnu screen output to a running python process? | I'm developing a small piece of software, that is able to control (start, stop, restart and so on - with gnu screen) every possible gameserver (which have a command line) and includes a tiny standalone webserver with a complete webinterface (you can access the gnu screen from there, like if you're attached to it) on li... | Writing to a pipe would work but it's dangerous since your command (the one writing the pipe) will block when you're not fast enough reading the data from the pipe.
A better solution would be create a local "log server" which publishes stdin on a socket. Now you can pipe the output of your command to the log server whi... | 0.135221 | false | 2 | 2,464 |
2013-03-28 22:53:18.933 | Shell scripts have different behavior when launched by Jenkins | I have a ton of scripts I need to execute, each on a separate machine. I'm trying to use Jenkins to do this. I have a Python script that can execute a single test and handles time limits and collection of test results, and a handful of Jenkins jobs that run this Python script with different args. When I run this script... | To debug this:
Add set -x towards the top of your shell script.
Set a PS4 which prints the line number of each line when it's invoked: PS4='+ $BASH_SOURCE:$FUNCNAME:$LINENO:'
Look in particular for any places where your scripts assume environment variables which aren't set when Hudson is running.
If your Python scrip... | 0.201295 | false | 1 | 2,465 |
2013-03-29 00:09:38.077 | Template to forms | I'd like to do somehow the contrary to what a template is used for: I want to write templates and programmatically derive a representation of the different tags and placeholders present in the template, to ultimately generate a form.
To put it another way, when you usually have the data and populate the template with i... | I think Jinja makes sense for building this, in particular because it contains a full-on lexer and parser. You can leverage those to derive your own versions of this that do what you need. | 1.2 | true | 1 | 2,466 |
2013-03-29 12:45:25.570 | Adding to empty doubly linked list in python | I know how to add nodes before and after the head and tail, but I dont know how to add a node to an empty doubly linked list. How would I go about doing this? Thank you. | When inserting into an empty list, make both head and tail refer to the new node. Also, make sure that the node's next and previous references are consistent with what the rest of the code is expecting. | 1.2 | true | 1 | 2,467 |
2013-03-30 04:29:52.837 | How to convert a Python PyQt based program to a portable package in Linux? | I've managed to make a single working executable file (for Windows) from a PyQt based Python app using PyInstaller, but is it also possible for Linux?
On linux machine (LUbuntu), when I run the .py script, I've got errors about missing PyQt bindings and I can't even download them by apt-get because of inability to conn... | If you package your application in the Linux distribution's package format, it can contain dependency information. That is the canonical solution to this problem.
Otherwise you'd have to include all nested dependencies to make sure that it'll work. | 1.2 | true | 1 | 2,468 |
2013-03-31 15:25:18.340 | Django Override password encryption | I am currently developing a tool in Python using Django, in which I have to import an existing User database. Obviously, password for these existing users have not the same encryption than the default password encryption used by Django.
I want to override the encryption for the password method to keep my passwords unmo... | Reconsider your decision about keeping your old password hashes.
EXCEPT if you already used some very modern and strong scheme for them (like pbkdf2, bcrypt. shaXXX_crypt) - and NOT just some (salted or not) sha1-hash.
I know it is tempting to just stay compatible and support the old crap, but these old (salted or unsa... | 0 | false | 1 | 2,469 |
2013-04-02 01:22:48.833 | How to gzip while uploading into s3 using boto | I have a large local file. I want to upload a gzipped version of that file into S3 using the boto library. The file is too large to gzip it efficiently on disk prior to uploading, so it should be gzipped in a streamed way during the upload.
The boto library knows a function set_contents_from_file() which expects a fi... | There really isn't a way to do this because S3 doesn't support true streaming input (i.e. chunked transfer encoding). You must know the Content-Length prior to upload and the only way to know that is to have performed the gzip operation first. | 1.2 | true | 1 | 2,470 |
2013-04-02 06:03:17.663 | Custom filetype in Python 3 | How to start creating my own filetype in Python ? I have a design in mind but how to pack my data into a file with a specific format ?
For example I would like my fileformat to be a mix of an archive ( like other format such as zip, apk, jar, etc etc, they are basically all archives ) with some room for packed files, p... | This may not be appropriate for your question but I think this may help you.
I have a similar problem faced... but end up with some thing like creating a zip file and then renamed the zip file format to my custom file format... But it can be opened with the winRar. | 0 | false | 1 | 2,471 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.