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
16,479,249
2013-05-10T09:35:00.000
2
0
0
1
multithreading,wsgi,python-multithreading
16,480,852
1
true
1
0
You mean why do you have 3 extra per mod_wsgi daemon process. For your configuration, 15 new threads will be created for handling the requests. The other 3 in a process are due to: The main thread which the process was started as. It will wait until the appropriate signal is received to shutdown the process. A monitor thread which checks for certain events to occur and which will signal the process to shutdown. A deadlock thread which checks to see if a deadlock has occurred in the Python interpreter. If it does occur, it will sent an event which thread (2) will detect. Thread (2) would then send a signal to the process to quit. That signal would be detected by thread (1) which would then gracefully exit the process and try and cleanup properly. So the extra threads are all about ensuring that the whole system is very robust in the event of various things that can occur. Plus ensuring that when the process is being shutdown that the Python sub intepreters are destroyed properly to allow atexit registered Python code to run to do its own cleanup.
1
3
0
I have deployed a wsgi application on the apache and I have configured it like this: WSGIDaemonProcess wsgi-pcapi user= group= processes=2 threads=15 After I restart the apache I am counting the number of threads: ps -efL | grep | grep -c httpd The local apache is running only one wsgi app but the number I get back is 36 and I cannot understand why. I know that there are 2 processes and 15 threads which means: 15*2+2=32 So why do I have 4 more?
How to count the threads and process of WSGI?
1.2
0
0
1,298
16,481,015
2013-05-10T11:14:00.000
1
1
1
0
python,exception,constants,organization
20,154,892
1
false
0
0
There are really two options to solve your problem. The first approach is to classify all the constants and exceptions, and have a smaller number of broader categories. This would allow you to easily navigate into which categories you want. A dictionary (or probably nested dictionaries) would be a good way to implement this, as you could maintain groups with titles in them. A second way you could do this if you wanted to customize the management a little bit more would be to make a class that would act a bit like a dictionary. It would have a list of children objects. This way, you could make unique, easier to access methods to navigate through all of your constants and exceptions, such as a new exception class that handles several similar exceptions. The other way to make it cleaner, which would require access to the source, would be to make all of those exceptions into a smaller group of exceptions that can each handle groups of similar problems. This would probably be a better way to deal with the exceptions, but you may not have access to the source to modify this.
1
5
0
I'm writing a Python module that has only about twenty interesting types and global methods, but lots of constants and exceptions (about 70 constants for locales, 60 constants for encodings, 20 formatting attributes, more than 200 exceptions, and so on). As a result help() on this module produces about 16,000 lines of text and is littered with nearly identical descriptions of each exception. The constants are not that demanding, but it's still difficult to navigate them. What would be a pythonic way to organize such a module? Just leave it as is and rely on other documentation? Move constants into separate dicts? Into submodules? Add them as class-level constants, where appropriate? Note that this is a C extension so I cannot easily add a real submodule here. I've heard that sys.modules doesn't really check if the object there is a module, so one could add dictionaries there; this way I could probably create mymodule.locales, mymodule.encoding, and mymodule.exceptions and add them into sys.modules when my module is imported. Would this be a good idea or it's too hackish?
How to organize a Python module with lots of constants and exceptions?
0.197375
0
0
776
16,485,470
2013-05-10T15:14:00.000
0
0
0
0
python,button,gtk
33,197,888
2
false
0
1
Assuming you are using a gtk.Entry() and a gtk.Button(), I think what you need to do is just connecting the gtk.Entry() to your data-process function like this: b = gtk.Button("Process") b.connect("clicked", data-process) e = gtk.Entry() e.connect("activate", data-process) That should do the "Trick". Hope this helped.
1
0
0
I want a key press to be mapped with a button click function in Gtk-python, i.e. if Enter key is pressed, the data-process function should execute, which is called by pressing the process button. Can this be done?
Map a key press to a button click in Gtk Python
0
0
0
1,088
16,487,059
2013-05-10T16:43:00.000
0
0
0
0
python,qt,user-interface,pyside
16,492,340
1
false
0
1
This may or may not help but when I encountered this the only thing that helped was reinstalling/updating pyside. I thought the fixed that bug a while back however.
1
2
0
I've been experiencing a really weird bug recently: Often when I zoom too much on a QGraphicsItem (using scale on the view containing it) that has a QGraphicsDropShadowEffect on it, my app closes with a segmentation fault (core dumped) error. What's weird is that: I use Python (with the PySide binding) If I remove the QGraphicsDropShadowEffect, the bug disappears I also had to remove the QGraphicsDropShadowEffect on a relatively big item because it got the app so slow to the point it became irresponsive when I zoomed a bit too much. Do anyone know how I could fix this ?
Qt : Segfault when zooming on QGraphicsDropShadowEffect
0
0
0
150
16,487,863
2013-05-10T17:34:00.000
0
0
0
0
python,django
16,488,072
2
false
1
0
Are you depending on the garbage collector to close your files? I.E. the handle goes out of scope and even though you've "closed" the file, it won't go away until GC runs. If the object chain never goes out of scope, GC cannot collect it. Also, if GC does not get an opportunity to run, they won't be collected either. I ran into the same issue with a long running process, and "solved" it by redesigning my system, such that all file access happened inside of a child object. That object got removed from the reference chain after it was done being used, or some error occurred. This allowed the GC to collect the handles.
1
1
0
I recently got an exception on my server about "Too many open files". I checked lsof, and sure enough, there are a bunch of PDF files that remain open (all in the same directory). This particular file is managed through a Django FileField. I've tried to track down any places in my project that explicitly open the file by name, and there's only one place I can find, and from what I can tell the file is being closed correctly there. There may be other places where the file is remaining open, but I have no idea how to find out what piece of code is actually keeping the file open. I've tried simply grepping for calls to open() and file(), but no luck. Is there any way to systematically track down what line of code is responsible for leaving the file open? EDIT: I understand how to properly open/close a file. My question is whether or not there is a way to track down an existing line of code that leaves is leaving a file open.
How can I find out which line of code is leaving a file open?
0
0
0
88
16,490,263
2013-05-10T20:23:00.000
0
0
0
0
python,user-interface,frame,wxwidgets
16,537,239
3
false
0
1
I'm not sure you can move a wxPanel from a wxFrame to another on the fly on wx. The main reason is that the panel is dependent of its parent and you can't change it on the fly. Now if you really want to do it, you'll have to create copy the panel in the other frame and delete the previous panel and frame (or just hide them). There's no built in copy but you can find a way to get the content of your original panel and copy it on the other one.
1
2
0
I am designing a GUI with several components and two wx.Frame objects F1 and F2. F1 is the main frame and F2 is the secondary frame. I would like to have a mechanism, so the user can attach these two frames into one frame, and also detach them into two frames again if needed. Assume F1 and F2 contain panels P1 and P2 respectively. When detached, the use should be able to move and resize each frame independently, and closing F1 will close the entire GUI. When attached, F1 will contain both P1 and P2 vertically and F2 will seem to vanish and become a part of F1. There is a lot of wiring and events and messages passed between P1 and P2 which should work in both attached and detached modes. I have seen this effect in some modern GUI's, but I was unable to find a proper technique online to carry this out. What is a proper way to do this? Thanks
Attach/Detach two frames in wxpython
0
0
0
829
16,490,795
2013-05-10T21:02:00.000
4
0
0
0
python,sockets,osi
16,491,016
1
true
0
0
Yes, that's correct. Note that the OSI model is not commonly used in practice. More typically, you see the Internet Reference model, which compresses the OSI layers 5, 6, and 7 into a single layer called the Application Layer.
1
0
0
In Python I have been playing around with server sockets that listen for messages, and client socket connections that send the data to the server. Am i correct in thinking that the server/client python programs that utilize the socket module span layers 5 (session),6(presentation) and 7(application)? I think of the python code that utilizes sockets as presenting data, managing sessions and creating sockets using transport protocols such as tcp or udp. Is my understanding/thinking correct? Thank you.
Python program sending data via sockets, what OSI layers?
1.2
0
1
1,025
16,490,822
2013-05-10T21:04:00.000
7
0
1
0
python,ruby-on-rails,ruby,rvm,virtualenv
16,492,610
2
true
0
0
At the basics, they are very similar: they provide a mean for you to have a "jailed" environment with the libraries you need in your project without installing them in the "host" environment. RVM however provides something called gemsets which I think doesn't have an equivalent in Virtualenv (the idea of grouping a set of libraries under a common name). Also, there's some integration with the shell you can do with RVM (called RVMRC files) so that when you change directory to a RVM-based project, it will auto-load the right version of ruby and the libraries for your project.
1
4
0
Having used VirtualEnv before, I'm wondering whether RVM is essentially the exact same action, of creating unique environments where updating dependencies won't break various projects, or if it departs in some ways.
Is VirtualEnv for Python essentially the same as RVM for Ruby
1.2
0
0
1,162
16,491,077
2013-05-10T21:27:00.000
0
1
0
1
python,windows,wmi,wmic
16,491,345
2
false
0
0
From CMD.EXE, I think the command I need is wmic path Win32_USBControllerDevice get * So most likely the general pattern is: PowerShell: gwmi MYCLASSNAME translates into: CMD.EXE: wmic path MYCLASSNAME get *
1
1
0
I am writing a Windows python program that needs to query WMI. I am planning to do this by using the subprocess module to call WMIC with the arguments I need. I see a lot of examples online of using WMI via PowerShell, usually using the "commandlet" Get-WmiObject or the equivalent gwmi. How do you do the equivalent of Get-WmiObject without using PowerShell, but rather with WMIC? Specificially, from within CMD.EXE, I want to do powershell gwmi Win32_USBControllerDevice, but without using powershell; rather, I want to invoke WMIC directly. Thanks, and sorry for the beginner question!
Get-WmiObject without PowerShell
0
0
0
1,863
16,494,463
2013-05-11T06:25:00.000
1
0
1
0
python
16,494,533
1
false
0
0
No. What you are looking for is sophisticated macro functionality. You can do this in Lisp, but Python (like most languages) does not support it. If you want, you can preprocess a file and parse it using the ast module. But you would have to do this as a separate step, before you run your Python script.
1
1
0
I am experimenting with writing more forgiving/ flexible functions and would like to know if it is possible to access the input arguments of a function as strings, before Python checks for syntax errors, NameErrors, etc, (for the purposes of doing my own input checking first)?
Is it possible to get at a function argument before it is parsed?
0.197375
0
0
55
16,500,292
2013-05-11T18:14:00.000
3
0
1
0
python,python-import
16,500,314
1
true
0
0
Import the modules in the module that uses them. Placing import os in __init__.py would put os in the package's global namespace, but it would not affect the namespace of the module that uses os. Global namespaces are not shared across modules or packages, so you would get NameErrors if you did not import them in the module that uses os.
1
2
0
When writing your own package in Python, should __init__.py contain imports like os, sys? Or should these just be imported within the file that is using them?
Should __init__.py also contain python module imports?
1.2
0
0
241
16,502,445
2013-05-11T22:51:00.000
5
0
0
0
python,python-2.7,numpy,scipy,scikit-learn
16,524,872
1
true
0
0
There is no function for that, as we like to keep the interface very simple. You can just do y - rf.predict(X)
1
4
1
When using RandomForestRegressor from Sklearn, how do you get the residuals of the regression? I would like to plot out these residuals to check the linearity.
Residuals of Random Forest Regression (Python)
1.2
0
0
2,682
16,503,242
2013-05-12T01:10:00.000
0
0
0
0
javascript,python,ruby,browser
16,503,582
3
false
1
0
One of the reasons you don't find browsers supporting languages like Ruby or Python, is because of the user's security. JavaScript was originally embedded in browsers for convenience, but, because that was an established relationship, as security issues occurred, JavaScript was locked down, as was the browser, to remove the capability of accessing the user's file system. Other languages would have to be stripped of their ability to read/write from the disk before they would be allowed into a browser. Java applets can be created that can access the disk, but they're supposed to be signed to prove they're safe. A similar mechanism could be created for other languages, but since JavaScript and Java applets exist, I'm not sure the movement for supporting other languages would gain much support.
1
0
0
Can a scripting language like Python or Ruby replace Javascript as the browser's interpreted language so that we could be writing .py or .rb files instead of .js for frontend work? If so, would that be a good idea? If not, why? If it's a good idea, why isn't it done that way? If Python/Ruby can't replace JS in the browser, why not?
Using an alternate Scripting Language to be interpreted by the browser instead of Javascript
0
0
0
392
16,504,470
2013-05-12T05:26:00.000
0
0
0
0
python,ruby-on-rails
16,525,800
1
false
1
0
Right now I am using Flask with localtunnel. It works.
1
3
0
I have a webapp that is built in Rails, but I'm working with graphs and Python has far better graph libraries (namely, Graph-Tool). There are on the order of 10k lines of code written already, so it would be a hassle to switch to Django. However, the work I'm doing involves querying very, very large graphs, ones that would take a lot of time to load into the interpreter. Is there a way to have a Python interpreter somewhere that Rails controls, with actions like "Load the graph" and "search the graph for x" and "restart the interpreter"? These can be on separate computers. I've heard of the SOA solution, but I'm not sure how to set that up or if the interpreter stays open after calls from Rails. Can someone point me to some guide, or give me advice?
Running a Python interpreter from Rails
0
0
0
73
16,504,499
2013-05-12T05:31:00.000
0
0
1
0
python,eval
16,506,039
1
true
0
0
I think you're confusing eval() with the exact type of z[0], which is, I guess, what does the magic here. I believe that if you try to run ((1 & z[0]) != 0) directly, without eval(), you'd get the same answer BoolRef: 1 & v__a != 0. Am I correct? If so, then you need to look in the class BoolRef to fix how it implements __repr__(), to include some extra parenthesis in the final string.
1
0
0
A string variable is defined clause1 = "((1 & z[0]) != 0)" Its eval() gives BoolRef: 1 & v__a != 0 while I actually need BoolRef: ((1 & v__a) != 0) How to keep the brackets in eval() and evaluate everything else
Stop python eval() from removing brackets
1.2
0
0
934
16,510,227
2013-05-12T17:36:00.000
4
0
0
0
python,scipy,curve-fitting,least-squares
16,521,114
3
false
0
0
Assuming your data are in arrays x, y with yerr, and the model is f(p, x), just define the error function to be minimized as (y-f(p,x))/yerr.
1
6
1
I am fitting data points using a logistic model. As I sometimes have data with a ydata error, I first used curve_fit and its sigma argument to include my individual standard deviations in the fit. Now I switched to leastsq, because I needed also some Goodness of Fit estimation that curve_fit could not provide. Everything works well, but now I miss the possibility to weigh the least sqares as "sigma" does with curve_fit. Has someone some code example as to how I could weight the least squares also in leastsq? Thanks, Woodpicker
Python / Scipy - implementing optimize.curve_fit 's sigma into optimize.leastsq
0.26052
0
0
4,123
16,511,231
2013-05-12T19:31:00.000
0
0
1
0
python,pydev
16,513,405
1
false
0
0
There is no 'automatic' way for that... But usually in this situation you can just do a find/replace from 2 spaces to 3 spaces (or whatever was the format you had to the expected format). Sometimes rectangular editing is helpful there too (hint: use alt+shift+A to enter/leave rectangular editing mode).
1
2
0
I am using PyDev perspective. I get a bad indentation warning in python files. I just copy code from somewhere else, I cannot make sure how much space others use... so how to automatically format that or how to erase that warning? It looks bad.
Pydev indentation warning in Eclipse
0
0
0
582
16,511,384
2013-05-12T19:49:00.000
1
0
0
0
python,google-chrome,selenium,selenium-webdriver
61,971,091
6
false
1
0
I also needed to add an extention to chrome while using selenium. What I did was first open the browser using selenium then add extention to the browser in the normal way like you would do in google chrome.
1
24
0
I am currently using Selenium to run instances of Chrome to test web pages. Each time my script runs, a clean instance of Chrome starts up (clean of extensions, bookmarks, browsing history, etc). I was wondering if it's possible to run my script with Chrome extensions. I've tried searching for a Python example, but nothing came up when I googled this.
Using Extensions with Selenium (Python)
0.033321
0
1
52,452
16,513,269
2013-05-13T00:06:00.000
-1
0
0
0
python,networking,udp
16,514,349
1
true
0
0
In short, yes. I use Python/Scapy to test network equipments all the time. I am assuming you will be using Threads for the two separate communication channels. If your CPU can handle it there is no reason why you cannot do this, and of course the amount of traffic generated by network games are usually not enough to significantly utilize modern day CPUs.
1
1
0
Okay, please don't kill me for asking this. I'm currently developing a 2D online multiplayer platformer shooter. Yeah, it's that cool. I have most of the game written with a couple of bugs and unoptimized, but I'm stuck when it comes to networking. I used PyGame, and so I tried using a bunch of Python libraries for networking. You name it, I think that I've looked at all the primary ones. Here are some PyEnet - thought it had internal congestion control, ugh MasterMind - not asynchronous PodSixNet - is this even UDP? Legume - currently stuck with the server giving me an exception, waiting for a response at the mailing list. Looks absolutely gorgeous otherwise. Can't remember all the other ones I tried. Anyways, what I need is UDP (trust me, I need UDP) and another reliable protocol for chat, masterserver, new player info, and all packets I can't afford to lose. I read somewhere that TCP and UDP used simultaneously wasn't a good idea, so I tried finding reliable UDP implementations in Python, therefore all my wandering about with these obscure libraries. Along the way I've learned to fool around with sockets myself, so I have two clear paths. 1) When people asked if UDP and TCP together were a bad idea, maybe they meant that they would use the same port for both protocols. How bad is it if I use two different ports? The TCP part will be idle most of the time, anyways, maybe 0-20 packets per 10 sec for a busy server. 2) Write my own reliable UDP. Ugh, it's what I was hiding from. If all fails, I guess I'll need to do that.
Python networking with UDP for action games
1.2
0
1
1,137
16,515,314
2013-05-13T05:20:00.000
0
0
0
0
python,formencode
16,554,536
2
true
1
0
I ended up moving from FormEncode to WTForms and everything is now a whole lot easier. Seems to me like Formencode wasn't very well thought out.
1
0
0
How can I write a custom validator which is always executed, even when the user has submitted an empty or missing value? I've tried overriding the to_python, validate_python, _to_python, _validate_python (and more) methods but none of these seem to get run if the user has submitted an empty or None value
Formencode and empty values
1.2
0
0
430
16,518,002
2013-05-13T08:46:00.000
0
1
0
0
python,django,jenkins,code-coverage,sonarqube
19,887,503
3
false
1
0
On Jenkins I found that coverage.xml has paths that are relative to the directory in which manage.py jenkins is run. In my case I need to run unit tests on a different machine than Jenkins. To allow Sonar to use the generated coverage.xml, it was necessary for me to run the tests from a folder in the same spot relative to the project as the workspace directory on Jenkins. Say I have the following on Jenkins /local/jenkins/tmp/workspace/my_build + my_project + app1 + app2 Say on test machine I have the following /local/test + my_project + app1 + app2 I run unit tests from /local/test on the test machine. Then coverage.xml has the correct relative paths, which look like my_project/app1/source1.py or my_project/app2/source2.py
1
4
0
I'm trying to get test unit coverage with Sonar. To do so, I have followed these steps : Generating report with python manage.py jenkins --coverage-html-report=report_coverage Setting properties in /sonar/sonar-3.5.1/conf/sonar.properties: sonar.dynamicAnalysis=reuseReports sonar.cobertura.reportPath=/var/lib/jenkins/workspace/origami/DEV/SRC/origami/reports/coverage.xml When I launch the tests, the reports are generated in the right place. However, no unit tests are detected by Sonar. Am I missing a step or is everything just wrong?
How to get tests coverage using Django, Jenkins and Sonar?
0
0
0
6,621
16,518,733
2013-05-13T09:26:00.000
6
0
0
0
python,django
16,518,803
2
false
1
0
The whole point of GET is that they are retrieved from the URL itself, removing them from the URL removes them entirely. If you want them 'hidden' you will need to use POST.
1
1
0
I have the form which i am showing by normal view. Then i am send the GET parameters to djnago ChangeList view like django does for lookups like this student/?region__id__exact=1&status__exact=Published now is there any way to remove that from the URL in the address bar. I don't users to see what i am doing
How can i remove the GET parameters from url in django
1
0
0
3,872
16,519,231
2013-05-13T09:53:00.000
1
0
0
0
python,http,python-2.6,python-requests,tor
16,529,177
1
true
0
0
If I remember, Tor changes routes after some pre-specified number of minutes. I'm tempted to say that the time period is 10 minutes, but I'm not entirely certain. Either way, so long as those two requests are made within that time-frame they'll have the same IP address.
1
0
0
I would like to use the library requests to make two HTTP-requests within a session. However I don't know whether the IP adresses will be the same for both HTTP-requests (within that session). Can you tell me whether it will use the same IP (important for me) or whether Tor will use two different Exit-nodes?
Make 2 HTTP-requests in a session through Tor with the same exit-node
1.2
0
1
180
16,519,506
2013-05-13T10:08:00.000
0
0
0
0
python,django,image,django-views
16,520,285
5
false
1
0
This can be only by serving your images with your custom views. E.g you should write your own view that will return static resources, and you will not use a standard django static handler
2
0
0
I have a django project which is running (for example) on localhost:8000. I have an image in this address localhost:8000/static/test.jpg . A user may open just this image by going to it's url and not open the containing page. I want to find out if this image is loaded in a user's browser (by loading the containing page or just entering the image's url) and I want to get the request object of that request. Can I have a method in my views just for that specific image? I searched through the internet but didn't find anything useful. any idea or solution?
How to find out if an image is loaded?
0
0
0
195
16,519,506
2013-05-13T10:08:00.000
0
0
0
0
python,django,image,django-views
16,767,630
5
false
1
0
Your way goes fine but bot for a high traffic. In that case you can use XSendFile library witch works with Apache
2
0
0
I have a django project which is running (for example) on localhost:8000. I have an image in this address localhost:8000/static/test.jpg . A user may open just this image by going to it's url and not open the containing page. I want to find out if this image is loaded in a user's browser (by loading the containing page or just entering the image's url) and I want to get the request object of that request. Can I have a method in my views just for that specific image? I searched through the internet but didn't find anything useful. any idea or solution?
How to find out if an image is loaded?
0
0
0
195
16,522,493
2013-05-13T12:49:00.000
0
0
0
0
android,python,sl4a
16,633,755
1
true
1
0
Ok, so I was silly to look for a droid command to write files. The standard Python open, write, read, close commands work fine.
1
1
0
Is there an API call for opening, reading and writing to text files on an Android device using SL4A and Python? If not, what options are available for persistent storage? e.g. database, preferences, dropbox, google drive.
Writing to file with SL4A Python
1.2
0
1
1,062
16,524,269
2013-05-13T14:16:00.000
0
0
1
0
python,inheritance
16,524,415
2
false
0
0
Are you coming from a Java background by any chance? First off, you've given no indication that any of your classes should inherit from another. For that matter, you probably don't need as many classes as you think you do. Solver #Contains the actual algorithm for solving If it's only one function you might as well just leave it as a free function. Output #Contains handles for all the plot output and has access to save file etc. If the functions don't have shared state, it could just as easily be a module. As for the run method, just stick it wherever it is most convenient. The nice thing about Python is that you can start prototyping without any classes, and just refactor into a class whenever you find yourself passing the same set of data around a lot.
1
1
0
This is a somewhat basic question about the correct order of class inheritance. Basically I'm trying to write a numerical simulation to solve a physical model, the details are not important (I happen to be writing this in python), it is a well known algorithm solved by iterating over a volume of space. The classes that I think I need are: Setup: A class that defines all of the simulation parameters, like volume size, and has methods for checking for correct parameter type, calculating derived parameters etc. Solver: Contains the actual algorithm for solving Output: Contains handles for all the plot output and has access to save file etc. I also need a run method which can run the solver and periodically (with periods defined in Setup) run some of the output functions. In a high quality program which class would inherit from which? (My guess Output inherits from Solver inherits from Setup) Where does the run method belong? Maybe there should be some extra base class like Interface that the user interacts with and includes the run method?
Class inheritance order for a simulation program
0
0
0
236
16,524,544
2013-05-13T14:28:00.000
2
0
1
0
python,multithreading
16,524,566
1
true
0
0
It returns nothing interesting, None.
1
0
0
What does the Python Thread.start() method return? I can't seem to find this in the Python docs. (I also think I miss something obvious from them because the return value for methods is seldom described.)
What does the standard thread.start() return in Python?
1.2
0
0
61
16,525,173
2013-05-13T14:59:00.000
0
0
1
0
python,hamcrest
33,946,106
3
false
0
0
I am using assertNotEqual([], list) to check if the list isn't empty
1
0
0
Is there a clean way to test that a list is not empty in Hamcrest (python). There are several ways to do it by checking the list length etc., but I'd like something that reads nicely for tests.
Python Hamcrest - test that list is not empty
0
0
0
2,139
16,525,623
2013-05-13T15:22:00.000
0
0
1
0
python,virtualenv,pip
16,564,496
2
false
0
0
Problem is solved by installing latest version of pip and recompiling python with SSL support.
1
0
0
I get this error when I try to use pip in virtualenv.It works nice when I deactivate environment. What could be wrong? I use python 2.7 in CentOS.
"'module' object has no attribute 'HTTPSConnection'" when try to use pip in virtualenv
0
0
0
1,788
16,526,314
2013-05-13T15:58:00.000
1
0
0
0
python,django,django-allauth
39,067,085
6
false
1
0
Allauth tries to extend myproject/templates/base.html. The easiest ways are to move base.html to myproject/templates/site/ in order to get myproject/templates/site/base.html or simply rename base.html
3
9
0
I've been trying to get django-allauth working for a couple days now and I finally found out what was going on. Instead of loading the base.html template that installs with django-allauth, the app loads the base.html file that I use for the rest of my website. How do i tell django-allauth to use the base.html template in the virtualenv/lib/python2.7/sitepackages/django-allauth directory instead of my project/template directory?
Django-allauth loads wrong base.html template
0.033321
0
0
2,348
16,526,314
2013-05-13T15:58:00.000
7
0
0
0
python,django,django-allauth
16,526,472
6
true
1
0
Unless called directly, your base.html is an extension of the templates that you define. For example, if you render a template called Page.html - at the top you will have {% extends "base.html" %}. When defined as above, base.html is located in the path that you defined in your settings.py under TEMPLATE_DIRS = () - which, from your description, is defined as project/template. Your best bet is to copy the django-allauth base.html file to the defined TEMPLATE_DIRS location, rename it to allauthbase.html, then extend your templates to include it instead of your default base via {% extends "allauthbase.html" %}. Alternatively you could add a subfolder to your template location like project/template/allauth, place the allauth base.html there, and then use {% extends "allauth/base.html" %}.
3
9
0
I've been trying to get django-allauth working for a couple days now and I finally found out what was going on. Instead of loading the base.html template that installs with django-allauth, the app loads the base.html file that I use for the rest of my website. How do i tell django-allauth to use the base.html template in the virtualenv/lib/python2.7/sitepackages/django-allauth directory instead of my project/template directory?
Django-allauth loads wrong base.html template
1.2
0
0
2,348
16,526,314
2013-05-13T15:58:00.000
2
0
0
0
python,django,django-allauth
53,967,402
6
false
1
0
All of the answers provided force you to rewrite files and modify your own project to fit in with allauth, which is a completely unacceptable workflow. Such a third-party application should not have such manipulative power over your own project. Truly, the easiest way to handle this situation, especially based on the answers provided, is to simply move the allauth app and its associated apps to the end of your INSTALLED_APPS list in your settings.py file. Django will find your base.html template before it finds the other base.html template in the other apps listed beneath it. Problem solved.
3
9
0
I've been trying to get django-allauth working for a couple days now and I finally found out what was going on. Instead of loading the base.html template that installs with django-allauth, the app loads the base.html file that I use for the rest of my website. How do i tell django-allauth to use the base.html template in the virtualenv/lib/python2.7/sitepackages/django-allauth directory instead of my project/template directory?
Django-allauth loads wrong base.html template
0.066568
0
0
2,348
16,528,178
2013-05-13T17:55:00.000
3
0
1
0
python,file-io
16,528,237
2
false
0
0
You write the exact number of characters == bytes, after .seek()-ing back to your start_offset position. These then overwrite the data that was there before. You can split that up into multiple writes, even writes of one character (byte) at a time if needed.
1
0
0
I've seen multiple tutorials in python, played around a bit with python file write(), tell(), seek() functions and also os.write(), lseek() functions. But I still don't get how can I do the following: What I have: In a file I know the start_offset and end_offset bytes. And I need to replace the bytes from start_offset to end_offset with a different set of bytes. How do I do this?? ftell() returns me the start_offset and similarly regex + ftell() returns me the end offset I have the bytes that will overwrite the original ones in the file. But write() only takes a string to write. Also how do I overwrite from start_pos to end_pos?? appreciate any pointers/suggestions
python overwrite bytes from offset1 to offset2
0.291313
0
0
561
16,532,314
2013-05-13T22:39:00.000
3
0
0
0
python,django,import,request,nlp
16,538,939
1
true
1
0
Django, under most deployment mechanism, does not import modules for every request. Even the development server only reloads code when it changes. I don't know how you're verifying that all the imports are re-run each time, but that certainly shouldn't be happening.
1
1
0
I'm working on a Python project, currently using Django, which does quite a bit of NLP work in a form post process. I'm using the NLTK package, and profiling my code and experimenting I've realised that the majority of the time the code takes is performing the import process of NLTK and various other packages. My question is, is there a way I can have this server start up, do these imports and then just wait for requests, passing them to a function that uses the already imported packages? This would be much faster and less wasteful than performing such imports on every request. If anybody has any ideas to avoid importing large packages on every request, it'd be great if you could help me out! Thanks, Callum
Python - Can a web server avoid imporing for every request?
1.2
0
1
216
16,536,683
2013-05-14T06:42:00.000
2
0
1
0
python,ipython,pypy
67,074,248
4
false
0
0
The "straight forward" way is: Install pypy3 pypy3 -m pip install ipython pypy3 -m IPython
1
27
0
How do I use ipython on top of a pypy interpreter rather than a cpython interpreter? ipython website just says it works, but is scant on the details of how to do it.
How to run ipython with pypy?
0.099668
0
0
6,903
16,541,847
2013-05-14T11:20:00.000
3
1
0
1
python,debugging,printing,pager,pdb
16,565,699
1
true
0
0
You might want to create a function which accepts a text, puts this text into a temporary file, and calls os.system('less %s' % temporary_file_name). To make it easier for everyday use: Put the function into a file (e.g: ~/.pythonrc) and specify it in your PYTHONSTARTUP. Alternatively you can just install bpython (pip install bpython), and start the bpython shell using bpython. This shell has a "pager" functionality which executes less with your last output.
1
4
0
I am using ipdb to debug a python script. I want to print a very long variable. Is there any ipdb pager like more or less used in shells? Thanks
Is there any ipdb print pager?
1.2
0
0
725
16,542,897
2013-05-14T12:16:00.000
5
1
1
0
python,haskell,compiler-construction,lisp,interpreter
16,543,659
3
false
0
0
If you mean the stackless compilation with lightweight concurrency, Haskell has done that from the very beginning. IIRC the first compilation scheme for Haskell was called the G-machine. Later that was replaced by the STG-machine. This is actually necessary for efficient laziness, but easy concurrency and parallelism comes as an additional bonus. Another notable language in this sector is Erlang and its bad joke imitation language Go, as well as continuation-based languages like Scheme. Unlike Haskell they don't use an STG compilation scheme.
2
2
0
Well thats the question. Are there any projects for other languages which try to imitate what stackless python is doing for python?
Are there any Stackless Python like projects for other languages (Java, Lisp, Haskell, Go etc)
0.321513
0
0
372
16,542,897
2013-05-14T12:16:00.000
4
1
1
0
python,haskell,compiler-construction,lisp,interpreter
16,543,577
3
false
0
0
Both Haskell and Erlang contain (in the standard implementation) microthreads/green threads with multi-core support, a preemptive scheduler, and some analogue of channels. The only rather unique feature of Stackless that I can think of is serialisation of threads, although you can sometimes fake it by providing a way of serializing function state.
2
2
0
Well thats the question. Are there any projects for other languages which try to imitate what stackless python is doing for python?
Are there any Stackless Python like projects for other languages (Java, Lisp, Haskell, Go etc)
0.26052
0
0
372
16,543,715
2013-05-14T12:52:00.000
0
1
0
0
python,raspberry-pi,schedule
16,543,818
3
false
0
0
The easiest way would be to set up a cron job to call a python script every hour.
1
1
0
I'd like to know how to preform an action every hour in python. My Raspberry Pi should send me information about the temp and so on every hour. Is this possible? I am new to python and linux, so a detailed explanation would be nice.
How to schedule an action in python?
0
0
0
7,805
16,543,855
2013-05-14T12:58:00.000
4
0
1
0
python,memory-management,storage,contiguous
16,544,131
1
false
0
0
No, except of course by coincidence. While this is highly implementation- and environment-specific, and there are actually memory management schemes which would dedicate page-sized memory regions to objects of the same type, no Python implementations I'm aware of exhibits the behavior you describe. With the possible exception of small numbers, which are sometimes cached under the hood and will likely be located next to each other. What you're seeing may be because string literals are created at import time (part of the constants in the byte code) and interned, while lists and tuples (that don't contain literals) are created while running code. If a bunch of memory is allocated in between (especially if it isn't freed), the state of the heap may be sufficiently different that quite different addresses are handed out when you're checking.
1
4
0
Does Python stores similar objects at memory locations nearer to each other? Because id of similar objects, say lists and tuples, are nearer to each other than an object of type str.
does python stores similar objects at contiguous memory locations?
0.664037
0
0
763
16,546,843
2013-05-14T15:12:00.000
0
0
1
0
python-idle
18,759,525
1
false
0
0
Did you use any othere mode file name to instead of sys mode? ex. I meet the same issue, after check, there is one 'string.py' when i do a test about Relative paths and an absolute path, so, when idle start, it always load wrong 'string.py', after i delete it which create by myself, it can work now.
1
0
0
I cannot start IDLE from my shortcut or from Start > All Programs > Python 3.3 > IDLE (Python GUI). When I click on it, nothing happens. I tried running as administrator; nothing either... It was working fine a few days ago. I can run it if I go to C:\Python 33\Lib\idlelib\_main_ (However a black python command line stays open and if I close it, IDLE closes as well.) I'm using a 64-bit release of Windows.
IDLE for Python 3.3 doesn't start and does not give an error message
0
0
0
1,787
16,547,305
2013-05-14T15:34:00.000
1
0
1
0
python,python-idle
50,389,292
3
false
0
0
In IDLE 3.6.5, it's Format > Untabify Region
1
6
0
I know that spaces are preferred over tabs in Python, so is there a way to easily convert tabs to spaces in IDLE or does it automatically do that?
Can I configure IDLE to automatically convert tabs to spaces?
0.066568
0
0
15,163
16,563,668
2013-05-15T11:19:00.000
2
0
1
0
python
16,563,725
3
false
0
0
I didn't exactly understand if you're talking about several scripts running in the same process, or several processes that need to share the same data: Several processes: I think the simplest way of doing this, sharing data between several scripts (different processes), is to use a simple file database. SQLite3 comes bundled with Python, so that would be a good choice. Single process: If you simply want to centralize the access of several methods running at the same time (within the same process), then you can declare your dictionary in one script, and have all the others access that one location, without duplicating the structure. You basically declare this dict in a script, and import it in all the others.
1
0
0
I am looking for a way to use a common or centralised dictionary in python. I have several scripts that work on the same data sets, but do different things. I have dictionarys in these scripts (e.g. instrument name) that are used in more than one script. If I make changes or add values I have to make shure I do this in all scripts, which is of course painfull and prone for errors. Is there a possibility, that I have one dictionary and use it in all the different scripts? Any help is appreciated - thanks.
Common or centralised dictionary in python
0.132549
0
0
96
16,564,791
2013-05-15T12:16:00.000
2
0
0
0
python,django,cloud-hosting,photo-gallery
16,565,006
1
false
1
0
Pros: You don't have to pay extra for your S3 servers after it crosses the 20GB limit. Cons Your server will slow down as it will not be able to take the load after certain limit. Performance of the server will go down, in worst case your servers may crash. Your node will also have limit on the disk space, which you cannot exceed but S3 or any other service will be able to do it seamlessly.
1
0
0
I have this small app in Django, hosted on cheap linode. We want to add photo-sharing functionality so I am wondering should I put all user uploaded static photo files locally on linode serwer or it is better to use Amazon S3 or similar cloud soulution ? What are pros and cons of both solutions ?
Should I store static files (photos) local or in the cloud?
0.379949
0
0
128
16,565,363
2013-05-15T12:45:00.000
13
1
1
1
python,linux,open-source
16,565,499
2
true
0
0
For sure, if this program is to be available only for root, then the main execution python script have to go to /usr/sbin/. Config files ought to go to /etc/, and log files to /var/log/. Other python files should be deployed to /usr/share/pyshared/. Executable scripts of other languages will go either in /usr/bin/ or /usr/sbin/ depending on whether they should be available to all users, or for root only.
2
12
0
My python program consists of several files: the main execution python script python modules in *.py files config file log files executables scripts of other languages. All this files should be available only for root. The main script should run on startup, e.g. via upstart. Where I should put all this files in Linux filesystem? What's the better way for distribution my program? pip, easy_install, deb, ...? I haven't worked with any of these tool, so I want something easy for me. The minimum supported Linux distributive should be Ubuntu.
Where I should put my python scripts in Linux?
1.2
0
0
14,785
16,565,363
2013-05-15T12:45:00.000
1
1
1
1
python,linux,open-source
16,565,490
2
false
0
0
If only root should access the scripts, why not put it in /root/ ? Secondly, if you're going to distribute your application you'll probably need easy_install or something similar, otherwise just tar.gz the stuff if only a few people will access it? It all depends on your scale.. Pyglet, wxPython and similar have a hughe userbase.. same for BeautifulSoup but they still tar.gz the stuff and you just use setuptools to deply it (whcih, is another option).
2
12
0
My python program consists of several files: the main execution python script python modules in *.py files config file log files executables scripts of other languages. All this files should be available only for root. The main script should run on startup, e.g. via upstart. Where I should put all this files in Linux filesystem? What's the better way for distribution my program? pip, easy_install, deb, ...? I haven't worked with any of these tool, so I want something easy for me. The minimum supported Linux distributive should be Ubuntu.
Where I should put my python scripts in Linux?
0.099668
0
0
14,785
16,566,430
2013-05-15T13:31:00.000
1
1
0
0
php,python,web
16,566,525
2
true
0
0
I personally think if you have little web development experience you should go with PHP. You can directly embed it in your HTML and perhaps that will make it easier to understand for you. That's of course if you don't want to make complicated websites (yet). After you familiarise yourself with web development, you can then decide again whether to use PHP or Python depending on the platform you want to use and what you want to achieve. Moreover if you have C++ experience, PHP's syntax is IMO closer to C++.
1
0
0
I want to design a website with minimal front end and a backend for periodic processing. Some 200 users will use the site.I have choosen php vs python. I have done few defect fixes in PHP and some automation scription in python and I have absolutely no web development experience. But I have application development experience in c++. I want to develop the site with ease and minimum effort(no CMS as I want to learn the language). Can anyone suggest me which one choose ?
from c++ development to PHP or Python
1.2
0
0
164
16,567,751
2013-05-15T14:26:00.000
0
0
0
0
python,django,django-models,django-forms
16,568,130
1
true
1
0
ModelForms are for creating/updating objects. Authentication doesn't modify the model instance (the User), therefore use a normal form instead. From the docs: The save() method Every form produced by ModelForm also has a save() method. This method creates and saves a database object from the data bound to the form. A subclass of ModelForm can accept an existing model instance as the keyword argument instance; if this is supplied, save() will update that instance. If it’s not supplied, save() will create a new instance of the specified model. If you weren't going to use this save(), method and you don't need most of the model fields either (only username/email and password), you would be throwing away most of the functionality offered by the ModelForm, so why would you use it in the first place?
1
0
0
ModelForms are a nice way to prevent repeating the definitions of models one creates. What I would like to do is take advantage of that feature and use it for more than just processing POST requests. I use forms a lot for validation. Example: Say you have a User model with the fields (email, password, first_name, last_name). The email field is unique and an index. UserCreationForm: uses all fields, fails validation if the email already exists. Processes POST requests UserUpdateForm: the same model, but doesn't allow to change the email. Because this field is excluded no issues there. UserAuthenticationForm: includes only the email and password fields. The problem is, this should be used for authentication and validation fails because the email already exists. Is there a way I can do this? That is, have the UserAuthenticationForm skip the email checking. Thank you.
Are ModelForms in django used only for POSTing?
1.2
0
0
84
16,568,621
2013-05-15T15:04:00.000
1
0
1
1
python,debian,apt
20,988,427
3
false
0
0
A very effective way is to create local apt caches for all the relevant distributions. The tool chdist from the devscripts package allows you to create a number of these caches without the need to use root privileges. You can then use the tools you are used to (e.g. apt-rdepends) to query those caches by wrapping them up in chdist. You can even point python-apt at your local cache using the rootdir keyword argument to apt.cache.Cache where you can then resolve dependencies.
1
5
0
I want to be able to look at local .deb files and at remote repositories and deduce dependencies etc so that I can build my own repositories and partial mirrors (probably by creating config files for reprepro). The challenge is that many of the command-line tools to help with this (apt-rdepends etc) assume that you're running on the target system and make use of your local apt cache, whereas I'll often be handling stuff for different Ubuntu and Debian distributions from the one I'm currently running on, so I'd like to do this a bit more at arm's length. The capable but very poorly-documented python-apt packages let me examine .deb files on the local filesystem and pull out dependencies. I'm now wondering if there are similar tools to parse the Packages.gz files from repositories? (It's not too tricky, but I don't want to reinvent the wheel!) The overall goal is to create and maintain two repositories: one with our own packages in, and a partial mirror of an Ubuntu distribution with some known required packages plus anything that they, or our own ones, depend upon.
How to query and manage Debian package repositories in Python?
0.066568
0
0
1,224
16,569,247
2013-05-15T15:32:00.000
1
0
1
0
regex,python-2.7
16,569,422
3
false
0
0
"R(\.|aj)? (K(\.|umar)? )?Goyal" will only match those four cases. You can modify this for other names as well.
2
0
0
I need a regular expression in python that will be able to match different name formats like I have 4 different names format for same person.like R. K. Goyal Raj K. Goyal Raj Kumar Goyal R. Goyal What will be the regular expression to get all these names from a single regular expression in a list of thousands. PS: My list have thousands of such name so I need some generic solution for it so that I can combine these names together.In the above example R and Goyal can be used to write RE. Thanks
Regular expression for matching diffrent name format in python
0.066568
0
0
403
16,569,247
2013-05-15T15:32:00.000
0
0
1
0
regex,python-2.7
16,569,677
3
false
0
0
Fair warning: I haven't used Python in a while, so I won't be giving you specific function names. If you're looking for a generic solution that will apply to any possible name, you're going to have to construct it dynamically. ASSUMING that the first name is always the one that won't be dropped (I know people whose names follow the format "John David Smith" and go by David) you should be able to grab the first letter of the string and call that the first initial. Next, you need to grab the last name- if you have no Jr's or Sr's or such, you can just take the last word (find the last occurrence of ' ', then take everything after that). From there, "<firstInitial>* <lastName>" is a good start. If you bother to grab the whole first name as well, you can reduce your false positive matches further with "<firstInitial>(\.|<restOfFirstName>)* <lastName>" as in joon's answer. If you want to get really fancy, detecting the presence of a middle name could reduce false positives even more.
2
0
0
I need a regular expression in python that will be able to match different name formats like I have 4 different names format for same person.like R. K. Goyal Raj K. Goyal Raj Kumar Goyal R. Goyal What will be the regular expression to get all these names from a single regular expression in a list of thousands. PS: My list have thousands of such name so I need some generic solution for it so that I can combine these names together.In the above example R and Goyal can be used to write RE. Thanks
Regular expression for matching diffrent name format in python
0
0
0
403
16,574,640
2013-05-15T20:43:00.000
1
0
0
0
python,pdf,reportlab
16,574,684
2
false
0
0
canvas.showPage() will force a new page (even though it sounds like its showing a page,) (assuming you are using the canvas) if you are using flowables I think there is a PageBreak flowable
1
0
0
How can I generate a PDF with two or more pages with reportlab? I've been unable to find anything in the documentation.
Reportlab 2 or more pages per file
0.099668
0
0
99
16,574,746
2013-05-15T20:51:00.000
0
1
0
0
python,twitter,tweepy
16,589,445
2
false
0
0
What one could do, is get the last nth tweet from a user, and then get the tweet.id of the relevant tweet. This can be done doing: latestTweets = api.user_timeline(screen_name = 'user', count = n, include_rts = False) I, however, doubt that it is the most efficient way.
1
1
0
I want to check if a certain tweet is a reply to the tweet that I sent. Here is how I think I can do it: Step1: Post a tweet and store id of posted tweet Step2: Listen to my handle and collect all the tweets that have my handle in it Step3: Use tweet.in_reply_to_status_id to see if tweet is reply to the stored id In this logic, I am not sure how to get the status id of the tweet that I am posting in step 1. Is there a way I can get it? If not, is there another way in which I can solve this problem?
How to get id of the tweet posted in tweepy
0
0
1
1,649
16,577,725
2013-05-16T01:43:00.000
0
1
0
0
javascript,python,ruby,perl
16,579,794
1
true
1
0
There is no way to accomplish this very oddly specific task without digging through the code, although this isn't as hard as it seems considering it's quite legible and easy to build on your own system, even if you don't have any previous experience with JavaScript.
1
0
0
In the Visual Event description, it says that it extracts "which elements have events attached to them". I can confirm this by running the bookmarklet and seeing all the colour highlights. I would like to extract this information without the fancy presentation so that I can play around with it into a script (Ruby/Python/Perl). In other words, I would like to get a list of the divs (and their info ideally) from Visual Event. Is there any way to do this without digging through the code on GitHub? Not to say that I'm not willing to do this, I was just wondering if there was an easier way.
Extracting Visual Event 2 output into script
1.2
0
0
67
16,578,545
2013-05-16T03:30:00.000
0
0
0
0
python,web-crawler
16,578,621
2
true
1
0
Well you should probably start by learning the language in general it would make it alot easier to do but for the Web stuff you can use something called urllib and urllib2 these can open up the browser to get the data without actually opening the window also there are a few automated web browsers like selenium which actually opens the window there are many others you can look through on the internet but that's only the web browser automation then you have to actually obtain the information and data you want for this you need something like scrapy like you said or beautifulsoup these go through the source code and pick out the information you want since i don't exactly know what you want its kind of hard to explain but i hope this gives you somewhere to start but like i said you should probably learn basic python and that would help alot I hope this helps!!
1
0
0
So i've been looking around trying to figure out how i could extract some specific data such as just the text, and push that data into a program that organizes the data. So if you took homedepot.com for example and wanted to extract from each item listed under "2x4 wood" and from each item you are needing to grab the name, the description, and the specifications and import that data into a piece of software that contains this data? So I guess that would be something like an automated data entry? From what I've researched I'd need to write a crawler program that is designed to search a specific term and then crawl each and every page that the result returns and grab the data that I need. However I have a bit of a problem: I don't really know any programming/scripting and am unsure where to start. I found something called Scrapy which is based off of Python. Is this what I want to use for the crawler? The next issue I have is the fact that I have no clue on how to now import the data gathered into the software? Any tips on where I should look to find this answer? I want to use this idea that I have to help me learn how to script.
Need to extract data from website and push to a program
1.2
0
1
225
16,579,775
2013-05-16T05:44:00.000
5
0
0
0
python,machine-learning,scikit-learn,scikits
16,583,343
2
false
0
0
First, a couple of remarks: the name of the algorithm is Gradient Boosting (Regression Trees or Machines) and is not directly related to Stochastic Gradient Descent you should never evaluate the accuracy of a machine learning algorithm on you training data, otherwise you won't be able to detect the over-fitting of the model. Use: sklearn.cross_validation.train_test_split to split X and y into a X_train, y_train for fitting and X_test, y_test for scoring instead. Now to answer your question, GBRT models are indeed non deterministic models. To get deterministic / reproducible runs, you can pass random_state=0 to seed the pseudo random number generator (or alternatively pass max_features=None but this is not recommended). The fact that you observe such big variations in your training error is weird though. Maybe your output signal if very correlated with a very small number of informative features and most other features are just noise? You could try to fit a RandomForestClassifier model to your data and use the computed feature_importance_ array to discard noisy features and help stabilize your GBRT models.
1
0
1
I'm using the Scikit module for Python to implement Stochastic Gradient Boosting. My data set has 2700 instances and 1700 features (x) and contains binary data. My output vector is 'y', and contains 0 or 1 (binary classification). My code is, gb = GradientBoostingClassifier(n_estimators=1000,learn_rate=1,subsample=0.5) gb.fit(x,y) print gb.score(x,y) Once I ran it, and got an accuracy of 1.0 (100%), and sometimes I get an accuracy of around 0.46 (46%). Any idea why there is such a huge gap in its performance?
Stochastic Gradient Boosting giving unpredictable results
0.462117
0
0
1,888
16,582,065
2013-05-16T08:05:00.000
0
0
1
0
python,image-processing,wordnet
16,582,205
1
false
0
0
Well, I suppose you take a bunch of path to images as strings, you can get them as command line arguments or reading them from stdin. Then you just have to open them or do whatever you want with it. Is that answering your question?
1
0
0
I am trying to take a set of tagged images as input and remove noisy tags from each image. I have written a python code which takes a text file as input, each line of which corresponds to tags of an image, and removes the noisy tags from each line. I have used the structure and similarity measures in Wordnet to do so. But i dunno how to take a set of images as input. Could someone please tell me how to do this.
Using set of images as an input
0
0
0
65
16,585,683
2013-05-16T11:00:00.000
1
0
1
0
python,c,gdb,coredump,gdb-python
16,720,674
1
false
0
0
There isn't a way to iterate over symbol tables from Python yet. So, it can't be done. However, adding support to expose this information to Python would be a reasonable thing to do.
1
1
0
how to extract all the global variables , data structures and sub-structures (with address, type and values) from core dump,using gdb-python, generated after crashing of a C code.?
Core dump : Extract all the global variables , data structures and sub-structures from a core dump
0.197375
0
0
894
16,586,364
2013-05-16T11:35:00.000
3
0
1
0
javascript,python,data-structures,map
16,619,311
5
true
0
0
I agree with delnan in that the human example is probably too close to that of an object. This works well if you are trying to transition into explaining how objects are implemented in loosely typed languages, however a map is a concept that exists in Java and C# as well. This could potentially be very confusing if they begin to use those languages. Essentially you need to understand that maps are instant look-ups that rely on a unique set of values as keys. These two things really need to be stressed, so here's a decent yet highly contrived example: Lets say you're having a party and everyone is supposed to bring one thing. To help the organizer, everyone says what their first name is and what they're bringing. Now lets pretend there are two ways to store this information. The first is by putting it down on a list and the second is by telling someone with a didactic memory. The contrived part is that they can only identify you through you're first name (so he's blind and has a cochlear implant so everyone sounds like a robot, best I can come up with). List: To add, you just append to the bottom of the list. To back out you just remove yourself from the list. If you want to see who is bringing something and what they're bringing, then you have to scan the entire list until you find them. If you don't find them after scanning, then they're clearly they're not on the list and not bringing anything. The list would clearly allow duplicates of people with the same first name. Dictionary (contrived person): You don't append to the end of the list, you just tell him someone's first name and what they're bringing. If you want to know what someone is bringing you just ask by name and he immediately tells you. Likewise if two people of the same name tell him they're bringing something, he'll think its the same person just changing what they're bringing. If someone hasn't signed up you would ask by name, but he'd be confused and ask you what you're talking about. Also you would have to say when you tell the guy that someone is no longer bringing something he would lose all memory of them, so yeah highly contrived. You might also want to show why the list is sufficient if you don't care who brings what, but just need to know what all is being brought. Maybe even leave the names off the list, to stress key/value pairs with the dictionary.
5
3
0
I'm trying to explain Map (aka hash table, dict) to someone who's new to programming. While the concepts of Array (=list of things) and Set (=bag of things) are familiar to everyone, I'm having a hard time finding a real-world metaphor for Maps (I'm specifically interested in python dicts and Javascript Objects). The often used dictionary/phone book analogy is incorrect, because dictionaries are sorted, while Maps are not - and this point is important to me. So the question is: what would be a real world phenomena or device that behaves like Map in computing?
Maps (hashtables) in the real world
1.2
0
0
239
16,586,364
2013-05-16T11:35:00.000
2
0
1
0
javascript,python,data-structures,map
16,588,162
5
false
0
0
Perhaps it would be the analogy of a human being that your meeting for the first time: Each person has an unordered amount of attributes, each of these attributes can only have 1 value, which is unique (like hair=long, eye_color=blue). And you would discover these attributes in no particular order. So for a person she can have a shoesize=38, hair_color=brown and eye_color=blue and when reciting (human_dict.get('shoe_size')) this to someone else you would mention the attributes in no particular order except by attribute name.
5
3
0
I'm trying to explain Map (aka hash table, dict) to someone who's new to programming. While the concepts of Array (=list of things) and Set (=bag of things) are familiar to everyone, I'm having a hard time finding a real-world metaphor for Maps (I'm specifically interested in python dicts and Javascript Objects). The often used dictionary/phone book analogy is incorrect, because dictionaries are sorted, while Maps are not - and this point is important to me. So the question is: what would be a real world phenomena or device that behaves like Map in computing?
Maps (hashtables) in the real world
0.07983
0
0
239
16,586,364
2013-05-16T11:35:00.000
1
0
1
0
javascript,python,data-structures,map
16,619,115
5
false
0
0
In some restaurants when you make your order in the counter, they give you a number to identify your order. The numbers : Don't need to be sorted. Don't need to be consecutive The only idea of the numbers is that they can find your order easily. In the map/hash table/associative array world the number would be the key and your order the value. After you finish your order they can use the same number for another order. So the number is basically the identifier for an order at certain point in time, this would fit the Javascript Object example where the properties of the objects can change their value.
5
3
0
I'm trying to explain Map (aka hash table, dict) to someone who's new to programming. While the concepts of Array (=list of things) and Set (=bag of things) are familiar to everyone, I'm having a hard time finding a real-world metaphor for Maps (I'm specifically interested in python dicts and Javascript Objects). The often used dictionary/phone book analogy is incorrect, because dictionaries are sorted, while Maps are not - and this point is important to me. So the question is: what would be a real world phenomena or device that behaves like Map in computing?
Maps (hashtables) in the real world
0.039979
0
0
239
16,586,364
2013-05-16T11:35:00.000
1
0
1
0
javascript,python,data-structures,map
16,587,930
5
false
0
0
I have seen cases where a large list of people were binned according to their last N digits of their identifying number, in order to save on key search. This binning is somewhat similar to hashing, and may help explain it.
5
3
0
I'm trying to explain Map (aka hash table, dict) to someone who's new to programming. While the concepts of Array (=list of things) and Set (=bag of things) are familiar to everyone, I'm having a hard time finding a real-world metaphor for Maps (I'm specifically interested in python dicts and Javascript Objects). The often used dictionary/phone book analogy is incorrect, because dictionaries are sorted, while Maps are not - and this point is important to me. So the question is: what would be a real world phenomena or device that behaves like Map in computing?
Maps (hashtables) in the real world
0.039979
0
0
239
16,586,364
2013-05-16T11:35:00.000
1
0
1
0
javascript,python,data-structures,map
16,617,849
5
false
0
0
Are you successful in explaining the array in a logical way..that array is a storage where elements are kept at first position. second position , third position....first,second.third are basically keys... Now extend it to say maps are storage where are keys are not necessarily numbers..lets say they are strings...or even numbers which are not consecutive or have any relationship Conversely lets say in array A(of int) are maps where index 1 is mapped to A's address, 2 to the address of A + 4 and so on....
5
3
0
I'm trying to explain Map (aka hash table, dict) to someone who's new to programming. While the concepts of Array (=list of things) and Set (=bag of things) are familiar to everyone, I'm having a hard time finding a real-world metaphor for Maps (I'm specifically interested in python dicts and Javascript Objects). The often used dictionary/phone book analogy is incorrect, because dictionaries are sorted, while Maps are not - and this point is important to me. So the question is: what would be a real world phenomena or device that behaves like Map in computing?
Maps (hashtables) in the real world
0.039979
0
0
239
16,587,145
2013-05-16T12:14:00.000
2
1
1
0
python,genetic-algorithm
45,485,156
6
false
0
0
Not exactly a GA library, but the book "Genetic Algorithms with Python" from Clinton Sheppard is quite useful as it helps you build your own GA library specified for your needs.
1
5
0
I'm currently looking for a mature GA library for python 3.x. But the only GA library can be found are pyevolve and pygene. They both support python 2.x only. I'd appreciate if anyone could help.
Any Genetic Algorithms module for python 3.x?
0.066568
0
0
11,702
16,589,274
2013-05-16T13:50:00.000
1
0
1
0
python,regex,optparse
16,589,345
3
false
0
0
Your question lacks alot of data to effectively answer it, but perhaps the following helps: If you are unable to use a regex that starts with spaces, try using the replacement characters that represent spaces: \s .. So \s{3}test will match "<3 spaces>test". If it is shell script, do remember to double-escape it since shell will otherwise just ignore the s in \s. So the right version would then be \\s{3}test
1
0
0
I am writing a regex match program, and I am unable to use regular expressions that start with spaces. Is there any way to tell OptParse to only delimit by the first whitespace?
optparse does not save second whitespace into arg
0.066568
0
0
229
16,591,244
2013-05-16T15:12:00.000
0
0
0
1
python,clipboard,timing,sendkeys,queuing
16,609,920
1
false
0
0
No, I don't think so. You're talking about separate message queues here. Alt+Esc is a global hotkey, presumably handled by windows explorer. Ctrl+A and Ctrl+C are handled by the source app, and should be processed in order. However, there will be a lag after the Ctrl+C, as the clipboard must be locked, cleared, and updated, and then clipboard notification messages are sent to all applications registered on the clipboard notification chain, as well as the newer clipboard notification API. After all of those applications have had a chance to react to the data, THEN it is safe to paste with Ctrl+V. Note that if you're running any sort of remote desktop software, you also have to wait for OTHER SYSTEMS to react to the clipboard notification, which will include syncing clipboard data across the network. Now you see why this is hard. Sorry for the bad news.
1
1
0
We are writing a Python application that relies on copying and pasting content from the top windows. To do that we issue sendkey commands: Ctrl-Esc for going to the previous windows Ctrl-A followed by Ctrl-C to copy all text from the window And Cnrl-V to paste the the clipboard content to the top window. Unfortunately at times we run into timing problems. Is there some way to queue the SendKey commands so that Cntl-A waits for Alt-Esc, and then Cntl-C waits till Cntl-A is done? Or perhaps there is a way to know when each command is finished before sending the next one? Thank you in advance for your help.
Is it possible to queue sendkey commands in Windows?
0
0
0
248
16,591,538
2013-05-16T15:25:00.000
0
1
0
0
python,graphic
22,495,380
1
false
0
0
If you take this approach, you will have to maintain an ever changing database of graphics cards and the performance capabilities of each. Typically, options are available to the user for changing texture quality, terrain/water detail, shadows, lighting, anti-aliasing, etc. There is also usually a test where the game renders a scene, and based on the frame rate the game can set ideal presets for most of the graphics options.
1
2
0
I am trying finding a library of Python that could detect the model of a graphics card. For a better graphics card, there is a higher score associated with it, because I need to configure a game's display based on the performance of graphic card.
Python Library Can Detect Graphic Card
0
0
0
252
16,594,103
2013-05-16T17:46:00.000
0
0
1
0
python,pep8
16,595,842
4
false
0
0
How about not returning anything but yielding the results one by one? Generators are generally a convenient thing, as they avoid building up lists that are then used and discarded one by one anyway.
2
2
0
I have a function which searches for results to a query. If there's no results what is recommended to return, False or None? I suppose it's not that important but I'd like to follow best practice.
In Python, what to return for no results, False or None?
0
0
0
1,272
16,594,103
2013-05-16T17:46:00.000
1
0
1
0
python,pep8
16,594,681
4
false
0
0
I would return an empty list, it will save you headaches when looking at the return values of this function down the road. If you want your program to die when you make assumptions that the list has elements however, None is a good choice.
2
2
0
I have a function which searches for results to a query. If there's no results what is recommended to return, False or None? I suppose it's not that important but I'd like to follow best practice.
In Python, what to return for no results, False or None?
0.049958
0
0
1,272
16,595,625
2013-05-16T19:15:00.000
0
0
1
0
python,time-complexity
16,597,039
4
false
0
0
I figured it out. T(n) = n*T(n-1) + n! + O(n^2) = n*T(n-1) + n! = n*( (n-1)T(n-2) + (n-1)! ) + n! = n(n-1)T(n-2) + 2n! = ... = n! = n*n! = O(n*n!)
1
3
0
When analyzing some code I've written, I've come up with the following recursive equation for its running time - T(n) = n*T(n-1) + n! + O(n^2). Initially, I assumed that O((n+1)!) = O(n!), and therefore I solved the equation like this - T(n) = n! + O(n!) + O(n^3) = O(n!) Reasoning that even had every recursion yielded another n! (instead of (n-1)!, (n-2)! etc.), it would still only come up to n*n! = (n+1)! = O(n!). The last argument is due to sum of squares. But, after thinking about it some more, I'm not sure my assumption that O((n+1)!) = O(n!) is correct, in fact, I'm pretty sure it isn't. If I am right in thinking I made a wrong assumption, I'm not really sure how to actually solve the above recursive equation, since there is no formula for the sum of factorials... Any guidance would be much appreciated. Thank you!!!
Factorial running time
0
0
0
2,532
16,596,188
2013-05-16T19:48:00.000
5
0
0
0
python,pandas,bioinformatics
42,148,893
2
false
0
0
Just ran into this issue--I specified a str converter for the column instead, so I could keep na elsewhere: pd.read_csv(... , converters={ "file name": str, "company name": str})
1
15
1
I just picked up Pandas to do with some data analysis work in my biology research. Turns out one of the proteins I'm analyzing is called 'NA'. I have a matrix with pairwise 'HA, M1, M2, NA, NP...' on the column headers, and the same as "row headers" (for the biologists who might read this, I'm working with influenza). When I import the data into Pandas directly from a CSV file, it reads the "row headers" as 'HA, M1, M2...' and then NA gets read as NaN. Is there any way to stop this? The column headers are fine - 'HA, M1, M2, NA, NP etc...'
Pandas Convert 'NA' to NaN
0.462117
0
0
11,645
16,597,149
2013-05-16T20:45:00.000
0
0
0
0
python,html,jsp,beautifulsoup
16,597,278
1
false
1
0
I assume you are talking about web scraping which is pulling information from other websites. You are not going to be able to do something like this in somebody's browser because it violates Javascript's same origin policy, AND there is no way a browser is going to let you download and execute a script on a client's computer. You could just write a python script to do this for you and execute it yourself on your machine however. Just be sure you are not violating web site's terms of service. EDIT: In that case I would recommend running the script on the command line, and then using the output of the program in the servlet to generate the responses you want.
1
0
0
I am trying to invoke a python code for screen scraping (using Beautiful Soup) from my jsp servlet. Or it would also work if it can be directly invoked from the HTML. Looked through few threads but couldn't get any solution. What I want is to give the python program some arguments and want it to do some screen scrapping and return the result to jsp somehow.
how to invoke python script in jsp/servlet?
0
0
0
1,132
16,597,216
2013-05-16T20:49:00.000
18
1
1
0
python,vim
16,606,672
3
false
0
0
Personally: When inside Vim editing my Python scripts, I simply hit CtrlZ so as to return in console mode. Run my script with command $ python my_script.py. When done, I enter $ fg in the command line and that gets me back inside Vim, in the state I was before hitting CtrlZ. (fg as in foreground) Edit Recently I have started using the :terminal mode of vim much more frequently. I tend to prefer it to CtrlZZ because it may happen that I forget that I used Ctrl-z and open an additional vim session: it may become messy. Also, having a terminal pane is easier for dealing with line number in errors message, since the two views are available at the same time. So the workflow I'm using nowadays has become: :terminal (in my case I have a vim mapping with leader key) <leader>tm :terminal<cr> so that I don't even type :terminal manually) Run my script with command $ python my_script.py. $ exit in the bash command line if I want to close the terminal pane
1
1
0
Is it possible to run Python code from within the vim editor? What is necessary to install the support along with Python syntax highlighting? How would I install "python.vim : Enhanced version of the python syntax highlighting script" ? I did not automatically create ~/.vim/syntax and I'm using a Mac, all I downloaded was the .app file, an executable that I don't know of its purpose and a readme file. I've tried also creating a folder for the python.vim file, but that didn't work out either.
Can Python be run from within the vim editor?
1
0
0
11,604
16,597,739
2013-05-16T21:23:00.000
1
0
0
0
python,django,email,django-email
16,599,805
1
true
1
0
Are you trying to read from a mailbox and write the information into the database? If so, then you want to: 1) Open a connection to the mail server using poplib or imaplib from the standard library 2) Retrieve messages from the server (again with poplib or imaplib) 3) Parse the messages with the email package from the standard library. From there, you can populate whatever stuff you want in your database, either using the Django ORM or not.
1
1
0
How to implement something like this: If someone send email with file in attachment to [email protected], this file is added automatically to database. Please general algorithm how to do or suggest existing app
Upload files via email in Django. General algorithm
1.2
0
0
99
16,599,357
2013-05-16T23:58:00.000
0
0
0
0
python,pandas,pip
21,592,812
2
false
0
0
Thanks, I just had the same issue with Angstrom Linux on the BeagleBone Black board and the easy_install downgrade solution solved it. One thing I did need to do, is after installing easy_install using opkg install python-setuptools I then had to go into the easy_install file (located in /usr/bin/easy_install) and change the top line from #!/usr/bin/python-native/python to #!/usr/bin/python this fixed easy_install so it would detect python on the BeagleBone and then I could run your solution.
1
3
1
So, I'm trying to install pandas for Python 3.3 and have been having a really hard time- between Python 2.7 and Python 3.3 and other factors. Some pertinent information: I am running Mac OSX Lion 10.7.5. I have both Python 2.7 and Python 3.3 installed, but for my programming purposes only use 3.3. This is where I'm at: I explicitly installed pip-3.3 and can now run that command to install things. I have XCode installed, and have also installed the command line tools (from 'Preferences'). I have looked through a number of pages through Google as well as through this site and haven't had any luck getting pandas to download/download and install. I have tried downloading the tarball, 'cd' into the downloaded file and running setup.py install, but to no avail. I have downloaded and installed EPD Free, and then added 'Library/Framework/Python.framework/Versions/Current/bin:${PATH} to .bash_profile - still doesn't work. I'm not sure where to go frome here...when I do pip-3.3 install pandas terminal relates that There was a problem confirming the ssl certificate: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:547)> and so nothing ends up getting downloaded or installed, for either pandas, or I also tried to the same for numpy as I thought that could be a problem, but the same error was returned.
Python 3.3 pandas, pip-3.3
0
0
0
2,260
16,601,049
2013-05-17T03:42:00.000
0
0
0
0
python,arrays,numpy,nested,vectorization
16,607,943
4
false
0
0
I think it makes little sense to use numpy arrays to do that, just think you're missing out on all the advantages of numpy.
1
0
1
In other words, each element of the outer array will be a row vector from the original 2D array.
How do I convert a 2D numpy array into a 1D numpy array of 1D numpy arrays?
0
0
0
5,758
16,603,207
2013-05-17T06:56:00.000
0
0
0
0
python,pyqt,qtableview,qstandarditemmodel
16,761,536
1
false
0
1
Did you follow the advice on subclassing model classes? I only encountered such problems if I didn't followed the hints in the docs ;) A removeRows() implementation must call beginRemoveRows() before the rows are removed from the data structure, and endRemoveRows() immediately afterwards.
1
0
0
Got a QStandardItemModel on my QTableView and trying to remove all the rows in it. I was first calling a method I created with a call to takeRow, which does not delete the object if I'm right. What about removeRows from QAbstractItemModel? I've tried it, and as I had a signal on the model ( dataChanged ), it seems that the signal hasn't been disconnected cause I still have some error in the background like "Underlying C/C++ object has been deleted" when I try to delete, and then add some new rows. Am I missing something here..?
QStandardItemModel removeRows does not remove signals on cells?
0
0
0
371
16,604,125
2013-05-17T07:53:00.000
1
1
0
0
c++,python,login,operating-system
16,604,457
1
true
0
0
Assuming that you would like to support login systems such as User/Pass, LDAP, OpenID, Oauth etc.. you have to model your authentication layer to be able to support all these mechanisms. I usually consider the above authentication methods as strategies. Lets say you have an Authentication class with an authenticate method which accepts an object that implements an interface "AuthStrategy" and the various authentication methods can implement this interface. Hope the object model is clear.
1
0
0
I would like to make an authentication system where users or an administrator can choose which login system they prefer. The problem is that different systems have different Login-Systems and different client-informations. I thought I will make an simple User-Class in the c++ application and an administrator can extend this class with its own one or more User-Login-Systems in Python. Off course this service runs on a server. How can I organize the different Login-Systems on the server and automatically use the prefered Login-System with the correct user-information class on the client application?
handling multiple login systems
1.2
0
0
398
16,604,372
2013-05-17T08:10:00.000
0
0
0
1
python,azure,azure-virtual-machine
16,604,662
1
false
1
0
Could it be that port 81 is blocked by firewall in Ubuntu?
1
1
0
I have created a VM on Windows Azure with Ubuntu 12.04 running on it. I have two end-points End-point1 public port: 50348 private port: 22 End-point2 public port: 81 private port: 81 Now, I have a simple python HTTP server running on the Virtual Machine, which is listening on port 81. When I try to connect to localhost:81 from within the Virtual machine, I am able to connect, so I know that the server is up and running. Say, the DNS name assigned to my VM be blah-blah.cloudapp.net But, when I try to connect to http://blah-blah.cloudapp.net:81 from somewhere outside, I always get a Server Not Found error. So, how can I connect to my server?
Azure - Running an http server on an VM
0
0
0
453
16,606,906
2013-05-17T10:33:00.000
1
0
0
0
python,hbase,thrift
16,608,107
1
false
0
0
HBase provides a scanner interface that allows you to enumerate over a range of keys in an HTable. HappyBase has support for scans and this is documented pretty well in their API. So this would solve your question if you were asking for a "like 'name%'" type of query which searches for anything that begins with the prefix 'name'. I am assuming name is the row key in your table, otherwise you would need a secondary index which relates the name field to the row key value of the table or go with the sub-awesome approach of scanning the entire table and doing the matching in Python yourself, depending on your usecase... Edit: HappyBase also supports passing a 'filter' string assuming you are using a recent HBase version. You could use the SubStringComparator or RegexStringComparator to fit your needs.
1
0
0
I want to do something like select * from table where name like '%name%' is there anyway to do this in Hbase ? and if there is a way so how to do that ps. I use HappyBase to communicate with Hbase
Hbase wildcard support
0.197375
1
0
364
16,615,838
2013-05-17T18:40:00.000
0
0
0
0
python,komodo
16,616,493
2
false
0
1
Ok heres what I personally do. Open run, type in cmd Navigate to whatever directory my mypythonfile.py file is Open whatever text editor you feel like ( personally i use notepad++ because it is NOT an IDE like kodomo, but just a pretty text editor.) Type python mypythonfile.py and hit enter. This will run the program. Open mypythonfile.py in text editor program. Make changes to the python file. Go back to the cmd window and press arrow up ( to go to the last typed command) and then press enter again, to run the program again. Repeat steps 6-7 until your program is perfect. It seems like you are having trouble with the Kodomo IDE instead of the actual learning python process. IDEs are complicated tools with lots of buttons that are scary. Learn the language first, then once you are comfortable there, then maybe you will use an IDE? Or maybe you will just keep using a text editor instead. Thats up to you.
1
1
0
I am just learning python as my first programming language, and I just installed python 3.3, 64 bit on my windows 7 OS. I installed komodo edit 8.0, and I am trying to print ('Hello world'). I set up the correct path so that I can access python through my command prompt. From komodo, I saved my helloworld.py file to my desktop. When I try to run the command prompt, I search for the file, and it says file not found, or file does not exist. I can open the folder from komodo, but it appears that it is empty. When I open the folder directly from my desktop, I see the file is in there, so it seems that komodo is not recognizing it. How can I get Komodo to recognize my saved file and run it in python? I am very new so please go step by step if you can. Thank you!
I need help recognizing files in komodo in order to run them in python
0
0
0
968
16,616,029
2013-05-17T18:52:00.000
2
0
0
0
python,gtk,pyqt,pygtk
16,616,290
3
true
0
1
The user interfaces create with glade are saved as xml file: using gtkbuilder, this file can be used with many programming languages, like c++ or python. Pygtk lets you create application with user interfaces, based on glade file.But you have to do all by hand.
1
3
0
I'm learning the Python and now I'm trying to choose cross-platform-GUI-framework. As I see, the PyGTK is the best one, which fits my goals completely. The only question: is there any analog of pyuic4 (which creates python class based on .ui file created by QtDesigner) for files made with Glade app? Or the only way is creating class manually?
How to convert .glade file to python class?
1.2
0
0
2,653
16,616,728
2013-05-17T19:43:00.000
0
0
0
0
c++,python,qt,pyqt,pyqt4
16,761,507
1
true
0
1
Use PySide. It's about 99.8 % compatible with PyQt, except for Signals and Slots. Replace every occurence of PyQt4 with PySide in your project, then replace pyqtSignal with Qt.Signal and pyqtSlot with Qt.Slot. It should work out of the box. Many projects support both PyQt and PySide because there is virtually no difference between the two…
1
0
0
Can someone tell whether there is any application that converts a PyQt4 (with syntax in Python) project to a Qt4 (with syntax in C++) project? This will help people to switch from using a GPL non-commercial license in case of PyQt to a much liberal LGPL non-commercial license in case of Qt!
is there any application that converts a PyQt (with syntax in Python) project to a Qt (with syntax in C++ ) project?
1.2
0
0
217
16,617,136
2013-05-17T20:12:00.000
0
0
1
0
python,sqlalchemy
16,617,300
2
false
0
0
try printing SQLAlchemy.__all__ which will return you a list of all functions in that module which are publicly available.
1
4
0
I'm using SQLAlchemy and am trying to import the function group_by into the interpreter, but I can't seem to find it. Is there an easy way to search the module tree to see where this function lives? Of course I've tried from sqlalchemy import + tab and searching manually, but at each tree level there are too many options to check.
How to locate a function in a Python module tree?
0
0
0
502
16,620,143
2013-05-18T02:36:00.000
1
0
0
0
python,localization,future-proof
25,901,048
2
true
0
0
It sounds like you are trying to use the English representation of your text as a unique ID for the message, but then when you change the English representation, it no longer matches the IDs in your previously stored preference files. The solution is to use a unique and permanent ID for each message. This ID could be English-readable, but you have to commit to never changing it. It's probably helpful to use a simple and standardized naming convention for this ID, with no unicode or uppercase characters. For example, one message ID might be 'cubic inches'. Another could be 'degrees fahrenheit' Then, you should define internationalized text for displaying this message in every language, including English. So if you want to display the 'cubic inches' message on an English system, you will lookup the English equivalent for this ID and get 'Cubic inches', 'Cubic Inches', u'in\u00b3' or whatever you like. Then your application can display that text. But you will always store the permanent message ID ('cubic inches') in the preferences file. This gives you the flexibility to change the English-language representation of the message, as shown to the user, without invalidating the IDs in previously-stored preference files.
2
1
0
so I know this is a not a good question for the StackOverflow format. but I am at a bit of a loss, feel free to recommend a different place to put this where it may get some eyeballs I am very familliar with the xgettext stuff for localizing your python program. currently we are saving user preferences as strings (eg: user_prefs = {'temperature':u'\u00b0C Fahrenheit', 'volumetric':'Cubic inches', ...} ) this works fine, and when operating in foreign languages we attempt(mostly successfully) to reverse the string localization back to english before saving it. so that the saved string is always the english version, and then we localize them when we start the program. however it leads to problems later if we change 'Cubic inches' to u'in\u00b3' or even a small change like 'Cubic inches' to 'Cubic Inches'. we have somewhat compensated for this by always doing comparisons in lower case, but it feels hackish to me, and it seems like there must be a better way to do it such as saving an id (be it an index into an array or even just some unique identifier). but wondering about others experiences here with regards to future proofing user preferences so that they will always be recognized. I suspect this will get closed (asking for subjective answers) but maybe I can get some good insight before it does
Localization and future-proofing
1.2
0
0
75
16,620,143
2013-05-18T02:36:00.000
0
0
0
0
python,localization,future-proof
16,623,416
2
false
0
0
i don't get your actual problem, where are you storing. but hope "base64 utf encoding decoding" can solve your problem.
2
1
0
so I know this is a not a good question for the StackOverflow format. but I am at a bit of a loss, feel free to recommend a different place to put this where it may get some eyeballs I am very familliar with the xgettext stuff for localizing your python program. currently we are saving user preferences as strings (eg: user_prefs = {'temperature':u'\u00b0C Fahrenheit', 'volumetric':'Cubic inches', ...} ) this works fine, and when operating in foreign languages we attempt(mostly successfully) to reverse the string localization back to english before saving it. so that the saved string is always the english version, and then we localize them when we start the program. however it leads to problems later if we change 'Cubic inches' to u'in\u00b3' or even a small change like 'Cubic inches' to 'Cubic Inches'. we have somewhat compensated for this by always doing comparisons in lower case, but it feels hackish to me, and it seems like there must be a better way to do it such as saving an id (be it an index into an array or even just some unique identifier). but wondering about others experiences here with regards to future proofing user preferences so that they will always be recognized. I suspect this will get closed (asking for subjective answers) but maybe I can get some good insight before it does
Localization and future-proofing
0
0
0
75
16,621,503
2013-05-18T06:41:00.000
0
0
1
0
python,file,text,reload
16,621,540
2
false
0
0
Why we cannot just reopen the file?
1
1
0
I am making a script that looks for changes in a file using python. It is being pushed using FTP to the server but I cannot make the script reload a file with the same name and get new data from that. i.e Mean_value=12 Server prints 12 BUT when I change that line to become 13 the following happens: Server prints 12 AGAIN. I would like it to print 13. Please help!
How to reload a changing file?
0
0
0
93
16,624,353
2013-05-18T12:39:00.000
1
0
0
0
python,math,2d,triangulation
16,624,415
1
true
0
0
First, solve the math. Make a drawing. You will find that you can use two points and their distance to reduce the possible points to just two, the third one will only be needed to disambiguate between the two. Putting the whole into Python should be easy then. Note that I'm not going to spell this out completely for you, because it is customary to not spoil other programmers the experience of doing their own homework, doing research etc. If you have something that you have a problem with, then ask specific questions and demonstrate some effort on your side first.
1
0
0
I have data about 10 points in a 2D map, I know the location of points 1,2 and 3. I also know the distance between point 1,2 and 3 to all other points. I know that cell phone uses distance from gsm towers to locate their location. I wish to use similar approach to locate points 3-10. How can I implement such a solution with python? Which libraries can I use? Thank you for all help
Locational triangulation
1.2
0
0
1,138
16,625,298
2013-05-18T14:20:00.000
1
0
0
0
python,scipy,numeric,numerical-methods
16,652,325
2
false
0
0
Before you can ask the programming question, it seems to me you need to investigate a more fundamental scientific one. Before you can start picking out particular equations to fit badfastclock to goodslowclock, you should investigate the nature of the drift. Let both clocks run a while, and look at their points together. Is badfastclock bad because it drifts linearly away from real time? If so, a simple quadratic equation should fit badfastclock to goodslowclock, just as a quadratic equation describes the linear acceleration of a object in gravity; i.e., if badfastclock is accelerating linearly away from real time, you can deterministically shift badfastclock toward real time. However, if you find that badfastclock is bad because it is jumping around, then smooth curves -- even complex smooth curves like splines -- won't fit. You must understand the data before trying to manipulate it.
2
2
1
I have some sampled (univariate) data - but the clock driving the sampling process is inaccurate - resulting in a random slip of (less than) 1 sample every 30. A more accurate clock at approximately 1/30 of the frequency provides reliable samples for the same data ... allowing me to establish a good estimate of the clock drift. I am looking to interpolate the sampled data to correct for this so that I 'fit' the high frequency data to the low-frequency. I need to do this 'real time' - with no more than the latency of a few low-frequency samples. I recognise that there is a wide range of interpolation algorithms - and, among those I've considered, a spline based approach looks most promising for this data. I'm working in Python - and have found the scipy.interpolate package - though I could see no obvious way to use it to 'stretch' n samples to correct a small timing error. Am I overlooking something? I am interested in pointers to either a suitable published algorithm, or - ideally - a Python library function to achieve this sort of transform. Is this supported by SciPy (or anything else)? UPDATE... I'm beginning to realise that what, at first, seemed a trivial problem isn't as straightforward as I first thought. I am no-longer convinced that naive use of splines will suffice. I've also realised that my problem can be better described without reference to 'clock drift'... like this: A single random variable is sampled at two different frequencies - one low and one high, with no common divisor - e.g. 5hz and 144hz. If we assume sample 0 is identical at both sample rates, sample 1 @5hz falls between samples 28 amd 29. I want to construct a new series - at 720hz, say - that fits all the known data points "as smoothly as possible". I had hoped to find an 'out of the box' solution.
Interpolaton algorithm to correct a slight clock drift
0.099668
0
0
426
16,625,298
2013-05-18T14:20:00.000
0
0
0
0
python,scipy,numeric,numerical-methods
16,708,058
2
false
0
0
Bsed on your updated question, if the data is smooth with time, just place all the samples in a time trace, and interpolate on the sparse grid (time).
2
2
1
I have some sampled (univariate) data - but the clock driving the sampling process is inaccurate - resulting in a random slip of (less than) 1 sample every 30. A more accurate clock at approximately 1/30 of the frequency provides reliable samples for the same data ... allowing me to establish a good estimate of the clock drift. I am looking to interpolate the sampled data to correct for this so that I 'fit' the high frequency data to the low-frequency. I need to do this 'real time' - with no more than the latency of a few low-frequency samples. I recognise that there is a wide range of interpolation algorithms - and, among those I've considered, a spline based approach looks most promising for this data. I'm working in Python - and have found the scipy.interpolate package - though I could see no obvious way to use it to 'stretch' n samples to correct a small timing error. Am I overlooking something? I am interested in pointers to either a suitable published algorithm, or - ideally - a Python library function to achieve this sort of transform. Is this supported by SciPy (or anything else)? UPDATE... I'm beginning to realise that what, at first, seemed a trivial problem isn't as straightforward as I first thought. I am no-longer convinced that naive use of splines will suffice. I've also realised that my problem can be better described without reference to 'clock drift'... like this: A single random variable is sampled at two different frequencies - one low and one high, with no common divisor - e.g. 5hz and 144hz. If we assume sample 0 is identical at both sample rates, sample 1 @5hz falls between samples 28 amd 29. I want to construct a new series - at 720hz, say - that fits all the known data points "as smoothly as possible". I had hoped to find an 'out of the box' solution.
Interpolaton algorithm to correct a slight clock drift
0
0
0
426
16,627,465
2013-05-18T18:15:00.000
3
0
1
0
python,image
16,627,502
3
false
0
0
One caveat is that .read() isn't necessarily guaranteed to read the entire file at once, so you must make sure to repeat the read/write cycle until all of the data has been copied. Another is that there may not be enough memory to read all of the data at once, in which case you'll need to perform multiple partial reads and writes in order to complete the copy.
2
2
0
I'm relatively new to python, and am part of the way through "Learning python the Hard Way," but have a question. So, from what I've read, if you want to make a copy of a text file, you can just open and read it contents to a variable, then write this variable to a different file. I've tested it out with images, and it actually seems to work. Are there downsides to this method of copying that I'll run into later, and are there any file types it specifically won't work for? Thank you very much!
Copying files with python
0.197375
0
0
2,498
16,627,465
2013-05-18T18:15:00.000
0
0
1
0
python,image
16,627,936
3
false
0
0
So, from what I've read, if you want to make a copy of a text file, you can just open and read it contents to a variable, then write this variable to a different file. I've tested it out with images, and it actually seems to work. Are there downsides to this method of copying that I'll run into later, and are there any file types it specifically won't work for? If you open both files in binary mode, you read with .read(), and write with write(), then you get an exact copy. If you use other mechanisms, you could strip out line endings or encounter troubles, in particular when you work cross-platform. From the docs On Windows, 'b' appended to the mode opens the file in binary mode, so there are also modes like 'rb', 'wb', and 'r+b'. Python on Windows makes a distinction between text and binary files; the end-of-line characters in text files are automatically altered slightly when data is read or written. This behind-the-scenes modification to file data is fine for ASCII text files, but it’ll corrupt binary data like that in JPEG or EXE files. Be very careful to use binary mode when reading and writing such files. On Unix, it doesn’t hurt to append a 'b' to the mode, so you can use it platform-independently for all binary files. In any case, use other approaches to file copy, like the ones suggested by others.
2
2
0
I'm relatively new to python, and am part of the way through "Learning python the Hard Way," but have a question. So, from what I've read, if you want to make a copy of a text file, you can just open and read it contents to a variable, then write this variable to a different file. I've tested it out with images, and it actually seems to work. Are there downsides to this method of copying that I'll run into later, and are there any file types it specifically won't work for? Thank you very much!
Copying files with python
0
0
0
2,498
16,628,859
2013-05-18T20:56:00.000
0
0
1
0
python,file,save,python-idle
65,625,337
2
false
0
0
It is in ".idlerc" named folder in your users directory in windows 10 here are the steps press win+R OR simply search in windows search(the taskbar one) then paste %USERPROFILE%\.idlerc hit enter copy all files in it to wherever you may like to (a usb in your case)
2
3
0
I have several computers at different locations, and although I'm not coding in IDLE, it is always running in the background, for small testing, debugging and researching tasks. I configured IDLE custom highlighting, key set, etc. at home, and it would be pretty comfy to save my settings into an external file, and install these settings onto any machines I'm working on. So my question: is there a way to do that? Or it would be also nice, if anyone knows where IDLE stores these datas — probably I can copy the file(s) from there.. Thanks in advance!
How to save custom preferences of python's IDLE?
0
0
0
2,340
16,628,859
2013-05-18T20:56:00.000
3
0
1
0
python,file,save,python-idle
16,629,655
2
true
0
0
IDLE saves its preferences in several files in the $HOME/.idlerc directory, creating the files (for example, config-main.cfg) as needed. The important ones, at least, are simple text files so you should be able to copy those files from your home directory on one machine to another. There are a few potential gotcha's to watch out for: When you copy the files to another home directory, make sure no IDLE instances are running. Be aware that currently all versions of IDLE (with Python 2.7, 3.2, 3.3, etc) share the same .idlerc directory and files. I'm not aware of any major conflicts at this point other than possibly recent files with file names with non-ASCII characters that require Unicode representation: that could cause problems sharing between IDLE 2.x and 3.x. Another issue might be line endings if you attempt to share files between Windows and non-Windows systems.
2
3
0
I have several computers at different locations, and although I'm not coding in IDLE, it is always running in the background, for small testing, debugging and researching tasks. I configured IDLE custom highlighting, key set, etc. at home, and it would be pretty comfy to save my settings into an external file, and install these settings onto any machines I'm working on. So my question: is there a way to do that? Or it would be also nice, if anyone knows where IDLE stores these datas — probably I can copy the file(s) from there.. Thanks in advance!
How to save custom preferences of python's IDLE?
1.2
0
0
2,340
16,629,529
2013-05-18T22:19:00.000
0
0
0
0
python,numpy,opencl,gpgpu
18,478,963
2
false
0
0
If memory servers, pyCuda at least, probably also pyOpenCL can work with numPy
1
2
1
I reconized numpy can link with blas, and I thought of why not using gpu accelerated blas library. Did anyone use to do so?
Can I link numpy with AMD's gpu accelerated blas library
0
0
0
2,411
16,630,537
2013-05-19T01:12:00.000
0
0
0
0
python,pdf-generation
16,631,012
1
false
1
0
Turns that Adobe's reader has a "Booklet" option in the printing options. Worked out nicely.
1
0
0
I'm trying to write a novel and I am trying to print out my own book prototypes. I have a PDF of the book. Now I want to merge the pages so that I can print it double-sided, fold it in half, and staple it like a boss. The problem I need to solve is how to splice 2 pages together with a left and right side. I looked at PyPDF2 and its mergePage function, but it only superimposes one page onto another. The new generated page will be twice the width of the original pages, one page superimposed on the left, and one page superimposed on the right. Thank you for your time in looking at this!
Splice 2 PDF pages into one with Python
0
0
0
255
16,630,885
2013-05-19T02:26:00.000
1
0
0
0
python,web2py
16,634,500
1
false
1
0
Can you share the error details? If you can't access the error dump file via the admin app, use some other tool to view the file under ...web2py/theapp/errors. The file format isn't easily readable, but the last few lines are usually pretty informative.
1
0
0
I have a web2py app I developed on my local machine. I tried to move the application to a Windows Server 2003 Virtual Machine but when I run it on the VM the app simply errors out on start up and when I click to see the error it prompts me for the admin password. When I enter it, the app errors again. There are no errors output on the console before, during, or closing the server. Is there something special I need to do for setup on a VM? Is this some kind of Apache problem? I believe the server only has http protocols active. I am using port 8080, since I think through version control the parameters_8000.py is a password I do not know. Thanks in advance.
web2py on a Virtual Machine
0.197375
0
0
169
16,630,969
2013-05-19T02:50:00.000
5
0
0
0
ipython-notebook
16,632,621
3
true
0
0
Not on stable, and only on Header(1-6) cell on master. Just click on the header cell and it will put the right anchor in the url bar, wich is usually #header_title_sanitized Using the prompt number is not a good idea as it might change. It will be supported on nbviewer as well, we are working on it.
1
13
0
I am writing documentation for a notebook-based framework. When referring to important cells in a demo-notebook, can I point to a particular cell by using some sort of anchor? For example if I have the demo-notebook at 127.0.0.1/mydemo, is it possible to refer to the input cell In[10] by some anchor tag like 127.0.0.1/mydemo#In10
ipython notebook anchor link to refer a cell directly from outside
1.2
0
0
10,450
16,634,773
2013-05-19T12:44:00.000
0
0
0
0
python,web
16,634,850
3
false
0
0
The urllib2 module has been split across several modules in Python 3.0 named urllib.request and urllib.error. The 2to3 tool will automatically adapt imports when converting your sources to 3
1
2
0
I wanted to use urllib2 for python 3, but I don't think it's available in such name. I use urllib.request, is there another way to use urllib2?
Using urllib2 for Python3
0
0
1
4,670