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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4,697,623 | 2011-01-15T01:55:00.000 | 3 | 0 | 0 | 0 | python,multithreading,network-programming,urllib2,python-multithreading | 4,697,664 | 1 | true | 1 | 0 | Are you sure you are closing TCP sessions after each request? Try to check netstat information from time to time and if you'll see that the number of active/established sessions is rising it means that you have some problems in your script.
Yes, usually you can ping even if you are out of free TCP sockets. | 1 | 0 | 0 | It's a GUI program I wrote in python checking website/server status running on my XP SP3, multi threads are used to check different site/server. After several hours running, the program starts to get urlopen error timed out all the time, and this always happens right after a POST request from a server(not a certain one... | Able to ping but cannot browse after several hours running of my python program | 1.2 | 0 | 1 | 204 |
4,698,103 | 2011-01-15T05:02:00.000 | 1 | 0 | 1 | 0 | python,data-structures,map | 4,698,371 | 4 | false | 0 | 0 | In C/C++, I believe that I would use pointers to reference the same piece of data from different keys.
Almost anything in Python qualifies as a "C/C++ pointer".
Use your option #1, two dictionaries, and test it for performance. If you define a class for the content, then constructors and destructors can manage the dict... | 3 | 1 | 0 | I am attempting to create a nice interface to access a data set where each value has several possible keys. For example, suppose that I have both a number and a name for each value in the data set. I want to be able to access each value using either the number OR the name.
I have considered several possible implementat... | Dictionaries with more than one key per value in Python | 0.049958 | 0 | 0 | 1,840 |
4,698,103 | 2011-01-15T05:02:00.000 | 1 | 0 | 1 | 0 | python,data-structures,map | 4,698,137 | 4 | false | 0 | 0 | Are both the names and numbers unique? Using one to find the other, first, isn't so very bad.
And two dictionaries pointing to the same data, like in C, won't duplicate the data, and is fine, too.
Encapsulating the two dictonaries into a self-contained object with add(name,number,value) and findByName(name), findByNumb... | 3 | 1 | 0 | I am attempting to create a nice interface to access a data set where each value has several possible keys. For example, suppose that I have both a number and a name for each value in the data set. I want to be able to access each value using either the number OR the name.
I have considered several possible implementat... | Dictionaries with more than one key per value in Python | 0.049958 | 0 | 0 | 1,840 |
4,698,103 | 2011-01-15T05:02:00.000 | 1 | 0 | 1 | 0 | python,data-structures,map | 4,698,351 | 4 | false | 0 | 0 | Look at it this way: You are in all essence wanting to have a three-column database where two columns are indexed, but with the simplification that you don't want to be able to look up the indexed values.
Option 5 is in practice trying to make such a simplified database. And what you end up with when making such a data... | 3 | 1 | 0 | I am attempting to create a nice interface to access a data set where each value has several possible keys. For example, suppose that I have both a number and a name for each value in the data set. I want to be able to access each value using either the number OR the name.
I have considered several possible implementat... | Dictionaries with more than one key per value in Python | 0.049958 | 0 | 0 | 1,840 |
4,698,265 | 2011-01-15T06:02:00.000 | 0 | 0 | 0 | 1 | python,django,google-app-engine,httpwebrequest | 4,698,277 | 1 | true | 1 | 0 | Should be in self.request.url in your RequestHandler-based class. | 1 | 0 | 0 | I'm using Google App Engine with the standard Django templates found in Webapp.
I wanted to display the permalink to the page the user is on. How do I get the uri? | Get the uri of the page in Google App Engine / Django? | 1.2 | 0 | 0 | 98 |
4,698,933 | 2011-01-15T09:49:00.000 | 0 | 0 | 0 | 0 | python,sqlite,tuples | 4,699,909 | 3 | false | 0 | 1 | If you are searching for a string matching the start using LIKE, eg 'abc%' (rather than anywhere in the string - '%abc%'), the search should be quite fast if you have an index on the field, as the db can use the index to help find the matches. | 2 | 0 | 0 | I'm having a database (sqlite) of members of an organisation (less then 200 people). Now I'm trying to write an wx app that will search the database and return some contact information in a wx.grid. The app will have 2 TextCtrls, one for the first name and one for the last name. What I want to do here is make it possi... | Searching a list of tuples in python | 0 | 0 | 0 | 697 |
4,698,933 | 2011-01-15T09:49:00.000 | 2 | 0 | 0 | 0 | python,sqlite,tuples | 4,698,981 | 3 | false | 0 | 1 | I think that generally, you shouldn't be afraid of giving tasks to a database. It's quite possible that the LIKE clause will be very fast. Sqlite is implemented in fairly robust C code, and will happily deal with queries like this.
If you're worried about sending too many requests, why not send a query once a user has ... | 2 | 0 | 0 | I'm having a database (sqlite) of members of an organisation (less then 200 people). Now I'm trying to write an wx app that will search the database and return some contact information in a wx.grid. The app will have 2 TextCtrls, one for the first name and one for the last name. What I want to do here is make it possi... | Searching a list of tuples in python | 0.132549 | 0 | 0 | 697 |
4,699,605 | 2011-01-15T12:36:00.000 | 3 | 0 | 0 | 0 | python,transactions,sqlite,autocommit | 15,967,816 | 5 | false | 0 | 0 | Python sqlite3 issues a BEGIN statement automatically before "INSERT" or "UPDATE". After that it automatically commits on any other command or db.close() | 1 | 18 | 0 | I read somewhere that to save data to a SQLite3 database in Python, the method commit of the connection object should be called. Yet I have never needed to do this. Why? | Why doesn’t SQLite3 require a commit() call to save data? | 0.119427 | 1 | 0 | 20,808 |
4,700,178 | 2011-01-15T14:47:00.000 | 0 | 0 | 1 | 0 | python,c,distutils | 4,700,264 | 3 | false | 0 | 1 | You could have two separate branches of the src, one containing the libraries and another that doesn't. That way you can explicitly warn your users in case they have installed the libraries. Another solution could be (if the licences of the libraries allow you) is to wrap 'em up in a single file.
I think there's no uni... | 1 | 7 | 0 | If I have a Python package that depends on some C libraries (like say the Gnu Scientific Library (GSL) for numerical computations), is it a good idea to bundle the library with my code?
I'd like to make my package as easy to install as possible for users and I don't want them to have to download C libraries by hand and... | Should I bundle C libraries with my Python application? | 0 | 0 | 0 | 629 |
4,700,188 | 2011-01-15T14:50:00.000 | 0 | 0 | 1 | 0 | python,syntax,python-idle | 35,235,025 | 3 | false | 0 | 0 | @squashua: I have the same issue when I try to run the code either in IDLE or Ubuntu terminal.
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25)
it highlights "5" as syntax error. | 2 | 0 | 0 | I'm a newbie programmer so I'll do my best to clearly ask my question. I'm running Python scripts in Mac 10.6.5 and now trying to write and save to a text file (following instructions in HeadsUp Python book). Whenever I hit function+F5 (as instructed) I get the same "invalid syntax" error and Idle highlights the "1" in... | Why is Python 3.1.3 in the header listed as a syntax error? | 0 | 0 | 0 | 1,254 |
4,700,188 | 2011-01-15T14:50:00.000 | 0 | 0 | 1 | 0 | python,syntax,python-idle | 7,627,960 | 3 | false | 0 | 0 | you are writing your script in the wrong IDLE window ! when starting IDLE, it opens 2 windows: one for writing a script and another one with an interactive python shell. executing the content of the interactive python shell makes no sense. | 2 | 0 | 0 | I'm a newbie programmer so I'll do my best to clearly ask my question. I'm running Python scripts in Mac 10.6.5 and now trying to write and save to a text file (following instructions in HeadsUp Python book). Whenever I hit function+F5 (as instructed) I get the same "invalid syntax" error and Idle highlights the "1" in... | Why is Python 3.1.3 in the header listed as a syntax error? | 0 | 0 | 0 | 1,254 |
4,700,292 | 2011-01-15T15:13:00.000 | 46 | 0 | 0 | 1 | python,rabbitmq,esb,amqp | 9,286,914 | 3 | true | 0 | 0 | Queue browsing is not supported directly, but if you declare a queue with NO auto acknowledgements and do not ACK the messages that you receive, then you can see everything in it. After you have had a look, send a CANCEL on the channel, or disconnect and reconnect to cause all the messages to be requeued. This does inc... | 1 | 48 | 0 | As a way to learn RabbitMQ and python I'm working on a project that allows me to distribute h264 encodes between a number of computers. The basics are done, I have a daemon that runs on Linux or Mac that attaches to queue, accepts jobs and encodes them using HandBrakeCLI and acks the message once the encode is complet... | Using RabbitMQ is there a way to look at the queue contents without a dequeue operation? | 1.2 | 0 | 0 | 26,786 |
4,700,614 | 2011-01-15T16:10:00.000 | 2 | 0 | 1 | 0 | python,matplotlib,legend | 4,710,783 | 17 | false | 0 | 0 | You can also try figlegend. It is possible to create a legend independent of any Axes object. However, you may need to create some "dummy" Paths to make sure the formatting for the objects gets passed on correctly. | 1 | 1,378 | 1 | I have a series of 20 plots (not subplots) to be made in a single figure. I want the legend to be outside of the box. At the same time, I do not want to change the axes, as the size of the figure gets reduced. Kindly help me for the following queries:
I want to keep the legend box outside the plot area. (I want the... | How to put the legend outside the plot in Matplotlib | 0.023525 | 0 | 0 | 1,360,273 |
4,701,576 | 2011-01-15T19:12:00.000 | 1 | 0 | 1 | 0 | python,timed-events | 4,701,613 | 3 | false | 0 | 0 | I don't think this can be guaranteed by a language construct (in any language) -- you'd have to be on a real-time operating system. I believe multimedia applications take advantage of device-level buffering to compensate for timing jitter in the OS process scheduler. | 2 | 3 | 0 | I want to execute a piece of my code in exactly the same time every time I execute it, somewhat like playing a media file... (the same piece of code is executed in exactly the same amount of time every time)
Is this possible in python? | python timed execution of code | 0.066568 | 0 | 0 | 356 |
4,701,576 | 2011-01-15T19:12:00.000 | 0 | 0 | 1 | 0 | python,timed-events | 4,701,608 | 3 | false | 0 | 0 | I should think this would be impossible in an operating system which interleaves instructions to simulate simultaneous execution of multiple threads.
You would need a real-time library or language in order to stipulate deadlines for your code, and even then execution cannot be guaranteed in the allotted time. | 2 | 3 | 0 | I want to execute a piece of my code in exactly the same time every time I execute it, somewhat like playing a media file... (the same piece of code is executed in exactly the same amount of time every time)
Is this possible in python? | python timed execution of code | 0 | 0 | 0 | 356 |
4,701,766 | 2011-01-15T19:45:00.000 | -1 | 1 | 0 | 1 | python,perl,bash,admin | 13,985,089 | 2 | false | 0 | 0 | I'd say if this is only your machine and you're not supposed to share those administration scripts with any other one, so you'd better to keep doing that in Python (which seems you feel more comfortable on that).
But if you have colleagues or your admin scripts are supposed to employee by other people, so let keep it i... | 1 | 8 | 0 | I normally code admin scripts in Python and I know of many that code them in Perl. I was about to invest some time on improving my skills on bash programming. But I wonder if people around think that this is a good idea ?
I know bash is a good skill to have and market very often demand it but ... if I can get by with ... | Python and/or Perl VS bash | -0.099668 | 0 | 0 | 5,752 |
4,701,902 | 2011-01-15T20:14:00.000 | 0 | 1 | 0 | 0 | php,python,svn,hook,svn-hooks | 4,701,984 | 2 | true | 0 | 0 | I would say that's possible, but you are going to need a bit of work to retrieve the username, date and commit message.
Subversion invokes the post-commit hook with the repo path and the number of revision which was just committed as arguments.
In order to retrieve the information you're looking for, you will need to u... | 2 | 1 | 0 | I've got a situation where I'm contemplating using subversion/svn as the repository/version control system for a project. I'm trying to figure out if it's possible, (and if so, how) to be able to have the subversion system, on a post commit hook/process to to write the user/file/time (and maybe msg) to either an extern... | subversion post commit hooks | 1.2 | 1 | 0 | 1,005 |
4,701,902 | 2011-01-15T20:14:00.000 | 0 | 1 | 0 | 0 | php,python,svn,hook,svn-hooks | 4,701,973 | 2 | false | 0 | 0 | Indeed it is very possible, in your repository root there should be a folder named hooks, inside which should be a file named post-commit (if not, create one), add whatever bash code you put there and it will execute after every commit.
Note, there are 2 variables that are passed into the script $1 is the repository, a... | 2 | 1 | 0 | I've got a situation where I'm contemplating using subversion/svn as the repository/version control system for a project. I'm trying to figure out if it's possible, (and if so, how) to be able to have the subversion system, on a post commit hook/process to to write the user/file/time (and maybe msg) to either an extern... | subversion post commit hooks | 0 | 1 | 0 | 1,005 |
4,702,133 | 2011-01-15T21:06:00.000 | 1 | 0 | 1 | 0 | python,ironpython,windows-server | 4,702,170 | 5 | false | 0 | 0 | I'm not sure about Windows, but Python is used a lot in Linux for administrative scripts and it is way better that a native Windows shell. And I think that Python is quite good for your tasks.
As another option you can take a look at cygwin and bash. | 1 | 9 | 0 | I'm currently working on a strategy for managing multiple Windows Server 2003 to 2008 running SQL Server 2000 - 2008 and I want/need a unified scripting platform for automating tasks. I'm becoming a big fan of Python and as such I'd like to know if Python has been used effectively as a scripting language for administe... | Can Python be used as an effective script language for Windows Server environment? | 0.039979 | 0 | 0 | 9,583 |
4,703,978 | 2011-01-16T05:28:00.000 | 0 | 0 | 1 | 0 | python,api,hardware | 5,414,882 | 4 | true | 0 | 0 | I ended up finding some good hardware by eData that was run off of embedded Linux with ssh, SOAP, REST, and Web GUI access. Unfortunately the integrator bid way too high and wouldn't commit to working in our time frame, so we ended up with the crappy Kantech stuff. Yay serial cables. :-( | 3 | 14 | 0 | Okay, so not strictly a programming question BUT the point is I want to integrate my new building's business access/alarm system into the rest of my *NIX setup at my business. I do NOT want to use some cruddy windows GUI program written for Windows XP SP1 that manages a bare circuit-board via a serial connection and p... | What alarm/access hardware can I control from *NIX? | 1.2 | 0 | 0 | 527 |
4,703,978 | 2011-01-16T05:28:00.000 | 0 | 0 | 1 | 0 | python,api,hardware | 4,746,220 | 4 | false | 0 | 0 | I suppose the way to go will be DPWS; as Windows provides built-in support for this now, you can expect hardware vendors to jump on the bandwagon. | 3 | 14 | 0 | Okay, so not strictly a programming question BUT the point is I want to integrate my new building's business access/alarm system into the rest of my *NIX setup at my business. I do NOT want to use some cruddy windows GUI program written for Windows XP SP1 that manages a bare circuit-board via a serial connection and p... | What alarm/access hardware can I control from *NIX? | 0 | 0 | 0 | 527 |
4,703,978 | 2011-01-16T05:28:00.000 | 1 | 0 | 1 | 0 | python,api,hardware | 4,823,577 | 4 | false | 0 | 0 | What do you actually want to do with your integrated system?
Two of my former employers developed access control systems, both running on Windows. Both provided a programmatic API (DCOM or TCP socket.) *NIX support was another matter, but you avoid the hardware interfacing problem, at least.
One was Honeywell, but that... | 3 | 14 | 0 | Okay, so not strictly a programming question BUT the point is I want to integrate my new building's business access/alarm system into the rest of my *NIX setup at my business. I do NOT want to use some cruddy windows GUI program written for Windows XP SP1 that manages a bare circuit-board via a serial connection and p... | What alarm/access hardware can I control from *NIX? | 0.049958 | 0 | 0 | 527 |
4,705,333 | 2011-01-16T12:30:00.000 | 0 | 0 | 0 | 0 | python,cherrypy | 4,706,295 | 4 | false | 1 | 0 | I've been running a CherryPy website with Python 3 for a few months now and it works well, but you have to use the code from the python3 branch of the repository because CherryPy 3.2 isn't released yet. | 1 | 6 | 0 | Does cherrypy support Python3 yet? What other web frameworks out there support Python 3? | Is cherrypy Python3-compatible yet? | 0 | 0 | 0 | 3,485 |
4,705,723 | 2011-01-16T13:58:00.000 | 3 | 1 | 1 | 1 | python,distutils | 4,706,043 | 3 | true | 0 | 0 | Do it the other way around. Add the version number, the author name and other metadata you need in the script to the script itself. Then import or execfile() the script in setup.py, and use the metadata defined in the script as arguments to the setup() function. | 1 | 2 | 0 | I have a python script that outputs the program name, version number and the author when called with command line arguments like --help or --version. Currently this information is hardcoded in the python script itself. But I use distutils for building/packaging the application so all this information is already present... | Replace symbols in python script on distribution | 1.2 | 0 | 0 | 201 |
4,707,008 | 2011-01-16T17:54:00.000 | 1 | 0 | 0 | 0 | python,django | 4,707,169 | 3 | false | 1 | 0 | As far as I am aware there is not built-in tag to do this. Depending on the nature of the words you want (they aren't inside, or part of a for-loop - although even then you could just do this recursively) you could just do what you want in the views.py and pass the output as a variable to the template?
So you'd do your... | 1 | 1 | 0 | am looking for a django templatetag that will count words and substring a whole paragraph without chopping off words. Is there a built in function? I tried looking into the built-in function list at Django template documentation but couldn't find anything.
Please advice? | django templatetag | 0.066568 | 0 | 0 | 737 |
4,707,136 | 2011-01-16T18:19:00.000 | 3 | 0 | 0 | 0 | python,django,datetime,view | 4,707,215 | 1 | true | 1 | 0 | If you have a created timestamp on your model, then could you sort ascending by this field and grab the first value?
To do the differences between the dates, you may be able to use an aggregate function to find the highest and lowest date, but I am uncertain. Something along the following lines might work:
MyModel.obje... | 1 | 2 | 0 | Looking for a way in a Django view to find the oldest entry in the database. Then take that value and to a time since. There has to be a simple way to do this with writing a complicated query. | Django find oldest entry in database | 1.2 | 0 | 0 | 1,478 |
4,707,192 | 2011-01-16T18:27:00.000 | 7 | 0 | 0 | 0 | python,django,forms | 11,547,550 | 5 | false | 1 | 0 | NOTE: There are three questions here. For the first two questions, see the fuller answer by AndiDog. I'm only answering the third question here:
Q. What widget method is responsible for going from the user's input back to the data model?
A. The value_from_datadict method -- it's sort of the inverse of a widget's render... | 1 | 63 | 0 | I am having a difficult time finding documentation on how to write a custom widget.
My questions are:
If I build a custom widget, can it be used equivalently for the admin interface or for normal forms?
If I want to allow the user to edit a list of items, what widget should I subclass? What methods of the widget do I ... | Django: How to build a custom form widget? | 1 | 0 | 0 | 51,410 |
4,708,482 | 2011-01-16T22:20:00.000 | 0 | 1 | 1 | 0 | c++,python,frameworks | 4,708,502 | 6 | true | 0 | 1 | Personally I prefer Python, but profesionally, that is if you want a good job C++ is a better choice. | 4 | 3 | 0 | I am thinking about to learn new language or framework. Now I deal with C# and WPF, WCF, Winforms. I have some free time so I would like get new skills.
But I have dilema, start with some C++ framework (such as Platinum, Reason, Evocosm, ACF)
or try Python / python framework.
I you are on my place which possibility you... | Start with some C++ framework or python | 1.2 | 0 | 0 | 438 |
4,708,482 | 2011-01-16T22:20:00.000 | 1 | 1 | 1 | 0 | c++,python,frameworks | 4,708,519 | 6 | false | 0 | 1 | I recommend you to keep learning C++. Before you started looking for framework learn some popular search algorithm and try implement them. After that try implement some structures, like queues, list, stack, binary trees and some operation on them. Meanwhile play with I/O (for example, try write your stack to file and r... | 4 | 3 | 0 | I am thinking about to learn new language or framework. Now I deal with C# and WPF, WCF, Winforms. I have some free time so I would like get new skills.
But I have dilema, start with some C++ framework (such as Platinum, Reason, Evocosm, ACF)
or try Python / python framework.
I you are on my place which possibility you... | Start with some C++ framework or python | 0.033321 | 0 | 0 | 438 |
4,708,482 | 2011-01-16T22:20:00.000 | 0 | 1 | 1 | 0 | c++,python,frameworks | 4,708,899 | 6 | false | 0 | 1 | Well. Learning Python basics will take a week, and you will save the time spent in a year since it is such a good language for small hacks and scripts. So I suggest you learn it first.
Learning C++ well will take you five to ten years, so there is not the same immediate benefit :) | 4 | 3 | 0 | I am thinking about to learn new language or framework. Now I deal with C# and WPF, WCF, Winforms. I have some free time so I would like get new skills.
But I have dilema, start with some C++ framework (such as Platinum, Reason, Evocosm, ACF)
or try Python / python framework.
I you are on my place which possibility you... | Start with some C++ framework or python | 0 | 0 | 0 | 438 |
4,708,482 | 2011-01-16T22:20:00.000 | 0 | 1 | 1 | 0 | c++,python,frameworks | 4,708,606 | 6 | false | 0 | 1 | I'd pick C++ for the sole reason that it's nothing like the languages you already know, even though it shares some syntax. | 4 | 3 | 0 | I am thinking about to learn new language or framework. Now I deal with C# and WPF, WCF, Winforms. I have some free time so I would like get new skills.
But I have dilema, start with some C++ framework (such as Platinum, Reason, Evocosm, ACF)
or try Python / python framework.
I you are on my place which possibility you... | Start with some C++ framework or python | 0 | 0 | 0 | 438 |
4,709,652 | 2011-01-17T03:02:00.000 | 4 | 0 | 1 | 0 | python,regex,date | 51,464,236 | 11 | false | 0 | 0 | Using this regular expression you can validate different kinds of Date/Time samples, just a little change is needed.
^\d\d\d\d/(0?[1-9]|1[0-2])/(0?[1-9]|[12][0-9]|3[01]) (00|[0-9]|1[0-9]|2[0-3]):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9])$ -->validate this: 2018/7/12 13:00:00
for your format you cad change it to:
^(0?[1-9]|[... | 1 | 62 | 0 | What regular expression in Python do I use to match dates like this: "11/12/98"? | Python regex to match dates | 0.072599 | 0 | 0 | 172,412 |
4,709,968 | 2011-01-17T04:07:00.000 | 3 | 0 | 0 | 1 | python,c,unix | 4,709,984 | 4 | false | 0 | 0 | No portable API exists to do this in Unix. Most filesystems don't index files inside directories by their mtime (or ctime), so even if it did it probably wouldn't be any faster than doing it yourself. | 1 | 4 | 0 | I'm trying to find out the latest file in a huge filesystem. One way to do this is to go through all directories - one at a time, read its contents, select the latest file etc.
The obvious drawback is I have to get all the files in a specific directory. I was wondering whether there was a 'magic' call in Python [1] whi... | Find the most recent file in a directory without reading all the contents of it | 0.148885 | 0 | 0 | 1,636 |
4,710,067 | 2011-01-17T04:38:00.000 | 8 | 0 | 1 | 0 | python,file,input | 19,823,767 | 17 | false | 0 | 0 | The issue with reading lines in first pass and making changes (deleting specific lines) in the second pass is that if you file sizes are huge, you will run out of RAM. Instead, a better approach is to read lines, one by one, and write them into a separate file, eliminating the ones you don't need. I have run this appro... | 3 | 194 | 0 | Let's say I have a text file full of nicknames. How can I delete a specific nickname from this file, using Python? | How to delete a specific line in a file? | 1 | 0 | 0 | 550,264 |
4,710,067 | 2011-01-17T04:38:00.000 | -3 | 0 | 1 | 0 | python,file,input | 4,710,074 | 17 | false | 0 | 0 | Take the contents of the file, split it by newline into a tuple. Then, access your tuple's line number, join your result tuple, and overwrite to the file. | 3 | 194 | 0 | Let's say I have a text file full of nicknames. How can I delete a specific nickname from this file, using Python? | How to delete a specific line in a file? | -0.035279 | 0 | 0 | 550,264 |
4,710,067 | 2011-01-17T04:38:00.000 | 1 | 0 | 1 | 0 | python,file,input | 4,710,385 | 17 | false | 0 | 0 | In general, you can't; you have to write the whole file again (at least from the point of change to the end).
In some specific cases you can do better than this -
if all your data elements are the same length and in no specific order, and you know the offset of the one you want to get rid of, you could copy the last it... | 3 | 194 | 0 | Let's say I have a text file full of nicknames. How can I delete a specific nickname from this file, using Python? | How to delete a specific line in a file? | 0.011764 | 0 | 0 | 550,264 |
4,710,433 | 2011-01-17T06:07:00.000 | 16 | 0 | 1 | 0 | python | 4,710,649 | 2 | true | 0 | 0 | Many of the differences between threading and multiprocessing are not really Python-specific, and some differences are specific to a certain Python implementation.
For CPython, I would use the multiprocessing module in either fo the following cases:
I need to make use of multiple cores simultaneously for performance r... | 1 | 34 | 0 | What are some good guidelines to follow when deciding to use threads or multiprocessing when speaking in terms of efficiency and code clarity? | Python:When to use Threads vs. Multiprocessing | 1.2 | 0 | 0 | 9,661 |
4,710,483 | 2011-01-17T06:17:00.000 | 9 | 0 | 0 | 0 | python,scrapy | 14,401,562 | 9 | false | 1 | 0 | that would be:
export http_proxy=http://user:password@proxy:port | 1 | 50 | 0 | How do you utilize proxy support with the python web-scraping framework Scrapy? | Scrapy and proxies | 1 | 0 | 1 | 69,413 |
4,710,588 | 2011-01-17T06:37:00.000 | 1 | 1 | 0 | 0 | python,networking,module,import,centralized | 4,734,071 | 6 | false | 0 | 0 | How I ended up doing this:
Control Panel\All Control Panel Items\System >> Advanced >> Environment Variables >> System Variables >> New >> Name = PYTHONPATH, value = \server\scriptFolder
Thanks everyone for all the help :) | 2 | 4 | 0 | Is there a way to get python to read modules from a network?
We have many machines and it would be a too much effort to update each machine manually each time I change a module so I want python to get the modules from a location on the network.
Any ideas? | Importing module from network | 0.033321 | 0 | 1 | 10,613 |
4,710,588 | 2011-01-17T06:37:00.000 | 4 | 1 | 0 | 0 | python,networking,module,import,centralized | 4,710,633 | 6 | true | 0 | 0 | Mount your network location into your file-system and add that path to your PYTHONPATH. That way, Python on your local machine will be able to see the modules which are present in the remote location.
You cannot directly import from modules remotely, like specifying a js file in html. | 2 | 4 | 0 | Is there a way to get python to read modules from a network?
We have many machines and it would be a too much effort to update each machine manually each time I change a module so I want python to get the modules from a location on the network.
Any ideas? | Importing module from network | 1.2 | 0 | 1 | 10,613 |
4,710,621 | 2011-01-17T06:43:00.000 | 7 | 1 | 1 | 0 | python,unit-testing | 4,710,652 | 3 | false | 0 | 0 | Write methods that don't rely on other models or resources - if they need to access them, they should be passed in to the method. | 2 | 14 | 0 | Are there any guidelines for writing test-friendly Python code?
What I believe:
One method does one thing.
Don't use side-effects.
Any other suggestions? | Any tips on writing testing-friendly code? | 1 | 0 | 0 | 3,938 |
4,710,621 | 2011-01-17T06:43:00.000 | 6 | 1 | 1 | 0 | python,unit-testing | 50,113,761 | 3 | false | 0 | 0 | Alfred‘s answer is great, but I would add one thing for the questioner:
If you want to read a book, that is all about testing in Python using pytest, I suggest you to read „Python Testing with pytest: Simple, Rapid, Effective, and Scalable“ by Brian Okken. It’s perfect for what you want to do and it’s brand new (publi... | 2 | 14 | 0 | Are there any guidelines for writing test-friendly Python code?
What I believe:
One method does one thing.
Don't use side-effects.
Any other suggestions? | Any tips on writing testing-friendly code? | 1 | 0 | 0 | 3,938 |
4,711,488 | 2011-01-17T09:07:00.000 | 2 | 0 | 1 | 0 | python,vim,ide,editor | 4,712,051 | 2 | false | 0 | 0 | I didn't redefine varname in my Vim configuration, and it works good, but I have vim compiled with python.
Maybe this is the problem?
Do you have VIM version 7.x installed, compiled with Python support? To check for this, enter :python print “hello, world”
into VIM. If you see an error message like
E319: Sorry, the c... | 1 | 5 | 0 | I'm getting started with using VIM to program Python. I've run into some issues, hopefully someone can help me with this one.
The "gd" command is supposed to take you to the first place a variable is defined/used in the current function. From what I understand, it's the same as doing "[[" to go to the top of the functi... | VIM + Python - "gd" command not working properly | 0.197375 | 0 | 0 | 1,653 |
4,711,544 | 2011-01-17T09:15:00.000 | 1 | 0 | 0 | 0 | php,python,google-app-engine | 4,718,973 | 2 | false | 1 | 0 | Quercus on App Engine runs on the Java runtime, while Python runs on, er, the Python runtime. While you can run one app with multiple runtimes, they have to be different major versions, which means that communication between them will be awkward - you'd have to make URLFetches between them.
I think you'll find it's far... | 1 | 1 | 0 | I need to write a small addition to a Python+Django based website, hosted on Google Apps. Trouble is that I don't have any experience with Python.
The addition is pretty straight forward, it requires little database access
So thought of 2 possible solution's:
Quickly dive into Python and get it done with Python.
Run ... | PHP part in Python based website | 0.099668 | 0 | 0 | 171 |
4,712,143 | 2011-01-17T10:32:00.000 | 2 | 0 | 0 | 1 | python,google-app-engine | 4,718,951 | 1 | false | 1 | 0 | The Datastore is the only interface to the underlying storage on App Engine. You should be able to use any valid UTF-8 string as a kind name, key name, or property name, however. | 1 | 1 | 0 | According to the Bigtable original article, a column key of a Bigtable is named using "family:qualifier" syntax where column family names must be printable but qualifiers may be arbitrary strings. In the application I am working on, I would like to specify the qualifiers using Chinese words (or phrase). Is it possible ... | Is there an API of Google App Engine provided to better configure the Bigtable besides Datastore? | 0.379949 | 1 | 0 | 134 |
4,712,705 | 2011-01-17T11:39:00.000 | 2 | 0 | 0 | 0 | python,pyqt4 | 4,712,851 | 2 | true | 0 | 1 | Yes. Use layout objects (such as QHBoxLayout or QGridLayout) to organize your widgets inside, and set the widgets' resize modes accordingly. Note that standard Qt-supplied widgets support resizing by default. | 2 | 1 | 0 | I have a main window and I want that when I maximize it the widgets inside it should automatically be resized ....
Is there any way I can do that ???? | PyQt4 - Maximize window along with inside widgets | 1.2 | 0 | 0 | 1,134 |
4,712,705 | 2011-01-17T11:39:00.000 | 1 | 0 | 0 | 0 | python,pyqt4 | 4,713,335 | 2 | false | 0 | 1 | If you want to save you a lot of work, don't hand-code the ui. Use Qt Creator to create a ui file and then load this file dynamically using PyQt4.uic module. There is also a "static" approach that generates python code from Qt Creator ui files. | 2 | 1 | 0 | I have a main window and I want that when I maximize it the widgets inside it should automatically be resized ....
Is there any way I can do that ???? | PyQt4 - Maximize window along with inside widgets | 0.099668 | 0 | 0 | 1,134 |
4,713,293 | 2011-01-17T12:46:00.000 | 1 | 0 | 0 | 0 | .net,python,django,single-sign-on | 4,718,045 | 2 | false | 1 | 0 | We implement OpenID at our company in a way that the only trusted openid provider is ourself. Because of this, the user doesn't have to use anything special to log into a website. They just click a login button and it pops them over to the main login site. If they've already logged in then it instantly sends them back ... | 1 | 2 | 0 | We have heterogeneous systems consisting of Django and .Net web applications. I primarily work on Django.Is it possible to integrate these heterogeneous systems using Single Sign On ?
Any ideas in this regard would be truly appreciated.
Thank You | Integrating Django and .Net applications using Single Sign On (SSO) | 0.099668 | 0 | 0 | 919 |
4,713,589 | 2011-01-17T13:20:00.000 | 0 | 0 | 1 | 1 | python,windows | 4,715,102 | 3 | false | 0 | 0 | Can you copy files that are open in Windows? I have a vague memory that you can't, and the file will be open while you execute it.
Is it really being copied? It doesn't exist there before copying? Did it copy the whole file? | 3 | 4 | 0 | I wrote a program that will copy a file called a.exe to C:/Windows/, then I pack it to exe with PyInstaller, and rename the exe file to a.exe. When I run the exe file, it output IOError [Errno 13] Permisson denied: 'C:/Windows/a.exe', but the file a.exe was copied to the directory C:/Windows. Then I ran it as the Admin... | "IOError [Errno 13] Permisson denied" when copy a file on Windows | 0 | 0 | 0 | 2,669 |
4,713,589 | 2011-01-17T13:20:00.000 | 4 | 0 | 1 | 1 | python,windows | 4,713,887 | 3 | true | 0 | 0 | Check if a.exe has read-only attribute. shutil.copy raises "Permission denied" error when it is called to overwrite existing file with read-only attribute set | 3 | 4 | 0 | I wrote a program that will copy a file called a.exe to C:/Windows/, then I pack it to exe with PyInstaller, and rename the exe file to a.exe. When I run the exe file, it output IOError [Errno 13] Permisson denied: 'C:/Windows/a.exe', but the file a.exe was copied to the directory C:/Windows. Then I ran it as the Admin... | "IOError [Errno 13] Permisson denied" when copy a file on Windows | 1.2 | 0 | 0 | 2,669 |
4,713,589 | 2011-01-17T13:20:00.000 | 0 | 0 | 1 | 1 | python,windows | 4,713,881 | 3 | false | 0 | 0 | Apparently you're trying to execute a file that moves itself to a different place ... I guess that cannot work. | 3 | 4 | 0 | I wrote a program that will copy a file called a.exe to C:/Windows/, then I pack it to exe with PyInstaller, and rename the exe file to a.exe. When I run the exe file, it output IOError [Errno 13] Permisson denied: 'C:/Windows/a.exe', but the file a.exe was copied to the directory C:/Windows. Then I ran it as the Admin... | "IOError [Errno 13] Permisson denied" when copy a file on Windows | 0 | 0 | 0 | 2,669 |
4,714,136 | 2011-01-17T14:14:00.000 | 59 | 0 | 1 | 0 | python,virtual-functions | 4,714,147 | 6 | false | 0 | 0 | Python methods are always virtual. | 1 | 102 | 0 | I know virtual methods from PHP or Java.
How can they be implemented in Python?
Or have I to define an empty method in an abstract class and override it? | How to implement virtual methods in Python? | 1 | 0 | 0 | 118,006 |
4,715,357 | 2011-01-17T16:21:00.000 | 0 | 0 | 1 | 0 | python,twisted,zope | 4,715,775 | 2 | false | 0 | 0 | If you install twisted with pip install or easy_install it will download and install zope.install for you as well. | 1 | 3 | 0 | I noticed that Twisted has a dependency on Zope. I found that when I tried to install Zope, after running, ./configure it tells me I need to use python2.4 (not python 2.5+ which I would like to be using).
However, I have seen some tutorials and guides that suggested using python 2.5 for Twisted. So I'm just generally c... | What version of python can I use with Twisted/Zope? | 0 | 0 | 0 | 1,584 |
4,716,689 | 2011-01-17T18:49:00.000 | 2 | 1 | 0 | 0 | php,python,comparison,pylons,web-frameworks | 4,721,004 | 3 | false | 0 | 0 | Being primarily a Python developer, and having used Pylons, TurboGears, and Django, I would whole heartedly, 100% recommend Kohana 3.x. To be completely honest I am not a huge fan of PHP, even though it is the language of choice at my current employer. Given the choice I would use Python and Pylons. But, using Kohan... | 1 | 5 | 0 | What is most similar PHP framework to Pylons?
I mean mostly ideology of programming. | PHP framework similar to Python Pylons | 0.132549 | 0 | 0 | 755 |
4,717,568 | 2011-01-17T20:31:00.000 | 3 | 0 | 0 | 1 | python,google-app-engine,blob,blobstore | 4,718,754 | 4 | true | 1 | 0 | I think storing it in the blobstore via a form post is your best currently-available option. We have plans to implement programmatic blobstore writing, but it's not ready quite yet. | 2 | 2 | 0 | Presently I have a GAE app that does some offline processing (backs up a user's data), and generates a file that's somewhere in the neighbourhood of 10 - 100 MB. I'm not sure of the best way to serve this file to the user. The two options I'm considering are:
Adding some code to the offline processing code that 'spo... | Serving large generated files using Google App Engine? | 1.2 | 0 | 0 | 793 |
4,717,568 | 2011-01-17T20:31:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine,blob,blobstore | 4,717,660 | 4 | false | 1 | 0 | There is some approach you are overlooking, although I'm not sure whether it is that much better:
Split the data into many 1MB chunks, and have individual requests to transfer the chunks.
This would require cooperation from the outside applications to actually retrieve the data in chunks; you might want to use the HTTP... | 2 | 2 | 0 | Presently I have a GAE app that does some offline processing (backs up a user's data), and generates a file that's somewhere in the neighbourhood of 10 - 100 MB. I'm not sure of the best way to serve this file to the user. The two options I'm considering are:
Adding some code to the offline processing code that 'spo... | Serving large generated files using Google App Engine? | 0 | 0 | 0 | 793 |
4,718,122 | 2011-01-17T21:31:00.000 | 0 | 0 | 1 | 1 | python,vim | 37,509,169 | 13 | false | 0 | 0 | After trying all answers in this thread without success, the following worked for me (Win10, Python 2.7 32bit, gvim 7.4 32bit):
Reinvoke the Python Installer, select Change Python
Select the Option Add Python to Path, which is off by default
After the installer is done, restart your machine | 7 | 54 | 0 | I'm trying to get Python support in gVim on Windows. Is there a way to accomplish that?
I'm using:
Windows XP SP3
gVim v. 7.3
Python 2.7.13 (ActivePython through Windows Installer binaries) | How to enable Python support in gVim on Windows? | 0 | 0 | 0 | 58,355 |
4,718,122 | 2011-01-17T21:31:00.000 | 0 | 0 | 1 | 1 | python,vim | 35,977,819 | 13 | false | 0 | 0 | Download the one called "OLE GUI executable" | 7 | 54 | 0 | I'm trying to get Python support in gVim on Windows. Is there a way to accomplish that?
I'm using:
Windows XP SP3
gVim v. 7.3
Python 2.7.13 (ActivePython through Windows Installer binaries) | How to enable Python support in gVim on Windows? | 0 | 0 | 0 | 58,355 |
4,718,122 | 2011-01-17T21:31:00.000 | 0 | 0 | 1 | 1 | python,vim | 35,925,222 | 13 | false | 0 | 0 | After reading the above, I can confirm that on Win8.1 it does matter the order you install them (least for me it did). I had 32bit VIM 7.4 installed for a few months, then tried adding Python and couldn't do it. Left Python 2.7.9 installed and uninstalled/reinstalled VIM and now it works. | 7 | 54 | 0 | I'm trying to get Python support in gVim on Windows. Is there a way to accomplish that?
I'm using:
Windows XP SP3
gVim v. 7.3
Python 2.7.13 (ActivePython through Windows Installer binaries) | How to enable Python support in gVim on Windows? | 0 | 0 | 0 | 58,355 |
4,718,122 | 2011-01-17T21:31:00.000 | 0 | 0 | 1 | 1 | python,vim | 25,298,763 | 13 | false | 0 | 0 | When I typed :version, it revealed that my Vim was not compiled with Python. Perhaps because I did not have Python (32-bit?) at the time.
I did install 32-bit Python as suggested, but reinstalling Vim seemed necessary. | 7 | 54 | 0 | I'm trying to get Python support in gVim on Windows. Is there a way to accomplish that?
I'm using:
Windows XP SP3
gVim v. 7.3
Python 2.7.13 (ActivePython through Windows Installer binaries) | How to enable Python support in gVim on Windows? | 0 | 0 | 0 | 58,355 |
4,718,122 | 2011-01-17T21:31:00.000 | 43 | 0 | 1 | 1 | python,vim | 17,963,884 | 13 | false | 0 | 0 | I had the same issue, but on Windows 7, and a restart didn't fix it.
I already had gVim 7.3 installed. At the time of writing the current Python version was 3.3, so I installed that. But :has ("python") and :has ("python3") still returned 0.
After much trial and error, I determined that:
If gVim is 32-bit, and it usu... | 7 | 54 | 0 | I'm trying to get Python support in gVim on Windows. Is there a way to accomplish that?
I'm using:
Windows XP SP3
gVim v. 7.3
Python 2.7.13 (ActivePython through Windows Installer binaries) | How to enable Python support in gVim on Windows? | 1 | 0 | 0 | 58,355 |
4,718,122 | 2011-01-17T21:31:00.000 | 27 | 0 | 1 | 1 | python,vim | 12,643,966 | 13 | false | 0 | 0 | I encountered this problem on Windows 7 64-bit. I realized I was using 64-bit Python 2.7.3 and 32-bit vim 7.3-46. I reinstalled both as 32-bit versions and then restarted the computer. Now it works. | 7 | 54 | 0 | I'm trying to get Python support in gVim on Windows. Is there a way to accomplish that?
I'm using:
Windows XP SP3
gVim v. 7.3
Python 2.7.13 (ActivePython through Windows Installer binaries) | How to enable Python support in gVim on Windows? | 1 | 0 | 0 | 58,355 |
4,718,122 | 2011-01-17T21:31:00.000 | 1 | 0 | 1 | 1 | python,vim | 31,216,863 | 13 | false | 0 | 0 | I had a similar problem. I've been enjoying vim's omni-completion feature for some years,using Windows XP, Python 2.7, gVim 7. Recently I moved to a new PC running Windows 8.1. I installed gVim and the plugins I like, then tried out everything. Omni-completion gave an error, saying I needed the version of vim compiled ... | 7 | 54 | 0 | I'm trying to get Python support in gVim on Windows. Is there a way to accomplish that?
I'm using:
Windows XP SP3
gVim v. 7.3
Python 2.7.13 (ActivePython through Windows Installer binaries) | How to enable Python support in gVim on Windows? | 0.015383 | 0 | 0 | 58,355 |
4,718,580 | 2011-01-17T22:22:00.000 | 1 | 0 | 0 | 0 | python,django,mongodb,mongoengine | 10,204,815 | 6 | false | 1 | 0 | I've used mongoengine with django but you need to create a file like mongo_models.py for example. In that file you define your Mongo documents. You then create forms to match each Mongo document. Each form has a save method which inserts or updates whats stored in Mongo. Django forms are designed to plug into any data ... | 5 | 2 | 0 | I want to try Mongodb w/ mongoengine. I'm new to Django and databases and I'm having a fit with Foreign Keys, Joins, Circular Imports (you name it). I know I could eventually work through these issues but Mongo just seems like a simpler solution for what I am doing. My question is I'm using a lot of pluggable apps (... | Converting Django project from MySQL to Mongo, any major pitfalls? | 0.033321 | 1 | 0 | 2,780 |
4,718,580 | 2011-01-17T22:22:00.000 | 9 | 0 | 0 | 0 | python,django,mongodb,mongoengine | 4,718,924 | 6 | true | 1 | 0 | There's no reason why you can't use one of the standard RDBMSs for all the standard Django apps, and then Mongo for your app. You'll just have to replace all the standard ways of processing things from the Django ORM with doing it the Mongo way.
So you can keep urls.py and its neat pattern matching, views will still ge... | 5 | 2 | 0 | I want to try Mongodb w/ mongoengine. I'm new to Django and databases and I'm having a fit with Foreign Keys, Joins, Circular Imports (you name it). I know I could eventually work through these issues but Mongo just seems like a simpler solution for what I am doing. My question is I'm using a lot of pluggable apps (... | Converting Django project from MySQL to Mongo, any major pitfalls? | 1.2 | 1 | 0 | 2,780 |
4,718,580 | 2011-01-17T22:22:00.000 | -1 | 0 | 0 | 0 | python,django,mongodb,mongoengine | 4,719,398 | 6 | false | 1 | 0 | Primary pitfall (for me): no JOINs! | 5 | 2 | 0 | I want to try Mongodb w/ mongoengine. I'm new to Django and databases and I'm having a fit with Foreign Keys, Joins, Circular Imports (you name it). I know I could eventually work through these issues but Mongo just seems like a simpler solution for what I am doing. My question is I'm using a lot of pluggable apps (... | Converting Django project from MySQL to Mongo, any major pitfalls? | -0.033321 | 1 | 0 | 2,780 |
4,718,580 | 2011-01-17T22:22:00.000 | 0 | 0 | 0 | 0 | python,django,mongodb,mongoengine | 4,719,167 | 6 | false | 1 | 0 | Upfront, it won't work for any existing Django app that ships it's models. There's no backend for storing Django's Model data in mongodb or other NoSQL storages at the moment and, database backends aside, models themselves are somewhat of a moot point, because once you get in to using someones app (django.contrib apps ... | 5 | 2 | 0 | I want to try Mongodb w/ mongoengine. I'm new to Django and databases and I'm having a fit with Foreign Keys, Joins, Circular Imports (you name it). I know I could eventually work through these issues but Mongo just seems like a simpler solution for what I am doing. My question is I'm using a lot of pluggable apps (... | Converting Django project from MySQL to Mongo, any major pitfalls? | 0 | 1 | 0 | 2,780 |
4,718,580 | 2011-01-17T22:22:00.000 | 0 | 0 | 0 | 0 | python,django,mongodb,mongoengine | 4,728,500 | 6 | false | 1 | 0 | I have recently tried this (although without Mongoengine). There are a huge number of pitfalls, IMHO:
No admin interface.
No Auth django.contrib.auth relies on the DB interface.
Many things rely on django.contrib.auth.User. For example, the RequestContext class. This is a huge hindrance.
No Registration (Relies ... | 5 | 2 | 0 | I want to try Mongodb w/ mongoengine. I'm new to Django and databases and I'm having a fit with Foreign Keys, Joins, Circular Imports (you name it). I know I could eventually work through these issues but Mongo just seems like a simpler solution for what I am doing. My question is I'm using a lot of pluggable apps (... | Converting Django project from MySQL to Mongo, any major pitfalls? | 0 | 1 | 0 | 2,780 |
4,718,588 | 2011-01-17T22:23:00.000 | 0 | 1 | 0 | 1 | python,progress-bar,tar | 4,718,870 | 5 | false | 0 | 0 | How are you adding files to the tar file? Is is through "add" with recursive=True? You could build the list of files yourself and call "add" one-by-one, showing the progress as you go. If you're building from a stream/file then it looks like you could wrap that fileobj to see the read status and pass that into addfile.... | 1 | 4 | 0 | Is there any library to show progress when adding files to a tar archive in python or alternativly would be be possible to extend the functionality of the tarfile module to do this?
In an ideal world I would like to show the overall progress of the tar creation as well as an ETA as to when it will be complete.
Any hel... | Python tarfile progress | 0 | 0 | 0 | 3,242 |
4,719,700 | 2011-01-18T01:29:00.000 | 6 | 0 | 0 | 1 | python,google-app-engine | 4,719,811 | 2 | false | 1 | 0 | You're right, there's no built in ReferenceListProperty. It'd be possible to write one yourself - custom Property subclasses are generally fairly easy - but getting it right is harder than you'd think, when it comes to deferencing and caching a list of references.
You can use a db.ListProperty(db.Key), however, which a... | 1 | 18 | 0 | In Google App Engine, there is such a thing as a ListProperty that allows you to hold a list (array) of items. You may also specify the type of the item being held, for instance string, integer, or whatever.
Google App Engine also allows you to have a ReferenceProperty. A ReferenceProperty "contains" a reference to an... | List of References in Google App Engine for Python | 1 | 0 | 0 | 2,691 |
4,719,836 | 2011-01-18T02:01:00.000 | 1 | 0 | 0 | 0 | python,sql,django,sqlite | 4,724,461 | 4 | false | 0 | 0 | Use a parameterized query
and
Use a transaction. | 2 | 6 | 0 | I have a .sql file containing thousands of individual insert statements. It takes forever to do them all. I am trying to figure out a way to do this more efficiently. In python the sqlite3 library can't do things like ".read" or ".import" but executescript is too slow for that many inserts.
I installed the sqlite3... | Python and sqlite3 - adding thousands of rows | 0.049958 | 1 | 0 | 1,859 |
4,719,836 | 2011-01-18T02:01:00.000 | 2 | 0 | 0 | 0 | python,sql,django,sqlite | 13,787,939 | 4 | false | 0 | 0 | In addition to running the queries in bulk inside a single transaction, also try VACUUM and ANALYZEing the database file. It helped a similar problem of mine. | 2 | 6 | 0 | I have a .sql file containing thousands of individual insert statements. It takes forever to do them all. I am trying to figure out a way to do this more efficiently. In python the sqlite3 library can't do things like ".read" or ".import" but executescript is too slow for that many inserts.
I installed the sqlite3... | Python and sqlite3 - adding thousands of rows | 0.099668 | 1 | 0 | 1,859 |
4,720,073 | 2011-01-18T02:52:00.000 | 1 | 0 | 1 | 0 | python,loops,time,permutation,while-loop | 4,720,112 | 3 | false | 0 | 0 | There's a very hacky way to do this by using time.asctime(). You store the asctime before entering the while loop and somewhere in the loop itself. Calculate the time difference between the stored time and the current time and if that difference is 10 seconds, then update the stored time to the current time and print t... | 1 | 7 | 0 | i have a loop that runs for up to a few hours at a time. how could I have it tell me how long it has been at a set interval?
just a generic...question
EDIT: it's a while loop that runs permutations, so can i have it print the time running every 10 seconds? | python -> time a while loop has been running | 0.066568 | 0 | 0 | 9,699 |
4,720,342 | 2011-01-18T03:55:00.000 | 2 | 0 | 0 | 0 | javascript,python,urllib2 | 4,721,276 | 1 | true | 1 | 0 | No, you'd need some sort of JS interpreter for that. There might be Python-Browser integrations to help parsing this kind of page. | 1 | 5 | 0 | I am coding a HTML scraper which gets values from a table on a website. I also need to grab the URL of an image, but the problem is this image is dynamically generated via javascript - and when i get contents of the website via urllib, the Javascript does not run or show in the resulting HTML.
Is there any way to enabl... | Python: Processing Javascript with urllib2? | 1.2 | 0 | 1 | 5,105 |
4,720,363 | 2011-01-18T04:00:00.000 | 0 | 0 | 1 | 0 | python,time,brute-force,combinations | 4,720,383 | 3 | false | 0 | 0 | How long as in time?
from time import time on top, at the start of the program do start = time(). at the nameerror part do print time() - start
please be a bit more specific | 1 | 1 | 0 | i decided to write a brute force function to show people how vulnerable a password is. right now, i can show them the list it goes through to find the password, but how do i tell them how long it took?
here's the code:
#!/usr/bin/python
import itertools
lower_a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k... | python -> password safety program | 0 | 0 | 0 | 521 |
4,721,285 | 2011-01-18T06:56:00.000 | 0 | 0 | 1 | 0 | python,multithreading,locking,memcached | 4,721,403 | 2 | false | 0 | 0 | It's a pretty big jump to go from a separate, controlled process space to shared memory and some kind of mutex.
If your problem is latency introduced by fifty round trips to process something, why don't you use multiget and always just do one? | 1 | 2 | 0 | So I have a program that is multi threaded, in a nutshell it downloads web pages, processes them and stores the results. The rules and whatnot it uses to process the web pages are stored within a database. Initially the database was absolutely hammered (1-50 requests to the database were needed to process each web page... | Python memory array shared among multiple threads (think memcached in process space) | 0 | 0 | 0 | 2,136 |
4,722,072 | 2011-01-18T08:48:00.000 | 5 | 1 | 1 | 1 | python | 4,722,121 | 1 | true | 0 | 0 | I see you are talking about the source bundle of Python, which includes Tools/Scripts, a set of helpful scripts for working with Python Source. It should be noted that they are not a part of Python Standard Library and installers are not obliged to bundle them with their distribution, for e.g in Ubuntu, I don't find it... | 1 | 3 | 0 | Python's installation comes with some handy tools, located under
$YOUR_PYTHON/Tools/Scripts. Is there a platform-independent way to find out where on a system they are located? I want to use ftpmirror.py as part of a shell script. | Python: detecting install location of python tools | 1.2 | 0 | 0 | 1,415 |
4,726,501 | 2011-01-18T16:35:00.000 | 2 | 0 | 1 | 0 | python,oop,concept | 4,726,576 | 5 | false | 0 | 0 | You don't store each object with a variable name. Variable names are for the convenience of a programmer.
If you want a collection of objects, you use just that - a collection. Use either a list or a dictionary containing object instances, referenced by index or key respectively.
So for example, if each employee has an... | 2 | 3 | 0 | I have a problem grasping the OOP concept when it comes to creating objects during runtime. All the educational code that I have looked into yet defines specific variables e.g. 'Bob' and assigns them to a new object instance. Bob = Person()
What I have trouble understanding now is how I would design a model that create... | Creating objects during runtime in Python | 0.07983 | 0 | 0 | 5,378 |
4,726,501 | 2011-01-18T16:35:00.000 | 0 | 0 | 1 | 0 | python,oop,concept | 4,726,829 | 5 | false | 0 | 0 | You would never do Bob = Person() in a real program. Any example that shows that is arguably a bad example; it is essentially hard-coding. You will more often (in real code) do person = Person(id, name) or something like that, to construct the object using data you obtained elsewhere (read from a file, received interac... | 2 | 3 | 0 | I have a problem grasping the OOP concept when it comes to creating objects during runtime. All the educational code that I have looked into yet defines specific variables e.g. 'Bob' and assigns them to a new object instance. Bob = Person()
What I have trouble understanding now is how I would design a model that create... | Creating objects during runtime in Python | 0 | 0 | 0 | 5,378 |
4,727,351 | 2011-01-18T17:57:00.000 | 15 | 1 | 1 | 0 | python | 4,727,418 | 2 | true | 0 | 0 | The main implementation is written in C, and that's compiled to machine code (i.e. assembly made readable for the CPU). So writing it assembly is certainly possible, and if it's possible for a compiler, it's possible for humans - in theory. In practice, it is not even remotely practical. Not only asm is even more low-l... | 2 | 4 | 0 | Am just being curious but I would like to know whether python can be implemented in assembly and if not why has it not been done to help for speed issues. forgive my naivete in matters of programming languages. | python implemented in assembly | 1.2 | 0 | 0 | 1,879 |
4,727,351 | 2011-01-18T17:57:00.000 | 6 | 1 | 1 | 0 | python | 4,727,381 | 2 | false | 0 | 0 | Native code isn't a magic make-it-go-faster operation. The language semantics really dictate quite a bit about how fast (or not) a language is. (For instance, erlang compiled to native code via Hipe is still fairly slow). | 2 | 4 | 0 | Am just being curious but I would like to know whether python can be implemented in assembly and if not why has it not been done to help for speed issues. forgive my naivete in matters of programming languages. | python implemented in assembly | 1 | 0 | 0 | 1,879 |
4,728,073 | 2011-01-18T19:19:00.000 | 11 | 0 | 1 | 0 | python,expression | 48,078,456 | 16 | false | 0 | 0 | An expression is a statement that returns a value. So if it can appear on the right side of an assignment, or as a parameter to a method call, it is an expression.
Some code can be both an expression or a statement, depending on the context. The language may have a means to differentiate between the two when they are... | 5 | 416 | 0 | In Python, what is the difference between expressions and statements? | What is the difference between an expression and a statement in Python? | 1 | 0 | 0 | 248,148 |
4,728,073 | 2011-01-18T19:19:00.000 | 0 | 0 | 1 | 0 | python,expression | 72,316,117 | 16 | false | 0 | 0 | Think of statements as consecutive actions or instructions that your program executes. So, value assignments, if clauses, together with for and while loops, are all statements. Function and class definitions are statements, too.
Think of expressions as anything that can be put into an if clause. Typical examples of exp... | 5 | 416 | 0 | In Python, what is the difference between expressions and statements? | What is the difference between an expression and a statement in Python? | 0 | 0 | 0 | 248,148 |
4,728,073 | 2011-01-18T19:19:00.000 | 5 | 0 | 1 | 0 | python,expression | 64,891,088 | 16 | false | 0 | 0 | An expression translates to a value.
A statement consumes a value* to produce a result**.
*That includes an empty value, like: print() or pop().
**This result can be any action that changes something; e.g. changes the memory ( x = 1) or changes something on the screen ( print("x") ).
A few notes:
Since a statement c... | 5 | 416 | 0 | In Python, what is the difference between expressions and statements? | What is the difference between an expression and a statement in Python? | 0.062419 | 0 | 0 | 248,148 |
4,728,073 | 2011-01-18T19:19:00.000 | 3 | 0 | 1 | 0 | python,expression | 59,512,195 | 16 | false | 0 | 0 | Statements before could change the state of our Python program: create or update variables, define function, etc.
And expressions just return some value can't change the global state or local state in a function.
But now we got :=, it's an alien! | 5 | 416 | 0 | In Python, what is the difference between expressions and statements? | What is the difference between an expression and a statement in Python? | 0.037482 | 0 | 0 | 248,148 |
4,728,073 | 2011-01-18T19:19:00.000 | 2 | 0 | 1 | 0 | python,expression | 45,828,442 | 16 | false | 0 | 0 | Expressions:
Expressions are formed by combining objects and operators.
An expression has a value, which has a type.
Syntax for a simple expression:<object><operator><object>
2.0 + 3 is an expression which evaluates to 5.0 and has a type float associated with it.
Statements
Statements are composed of expression(s). I... | 5 | 416 | 0 | In Python, what is the difference between expressions and statements? | What is the difference between an expression and a statement in Python? | 0.024995 | 0 | 0 | 248,148 |
4,728,983 | 2011-01-18T21:03:00.000 | 0 | 0 | 0 | 0 | python,mysql,django | 4,733,618 | 1 | false | 1 | 0 | You haven't provided much details so I'm guessing that you mean that you have a form and it doesn't have required=False set for the BooleanField. | 1 | 0 | 0 | DJango: 1.24
DB: MySQL
Column Type: Bit
Code: models.BooleanField(db_column='InStock')
The checkbox always shows checked no matter what the value is (1 or 0). The value gets saved correctly but when it renders the edit page, it always checked.
Any pointers? | Django's BooleanField showing incorrect value in edit mode | 0 | 0 | 0 | 286 |
4,729,361 | 2011-01-18T21:40:00.000 | 2 | 0 | 0 | 0 | python,database,sqlalchemy,pylons,connection-pooling | 4,729,629 | 1 | false | 0 | 0 | I think it's reasonable to require one connection per concurrent activity, and it's reasonable to assume that concurrent HTTP requests are concurrently executed.
Now, the number of concurrent HTTP requests you want to process should scale with a) the load on your server, and b) the number of CPUs you have available. If... | 1 | 3 | 0 | At my organization, PostgreSQL databases are created with a 20-connection limit as a matter of policy. This tends to interact poorly when multiple applications are in play that use connection pools, since many of those open up their full suite of connections and hold them idle.
As soon as there are more than a couple o... | How can I determine what my database's connection limits should be? | 0.379949 | 1 | 0 | 303 |
4,730,082 | 2011-01-18T23:06:00.000 | 1 | 0 | 0 | 0 | java,python,xml,serialization | 4,730,212 | 4 | true | 1 | 0 | Since Java and Python objects are so different in themselves, it's almost impossible to do this, unless you on both sides restrict the types allowed and such things.
And in that case, I'd recommend you use JSON, which is a nice interoperability format, even though it's not XML.
Otherwise you could easily write a librar... | 1 | 1 | 0 | I have been searching for an xml serialization library that can serialize and deserialize an (Java/Python) object into xml and back. I am using XStream right now for Java. If XStream had a python version to deserialize from xml generated by Xstream that would have done it for me. Thrift or such other libraries is not g... | XML serialization library interoperability between Java and Python | 1.2 | 0 | 1 | 1,140 |
4,730,785 | 2011-01-19T01:08:00.000 | 1 | 0 | 0 | 0 | python,menu,cross-platform,wxpython,menubar | 4,763,966 | 1 | false | 0 | 1 | If the native menubar doesn't support it, then wxPython probably won't either. There is a pure Python implementation of the menubar though. It's called FlatMenu. I would try that. If it doesn't work, at least you can hack it or submit a patch in Python code rather than trying to figure out the C++ for fixing wxWidgets. | 1 | 2 | 0 | I'm trying to create a menu bar in wxPython 2.8.11.0 and Python 2.7 where most of the menus are left aligned (as normal) but one is - ideally - right aligned, or at least separated in some way from the rest.
Is this possible?
EDIT: This needs to be a cross-platform solution. | Is it possible to align a menu to the right of the menu bar using wxPython? | 0.197375 | 0 | 0 | 608 |
4,731,104 | 2011-01-19T02:06:00.000 | 11 | 0 | 1 | 0 | python,regex,perl,optimization,analysis | 6,631,538 | 3 | false | 0 | 0 | Note that it depends on the engine. While regex theory is based on straight automata theory, most of the engines are not strict translations of those theories. For this reason, for instance, some engines incur in exponential time while strict NFA processing would not. | 1 | 49 | 0 | Are there any tools that will take a particular regular expression and return the worst case scenario in terms of the number of operations required for a certain number of characters that the regular expression is matched against?
So for example, given a (f|a)oo.*[ ]baz, how many steps might the engine possibly go thou... | Worst Case Analysis for Regular Expressions | 1 | 0 | 0 | 3,086 |
4,731,352 | 2011-01-19T03:00:00.000 | 0 | 0 | 0 | 0 | python,django,django-models,django-settings,django-fixtures | 4,731,825 | 2 | false | 1 | 0 | The easiest way is to use manage.py testserver [fixture ...]
If this is a staging (rather than dev) deployment, though, you may not want to use django's builtin server. In that case, a quick (if hacky) way of doing what you're after is to have the fixtures in an app (called, for example, "undeployed") that is only inst... | 1 | 2 | 0 | I have an initial_data fixture that I want to load everytime except for production. I already have different settings file for production and non-production deployments.
Any suggestions on how to accomplish this?
Clarification: I do not want test fixtures. Basically, I just need the fixture to be loaded based on a sett... | Have different initial_data fixtures for different stages (testing v. production) | 0 | 0 | 0 | 490 |
4,731,419 | 2011-01-19T03:16:00.000 | 3 | 1 | 0 | 0 | python,django,email,schedule | 4,731,583 | 5 | false | 1 | 0 | I would set up a cron job which could handle everything you want to do... | 2 | 2 | 0 | I want to schedule an email to be sent to a user upon a specific action.
However, if the user takes another action I want to cancel that email and have it not send.
How would I do that in django or python? | How can I schedule an email to be sent at some point in the future in django? | 0.119427 | 0 | 0 | 5,173 |
4,731,419 | 2011-01-19T03:16:00.000 | 0 | 1 | 0 | 0 | python,django,email,schedule | 4,741,503 | 5 | false | 1 | 0 | You said that you want to do it through Python or Django, but it seems as though something else will need to be involved. Considering you are on a shared host, there is a chance installing other packages could also be a problem.
Another possible solution could be something like this:
Use a javascript framework which ca... | 2 | 2 | 0 | I want to schedule an email to be sent to a user upon a specific action.
However, if the user takes another action I want to cancel that email and have it not send.
How would I do that in django or python? | How can I schedule an email to be sent at some point in the future in django? | 0 | 0 | 0 | 5,173 |
4,732,230 | 2011-01-19T06:03:00.000 | 2 | 1 | 0 | 1 | python,facebook,chat,xmpppy | 5,268,496 | 2 | false | 0 | 0 | I also started the same project, and was trapped into same problem. I found the solution too. You have to write the UserName of facebook (Hence You must opt one Username) and that too in small Caps. This is the most important part. Most probably you too like me would not be writing it in small Caps. | 1 | 3 | 0 | I'm trying to create a very simple script that uses python's xmpppy to send a message over facebook chat.
import xmpp
FACEBOOK_ID = "username@chat.facebook.com"
PASS = "password"
SERVER = "chat.facebook.com"
jid=xmpp.protocol.JID(FACEBOOK_ID)
C=xmpp.Client(jid.getDomain(),debug=[])
if not C.connect((SERVER,5222)):
... | xmpppy and Facebook Chat Integration | 0.197375 | 0 | 1 | 2,814 |
4,733,252 | 2011-01-19T08:42:00.000 | 3 | 0 | 1 | 0 | python,activepython | 13,039,769 | 5 | false | 0 | 0 | ActiveState usually only provides the latest versions of their packages for free, if you need an older version for whatever reason you will have to sign up for one of their paid accounts. Python.org seems to have all their old versions available for download. | 4 | 34 | 0 | I am new to Python. I am supposed to launch an application and perform some tasks on the application from Python.
I found Python from python.org and ActivePython from activestate.com.
What is the difference between them? Which should I install? | What is the difference between ActivePython and Python? | 0.119427 | 0 | 0 | 22,486 |
4,733,252 | 2011-01-19T08:42:00.000 | 2 | 0 | 1 | 0 | python,activepython | 59,648,957 | 5 | false | 0 | 0 | An important difference is that ActiveState Python is proprietary software and, if you put it in production, they can force you into subscription software fees and sue you if you don't pay. Their sales people have been tracking down heavier users and companies with more users and threatening them into unexpected payme... | 4 | 34 | 0 | I am new to Python. I am supposed to launch an application and perform some tasks on the application from Python.
I found Python from python.org and ActivePython from activestate.com.
What is the difference between them? Which should I install? | What is the difference between ActivePython and Python? | 0.07983 | 0 | 0 | 22,486 |
4,733,252 | 2011-01-19T08:42:00.000 | 0 | 0 | 1 | 0 | python,activepython | 69,076,465 | 5 | false | 0 | 0 | Starting with Python 3.9, ActiveState has a new approach. Developers can create their own builds of Python 3.9 for free on the ActiveState Platform - and these builds are pure Open Source.
There still are proprietary limits - but these are based on how much an individual or organization uses the ActiveState Platform an... | 4 | 34 | 0 | I am new to Python. I am supposed to launch an application and perform some tasks on the application from Python.
I found Python from python.org and ActivePython from activestate.com.
What is the difference between them? Which should I install? | What is the difference between ActivePython and Python? | 0 | 0 | 0 | 22,486 |
4,733,252 | 2011-01-19T08:42:00.000 | 21 | 0 | 1 | 0 | python,activepython | 4,733,301 | 5 | false | 0 | 0 | ActiveState is an open source company which bundles Python with some additional packages and makes it available for variety of platforms. Sometimes they support platforms which the standard Python distrubution does not. For example AIX comes to my mind.
Many beginners to python on Windows have this doubt when they star... | 4 | 34 | 0 | I am new to Python. I am supposed to launch an application and perform some tasks on the application from Python.
I found Python from python.org and ActivePython from activestate.com.
What is the difference between them? Which should I install? | What is the difference between ActivePython and Python? | 1 | 0 | 0 | 22,486 |
4,733,866 | 2011-01-19T09:58:00.000 | 0 | 0 | 1 | 0 | python,perl,nlp | 4,734,305 | 2 | false | 0 | 0 | Google people may already be working on such a thing. ;-)
If I get you right, you want a tool that will read a book for you and then briefly summarize for you what it was all about so you can spare the time reading it yourself. Maybe you're not interested in the contents but rather want to categorize the material, as a... | 1 | 3 | 0 | I am really looking for a toolkit or readymade tool which will parse a given document and then generate a brief summary of better still a mindmap of the document. I know Python has ntlk and perl has quite a few modules which will help in natural language parsing etc.
It is even feasible to write a tool to do so, with... | Is there an open source tool based on perl or python to generate the summary of mindmap of documents | 0 | 0 | 0 | 511 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.