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
27,138,752
2014-11-25T23:31:00.000
1
0
0
0
python,machine-learning,scikit-learn,pmml
27,368,753
1
true
0
0
Since the PMML representation of the Naive Bayes model implements representing joint probabilities via the "PairCounts" element, one can simply replace that ratio with the probabilities output (not the log probability). Since the final probabilities are normalized, the difference doesn't matter. If the requirements involve a large number of proabilities which are mostly 0, the "threshold" attribute of the model can be used to set the default values for such probabilities.
1
0
1
I am trying to build my own pmml exporter for Naive Bayes model that I have built in scikit learn. In reading the PMML documentation it seems that for each feature vector you can either output the model in terms of count data if it is discrete or as a Gaussian/Poisson distribution if it is continous. But the coefficients of my scikit learn model are in terms of Empirical log probability of features i.e p(y|x_i). Is it possible to specify the Bayes input parameters in terms of these probability rather than counts?
naive bayes feature vectors in pmml
1.2
0
0
170
27,139,271
2014-11-26T00:21:00.000
1
1
0
1
python,amazon-web-services,ssh,amazon-ec2,amazon-elastic-beanstalk
27,139,451
2
true
0
0
Hi you have to declare the keypair to use on the web console. Go to elasticbeanstalk > your application > edit configuration > Instances > select keypair Alternatively, this sounds like a hack but you can write a python script file that call for the modules that you installed and throws an error if the module is not found. The error is captured and you can view it in the web logs.
1
1
0
I am using python and Amazon EC2 I am trying to progrmamtically SSH into the instance created by the Elastic Beanstalk Worker. While using 'eb init' there is no option to specify the KeyPair to use for the instance and hence I am not able to SSH into it. Reason for me to do this is that I want to check if the dependencies in requirements.txt are installed correctly in the instance. Is there any other way to check this other than SSHing into the instance and checking?
SSH into EC2 Instance created by EBS
1.2
0
0
723
27,142,550
2014-11-26T06:19:00.000
0
1
0
0
python,active-directory,windows-server-2008-r2,domainservices
27,160,376
1
true
0
0
Whenever I have seen that error before it has normally just required the machine in question to be removed from the domain and joined back to it again. So if it just one computer then I would suggest trying that first of all.
1
0
0
I have very basic question here... I have a situation where friend of mine claims that he has a parent child domains created. As they are parent child domains there is two way transitive trust created by default... But when I try to run Python application which internally calls win32security.LookupAccountName("", LocalSystem), it is taking approx. 2 minutes to complete and fails with exception "The trust relationship between the primary domain and the trusted domain failed " - Error Code -1788 Any idea what could have happened ? And how to resolve this ? Is there any way to verify the trust relationship between these domains ?
win32security.LookupAccountName fails with error The trust relationship between the primary domain and the trusted domain failed
1.2
0
0
902
27,145,014
2014-11-26T09:05:00.000
0
0
1
0
javascript,python,processing
49,843,328
1
false
1
0
At the moment there is no straightforward way to do this. But some workarounds can be found. For example, since Processing's python mode is using Jython language (Python on JVM) you can do the following: Compile the Jython code to Java bytecode Decompile Java bytecode to real Java code Use processing.js to make the sketch run in a webpage Of course, there are chances that the generated Java code will not be 100% Processing code, thus will not be converted to Javascript by the processing.js library.
1
4
0
The title says it all. I spent a lot of time designing a sketch in Processing using the Python language. Now, I would like to put the sketch on a webpage. Of course, I could just translate the sketch from python language to javascript and use a javascript library for processing. However, this would be a very lengthy process. As such, do you know if there is a way to integrate a python sketch in the website? If yes, how to do that? Thank you in advance!
Is there a way to integrate a processing sketch written in Python in a webpage?
0
0
0
144
27,145,789
2014-11-26T09:43:00.000
0
0
1
0
python,algorithm,mathematical-optimization,knapsack-problem,greedy
27,156,673
4
false
0
0
This problem can be phrased as a zero-one assignment problem, and solved with a linear programming package, such as GLPK, which can handle integer programming problems. The problem is to find binary variables x[i] such that the sum of x[i]*w[i] is as large as possible, and less than the prescribed limit, where w[i] are the values which are added up. My advice is to use an existing package; combinatorial optimization algorithms are generally very complex. There is probably a Python interface for some package you can use; I don't know if GLPK has such an interface, but probably some package does.
1
0
1
How to find biggest sum of items not exceeding some value? For example I have 45 values like this: 1.0986122886681098, 1.6094379124341003, 3.970291913552122, 3.1354942159291497, 2.5649493574615367. I need to find biggest possible combination not exceeding 30.7623. I can't use bruteforce to find all combinations as amount of combination will be huge. So I need to use some greedy algorithm.
How to find biggest sum of items not exceeding some value?
0
0
0
1,217
27,146,262
2014-11-26T10:06:00.000
0
0
1
0
python,configuration,argparse
66,471,482
7
false
0
0
found a very simple solution : vars(args) will transform it into a dict object.
1
14
0
I'm using argparse module to set my command line options. I'm also using a dict as a config in my application. Simple key/value store. What I'm looking for is a possibility to override JSON options using command line arguments, without defining all possible arguments in advance. Something like --conf-key-1 value1 --conf-key-2 value2, which would create a dict {'key_1': 'value1','key_2': 'value2'} ('-' in the argument is replaced by '_' in the dict). Then I can combine this dict with my JSON config (dict). So basically I would like to define --conf-* as an argument, where * can be any key and what comes after is the value. I did find configargparse module, but as far as I can see I start with a dict I already use. Any ideas how I could approach this?
Create variable key/value pairs with argparse (python)
0
0
0
19,341
27,152,414
2014-11-26T15:04:00.000
229
0
1
0
python,sublimetext2,pycharm
27,168,576
3
true
0
0
I think you want something like Settings | Editor | General | Smart Keys -> Surround selection on typing quote or brace
1
126
0
Is there a way to configure PyCharm to be able to surround selected code with parenthesis by just typing on the parenthesis key, like when we use SublimText 2?
How to surround selected text in PyCharm like with Sublime Text
1.2
0
0
28,935
27,152,624
2014-11-26T15:14:00.000
1
0
0
0
python-2.7,image-processing,plot,scikit-image
27,156,595
1
true
0
0
See skimage.feature.plot_matches, pass empty list of keypoints and matches if you only want to plot the images without points.
1
3
1
Looking up at different feature matching tutorials I've noticed that it's tipical to illustrate how the matching works by plotting side by side the same image in two different version (one normal and the other one rotated or distorted). I want to work on feature matching by using two distinct images (same scene shot from slightly different angles). How do I plot them together side by side? I'm willing to use skimage on python 2.7
Plot two images side by side with skimage
1.2
0
0
722
27,154,325
2014-11-26T16:34:00.000
10
0
1
0
python,windows,dll,clr
27,154,618
2
false
0
0
If you have Microsoft Visual Studio available, 1) open the Visual Studio project that your DLL is part of (or create a new project). 2) If you have set up your DLL for debugging (you've built it with debugging info, and it will be the one that your python program will use), you can set breakpoints in the DLL code. 3) Start the program you want to debug as you would do normally. 4) Go back to the Visual Studio IDE and go to the Debug menu. Choose the Attach to Process option. You will then get a list of all the running processes. 5) Choose the process you want to debug, which will be your python program, or runtime that is running your program. 6) Sit back and wait for one of your breakpoints to be hit, or you can try a Break All from the Debug menu to temporarily halt the program. This is a general way of starting out debugging not only python programs, but any program where you need to debug a DLL that is being used by the program. Note that the above advice works best if you have built the DLL yourself with debugging information and is being utilized by your python application. If it is a third-party DLL where you have no source code, you can still debug from Visual Studio, but will need to know assembly language (since the source code is usually not available).
1
6
0
On Windows7 I have a python script that uses Windows DLLs, using the .NET Common Language Runtime (CLR). An error occurs inside one of the used DLL, but the standard Python debugger only debugs on the Python code level (and not the DLL). How can I debug what is going on inside the DLL(s)?
How to debug a Windows DLL used inside Python?
1
0
0
4,688
27,154,600
2014-11-26T16:48:00.000
1
0
1
0
python,regex,match
27,154,695
2
false
0
0
You are almost there. Try this: ([a-zA-Z]{2} ){1,4}[a-zA-Z]{2}
1
2
0
I'm using regex to find occurrences in a string python, for example: "cw cx", "cw cx av", "cw cx dr wt" or "cw cx qw hv eb". The match can be 2, 3, 4 or 5 pairs. I'm thinking something like this "([a-zA-Z]{2}) ([a-zA-Z]{2})" Please help me
how can I search letter pairs matches with regex?
0.099668
0
0
147
27,157,087
2014-11-26T19:10:00.000
0
0
1
0
python,numpy,save,append
27,238,940
1
false
0
0
Thanks for your thoughts. These two options came to my mind too but I need the mixture of both: My specific use case requires the file to be human readable - as far as I know pickling does not provide that and saving to a dictionary destroys the order. I need the data to be dropped as they need to be manipulated in other scripts before the next data is produced. The not very elegant way I am doing it now: numpy.savetxt() to files labeled by the run, and bash "cat" applied in the end.
1
0
1
In one run my python script calculates and returns the results for the variables A, B, C. I would like to append the results run by run, row by row to a human-readable file. After the runs i, I want to read the data back as numpy.arrays of the columns. i | A B C 1 | 3 4 6 2 | 4 6 7 And maybe even access the row where e.g. A equals 3 specifically.
Append data to end of human-readable file Python
0
0
0
105
27,157,849
2014-11-26T19:57:00.000
0
0
1
0
python,unicode
27,158,045
2
true
0
0
The text b'\xe6\x88\x91' is the representation of the bytes that are the utf-8 encoding of the unicode codepoint \u6211 which is the character 我. So there is no need in converting something, other than to a unicode string with .decode('utf-8').
1
2
0
I first tried typing in a Unicode character, encode it in UTF-8, and decode it back. Python happily gives back the original character. I took a look at the encoded string, it is b'\xe6\x88\x91'. I don't understand what this is, it looks like 3 hex numbers. Then I did some research and I found that the CJK set starts from 4E00, so now I want Python to show me what this character looks like. How do I do that? Do I need to convert 4E00 to the form of something like the one above?
How to convert unicode to its original character in Python
1.2
0
0
663
27,160,020
2014-11-26T22:29:00.000
20
0
1
0
python,ipython,ipython-notebook
34,639,159
1
false
0
0
The asterisk next to a cell [*] indicates that the cell is currently executing. While IPython provides each notebook with it's own kernel, there is only one kernel per notebook. When that kernel is busy executing code (either a cell, or a series of cells) it cannot accept or run any further code until what it is currently doing is finished. New executions sit in a queue, until the kernel is ready. If you wait long enough after trying to execute 2+2 you should find that it will eventually execute (assuming your main code ever exits). The solution to this depends on your code, and how long you're willing to wait to get the results. As a general rule try the following: Use a smaller data set to test the algorithm, then scale up gradually noting the increase in time. Is it going to be feasible with your full dataset? Is your algorithm reading/writing to the disk? Can you avoid it, or pre-load/post-save state? Is it possible to split your data into batches? If your algorithm is batchable, can you parallelize it to make best use of your CPU? You can interrupt the kernel, however this will not work if the execution is currently out of the kernel's hands e.g. in external C modules (a lot of numpy for example). In these cases you may need to restart completely.
1
18
0
I'm sure this is a very newb question, so I apologize in advance. I'm trying to use ipython notebook for a group project. The program we are building is fairly large and pulls in a large number of external datasets. Much of the time, Ipython seems to stop working. I'll try to run a cell or multiple cells and nothing will happen (except a little asterisk * will appear in the brackets [] to the left of the cell). Even if I try to just add a new cell and execute 2+2, nothing will happen. What is going on here? How do I fix this? Thanks!
Why do Ipython cells stop executing?
1
0
0
14,050
27,161,760
2014-11-27T01:37:00.000
2
0
0
0
python,linux,python-2.7,ubuntu,sqlalchemy
27,371,294
2
true
1
0
To get passed this error I just simply ran the command: sudo easy_install "SQLAlchemy==0.7.8" The virtual environments do seem like the preferred method though, so hopefully I don't run into any additional problems from downgrading system-wide.
1
1
0
I am using Ubuntu 14.04 and trying to run snoopy_auth which is a part of the snoopy-ng application I downloaded and installed from their GitHub. When running, I get an error that is documented on snoopy-ng's GitHub page, which says that it works using version 0.7.8. How can I downgrade sqlalchemy to 0.7.8? The error looks like: snoopy_auth -l [+] Available drone accounts: Traceback (most recent call last): File "/usr/bin/snoopy_auth", line 103, in drones = auth_.manage_drone_account("foo", "list") File "/usr/bin/snoopy_auth", line 29, in manage_drone_account self.db.create(self.drone_tbl_def ) File "", line 2, in create File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/deprecations.py", line 106, in warned return fn(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/interfaces.py", line 859, in create raise NotImplementedError() NotImplementedError
How can I remove version 0.9.7 of sqlalchemy and install 0.7.8 instead?
1.2
1
0
1,813
27,162,717
2014-11-27T03:42:00.000
1
0
0
0
python,unit-testing,csv
27,162,750
3
false
0
0
store in a dictionary with corresponding head of csv file as key and first row as values read the second file and check against with dictionary.
1
1
1
For unit testing a method, I want to compare a CSV file generated by that method (the actual result) against a manually created CSV (the expected result). The files are considered equal, if the fields of the first row are exactly the same (i.e. the headers), and if the remaining row contain the same information. The following things must not matter: order of the columns, order of the rows (except for the header row), empty lines, end-of-line encoding, encoding of boolean values.
Python: How to check that two CSV files with header rows contain same information disregarding row and column order?
0.066568
0
0
1,472
27,162,982
2014-11-27T04:17:00.000
2
0
0
0
python,django,database,git
27,163,084
1
true
1
0
Follow the following steps to push from local and pull to server. make changes to models.py Use this cmd to add change to git . > git add models.py use this cmd to commit > git commit -m "your message" git push > this will push your local changes to repo. go to sever now. run cmd > git status see if there are any local changes done to models.py file. you can see those local changes using > git diff models.py If those changes are already in your repo. use this cmd to discard them > git checkout models.py Now run cmd which will take your latest changes from server.> git pull P.S. : Use the same commands for all the changes made to any file into the clone. South migrations for syncing database: Initial : 1. python manage.py schemamigration --initial 2. python manage.py migrate --fake Do any change to database and do following steps: 1. python manage.py schemamigration --auto 2. python manage.py migrate Do not checkin the migration folder created in app as it will conflict between your local and production clone. Note: All the history for south migrations are stored in south_migrations table in database.
1
0
0
I have a working Django 1.6 project using sqlite deployed in Digital Ocean, Ubuntu. I use Git to update my project on server side. (Git clone and git pull thereafter) My question is: every time after I update my database locally (e.g. added some new tables), how can I synchronise with the server one? Using git pull results in conflicts that cannot be resolved. I can do it using git fetch --all and git reset --HARD. But it doesn't seem to be the correct way. Any help is greatly appreciated! Thank you in advance.
How to synchronise local Django sqlite database with the server one?
1.2
1
0
860
27,166,357
2014-11-27T08:43:00.000
1
0
0
0
python,search,curl,elasticsearch
27,177,167
2
false
0
0
the above search example looks correct.Try lowercasing the Data "Analyst" as "data analyst". if doesn't help post your mappings,query you firing and response you are getting.
1
0
1
I have uploaded some data into Elastic server as " job id , job place , job req , job desc ". My index is my_index and doctype = job_list. I need to write a query to find a particular term say " Data Analyst " and it should give me back matching results with a specified field like " job place " . ie, Data Analyst term matching in the documents , and I need to have all "job place" information only. Any help. I tried curd . but not working. if it is in python good.
Elastic Search query filtering
0.099668
1
0
5,426
27,170,958
2014-11-27T12:34:00.000
0
0
1
0
python,python-sphinx
59,568,068
3
false
0
0
I use :py:obj: instead. :py:attr: won't work for me when the property is in another page.
1
16
0
How can I reference a method, decorated with @property? For simple methods, :py:meth: is working fine, but not for properties: it does not create a link to them.
Sphinx documentation: how to reference a Python property?
0
0
0
6,984
27,172,062
2014-11-27T13:40:00.000
0
0
0
1
python,netcat
27,194,201
1
true
0
0
So, I finally found the solution In the shebang, add the option -u to the interpreter to unbuffer stdin stdout and stderr Shebang line: #!usr/bin/python -u
1
0
0
I am starting a basic netcat server with the command nc.traditional -l -e server.py -p 4567 Problem is when I'm connecting to it (telnet 127.0.0.1 4567), the script starts but nothing gets on screen. I have print instructions on the beginning of the script that are read by the interpreter (I tested that it starts via file manipulation) but nothing is written on my telnet terminal. Moreover, it stays stuck on a raw_input instruction. I can write in the telnet terminal, but nothing seems to be sent to the python script. I've tried with a bash script replacing the python one and this works, it prints things on screen and read inputs. I've also tried connecting via ftp instead of telnet without results.
nc.traditional -e script.py Not printing anything
1.2
0
0
136
27,177,721
2014-11-27T19:37:00.000
1
0
0
0
python-3.x,tf-idf,lda,topic-modeling,gensim
27,378,733
1
false
0
0
id2word must map each id (integer) to term (string). In other words, it must support id2word[123] == 'koala'. A plain Python dict is the easiest option.
1
3
1
I have a tf-idf matrix already, with rows for terms and columns for documents. Now I want to train a LDA model with the given terms-documents matrix. The first step seems to be using gensim.matutils.Dense2Corpus to convert the matrix into the corpus format. But how to construct the id2word parameter? I have the list of the terms (#terms==#rows) but I don't know the format of the dictionary so I cannot construct the dictionary from functions like gensim.corpora.Dictionary.load_from_text. Any suggestions? Thank you.
Training a LDA model with gensim from some external tf-idf matrix and term list
0.197375
0
0
505
27,177,999
2014-11-27T20:00:00.000
3
0
0
0
python,flask,socket.io
50,516,756
3
false
0
0
Consider using request.sid which gets its value populated from the FlaskSocketIO library.
1
8
0
Is there a way to get socket id of current client? I have seen it is possible to get socket id in node.js. But it seems flask's socket.io extension is a little bit different than node's socketio.
getting socket id of a client in flask socket.io
0.197375
0
1
10,949
27,183,298
2014-11-28T06:43:00.000
0
0
0
0
python,pycharm
27,185,315
1
false
0
0
This has been solved by updating to Django 4.0.1 from Django 4.0
1
0
0
I recently posted a question which gave me the answer that I needed to set my path mappings. This currently doesn't work, and I can't figure out why. Clicking on the... doesn't open up anything, and the textbox is disabled. Could anyone suggest why it might not work? thanks.
In PyCharm 4 Professional, why can't i set path mappings?
0
0
0
209
27,186,207
2014-11-28T10:04:00.000
5
0
1
0
python,python-3.x,python-venv
27,188,184
1
false
0
0
Nope, commands installed in ./bin have fixed paths in shabang lines.
1
12
0
As of python 3.3 the stdlib has the venv module for creating virtual environments. Are python 3.x venv environments relocatable?
Are python 3.x venv environments relocatable?
0.761594
0
0
2,189
27,192,467
2014-11-28T16:11:00.000
3
0
0
0
python,random,spatial,coordinate
27,192,613
1
true
0
1
There's a lot that's unspecified in your question, such as what distribution you want to use. For the sake of this answer, I'll assume a uniform distribution. The straightforward way to handle an arbitrary volume uniform distribution is to choose three uniformly random numbers as coordinates in the range of the bounding rectilinear solid enclosing your volume, then check to see if the chosen coordinate lies within the volume. If the coordinate is not within the volume, discard it and generate a new one. If this is not sufficient, due to its non-constant performance or whatever other reason, you'll need to constrain your problem (say, to only tetrahedra) and do a bunch of calculus to compute the necessary random distributions and model the dependencies between the axes. For example, you could start with the x axis and integrate the area of the intersecting shapes between the volume and the plane where x = t. This will give you a function p(x) which, when normalized, is the probability density function along the X axis. (If you want nonuniform distribution, you need to put that in the integrated function, too.) Then you need to do another set of integrals to determine p(y|x0), the probability distribution function on the Y axis given the chosen x coordinate. Finally, you'll need to determine p(z|x0,y0), the probability distribution function on the z axis. Once you have all this, you need to use whatever random number algorithm you have to choose random numbers in these distributions: first choose x0 from p(x), then use that to choose y0 from p(y|x0), then use those to choose z0 from p(z|x0,y0), and you'll have your result (x0, y0, z0). There are various algorithms to determine if a point is outside a volume, but a simple one could be: For each polygon face: Compute its characteristic planes. Use cross product to compute plane normals. One vertex of the face and the plane normal are sufficient to define the plane. Remember the right-hand rule and choose the points so that the plane normal consistently points into or out of the polyhedron. Check that the random point lies on the "inside" half-space of that plane. A half-space is the set of all points on one side of the plane. Compute the vector from the plane vertex to the random point. Compute the dot product between the plane normal and this vector. If you defined the plane normals to point out of the polyhedron, then all dot products must be negative. If you defined the plane normals to point into the polyhedron, then all dot products must be positive. Note that you only have to recompute characteristic planes when the volume moves, not for each random point. There are probably much better algorithms out there, and their discussion is outside the scope of this question and answer. This algorithm is what I could come up with with no research, and is probably as good as a bubble sort.
1
0
1
I would like to generate a uniformly random coordinate that is inside a convex bounding box defined by its (at least) 4 vertices (for the case of a tetrahedron). Can someone suggest an algorithm that I can use? Thanks! If a point is generated in a bounding box, how do you detect whether or not it is outside the geometry but inside the box?
Generate a random point in space (x, y, z) with a boundary
1.2
0
0
1,463
27,192,852
2014-11-28T16:35:00.000
1
0
0
1
python,hadoop,apache-spark
27,195,171
1
false
0
0
First and foremost what are you trying to achieve? What does running on Hadoop technology mean to you? If the goal is to work with a lot of data, this is one thing, if it's to parallelize the algorithm, it's another. My guess is you want both. First thing is: is the algorithm parallelizable? Can it run on multiple pieces of data at the same time and gather them all in the end to make the final answer? Some algorithms are not, especially if they are recursive and require previously computed data to process the next. In any case, running on Hadoop means running using Hadoop tools, whether it is Spark, Storm or other services that can run on Python, taking advantage of Hadoop means writing your algorithm for it. if your algorithm is parallelizable, then likely you can easily take the piece that processes one piece of data and adapt it to run with Spark or Storm on huge datasets.
1
0
1
I am having an algorithm written in python (not hadoop compatible i.e. not mapper.py and reducer.py) and it is running perfectly in local system (not hadoop). My objective is to run this in hadoop. Option 1: Hadoop streaming. But, I need to convert this python script into mapper and reducer. Any other way? Option 2: To run this python script through Storm. But, I am using cloudera which doesn't have Storm. either I need to install storm in cloudera or need to use Spark. If I install storm in cloudera. Is it better option? Option 3: To run this python script through Spark (Cloudera). Is it possible. This algorithm is not for real time processing. But, we want to process it in hadoop technology. Please help with other suitable solution.
To run python script in apache spark/Storm
0.197375
0
0
1,217
27,192,905
2014-11-28T16:39:00.000
1
0
1
0
ipython,ipython-notebook
27,229,741
3
true
0
0
I didn't find how to get the previous content cell in a cell. But I found another solution, creating a custom magic notebook function to capture the cell content and work with that.
1
5
0
Is it possible in an IPython-Notebook cell to get the previous (above) cell content ? I can see previous output with %capture magic function but I don't find how to get the previous cell content.
IPython Notebook previous cell content
1.2
0
0
3,415
27,193,835
2014-11-28T17:56:00.000
0
1
0
0
qpython
27,197,253
2
false
0
1
The comment from Yulia V got me thinking, maybe I just needed to append the location of "Scripts" to the sys.path, and Yep, that worked fine!! Thanks Yulia!
2
0
0
With QPython on Kindle fire .. I use QEdit to write & save a .py file .. say bob.py .. But when I switch to Console, I can't IMPORT from bob .. Can someone tell me how to do this? John (new to QPython)
How to import from saved QPython file?
0
0
0
1,136
27,193,835
2014-11-28T17:56:00.000
0
1
0
0
qpython
27,209,867
2
false
0
1
I think you can save the module file into the same directory which you script locates or /sdcard/com.hipipal.qpyplus/lib/python2.7/site-packages/
2
0
0
With QPython on Kindle fire .. I use QEdit to write & save a .py file .. say bob.py .. But when I switch to Console, I can't IMPORT from bob .. Can someone tell me how to do this? John (new to QPython)
How to import from saved QPython file?
0
0
0
1,136
27,193,849
2014-11-28T17:57:00.000
5
0
0
0
python,multithreading,sqlalchemy
27,194,059
1
true
1
0
Session.merge() is enough and should do what you're after, but even then it gets fiddly with threads. You might want to rethink this. Pass the primary key(s) to the worker instead of the objects, and then handle object loading and the actual work in the worker itself. No messing around with threading and open/closed sessions that will eventually lead to headaches. Once the workers can deal with the objects separately, you could even move the workers to a separate process (similar to what Celery does).
1
2
0
I'm working on a multithreaded application that uses the SQLAlchemy ORM. It already uses scoped_session with the thread as its scope, but we are having some issues when we pass an ORM object from a worker thread back to the main thread. Since the objects are attached to the worker thread's session, when the worker thread is shut down, we start getting DetachedInstanceErrors on those objects. Is there a way I can generically tell the ORM objects to detach/reattach themselves to the correct session as needed? We spawn a new thread whenever we have a slow operation that we don't want locking up our UI, so putting the reattach code in everywhere we spawn a new thread would be a mess. I think we also need to be able to clone the ORM object when we spawn the thread, so that we can have one in the main thread and one in the worker thread. I see a "merge" but no "split". Is this possible?
SQLAlchemy ORM: safely passing objects between threads without manually reattaching?
1.2
1
0
1,254
27,194,932
2014-11-28T19:32:00.000
2
1
1
0
python
30,282,342
2
false
0
0
You run your .py files just like you would if you were running the python commandline in windows. ex. python myfile.py Open a SSH terminal from your python devbox and type it in the cmd line and you're all set.
1
2
0
I just started with learning Python 3.4.x. I really want to keep learning and developing on all devices. That's why I'm using Codeanywhere. But the problem is I don't know how to execute a .py file in Codeanywhere. Is there a method to do it? Thanks
How do I run python in Codeanywhere?
0.197375
0
0
9,516
27,196,501
2014-11-28T22:07:00.000
0
0
1
0
python,formatting,tabular
27,209,158
2
false
0
0
My shell has the font settings changed so the alignment was off. Back to font: "Courier" and everything is working fine. Sorry.
1
1
0
Right now I'm using print(), calling the variables I want that are stored in a tuple and then formatting them using: print(format(x,"<10s")+ format(y,"<40s")...) but this gives me output that isn't aligned in a column form. How do I make it so that each row's element is aligned? So, my code is for storing student details. First, it takes a string and returns a tuple, with constituent parts like: (name,surname,student ID, year). It reads these details from a long text file on student details, and then it parses them through a tuplelayout function (the bit which will format the tuple) and is meant to tabulate the results. So, the argument for the tuplelayout function is a tuple, of the form: surname | name | reg number | course | year
Format strings to make 'table' in Python 3
0
1
0
5,713
27,196,845
2014-11-28T22:47:00.000
0
0
0
0
python,django,python-2.7
27,198,456
1
true
1
0
It turns out that for my purposes, I needed to be calling my custom commands from within another custom command file. My intent was to have one file that would call my other custom commands and this wasn't working with just a regular Python file. As soon as I made this regular Python file into another custom command file, it worked for what I needed.
1
1
0
I have a custom django admin call that I am able to successfully call from the command line using: python manage.py mycustomcommand. Therefore, the directories are setup with the necessary init files in 'management' and 'commands' folders, and I have listed the apps under INSTALLED_APPS in my settings file. When I try to run the command from another file and use call_command('mycustomcommand') is says the command is an unknown command. How does it work from the command line but not from call_command? I ran get_commands() from 'core.management' and my command is not listed there. Do I need to do something more so that it can be found? If it matters, I am trying to call mycustomcommand from an app directory that is different from the app directory where the custom command lives. All my app directories have the correct structure and are in INSTALLED_APPS. All my googling seems to suggest it should just work and I've tried all reasonable suggestions to no avail. Thanks for any insight.
Django custom command works on command line, but not call_command
1.2
0
0
591
27,198,697
2014-11-29T03:58:00.000
1
0
1
0
python,linux,sockets,video,udp
27,199,731
1
true
0
0
If you are to send a video(with audio) to a peer in the network, you would better use RTP(Real time Transfer Protocol) which works on top of UDP. RTP provides feature of timestamps and profile which help you syncronize the audio and video sent through two ports.
1
0
0
I am doing a project on media (more like a video conferencing). The problem is , although I am able to send text/string data from one peer to another, I am still not sure about video files. Using gstreamer, I am able to capture video stream from my webcam and doing the encoding/coding (H.264) , I am able to write the video stream into actual mp4 contanier directly using a file sink Now my problem is, I am not sure on reading the video files as it contains both audio and video streams, convert into transmission stream to transmit it using packets (I am able to send a very small jpeg file although). I am using socket module and implementing UDP
python - how to have video file(data) into list?
1.2
0
1
73
27,198,906
2014-11-29T04:35:00.000
1
0
1
0
python
27,198,951
5
false
0
0
You can make class with attributes as units and values. Another possible solution to this can be using dictionary {a: 'm/s', b: 'm^2'} Or two lists if duplicate values can occur myVars = [a, b, 100, d] myUnits = ['m/s', 'm^2', 's', 'm'] Then myResult = str(myVars[0]) + str(myUnits[0])
1
2
0
I want to know if it is possible to add an attribute to a variable in python. For example create the variable a=45 and then add as a label or property something like units=m/s Thank you.
Is it possible to add an attribute to a variable in python?
0.039979
0
0
284
27,204,134
2014-11-29T15:58:00.000
0
1
0
0
python,serialization,raspberry-pi
64,522,252
3
false
0
0
It's the cable. Check the USB cable. All of that yanking
1
1
0
I'm making a code where the pi gets a serial input from a usb-serial board(From the sparkfun RFID starter kit), how can I make this work? error Traceback (most recent call last): File "main", line 22, in ser = s.Serial('ttyUSB0', 9600, timeout=10000) File "/usr/lib/python2.7/dist-packages/serial/serialutil.py", line 260, in init self.open() File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 276, in open raise SerialException("could not open port %s: %s" % (self._port, msg)) serial.serialutil.SerialException: could not open port ttyUSB0: [Errno 2] No such file or >directory: 'ttyUSB0' The RFID port is the ttyUSB0
ttyUSB0 not found on Raspberry Pi
0
0
0
9,230
27,204,135
2014-11-29T15:58:00.000
3
0
1
0
python,pycharm,kivy
27,204,313
2
false
0
0
Did you install kivy in your system from the zip, using the setup.py file in it?. I had a similar problem, which was because I hadn't installed it properly and using it in portable mode.
1
4
0
I am a Mac-based Pycharm Python developer. It seems like I can't use Pycharm to develop using the Kivy framework because there is no official support. While choosing the path: /usr/local/bin/kivy as the interpreter path, an error message: Invalid python interpreter name{0} appears. How can I use Kivy in Pycharm?
Setting Kivy in Pycharm (Mac)
0.291313
0
0
772
27,207,643
2014-11-29T22:02:00.000
1
0
0
0
python,performance,tkinter,syntax-highlighting,lexical-analysis
27,210,959
1
false
0
1
One possible answer is to do something like Idle does. As a user hits each key, its custom incremental parser tags identifiers that are a keyword, builtin, or def/class name*. It also tags delimited char sequences that are a string or comment. I does what can be done quickly enough. For example, if one types printer not in a string or comment, Idle checks if the word is a keyword or builtin name after each key. After t is hit, print is tagged. After e (or any other identifier char) is entered, printe is untagged. I believe some of the code is in idlelib/Hyperparser.py and some in ColorDelegator.py. You are free to copy and adapt code, but please do not use it directly, as the API may change. I presume the parser does the minimum needed according to the current state (after def/class, in an identifier, comment, string, etc.) Idle has an re-based function to retag the entire file. I 'think' this is separate from the incremental colorizer, but I have not read all the relevant code. If one edits a long enough file, such as idlelib/EditorWindow.py (about 3000 lines), and changes font size, Idle retags the file (I am not sure why). There is a noticeable delay between the file turning all black and its being recolorized. You definitely would not want that delay with each keystroke. Class/functions names with non-ascii chars are not yet properly recognized in 3.x, but should be. The patch is stuck on deciding the faster accurate method. Recognizing an ascii-only (2.x) indentifier is trivial by comparison. PS I am correctly in guessing that you are interested in tagging something other than Python code?
1
0
0
I'm trying to implement syntax highlighting for text in a Text widget. I use an external library to lexically analyse the text and give me the tokenised text. After that I go over all the words in the text and apply tag to their position in the text widget so that I can style each word. My concern now is how do I deal with changes. Every time the user presses a key, do I tokenise the entire text again and add style tags to the text widget for the entire text. This is proving to be quite slow. I then transitioned to only doing the highlighting process for the line the insert character was to make it faster but this is giving faulty results and the highlighting is not perfect now. What would be an ideal compromise between fast and perfect? What is the best way to do this?
Efficiently applying text widget tags in tkinter text widgets
0.197375
0
0
228
27,208,748
2014-11-30T00:34:00.000
3
0
1
0
python,python-2.7,if-statement,any
27,208,777
2
false
0
0
item.isdigit() should be char.isdigit().
1
1
0
I have a problem with the Python function any(). I want to use the any() function to remove from a list any items that contains a digit. For instance: lst = ['abc123','qwerty','123','hello'] and I apply the following code to remove from lst the items: 'abc123','123' new_list = [item for item in lst if not any(item.isdigit() for char in item)] I want new_list to contain only the items ['qwerty','hello'] but it turns out that new_list=lst...there is no change. Why? I also tried using import __builtin__ and __builtin__.any and no luck. I use Python 2.7.
Python: Issues with "if not any"
0.291313
0
0
2,547
27,208,926
2014-11-30T01:01:00.000
1
0
0
0
c#,.net,dll,ironpython
27,233,826
1
true
1
1
You can try replicating what "works for me". Create a solution containing: python project (ironpython) C# project Add a reference to desired oracle library (Oracle.DataAccess.dll) to C# project using the standard VS mechanism. C# project should also contains a post build step to copy the resulting dll and pdb into the place where python script can find it. In my case root of the python project. Your python project is selected as Startup Project. I use Ctrl-F5 and F5 to start it. In both cases things work as expected. In debug mode I am able to set and hit breakpoint in python and in referenced C# module. I can see the oracle library being loaded (Output window of debugger). However: The stack traces are C# only. Visual Studio 2013 Update 4 together with PTVS 2.1 crashes on occasions when debugging.
1
0
0
I want to debug separate pieces of my application in Visual Studio 2012. I have C# executable which works with Oracle.DataAccess dll. It works fine. Within it IronPython runtime is invoked and it works fine too. Within these IronPython modules object from main C# application is invoked and it works fine with Oracle dll. If IronPython script is invoked standalone then it works fine and uses C# object fine as well. However in this case C# object doesn't see Oracle dll. To debug IronPython scripts I have to create separate Python solution so I cannot configure my C# solution. So I do not have control of C# references. GAC has right Oracle dll but how to tell C# dll to use it? Vise versa if I'm in C# solution where I can manage the references then I cannot add py files and debug them. In what way can I configure VS to be able to run/debug my application with dual entry C# or IronPython separately?
DLL loading (C#/IronPython/C#) in VS2012
1.2
0
0
390
27,210,351
2014-11-30T05:29:00.000
0
0
1
0
python,python-3.x,installation
27,210,767
4
false
0
0
(In addition to Owens points). Use py2exe or one of the other exe builder utils for python on windows. On other platforms just use the python script.
1
4
0
I have an installer which uses a Python script to install several components. I do not want to install Python on the users computer if they do not already have it and I also do not want having Python installed to be a prerequisite for using my installer. Is there a way of downloading Python without using the installer and just running it from a directory which can be easily removed after the installation is complete?
Use Python without installing
0
0
0
23,388
27,214,104
2014-11-30T14:06:00.000
0
0
0
1
python,django,google-app-engine
27,214,235
2
false
1
0
You can hardly hide the secret keys from an attacker that can access your server, since the server needs to know the keys. But you can make it hard for an attacker with low privileges. Obfuscating is generally not considered as a good practice. Your option 5 seems reasonable. Storing the keys in a non-source controlled file allows to keep the keys in a single and well-defined place. You can set appropriate permissions on that file so that an attacker would need high privileges to open it. Also make sure that high privileges are required to edit the rest of the project, otherwise, the attacker could modify a random file of the project to access the keys. I myself use your option 5 in my projects.
2
7
0
I have a Django app that uses some secret keys (for example for OAuth2 / JWT authentication). I wonder where is the right place to store these keys. Here are the methods I found so far: Hardcoding: not an option, I don't want my secrets on the source control. Hardcoding + obfuscating: same as #1 - attackers can just run my code to get the secret. Storing in environment variables: my app.yaml is also source-controlled. Storing in DB: Not sure about that. DB is not reliable enough in terms of availability and security. Storing in a non-source-controlled file: my favorite method so far. The problem is that I need some backup for the files, and manual backup doesn't sound right. Am I missing something? Is there a best practice for storing secret keys for Django apps or App Engine apps?
Storing client secrets on Django app on App Engine
0
0
0
812
27,214,104
2014-11-30T14:06:00.000
0
0
0
1
python,django,google-app-engine
37,824,536
2
false
1
0
A solution I've seen is to store an encrypted copy of the secret configuration in your repository using gpg. Depending on the structure of your team you could encrypt it symmetrically and share the password to decrypt it or encrypt it with the public keys of core members / maintainers. That way your secrets are backed up the same way your code is without making them as visible.
2
7
0
I have a Django app that uses some secret keys (for example for OAuth2 / JWT authentication). I wonder where is the right place to store these keys. Here are the methods I found so far: Hardcoding: not an option, I don't want my secrets on the source control. Hardcoding + obfuscating: same as #1 - attackers can just run my code to get the secret. Storing in environment variables: my app.yaml is also source-controlled. Storing in DB: Not sure about that. DB is not reliable enough in terms of availability and security. Storing in a non-source-controlled file: my favorite method so far. The problem is that I need some backup for the files, and manual backup doesn't sound right. Am I missing something? Is there a best practice for storing secret keys for Django apps or App Engine apps?
Storing client secrets on Django app on App Engine
0
0
0
812
27,215,170
2014-11-30T16:04:00.000
4
0
1
0
python,anaconda
27,239,565
1
true
0
0
There is no need to remove your system Python. Anaconda sits alongside it. When it installs, it adds a line to your .bashrc that adds the Anaconda directory first in your PATH. This means that whenever you type python or ipython in the terminal, it will use the Anaconda Python (and the Anaconda Python will automatically use all the Anaconda Python libraries like numpy and scipy rather than the system ones). You should leave the system Python alone, as some system tools use it. The important points are: Whichever Python is first on your PATH is what gets used when you use Python in the terminal. If you create a conda environment with conda and use source activate it will put that environment first on the PATH. Each Python (Anaconda or the system) will use its own libraries and not look at the others (this is not true if you set the PYTHONPATH environment variable, but I recommend that you don't).
1
5
1
I've been installing few Library/Toolkit for Python like NLTK, SciPy and NumPy on my Ubuntu. I would like to try to use Anaconda distribution though. Should I remove my existing libraries before installing Anaconda?
Integrating exisiting Python Library to Anaconda
1.2
0
0
3,390
27,217,051
2014-11-30T19:08:00.000
0
0
0
0
python,opengl,webgl,ipython,vispy
27,259,240
1
true
0
0
This looks like a good use-case for Vispy indeed. You'd need to use a PointVisual for the nodes, and a LineVisual for the edges. Then you can update the edges in real time as the simulation is executed. The animation would also work in the IPython notebook with WebGL. Note that other graphics toolkits might also work for you (although you'd not necessarily have GPU acceleration through OpenGL) if you specify static positions for the nodes. I think you can fix the nodes positions with d3js or networkx instead of relying on an automatic layout algorithm.
1
0
1
So I have a particular task I need help with, but I was not sure how to do it. I have a model for the formation of ties between a fixed set of network nodes. So I want to set up a window or visualization that shows the set of all nodes on some sort of 2-dimensional or 3-dimensional grid. Then for each timestep, I want to update the visualization window with the latest set of ties between nodes. So I would start with a set of nodes positioned in space, and then with each timestep the visualization will gradually add the new edges. The challenge here is that I know in something like networkx, redrawing the network at each timestep won't work. Many of the common network display algorithms randomly place nodes so that as to maximize the distance between thenm and better show the edges. So if I were to redraw the network at each timestep, the nodes would end up in different locations each time, and it would be hard to identify the pattern of network growth. That is why I want a set of static nodes, so I can see how the edges get added at each timestep. I am looking to visualize about 100 nodes at a time. So I will start with a small number of nodes like 20 or so, and gradually build up to 100 nodes. After the model is validated, then I would build up to 1000 or 2000 nodes. Of course it is hard to visualize 1000 or 2000 node network, that is why I just want to make sure I can visualize the network when I just have 100 nodes in the simulation. I was not sure if I could do this in webgl or something, or if there is a good way to do this in python. I can use Vispy for communication between python and webgl if needed.
network animation with static nodes in python or even webgl
1.2
0
0
308
27,217,237
2014-11-30T19:26:00.000
0
0
0
0
python,django,python-2.7,django-templates,django-views
27,217,307
2
false
1
0
You can try using custom tags in django templates.
1
0
0
http://www.example.com/soe/?param1=val1 this is current url and I want to access variable {{param1}} in django template. (Django 1.7) I know there are already many threads available for this problem but all of them are using ContextProcessor.(or render_to_response) I'm simply using return render(request, template, {}) and dont want to use ContextProcessors. One way to solve this problem is I pass the value of param1 when rendering, I mean return render(request, template, {'param1': request.GET.get('param1')}) but I'm just wondering If I can access this variable in template itself? because there might be 10 parameters.
Access URL parameters in django 1.7 template without using context processors
0
0
0
815
27,217,401
2014-11-30T19:43:00.000
1
0
0
0
java,python,operators
57,453,225
4
false
1
0
One thing to notice is: in python 3: 6 // -132 = -1 in java: 6 / -132 = 0
1
2
0
Is there a form of the // operator that is used in python that I can use in java, or some sort of workaround? 10 // 3 = 3
Operator in Java like // in python?
0.049958
0
0
2,327
27,217,584
2014-11-30T19:59:00.000
2
0
0
0
python,django,database-design,design-principles
27,220,032
1
false
1
0
First, if you want to use email as username, use the Django custom user functionnality. It works well. Then, note that it's not because you created your own User that you can't extend it with a Profile. So, a good solution could be : Create a Django custom User without trying to add specific fields to it (the one and only purpose here is to use email to log instead of username). Create a PatientProfile class that have a one-to-one relatioship (blank=True) with User class. This way, a patient that can log in will be related to a User instance and will use this instance for this purpose. On the other hand, the patient who can't log in won't be related to any User instance. In the end, there's no problem to use OneToMany relationship with PatientProfile for what's you want to do.
1
3
0
Probably some of you would tell that is a recurrent topic, but after reading many articles, it still seems very ambiguous to me. My question is about the best way to use and to extend the User model preserving the authentication (and others) mechanisms available in Django. However, I prefer to describe my design: There are users (Patients) that can sign up providing basic info (first name, last name, birth date, gender, email, password). Preferably, email should replace the username. When a Patient is in the application, it can register a new Patient (imagine a member of the family), but email and password are not required because they won't log into the system. For the first part, Django doc propose to extend User with a OneToOne relation to a Profile. However, to replace username by email they propose then to create a custom User extending from an AbstractUser, as well as an associated UserManager. The second requirement is like doing a one-to-many relation from users to users. So, according to Django, which should be the best strategy: creating a completely new user model and the one-to-many user-user adding an specific attribute that distinguish between main users and family members? OR extending Django User with a Profile and then a one-to-many relation profile-profile? Which option preserves the best the benefits of Django user authentication and model administration? Thank you for any comment, suggestion, example.
Django best user model design
0.379949
0
0
603
27,218,696
2014-11-30T21:54:00.000
0
0
1
0
python,unicode
27,218,864
3
false
0
0
Do re.search(r'\d+ Seconds',myString), and then remove Seconds from the output using output.replace(' Seconds','').
1
0
0
I am new to python and I am having issues with a unicode string Here is my string: u'3 hrs, 12 mins, 56 secs (11576 Seconds)' I am trying to pull out the number of seconds for use in another function. I was trying to use re.search() but was having difficulty. Can someone please suggest a way to do this? Thanks C
Python re.search unicode parsing
0
0
0
193
27,218,894
2014-11-30T22:14:00.000
0
0
1
0
java,python,c,algorithm,gray-code
32,443,234
9
false
0
0
An obvious answer, but it works. Convert each gray code into its respective Binary form, subtract the two. If you answer is a binary equivalent of +1 or -1 then the two gray codes are adjacent. This seems like an over kill, but when you're siting in an interview and don't know the correct method, this works. Also to optimize, one can check the single bit difference filter, so we don't waste time converting and subtracting numbers that we know for sure aren't adjacent.
1
6
0
I am trying to come up with a solution to the problem that given two numbers, find if they are the consecutive numbers in the gray code sequence i.e., if they are gray code neighbors assuming that the gray code sequence is not mentioned. I searched on various forums but couldn't get the right answer. It would be great if you can provide a solution for this. My attempt to the problem - Convert two integers to binary and add the digits in both the numbers separately and find the difference between the sum of the digits in two numbers. If the difference is one then they are gray code neighbors. But I feel this wont work for all cases. Any help is highly appreciated. Thanks a lot in advance!!!
How to find if two numbers are consecutive numbers in gray code sequence
0
0
0
17,392
27,221,954
2014-12-01T05:00:00.000
1
0
1
0
python,c++,parsing,python-3.x
27,221,965
2
false
0
0
Clang has an API that can be used for code completion and more, AFAIK, with python bindings.
1
1
0
I'm looking to parse c++ code files in python. I'm mostly concerned with only the function declarations, not the definitions. The kind of output GCCXML gives seems perfect to me but the thing is I can't get GCCXML to work, I can't find proper documentation. All the articles I found online are old and possibly outdated. Can anyone suggest any other alternative? Or and updated links regarding GCCXML. I'm using Python 3.4.2 and IDLE.
parsing c++ in python
0.099668
0
0
143
27,225,181
2014-12-01T09:22:00.000
0
0
0
0
python,django
27,225,478
2
false
1
0
You need to keep checking the socket connection status continuously in a script that will inform you regarding the same. In case you are more concerned with the performance issues then you can make use of a in memory caching system like redis etc. cheers :-)
1
0
0
I want to show instant error page when database host is unavailable. Default behavior for django is that ,when user requests , it takes long time and then displays error page. Is there is any way to display some error instantly when database host is unreachable or database host is invalid with django without any delay ? Any suggestions ?
Show instant error page when database host is unavailable - django
0
0
0
271
27,226,551
2014-12-01T10:39:00.000
1
1
0
1
python,perl,ubuntu,automation,perl-module
27,242,918
1
false
0
0
The main thing to understand is that each tab has a different instance of terminal running, more importantly a different instance of shell (just thought I would mention as it didnt seem like you were clear about that from your choice of words). So "passing control" in such a scenario could most probably entail inter-process communication (IPC). Now that opens up a range of possibilities. You could, for example, have a python/perl script running in the target shell (tab) to listen on a unix socket for commands in the form of text, which the script can then execute. In Python, you have modules subprocess (call, Popen) and os (exec*) for this. If you have to transfer control back to the calling process, then I would suggest using subprocess as you would be able to send back return codes too. Switching between tabs is a different action and has no consequences on the calling/called processes. And you have already mentioned how you intend on doing that.
1
0
0
I am trying to automate a scenario in which, I have a terminal window open with multiple tabs open in it. I am able to migrate between the tabs, but my problem is how do i pass control to another terminal tab while i run my perl script in a different tab. Example: I have a terminal open with Tab1,Tab2,Tab3,Tab4 open in the same terminal, i run the perl script in Tab3 and i would want to pass some commands onto Tab1. Could you please tell me how can i do this ?? I use GUI tool to switch between tabs X11::GUITest and use keyboard shortcuts to switch between tabs, any alternative suggestion is welcome, my ultimate aim is to pass control on to a different tab.
How do i pass on control on to different terminal tab using perl?
0.197375
0
0
134
27,226,833
2014-12-01T10:56:00.000
0
0
1
0
python,debugging,pycharm
27,227,181
1
true
0
0
The classic method is to write a program that reproduces the conditions that lead into the buggy code, without taking a bunch of time -- say, read in the data from a file instead of generating it -- and then paste in the code you're trying to fix. If you get it fixed in the test wrapper, and it still doesn't work in the original program, you then "only" have to find the interaction with the rest of the program that's faulty (global variables, bad parameters passes, etc.)
1
0
0
In the PyCharm debugger we can pause a process. I have a program to debug that takes a lot of time before we arrive to the part I'm debugging. The program can be modeled like that: GOOD_CODE -> CODE_TO_DEBUG. I'm wondering if there is a way to.. run GOOD_CODE save the process edit the code in CODE_TO_DEBUG restore the process and with the edited CODE_TO_DEBUG Is serialization the good way to do it or is there some tool to do that? I'm working on OSX with PyCharm. Thank you for your kind answers.
How to save python process for debug?
1.2
0
0
66
27,227,971
2014-12-01T12:01:00.000
0
0
1
0
python,file-io,python-multiprocessing
27,228,128
2
false
0
0
You are indeed right, the bottleneck will be disk-IO. However, the only way to really know, is to measure both approaches. If you have influence on the files, you could go for one larger file as opposed to many smaller files.
2
4
0
I intent to use multiprocessing to read a set of small files with multiprocesing capabilities of Python. However this is awkward in some sense to me because if the disk is rotational then the bottle neck is the rotation time and even-though I use multiple processes, total read time should be similar with single process read. Am I wrong ? What are your comments? I addition, do you think using multiprocessing might cause intertwined reading of the files so the contents of these files are skewed in some way?
Is it meaningful to use multiprocessing to read multiple files with Python?
0
0
0
352
27,227,971
2014-12-01T12:01:00.000
0
0
1
0
python,file-io,python-multiprocessing
27,228,116
2
false
0
0
Your reasoning is sound, but the only way to find out for sure is by benchmarking (that said, it is unlikely that reading many small files in parallel will increase performance over reading them sequentially). I am not entirely sure what you mean by "intertwined reading", but -- unless there are bugs in your code or the files are being changed while you're reading them -- you will get exactly the same contents irrespective of how you read it.
2
4
0
I intent to use multiprocessing to read a set of small files with multiprocesing capabilities of Python. However this is awkward in some sense to me because if the disk is rotational then the bottle neck is the rotation time and even-though I use multiple processes, total read time should be similar with single process read. Am I wrong ? What are your comments? I addition, do you think using multiprocessing might cause intertwined reading of the files so the contents of these files are skewed in some way?
Is it meaningful to use multiprocessing to read multiple files with Python?
0
0
0
352
27,234,386
2014-12-01T18:02:00.000
2
0
0
0
python,kivy
27,235,194
2
false
0
1
Set kivy.core.window.Window.size to (800, 600). You can't set it directly in kv, but you could bind it to a button or similar. You would also need to import the Window to kv, using the #:import statement explained in the doc.
1
1
0
I don't find how to force the window size with the kivy language. (ex: 800x600p) Can you help me ? Thanks for reading. PITO2901
Force Window Size Kivy
0.197375
0
0
1,505
27,239,706
2014-12-02T00:09:00.000
3
0
1
0
python,date
27,252,306
2
false
0
0
If there is no year; don't use datetime.date class. date must have year. Either compute date field on the fly everytime you need it if year is present, and/or make self.date property on your custom object to raise an error if it is used for an object without a year.
1
5
0
I have a script that looks at a list of birthdays and then calculates the age. Some birthdays have year, month, day and some only have month, day. For the ones with years, I have dob = date(year, month, day) But for the ones without years, what is the appropriate convention for storing the date, since date() requires a year argument? Right now I'm saying that everyone without a birth year was born in the year 1500 (so I can at least identify them easily later on), but it's obviously a stupid solution.
Python: Convention for date with no year
0.291313
0
0
2,033
27,241,268
2014-12-02T03:16:00.000
24
0
1
0
python-3.x,pycharm
41,670,055
12
false
0
0
In Pycharm: CMD + , (or Pycharm preferences); Search: "clear all"; Double click -> Add keyboard shortcut (set it to CTRL + L or anything) Enjoy this new hot key in your Pycharm console!
7
22
0
Is there a way to clear the "Run" console in PyCharm? I want a code that delete/hide all the print() made previously. Like the "clear_all" button, but without having to press it manually. I have read that there is a way to do it in a terminal with os.system("cls"), but in PyCharm, it only adds a small square without clearing anything. Also, I don't want to use print("\n" *100) since I don't want to be able to scroll back and see the previous prints.
Clear PyCharm Run Window
1
0
0
58,712
27,241,268
2014-12-02T03:16:00.000
0
0
1
0
python-3.x,pycharm
58,573,012
12
false
0
0
Just click the trash can icon to the left of the command window and it clears the command history!
7
22
0
Is there a way to clear the "Run" console in PyCharm? I want a code that delete/hide all the print() made previously. Like the "clear_all" button, but without having to press it manually. I have read that there is a way to do it in a terminal with os.system("cls"), but in PyCharm, it only adds a small square without clearing anything. Also, I don't want to use print("\n" *100) since I don't want to be able to scroll back and see the previous prints.
Clear PyCharm Run Window
0
0
0
58,712
27,241,268
2014-12-02T03:16:00.000
1
0
1
0
python-3.x,pycharm
62,864,343
12
false
0
0
In PyCharm terminal you can type 'cls' just like in linux terminal. For Python Console (where you see the output) assign a shortkey for "clear all" in File -> Settings -> Keymap -> Other -> "Clear all" You can also click somewhere on the PythonConsole -> Right button -> clear. Hope it helps
7
22
0
Is there a way to clear the "Run" console in PyCharm? I want a code that delete/hide all the print() made previously. Like the "clear_all" button, but without having to press it manually. I have read that there is a way to do it in a terminal with os.system("cls"), but in PyCharm, it only adds a small square without clearing anything. Also, I don't want to use print("\n" *100) since I don't want to be able to scroll back and see the previous prints.
Clear PyCharm Run Window
0.016665
0
0
58,712
27,241,268
2014-12-02T03:16:00.000
0
0
1
0
python-3.x,pycharm
65,587,408
12
false
0
0
In PyCharm 2019.3.3 you can right click and select "Clear All" button.This is deleting all written data inside of the console and unfortunately this is manual.
7
22
0
Is there a way to clear the "Run" console in PyCharm? I want a code that delete/hide all the print() made previously. Like the "clear_all" button, but without having to press it manually. I have read that there is a way to do it in a terminal with os.system("cls"), but in PyCharm, it only adds a small square without clearing anything. Also, I don't want to use print("\n" *100) since I don't want to be able to scroll back and see the previous prints.
Clear PyCharm Run Window
0
0
0
58,712
27,241,268
2014-12-02T03:16:00.000
0
0
1
0
python-3.x,pycharm
72,250,752
12
false
0
0
If you edit the run configuration you can enable "emulate terminal in output console" and you can use the os.system("cls") line and it will work normally.
7
22
0
Is there a way to clear the "Run" console in PyCharm? I want a code that delete/hide all the print() made previously. Like the "clear_all" button, but without having to press it manually. I have read that there is a way to do it in a terminal with os.system("cls"), but in PyCharm, it only adds a small square without clearing anything. Also, I don't want to use print("\n" *100) since I don't want to be able to scroll back and see the previous prints.
Clear PyCharm Run Window
0
0
0
58,712
27,241,268
2014-12-02T03:16:00.000
7
0
1
0
python-3.x,pycharm
59,173,412
12
false
0
0
Easy Method: Shortcut: Control K, Right click on terminal and clear Buffer
7
22
0
Is there a way to clear the "Run" console in PyCharm? I want a code that delete/hide all the print() made previously. Like the "clear_all" button, but without having to press it manually. I have read that there is a way to do it in a terminal with os.system("cls"), but in PyCharm, it only adds a small square without clearing anything. Also, I don't want to use print("\n" *100) since I don't want to be able to scroll back and see the previous prints.
Clear PyCharm Run Window
1
0
0
58,712
27,241,268
2014-12-02T03:16:00.000
1
0
1
0
python-3.x,pycharm
59,848,299
12
false
0
0
You could just do a ("\n" * 100000000), so it'll be impossible to scroll back.
7
22
0
Is there a way to clear the "Run" console in PyCharm? I want a code that delete/hide all the print() made previously. Like the "clear_all" button, but without having to press it manually. I have read that there is a way to do it in a terminal with os.system("cls"), but in PyCharm, it only adds a small square without clearing anything. Also, I don't want to use print("\n" *100) since I don't want to be able to scroll back and see the previous prints.
Clear PyCharm Run Window
0.016665
0
0
58,712
27,242,453
2014-12-02T05:26:00.000
3
0
0
0
python,active-directory,ldap,windows-server-2012
27,249,499
2
false
0
0
You need to modify the entry after it is created and set the userAccountControl attribute. The userAccountControl attribute is a bit flag. There are a few different enabled states that can be set. 512 - is a default enabled account 67048 - is an enabled account where the password does not expire
1
1
0
I am using ldap module in python to add user to Microsoft 2012 Active Directory. As I am successfully able to add user to the AD, user gets added with next logon and account as disabled options ticked. I tried lot of option to enable the account but not able to do so. Tried option of enabling account while creating user but that doesn't work too. Tried modify function but still no luck. Could anyone suggest a detour for the above problem? Thanks in advance
Enable Active Directory user account using ldap python
0.291313
0
0
2,653
27,243,455
2014-12-02T06:48:00.000
0
0
0
0
python,layout,pyqt,scrollbar
30,058,134
2
true
0
1
I found I can do this by creating separate QTabBar and QScrollBar widgets that are attached to a QTabWidget and QAbstractScrollArea (I'm using a QListWidget now but I'm sure it'll work for QGraphicsView too) and then putting those widgets in a QVBoxLayout, and then putting the QVBoxLayout next to the QTabWidget/QAbstractScrollArea via a QHBoxLayout.
1
0
0
I have a QGraphicsView in a QTabWidget with its tabs on the left. I want to move the location of the vertical scrollbar of my QGraphicsView to the left side, directly underneath the tabs. Is this possible?
PyQt move vertical scrollbar location in QGraphicsView
1.2
0
0
476
27,245,890
2014-12-02T09:27:00.000
0
0
1
1
python
27,246,214
3
false
0
0
you can use which python command to find what python you are using. This gives the output as path to symlink, you can find the original python by reading the symlink.
1
0
0
It looks like there is more than one Python installed on my mac. Modules installed are not recognized by python interpreter (2.7.6) until I add them to PYTHONPATH. Could anyone show me how I can locate all the Pythons installed on my mac? Thank you
How can I find out what different versions of Python installed on OSX?
0
0
0
132
27,255,560
2014-12-02T17:36:00.000
1
0
0
0
python,machine-learning,language-features,feature-selection
27,256,151
1
true
0
0
You either need to under-sample the bigger class (take a small random sample to match the size of the smaller class), over-sample the smaller class (bootstrap sample), or use an algorithm that supports unbalanced data - and for that you'll need to read the documentation. You need to turn your words into a word vector. Columns are all the unique words in your corpus. Rows are the documents. Cell values are one of: whether the word appears in the document, the number of times it appears, the relative frequency of its appearance, or its TFIDF score. You can then have these columns along with your other non-word columns. Now you probably have more columns than rows, meaning you'll get a singularity with matrix-based algorithms, in which case you need something like SVM or Naive Bayes.
1
2
1
I have been trying to build a prediction model using a user’s data. Model’s input is documents’ metadata (date published, title etc) and document label is that user’s preference (like/dislike). I would like to ask some questions that I have come across hoping for some answers: There are way more liked documents than disliked. I read somewhere that if somebody train’s a model using way more inputs of one label than the other this affects the performance in a bad way (model tends to classify everything to the label/outcome that has the majority of inputs Is there possible to have input to a ML algorithm e.g logistic regression be hybrid in terms of numbers and words and how that could be done, sth like: input = [18,23,1,0,’cryptography’] with label = [‘Like’] Also can we use a vector ( that represents a word, using tfidf etc) as an input feature (e.g. 50-dimensions vector) ? In order to construct a prediction model using textual data the only way to do so is by deriving a dictionary out of every word mentioned in our documents and then construct a binary input that will dictate if a term is mentioned or not? Using such a version though we lose the weight of the term in the collection right? Can we use something as a word2vec vector as a single input in a supervised learning model? Thank you for your time.
Training a Machine Learning predictor
1.2
0
0
232
27,256,519
2014-12-02T18:34:00.000
1
0
1
0
python,installation,pip
27,256,564
1
false
0
0
You are entering these commands in the Python shell. Exit it, and enter pip install moviepy at the regular command prompt.
1
0
0
i am having problem installing moviepy on my pytho3.4 version on windows. i wrote this code: py -3.4 -m pip install moviepy and got the error: File "<stdin>", line 1 py -3.4 -m pip install moviepy (the pointer is on 2nd 'p' of pip) SyntaxError: invalid syntax tried this: (sudo) pip install moviepy got the error: File "<stdin>", line 1 pip install moviepy (the pointer is on 2nd 'l' of install) SyntaxError: invalid syntax tried this: (sudo)pip install moviepy got the error: File "<stdin>", line 1 (sudo)pip install moviepy(the pointer is on 2nd 'l' of install) SyntaxError: invalid syntax I need help installing this package...i have pip installed in my version of python i.e. Python3.4
installing moviepy in python3.4 on windows
0.197375
0
0
1,458
27,259,478
2014-12-02T21:38:00.000
4
0
0
0
python,excel,openpyxl
27,280,801
1
true
0
0
In openpyxl cells are stored individually in a dictionary. This makes aggregate actions like deleting or adding columns or rows difficult as code has to process lots of individual cells. However, even moving to a tabular or matrix implementation is tricky as the coordinates of each cell are stored on each cell meaning that you have process all cells to the right and below an inserted or deleted cell. This is why we have not yet added any convenience methods for this as they could be really, really slow and we don't want the responsibility for that. Hoping to move towards a matrix implementation in a future version but there's still the problem of cell coordinates to deal with.
1
1
0
I'm trying to delete cells from an Excel spreadsheet using openpyxl. It seems like a pretty basic command, but I've looked around and can't find out how to do it. I can set their values to None, but they still exist as empty cells. worksheet.garbage_collect() throws an error saying that it's deprecated. I'm using the most recent version of openpyxl. Is there any way of just deleting an empty cell (as one would do in Excel), or do I have to manually shift all the cells up? Thanks.
Delete cells in Excel using Python 2.7 and openpyxl
1.2
1
0
2,658
27,261,392
2014-12-03T00:10:00.000
0
0
1
0
python,return,return-value,multiple-variable-return
27,261,525
5
false
0
0
However, depending on the input given, the function may produce multiple pairs, which will result in the function returning [[a, b], [c, d], [e, f]]. Instead, I would like it to return [a, b], [c, d], [e, f] Can you not just use the returned list (i.e. the list [[a, b], [c, d], [e, f]]) and extract the elements from it? Seems to meet your criteria of arbitrary number of / multiple values.
1
7
0
I know that it is possible for a function to return multiple values in Python. What I would like to do is return each element in a list as a separate return value. This could be an arbitrary number of elements, depending on user input. I am wondering if there is a pythonic way of doing so? For example, I have a function that will return a pair of items as an array, e.g., it will return [a, b]. However, depending on the input given, the function may produce multiple pairs, which will result in the function returning [[a, b], [c, d], [e, f]]. Instead, I would like it to return [a, b], [c, d], [e, f] As of now, I have implemented a very shoddy function with lots of temporary variables and counts, and am looking for a cleaner suggestion. Appreciate the help!
Returning every element from a list (Python)
0
0
0
48,754
27,264,051
2014-12-03T05:06:00.000
2
0
0
0
python,python-3.x,tkinter,pygame
27,306,611
1
false
0
1
I have not implemented the solution to this particular problem personally, but I will try to suggest one. Of course any of the solutions will slow down your programm cardinally, but technically it is possible. So what is probably worth trying, that you could use pygame.image.tostring() on you current frame, then just write (append) every frame to a file. So that will be actually your video in a raw format. Now if you want some particular video format, you should just convert it, best way is to use ffmpeg (you can call it before game exit with certain parameters from your game with subprocess.Popen("ffmpeg ...")). The only problem here is that the user, who want to record in such a way, must have ffmpeg installed in the system, so that ffmpeg is callable from the shell commandline. Advantage of this approach - it should be quite fast and does not use much extra memory, since you encode only once (for example when the user stops recording or exits the game) from the binary stream. Edit: that is just a broad description, of course you should find out also the wright parameters for ffmpeg, such as frame count, size and so on, and of course delete the raw data, since it can be really big file.
1
7
0
I'd like to add a feature where a user can record a video of the game that they're playing. How do I do this?
How do you record a "game" (PyGame or Tk) into a video?
0.379949
0
0
2,016
27,267,159
2014-12-03T08:46:00.000
1
0
0
0
python,linux,psutil,cpu-load
27,490,136
1
false
0
0
Yes, psutil.cpu_times_percent() should reflect the same timings as shown by 'top' but of course they cannot be exactly the same, just approximately the same.
1
3
0
I'm writing a program that will perform some logging of my company's webserver load. One information I need to log is the server's CPU Load. I know that CPU Load -- in monit or top/htop -- reflects the total load across cores, normalized against 1 core. So, for an 8 core server, the total load (when it's heavily loaded) will be higher than 100%. And when all cores are running full load, might reach 800%. However, monit and top/htop also might show oversubscribed CPU Load, in which the CPU Load number is higher than 800%, indicating that jobs are being queued. I'm interested in such situation. My questions: Does the psutil.cpu_times_percent() function behave the same as monit's/top's CPU Load indicator? That is, will the percentage returned be higher than 100% (cpu_times_percent() normalizes to 100% instead of to 1 core) if there are jobs being queued? If the answer to #1 is "no", then how can I detect oversubscription / jobs being queued?
Python's psutils -- will it reflect CPU Load similar to top/monit?
0.197375
0
0
683
27,269,574
2014-12-03T10:42:00.000
125
0
0
0
python,django,configuration,ide,pycharm
28,256,637
2
true
1
0
Yes you can. In Run -> Edit Configurations create new configuration [+] / Python Name: runserver Scrip Path: path_to/manage.py Parameters: runserver
1
43
0
Has anyone had issues setting up a debug configuration for Django project in PyCharm Community Edition? Community Edition of the IDE is lacking the project type option on project setup and then when I am setting up Debug or Run config it asks me for a script it should run. What script would it be for Django, manage.py? Thanks in advance
How to run Debug server for Django project in PyCharm Community Edition?
1.2
0
0
28,760
27,271,747
2014-12-03T12:26:00.000
0
0
0
1
python-2.7,nginx,python-requests,pyopenssl
28,087,767
1
false
0
0
Many TLS clients and servers consider it reasonable to abruptly close the TCP connection without finishing the TLS disconnect handshake. They may not do it all the time. It may depend on very specific, esoteric network conditions (eg, how quickly certain sends are executed). When this happens, you get the error you've reported. Typically this isn't actually a problem. All application data has been transferred already. Unfortunately you can't be entirely sure about this (that's part of the reason there is a TLS disconnect handshake) but there may also be little or nothing you can do about it. I don't know that nginx's TLS support closes connections this way but if this is the only symptom (in other words, if you're not losing application data) and your server uses Content-Length or Transfer-Encoding: chunked (to offer you some other protection against truncation attacks) this might just be expected behavior.
1
0
0
After installing pyopenssl, ndg-httpsclient and pyasn1 to support SSL with SNI. I get the following error, for certain https urls: (-1, 'Unexpected EOF') only when running under nginx tried: removing the gzip from nginx.
Unexpected EOF for https with python requests under nginx
0
0
0
1,403
27,273,499
2014-12-03T13:54:00.000
0
0
0
1
java,python,c++,multithreading,affinity
27,275,002
2
false
0
0
I'm not sure I understand what you want exactly, but in Java I remember that I could launch multiple JVM and run my java programs on different OS processes, using inter-processes communication (socket, pipe or whatever you want) to do multi-core processing and syncronization. Knowing that, it might be possible to then set a process (whole JVM) exclusively on a core. You can get the PID of the JVM.
1
1
0
When I create a thread with Java or Python I can't find the pid among the operating system threads. In fact get_ident() in Python gives me a very large number that can't be the PID. In fact I need to set the process affinity of all other threads to the first processor core then I want to dedicate the other cores to my specific threads run in a program to create a real time environment. The threads will be less than remaining processor cores. As I have read in stackoverflow it is not possible in Java and there will be the esigence of native calls. Can it be done in Python or I must use C/C++? The program will be installed in a Linux machine.
set thread affinity in python and java
0
0
0
1,814
27,276,680
2014-12-03T16:23:00.000
3
0
1
0
python,keyboard-shortcuts,shortcut
27,276,785
2
true
0
0
If you're in IDLE, use Alt+P and Alt+N to navigate your command history.
2
1
0
When I use R and execute a command in the command window, I can just press up and I get the last executed command in the current command line. What key do I need to press in order to get the same in Python? Edit: When I asked this question, I did not know what IDLE or iPython is. I just googled "download python" and downloaded it. But now I know I am using IDLE.
How to get the last executed command in IDLE as in R?
1.2
0
0
415
27,276,680
2014-12-03T16:23:00.000
1
0
1
0
python,keyboard-shortcuts,shortcut
33,307,145
2
false
0
0
For anyone else who comes upon this looking for a mac solution, I found that Contrl+Option+n and Contrl+Option+n worked to cycle through previously executed lines in IDLE (Python) 2.7.10 on OS 10.8.5. I realize that this should work without the Option, but for months I needed to use both modifier keys to execute the shortcut properly.
2
1
0
When I use R and execute a command in the command window, I can just press up and I get the last executed command in the current command line. What key do I need to press in order to get the same in Python? Edit: When I asked this question, I did not know what IDLE or iPython is. I just googled "download python" and downloaded it. But now I know I am using IDLE.
How to get the last executed command in IDLE as in R?
0.099668
0
0
415
27,278,145
2014-12-03T17:39:00.000
2
0
0
1
python,windows,path,directory
27,278,464
2
false
0
0
I second @iCodez's answer to use os.getenvto get the path string from a system environment variable, but you might want to use the paths defined for APPDATA or LOCALAPPDATA instead. Windows permissions settings on the Program Files directory may prevent a standard user account from writing data to the directory. I believe the APPDATA and LOCALAPPDATA paths were designed for just such a use. On my system, APPDATA = C:\Users\myname\AppData\Roaming and LOCALAPPDATA = C:\Users\myname\AppData\Local. My user account has full read/write permission for both directories.
1
0
0
I've made a game and I'd like to save the highscore. So I need a place to do that. I chose to put it in the C:\All Programs directory. My problem is that that directory name isn't the same on every computer. For example on mine it's C:/Program Files (x86). So my question: Is there a way, to discover that path on any computer? PROBLEM SOLVED: os.getenv('PROGRAMFILES')
Find C:\Programs path (not scripts path)
0.197375
0
0
124
27,278,297
2014-12-03T17:47:00.000
0
0
0
1
google-app-engine,google-cloud-storage,google-cloud-datastore,mysql-python,app-engine-ndb
28,197,823
1
false
1
0
MySQL commands cannot be run on NoSQL. You will need to do some conversions during manipulation of the data from both DBs.
1
1
0
Is it just about creating models that use the best fitting data store API? For part of the data I need relations, joins and sum(). For other this is not necessary but nosql way is more appropriate.
can I combine NDB and mysqldb in one app on google cloud platform
0
1
0
62
27,279,922
2014-12-03T19:21:00.000
0
1
0
0
python,python-3.x,bots,irc
27,316,992
1
true
0
0
It sounds like you want to write the same QUIT log message to multiple per-channel log files, but only specific ones the bot is in? To accomplish something similar, I ended up getting the list of names in a channel when the bot joins, then keeping track of every nick change, join, part, kick, and quit, and adjusting the bot's internal list. That way, on a quit, I could just check the internal list and see what channels they were on.
1
0
0
So I'm writting an IRC bot in Python. Right now, the first thing I'm trying to get it to do is Log all the important things in every channel it's on (as well as private messages to the bot itself). So far I've gotten it to log the JOIN, PRIVMSG (including CTCP commands) and PART. However I'm having some trouble with the QUIT command. Now I know the QUIT command doesn't include the <channel> parameter because it doesn't need it. However my bot is connected to multiple channels and I need to be able to differentiate which channels the user was connected to when he/she issued the QUIT command to appropriate log it. Many users won't be connected to every channel the bot is. What would be the ideal way to go about this? Thanks for your help.
Logging where the QUIT command comes from in IRC
1.2
0
1
73
27,280,673
2014-12-03T20:07:00.000
0
0
1
0
python,parallel-processing,queue,gevent
27,281,582
1
true
0
0
This is a very simple approach, but might work within the constraints you've outlined. However, it does not make use of gevent directly. Write the output of each task to a temporary file named according to the id (order) of the task. When all tasks are complete, read the files in order and append the contents of each to the final output file. Thus, the contents of only one task's output is in memory at any given time.
1
0
0
Currently, there is a Python project using gevent to submit tasks that execute socket calls to one of our computing resources. The python program generates the requests of almost 1000 objects and executes them concurrently. When it receives the request (fixed width string stream), it writes the output straight into a file and appending to this file as the task results come in. This keep memory overhead low and keeps moving things as fast as possible. Now, as with all projects, a new requirement has been introduced. The Python solution needs to sort the data in the file. What complicates this is the fact that the output file is fixed width and slicing it up/sorting within Python would be too much throw away work. Is there a pattern where gevent can execute a list of tasks in parallel but, somehow, keep the results in the same order it was submitted in the list? I do have to keep in mind that the results that come back are sizable and I'm trying to keep memory requirements as low as possible.
How to process multiple tasks concurrently while maintaining order on the input & output?
1.2
0
0
138
27,283,326
2014-12-03T23:02:00.000
0
0
0
0
python,json,python-requests
27,283,764
1
true
0
0
Jon Skeet: Looks like it's the format from DataContractJsonSerializer apart from anything else - millis since the Unix epoch, and offset from UTC
1
0
0
I haven't been able to find an answer to this, and I was hoping y'all could help me out. When accessing the API for one of the products we use at work, a date field comes back in two different forms depending on if you request JSON or XML. The first, which I understand, is what XML sends: 2014-12-03T23:59:00 The second, is what I can't figure out. When requesting JSON, it sends the same date in the following format: \/Date(1417672740000-0600)\/ Forgive me if this has already been answered, I just haven't been able to find it here or on Google. Hopefully it's something I should already know. FYI, I'm using the requests module for Python.
API Date in a Strange Format
1.2
0
1
43
27,285,162
2014-12-04T02:17:00.000
0
0
1
0
java,python,eclipse,pydev
27,285,251
2
false
0
0
1 way to solve this problem is by turning off Automatically Closed parentheses. Open the preferences for editing, then go to Java -> Editor -> Typing and turn off parentheses.
2
3
0
This isn't really a coding problem, but more of just an Eclipse problem. Say you're typing x = (1), Eclipse will make the closing parenthesis for you the moment you type '(' It also normally writes over the closing parenthesis as you are typing as well. However, for some reason when I'm typing, it doesn't automatically write over it and I'm confused because I'm pretty sure I didn't hit any special setting so I have no idea what to do to revert this. So normally you'll type x = (1), and it'll show as x = (1), but right now it's showing x(1)). How do I change it back?? Thanks for the help!
Eclipse isn't overwriting parenthesis
0
0
0
213
27,285,162
2014-12-04T02:17:00.000
0
0
1
0
java,python,eclipse,pydev
27,285,239
2
false
0
0
Check in the Settings Content Assist for your Editor. It has a setting to overwrite or not. And in my case it specifically mentions you can toggle that with Ctrl Key while the assist is active. The other setting related is Editor -> Typing. It also has some brace-close settings.
2
3
0
This isn't really a coding problem, but more of just an Eclipse problem. Say you're typing x = (1), Eclipse will make the closing parenthesis for you the moment you type '(' It also normally writes over the closing parenthesis as you are typing as well. However, for some reason when I'm typing, it doesn't automatically write over it and I'm confused because I'm pretty sure I didn't hit any special setting so I have no idea what to do to revert this. So normally you'll type x = (1), and it'll show as x = (1), but right now it's showing x(1)). How do I change it back?? Thanks for the help!
Eclipse isn't overwriting parenthesis
0
0
0
213
27,293,173
2014-12-04T11:42:00.000
4
0
0
1
linux,python-2.7,plone,sles
27,300,059
1
false
1
0
The installer command: ./install.sh standalone --build-python --static-lxml=yes worked perfectly for me. The installer downloaded and built the Python and libxml2/libxslt components necessary to remedy the terribly out-of-date (and vulnerable) versions included with sles11sp3. System packages needed for the build were: gcc-c++ make readline-devel libjpeg-devel zlib-devel patch libopenssl-devel libexpat-devel man All installed via zypper. I'd advise not using sudo for the install. If you want to, you'll need to create the plone_daemon and plone_buildout users and the plone_group group in advance due to oddities in SUSE's adduser implementation.
1
1
0
I'm trying to install plone 4.3.4 on a SLES 11 SP3 64bit server via the Unified Installer. I've fullfilled all the dependencies listed in the readme.txt, but when I try to get the installer running with the command sudo ./install.sh --password=******* standalone I get the error message: which: no python2.7 in (/usr/bin:/bin:/usr/sbin:/sbin) Unable to find python2.7 on system exec path. I find that rather strange as in the description of the unified installer it is said "The new Zope/Plone install will use its own copy of Python, and the Python installed by the Unified Installer will not replace your system's copy of Python. You may optionally use your system (or some other) Python, and the Unified Installer will use it without modifying it or your site libraries." on the Plone-Website. So - what am I doing wrong??? I've just tried adding the parameter --build-python but had to find out that the libxml2-devel and libxslt-devel libraries that are available for SLES-11-SP-3 are sadly not up-to-date enough 2.7.6 instead of 2.7.8 and 1.1.24 instead of 1.1.26 respectively. So no joy there either. :-( Is there any way to install the current version of plone on SLES 11 SP3 64bit? Kate
Plone Unified Installer missing Python
0.664037
0
0
226
27,297,668
2014-12-04T15:24:00.000
0
0
0
0
python,powerpoint
27,297,868
1
true
0
1
It is probably possible to modify a .pptx file with the standard library without much effort: these new generation of files are meant to be zip-compressed XML + external images files, and can be handled by ziplib and standard xml parsers. Legacy .ppt files however are a binary closed format, with little documentation, and hundrededs of corner cases. It would alwasys "be possible" to change them, since they are still just bytes, but it would take considerable effort. That said, starting with Python 3.4, the Python installer "PIP" comes default with the language install: probably the best way to go would be to script the installation of external libraries based on the built-in PIP - that way one would not have to all external library usage.
1
0
0
I know this is possible to do using additional libraries such as win32com or python-pptx, but I wasn wondering if anyone knew of a way to insert an image into a powerpoint slide using the standard libraries. Lots of googling has indicated that the best solution is probably win32com, but since I can guarantee that every system this script will be deployed to will have win32com, I am looking for an implemention leveraging libraries all systems with a standard python 2.7 install will have.
Insert Image into PPT using Standard Libraries
1.2
0
0
507
27,300,409
2014-12-04T17:36:00.000
2
1
1
0
python,python-3.x,hash,cryptography,digital-signature
27,312,944
2
false
0
0
The best standardized algorithm currently available is still SHA-2. SHA-2 now consists of 6 hash functions: SHA-256, SHA-384 and SHA-512 were first defined. SHA-224 was later added to allow for a smaller output size. After that the less well available SHA-512/224 and SHA-512/256 were introduced. SHA-2 mainly consists of the 32-bit oriented SHA-256 variants - SHA-256 and SHA-224 - and the 64-bit SHA-512 variants - the others. The performance of the SHA-512 variants may actually be higher on 64 bit machines, hence the introduction of SHA-512/224 and SHA-512/256. Basically the variants of SHA-256 / SHA-512 only differ in the constants they use internally and the amount of bits used as output size. Some newer Intel and AMD processors SHA extensions that only accelerate SHA-256, not SHA-512, possibly shifting the favor again towards SHA-256 with regard to speed. During the SHA-3 competition it came to light that SHA-2 is still pretty strong, even if SHA-1 is under attack. I would suggest only to look at other hashes if SHA-2 is under attack or if better hash algorithms get standardized and used. From Wikipedia: In 2005, security flaws were identified in SHA-1, namely that a mathematical weakness might exist, indicating that a stronger hash function would be desirable.[6] Although SHA-2 bears some similarity to the SHA-1 algorithm, these attacks have not been successfully extended to SHA-2. Note that SHA-2 uses a considerably more complex round function compared to SHA-1. So although it has a similar structure (both are so called Merkle-Damgard hashes) SHA-2 may be much more resistant than SHA-1 against attack none-the-less.
1
6
0
I am writing a program in Python for elliptic curve cryptography (for school and out of interest). I am currently working on the digital signature algorithm. I am currently looking for a good and secure hashing function which is either standard in Python or can easily be downloaded and imported. I thought about SHA256, since that's the only one I know which hasn't been broken yet (as far as I know). However, I have also read that SHA shouldn't be used for cryptography. Is SHA256 appropriate for a digital signature algorithm? Or should a different hashing function be used? If so, which one would be a good choice?
Cryptographic hash functions in Python
0.197375
0
0
5,345
27,304,973
2014-12-04T22:01:00.000
0
0
0
0
python,tkinter
27,305,312
1
true
0
1
No, there isn't a way to tell what type of event is flagged by <<ListboxSelect>>. Using <<ListboxSelect>> is useless for binding to a letter key, however. It only will fire for mouse clicks and using the arrow keys to navigate the listbox. You can bind to <KeyPress>. That binding will tell you what key was pressed, and in that binding you can change the widget's selection. You can get that information from event.keysym
1
0
0
I am binding to ListBoxSelect and i want to implement a function which recognizes an alphabetical key-press and uses this to jump to the corresponding place in an alphabetically sorted list. Is there a way to tell what type of event is flagged by ListBoxSelect? I see something in the documentation about getting event "keysym" but i dont know how to access this.
How to determine the type of event flagged by <> in Tkinter?
1.2
0
0
47
27,308,234
2014-12-05T03:25:00.000
8
0
1
1
python,macos,python-2.7,numpy,matplotlib
27,308,244
2
true
0
0
Points to keep in mind about Python If a script foobar.py starts with #!/usr/bin/env python, then you will always get the OS X Python. That's the case even though MacPorts puts /opt/local/bin ahead of /usr/bin in your path. The reason is that MacPorts uses the name python2.7. If you want to use env and yet use MacPorts Python, you have to write #!/usr/bin/env python2.7. If a script foobar.py starts explicitly with #!/usr/bin/python or with #!/opt/local/bin/python2.7, then the corresponding Python interpreter will be used. What to keep in mind about pip To install pip for /usr/bin/python, you need to run sudo /usr/bin/easy_install pip. You then call pip (which will not be installed by easy_install in /usr/bin/pip, but rather in /usr/local/bin/pip) To install pip for /opt/local/bin/python2.7, you need to run sudo port install py27-pip. You would then call pip-2.7. You will get the pip in /opt/local/bin. Be careful, because if you type pip2.7 you will get /usr/local/bin/pip2.7 (the OS X pip). Installing networkx and matplotlib To install networkx for the OS X Python you would run sudo /usr/local/bin/pip install networkx. I don't know how to install matplotlib on OS X Lion. It may be that OS X has to stick to numpy 1.5.1 because it uses it internally. To install networkx and matplotlib for MacPorts-Python, call sudo pip-2.7 install networkx and sudo pip-2.7 install matplotlib. matplotlib installs with a lot of warnings, but it passes.
2
6
1
Can you shed some light on the interaction between the Python interpreter distributed with OS X and the one that can be installed through MacPorts? While installing networkx and matplotlib I am having difficulties with the interaction of /usr/bin/python and /opt/local/bin/python2.7. (The latter is itself a soft pointer to /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7) How can I be certain which Python, pip, and Python libraries I am using at any one time? More importantly, it appears that installing matplotlib is not possible on Lion. It fails with Requires numpy 1.6 or later to build. (Found 1.5.1). If I upgrade by running sudo pip install --upgrade numpy, it does not help. Subsequently attempting to install matplotlib (sudo /usr/local/bin/pip install matplotlib) still fails with the same (Requires numpy 1.6...) message. How can I install matplotlib?
/usr/bin/python vs /opt/local/bin/python2.7 on OS X
1.2
0
0
10,161
27,308,234
2014-12-05T03:25:00.000
0
0
1
1
python,macos,python-2.7,numpy,matplotlib
27,400,616
2
false
0
0
May I also suggest using Continuum Analytics "anaconda" distribution. One benefit in doing so would be that you won't then need to modify he standard OS X python environment.
2
6
1
Can you shed some light on the interaction between the Python interpreter distributed with OS X and the one that can be installed through MacPorts? While installing networkx and matplotlib I am having difficulties with the interaction of /usr/bin/python and /opt/local/bin/python2.7. (The latter is itself a soft pointer to /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7) How can I be certain which Python, pip, and Python libraries I am using at any one time? More importantly, it appears that installing matplotlib is not possible on Lion. It fails with Requires numpy 1.6 or later to build. (Found 1.5.1). If I upgrade by running sudo pip install --upgrade numpy, it does not help. Subsequently attempting to install matplotlib (sudo /usr/local/bin/pip install matplotlib) still fails with the same (Requires numpy 1.6...) message. How can I install matplotlib?
/usr/bin/python vs /opt/local/bin/python2.7 on OS X
0
0
0
10,161
27,308,293
2014-12-05T03:32:00.000
-2
0
1
0
python,duplicates,package,pip
27,308,401
9
false
0
0
This is not possible with the pip command line tool. All of the packages on PyPI have unique names. Packages often require and depend on each other, and assume the name will not change.
5
51
0
When installing a new python package with PIP, can I change the package name because there is another package with the same name? Or, how can I change the existing package's name?
How to install python package with a different name using PIP
-0.044415
0
0
22,776
27,308,293
2014-12-05T03:32:00.000
13
0
1
0
python,duplicates,package,pip
55,817,170
9
false
0
0
It's not possible to change "import path" (installed name) by specifying arguments to pip. All other options require some form of "changes to the package": A. Use pip install -e git+http://some_url#egg=some-name: that way even if both packages have the same import path, they will be saved under different directories (using some-name provided after #egg=). After this you can go to the source directories of packages (usually venv/src/some-name) and rename some folders to change import paths B-C. Fork the repository, make changes, then install the package from that repository. Or you can publish your package on PyPI using different name and install it by name D. use pip download to put one of the packages in your project, then rename folders as you like
5
51
0
When installing a new python package with PIP, can I change the package name because there is another package with the same name? Or, how can I change the existing package's name?
How to install python package with a different name using PIP
1
0
0
22,776
27,308,293
2014-12-05T03:32:00.000
0
0
1
0
python,duplicates,package,pip
48,315,327
9
false
0
0
I Don't think it is possible to change the name of package by using pip. Because pip can install packages which are exist and gives error if there is no package name which you write for change the name of package.
5
51
0
When installing a new python package with PIP, can I change the package name because there is another package with the same name? Or, how can I change the existing package's name?
How to install python package with a different name using PIP
0
0
0
22,776
27,308,293
2014-12-05T03:32:00.000
2
0
1
0
python,duplicates,package,pip
49,680,767
9
false
0
0
If you are struggling to install the correct package when using pip install 'module', you could always download its corresponding wheel file (.whl extension) and then install this directly using pip. This has worked for me in various situations in the past.
5
51
0
When installing a new python package with PIP, can I change the package name because there is another package with the same name? Or, how can I change the existing package's name?
How to install python package with a different name using PIP
0.044415
0
0
22,776
27,308,293
2014-12-05T03:32:00.000
4
0
1
0
python,duplicates,package,pip
50,367,038
9
false
0
0
Create a new virtualenv and then install the package on new virtualenv, with this you can have the different version of packages as well.
5
51
0
When installing a new python package with PIP, can I change the package name because there is another package with the same name? Or, how can I change the existing package's name?
How to install python package with a different name using PIP
0.088656
0
0
22,776
27,308,836
2014-12-05T04:35:00.000
1
0
0
0
python,module,openerp-7,odoo,time-management
27,353,088
1
true
1
0
You can manage this by grouping each employee according to their privilege. For example you have two groups Managerial and employee group so each of them might have different or some how common privilege on certain python objects from OpenERP so please identify those python objects and explore more in Setting >> Users >> Groups
1
0
0
I have downloaded and installed and also tested via a virtual machine online Odoo 8 and OpenErp 7. I have spent many hours tinkering with the apps and features of both. I am unable to find any way from hours I spend searching or tinkering for a method to change the approve timesheet functionality in the manner I will explain below. Each project will have an assigned manager. Any number employees can enter time for a project. Once employees send their timesheet to be be approved, each respective manager will only get that portion of the timesheet for which time was charged to the project they managed. They should be able to view each project and the employees in them.
In using OpenErp 7 or Odoo 8, how do I modify it such that a manager assigned to a project is the one who will approve all timesheet entries for it?
1.2
0
0
364
27,309,902
2014-12-05T06:13:00.000
1
0
1
0
python,json
27,310,481
1
true
0
0
close the reading instances with instance.close() after loading the values with json_object.loads().
1
0
0
I am working on an attendance system on Local server which contains the database file in json format and when a request is made to the system via RFID the script looks into the local json file for the RFID and respond accordingly. Now the problem is that for single request it is performing well but as our script(made in Python 3.3) works on multiple threading so when two or more request hits at the same time i get an exception of "expecting object:line 1 column" ... like this. So what is the problem in the script or what can be the possible solution for this. Remember there is no online request made during the script working.
Error on reading json file by multiple instances at the same time
1.2
0
1
135
27,311,941
2014-12-05T08:45:00.000
1
0
0
0
python,arrays,numpy
27,312,169
1
true
0
0
Just putting a list(...) call around your call to normal will turn it into a regular Python list.
1
0
1
I am using the function numpy.random.normal(0,0.1,20) to generate some numbers. Given below is the output I get from the function. The problem is I want these numbers to be in an array format. [ 0.13500488 0.11023982 0.09908623 -0.01437589 0.00619559 -0.17200946 -0.00501746 0.07422642 0.1226481 -0.01422786 -0.02986386 -0.02507335 -0.12959589 -0.09346143 -0.01287027 0.02656667 -0.07538371 -0.10534301 -0.02208811 -0.14634084] Can anyone help me?
How to convert numpy distribution to an array?
1.2
0
0
330
27,315,254
2014-12-05T11:47:00.000
0
0
1
1
python,windows,login
27,330,723
1
true
0
0
So I've found a way to do it from a Windows service (written in C++) and presumably the ctypes library will permit me to use it. Simple as using LogonUser from Win32API so far as I can see. Yet to actually set up and test it but it does seem to be exactly what I need. The difficulty being that session0 can only be accessed once logged in or via some remote debugging, so getting something like this working is no easy feat.
1
0
0
I'm theory crafting a Python service which will manipulate domain joined machines into running tests as part of a suite. Details of requirements We must be logged in as a domain user, and we must not have the automatic login enabled We need to reboot machines a few times, so it's a requirement for this to be sustainable I'm wondering if it's possible to, from a Python service, somehow convince Windows to log us in? Presumably a Python service runs in Session0, as does Microsoft's Hardware Certification Kit? If that's capable of doing it, Python should also be (so far as I can see). Any suggestions most welcome, I've got a suspicion there's a cheeky Windows API call that does this, but can't seem to find it anywhere.
Log in to Windows from a Python service?
1.2
0
0
46