Q_Id
int64 337
49.3M
| CreationDate
stringlengths 23
23
| Users Score
int64 -42
1.15k
| Other
int64 0
1
| Python Basics and Environment
int64 0
1
| System Administration and DevOps
int64 0
1
| Tags
stringlengths 6
105
| A_Id
int64 518
72.5M
| AnswerCount
int64 1
64
| is_accepted
bool 2
classes | Web Development
int64 0
1
| GUI and Desktop Applications
int64 0
1
| Answer
stringlengths 6
11.6k
| Available Count
int64 1
31
| Q_Score
int64 0
6.79k
| Data Science and Machine Learning
int64 0
1
| Question
stringlengths 15
29k
| Title
stringlengths 11
150
| Score
float64 -1
1.2
| Database and SQL
int64 0
1
| Networking and APIs
int64 0
1
| ViewCount
int64 8
6.81M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
22,330,472 | 2014-03-11T16:15:00.000 | 1 | 0 | 1 | 0 | python | 22,330,828 | 4 | false | 0 | 0 | s = set()
[e for e in l if len(e) not in s and s.add(len(e)) is None] | 1 | 5 | 0 | For example, I have a list:
[[1,3],[23,4],[13,45,6],[8,3],[44,33,12]]
Is there any efficient way that I can finally get the list below?
[[1,3],[13,45,6]]
For every length of the list, keep only one element. | How to efficiently remove the same-length elements from a list in python | 0.049958 | 0 | 0 | 211 |
22,331,935 | 2014-03-11T17:17:00.000 | 1 | 0 | 0 | 1 | python,twisted | 22,333,848 | 1 | true | 0 | 0 | There aren't any peek-ahead APIs in Twisted that will let you know if there is data waiting in a buffer somewhere that's about to be delivered.
I think your second idea is just fine - as long as you notice that you can pick an arbitrarily small constant delay. For example, you could pick 0 seconds. In practice this introduces a slightly longer delay (unless you have a really fast computer ;) but it's still small enough that you probably won't notice it.
It's possibly also worth knowing that Twisted reactors try to interleave processing of time-based events with processing of file descriptor-based events. If you didn't know this then you might suspect that using reactor.callLater(0, f) would call f before any more I/O happens. While there's no guarantee of exactly how events are ordered, all of the reactors that ship with Twisted just go back and forth: process all I/O events, process all time events, repeat.
And if you pick only a slightly larger value, perhaps 1/10th of 1 millisecond, then you can pretty much be sure that if dataReceived isn't called again before the timer expires there isn't any more locally received data that is about to be delivered to your application. | 1 | 0 | 0 | I want to write a client for a protocol where the server sends length-prefixed data. The data requires nontrivial decoding and processing, and at any moment the client only needs the latest available data: if there is more data available, it's desirable to flush the old entries and use only the newest one. This is to avoid situations where the client spends so much time processing data that it starts getting more and more behind the server.
I can easily implement reading the length-prefixed data with twisted.protocols.basic.IntNStringReceiver, but how would I check if there is more data available? What I would perhaps like to do is call select on the socket with a zero timeout to see if reading from the socket would block, and if not I'd just skip all decoding and processing. The socket is of course not available in the Protocol.dataReceived method call. Another idea would be to store the data somewhere and start a delay, and if the method is called again before the delay fires, overwrite the data. This imposes a constant delay even in the usual case where there is no more data available. Is there some way to do this that would fit well the Twisted programming model? | Skipping stale data in a Twisted protocol handler | 1.2 | 0 | 1 | 71 |
22,333,873 | 2014-03-11T18:44:00.000 | 1 | 0 | 0 | 0 | python,django,module | 22,335,116 | 2 | false | 1 | 0 | Your "Mod" folder appears to be missing a "init.py" which it will need if you want to import from it.
I also don't recommend a capitalized folder in Python, kind of confusing.
I'd also recommend you add "mod" to your python path so you're not having to do Mod.mod.module you can just do mod.module. I assume you have "mod" (lowercase) as an "INSTALLED_APP" in settings.py? Or is "module" the app? Either way you may want to check out Django's documentation on how to organize a project, especially if this is your first time. | 1 | 0 | 0 | I am on Django 1.6 with Python 2.7, getting an issue with importing some custom modules.
On my views.py file, I have import Mod.mod.module.file, where the Mod folder is stored in the project directory, outside the folders with settings.py and views.py.
The traceback gives me ImportError: No module named Mod.mod.module.file
Thanks for any help!
EDIT: directory structure--
projectFolder
project (includes settings.py, urls.py, wsgi.py)
Mod
mod
module
file
appFolder
views.py | Django app - importing module issues | 0.099668 | 0 | 0 | 62 |
22,338,014 | 2014-03-11T22:27:00.000 | 0 | 0 | 0 | 1 | python,json,google-app-engine,app-engine-ndb | 22,552,471 | 2 | false | 1 | 0 | I would process the data from json, and place it in Model. As far as schema goes, you really need not worry about having redundancies as you cannot really think of the ndb as a relational database. So do not bother yourself too much about normalising the schema.
But don't process on the client side, it is really not a good way to design it like that. | 1 | 0 | 0 | I need to store information on artists, albums and songs in Google App Engine for a project I'm working on. The information is meta data taken from a directory of MP3s (using Python) that needs to be sent to App Engine for display to users. Along with the meta data, the song's path will need to be stored.
Currently while scanning I'm storing the data in an list of dictionaries named Artists, each artist dictionary has a name and a list of Album dictionaries and each Album dictionary has a name and list of song dictionaries, each song then contains some meta data and the path to the MP3.
I've been thinking of ways to store this data and have tried sending the data in JSON format to App Engine, then processing this into three models: Artist, containing the name and a repeated KeyProperty for each Album, Album then has a name and a repeated KeyProperty for each song and the song contains the rest of the meta data. Each of these will also contain a KeyProperty related the the Group that they belong to.
The problems with this are: Lots of repeated data (Group Keys) and processing the data not only often exceeds the request deadline, but also uses an obscene amount of datastore writes.
The only way I could think of to get around these problems would be to store the JSON provided after the scan as a JsonProperty and then pass this directly to the user for processing on the client side using JavaScript. The only issue I could see with that is that I don't particularly want to provide the path to the user (as this will need to be passed back and actioned on).
Does anyone have experience using or storing this kind of data, or can provide any outside the box solutions? | Storing song, artist and album data on App Engine | 0 | 0 | 0 | 235 |
22,340,087 | 2014-03-12T01:17:00.000 | 2 | 0 | 1 | 0 | python | 50,956,200 | 4 | false | 0 | 0 | A list is supposed to be iterated and/or randomly accessed.
Typical usage: store a collection of homogeneous data items.
A queue is designed to be operated at the end/beginning.
Typical usage: store data with priority information, facilitating a wide/depth-first search. | 3 | 11 | 0 | I'm reading the Python Documentation: I don't understand how a deque is different from a list. From the documentation:
Returns a new deque object initialized left-to-right (using append())
with data from iterable. If iterable is not specified, the new deque
is empty.
Deques are a generalization of stacks and queues (the name is
pronounced “deck” and is short for “double-ended queue”). Deques
support thread-safe, memory efficient appends and pops from either
side of the deque with approximately the same O(1) performance in
either direction.
Though list objects support similar operations, they are optimized for
fast fixed-length operations and incur O(n) memory movement costs for
pop(0) and insert(0, v) operations which change both the size and
position of the underlying data representation.
If a deque is basically a list, but more efficient, why would one use a list in place of a deque? | Python deque: difference from list? | 0.099668 | 0 | 0 | 6,624 |
22,340,087 | 2014-03-12T01:17:00.000 | 17 | 0 | 1 | 0 | python | 22,340,135 | 4 | true | 0 | 0 | A deque is more efficient for pushing and popping from the ends. Read on, and below the list of methods you'll find:
Indexed access is O(1) at both ends but slows to O(n) in the middle. For fast random access, use lists instead.
Adding to or removing from the beginning of a list is O(n), but fetching elements from the middle is O(1). For a deque, the reverse is true.
So generally you only want a deque when you don't care about what's in the middle; you want to feed it things in some order and then get them back in that order elsewhere. | 3 | 11 | 0 | I'm reading the Python Documentation: I don't understand how a deque is different from a list. From the documentation:
Returns a new deque object initialized left-to-right (using append())
with data from iterable. If iterable is not specified, the new deque
is empty.
Deques are a generalization of stacks and queues (the name is
pronounced “deck” and is short for “double-ended queue”). Deques
support thread-safe, memory efficient appends and pops from either
side of the deque with approximately the same O(1) performance in
either direction.
Though list objects support similar operations, they are optimized for
fast fixed-length operations and incur O(n) memory movement costs for
pop(0) and insert(0, v) operations which change both the size and
position of the underlying data representation.
If a deque is basically a list, but more efficient, why would one use a list in place of a deque? | Python deque: difference from list? | 1.2 | 0 | 0 | 6,624 |
22,340,087 | 2014-03-12T01:17:00.000 | 5 | 0 | 1 | 0 | python | 22,340,217 | 4 | false | 0 | 0 | Deque is a doubly linked list while List is just an array.
Randomly accessing an object at index i is O(n) for Deque but O(1) for List.
Fast insertions and deletions at the beginning is the biggest advantage of Deque.
Fast random reads is the advantage of List.
If insertions and deletions happen randomly in the middle of the container, Deque will have to find the node (O(n), then insert a new node (O(1)), while List having to move some nodes (O(n)).
They both have their use cases. | 3 | 11 | 0 | I'm reading the Python Documentation: I don't understand how a deque is different from a list. From the documentation:
Returns a new deque object initialized left-to-right (using append())
with data from iterable. If iterable is not specified, the new deque
is empty.
Deques are a generalization of stacks and queues (the name is
pronounced “deck” and is short for “double-ended queue”). Deques
support thread-safe, memory efficient appends and pops from either
side of the deque with approximately the same O(1) performance in
either direction.
Though list objects support similar operations, they are optimized for
fast fixed-length operations and incur O(n) memory movement costs for
pop(0) and insert(0, v) operations which change both the size and
position of the underlying data representation.
If a deque is basically a list, but more efficient, why would one use a list in place of a deque? | Python deque: difference from list? | 0.244919 | 0 | 0 | 6,624 |
22,340,514 | 2014-03-12T02:00:00.000 | 0 | 0 | 0 | 0 | python,qt,pyqt,pyqt4,qt-designer | 66,103,178 | 2 | false | 0 | 1 | The age-old question. There is an answer here, but I'll try to give some clarification: for several components there isn't enough to set item flag Qt::ItemIsUserCheckable, one needs to set item's check state for the checkbox to appear. Also, there is no widget flag to make all items checkable.
An excerpt from Qt documentation:
Note that checkable items need to be given both a suitable set of
flags and an initial state, indicating whether the item is checked or
not. This is handled automatically for model/view components, but
needs to be explicitly set for instances of QListWidgetItem,
QTableWidgetItem, and QTreeWidgetItem. | 1 | 5 | 0 | I am using PyQt4 and Qt Designer. I have a QListWidget in which I populate after loading a file in my program.
I want to set it so that all items will be checkable, as opposed to just selectable. I have found online that this is a 'flag' of the QListWidget, however, in Qt Designer I can't see where to do this.
Is it possible? | Qt Designer QListWidget checkbox | 0 | 0 | 0 | 14,967 |
22,342,581 | 2014-03-12T05:16:00.000 | 1 | 0 | 1 | 0 | python,c++,vector,indexing | 22,342,811 | 7 | false | 0 | 0 | No, there is no explicit function that can do this but what #51k has pointed in the right direction. You might have to write your own implementation if you have a need, other have mentioned some of those | 1 | 3 | 0 | I am trying to find the first index of an element in a vector in c++.
Let's say you have a vector: [2, 3, 4, 2, 6, 7, 1, 2, 6, 3].
I would like to find the position of the number 6.
So the first time the number 6 occurs is at an index value of 4.
Is there a function that can do that in C++?
I know in Python, I can use the list.index(n) method to do that for me. | Returning the first index of an element in a vector in C++ | 0.028564 | 0 | 0 | 5,143 |
22,346,684 | 2014-03-12T09:10:00.000 | 1 | 0 | 0 | 0 | python,matlab,random,numpy,permutation | 22,346,834 | 1 | false | 0 | 0 | This is a common issue. While the random number generator is identical, the function which converts your random number stream into a random permutation is different. There is no specified standard algorithm which describes the expected result.
To solve this issue, you have to use the same library in both tools. | 1 | 2 | 1 | I'm having problems to compare the output of two code because of random number state.
I'm comparing the MATLAB randperm function with the output of the equivalent numpy.random.permutation function but, even if I've set the seed to the same value with a MATLAB rand('twister',0) and a python numpy.random.seed(0) I'm obtaining different permutations.
I've to say that the result of MATLAB's rand and numpy numpy.random.rand are the same if the seed are set like above. | Compare Numpy and Matlab code that uses random permutation | 0.197375 | 0 | 0 | 1,337 |
22,348,501 | 2014-03-12T10:25:00.000 | 0 | 0 | 0 | 0 | javascript,python,html | 22,348,762 | 2 | false | 1 | 0 | I am not going to search the code for you. But most sites tell you you need an onclick event because that is needed to open a link. And example.com#idOfDiv, is the kind of link you would open. Howerver, there is another possibility.
Find some javascript code to decide the position of an element in x and y coordinats. After you got it, make JS Scroll ;). | 1 | 1 | 0 | I am new to JavaScript.
The problem goes as follows: I have 10 div in my html file. I am using links to go from one to another. Now, I want to test a condition which if satisfied (I am using python for this), should redirect me to another div within the same html. But I want that to be automatic. For eg, I am in <div id="table1"> and inside it I am checking a condition. If that is true, I should be redirected automatically to <div id="table3">.Can anyone please help me find the way out?On google,when I am trying to search for it, it is giving me results where I have to click a button for redirection (which will invoke a JS function). But I don't want that. I want it to happen automatically. So, please tell.
<div id="table5">
<div style="position:fixed;right:40px;top:65px;">
<a name="t10" href="#t10" onclick='show(10);'><button> GO TO MAIN PAGE </button></a>
</div>
% if not obj.i:
<h2>REDIRECT ME TO id="table3"</h2>
% else:
<table border=1 cellpadding=7>
<tr>
<th>Row No. in Sheet</th>
<th>Parameters</th>
</tr>
<tr>
<th colspan=2>Total : ${value}</th>
</tr>
</table>
% endif
</div> | Get redirected to a div automatically without user's intervention | 0 | 0 | 1 | 68 |
22,354,902 | 2014-03-12T14:39:00.000 | 1 | 1 | 0 | 1 | python,c,file | 22,355,036 | 1 | false | 0 | 0 | It should be possible. In C, you can get the file descriptor with fileno(fh) and open it in Python with os.fdopen(fd). Make sure you remember to close it -- I doubt that the Python file object going out of scope would accomplish this. | 1 | 2 | 0 | I've been trying to integrate C code into Python under Linux and I came up with the following problem: ¿is it possible to share an already opened file between C and Python? I mean a C FILE and a Python file object.
The C function which I'm struggling with is called exhaustively, so I'd like to avoid opening/closing the file each time this happens and pass the opened file from Python to C. I'm open to any efficient solution. | Share file stream between Python and C | 0.197375 | 0 | 0 | 258 |
22,355,264 | 2014-03-12T14:52:00.000 | 0 | 0 | 1 | 1 | python,linux,linux-kernel,driver | 29,156,444 | 3 | false | 0 | 0 | No; LKM on Linux have to be compiled down do a specific ELF object code format.
Of course you could make your own hack of Python that does compile down to kernel object code, but as far as I know, at this time there is no such Python publicly available. | 1 | 7 | 0 | I have been wondering if developing Linux kernel modules (drivers) with Python is possible. Is it? | Developing Linux Kernel Modules in Python | 0 | 0 | 0 | 12,935 |
22,355,594 | 2014-03-12T15:04:00.000 | 0 | 0 | 0 | 0 | python,protocol-buffers | 22,355,757 | 1 | false | 0 | 0 | It will depend on how you represent the object as str(). If the object is machine parseable, you will have the best luck. If you use json, yaml or xml, you can use built in serialization libraries, otherwise you'll need to roll your own. | 1 | 0 | 0 | I have a protobuf string representation for some object (__str___() def). Is it possible easily create that object from that string? Or the only possible way is the self written parser?
Default serialization\deserialization is not applicable since the object state modification should be performed outside of the programming scope. And the whole flow is following:
get ser representation from network;
deser this representation to the object;
get the string representation for the object;
pass this representation to somebody who wants change some fields
(values changed in the string representation). here will be created
a separate file with the str representation for all received objects
(there will be lots of objects);
convert NEW string to the Py object;
Ser object;
Pass ser message over network. | Is it possible to create an object from the protobuf str representation in Python | 0 | 0 | 1 | 717 |
22,357,298 | 2014-03-12T16:07:00.000 | 1 | 0 | 0 | 0 | python,twitter-bootstrap,hosting | 22,357,361 | 2 | false | 1 | 0 | Well, then use your ubuntu system, forward the right ports in your router and give your customers a link to your IPadres. I assume you use your ubuntu system as an webserver already for testing your site? | 1 | 2 | 0 | I'm developing a website in python (with django and GIT) for an association, and I am to a point where I need to share my work for approval from the team.
I have around 50 people who need to be able to access my "website" 24/7.
Apparently, free hosting is not the best way to do it (see answers to my original question).
I've never done such a thing, so I'm a bit lost. It looks like I can use without too many investment in effort my ubuntu computer. And apparently there is other tools for this application.
I'm looking for advise and explanation on how to implement a working solution.
EDIT: The 50 people are not in my local network.
[ORIGINAL POST BELOW]
What is the best way to share my website to partners?
I'm developing a website for an association, and I want to know if there is a way to let them access to my work in progress.
I was thinking of free hosting solutions?
I'm not looking for a professional host, I'm just looking for a way to share my work with maximum 50 peoples.
Is there another solution?
I have an ubuntu pc that I could use as server (I have high speed connection).
(I don't know if this is relevant, but I'm using python-django and bootstrap for the design) | How can I share my website in progress to partner? | 0.099668 | 0 | 0 | 122 |
22,358,516 | 2014-03-12T16:54:00.000 | 3 | 0 | 0 | 1 | python,linux,bash | 22,358,568 | 1 | false | 0 | 0 | You can remotely execute the command hostname command on these machines to acquire the Hostname | 1 | 1 | 0 | I want to be able to scan a network of servers and match IP addresses to hostnames.
I saw a lot of questions about this (with a lot of down votes), but none are exactly what I'm looking for.
So I've tried python's socket library socket.gethostbyaddr(ip). But this only returns results if I have a DNS setup or the IP-to-host mapping is in my hosts file.
I want to be able to ask a machine for their hostname, rather than querying DNS.
How can a query a Linux machine for their hostname?
Preferably using python or bash, but other ways are good too. | Query machine for hostname | 0.53705 | 0 | 1 | 218 |
22,358,713 | 2014-03-12T17:01:00.000 | 2 | 0 | 1 | 1 | python-3.x | 22,358,774 | 1 | true | 0 | 0 | Each installation of Python comes with its own respective version if IDLE. I suggest you explore your Python installation folder, and find the version of IDLE you're looking for and create a shortcut to it, or add it to your environment variable list, so you can invoke a specific version from the command line. | 1 | 0 | 0 | I am using Windows 8.
Python version 2.7.3 have been installed on my computer together with another software.
Now I have installed python 3.3.5 and i want to use this version from now.
But everytime I run Python IDLE it runs version 2.7.3.
Even if I go to C:\Python33\Lib\idlelib\idle.pyw and run idle.pyw it runs with the 2.7.3 version.
I thought that every python version install its own IDLE so I am quiet confused here.
When I run Hello world program from the console it runs using the version 3.3.5 I have checked that.
So what I need to do is to run IDLE using 3.3.5 version
Anybody knows what to do? | How to set Python IDLE to use certain python version | 1.2 | 0 | 0 | 271 |
22,359,664 | 2014-03-12T17:43:00.000 | 3 | 0 | 1 | 0 | python,python-3.x,set | 22,359,828 | 2 | false | 0 | 0 | To compliment what Martijn said, I frequently use them for cache keys. For example, a memoize decorator that would key off (args, frozenset(kwargs.items()). | 1 | 7 | 0 | Could I be supplied with some simple examples of when using a frozenset would be the best option to help me understand the concept more please. | frozenset() - Example of when one might use them | 0.291313 | 0 | 0 | 2,857 |
22,360,093 | 2014-03-12T18:02:00.000 | 2 | 1 | 0 | 0 | python,networking,p2p,bitcoin,peer | 22,360,849 | 2 | true | 0 | 0 | Depends which part is in Python. The network is, by definition, I/O bound. It's unlikely that using Python rather than C/C++/etc. will cause a noticeable performance drop for the client itself. Your choice of cryptographic algorithm will also have a large impact on performance (how quick it is to verify transactions, etc.).
Now, as for 'mining' the currency, it would be silly to do that with Python since that's very much a CPU-bound task. In fact, using a GPU which allows for massive parallelism on trivially parallel problems is a much better idea (CUDA or OpenCL work great here). | 2 | 0 | 0 | I'd like to make my own crypto currency. I don't want to just recompile the Bitcoin source code and the rename it. I'd like to do it from scratch just to learn more about it. I'm thinking of using Python as the language for the implementation but I heard that in terms of performance Python isn't the best. My question is, would a network written in Python be able to perform well under the possibility of millions of peers (I know it's not going to happen but I'd like to make my network scalable.) | Python Peer to Peer Network | 1.2 | 0 | 1 | 744 |
22,360,093 | 2014-03-12T18:02:00.000 | 2 | 1 | 0 | 0 | python,networking,p2p,bitcoin,peer | 22,360,906 | 2 | false | 0 | 0 | Nothing beats good ol' C for performance. However, if you plan on parallelising everything for multi-CPU support I would give Haskell a try. It is inherently parallel, so you won't have to put in extra effort for optimizations.
You can also do something similar in C with OpenMP and Cilk using pragmas.
Good Luck! | 2 | 0 | 0 | I'd like to make my own crypto currency. I don't want to just recompile the Bitcoin source code and the rename it. I'd like to do it from scratch just to learn more about it. I'm thinking of using Python as the language for the implementation but I heard that in terms of performance Python isn't the best. My question is, would a network written in Python be able to perform well under the possibility of millions of peers (I know it's not going to happen but I'd like to make my network scalable.) | Python Peer to Peer Network | 0.197375 | 0 | 1 | 744 |
22,360,412 | 2014-03-12T18:17:00.000 | 0 | 0 | 0 | 0 | python,neural-network | 22,360,726 | 1 | true | 0 | 0 | Simply use a standard sigmoid/logistic activation function on the output neuron. sigmoid(x) > 0 forall real-valued x so that should do what you want.
By default, many neural network libraries will use either linear or symmetric sigmoid outputs (which can go negative).
Just note that it takes longer to train networks with a standard sigmoid output function. It's usually better in practice to let the values go negative and instead transform the outputs from the network into the range [0,1] after the fact (shift up by the minimum, divide by the range (aka max-min)). | 1 | 1 | 1 | I am learning some model based on examples ${((x_{i1},x_{i2},....,x_{ip}),y_i)}_{i=1...N}$ using a neural network of Feed Forward Multilayer Perceptron (newff) (using python library neurolab). I expect the output of the NN to be positive for any further simulation of the NN.
How can I make sure that the results of simulation of my learned NN are always positive?
(how I do it in neurolab?) | Python Neurolab - fixing output range | 1.2 | 0 | 0 | 948 |
22,361,870 | 2014-03-12T19:27:00.000 | 1 | 0 | 0 | 0 | python,pygame,pygame-surface | 22,363,605 | 2 | false | 0 | 1 | Just call window.fill([0, 0, 0]) each time in your main loop. Where the window is your pygame.display.set_mode() main surface. If you have any questions, just comment below. | 1 | 1 | 0 | I've been working with Python and PyGame days ago, and i noticed that when i move the player in my game, it will blit over itself again and again while moving, leaving a tail, is there any way i can clean up all the old sprites that the player left while moving?
I tried bliting the background again while moving to remove them, but that was frustrating in a point. Any Idea?
Thanks | PyGame, How to clean up Old Sprites | 0.099668 | 0 | 0 | 421 |
22,362,449 | 2014-03-12T19:56:00.000 | 0 | 1 | 1 | 0 | python | 22,362,518 | 3 | false | 0 | 0 | Put __init__.py into directory my_module, make sure my_module is in sys.path, and then from my_module import WHAT_EVER_YOU_WANT | 2 | 4 | 0 | I have an improperly packaged Python module. It only has __init__.py file in the directory. This file defines the class that I wish to use. What would be the best way to use it as a module in my script?
** EDIT **
There was a period (.) in the the name of the folder. So the methods suggested here were not working. It works fine if I rename the folder to have a valid name. | Import a module in Python | 0 | 0 | 0 | 87 |
22,362,449 | 2014-03-12T19:56:00.000 | 0 | 1 | 1 | 0 | python | 22,362,523 | 3 | false | 0 | 0 | It's not necessarily improperly packaged. You should be able to do from package import X just like you would normally. __init__.py files are modules just like any other .py file, they just have some special semantics as to how they are evaluated in addition to the normal usage, and are basically aliased to the package name. | 2 | 4 | 0 | I have an improperly packaged Python module. It only has __init__.py file in the directory. This file defines the class that I wish to use. What would be the best way to use it as a module in my script?
** EDIT **
There was a period (.) in the the name of the folder. So the methods suggested here were not working. It works fine if I rename the folder to have a valid name. | Import a module in Python | 0 | 0 | 0 | 87 |
22,365,018 | 2014-03-12T22:12:00.000 | 0 | 1 | 0 | 1 | php,python,google-app-engine | 22,365,130 | 1 | false | 1 | 0 | You can (and many do) use a front-end like nginx or Apache that handles and forwards different paths differently. I do not see why you would want your application engine to be "bilingual" though. | 1 | 0 | 0 | Can I serve PHP and python on a single project in app engine?
for example
/php/* will run php code, but the root / will run python code. | can i serve PHP and python on a single project in app engine? | 0 | 0 | 0 | 63 |
22,369,171 | 2014-03-13T04:36:00.000 | 1 | 0 | 0 | 0 | python-2.7,bokeh | 22,407,756 | 1 | false | 0 | 0 | Yes, this is the git hash. Try looking at bokeh.__version__. We'll fix this up by the next release.
Thanks! | 1 | 2 | 0 | I'm user of Bokeh
I update the Bokeh yesterday, but I found the abnormal version number
import bokeh
bokeh.version # under bar ???
result ---> '96d477c368eb4384b048cef164b41c572de1f43f'
????
I don't know that version number is abnormal number | bokeh version is abnormal (python 2.76, bokeh 4.2) | 0.197375 | 0 | 0 | 179 |
22,369,384 | 2014-03-13T04:56:00.000 | 1 | 0 | 0 | 1 | python,django,google-app-engine,gql | 22,370,376 | 1 | true | 1 | 0 | Fetch the record you want to edit (by key , id or any filter) , modify the field you want to edit and then put() it. | 1 | 0 | 0 | I was create one app which have model and it was created but i facing problem how to edit data in google data store using python or Django. Please Help me. | How to edit record in google datastore in AppEngine? | 1.2 | 0 | 0 | 255 |
22,370,488 | 2014-03-13T06:13:00.000 | 2 | 1 | 1 | 0 | python | 22,371,140 | 3 | false | 0 | 0 | When using Python for a large project using automated testing is a must because otherwise you would never dare to do any serious refactoring and the code base will rot in no time as all your changes will always try to touch nothing leading to bad solution (simply because you'd be too scared to implement the correct solution instead).
Indeed the above is true even with C++ or, as it often happens with large projects, with mixed-languages solutions.
Not longer than a few HOURS ago for example I had to make a branch for a four line bugfix (one of the lines is a single brace) for a specific customer because the trunk evolved too much from the version he has in production and the guy in charge of the release process told me his use cases have not yet been covered with manual testing in current version and therefore I cannot upgrade his installation.
The compiler can tell you something, but it cannot provide any confidence in stability after a refactoring if the software is complex. The idea that if some piece of code compiles then it's correct is bogus (possibly with the exception of hello_world.cpp).
That said you normally don't use dictionaries in Python for everything, unless you really care about the dynamic aspect (but in this case the code doesn't access the dictionary with a literal key). If your Python code has a lot of d["foo"] instead of d[k] when using dicts then I'd say there is a smell of a design problem. | 1 | 6 | 0 | I am new to dynamic languages in general, and I have discovered that languages like Python prefer simple data structures, like dictionaries, for sending data between parts of a system (across functions, modules, etc).
In the C# world, when two parts of a system communicate, the developer defines a class (possibly one that implements an interface) that contains properties (like a Person class with a Name, Birth date, etc) where the sender in the system instantiates the class and assigns values to the properties. The receiver then accesses these properties. The class is called a DTO and it is "well- defined" and explicit. If I remove a property from the DTO's class, the compiler will instantly warn me of all parts of the code that use that DTO and are attempting to access what is now a non-existent property. I know exactly what has broken in my codebase.
In Python, functions that produce data (senders) create implicit DTOs by building up dictionaries and returning them. Coming from a compiled world, this scares me. I immediately think of the scenario of a large code base where a function producing a dictionary has the name of a key changed (or a key is removed altogether) and boom- tons of potential KeyErrors begin to crop up as pieces of the code base that work with that dictionary and expect a key are no longer able to access the data they were expecting. Without unit testing, the developer would have no reliable way of knowing where these errors will appear.
Maybe I misunderstand altogether. Are dictionaries a best practice tool for passing data around? If so, how do developers solve this kind of problem? How are implicit data structures and the functions that use them maintained? How do I become less afraid of what seems like a huge amount of uncertainty? | How does Python provide a maintainable way to pass data structures around in a system? | 0.132549 | 0 | 0 | 1,529 |
22,370,760 | 2014-03-13T06:28:00.000 | 1 | 0 | 1 | 0 | python,pandas | 22,375,190 | 1 | true | 0 | 0 | In dateutil 2.2 there was an internal API change. Pandas 0.12 shows this bug as it relies on this API.
Pandas >= 0.13 works around, or you can downgrade to dateutil 2.1 | 1 | 0 | 1 | I am running code on two separate machines, it works on one machine and not on the other. I have a Pandas panel object x and I am using x.truncate('2002-01-01'). It works on one machine and not the other.
The error thrown is DateParseError: 'tuple' object has no attribute 'year'.
I have some inkling there is something wrong with the dateUtil package upgrade but didn't know if there's a better fix than backwardating the install. | Panel truncate error: tuple object has no attribute 'year' | 1.2 | 0 | 0 | 179 |
22,371,860 | 2014-03-13T07:27:00.000 | 5 | 0 | 1 | 0 | python,types,strong-typing,static-typing,rpython | 22,372,435 | 5 | false | 0 | 0 | The short answer is no. What you are asking for is deeply built into Python, and can't be changed without changing the language so drastically that is wouldn't be Python.
I'm assuming you don't like variables that are re-typed when re-assigned to? You might consider other ways to check for this if this is a problem with your code. | 2 | 11 | 0 | I rather like Python's syntactic sugar; and standard library functions.
However the one feature which I dislike; is implicit typing.
Is there a distribution of Python with explicit typing; which is still compatible with e.g.: packages on PyPi?
[I was looking into RPython] | Explicitly typed version of Python? | 0.197375 | 0 | 0 | 7,510 |
22,371,860 | 2014-03-13T07:27:00.000 | 1 | 0 | 1 | 0 | python,types,strong-typing,static-typing,rpython | 22,372,459 | 5 | false | 0 | 0 | No You can not have cake and eat cake.
Python is great because its dynamically typed! Period. (That's why it have such nice standard library too)
There is only 2 advantages of statically typed languages 1) speed - when algorithms are right to begin with and 2) compilation errors
As for 1)
Use PyPi,
Profile,
Use ctype libs for great performance.
Its typical to have only 10% or less code that is performance critical. All that other 90%? Enjoy advantages of dynamic typing.
As for 2)
Use Classes (And contracts)
Use Unit Testing
Use refactoring
Use good code editor
Its typical to have data NOT FITTING into standard data types, which are too strict or too loose in what they allow to be stored in them. Make sure that You validate Your data on Your own.
Unit Testing is must have for algorithm testing, which no compiler can do for You, and should catch any problems arising from wrong data types (and unlike compiler they are as fine grained as you need them to be)
Refactoring solves all those issues when You are not sure if given changes wont break Your code (and again, strongly typed data can not guarantee that either).
And good code editor can solve so many problems... Use Sublime Text for a while. And then You will know what I mean.
(To be sure, I do not give You answer You want to have. But rather I question Your needs, especially those that You did not included in Your question) | 2 | 11 | 0 | I rather like Python's syntactic sugar; and standard library functions.
However the one feature which I dislike; is implicit typing.
Is there a distribution of Python with explicit typing; which is still compatible with e.g.: packages on PyPi?
[I was looking into RPython] | Explicitly typed version of Python? | 0.039979 | 0 | 0 | 7,510 |
22,373,983 | 2014-03-13T09:18:00.000 | 0 | 0 | 0 | 0 | python,windows,berkeley-db,bsddb | 22,391,487 | 1 | false | 0 | 0 | Deleting the 's' symbol isn't appropriate - the s designates the static libdb53 library. Assuming you are building libdb53 from source as well, in the build_windows directory there is a Berkeley_DB.sln that includes Static_Debug and Static_Release configurations that will build these.
However, your troubles may not end there. I'm using the static libraries and still getting similar unresolved external errors. | 1 | 2 | 0 | building bsddb3-6.0.1, Python 3.3.2, BerkeleyDB 5.3, Windows7.
First linker asked for libdb53s.lib, but there's no such file, so I deleted 's' symbol (in setup3.py) and now linker can find libdb53.lib, but...
_bsddb.obj : error LNK2019: unresolved external symbol db_create referenced in f
unction newDBObject
_bsddb.obj : error LNK2019: unresolved external symbol db_strerror referenced in
function makeDBError
_bsddb.obj : error LNK2019: unresolved external symbol db_env_create referenced
in function newDBEnvObject
_bsddb.obj : error LNK2019: unresolved external symbol db_version referenced in
function _promote_transaction_dbs_and_sequences
_bsddb.obj : error LNK2019: unresolved external symbol db_full_version reference
d in function _promote_transaction_dbs_and_sequences
_bsddb.obj : error LNK2019: unresolved external symbol db_sequence_create refere
nced in function newDBSequenceObject
build\lib.win-amd64-3.3\bsddb3_pybsddb.pyd : fatal error LNK1120: 6 unresolved
externals
error: command '"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\amd6
4\link.exe"' failed with exit status 1120
Copied BDB folders to bsddb3-6.0.1\db
bsddb3-6.0.1\db\lib contains libdb53.lib
bsddb3-6.0.1\db\bin contains libdb53.dll
Are there any ready to use bsddb3 binaries for Python3.3.2 ? | bsddb3-6.0.1 Windows7 bulid error: _bsddb.obj : error LNK2019: unresolved external symbol db_create referenced in function newDBObject | 0 | 1 | 0 | 183 |
22,374,305 | 2014-03-13T09:33:00.000 | 0 | 0 | 1 | 0 | python,shortcut,spyder | 70,258,207 | 3 | false | 0 | 0 | in python 3.8 , only
Ctrl + Shift + p
worked for me | 2 | 1 | 0 | Does anyone know the shortcuts to switch between different scripts opened in Spyder?
I know that Ctrl + Shift + E is for switching to editor, but within the editor, is there any ways to switch with just keyboards? | Shortcuts for Switching Scripts within Editor in Spyder | 0 | 0 | 0 | 3,727 |
22,374,305 | 2014-03-13T09:33:00.000 | 2 | 0 | 1 | 0 | python,shortcut,spyder | 22,381,555 | 3 | false | 0 | 0 | You can also use Ctrl+P to show a widget listing all your open files. You can filter them there too. | 2 | 1 | 0 | Does anyone know the shortcuts to switch between different scripts opened in Spyder?
I know that Ctrl + Shift + E is for switching to editor, but within the editor, is there any ways to switch with just keyboards? | Shortcuts for Switching Scripts within Editor in Spyder | 0.132549 | 0 | 0 | 3,727 |
22,378,590 | 2014-03-13T12:25:00.000 | 0 | 1 | 0 | 0 | python,c++,dll,swig | 22,378,831 | 3 | false | 0 | 1 | To use a library (static or dynamic), you need headers and library file .a, .lib...
Its true for c++ and I think its the same for Python | 2 | 0 | 0 | I have a third party DLL (no header file) written in C++ and I am able to get the function prototype information from the developer, but it is proprietary and he will not provide the source.
I've gone through the SWIG tutorial but I could not find anywhere specifying how to use SWIG to access any functions with only the DLL file. Everything on the tutorial shows that I need to have the header so SWIG knows what the function prototypes look like.
Is SWIG the right route to use in this case? I am trying to load this DLL in Python so I can utilize a function. From all of my research, it looks like Python's ctypes does not work with C++ DLL files and I am trying to find the best route to follow to do this. Boost.python seems to require changing the underlying C++ code to make it work with Python.
To sum up, is there a way to use SWIG when I know the function prototype but do not have the header file or source code? | SWIG C++ Precompiled DLL | 0 | 0 | 0 | 1,508 |
22,378,590 | 2014-03-13T12:25:00.000 | 0 | 1 | 0 | 0 | python,c++,dll,swig | 22,389,172 | 3 | false | 0 | 1 | SWIG cannot be used without the header files. Your only option is a lib like ctypes. If you find ctypes doesn't do it for you and you can't find alternative then post a question with why ctypes not useable in your case. | 2 | 0 | 0 | I have a third party DLL (no header file) written in C++ and I am able to get the function prototype information from the developer, but it is proprietary and he will not provide the source.
I've gone through the SWIG tutorial but I could not find anywhere specifying how to use SWIG to access any functions with only the DLL file. Everything on the tutorial shows that I need to have the header so SWIG knows what the function prototypes look like.
Is SWIG the right route to use in this case? I am trying to load this DLL in Python so I can utilize a function. From all of my research, it looks like Python's ctypes does not work with C++ DLL files and I am trying to find the best route to follow to do this. Boost.python seems to require changing the underlying C++ code to make it work with Python.
To sum up, is there a way to use SWIG when I know the function prototype but do not have the header file or source code? | SWIG C++ Precompiled DLL | 0 | 0 | 0 | 1,508 |
22,379,103 | 2014-03-13T12:45:00.000 | 2 | 0 | 1 | 1 | python,macos,virtualenv,homebrew | 22,379,177 | 2 | true | 0 | 0 | I don't think if they are related. You have to use pip for python package management when you use virtualenv. this way you make sure that your new stuff is on the sandbox you created. AFAIK home-brew installs stuff globally. So better not use it to get the python modules. hope it helps. | 1 | 5 | 0 | Simple question: is running homebrew while in a virtualenv a bad idea?
If so, is there any way that I can automatically deactivate the virtualenv each time I run a homebrew command? I don't trust myself to always remember to deactivate the virtualenv or open a new terminal window. | Running homebrew while in a virtualenv | 1.2 | 0 | 0 | 1,012 |
22,381,146 | 2014-03-13T14:07:00.000 | 3 | 0 | 0 | 1 | python-3.x,setuptools,egg,python-egg-cache | 22,385,552 | 1 | true | 0 | 0 | Found the cause of the issue. As @erykson noted I was using the wrong directory.
After replacing
html_path = resource_filename(__name__, "html")
with
html_path = resource_filename(Requirement.parse("myproj"), "html")
everything works fine. | 1 | 4 | 0 | I want to package a project that contains (and uses) template html files and distribuite it as an egg. Since I’m using tornadoweb, which requires file paths to point to html files, I can’t access the resources via stream and I really need the html files to be extracted when my program is running.
I’m having a look at setuptools and according to resource_filename docs (bold is mine):
Sometimes, it is not sufficient to access a resource in string or stream form, and a true filesystem filename is needed. In such cases, you can use this method (or module-level function) to obtain a filename for a resource. If the resource is in an archive distribution (such as a zipped egg), it will be extracted to a cache directory, and the filename within the cache will be returned. If the named resource is a directory, then all resources within that directory (including subdirectories) are also extracted. If the named resource is a C extension or “eager resource” (see the setuptools documentation for details), then all C extensions and eager resources are extracted at the same time.
Which seems exactly what I need. However this is not what happens on my machine. My setup.py contains the following line:
data_files = [('html', ['html/index.html'])]
And index.html is actually included in my egg file. When I run python3 setup.py install my project gets installed as a single zipped egg file. Unfortunately, when my program executes the following line:
html_path = resource_filename(__name__, "html")
I get the following return value:
/usr/local/lib/python3.2/dist-packages/myproj-0.1-py3.2.egg/EGG-INFO/scripts/html/
The problem is that myproj-0.1-py3.2.egg is actually a zip file so this is not a valid path.
It’s strange because if I call pkg_resources.get_cache_path(‘myproj’) I get the following path back:
/root/.python-eggs/myproj-tmp
But nothing is extracted there (yes, I’m running the program as root, but I’m just testing it).
Any idea why my html directory is not extracted? | pkg_resources.resource_filename is not extracting files | 1.2 | 0 | 0 | 5,826 |
22,381,841 | 2014-03-13T14:32:00.000 | 4 | 0 | 1 | 0 | python,dll | 22,383,385 | 2 | true | 0 | 0 | It's most probably a 32-bit or 64-bit issue. Try downloading proper version. | 2 | 6 | 0 | I have downloaded my code from bit-bucket which was made by my group member. It contain all the frameworks and python script folder. But when I run this code on my system it generates the following error:
This program can't start because python27.dll is missing from your
computer. Try reinstalling the program to fix this program
I have also downloaded and installed python 2.7 on my system but when I run it generates the same error.
Please tell me how can I fix this problem. | Python27.dll File Missing - Exception | 1.2 | 0 | 0 | 16,517 |
22,381,841 | 2014-03-13T14:32:00.000 | 3 | 0 | 1 | 0 | python,dll | 30,247,563 | 2 | false | 0 | 0 | I also got this error when I copied my python environment from one computer to another. Both computers were 64 bit and the installation was 64 bit. What happens is that python installer updates Microsoft registry. When I simply copied the python files, the registry did not get updated, of course, resulting in the dll file missing error message.
I solved it by installing the 64 bit version of python first on my target computer, and then did my copy of the environment, i.e. copied c:\pythonFromComputerA to target computer's c:\python27, effectively overwriting the python that had just been installed. But because the installer updated the registry, I could now run with my python environment on the target computer without getting the error message.
Thought I'd provide this in case others are out there scratching their heads, having correctly matching installation with OS yet getting this error message. | 2 | 6 | 0 | I have downloaded my code from bit-bucket which was made by my group member. It contain all the frameworks and python script folder. But when I run this code on my system it generates the following error:
This program can't start because python27.dll is missing from your
computer. Try reinstalling the program to fix this program
I have also downloaded and installed python 2.7 on my system but when I run it generates the same error.
Please tell me how can I fix this problem. | Python27.dll File Missing - Exception | 0.291313 | 0 | 0 | 16,517 |
22,383,464 | 2014-03-13T15:31:00.000 | 2 | 0 | 1 | 0 | javascript,python,django,angularjs,karma-runner | 22,385,076 | 1 | true | 1 | 0 | I have found that you need to install a particular node module in a folder that encompasses all files that will use it. This is most easily accomplished by putting all node modules in the root folder of your website. This is by design of node's creator, though I'm not sure if he wants it that way or just does not want to change it. Either way, there is no way around this.
As for karma, as it is a node module, it needs to be in a folder that includes all files that will use it; therefore, if your entire website uses it, you're better off putting it in the website's root folder.
Of course, as node is open source, you could go in & change this requirement of node modules so they can be installed anywhere, maybe with a pointer from a file that uses it to that node module.
Only you & your team (and your users) can determine if you want to push or ignore your website files, but in general with node_modules, if your users need them, send them. If only your developers need them, either install them individually on all developers' machines or make another branch for development work. Node also has a way to separate development modules from release modules, so you could look into that. | 1 | 2 | 0 | I am just starting on integrating AngularJS into my Django project.
After I installed Karma for testing following the tutorial I got bunch of Node.js modules installed in my root project folder.
Should I check all of this files from node_modules folder into my repo? Or should I ignore them with .gitignore?
Are there alternatives to installing Karma to root or is it required? | What is a preferred way for installing Karma in Angular/Django project? | 1.2 | 0 | 0 | 634 |
22,383,642 | 2014-03-13T15:39:00.000 | 0 | 0 | 0 | 0 | python,arrays,math,numpy,combinations | 22,389,392 | 2 | false | 0 | 0 | Your algorithm could look like this:
Keep the last X (say 10) of the combinations that have been used in a list of some sort.
Pick Y (say 10) combinations randomly.
Analyze each of the Y combinations against the last X combinations to find the most dissimilar combination. This would involve writing a method that would generate a score as to how dissimilar the combination is with each of the last X combinations. Average the score and pick the one that is most dissimilar. | 1 | 0 | 1 | Say I have an array of shape (32,).
Each element can have one of four int values:0 to 3
If I wanted to create an array for each possible combination I would have 432 ( approximately 1.84 x 1019) arrays - this is overly burdensome.
Is there a straightforward way to pick fewer arrays, say 1 x 106, by picking the 'most dissimilar' combinations?
By 'most dissimilar' I mean avoiding arrays that are different by one (or few) values and picking arrays that have many dissimilar values.
Also, if there is an area of mathematics that I should be looking at to improve my description please let me know. | How can I create a subset of the 'most dissimilar' arrays from a set of possible combinations? | 0 | 0 | 0 | 120 |
22,384,473 | 2014-03-13T16:11:00.000 | 0 | 0 | 0 | 0 | python,django | 22,384,701 | 1 | false | 1 | 0 | Try to move your app name up to admin app in your INSTALLED_APPS settings.py tuple. | 1 | 0 | 0 | I have a Django project in which I have changed the default 'Django Administration' text in the header.
Now I have implemented translation of strings that django knows about, but I cannot figure out how to translate this title.
I put the translation function in models.py but it doesn't change when I change Language.
I've edited the base.html template like so
{% trans 'My Console' %}
And added the msgstr in my .po files and ran makemessages and compilemessages
I am running out of things to try.
Can anyone shed some light on how to do this?
I can supply code if it will help.
Thanks for reading. | Where do I put the specific translation functions in Django App? | 0 | 0 | 0 | 90 |
22,387,166 | 2014-03-13T18:03:00.000 | 2 | 1 | 1 | 0 | python,operators,absolute-value | 22,387,237 | 1 | false | 0 | 0 | abs(...)
abs(a) -- Same as abs(a).
No, I don’t think there’s some other fancy way you don’t know about, or really any reason at all for this to be here at all except for consistency (since operator has methods for the other __operator__s). | 1 | 5 | 0 | In operators module we have a helper method operator.abs. But in python abs is already a function, and the only way I know to invoke the __abs__ method on an object is by function call anyway.
Is there some other fancy way I don't know about to take the absolute value of a number? If not, why does operator.abs exist in the first place, and what is an example where you would have to use it instead of plain old abs? | How/why do we use operator.abs | 0.379949 | 0 | 0 | 723 |
22,389,675 | 2014-03-13T20:03:00.000 | 0 | 0 | 0 | 0 | python,mysql,sqlalchemy | 22,668,180 | 1 | false | 0 | 0 | It took me a while but it appears that the transaction was automatically rolled back by error 1213 (deadlock) and 1205 (lock wait timeout exceeded). It did not help that these errors were caught in some internal middleware that tried to execute again the statement that failed instead of forwarding the error up to the transaction layer where the entire transaction could be retried or abandoned as a whole. The result was that the code would keep on executing normally under the assumption that the ongoing transaction was still ongoing while it had been rolled back by the mysql server. | 1 | 0 | 0 | I keep seeing what appears to be a partly-commited transaction using innodb tables:
all my tables use innodb as a backend
mysql version: 5.5.31-0ubuntu0.13.04.1-log
python web application based on uwsgi, each http request is wrapped in a separate transaction that is either commited or rolled back depending on whether an exception is generated during the request
each request-serving process uses a single mysql connection that is not shared across processes
a couple of other processes connect to the DB to perform background tasks that are all wrapped in transactions
transactions are all created and tracked through a sqlalchemy middleware which is configured to not change the default mysql isolation level which is REPEATABLE READ
Despite all this (I triple checked each item a couple of times), my DB appears to contain half-commited transactions:
1. 2 tables A and B with A that contains a foreign key to B (there are no constraints defined in the DB)
2. A contains a valid row that points to a non-existent row in B.
3. B contains rows with id + 1 and id - 1.
4. both rows in both tables are inserted within a single transaction
To summarize, I can't see what I could have possibly done wrong. I can't imagine I am hitting a bug in the mysql storage backend so, I am looking for help on how I could debug this further and what assumption I made above is the most likely to be wrong. | mysql transaction commited only partly | 0 | 1 | 0 | 73 |
22,391,805 | 2014-03-13T21:54:00.000 | 0 | 0 | 0 | 1 | python,linux,bash,file-io | 22,392,153 | 4 | false | 0 | 0 | There are various command line applications that would be able to accomplish this when working together. For example, you could cat all the files one after another, grep -v the patterns you don't want, redirecting >> to a new file. In effect this is doing the same thing as your Python script would do, because every line of every file must be copied (except the duplicates). It might be faster than Python, though, because those tools are written in C. | 1 | 0 | 0 | I have a number of huge delimited text files containing information logged by date. Some of the files overlap slightly with each other by date (which I don't want since it leads to duplicates). I know what the overlapping dates are so I want to be able to go through some of the files and delete each of the rows that contains those specified dates.
I know how to do this in python (rewriting each of the lines I want) but because of the size of the files (each is a few GBs) I was wondering if it would be a lot faster to do this through linux?
The text files will be sorted by date, earliest to latest, and the dates I need to delete are always going to be in the beginning of the file so I can search until I hit a row that has a date right after the ones I want to delete and write out the rest of the file to another file (or delete all the contents above). | deleting rows in linux | 0 | 0 | 0 | 115 |
22,393,734 | 2014-03-14T00:17:00.000 | 0 | 0 | 1 | 0 | python,default-programs | 22,394,225 | 1 | true | 0 | 0 | As pointed out by Makoto, this is exactly what you do when you send a person a trojan / virus. In general, files downloaded from the internet are not executed without warnings (jpgs are not executable anyway), and even so, a competent computer user will probably get suspicious.
Having said that, if you are the unstoppable kind and he is a close friend and who trusts you with his computer, I suggest that you recruit another friend to divert your birthday friend away from his computer and run the python script in the background.
It will be sure to surprise him and really freak him out, if its done right. It would be a good april fool's joke too. | 1 | 0 | 0 | My friend's birthday is coming up, so another friend and I are working on a birthday card/prank. We wrote a short Python script that, upon execution, sleeps for a certain amount of time and then launches the virtual birthday card. We want to send our friend a file (say, the day before his birthday), telling him it's a picture of us or something unsuspicious (the filename would of course end in .jpg or something along those lines) but when he opens it, he actually just activates the sleeper (which will then launch the virtual birthday card the next day, or whatever, depending on when we send it) and surprise him on his actual birthday. (He never turns off his computer, so we're not worried about the whole 'sleep' thing.)
So anyway. The trouble is that if we call it filename.jpg, his computer will automatically open it with an image viewer (i.e., Preview if on a Mac). Is it possible for us to programmatically change the default application that attempts to run our program? That is, is it possible for his computer to run the Python file upon him double-clicking (or otherwise attempting to open) the file? | Program that opens with different application than default | 1.2 | 0 | 0 | 59 |
22,394,338 | 2014-03-14T01:19:00.000 | 0 | 0 | 1 | 0 | python,emacs,shortcut,spyder | 24,424,345 | 2 | false | 0 | 0 | I use the File Explorer window in Spyder, I find it really handy. | 1 | 2 | 0 | I was an Emacs user and I used to find and open files with shortcuts Ctrl + x + f
Now my Python IDE is Spyder so I'm wondering if there is an equivalent command?
I have tried Ctrl + N and Ctrl + O but both returns a window which I need to use the mouse to select by clicking on it. | Spyder Shortcuts to find and open file? | 0 | 0 | 0 | 2,666 |
22,395,199 | 2014-03-14T02:46:00.000 | 2 | 1 | 0 | 1 | php,python-2.7,xampp,windows-8.1 | 22,395,764 | 1 | true | 0 | 0 | I have finally figured this out:
I will have to restart the server whenever I add a new cgi script in the server. This worked.
In this case BridgePHP.py | 1 | 2 | 0 | These are the actions that I have taken and I still can't seem to run the script on PHP on my windows 8.1 platform.
Please do note that I have installed Python and have tested it. I am running python 2.7
(1) Step 1: Edited the Apache httpd.conf scripts to run cgi .py scripts
AddHandler cgi-script .cgi .pl .asp .py
(2) Step 2: Added a test script in cgi-bin folder of xampp. It is called
#!/Python27/python
print "Content-type: text/plain\n\n"
print "Hello world"
(3) Step 3: Created a PHP Code called Python.php
$python = exec('python C:\xampp\cgi-bin\BridgePHP.py');
echo "Python is printing: " . $python;
(4) I get the following output in my browser:
Python is printing:
(5) I tested by running using the standard command prompt and the word "Hello World" was printed
I am unsure why php script is unable to run the python script. Is there any other settings that I should do? | Running Python in PHP as a script in XAMPP (WINDOWS 8.1) | 1.2 | 0 | 0 | 3,357 |
22,396,635 | 2014-03-14T05:10:00.000 | 0 | 0 | 0 | 0 | python,sockets,networking | 22,396,729 | 3 | false | 0 | 0 | It sounds like you need to set up port forwarding -- essentially tell your router to forward calls it receives on a specific port to a service that sits behind it.
That's usually done through your router's admin interface. | 1 | 3 | 0 | So for sake of understanding, we're going to assume both machines are on ipv4 and behind NAT networks. I'd like to be able to open a socket on both machines and have the machines connect through those sockets (or a similar system). I know nat punchthrough is required for this, but I'm not sure how nat punchtrough applies (can a socket that was once connecting now be accepting?) Anyone who has worked with nat punchthrough in python I would really appreciate the help. | Python P2P Networking (NAT Punchtrough) | 0 | 0 | 1 | 3,618 |
22,399,825 | 2014-03-14T08:36:00.000 | 3 | 0 | 0 | 0 | python,mysql | 22,399,907 | 2 | true | 0 | 0 | You can use connection.insert_id() | 2 | 3 | 0 | I am using MySQLdb in python 3 to insert multiple rows using executemany.
Now I need to get the primary keys after the multi insert..
Is there any way to get them? | Get primary keys inserted after executemany | 1.2 | 1 | 0 | 591 |
22,399,825 | 2014-03-14T08:36:00.000 | 1 | 0 | 0 | 0 | python,mysql | 22,399,968 | 2 | false | 0 | 0 | When you use executemany you insert multiple rows at a time. You will get first inserted rows primery key using connection.inster_id()
To get all inserted ids, you have to run another query. | 2 | 3 | 0 | I am using MySQLdb in python 3 to insert multiple rows using executemany.
Now I need to get the primary keys after the multi insert..
Is there any way to get them? | Get primary keys inserted after executemany | 0.099668 | 1 | 0 | 591 |
22,401,722 | 2014-03-14T10:01:00.000 | 0 | 0 | 0 | 0 | python,django,django-models,django-fixtures | 22,408,947 | 1 | false | 1 | 0 | The answer to your top question is yes, you should be able to use the Django test framework pieces that don't depend on models.
The answer to your inner question about using fixtures (which sounds like it may be the real question) is, not without writing some additional test code. Django uses fixtures to populate Django models, and you don't have any Django models.
So, write your tests using django.utils.unittest and deal with the fixture loading there. | 1 | 2 | 0 | my problem is that. this is a old django project that I need to work on it.
As unknown reason, the project don't use django model. Instead, it define some class to CRUD the database by pure sql. and the project has no tests at all.
now, I want to add unittest for the project(views/models/and so on).but I wonder if this test can use fixture without model define?
I don't have so much time to test this by my hand. So is there any one knows about this? | can I run django test but with out model define? | 0 | 0 | 0 | 113 |
22,402,964 | 2014-03-14T10:51:00.000 | 0 | 0 | 1 | 0 | python-2.7,cpu,cpu-usage,temperature | 22,403,079 | 1 | false | 0 | 0 | The psutil library will give you some system information (CPU / Memory usage) on a variety of platforms. psutil is a module providing an interface for retrieving information on running processes and system utilization (CPU, memory) in a portable way by using Python, implementing many functionalities offered by tools like ps, top and Windows task manager
It currently supports Linux, OS X, FreeBSD and Windows with Python versions from 2.4 to 3.1 by using a unique code base. | 1 | 1 | 0 | I want to start work on a project but I need help monitoring the CPU core usage and temperatures with python.
Any Help will be greatly appreciated.
Using Python 2.7, Windows 8 | Python - Read system information (CPU core usage and temperatures) | 0 | 0 | 0 | 887 |
22,404,358 | 2014-03-14T11:58:00.000 | 2 | 0 | 0 | 0 | javascript,python,angularjs,google-app-engine,jinja2 | 22,408,064 | 2 | false | 1 | 0 | Since you are already going to build an Angular app for the front-end, why not make the whole architecture RESTful? That way the front-end Angular app will be in charge of presentation and the server of just the data. You can pass data between the server and front-end through JSON which has the benefit of not needing to deal with html or templates in the back end? Angular already has Service and $http that can abstract away the two-way data binding, and using webapp2's RESTful nature you can make this happen fairly painlessly. | 1 | 0 | 0 | I am programming a small web app on GAE using python webapp2 framework.
What I want to achieve is displaying server data to the html view through javascript or angularjs. Actually the app draws some graph using d3.js based on the server data. I know I can use $http.get to retrieve the data from server. But this way I need to create another page or handler. I am wondering if there is some way which I can do the below actions.
On the server python handler, retrieve the stored data, then passing to the jinja2 template values. Render the html.
Display some of the data on the html view via jinja2 template values.
(The missing part) How to pass the data to js from the python handler? Or how to pass the data to js from html view? I know two ways from the html view. One is using embedded javascript code.
var data = {{serverData}};
The other is using hidden input form with angular data bind. Both of them not so nicely.
4.Compute the data and draw back to the view using d3js or other js lib.
Any idea about this? I reckon there might be some angular way to do this beautifully but didnt figure out. | How to transfer html view data or (Python) server data to Angular or Javascript? | 0.197375 | 0 | 0 | 586 |
22,407,628 | 2014-03-14T14:20:00.000 | 0 | 0 | 0 | 0 | javascript,python,forms,web | 22,408,435 | 1 | true | 1 | 0 | Yea. Reverse engineer the javascript using the chrome/firefox console, see what request it makes and mimic them in python using urllib2 or the requests library. | 1 | 0 | 0 | I'm going to have to code a program in python that retrieves results after filling a web form (which in turn calls different javascript functions), and those results appear in a different frame of the website. I considered using the Selenium web engine, but I was wondering if anyone has any better idea?
Thank you
Daniel | How do I fill a form in a web site that calls javascript code and retrieve the results from a different frame using python? | 1.2 | 0 | 1 | 41 |
22,408,098 | 2014-03-14T14:39:00.000 | 0 | 0 | 1 | 0 | python,exception-handling | 22,408,262 | 5 | false | 0 | 0 | Aside from that why would you ever want just an except: clause?
Short answer: You don't want that.
Longer answer: Using a bare except: takes away the ability to distinguish between exceptions, and even getting a hand on the exception object is a bit harder. So you normally always use the form except ExceptionType as e:. | 2 | 4 | 0 | In python is it true that except Exception as ex or except BaseException as ex is the the same as except: but you get a reference to the exception?
From what I understand BaseException is the newer default catch-all.
Aside from that why would you ever want just an except: clause? | In python why ever use except: | 0 | 0 | 0 | 1,962 |
22,408,098 | 2014-03-14T14:39:00.000 | 3 | 0 | 1 | 0 | python,exception-handling | 22,408,172 | 5 | false | 0 | 0 | If you truly do not care what the reason or message of the failure was, you can use a bare except:. Sometimes this is useful if you are trying to access some functionality which may or may not be present or working, and if it fails you plan to degrade gracefully to some other code path. In that case, what the error type or string was does not affect what you're going to do. | 2 | 4 | 0 | In python is it true that except Exception as ex or except BaseException as ex is the the same as except: but you get a reference to the exception?
From what I understand BaseException is the newer default catch-all.
Aside from that why would you ever want just an except: clause? | In python why ever use except: | 0.119427 | 0 | 0 | 1,962 |
22,410,923 | 2014-03-14T16:40:00.000 | 0 | 1 | 1 | 0 | python,module,packages,python-module | 22,411,037 | 1 | true | 0 | 0 | For readability purposes it would be better to import each one in every file. So as you said it would make no sense with those files coming from no where. So for the purpose of readability it would be much, much better to import each one in every file. I could share some examples if you would like.
Cheers! | 1 | 0 | 0 | I have a project where I have to import a bunch of modules everytime I want to run some code. In order to avoid writing these over every time I create a new file, I created a sort of setup script that imports all of these, and then I just import * from that startup script. Is this stylistically ok? I could see why this would be confusing, when I reference modules/classes that can't be seen on import.... on the other hand, it saves time and space by not writing out the setup each time. What method should I do? | Should I create a file with all my module imports and then import * from that, or should I import the modules to each file I use? | 1.2 | 0 | 0 | 35 |
22,412,053 | 2014-03-14T17:37:00.000 | 1 | 0 | 1 | 0 | python,django,pip,easy-install,django-oscar | 22,425,918 | 1 | true | 1 | 0 | This isn't really what pip was designed to do. You should post your version of django-oscar to github, then reference that in your pip requirements.txt
Or if you don't want to have it hosted remote you might as well just include it in your project directory as you would a Django app you are making. | 1 | 0 | 0 | I have some django packages like django-oscar. I need to install it with pip and then edit code & revise.
I'm tried to install it through setup.py deploy and to make .egg-info. Then I understand that pip doesn't have feature to install packages through .egg-info.
I also tried to install package from local directory using -e /path/to/package, but pip doesn't allow me install from directory. It message me: --editable=src/django-oscar-master/oscar/ should be formatted with svn+URL, git+URL, hg+URL or bzr+URL
Then I'm tried to install through pip install django-oscar --no-index --find-links=file://src/django-oscar-master/ and similar commands. It always message me: Could not find any downloads that satisfy the requirement django-oscar
How to install package not in site-packages of virtualenv and put command in requirements.txt that will install this package from local dir? | How to install package not in site-packages of virtualenv and put command in requirements.txt that will install this package from local dir? | 1.2 | 0 | 0 | 275 |
22,413,513 | 2014-03-14T18:57:00.000 | 0 | 0 | 0 | 0 | javascript,python,html,flask | 22,413,574 | 2 | false | 1 | 0 | There is many ways to do this
Here is the easiest 3
Use JavaScript
2 install wampserver or similar and use php o modify the file
3 don't use te browser to delete and instead use a bat file to open the browser and remove the link from the text file | 1 | 0 | 0 | I've generated an HTML file that sits on my local disk, and which I can access through my browser. The HTML file is basically a list of links to external websites. The HTML file is generated from a local text file, which is itself a list of links to the remote sites.
When I click on one of the links in the HTML document, as well the browser loading the relevant site (in a new tab), I want to remove the site from the list of sites in the local text file.
I've looked at Javascript, Flask (Python), and CherryPy (Python), but I'm not sure these are valid solutions.
Could someone advise on where I should look next? I'd prefer to do this with Python somehow - because it's what I'm familar with - but I'm open to anything.
Note that I'm running on a Linux box. | How to manipulate a local text file from an HTML page | 0 | 0 | 1 | 994 |
22,413,763 | 2014-03-14T19:10:00.000 | -1 | 0 | 1 | 0 | python,regex,expression | 22,430,200 | 6 | false | 0 | 0 | So I was actually able to get it to work like this : [a-z]\w+. | 2 | 0 | 0 | I'd like to combine the regular expressions \w+ and [a-z] together in Python to only accept a word that is all lowercase, but cannot seem to figure out the right way to do that. Does anyone know how? | Combining regular expressions in Python | -0.033321 | 0 | 0 | 449 |
22,413,763 | 2014-03-14T19:10:00.000 | 1 | 0 | 1 | 0 | python,regex,expression | 22,413,846 | 6 | true | 0 | 0 | If you only want lowercase words, all you need is [a-z]+
\w includes uppercase letters, digits, and underscore | 2 | 0 | 0 | I'd like to combine the regular expressions \w+ and [a-z] together in Python to only accept a word that is all lowercase, but cannot seem to figure out the right way to do that. Does anyone know how? | Combining regular expressions in Python | 1.2 | 0 | 0 | 449 |
22,418,958 | 2014-03-15T02:54:00.000 | 1 | 0 | 0 | 0 | python,scikit-learn,random-forest | 22,419,620 | 1 | false | 0 | 0 | I believe RandomForestClassier will use the entire training set to build each tree. Typically building each tree involves selecting the features which have the most predictive power(the ones which create the largest 'split'), and having more data makes computing that more accurate. | 1 | 3 | 1 | In scikit-learn's RandomForestClassifier, there is no setting to specify how many samples each tree should be built from. That is, how big the subsets should be that are randomly pulled from the data to build each tree.
I'm having trouble finding how many samples scikit-learn pulls by default. Does anyone know? | Scikit-learn, random forests - How many samples does each tree contain? | 0.197375 | 0 | 0 | 280 |
22,419,345 | 2014-03-15T03:59:00.000 | 1 | 0 | 0 | 0 | python,wxpython,wxwidgets | 22,424,553 | 1 | true | 0 | 1 | It is possible to paste it in, but this is obviously not user friendly. I'd use a custom dialog with the predefined choices (e.g. radio buttons) for TAB, comma, semicolon etc and a text control for a custom separator entry. | 1 | 0 | 0 | Is there a way to allow wxTextEntryDialogs to accept the tab character? I'm using wxPython and would like to accept tabs so that I can ask the user for the delimiter used in a text file. | wxTextEntryDialog with Tabs | 1.2 | 0 | 0 | 65 |
22,419,455 | 2014-03-15T04:18:00.000 | 1 | 0 | 0 | 0 | python,algorithm | 22,420,037 | 3 | false | 0 | 0 | Why not use score(weight) to mark those?
The idea is assign score for each type of card and calculate them for comparison.
Eg.
Assume cards from [3,4,5,...,J,Q,K,A,2] from small to big.
Then you can assign score for it, like [1,10,100,1000...].
And Spade>Heart>Club>Diamond, assign score for it too, like Spade is 4, Heart is 3, Club is 2, Diamond is 1.
So when you get two cards:
Spade 3 and Diamond 4, you get score 1+4=5 for Spade 3 and 10+1 = 11 for Diamond4, therefor Diamond 4 > Spade 3.
Or
Spade 3 and Club 3, you get 5 for Spade 3 and 1+2 = 3 for Club 4, therefor Spade 3 > Club 3. | 2 | 1 | 0 | I'd like to made a new poker game invent by myself.
In which I need to compare the value of the poker cards.
In this game, Spade>Heart>Club>Diamond(Relation passable, ex:Spade>Club,Heart>Diaomd), with a special rule that Diamond trumps Spade(but still weaker than Heart and Club).
I'd like to use S,H,C,D as head rather than a,b,c,d.
So far there are two players need to compare their card, if their card have same head, then the one with greater number value(represent A to K) wins.
But for me, I've only figure out a clumsy way to realize this comparison. That's to exhaust the possibility.
Like:
If A's card is S, what to do if B's card is S,H,C,D
If A's card is H, what to do if B's card is S,H,C,D
If A's card is C, what to do if B's card is S,H,C,D
If A's card is D, what to do if B's card is S,H,C,D
Thus I need to do almost 16 times of comparison. Though I've figured out that I can do the same comparison with all equal colors like S vs S, D vs D, still I need to do 13 times of comparison.
Is there a better way to do this comparison, or this is already the best way? | Is there a simpler way to compare cards where one suite trumps another? | 0.066568 | 0 | 0 | 203 |
22,419,455 | 2014-03-15T04:18:00.000 | 1 | 0 | 0 | 0 | python,algorithm | 22,419,717 | 3 | false | 0 | 0 | I'm not sure if you need to do 16 comparisons.
Let's see if I got this straight:
Assuming there are just two players as you indicated above AND a and b are equal in numeric value...
Let's see...You could write your control statements in this order:
Suits are identical, it's a TIE.
A is a spade, B is a diamond, A LOSES.
A is a spade, A WINS
first and second if statements are false
A is a diamond AND B is a spade, A WINS, else A LOSES.
diamonds lose to non-spades
A is a heart AND B is a club OR A is a heart AND B is a diamond, A WINS.
A is a club AND B is a diamond, A WINS.
only way a club wins
Else, A LOSES.
hearts lose to spades
clubs lose to hearts and spades
diamonds were covered in covered in the 4th if/else condition.
Is that it?
Am I forgetting any others? | 2 | 1 | 0 | I'd like to made a new poker game invent by myself.
In which I need to compare the value of the poker cards.
In this game, Spade>Heart>Club>Diamond(Relation passable, ex:Spade>Club,Heart>Diaomd), with a special rule that Diamond trumps Spade(but still weaker than Heart and Club).
I'd like to use S,H,C,D as head rather than a,b,c,d.
So far there are two players need to compare their card, if their card have same head, then the one with greater number value(represent A to K) wins.
But for me, I've only figure out a clumsy way to realize this comparison. That's to exhaust the possibility.
Like:
If A's card is S, what to do if B's card is S,H,C,D
If A's card is H, what to do if B's card is S,H,C,D
If A's card is C, what to do if B's card is S,H,C,D
If A's card is D, what to do if B's card is S,H,C,D
Thus I need to do almost 16 times of comparison. Though I've figured out that I can do the same comparison with all equal colors like S vs S, D vs D, still I need to do 13 times of comparison.
Is there a better way to do this comparison, or this is already the best way? | Is there a simpler way to compare cards where one suite trumps another? | 0.066568 | 0 | 0 | 203 |
22,419,733 | 2014-03-15T04:57:00.000 | 0 | 0 | 0 | 0 | python,openerp,invoice,erp | 22,589,593 | 1 | false | 1 | 0 | you have to override a create method in Invoice Model | 1 | 0 | 0 | How to make multiple invoices on a sale order when it contains products from different companies? My configuration is: - Main Company has: sub company 1, sub company 2. These companies has many products. I wish make multiple invoices when I create a sale order if it contains products from different companies. For example: Sale order contains: - Product A: sub company 1. - Product B: sub company 2. This sale order should make two invoices but in one sale order. It is like group by order lines by company from product.
I use OpenERP 7 2014-March. | OpenERP. How to make multiple invoices on a sale order when it contains products from different companies? | 0 | 0 | 0 | 632 |
22,423,750 | 2014-03-15T12:22:00.000 | 3 | 0 | 1 | 0 | python,multithreading,python-multithreading,thread-local-storage | 22,620,970 | 1 | true | 0 | 0 | In threading.Thread(target=x), is x shared or private?
It is private. Each thread has its own private invocation of x.
This is similar to recursion, for example (regardless of multithreading). If x calls itself, each invocation of x gets its own "private" frame, with its own private local variables.
What is the preferred way to pass mutable variables to threads? Do I have to subclass Thread to update data?
I view the target argument as a quick shortcut, good for quick experiments, but not much else. Using it where it ought not be used leads to all the limitations you describe in your question (and the hacks you describe in the possible solutions you contemplate).
Most of the time, you'd want to subclass threading.Thread. The code creating/managing the threads would pass all mutable shared objects to your thread-classes' __init__, and they should keep those objects as their attributes, and access them when running (within their run method).
When do I need threading.local()?
You rarely do, so you probably don't.
I'd like to avoid _thread if possible to be pythonic
Without a doubt, avoid it. | 1 | 4 | 0 | I'm having a hard time wrapping my head around Python threading, especially since the documentation explicitly tells you to RTFS at some points, instead of kindly including the relevant info. I'll admit I don't feel qualified to read the threading module. I've seen lots of dirt-simple examples, but they all use global variables, which is offensive and makes me wonder if anyone really knows when or where it's required to use them as opposed to just convenient.
In particular, I'd like to know:
In threading.Thread(target=x), is x shared or private? Does each thread have its own stack, or are all threads using the same context simultaneously?
What is the preferred way to pass mutable variables to threads? Immutable ones are obviously through Thread(args=[],kwargs={}) and that's what all the examples cover. If it's global, I'll have to hold my nose and use it, but it seems like there has to be a better way. I suppose I could wrap everything in a class and just pass the instance in, but it'd be nice to point at regular variables, too.
When do I need threading.local()? In the x above?
Do I have to subclass Thread to update data, as many examples show?
I'm used to Win32 threads and pthreads, where it's explicitly laid out in docs what is and isn't shared with different uses of threads. Those are pretty low-level, and I'd like to avoid _thread if possible to be pythonic.
I'm not sure if it's relevant, but I'm trying to thread OpenMP-style to get the hang of it - make a for loop run concurrently using a queue and some threads. It was easy with globals and locks, but now I'd like to nail down scopes for better lock use. | What is and isn't automatically thread-local in Python Threading? | 1.2 | 0 | 0 | 590 |
22,425,631 | 2014-03-15T15:19:00.000 | 0 | 0 | 0 | 0 | python,iphone,nscache,memory-optimization | 22,482,214 | 1 | false | 1 | 0 | Maybe you should use NSData to retrieve data from your service instead of NSCache.
NSCache is for temporary objects, however NSData is used to move data between applications (from your service to your app)
Description of NSCache by Apple:
An NSCache object is a collection-like container, or cache, that stores key-value pairs, similar to the NSDictionary class. Developers often incorporate caches to temporarily store objects with transient data that are expensive to create. Reusing these objects can provide performance benefits, because their values do not have to be recalculated. However, the objects are not critical to the application and can be discarded if memory is tight. If discarded, their values will have to be recomputed again when needed.
Description of NSData by Apple:
*NSData and its mutable subclass NSMutableData provide data objects, object-oriented wrappers for byte buffers. Data objects let simple allocated buffers (that is, data with no embedded pointers) take on the behavior of Foundation objects.
NSData creates static data objects, and NSMutableData creates dynamic data objects. NSData and NSMutableData are typically used for data storage and are also useful in Distributed Objects applications, where data contained in data objects can be copied or moved between applications.* | 1 | 1 | 0 | My service return up to 500 objects at time i've notice that my iphone application is crashing when the amount of data goes over 60 objects. to workaround this issue I'm running a query that brings back only the top 40 results but that is slower than just returning the entire data
what are the best practices and how can i retrieve more objects?
what is the maximum amount of memory allocated to an application in iphone and is there a way to extend it?
How many objects should I retrieve from server
How many can be stored in NSCache? | How many objects should I retrieve from server and How many can be stored in NSCache? | 0 | 0 | 0 | 54 |
22,426,005 | 2014-03-15T15:48:00.000 | 1 | 0 | 0 | 0 | python,d3.js,local | 22,430,282 | 1 | false | 1 | 0 | The SimpleHTTPServer module will only serve things that are within the directory you're telling it to serve and folders beneath that directory, for security reasons. (Otherwise a visitor could ask it for e.g. ../../../../etc/passwd or similar.)
If you want to serve scripts and other assets, you'll need to put them in a subfolder of the directory you're running SimpleHTTPServer in. | 1 | 1 | 0 | I'm currently running an html and jsp file locally and hosting it by running this command through the terminal: python -m SimpleHTTPServer 8888 &.
This has been going smoothly, but I recently ran into an issue where I have to include library files (d3, jQuery, ajax, etc.)
I've included the following command in my html file <script src="../libs/d3.v3.min.js">
but noticed that it was pulling up a 404 error. I've tried to remedy it with a change in script to : <script src="http://d3js.org/d3.v3.min.js">.
But I actually feel that it doesn't go to the root of the problem. Why am I unable to include the files I have in my lib?
Edited wording to question thanks for the heads up Amber: The lib file is located one directory up from the html file. | How to include libraries through the python local server | 0.197375 | 0 | 1 | 197 |
22,430,150 | 2014-03-15T21:44:00.000 | 0 | 1 | 1 | 0 | python,git,pypi | 22,455,499 | 1 | true | 0 | 0 | Could not figure out the issue with distutils. Switched to setuptools and everything is working correctly, no tests.py being added to the tarball. | 1 | 0 | 0 | For some reason, every time I upload my package to PyPI, it includes a tests.py file that:
Isn't tracked in git
Isn't even in the project directory anymore
Isn't added to the /dist tarball after running sdist
Isn't in the tarball hosted on Github
Isn't in MANIFEST
Where is it picking this file up from? It was part of my package during development but I've done everything I can to remove it before publishing - and it still shows up. | PyPI tarball includes files that aren't in the dist package | 1.2 | 0 | 0 | 56 |
22,432,826 | 2014-03-16T04:05:00.000 | 0 | 0 | 0 | 0 | python,nginx,flask,uwsgi | 22,432,964 | 3 | false | 1 | 0 | What you are asking for is not "best practices", but "conventions". No, there are no conventions in the project about paths, privileges and so on. Each sysadmin (or developer) has its needs and tastes, so if you are satisfied with your current setup... well "mission accomplished". There are no uWSGI gods to make happy :) Obviously distro-supplied packages must have their conventions, but again they are different from distro to distro. | 1 | 7 | 0 | I'm trying to set up my first web server using the combination of Flask, uWSGI, and nginx. I've had some success getting the Flask & uWSGI components running. I've also gotten many tips from various blogs on how to set this up. However, there is no consistency and the articles suggest many different ways of setting this up especially where folder structures, nginx configurations and users/permissions are concerned (I've tried some of these suggestions and many do work, but I am not sure which is best). So is there one basic "best practice" way of setting up this stack? | Best practice for setting up Flask+uWSGI+nginx | 0 | 0 | 0 | 3,061 |
22,434,131 | 2014-03-16T07:22:00.000 | 2 | 0 | 1 | 0 | python,subprocess | 22,434,681 | 2 | true | 0 | 0 | From what you've described, you want the "worker", which may crash and be restarted, to publish some dictionary of data to the "web server." I think the easiest way to do this is to simply have the web server accept incoming messages from the worker via HTTP PUT. You can encode the worker's dict as JSON and put that in the HTTP body. This makes use of the protocols you are likely already using, and avoids having to coordinate restarts of the worker to rediscover it when its PID changes.
Of course, if the server hasn't seen an update after a certain amount of time, it can consider the worker to be dead. It may even be able to subsume the watchdog functionality therefore. | 1 | 0 | 0 | Is it possible to use 'multiprocessing' communication to a process that I didn't spawn?
The 'multiprocessing' module looks ideal for my needs, but in all the examples one process spawns the other. How can I get a 'handle' on the process I want to communicate with if I didn't spawn it?
Background Information
There are three processes in total - all Python 2.7 - a worker, a watchdog, and a web server.
The worker is a long-running test system. I want the web server to be able to query the worker to see how it is progressing. As the worker may often crash, a watchdog process restarts it from time to time (and hence it will have a new PID).
I have access to the source of the worker and the watchdog, but I want to modify those as little as possible.
My idea is to have the web server query the worker periodically and share, say, a dict. | Communicating between Pre-Existing Python Processes using Multiprocessing | 1.2 | 0 | 0 | 283 |
22,435,352 | 2014-03-16T09:50:00.000 | 0 | 0 | 1 | 0 | python,c,multithreading,gil | 22,435,597 | 2 | false | 0 | 1 | If your main requirement is to have several interpreters independent from each other, you'd probably better suited doing fork() and exec() than doing multithreading.
This way each of the interpreters would live in it's own address space not disturbing one of the others. | 1 | 2 | 0 | I have a really specific need :
I want to create a python console with a Qt Widget, and to be able to have several independent interpreters.
Now let me try to explain where are my problems and all tries I did, in order of the ones I'd most like to make working to those I can use by default
The first point is that all functions in the Python C API (PyRun[...], PyEval[...] ...) need the GIL locked, that forbid any concurrent code interpretations from C ( or I'd be really glad to be wrong !!! :D )
Therefore, I tried another approach than the "usual way" : I made a loop in python that call read() on my special file and eval the result. This function (implemented as a built extension) blocks until there is data to read. (Actually, it's currently a while in C code rather than a pthread based condition)
Then, with PyRun_simpleString(), I launch my loop in another thread. This is where the problem is : my read function, in addition to block the current thread (that is totally normal), it blocks the whole interpreter, and PyRun_simpleString() doesn't return...
Finally I've this last idea which risks to be relatively slow : To have a dedicated thread in C++ which run the interpreter, and do every thing in python to manage input/output. This could be a loop which creates the jobs when there is a console needing to execute a command. Seems not to be really hard to do, but I prefer ask you : is there a way to make the above possibilities to work, or is there another way I didn't think about or is my last idea the best ? | Python & C/C++ multithreading : run several threads executing python in the background of C | 0 | 0 | 0 | 1,118 |
22,435,753 | 2014-03-16T10:34:00.000 | 1 | 1 | 0 | 0 | python,midi,synthesizer,fluidsynth | 22,449,199 | 1 | true | 1 | 0 | In MIDI if you send a note on message it stays on until you send a note off. Maybe you are sending a note on every time you check the state of the button? If so, you shouldn't, send the note on/note off only when the button state changes. | 1 | 0 | 0 | I'm working on a Raspberry Pi project at the moment and I'm searching for a possibility to play a note as long as ey press a button (connected with gpio).
I use pyFluidsynth and got it working but it's note holding a note as long as i press a button, it repeats it really fast but to slow not to hear it.
Is there any control I don't know? I'm just using noteon and noteoff, is there maybe something like "notehold"?
thanks! | How to play a note as long as I hit the key (Fluidsynth)? | 1.2 | 0 | 0 | 317 |
22,436,119 | 2014-03-16T11:17:00.000 | 0 | 0 | 0 | 0 | python,scapy,icmp,tunneling | 22,436,235 | 2 | false | 0 | 0 | I think you've discovered why the inventors of the Internet developed TCP. There's a limit on the payload size in an ICMP packet. Most networks have a 1500-byte total limit on the size of Ethernet packets, so with a 20-byte IP header and an 8-byte ICMP header, your maximum payload size in a single packet will be 1472 octets. That's not enough for many image files.
You need a way of breaking up your image data stream into chunks of about that size, sending them in multiple ICMP packets, and reassembling them into a data stream on the receiver.
Considering that there's no guarantee ICMP packets are received in order, and indeed no guarantee that they'll all be received in order, you will need to put some kind of sequence number into the the individual packets, so you can reassembly them in order. You also may need some timeout logic so your receiving machine can figure out that a packet was lost and so the image will never be completed.
RTP and TCP are two protocols layered on IP that do that. They are documented in precise detail, and you can learn from those documents how to do what you're trying to do and some of the pitfalls and performance implications. | 1 | 0 | 0 | I am using scapy to send data over ICMP. I need to send image and other files over ICMP using scapy. I am able to send simple strings in ICMP. How could I send image and other files ? | How to send an image in ICMP data field using ICMP | 0 | 0 | 1 | 2,190 |
22,436,515 | 2014-03-16T11:55:00.000 | 1 | 0 | 0 | 0 | python,r,hdf5,statistics,h5py | 22,436,696 | 1 | false | 0 | 0 | Is there a way to convert the data without losing any information?
If the HDF5 data is regular enough, you can just load it in Python or R and save it out again as CSV (or even SPSS .sav format if you're a bit more adventurous and/or care about performance).
Why doesn't SPSS support h5 anyway?
Who knows. It probably should. Oh well.
Do you think it is worthwhile to learn programming in R?
If you find SPSS useful, you may also find R useful. Since you mentioned Python, you may find that useful too, but it's more of a general-purpose language: more flexible, but less focused on math and stats.
Would R give me the same arsenal of methods as I have in SPSS?
Probably, depending on exactly what you're doing. R has most stuff for math and stats, including some fairly esoteric and/or new algorithms in installable packages. It has a few things Python doesn't have (yet), but Python also covers most of the bases for many users. | 1 | 0 | 1 | I have two sets of data in separated .h5 files (Hierarchical Data Format 5, HDF5), obtained with python scripts, and I would like to perform statistical analysis to find correlations between them. My experience here is limited; I don't know any R.
I would like to load the data into SPSS, but SPSS doesn't seem to support .h5. What would be the best way to go here? I can write everything to a .csv file, but I would loose the names of the variables. Is there a way to convert the data without loosing any information? And why doesn't SPSS support h5 anyway?
I am aware of the existence of the Rpy module. Do you think it is worthwhile to learn programming in R? Would this give me the same arsenal of methods as I have in SPSS?
Thank you for your input! | Statistical analysis of .h5 files (SPSS?) | 0.197375 | 0 | 0 | 398 |
22,437,058 | 2014-03-16T12:51:00.000 | 2 | 0 | 0 | 0 | java,python,json,cassandra,cassandra-cli | 22,519,952 | 1 | false | 0 | 0 | If you don't need to be able to query individual items from the json structure, just store the whole serialized string into one column.
If you do need to be able to query individual items, I suggest using one of the collection types: list, set, or map. As far as typing goes, I would leave the value as text or blob and rely on json to handle the typing. In other words, json encode the values before inserting and then json decode the values when reading. | 1 | 1 | 1 | I have list of nested Json objects which I want to save into cassandra (1.2.15).
However the constraint I have is that I do not know the column family's column data types before hand i.e each Json object has got a different structure with fields of different datatypes.
So I am planning to use dynamic composite type for creating a column family.
So I would like to know if there is an API or suggest some ideas on how to save such Json object list into cassandra.
Thanks | Import nested Json into cassandra | 0.379949 | 1 | 0 | 1,459 |
22,438,569 | 2014-03-16T15:06:00.000 | 1 | 0 | 0 | 0 | algorithm,python-3.x,message-passing | 22,452,071 | 1 | false | 0 | 1 | The issue is trying to give an absolute value to the priority. Rather you need to build a relative priority data structure for each call. This way you can say that hit() is highest priority for super-shields then shields then hull. The mod would then simply need to change the hit sound effects for the hull or add an additional sound effect to be played as well.
The most straightforward way to go about it would requiring that any new object's priority for a given call be linked to another object with that call. It then requires selecting if the new object's priority is lower or higher. So shields and hull are linked (hull < shields) and super-shields and shields are linked (shields < super-shields). That information would make it fairly easy to build a 2D multiple items (2D to have allow for same priority) linked list that holds the priorities for each call. Thus the register function might look like this, "myship.register("hit",shields,"lower",super-shields)" and give shields a lower priority than super-shields. You could allow for additional conditions such as myship.register("hit",hull,"lower",shields,"lower",super-shields) if you already had the hull and super-shields, and wanted to add shields between them. However, then you run the risk of having to deal with contradictions or violating the conditions. | 1 | 0 | 0 | I'm writing a prototype for the tactical spaceship combat in a game I'm working on.
The basic idea of the part I'm working on right now is that a 'ship' object (which represents a single individual ship) contains a list of 'system' objects. When a ship is first initialized, it calls an initialize() function on each of its systems (which is not the same as the standard __init__ function called whenever an instance of an object is made) that will (among other things) call a register() function on the ship the system is a part of.
That register() function takes a string as a parameter, which is the name of a function that the system expects to be called on the ship object. Whenever that function is called on the ship object, the ship object will call it on all systems that registered to receive it until either one of them returns True (indicating that the system 'dealt with' the action in a final manner) or it runs out of systems that have signed up to receive the call. So far so good.
However, some systems might want to get their calls before other systems do. For example, your hull system will want to be the last system to receive a hit(); the shields will want to hear it first. The simplest solution might be to implement a priority system: the shields will call myship.register("hit",priority=1), and the hull will call myship.register("hit",priority=0).
But now we imagine that there ought to be "super-shields" that intercept the hit before the main shields take it. Simple enough: give them priority 2. This might get annoying for the developer if a whole lot of systems want to take a certain request, but he can manage it.
However, this game is intended to be highly user-extensible. If someone releases an addon that (for a stupid example) plays Full Metal Jacket sound clips every time the player's ship is hit, the developer of that addon might not be aware of the addon that adds the "super-shields", and give his Annoying Drill Sergeant system the same or lower priority as the super-shields, and thus may not receive hit messages before they are acknowledged by the super-shield. This is, of course, undesirable behavior.
Does anyone have any ideas as to how to avoid this problem?
Others have suggested having a way a system can request the priority level one higher than or one lower than the highest/lowest current priority level, but that causes largely undefined behavior, since the priority levels would be based on the order in which the systems are initialized.
I've also considered adding a "super-priority", where a system always receives the message before other systems but cannot acknowledge and stop it. This would be only a partial solution though; it'd fix the given example, but not a situation where there are super-shields layered under super-super-shields that need to block the message. | Algorithm design for systems on a spaceship taking messages | 0.197375 | 0 | 0 | 112 |
22,438,807 | 2014-03-16T15:27:00.000 | 1 | 1 | 1 | 0 | python,exception,cgi | 22,439,025 | 1 | false | 0 | 0 | Any unhandled exception causes program to terminate.
That means if your program is doing some thing and exception occurs it will shutdown in an unclean fashion without releasing resources.
Any ways CGI is obsolete use Django, Flask, Web2py or something. | 1 | 1 | 0 | I have a python CGI script that takes several query strings as arguments.
The query strings are generated by another script, so there is little possibility to get illegal arguments,
unless some "naughty" user changes them intentionally.
A illegal argument may throw a exception (e.g. int() function get non-numerical inputs),
but does it make sense to write some codes to catch such rare errors? Any security risk or performance penalty if not caught?
I know the page may go ugly if exceptions are not nicely handled, but a naughty user deserves it, right? | What is the risk of not catching exceptions in a CGI script | 0.197375 | 0 | 0 | 54 |
22,439,542 | 2014-03-16T16:29:00.000 | 5 | 0 | 1 | 0 | python,palindrome | 22,439,567 | 2 | false | 0 | 0 | Let's assume n is even. Generate every string of length n/2 that consists of x and y, and append its mirror image to get a palindrome.
Exercise 1: prove that this generates all palindromes of length n.
Exercise 2: figure out what to do when n is odd. | 1 | 3 | 0 | is there any patterns i can use to sort out how to create a string that is palindrome which made up with 'X' 'Y' | How to generate a list of palindromes with only 'x','y' and a given length n in Python? | 0.462117 | 0 | 0 | 1,191 |
22,440,743 | 2014-03-16T18:09:00.000 | 2 | 0 | 0 | 0 | python,opengl,pygame,pixels | 22,441,324 | 1 | false | 0 | 1 | What you are asking for seems to be two things in one... you want an off-screen buffer (FBO) and you want to get the contents of the framebuffer in client memory.
Can you indicate which version of GL you are targeting?
If you are targeting OpenGL 3.0+, then you can use FBOs (Framebuffer Objects) and PBOs (Pixel Buffer Objects) to do this efficiently. However, since you are using glVertex, I do not think you need to bother with efficiency. I would focus on learning to use Framebuffer Objects for the time being.
If you are not using GL3 you might have access to the old EXT FBO extension, but if you do not have that even you might need a PBuffer.
Note that PBuffers and Pixel Buffer Objects are two different things even though they sound the same. Before GL3/FBOs, WGL, GLX, etc. had special platform-specific functionality called Pixel Buffers for drawing off-screen. | 1 | 0 | 0 | Is there a way to use OpenGL to draw offscreen? What I want to do is this: I want to be able to use functions like glVertex, and get the result in a 2D pixel array.
I am using Python. I tried using PyGame, but it's not working very well. The problem with PyGame is that uses a window event though i don't need it. In addition, I had to draw to scene + flip the screen twice in order to access screen pixels using glReadPixels.
An other problem is that I can't have more that one window at once.
Is there any proper way to accomplish what I am trying to do? | Draw with OpenGL offscreen | 0.379949 | 0 | 0 | 587 |
22,440,923 | 2014-03-16T18:23:00.000 | 1 | 0 | 0 | 0 | python,arrays,numpy | 22,440,992 | 2 | false | 0 | 0 | If you're willing to accept probabilistic times and you have fewer than 50% ignored values, you can just retry until you have an acceptable value.
If you can't, you're going to have to go over the entire array at least once to know which values to ignore, but that takes n memory. | 1 | 2 | 1 | I'm using python.
I have what might be an easy question, though I can't see it.
If I have an array x = array([1.0,0.0,1.5,0.0,6.0]) and y = array([1,2,3,4,5])
I'm looking for an efficient way to pick randomly between 1.0,1.5,6.0 ignoring all zeros while retaining the index for comparison with another array such as y. So if I was to randomly pick 6.0 I could still relate it to y[4].
The reason for the efficient bit is that eventually I want to pick between possibly 10 values from an array of 1000+ with the rest zero. Depending on how intensive the other calculations become depends on the size of the array though it could easily become much larger than 1000.
Thanks | How to pick a random element in an np array only if it isn't a certain value | 0.099668 | 0 | 0 | 1,746 |
22,442,378 | 2014-03-16T20:16:00.000 | 405 | 0 | 1 | 0 | python,list,sorting,copy,in-place | 22,442,440 | 6 | true | 0 | 0 | sorted() returns a new sorted list, leaving the original list unaffected. list.sort() sorts the list in-place, mutating the list indices, and returns None (like all in-place operations).
sorted() works on any iterable, not just lists. Strings, tuples, dictionaries (you'll get the keys), generators, etc., returning a list containing all elements, sorted.
Use list.sort() when you want to mutate the list, sorted() when you want a new sorted object back. Use sorted() when you want to sort something that is an iterable, not a list yet.
For lists, list.sort() is faster than sorted() because it doesn't have to create a copy. For any other iterable, you have no choice.
No, you cannot retrieve the original positions. Once you called list.sort() the original order is gone. | 2 | 264 | 0 | list.sort() sorts the list and replaces the original list, whereas sorted(list) returns a sorted copy of the list, without changing the original list.
When is one preferred over the other?
Which is more efficient? By how much?
Can a list be reverted to the unsorted state after list.sort() has been performed? | What is the difference between `sorted(list)` vs `list.sort()`? | 1.2 | 0 | 0 | 136,029 |
22,442,378 | 2014-03-16T20:16:00.000 | 1 | 0 | 1 | 0 | python,list,sorting,copy,in-place | 49,599,301 | 6 | false | 0 | 0 | The .sort() function stores the value of new list directly in the list variable; so answer for your third question would be NO.
Also if you do this using sorted(list), then you can get it use because it is not stored in the list variable. Also sometimes .sort() method acts as function, or say that it takes arguments in it.
You have to store the value of sorted(list) in a variable explicitly.
Also for short data processing the speed will have no difference; but for long lists; you should directly use .sort() method for fast work; but again you will face irreversible actions. | 2 | 264 | 0 | list.sort() sorts the list and replaces the original list, whereas sorted(list) returns a sorted copy of the list, without changing the original list.
When is one preferred over the other?
Which is more efficient? By how much?
Can a list be reverted to the unsorted state after list.sort() has been performed? | What is the difference between `sorted(list)` vs `list.sort()`? | 0.033321 | 0 | 0 | 136,029 |
22,443,297 | 2014-03-16T21:31:00.000 | 0 | 0 | 0 | 0 | python,linux,database,sqlite | 22,443,606 | 2 | true | 0 | 0 | I don't think this can be done in full generality without out-of-band information or just treating everything as strings/text. That is, the information contained in the CSV file won't, in general, be sufficient to create a semantically “satisfying” solution. It might be good enough to infer what the types probably are for some cases, but it'll be far from bulletproof.
I would use Python's csv and sqlite3 modules, and try to:
convert the cells in the first CSV line into names for the SQL columns (strip “oddball” characters)
infer the types of the columns by going through the cells in the second CSV file line (first line of data), attempting to convert each one first to an int, if that fails, try a float, and if that fails too, fall back to strings
this would give you a list of names and a list of corresponding probably types from which you can roll a CREATE TABLE statement and execute it
try to INSERT the first and subsequent data lines from the CSV file
There are many things to criticize in such an approach (e.g. no keys or indexes, fails if first line contains a field that is a string in general but just so happens to contain a value that's Python-convertible to an int or float in the first data line), but it'll probably work passably for the majority of CSV files. | 1 | 0 | 0 | I want to convert a csv file to a db (database) file using python. How should I do it ? | How do I convert a .csv file to .db file using python? | 1.2 | 1 | 0 | 933 |
22,446,362 | 2014-03-17T03:20:00.000 | 2 | 0 | 1 | 0 | python | 22,446,407 | 2 | false | 0 | 0 | Just do
for (i, c) in enumerate(s):
if c.isdigit():
break
else:
raise ValueError('input with no number part')
fields = s[:i].split('-') | 1 | 0 | 0 | I have some strings that look like this:
text-text-text-12345
but the number of "text"'s are not the same so I don't want to string split on "-"
Is there any way I can split on the first appearance of a number, so I have the string
text-text-text-?
I am thinking about using regular expressions but I would love to figure out if str.split can deal with this problem.
Thanks so much. | Python- can I split a string with str.split after the first integer? | 0.197375 | 0 | 0 | 1,287 |
22,449,304 | 2014-03-17T08:02:00.000 | 2 | 0 | 0 | 1 | python,macos,python-imaging-library | 22,470,752 | 2 | false | 0 | 0 | following line helped me.
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pillow | 1 | 2 | 0 | When I try to install PIL library on Macosx 10.9.2, it's giving following error, how to install it.
$: sudo pip install pillow
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DHAVE_LIBJPEG -DHAVE_LIBZ -DHAVE_LIBTIFF -I/System/Library/Frameworks/Tcl.framework/Versions/8.5/Headers -I/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/Cellar/freetype/2.5.2/include/freetype2 -I/private/tmp/pip_build_root/pillow/libImaging -I/System/Library/Frameworks/Python.framework/Versions/2.7/include -I/usr/local/include -I/usr/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.9-intel-2.7/_imaging.o
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: command 'cc' failed with exit status 1 | how to install PIL on Macosx 10.9? | 0.197375 | 0 | 0 | 751 |
22,451,973 | 2014-03-17T10:31:00.000 | 1 | 0 | 0 | 0 | python,excel,xlwt,openpyxl,pyxll | 22,486,256 | 6 | false | 0 | 0 | No, and in openpyxl there will never be. I think there is a Python library that purports to implements an engine for such formualae which you can use. | 1 | 13 | 0 | I made a script that opens a .xls file, writes a few new values in it, then saves the file.
Later, the script opens it again, and wants to find the answers in some cells which contain formulas.
If I call that cell with openpyxl, I get the formula (ie: "=A1*B1").
And if I activate data_only, I get nothing.
Is there a way to let Python calculate the .xls file? (or should I try PyXll?) | Calculating Excel sheets without opening them (openpyxl or xlwt) | 0.033321 | 1 | 0 | 24,869 |
22,452,284 | 2014-03-17T10:45:00.000 | 2 | 0 | 0 | 0 | python,django | 22,452,380 | 1 | true | 1 | 0 | Since the operator module is part of the standard library, it looks like you have a corrupt Python installation in your virtualenv. The best thing to do would be to simply delete and recreate your virtualenv. | 1 | 0 | 0 | So these are my website informations:
framework : Django
hosting : alwaysdata
python : 2.7
virtualenv is used
The problem :
I have the non explicit 500 error :Internal Server Error
I have not any error log
But :
I found a trail to solve this issue. Indeed when i run manually the django.fcgi, i got this traceback:
Traceback (most recent call last):
File "public/django.fcgi", line 14, in
from django.core.servers.fastcgi import runfastcgi
File "/home/usr/.virtualenvs/thevirtualenv/lib/python2.7/site-packages/django/core/servers/fastcgi.py", line 17, in
from django.utils import importlib
File "/home/usr/.virtualenvs/thevirtualenv/lib/python2.7/site-packages/django/utils/importlib.py", line 4, in
from django.utils import six
File "/home/usr/.virtualenvs/thevirtualenv/lib/python2.7/site-packages/django/utils/six.py", line 23, in
import operator
ImportError: No module named operator
Manipulation(s) which could occur this issue :
I had this issue for 3 week ago, i let it rest too long, so now i can't remember what i have done to bring about this.. But i think it was a dirty virtualenv creation or edition, something like that..
Thanks to bear with my english.
Does anyone have an Idea about my case?
Attempts to solve this issue:
I just tried to recreate my virtualenv and got this error message :
Traceback (most recent call last):
File "/home/usr/python/python27/bin/virtualenv", line 5, in
from pkg_resources import load_entry_point
zipimport.ZipImportError: can't decompress data; zlib not available | django.fcgi or virtualenv : no module named operator | 1.2 | 0 | 0 | 2,136 |
22,453,554 | 2014-03-17T11:51:00.000 | 3 | 0 | 0 | 0 | python,widget,tkinter,label,styling | 22,455,831 | 2 | false | 0 | 1 | There is nothing you can do with the label widget -- it only supports a single font and single color for the entire label. However, you can easily substitute a canvas or text widget anywhere you need this feature. There's no reason why you can't use a text widget that is one line tall and a dozen or so characters wide. | 1 | 2 | 0 | I'm wondering how I can change the font of a Python Tkinter label widget so that half the displayed text is bold and half is not without having to use two labels. The text for the widget is assigned prior to the label actually being created and stored in a variable so I need some kind of flag presumably to tell it how much of the string should be bold. I don't it is possible but suggestions appreciated. | How to change font style for part of a tkinter label | 0.291313 | 0 | 0 | 9,774 |
22,455,309 | 2014-03-17T13:16:00.000 | 2 | 0 | 0 | 1 | python,file,python-3.x,exe,cx-freeze | 22,455,449 | 2 | false | 0 | 0 | The only way Windows associates files with a particular program is by their extension, so this only works if your files have a unique extension (which it looks like maybe they do). So your user would need to setup the association on their machine, which varies depending on the version of Windows. For instance, in Windows 7 it would probably be through Control Panel\All Control Panel Items\Default Programs\Set Associations.
It is possible for you to automatically setup this association on their system (probably by editing the Windows registry), but that would generally be done during an installation, and you should ask the users permission to do this first. | 1 | 6 | 0 | I am programming on a windows machine and I have an app that reads file selected by the user. Is it possible to allow them to open the file directly when they double click. This needs to work when the program is "compiled" as an .exe with cxfreeze.
What I am really asking is this:
Is there a way to allow the user to double click on a custom file (.lpd) and when they do windows starts the program (a compiled cxfreeze .exe) and passes it the file path as an argument. | How can I directly open a custom file with python on a double click? | 0.197375 | 0 | 0 | 541 |
22,456,509 | 2014-03-17T14:07:00.000 | 1 | 0 | 0 | 0 | python,sdk,render,maya,autodesk | 22,980,455 | 1 | true | 0 | 1 | I was able to do some of the things by parsing the file using basic Python and then extracting the things I needed.
The V-Ray API has a proprietary license, and there is no open source way to access the .vrscene
I decided to try with a trial version of the SDK, and by using the SDK you will be able to find a nice Python build wrapped with a bunch of examples within the V-Ray Application SDK.
The price is 1250 euro annually for a single development license (for one server node).
Support is included.
They can give you a preliminary evaluation version for 3 months under NDA (What I used).
No reverse engineering is permitted so if you are planning to develop over V-Ray you should buy it. | 1 | 0 | 0 | I'm developing some Python scripts to read/parse/process some .vrscene files.
From others' examples, I can see that there is a Python SDK for VRay called vrayutils.
I want to get this information from the SettingsOutput object.
From a .vrscene file I want to get the total frame numbers.
Does anyone know where I can get that Python library or how I can call it? | Getting access to VRay Python SDK | 1.2 | 0 | 0 | 1,560 |
22,456,531 | 2014-03-17T14:08:00.000 | 1 | 0 | 0 | 0 | python,wxpython,publish-subscribe,subscription | 22,482,340 | 3 | false | 0 | 0 | It is a bad idea in the first place. You should let pubsub do the work for you. One listener per topic. There is no cost to doing that, it segregates your code, makes it easier to maintain, separation of responsibilities.
That said, a listener can listen to base topic: pub.subscribe('a.b', listener) will get messages for topic a.b, a.b.c, a.b.d, a.b.c.e, etc. As described in the pubsub docs, you can tell pusub to give the topic object as part of message by using a keyword arg that has a default value of pub.AUTO_TOPIC. But if you use this strategy and you end up with a long list of if/elif/else its probably not the way to go.
Perhaps if you give more details about the topic hierarchy you intend to have, and the kind of if/else you had in mind, I can provide more useful feedback. | 1 | 2 | 0 | This may seem a bit general, but the problem is quite simple actually. Is it possible to subscribe to a subset of topics using the pubsub module.
Let me briefly explain what I would like to accomplish. In a wxpython project I want to change the text in the status bar according to different events. So I would like to have one function (one listener) which would subscribe to a set of topics. In the listener I would have if statement and several elif statements where the topic's name would be checked. Then the status bar text would be changed accordingly.
Is it possible to do this, or is it a bad idea in the first place. How should I deal with that kind of situation.
Thanks in advance | python pubsub subscribe to more than one topic | 0.066568 | 0 | 0 | 2,130 |
22,458,670 | 2014-03-17T15:38:00.000 | 0 | 0 | 0 | 0 | python,expect | 22,616,702 | 1 | true | 0 | 0 | So, I found out that the string I was passing to winpexpect was Unicode in one case and str in another case. It seems that winpexpect will block at winspawn if the string you pass in is unicode. | 1 | 0 | 0 | I am trying to use winpexpect to have an interactive subprocesses in Python. I am completely baffled. When I run a unit test, winspawn executes normally along with all the expects. When I run my program as a whole, winspawn inexplicably blocks forever. How can this be? As far as I know, winspawn is non-blocking. | winpexpect: winspawn is blocking | 1.2 | 0 | 0 | 479 |
22,460,124 | 2014-03-17T16:39:00.000 | -1 | 0 | 1 | 0 | python,eclipse,pydev,pylint | 22,460,335 | 2 | false | 0 | 0 | try %@?
this might be your answer. Not a whole lot out there about special characters in python. | 1 | 1 | 0 | I'm trying to create a simple string like:
test = "[email protected]" in Pydev but it automatically interpret "@" as a special symbol and the statement cannot pe done.
When I focus on the variable in Pydev, I can see:
test = "abc*@email.com"* instead of test = "[email protected]"
Anyone has any idea why I have this issue?
If I run the statement in windows command prompt python, then it is correctly assigned.
Does it have any relation with pylint?
Thanks, | Cannot create a string with "@" symbol inside the text in Pydev | -0.099668 | 0 | 0 | 72 |
22,460,645 | 2014-03-17T17:03:00.000 | 0 | 0 | 0 | 0 | eclipse,macos,opencv,python-2.7,pydev | 22,673,856 | 1 | true | 0 | 0 | Ok, it's working now. Here is what I did:
Install Python and every package I need for it with Macports
Set the Macports version as standard
Adjust PATH and PYTHONPATH
Reboot (not sure if needed)
Remove old interpreter and libs in Eclipse
Choose the new Python installation as Interpreter in Eclipse
Confirm the new libs in Eclipse
Restart Eclipse
Done | 1 | 0 | 1 | My final goal is to use Python scripts with SciPy, NumPy, Theano and openCV libraries to write code for a machine learning application. Everything worked so far apart from the openCV.
I am trying to install openCV 2.4.8 to use in Python projects in my Eclipse Kepler installation on my MBA running Mac OSX 10.9.2. I have the PyDef plugin v2.7 and a installation of Anaconda v1.9.1.
Here is what I did to install opencv:
sudo port selfupdate
sudo port upgrade outdated
sudo port install opencv
Then I realized that I can't use it that way in Python and did another:
sudo port install opencv +python27
Ok, then I had another Python installation and I added it to my PYTHONPATH in Eclipse>Preferences>PyDev>Interpreter-Python>Libraries.
Before the installation I got an error in the line import cv2, and everything else looked promising. Now this error disappeared but I get other errors when using any functions or variables of cv2. For example I get two errors in this line: cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
Also Python crashes and has to be restarted when I run a simple test program which worked fine before.
With this PYTHONPATH everything works but I have no openCV:
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pyObjC
/Library/Python/2.7/site-packages/
/Users/xxx/anaconda/lib/python2.7/site-packages
When I add this new folder to the PYTHONPATH...
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
... openCV seems to work but I have the crashes and the other issue described above.
So, can anyone tell me what the problem is and what I can do to make this work?
Thanks for reading this so far and any help/hint you can provide! Please don't be too harsh, I am, as you can probably easily see just a beginner. | Python with openCV on MAC crashes | 1.2 | 0 | 0 | 611 |
22,460,948 | 2014-03-17T17:15:00.000 | 4 | 0 | 0 | 0 | python,machine-learning,scikit-learn | 22,463,625 | 2 | true | 0 | 0 | For which algorithms in scikit-learn is this transformation into dummy variables necessary? And for those algorithms that aren't, it can't hurt, right?
All algorithms in sklearn with the notable exception of tree-based methods require one-hot encoding (also known as dummy variables) for nominal categorical variables.
Using dummy variables for categorical features with very large cardinalities might hurt tree-based methods, especially randomized tree methods by introducing a bias in the feature split sampler. Tree-based method tend to work reasonably well with a basic integer encoding of categorical features. | 1 | 2 | 1 | In scikit-learn, which models do I need to break categorical variables into dummy binary fields?
For example, if the column is political-party, and the values are democrat, republican and green, for many algorithms, you have to break this into three columns where each row can only hold one 1, and all the rest must be 0.
This avoids enforcing an ordinality that doesn't exist when discretizing [democrat, republican and green] => [0, 1, 2], since democrat and green aren't actually "farther" away then another pair.
For which algorithms in scikit-learn is this transformation into dummy variables necessary? And for those algorithms that aren't, it can't hurt, right? | scikit learn creation of dummy variables | 1.2 | 0 | 0 | 3,572 |
22,464,447 | 2014-03-17T20:17:00.000 | 0 | 0 | 0 | 0 | python,django,monitor | 22,575,690 | 1 | true | 1 | 0 | Well, there are many ways to do this. One would be a simple daemon (card observer) script that reads the card data every second or so and puts it in a memcached/db/file. Then you simply read it in the view.
Once you get this working, you may want to take another course, like running a observer thread from Django etc. | 1 | 0 | 0 | I have a django-based website. And I have an RFID-reader used by the django site. The reader's have a monitor, and a function, wich gives back the uid of the inserted card. When card isn't inserted, it gives back None.
I'd like to "run" the monitor's code while the django site is running, and I'd like to call the function of the monitor from my views, to use the uid of the rfid. How can I do this?
Thanks! | Django background monitor service | 1.2 | 0 | 0 | 128 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.