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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
10,210,233 | 2012-04-18T13:19:00.000 | 0 | 0 | 1 | 0 | python,list,class,function,contains | 10,210,281 | 4 | false | 0 | 0 | It depends on the class how it does the check. For the builtin list it uses the == operator; otherwise you couldn't e.g. use 'something' in somelist safely.
To be more specific, it check if the item is equal to an item in the list - so internally it's most likely a hash(a) == hash(b) comparison; if the hashes are equal... | 1 | 13 | 0 | Does the __contains__ method of a list class check whether an object itself is an element of a list, or does it check whether the list contains an element equivalent to the given parameter?
Could you give me an example to demonstrate? | Python List Class __contains__ Method Functionality | 0 | 0 | 0 | 6,929 |
10,212,293 | 2012-04-18T15:06:00.000 | 1 | 0 | 0 | 0 | python,google-app-engine,http-status-codes | 10,212,363 | 2 | false | 1 | 0 | I might be wrong but there is no such thing as incoming request status code, application doing requests in case of redirect gets 302 from initial request checks location and do another request. And history of incoming request in shape of thing like "traceroute" just don't exists in HTTP. | 1 | 0 | 0 | How can I check the status code of a request? I want to check what kind of redirects were used to access a page.
For response objects I would use *response.status_code* | How to determine status code of request | 0.099668 | 0 | 1 | 111 |
10,212,442 | 2012-04-18T15:14:00.000 | -15 | 0 | 1 | 0 | python | 10,212,669 | 2 | false | 0 | 0 | No there is not a duplicate code checker, as there is no way to easily distinguish whether it has repeated or not because depending on the program, there may be dependencies on the code that is "duplicated" and things may be overwritten, ect. . All in all, no, there is no duplicate code checker that i know of for pytho... | 1 | 21 | 0 | Is there any library in python for duplicate code checker? I use python IDE and I am finding trouble refactoring my code. Are there any python library available which suggest duplicate code in the program/project?
Update: I found clone digger which as per its site,
We have tested Clone Digger on sources of several open... | Removing duplicate code in python | -1 | 0 | 0 | 8,400 |
10,212,791 | 2012-04-18T15:32:00.000 | 1 | 0 | 0 | 0 | python,django,facebook,celery,django-signals | 10,213,618 | 1 | false | 1 | 0 | This really comes down to synchronous vs asynchronous. Django signals are synchronous that is they will block the response until they are completed. Celery tasks are asynchronous.
Which will be better will depend on whether the benefits of handling the profile building asynchronously outweighs the negatives of the ma... | 1 | 0 | 0 | I recently started playing around with django-social-auth and am looking for some help from the community to figure out the best way to move forward with an idea.
Once a user has registered you have access to his oauth token which allows you to pull certain data.
In my case I want to build a nice little profile based o... | django-social-auth profile builder | 0.197375 | 0 | 0 | 210 |
10,214,771 | 2012-04-18T17:33:00.000 | 0 | 0 | 1 | 0 | python,function,ipython | 19,082,190 | 4 | false | 0 | 0 | Fumctions in IPython are considered dynamically generated if:
they are metaprogrammed - they are created by another function. in this case ther is no source code, it simply does not exist.
they are referenced in a different namespace to which they were created and there is no information as to what namespace they are ... | 1 | 7 | 0 | In an IPython session, I usually define custom functions...problem is, sometimes I want to see the actual code for these functions. So far, I have not been able to find a way to display this. Using ? and ?? simply returns "Dynamically generated function. No source code available." Is there any way to display source cod... | How to show source code for dynamically created ("custom") function in IPython? | 0 | 0 | 0 | 893 |
10,214,827 | 2012-04-18T17:37:00.000 | 0 | 0 | 1 | 0 | python,pip | 57,027,462 | 16 | false | 0 | 0 | In question, it is not mentioned which OS user is using (Windows/Linux/Mac)
As there are couple of answers which will work flawlessly on Mac and Linux.
Below command can be used in case the user is trying to find the version of a python package on windows.
In PowerShell use below command :
pip list | findstr <PackageN... | 1 | 976 | 0 | Using pip, is it possible to figure out which version of a package is currently installed?
I know about pip install XYZ --upgrade but I am wondering if there is anything like pip info XYZ. If not what would be the best way to tell what version I am currently using. | Find which version of package is installed with pip | 0 | 0 | 0 | 993,511 |
10,217,708 | 2012-04-18T20:47:00.000 | 1 | 0 | 0 | 0 | python,web-crawler,scrapy | 10,217,884 | 3 | false | 1 | 0 | This has nothing to do with download speed.
XPath //* selects the entire page. XPath //script/text() selects only text inside script elements. So of course the second one is faster, because there is less text to search with the re() call! | 3 | 0 | 0 | I am using Scrapy crawler to crawl over 100k pages website. The speed is the big concern in this case. Today I noticed that hxs.select('//*').re('something') is way slower than hxs.select('//script/text()').re('something'). Can any expert explain to me why?
As I understand, the crawler should download the entire pa... | How does xpathselector affect the speed of scrapy crawl running? | 0.066568 | 0 | 1 | 410 |
10,217,708 | 2012-04-18T20:47:00.000 | 0 | 0 | 0 | 0 | python,web-crawler,scrapy | 10,248,266 | 3 | false | 1 | 0 | XPath definitely has a role in crawler speed, crawler download the page, but Xpath process the Html that crawler downloaded. so if the page is big then xpath will take time to process whole Html. | 3 | 0 | 0 | I am using Scrapy crawler to crawl over 100k pages website. The speed is the big concern in this case. Today I noticed that hxs.select('//*').re('something') is way slower than hxs.select('//script/text()').re('something'). Can any expert explain to me why?
As I understand, the crawler should download the entire pa... | How does xpathselector affect the speed of scrapy crawl running? | 0 | 0 | 1 | 410 |
10,217,708 | 2012-04-18T20:47:00.000 | 1 | 0 | 0 | 0 | python,web-crawler,scrapy | 10,217,990 | 3 | false | 1 | 0 | I am afraid that you might look for 'something' in the entire document, so you probably should still use hxs.select('//*').re('something').
And about the speed question: the answer is that if you look for the word 'something' in a document which is 4k large, of course it will take longer then filtering the document for... | 3 | 0 | 0 | I am using Scrapy crawler to crawl over 100k pages website. The speed is the big concern in this case. Today I noticed that hxs.select('//*').re('something') is way slower than hxs.select('//script/text()').re('something'). Can any expert explain to me why?
As I understand, the crawler should download the entire pa... | How does xpathselector affect the speed of scrapy crawl running? | 0.066568 | 0 | 1 | 410 |
10,217,948 | 2012-04-18T21:02:00.000 | 1 | 0 | 0 | 1 | python,google-app-engine,analytics,visitors | 10,221,347 | 3 | false | 1 | 0 | There is no way to tell when someone stops viewing a page unless you use Javascript to inform the server when that happens. Forums etc typically assume that someone has stopped viewing a page after n minutes of inactivity, and base their figures on that.
For minimal resource use, I would suggest using memcache exclusiv... | 1 | 2 | 0 | I need to get the number of unique visitors(say, for the last 5 minutes) that are currently looking at an article, so I can display that number, and sort the articles by most popular.
ex. Similar to how most forums display 'There are n people viewing this thread'
How can I achieve this on Google App Engine? I am using ... | How to get number of visitors of a page on GAE? | 0.066568 | 0 | 0 | 1,919 |
10,218,679 | 2012-04-18T21:59:00.000 | 1 | 1 | 0 | 0 | python,selenium | 10,218,792 | 6 | false | 1 | 0 | My experience has been that any sufficiently useful test framework will end up needing a customized logging solution. You are going to end up wanting domain specific and context relevant information, and the pre-baked solutions never really fit the bill by virtue of being specifically designed to be generic and broadl... | 1 | 7 | 0 | I am doing some R&D on selenium+python. I wrote some test cases in python using selenium webdriver and unittest module. I want to know how can I create report of the test cases. Is there inbuilt solution available in selenium or I need to code to generate file.
Or is there any other web testing framework with javascrip... | Selenium+python Reporting | 0.033321 | 0 | 1 | 24,481 |
10,219,934 | 2012-04-19T00:13:00.000 | 0 | 0 | 0 | 1 | python,django,queue | 10,219,986 | 1 | true | 1 | 0 | Looks like duplicate imports in my project were causing the problems. | 1 | 0 | 0 | When djutils goes through autodiscover in the init, it imports my task "app.commands.task1" and states this as part of the output of the log.
But when I run webserver and try to queue the command, the queue_consumer log indicates that it cannot find the key "project.app.commands.queuecmd_task1"
QueueException: project... | djutils autodiscover importing command without top level parent, queue_consumer doesn't like it | 1.2 | 0 | 0 | 35 |
10,220,654 | 2012-04-19T01:59:00.000 | 5 | 0 | 1 | 0 | java,python,list | 10,220,713 | 6 | true | 0 | 0 | You can use Arrays.asList then use List.indexOf. The other suggestions to use Arrays.binarySearch are good but require the array to be sorted. | 1 | 0 | 0 | For Python, I can do something like array.index(element) to get the index for an element in array. How can I do this in Java using regular arrays, not arrayList? Is there a similar function? | Java array analog for python list.index()? | 1.2 | 0 | 0 | 257 |
10,220,943 | 2012-04-19T02:41:00.000 | 0 | 1 | 0 | 0 | python,windows | 10,220,978 | 4 | false | 0 | 0 | raw_input('Please fill in questionnaire 1 and press [ENTER] when you are done.') will wait for someone to hit [enter].
Clearing the screen may be OS/environment dependent, I am not sure. | 1 | 0 | 0 | 'lo,
I am currently trying to code a simple routine for an experiment we are planning to run. The experiment starts by entering a subject number and creating a bunch of files. I got that part working. Next, we want the screen to go blank and display a message. Something like 'Please fill in questionnaire 1 and press [E... | Present blank screen, wait for key press -- how? | 0 | 0 | 0 | 5,401 |
10,221,441 | 2012-04-19T03:55:00.000 | 2 | 0 | 1 | 0 | python,function | 10,221,621 | 2 | false | 0 | 0 | In general
import multiprocessing
multiprocessing.__path__
multiprocessing.__file__
__path__ yields location of the library
__file__ yields complete path of the file.
If above didn't work, you need to look into python development source code.
Regarding type source code, Raymond Hettinger's answer is correct. | 1 | 2 | 0 | I have used type() function in my program...
I just want to know how does Python implement this? Or where could I find the source code file that implement this function? | source code of python inbuilt functions | 0.197375 | 0 | 0 | 2,787 |
10,222,493 | 2012-04-19T06:05:00.000 | 2 | 0 | 0 | 0 | python,xml,openerp | 10,224,838 | 1 | true | 1 | 0 | No you cannot do that:
the field names are keys in a Python dictionary, in what you write the second invoice_line will overwrite the first one
this would mess up OpenERP's ORM anyway as it does not handle relations to different tables.
So you need two different columns, one relative to account.invoice.line and the ... | 1 | 0 | 0 | I try to create a related field on OpenERP 6.0.1 . is it possible to define two different onetomany relationfor the same field name? What all changes i must do in the(.py file and XML Files). | onetomany relation field in Openerp | 1.2 | 0 | 1 | 759 |
10,223,003 | 2012-04-19T06:53:00.000 | 1 | 0 | 0 | 1 | python,design-patterns,twisted | 10,223,666 | 1 | true | 0 | 0 | Twisted havs a package "twisted.words.xish.utility.EventDispatcher", pydoc it to know the usage, it is simple. However, I think what make Twisted strong is its "Deferred". You can looks Deferred object as a Closure of related events (something OK, something failed), callback, fallback are registed observer function. D... | 1 | 1 | 0 | I just wanted to hear ideas on correct usage of EventListener/EventSubscription provider in twisted. Most of the examples and the twisted source handle events through the specific methods with a pretty hard coupling. Dispatching target methods of those events are "hardcoded" in a specific Protocol class and then it is ... | EventListener mechanism in twisted | 1.2 | 0 | 0 | 389 |
10,224,384 | 2012-04-19T08:32:00.000 | 0 | 0 | 1 | 1 | java,python | 10,224,419 | 2 | false | 0 | 0 | Import all the files in Eclipse. If you manage to get the code compile using the refactor functions of the IDE it will save you all the trouble.
There is no functionality of adding synonyms to the imports in java, but even if there was such how would that have helped you? You still will need to change all your files. | 1 | 1 | 0 | I have a bunch of idl files that automatically create four packages, with a lot of java files into it.
I need to insert those java files in a com.bla. package architecture.
Thing is in my generated files I have imports UCO.State for example, that do not fit with my new package architecture.
So question is : Is ther... | python import as equivalent in Java? | 0 | 0 | 0 | 982 |
10,227,042 | 2012-04-19T11:28:00.000 | 2 | 0 | 0 | 1 | google-app-engine,python-2.7,blobstore | 10,227,981 | 1 | true | 0 | 0 | Try checking for user IP at the point where you generate upload url via create_upload_url().
The upload handler is actually called by Blobstore upload logic after the upload is done, hence the strange IP. | 1 | 1 | 0 | I'm attempting to get the user's IP from inside of my upload handler, but it seems that the only IP supplied is 0.1.0.30. Is there any way around this or any way to get the user's actual IP from inside of the upload handler? | How can I get a user's IP from a Blobstore upload handler? | 1.2 | 0 | 1 | 204 |
10,228,275 | 2012-04-19T12:39:00.000 | 6 | 0 | 1 | 0 | python | 10,228,323 | 5 | false | 0 | 0 | it prevents the Python interpreter from attaching any special meanings to special characters in the string (such as the backslash), and just interpret it as is (i.e., in its "raw" form). This is one way you can "escape" special characters in strings you use.
You'll often see raw strings in path specifications. Let's... | 4 | 3 | 0 | This has probably answered somewhere at sometime but the titles I have seen don't connect so here it goes. I have seen python commands that read os.listdir(r".\bootstrapper"). What is the 'r' doing?
Cheers... | 'r' in Python commands | 1 | 0 | 0 | 5,636 |
10,228,275 | 2012-04-19T12:39:00.000 | 1 | 0 | 1 | 0 | python | 10,228,303 | 5 | false | 0 | 0 | It makes it a raw string. In other words, backslashes will be preserved. '\n' is interpreted as a new-line, but r'\n' is interpreted as the literal characters '\' and 'n'.
Also note that occasionally you'll see u'string' if you're using python2.x code. This implies that the string should be interpreted as a unicode ... | 4 | 3 | 0 | This has probably answered somewhere at sometime but the titles I have seen don't connect so here it goes. I have seen python commands that read os.listdir(r".\bootstrapper"). What is the 'r' doing?
Cheers... | 'r' in Python commands | 0.039979 | 0 | 0 | 5,636 |
10,228,275 | 2012-04-19T12:39:00.000 | 3 | 0 | 1 | 0 | python | 10,228,297 | 5 | false | 0 | 0 | r marks raw input. This means that the normal escape characters within the string are ignored (like \ ) | 4 | 3 | 0 | This has probably answered somewhere at sometime but the titles I have seen don't connect so here it goes. I have seen python commands that read os.listdir(r".\bootstrapper"). What is the 'r' doing?
Cheers... | 'r' in Python commands | 0.119427 | 0 | 0 | 5,636 |
10,228,275 | 2012-04-19T12:39:00.000 | 1 | 0 | 1 | 0 | python | 11,424,906 | 5 | false | 0 | 0 | r means raw input. If a string is marked as r, then the meaning of any special character whithin the string will be ignored, the most frequently situation will be the backslash. | 4 | 3 | 0 | This has probably answered somewhere at sometime but the titles I have seen don't connect so here it goes. I have seen python commands that read os.listdir(r".\bootstrapper"). What is the 'r' doing?
Cheers... | 'r' in Python commands | 0.039979 | 0 | 0 | 5,636 |
10,228,596 | 2012-04-19T12:57:00.000 | 0 | 0 | 0 | 0 | python,plone,ploneformgen | 10,232,165 | 2 | false | 1 | 0 | As I recall, PFG submissions don't generate Plone events. While you could potentially modify PFG (or better yet, contribute enhancements) to add events on form submission, I think the use-case you are describing is probably better realized by building a custom content type to represent your Leave Application Form. Wh... | 2 | 1 | 0 | how to trigger a content rule if PloneFormGen's form data is submitted in Plone 4.1. eg. I have created a Leave application form for employees. Once the employee submits data, the content rule should send the leave data to his manager. If he approves, final approval should be taken from the General Manager(GM). if the... | how to trigger a content rule if PloneFormGen's form data is submitted in Plone 4.1 | 0 | 0 | 0 | 173 |
10,228,596 | 2012-04-19T12:57:00.000 | 2 | 0 | 0 | 0 | python,plone,ploneformgen | 10,234,004 | 2 | true | 1 | 0 | Use uwosh.pdf.d2c to store the content submissions as actual plone content. Then you can use content rules on those objects. | 2 | 1 | 0 | how to trigger a content rule if PloneFormGen's form data is submitted in Plone 4.1. eg. I have created a Leave application form for employees. Once the employee submits data, the content rule should send the leave data to his manager. If he approves, final approval should be taken from the General Manager(GM). if the... | how to trigger a content rule if PloneFormGen's form data is submitted in Plone 4.1 | 1.2 | 0 | 0 | 173 |
10,230,820 | 2012-04-19T14:55:00.000 | 23 | 0 | 1 | 0 | python,ipython,multiline,paste | 10,522,299 | 2 | false | 0 | 0 | Type %paste into the IPython command line. | 2 | 12 | 0 | I used IPython in the past and I used to be able to copy and paste multi-line commands, e.g., a for loop in IPython. Working in my new PC after installing Python(x,y) 2.7.2.1, I can paste multi-line snippets by using Right-click → Edit → Paste but not by using CTRL+P, as I used to do. When using CTRL+P only the first l... | Paste Multi-line Snippets into IPython | 1 | 0 | 0 | 8,856 |
10,230,820 | 2012-04-19T14:55:00.000 | 16 | 0 | 1 | 0 | python,ipython,multiline,paste | 48,710,809 | 2 | false | 0 | 0 | You can use %cpaste with IPython shell (which is also what is used by Django's management shell). If you want to learn more of the features, type %quickref. | 2 | 12 | 0 | I used IPython in the past and I used to be able to copy and paste multi-line commands, e.g., a for loop in IPython. Working in my new PC after installing Python(x,y) 2.7.2.1, I can paste multi-line snippets by using Right-click → Edit → Paste but not by using CTRL+P, as I used to do. When using CTRL+P only the first l... | Paste Multi-line Snippets into IPython | 1 | 0 | 0 | 8,856 |
10,231,221 | 2012-04-19T15:15:00.000 | 0 | 0 | 0 | 0 | python,django,download | 10,248,076 | 1 | false | 1 | 0 | In such cases, I usually return an archived file to user with HttpResponse and set the content type to "attachment". This way the download starts automatically and I don't have to save the archived file. Is this approach helps you or not? | 1 | 1 | 0 | In my server side code in Django, i download a set of files on the server and create an archive which is then sent to the client side for download.
Is there a way i can automatically delete this archive once the download on the client side is complete or aborted ?
Thank You | Automatically deleting archive on server in Django when client side download completes | 0 | 0 | 0 | 113 |
10,232,673 | 2012-04-19T16:36:00.000 | 14 | 0 | 0 | 0 | python,django,web-services | 25,833,953 | 5 | false | 1 | 0 | AWS :
Free tier available
great support(but for technical help you got to pay)
can use platform (PAAS) BeanStalk
can customize architecture in case you get a dedicated instance
great community of support
Custom domain
great documentation
can SSH
Most popular
Heroku:(Django)
Free to some extent
Can use only POSTgres... | 1 | 15 | 0 | Hi I'm looking for some advice I currently own a resseller package with Heart internet as I host a few personal websites. However I'm currently learning Django (The python Framework) and want to be able to host my own server.
I have been setting up virtual servers to play around with. Anyway to have SSH access you have... | Hosting my Django site | 1 | 0 | 0 | 29,244 |
10,233,088 | 2012-04-19T17:01:00.000 | 4 | 0 | 1 | 0 | javascript,parameters,python-sphinx | 10,245,168 | 1 | false | 1 | 0 | You need to add a blank line between the directive and its options. | 1 | 3 | 0 | I get the following error using the js:function directive. Why doesn't :param recognise multiple values between ::?
"
invalid option data: extension option field name may not contain multiple words.
.. js:function:: f(test,test2)
:param test:
:param test2:
" | sphinx js:function directive doesn't recognise params | 0.664037 | 0 | 0 | 423 |
10,233,187 | 2012-04-19T17:08:00.000 | 0 | 0 | 0 | 0 | php,python,mysql,django,cakephp | 10,233,231 | 2 | false | 1 | 0 | This is one of the reasons to use RDBMS to provide access for different users and applications to the same data. There should absolutely no problem with this. | 1 | 0 | 0 | I have a web application that has been done using Cakephp with MySql as the DB. The webapp also exposes a set of web services that get and update data to the MySQL DB. I will like to extend the app to provide a fresh set of web services but will like to use a python based framework like web2py/django etc. Since both wi... | Same MySql DB working with a php and a python framework | 0 | 1 | 0 | 73 |
10,234,885 | 2012-04-19T18:55:00.000 | 1 | 0 | 0 | 0 | javascript,detect,python-idle | 10,234,996 | 5 | false | 0 | 0 | Store their last activity in a database table when they are active. You can use mouse movement, keypresses, or some other activity to update the timestamp. Periodically poll that table with an ajax call on the page on which the user would see their online/offline status. If the last active time is > 5 minutes, show ... | 3 | 3 | 0 | I have a script that sends a time-sensitive notification to users when there is a new question directed to them. However, I found that some people leave their computers open and go grab lunch, therefore missing notifications.
I'm looking to put together a script that detects if the user is idle for 5 minutes, and if so... | Is it possible to detect idle time even across tabs? | 0.039979 | 0 | 1 | 3,773 |
10,234,885 | 2012-04-19T18:55:00.000 | 2 | 0 | 0 | 0 | javascript,detect,python-idle | 10,235,006 | 5 | true | 0 | 0 | Everything that happens when the user is NOT on your side is impossible to track (luckily).
So not this is not possible (think about the security).
UPDATE
Now that I think of it. It is possible, however very unlikely that you can do it. If your name would have been Google you would have come a long way, because lots of... | 3 | 3 | 0 | I have a script that sends a time-sensitive notification to users when there is a new question directed to them. However, I found that some people leave their computers open and go grab lunch, therefore missing notifications.
I'm looking to put together a script that detects if the user is idle for 5 minutes, and if so... | Is it possible to detect idle time even across tabs? | 1.2 | 0 | 1 | 3,773 |
10,234,885 | 2012-04-19T18:55:00.000 | 1 | 0 | 0 | 0 | javascript,detect,python-idle | 10,235,004 | 5 | false | 0 | 0 | if I am on such a thing I use either the HTML5 Visibility API or fallback to blur and focus events observing when the user left the page and then returns... leaving means unfocus the browser window or tab (but still keeping the page open)
but since you wanna react on inactivity... hmmm you could start a timeout (of cou... | 3 | 3 | 0 | I have a script that sends a time-sensitive notification to users when there is a new question directed to them. However, I found that some people leave their computers open and go grab lunch, therefore missing notifications.
I'm looking to put together a script that detects if the user is idle for 5 minutes, and if so... | Is it possible to detect idle time even across tabs? | 0.039979 | 0 | 1 | 3,773 |
10,235,220 | 2012-04-19T19:19:00.000 | 2 | 0 | 0 | 1 | python,logging,multiprocessing,logrotate | 10,238,553 | 2 | false | 0 | 0 | As WatchedFileHandler was provided specifically for use with external rotation tools like logrotate, I would suggest that it be used (Option 1). Why do you think you need Option 2?
In a multi-process environment where each process writes to its own logs, there shouldn't be any problems. However, processes shouldn't eve... | 2 | 2 | 0 | I am trying to use logrotate to rotate logs for a multi-process python service. Which of the following combination is commonly used (right and safe)?
WatchedFileHandler + logrotate with create option
OR
FileHandler + logrotate with copytruncate option
Option-1 seem to be used in openstack nova and glance projects. I ... | Python logging - logrotate options | 0.197375 | 0 | 0 | 2,637 |
10,235,220 | 2012-04-19T19:19:00.000 | 0 | 0 | 0 | 1 | python,logging,multiprocessing,logrotate | 10,235,643 | 2 | false | 0 | 0 | I would suggest using Python's own log rotation to get the best integration. The only drawback is that you have an additional place to configure the details. | 2 | 2 | 0 | I am trying to use logrotate to rotate logs for a multi-process python service. Which of the following combination is commonly used (right and safe)?
WatchedFileHandler + logrotate with create option
OR
FileHandler + logrotate with copytruncate option
Option-1 seem to be used in openstack nova and glance projects. I ... | Python logging - logrotate options | 0 | 0 | 0 | 2,637 |
10,235,579 | 2012-04-19T19:42:00.000 | 0 | 0 | 0 | 0 | python,django,beautifulsoup | 10,235,640 | 2 | false | 1 | 0 | Try copying and pasting that URL into your browser. I get an access key error; fix that and your problem is solved. | 1 | 1 | 0 | Beautiful Soup works in the Python shell using Django. I can also successfully import from bs4 import BeautifulSoup into views.py, but when I call something like soup = BeautifulSoup(xml), I get a 502 Bad Gateway error. I talked to my host, and they could not find the problem. Any ideas?
Note the xml is xml = urllib2.u... | 502 Bad Gateway using Beautiful Soup, Python/Django | 0 | 0 | 0 | 1,024 |
10,236,321 | 2012-04-19T20:35:00.000 | 4 | 1 | 0 | 0 | python,point-of-sale,prototyping | 10,236,867 | 2 | false | 1 | 0 | Python is a very quick and productive language to develop in, so that would be a good choice, IMO. Personally I find it the most pleasant language to develop in.
But I think a POS system is a terrible first programming project. A proper POS system covers too many aspects like security, authentication, data storage, cli... | 1 | 3 | 0 | I am considering of prototyping a web based point-of-sale system.
I don't have programming skills but I'm thinking of using this project in order to learn.
I would like to ask you the following two questions:
Do you think the above task is achievable within the period of 6 months (for building a rough prototype of the... | Creating a web based point of sale system | 0.379949 | 0 | 0 | 9,646 |
10,238,473 | 2012-04-19T23:53:00.000 | 0 | 1 | 1 | 0 | python,pylint | 44,339,590 | 6 | false | 0 | 0 | My use case is to run pylint *.py to process all files in a directory, except that I want to skip one particular file.
Adding # pylint: skip-file caused Pylint to fail with I: 8, 0: Ignoring entire file (file-ignored). Adding # pylint: disable=file-ignored does not fix that. Presumably, it's a global error rather than... | 2 | 116 | 0 | We are using Pylint within our build system.
We have a Python package within our code base that has throwaway code, and I'd like to disable all warnings for a module temporarily so I can stop bugging the other devs with these superfluous messages. Is there an easy way to pylint: disable all warnings for a module? | Disable all Pylint warnings for a file | 0 | 0 | 0 | 88,564 |
10,238,473 | 2012-04-19T23:53:00.000 | 7 | 1 | 1 | 0 | python,pylint | 10,276,255 | 6 | false | 0 | 0 | Another option is to use the --ignore command line option to skip analysis for some files. | 2 | 116 | 0 | We are using Pylint within our build system.
We have a Python package within our code base that has throwaway code, and I'd like to disable all warnings for a module temporarily so I can stop bugging the other devs with these superfluous messages. Is there an easy way to pylint: disable all warnings for a module? | Disable all Pylint warnings for a file | 1 | 0 | 0 | 88,564 |
10,239,073 | 2012-04-20T01:32:00.000 | 4 | 0 | 1 | 0 | python,django | 10,239,569 | 1 | true | 1 | 0 | It's not a problem unless you find yourself writing exactly the same code on model after model. At that point you should consider writing a template tag that takes the model as a parameter instead. | 1 | 6 | 0 | I would like to know what would be the best practice. I have been using the @property decorator a lot because it allows me to avoid creating custom context variables when I want to display something related to a model instance on a template.
I feel like my models are too big. Is this ok? | Django models: when should I use the @property decorator for attributes? | 1.2 | 0 | 0 | 1,584 |
10,241,279 | 2012-04-20T06:27:00.000 | 0 | 0 | 1 | 1 | python,emacs,interpreter | 15,099,767 | 8 | false | 0 | 0 | In emacs 24.2 there is python-switch-to-python | 2 | 32 | 0 | I just downloaded GNU emacs23.4, and I already have python3.2 installed in Windows7.
I have been using Python IDLE to edit python files.
The problem is that I can edit python files with Emacs but I do not know how to run python interpreter in Emacs. When i click on "switch to interpreter", then it says "Searching for p... | How do I run a python interpreter in Emacs? | 0 | 0 | 0 | 37,056 |
10,241,279 | 2012-04-20T06:27:00.000 | 14 | 0 | 1 | 1 | python,emacs,interpreter | 20,375,113 | 8 | false | 0 | 0 | C-c C-z can do this. It is the key-binding for the command python-switch-to-python | 2 | 32 | 0 | I just downloaded GNU emacs23.4, and I already have python3.2 installed in Windows7.
I have been using Python IDLE to edit python files.
The problem is that I can edit python files with Emacs but I do not know how to run python interpreter in Emacs. When i click on "switch to interpreter", then it says "Searching for p... | How do I run a python interpreter in Emacs? | 1 | 0 | 0 | 37,056 |
10,241,950 | 2012-04-20T07:23:00.000 | 0 | 0 | 0 | 0 | php,python,temporary-files | 10,266,536 | 3 | true | 1 | 0 | I don't know why I didn't think of it, but I was on an IRC for Python, discussing a completely unrelated issue, and someone asked why I didn't just serve the file. Exactly!
I never needed to save the file, just to send it back to the user with the correct header. Problem solved! | 1 | 3 | 0 | I need to set up a page that will let the user upload a file, modify the file with a script, and then serve the file back to the user.
I have the uploading and modifying parts down, but I don't know where to put the file. They are going to be in the area of 1 or 2mb, and I have very little space on my webhosting plan, ... | Store file for duration of time on webpage | 1.2 | 0 | 1 | 136 |
10,242,525 | 2012-04-20T08:10:00.000 | 1 | 0 | 1 | 0 | python,dictionary,parallel-processing,multiprocessing,large-data | 10,248,052 | 2 | false | 0 | 0 | I hit a similar issue: parallelizing calculations on a big dataset. As you mentioned multiprocessing.Pool.map pickles the arguments. What I did was to implement my own fork() wrapper that only pickles the return values back to the parent process, hence avoiding pickling the arguments. And a parallel map() on top of the... | 1 | 2 | 1 | Is it efficient to calculate many results in parallel with multiprocessing.Pool.map() in a situation where each input value is large (say 500 MB), but where input values general contain the same large object? I am afraid that the way multiprocessing works is by sending a pickled version of each input value to each wor... | When to and when not to use map() with multiprocessing.Pool, in Python? case of big input values | 0.099668 | 0 | 0 | 2,008 |
10,243,310 | 2012-04-20T09:10:00.000 | 1 | 0 | 0 | 0 | php,python,django,wordpress,heroku | 10,243,597 | 1 | true | 1 | 0 | no, application type is determined at slug compilation time when the application is pushed to Heroku. Not sure if you could do anything with a custom build pack but I would have thought so. | 1 | 1 | 0 | Is it possible to run some php app (e.g. wordpress) together with django within one heroku instance, so that the part of app's urls would be served by php and the rest by django? | PHP together with django in heroku instance | 1.2 | 0 | 0 | 252 |
10,244,713 | 2012-04-20T10:44:00.000 | 0 | 0 | 0 | 1 | c++,python,objective-c,plugins,cross-platform | 10,245,373 | 2 | false | 0 | 1 | The simplest way to share the cross-platform Python component of your application would probably be to implement it as a command-line program, and then invoke it using the relevant system calls in each of the front-ends. It's not the most robust way, but it could be sufficient.
If you want plugins to just be a file con... | 1 | 0 | 0 | I am writing an application which should be able to run on Linux, Mac OS X, Windows and BSD (not necessarily as a single executable, so it doesn't have to be Java) and be extensible using simple plugins.
The way I want my plugins to be implemented is as a simple Python program which must implement a certain function an... | Simplest way to write cross-platform application with Python plugin extensibility? | 0 | 0 | 0 | 1,296 |
10,246,539 | 2012-04-20T12:47:00.000 | 2 | 0 | 0 | 1 | python,asynchronous,tornado | 10,246,669 | 1 | true | 0 | 0 | Yes, as I understand your question, that is a normal use-case for Tornado.
If all requests to your Tornado server would make requests to myapi.com, and myapi.com is blocking, then yes, myapi.com would still be the bottleneck. However, if only some requests have to be handled by myapi.com, then Tornado would still be a ... | 1 | 2 | 0 | I have just begun to look at tornado and asynchronous web servers. In many examples for tornado, longer requests are handled by something like:
make a call to tornado webserver
tornado makes async web call to an api
let tornado keep taking requests while callback waits to be called
handle response in callback. server... | Tornado/Async Webserver theory, how to handle longer running operations to utilize the async server | 1.2 | 0 | 0 | 652 |
10,247,264 | 2012-04-20T13:31:00.000 | 12 | 0 | 1 | 0 | python,naming,nomenclature | 10,247,378 | 3 | false | 0 | 0 | I think site is used to mean the same thing as local, as in /usr/local/* - it's those elements that are installed locally/for this site, as opposed to those that are provided by the system. | 2 | 13 | 0 | I've always been a bit curious about the rationale of the naming of site-packages. What does site mean in this context? I doubt it means 'website', and I've never heard 'site' used in relation to the installation location, or the context of the machine.
Any ideas? | What does 'site' in 'site-packages' actually mean? | 1 | 0 | 0 | 501 |
10,247,264 | 2012-04-20T13:31:00.000 | 5 | 0 | 1 | 0 | python,naming,nomenclature | 10,247,716 | 3 | false | 0 | 0 | I have always understood this as short for on-site - oposite to remote. Probably because those are the packages that are on your machine. That's just my guess, though :) | 2 | 13 | 0 | I've always been a bit curious about the rationale of the naming of site-packages. What does site mean in this context? I doubt it means 'website', and I've never heard 'site' used in relation to the installation location, or the context of the machine.
Any ideas? | What does 'site' in 'site-packages' actually mean? | 0.321513 | 0 | 0 | 501 |
10,248,880 | 2012-04-20T15:13:00.000 | 0 | 0 | 1 | 0 | python,opencv | 59,521,987 | 4 | false | 0 | 0 | In terminal write:
for python 2.X python2 -c 'import cv2; print cv2.__version__'
for python 3.X python3 -c 'import cv2; print(cv2.__version__)' | 1 | 20 | 0 | I want to write to short code snippet in python, to determine which version of OpenCV has been installed in my System. How do i do it ?
Thank you. | Determine which version of OpenCV | 0 | 0 | 0 | 31,954 |
10,249,121 | 2012-04-20T15:31:00.000 | 0 | 0 | 0 | 0 | python | 10,249,180 | 3 | false | 0 | 0 | Get the functional module from pypi. It has a compose function to compose two callables. With that, you can chain functions together.
Both that module, and functool provide a partial function, for partial-application.
You can use the composed functions in a generator expression just like any other. | 1 | 3 | 0 | here is the problem:
1) suppose that I have some measure data (like 1Msample read from my electronics) and I need to process them by a processing chain.
2) this processing chain consists of different operations, which can be swapped/omitted/have different parameters. A typical example would be to take this data, first ... | how to implement 'daisychaining' of pluggable function in python? | 0 | 0 | 0 | 987 |
10,249,240 | 2012-04-20T15:38:00.000 | 1 | 1 | 1 | 0 | python,character-encoding | 10,250,521 | 1 | true | 0 | 0 | If it is None, simply output your data as utf-8, and document it. If it happens that there are use cases for other encodings, make that an option through the command line or other means. | 1 | 2 | 0 | I am trying to handle the different encodings in a Python script the more user-friendly and auto-magic way possible (there are APIs for utf8). It is a cross-platform console script.
For printing to stdout I use sys.stdout.encoding and it seems to do the right thing almost always when printing to the console. However wh... | What should I do when sys.stdout.encoding is None? | 1.2 | 0 | 0 | 643 |
10,250,353 | 2012-04-20T16:55:00.000 | 1 | 0 | 0 | 1 | java,python,windows,stdin | 10,251,723 | 1 | true | 1 | 0 | Have the java app read from a named pipe. A named pipe allows multiple clients to write to it, and are language-agnostic. | 1 | 0 | 0 | I need to send text to a java app's stdin that is started independently from Python. I have been using pywin32 sendkeys up to this point, but there are some inconsistencies with the output that are making me look for other solutions.
I am aware of subprocess, but it looks like that can only be used to interact with a c... | Python: possible to send text to a java app's stdin that is already running? | 1.2 | 0 | 0 | 159 |
10,250,437 | 2012-04-20T17:00:00.000 | 1 | 0 | 0 | 0 | java,python | 10,251,394 | 1 | true | 1 | 0 | Ask the company that makes the software if they have an SDK or documentation on their API. Even if they have one, if you already don't like the application, this may not be much use to you.
If the main purpose of the application is to report on the contents of a database, there are plenty of libraries in python for re... | 1 | 0 | 0 | I have one proprietary software my office uses for database access and reporting which nobody likes in my office. I am thinking of building a python/Java application with a simple interface which does the task of communicating with the propriety software. My problem is: Since the software is proprietary, there is no kn... | Creating interface with the software without API-Possibilities | 1.2 | 0 | 0 | 266 |
10,252,304 | 2012-04-20T19:22:00.000 | 1 | 0 | 1 | 1 | python,gcc,cygwin,pypy | 10,252,762 | 3 | false | 0 | 0 | Windows needs the ".exe" extension to know that it's executable. You'll need to modify the build to look for Windows and use the .exe extension. | 1 | 2 | 0 | I'm trying to compile PyPy on cygwin, and the compilation stops when python tries to open the file "externmod", which was just compiled with gcc. The problem with gcc on cygwin is that it automatically appends a '.exe' to whatever you're compiling, so even though gcc is called as gcc -shared -Wl,--enable-auto-image-ba... | Compiling PyPy on cygwin | 0.066568 | 0 | 0 | 1,101 |
10,253,855 | 2012-04-20T21:34:00.000 | 4 | 0 | 1 | 0 | python,python-3.x,copy,deep-copy | 10,254,186 | 2 | true | 0 | 0 | Is it really necessary to use the copy module for copying instances of this class? I would argue that instead of overriding __copy__ or __deepcopy__ you should create a copy method for your class that returns a new object using the copy semantics you defined.
If for some consistency reason you do need to use the copy ... | 1 | 6 | 0 | My class represents states of various systems. Each instance has two attributes: one is a container shared between all the states of the same system, and the other is a container that is unique to each instance.
A copy of a state should reuse the "shared" attribute, but create a deep copy of the "unique" attribute. Thi... | copy vs deepcopy: semantics | 1.2 | 0 | 0 | 764 |
10,253,898 | 2012-04-20T21:37:00.000 | 3 | 1 | 0 | 0 | python,cgi | 10,254,010 | 2 | true | 0 | 0 | there are a couple of options, use the logging module as directed, you can tail the server's error log, and you can enable cgitb with import cgitb; cgitb.enable()
Depending on exactly where the error occurs, the error will show up in different places, so checking all three, and using print statements and exception bloc... | 1 | 0 | 0 | I'm new to cgi and python, so I've been making quite a few mistakes. The problem is that if something goes wrong with the script, I just get a 500 error on the webpage. The only way I can see what caused the error is by executing the page via ssh, but the page involves file uploads, so I can't test that part.
Is there ... | Logging python errors on website? | 1.2 | 0 | 1 | 2,081 |
10,254,466 | 2012-04-20T22:42:00.000 | 6 | 0 | 0 | 0 | python,django,django-templates | 10,255,173 | 1 | true | 1 | 0 | Even if this might be possible to achieve in the template, I (and probably many other people) would advise against it. To achieve this, you basically need to find out whether there are any objects in the database matching some criteria. That is certainly not something that belongs into a template.
Templates are intende... | 1 | 1 | 0 | I have the following code in my template:
{% for req in user.requests_made_set.all %}
{% if not req.is_published %}
{{ req }}
{% endif %}
{% empty %}
No requests
{% endfor %}
If there are some requests but none has the is_published = True then how could I output a message (like "No requests") ?? I'd only li... | Django template check for empty when I have an if inside a for | 1.2 | 0 | 0 | 3,317 |
10,255,185 | 2012-04-21T00:44:00.000 | 2 | 0 | 0 | 0 | python,excel,web-scraping | 10,255,232 | 2 | false | 0 | 0 | if you don't want to introduce a full excel library, you can write an HTML table or CSV and Excel will happily import those. The downside with this is that you're limited to one worksheet and no formulaes. | 1 | 2 | 0 | I would like to know how I would have a python web scrape dump all of it's results into excel.
It's not that I don't know how to webscrape, it's just I do not know how to scrape into excel. | How to scrape in python into excel | 0.197375 | 0 | 1 | 4,830 |
10,255,319 | 2012-04-21T01:07:00.000 | 0 | 0 | 0 | 1 | python,networking,arp,scapy,spoof | 10,255,376 | 1 | false | 0 | 0 | The strange thing I see here that how the ARP Reply bounced back to VM(1) although it uses a spoofed MAC address..
Well, try to check on the ARP table on VM (2) and see which MAC record it holds for VM (1); probably you'll find the legitimate MAC address cached due to some communications before you spoof the MAC addres... | 1 | 3 | 0 | I am programming with Python and his partner Scapy. I am facing a situation that i dont know if it is a normal behavior from ARP Protocol or some another problem.
I have this scenario:
1- A vm machine (1) sending an "ARP Request" to another vm machine (2) with Spoofed Source MAC Address field (generated with Scapy).
2 ... | Behavior of Spoof MAC Address communication | 0 | 0 | 0 | 1,699 |
10,258,703 | 2012-04-21T12:01:00.000 | 2 | 0 | 1 | 0 | android,python | 10,258,955 | 2 | true | 1 | 1 | Your users have to install SL4A and the language plugin (python?) on their phones, this is not a built-in functionality.
Since the source code is available, it's possible to create combined application, which includes your scripts and SL4A/python code, but in my opinion this defies the purpose of scripting in the first... | 1 | 6 | 0 | In order to develop an Android app using Python, I need to install Python for Android and SL4A on my computer to be used with the Android emulator. My question is, when I distribute this app to actual users/phones, do the phones need to get Python for Android and SL4A explicitly? Or is the supporting infrastructure bui... | Running a Python app on real Android phone | 1.2 | 0 | 0 | 1,128 |
10,259,148 | 2012-04-21T13:02:00.000 | 3 | 0 | 0 | 1 | python,ide,geany | 10,625,293 | 1 | true | 0 | 0 | To solve that problem I added additional parameters to terminal command that geany runs.
In Geany go to preferences (Edit->Preferences).
Open Tools tab.
There is an input field named Terminal where you can specify terminal program to use.
I changed that to "gnome-terminal --maximize" to open terminal maximized.
For G... | 1 | 3 | 0 | I'm using Geany 0.18 for python developing and am in general really satisfied, but there is one little thing, that's still bugging me:
I usually use the F5 (Build-->Execute) option to test my scripts, the appearing window is rather small, and if my script prints lines which are too long they are hard to read. I would l... | Changing window size of Geany's execute (F5) option | 1.2 | 0 | 0 | 1,116 |
10,260,925 | 2012-04-21T16:36:00.000 | 2 | 0 | 0 | 1 | python,celery | 43,633,216 | 2 | false | 1 | 0 | The way I deployed it is like this:
clone your django project on a heroku instance (this will run the frontend)
add RabitMQ as an add on and configure it
clone your django project into another heroku instance (call it like worker) where you will run the celery tasks | 2 | 58 | 0 | I am new to celery.I know how to install and run one server but I need to distribute the task to multiple machines.
My project uses celery to assign user requests passing to a web framework to different machines and then returns the result.
I read the documentation but there it doesn't mention how to set up multiple ma... | How to set up celery workers on separate machines? | 0.197375 | 0 | 0 | 26,305 |
10,260,925 | 2012-04-21T16:36:00.000 | 60 | 0 | 0 | 1 | python,celery | 10,261,277 | 2 | true | 1 | 0 | My understanding is that your app will push requests into a queueing system (e.g. rabbitMQ) and then you can start any number of workers on different machines (with access to the same code as the app which submitted the task). They will pick out tasks from the message queue and then get to work on them. Once they're do... | 2 | 58 | 0 | I am new to celery.I know how to install and run one server but I need to distribute the task to multiple machines.
My project uses celery to assign user requests passing to a web framework to different machines and then returns the result.
I read the documentation but there it doesn't mention how to set up multiple ma... | How to set up celery workers on separate machines? | 1.2 | 0 | 0 | 26,305 |
10,262,114 | 2012-04-21T19:10:00.000 | 7 | 1 | 0 | 1 | python,scripting,programming-languages,lua | 10,262,395 | 5 | false | 0 | 0 | Lua strings are encoding-agnostic. So, yes, you can write unicode strings in Lua scripts. If you need pattern matching, then the standard Lua string library does not support unicode classes. But plain substring search works. | 1 | 2 | 0 | I need to script my app (not a game) and I have a problem, choosing a script lang for this.
Lua looks fine (actually, it is ideal for my task), but it has problems with unicode strings, which will be used.
Also, I thought about Python, but I don't like It's syntax, and it's Dll is too big for me ( about 2.5 Mib).
Pytho... | Choosing Scripting lang | 1 | 0 | 0 | 492 |
10,264,905 | 2012-04-22T03:10:00.000 | 2 | 0 | 0 | 0 | python,flask | 10,269,311 | 1 | false | 1 | 0 | I figured it's probably not possible.
It's not possible for the server to receive the entire request as it has to terminate the connection once the max_content_length threshold has been passed, discarding any other form data that would have been sent after the file upload. The server resets the connection with a HTTP 4... | 1 | 2 | 0 | I've read through the docs and Googled my problem, but I don't seem to be able to figure out a way to handle errors in Flask without terminating the request and displaying an error page.
The error I want to handle is werkzeug.exceptions.RequestEntityTooLarge which is raised when a file upload exceeds the specified limi... | Capturing errors in Flask but continuing with the request as normal | 0.379949 | 0 | 0 | 327 |
10,265,351 | 2012-04-22T04:56:00.000 | 0 | 1 | 1 | 0 | python | 10,265,367 | 2 | false | 0 | 0 | It comes with the book "Python Scripting for Computational Science". | 2 | 0 | 0 | I need the python moduel py4cs, but I cannot find it anywhere, it is not on pypi or anywhere else. Please Help. Thanks! | Where to find a python module, py4cs? | 0 | 0 | 0 | 186 |
10,265,351 | 2012-04-22T04:56:00.000 | 1 | 1 | 1 | 0 | python | 23,199,828 | 2 | false | 0 | 0 | It is a set of tools useful for scientific programming in Python. Initially, it was distributed as py4cs only with purchase of the book by Hans Petter Langtangen. It is now called scitools and is widely available. | 2 | 0 | 0 | I need the python moduel py4cs, but I cannot find it anywhere, it is not on pypi or anywhere else. Please Help. Thanks! | Where to find a python module, py4cs? | 0.099668 | 0 | 0 | 186 |
10,265,506 | 2012-04-22T05:32:00.000 | 0 | 0 | 0 | 1 | python,twisted | 10,267,334 | 1 | false | 0 | 0 | You might want to consider running an established load-balancing reverse proxy such as HAProxy or nginx, since it will be the weak point of your system. If you have a bug in your reverse proxy/load balancer, everything goes down. You could also handle SSL at the proxy so your twisted application servers don't need hand... | 1 | 0 | 0 | I'm looking for a way implement a reverseProxy to copies of (Twisted) server processes. I'm think of a setup where the business logic is run in copies to allow for easy maintenance and upgrade, and stores shared data in a database and perhaps memcached.
I saw the reverseProxy class in twisted.web, but I don't think thi... | TCP reverse proxy to copies of Twisted business logic processes | 0 | 0 | 0 | 382 |
10,267,841 | 2012-04-22T12:14:00.000 | 2 | 0 | 1 | 0 | python,for-loop,arraylist,operators,boolean | 10,267,873 | 6 | false | 0 | 0 | As you wrote it, python evaluates ('.png' or '.jpg' or 'jpeg'), and compares i[-4:] to the result.
What you probably want is what @ThiefMaster suggests: the in operator. | 1 | 1 | 0 | I am trying to populate a list called images with files that have the extensions '.png', '.jpg' or 'jpeg' in a one line for loop. I tried this by using the logical or operator but that only resulted in an empty list.
images = [i for i in os.listdir('.') if i[-4:] == ('.png' or '.jpg' or 'jpeg')]
How do I check to see ... | Python logical or operator acting strange | 0.066568 | 0 | 0 | 335 |
10,268,189 | 2012-04-22T13:09:00.000 | 0 | 1 | 1 | 0 | python,unit-testing,nose,distribute,python-2to3 | 10,294,908 | 1 | true | 0 | 0 | OK, I did some more lookup and I found that at least in nose there is a custom script that adds this command. So I will probably have to copy this idea if I want to have tests for py3k. | 1 | 0 | 0 | When I was reading examples for testing a package in multiple pythons with tox I found about a command "build_tests" that would put (2to3'd) test files in build/ directory. I could also google it in some projects' tox.ini files and some gentoo ebuilds, but I still don't know which package installs this command. I have ... | Where to find build_tests command? | 1.2 | 0 | 0 | 82 |
10,269,245 | 2012-04-22T15:28:00.000 | 0 | 0 | 0 | 1 | python,eclipse,pydev | 10,273,751 | 1 | true | 0 | 0 | I got it. When I was creating a file, I needed to specify the .py extension. After doing this, the file ran. | 1 | 1 | 0 | This is my first time using Eclipse, so I think it must be some newbie configuration error. However, I can not sort it out, so I hope one of you might be able to help me.
This is what I did:
Installed Python 2.7
Installed EasyEclipse for Python 1.3.1
Went to Window>Preferences>Pydev>Interpreter-Python and selected C:\... | Trying to Run a Python script using EasyEclipse for Python, get error "The selection cannot be launched, and there are no recent launches." | 1.2 | 0 | 0 | 2,868 |
10,270,331 | 2012-04-22T17:35:00.000 | -1 | 0 | 1 | 0 | python,html,regex,markdown,markup | 10,270,412 | 2 | false | 0 | 0 | Regular expressions, of course! If still haven't done so, learn it. After you are done, you will find it hard to imagine how you got along without it. The samples you show are simple with regular expressions. For example, an asterisk, then a space then a word is expressed as:
\*\s\w+
Nothing else but regular expression... | 1 | 1 | 0 | This question may have been asked in a different way, if so please point it to me. I just couldn't find it among my search results.
I would like to parse text for mark-ups, like those here on SO.
eg. * some string for bullet list
eg. *some string* for italic text
eg. &some string& for a URL
eg. &some string&specifi... | What is the most efficient way to trace markups in a string? | -0.099668 | 0 | 0 | 102 |
10,273,186 | 2012-04-22T23:49:00.000 | 6 | 0 | 1 | 0 | python,copy | 10,273,201 | 2 | true | 0 | 0 | The right is evaluated first, placed into a temporary variable, and x is re-assigned to the temp variable. You never see it, of course. | 1 | 4 | 0 | It copies a list right? but in the code I'm looking at its x = x[:] which I don't understand. How can both copies be called the same thing? | How does [:] work in python? | 1.2 | 0 | 0 | 388 |
10,274,231 | 2012-04-23T02:45:00.000 | 12 | 0 | 1 | 1 | python,listdir | 10,274,338 | 1 | true | 0 | 0 | I personally find the division between os and os.path to be a little inconsistent. According to the documentation, os.path should just be an alias to a module that works with paths for a particular platform (i.e., on OS X, Linux, and BSD you'll get posixpath, on Windows or ancient Macs you'll get something else).
>>>... | 1 | 2 | 0 | os.path module seems to be the default module for all path related functions. Yet, the listdir() function is part of the os module and not os.path module, even though it accepts a path as its input. Why has this design decision been made ? | Why is the listdir() function part of os module and not os.path? | 1.2 | 0 | 0 | 370 |
10,279,943 | 2012-04-23T11:47:00.000 | 0 | 0 | 1 | 0 | python-2.7 | 10,595,746 | 1 | false | 0 | 0 | Start with the example from the python library documentation for os.walk it is close to what you need. Test the directorynames and filenames with os.path.islink to seperate the dirs/files from the links. Keep three counters in the local environment, one for each of the things you want to count. | 1 | 0 | 0 | I need the Python code to recursively search through a given path and return the number of files, folders and symbolic links within the location passed in? It should just do the search of the directory once and then increment the value of num of files, num of dirs, num of symbolic links as it is executed. It shouldn't ... | File, folder and symbolic link recursive count using Python | 0 | 0 | 0 | 607 |
10,282,132 | 2012-04-23T14:05:00.000 | 4 | 1 | 1 | 0 | python,perl,bash,sed,awk | 10,282,359 | 3 | false | 0 | 0 | grep '\$NT\$'filename
If there might be other occurrences of $NT$ outside the field you're looking for, you could be more specific - this will find only lines that have it in the second colon-delimited field:
awk -F: '$2 ~ /\$NT\$/'filename | 1 | 0 | 0 | I am attempting to write a script that will pull out NTLM hashes from a text file that contains about 500,000 lines of data. Not all accounts contain hashes and I only need the ones that do contain hashes.
Here is a sample of what the data looks like:
Mango Chango A (a):$NT$547e2494658ca345d3847c36cf1fsef8:::
There ... | Script to pull hashes out of large text file | 0.26052 | 0 | 0 | 575 |
10,282,347 | 2012-04-23T14:17:00.000 | 1 | 0 | 0 | 0 | python,django,desktop-application,web-frameworks | 10,285,038 | 3 | false | 1 | 0 | This might not fit with how your users use your application but one option would be to make a Linux virtual machine (Virtualbox supports most common operating systems as hosts) and distribute that instead.
This would give you a single target to develop against and, as a bonus if you looked into the update mechanism of ... | 1 | 5 | 0 | I'm using wxPython since about 2 years for several small scientific programs which I distribute to many Colleagues. I like wxPython and I'm already very familiar with it but there are few things which drive me crazy (not because of wxPython, actually I would like to continue to use it):
1) I have many users on differen... | Python Desktop Applications | 0.066568 | 0 | 0 | 3,254 |
10,284,847 | 2012-04-23T16:55:00.000 | 6 | 0 | 1 | 0 | python,latex,matplotlib | 44,506,534 | 4 | false | 0 | 0 | Quick solutions
plt.annotate("I am \n"+r"$\frac{1}{2}$"+"\n in latex math environment", xy=(0.5, 0.5)) | 1 | 24 | 0 | I have a very basic question : how to do a line break with matplotlib in python with an "annotate" command. I tried "\" and "\n" but it does not work. And how to do this for a "Latex" annotation and for a normal text annotation ?
Thank you very much. | Python : Matplotlib annotate line break (with and without latex) | 1 | 0 | 0 | 40,716 |
10,285,748 | 2012-04-23T17:59:00.000 | 0 | 1 | 1 | 0 | python | 10,285,800 | 3 | false | 0 | 0 | If all the arguments are known ahead, use an explicit argument list, optionally with default values, like def abc(arg1="hello", arg2="world",...). This will make the code most readable.
When you call the function, you can use either abd("hello", "world") or abc(arg1="hello", arg2="world"). I use the longer form if ther... | 1 | 0 | 0 | I am creating a module in python that can take multiple arguments. What would be the best way to pass the arguments to the definition of a method?
def abc(arg):
...
abc({"host" : "10.1.0.100", "protocol" : "http"})
def abc(host, protocol):
...
abc("10.1.0.100", "http")
def abc(**kwargs):
...
abc(ho... | What is the best way to pass multiple parameters to class init in python? | 0 | 0 | 0 | 1,331 |
10,287,853 | 2012-04-23T20:34:00.000 | 0 | 1 | 0 | 1 | python,ruby,usb,native | 10,289,020 | 1 | false | 0 | 0 | Well it is definitely possible; I don't know what the equivalent is in rubygems by pyUSB is a easy to use module you can leverage to do this and then there are numerous http libraries for python.
As for making it self contained, it is possible but not ideal. py2exe is a program that basically takes a copy of the pytho... | 1 | 1 | 0 | I'd like to develop an app that runs natively (self-contained executable) for both Mac and Windows that will detect/poll for a USB device being inserted and send an HTTP call as a result. I'm mainly a Ruby programmer, so ideally I could do this with a combination of Macruby/IronRuby and shared libraries, but it's looki... | Cross-platform USB development for Mac/Windows - possible with Ruby/Python? | 0 | 0 | 0 | 528 |
10,288,488 | 2012-04-23T21:18:00.000 | 0 | 1 | 1 | 0 | java,c++,python,eclipse,visual-studio | 10,288,556 | 1 | false | 0 | 0 | To my knowledge, Eclipse has no support for multidebugger debugging. However, it might be possible to debug the same workspace in many Eclipse instance at the same time. Simply launch the debugger for each language separately by attaching to them as you said. | 1 | 3 | 0 | I have a software that uses multiple languages, which are all available as eclipse plugins (java, c++, python). The exes call each other. I was wondering if there is a way I could debug all these languages using eclipse. I have the sources for all of them, and all of them are projects in eclipse, but so far they work i... | multi language IDE | 0 | 0 | 0 | 240 |
10,288,554 | 2012-04-23T21:24:00.000 | 2 | 0 | 0 | 0 | python,python-3.x,tkinter | 10,289,415 | 3 | false | 0 | 1 | I've run into that exact same problem a couple times jaccarmac, and to my knowledge there is no way to find the width of a string of characters. Really the only way is to use the winfo_ commands: width, height, geometry. However, it kind of sounds like you just want to make sure that all of the text is displayed if you... | 2 | 1 | 0 | I am trying to create a roguelike using the Text widget.
I have figured out a few things, namely that I can set the size of the widget using width and height options and that I can find the pixel height or width of said widget. However, what I want to do is have the widget resizable (pack(expand="yes", fill="both")) bu... | Finding The Current Size Of A tkinter.Text Widget | 0.132549 | 0 | 0 | 1,580 |
10,288,554 | 2012-04-23T21:24:00.000 | 0 | 0 | 0 | 0 | python,python-3.x,tkinter | 10,290,058 | 3 | true | 0 | 1 | There is no way to automatically get the width in characters, but it's easy to calculate, assuming you're using a fixed width font. One way to do this is to use the font_measure method of a font object. Use font_measure to get the width of a '0' (or any other character for that matter; I think tk users zero internally,... | 2 | 1 | 0 | I am trying to create a roguelike using the Text widget.
I have figured out a few things, namely that I can set the size of the widget using width and height options and that I can find the pixel height or width of said widget. However, what I want to do is have the widget resizable (pack(expand="yes", fill="both")) bu... | Finding The Current Size Of A tkinter.Text Widget | 1.2 | 0 | 0 | 1,580 |
10,295,327 | 2012-04-24T09:37:00.000 | 0 | 0 | 1 | 0 | python,locale,string-conversion | 10,295,512 | 1 | true | 0 | 0 | You can make some assumptions on which character is the thousands separator and which is the decimal point. However, there is a case where you cannot know for sure what do do:
Look for the last character that is . or ,. If it occurs more than once, the number does not have a decimal point and that character is the tho... | 1 | 0 | 0 | I need to convert string to float, but there can be different input string formats, such as '1234,5' or '1234.5' or '1 234,5' or '1,234.5' or whatever. And I can not change locale decimal pointer or thousands separator, because I may not know what data I will get in advance.
Is there a way or method or library to parse... | Locale-indepenent string to float conversion in python | 1.2 | 0 | 0 | 638 |
10,295,384 | 2012-04-24T09:41:00.000 | 1 | 0 | 0 | 0 | python,checkbox,tkinter,message | 10,296,668 | 1 | true | 0 | 1 | No, the standard dialogs don't support that.
If you want such a feature you'll have to build your own dialog out of a Toplevel window and other widgets. | 1 | 2 | 0 | I'm creating message boxes in Tkinter using tkMessageBox.showwarning.
Does Tkinter let you insert a sort of checkbox with the message that says, for example, "do not show again" so when selected the message won't appear the next time? | "do not show message again" checkbox in Tkinter warning message | 1.2 | 0 | 0 | 410 |
10,295,954 | 2012-04-24T10:16:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine | 10,296,008 | 1 | true | 1 | 0 | Try calling python appcfg.py update myapp/ | 1 | 0 | 0 | I am new to google app engine and python. I have created an application in python with the help of google app engine.
i am using cmmand 'appcfg.py update myapp/' from command prompt to update live code. this command was working perfectly but suddenly it stops working. Now every time i run this command it opens up the a... | Updating app engine project code | 1.2 | 0 | 0 | 270 |
10,298,104 | 2012-04-24T12:46:00.000 | 4 | 0 | 1 | 0 | python,windows-installer,pywinauto | 10,298,383 | 1 | false | 0 | 0 | You need to launch "msiexec.exe" and pass the MSI as a command line parameter for it to be installed. You cannot launch directly an MSI as you would launch an EXE file.
Example: msiexec.exe /i [MSI_path] | 1 | 2 | 0 | I am looking at using pywinauto in python to automate the installation of a Windows MSI installer for testing purposes.
When I try to launch the MSI through the application.start I get the following error:
"Error returned by CreateProcess: [Error 193] "
Is it possible to even do this, or do I need to launch the MSI fir... | Using pywinauto to automate an MSI installer | 0.664037 | 0 | 0 | 1,186 |
10,301,071 | 2012-04-24T15:27:00.000 | 2 | 0 | 1 | 0 | python,python-idle | 31,353,166 | 8 | false | 0 | 0 | I may not be a Python expert/guru yet but this question is a user-experience / usability question more than anything. Some might say "Yeah, PEP 8 style guide... blah blah blah" but if I have the IDLE window a certain size (let's say small width), there's no reason I as a user shouldn't be able to scroll. It's simply ... | 3 | 2 | 0 | I am using IDLE to learn Python 2.7 on Windows 7.
The Vertical scroll bar works fine but I cannot find
a way to activate the Horizontal scroll bar.
Is there a horizontal scroll bar in Python's IDLE?
Thanks | Is there a horizontal scroll bar in python's idle? | 0.049958 | 0 | 0 | 12,406 |
10,301,071 | 2012-04-24T15:27:00.000 | 2 | 0 | 1 | 0 | python,python-idle | 29,691,434 | 8 | false | 0 | 0 | I'm using IDLE 2.7.3, Windows 7, and I can scroll horizontally by holding down the center mouse button/scroll wheel, and "dragging" around the cursor like that. | 3 | 2 | 0 | I am using IDLE to learn Python 2.7 on Windows 7.
The Vertical scroll bar works fine but I cannot find
a way to activate the Horizontal scroll bar.
Is there a horizontal scroll bar in Python's IDLE?
Thanks | Is there a horizontal scroll bar in python's idle? | 0.049958 | 0 | 0 | 12,406 |
10,301,071 | 2012-04-24T15:27:00.000 | 1 | 0 | 1 | 0 | python,python-idle | 10,301,180 | 8 | false | 0 | 0 | No, the text scrolls horizontally based on where the insertion point or selection is. | 3 | 2 | 0 | I am using IDLE to learn Python 2.7 on Windows 7.
The Vertical scroll bar works fine but I cannot find
a way to activate the Horizontal scroll bar.
Is there a horizontal scroll bar in Python's IDLE?
Thanks | Is there a horizontal scroll bar in python's idle? | 0.024995 | 0 | 0 | 12,406 |
10,301,589 | 2012-04-24T15:58:00.000 | 4 | 0 | 1 | 0 | python,list,dictionary,tuples | 10,301,663 | 6 | false | 0 | 0 | A dictionary value can't contain two tuples just by themselves. Each dictionary key maps to a single value, so the only way you can have two separate tuples associated with that key is for them to be themselves contained within a tuple or list: {'Key1':[(1.000,2.003,3.0029),(2.3232,13.5232,1325.123)]} - note the extra ... | 1 | 4 | 0 | I've been trying to figure out how to add multiple tuples that contain multiple values to to a single key in a dictionary. But with no success so far. I can add the values to a tuple or list, but I can't figure out how to add a tuple so that the key will now have 2 tuples containing values, as opposed to one tuple with... | How do you add multiple tuples(lists, whatever) to a single dictionary key without merging them? | 0.132549 | 0 | 0 | 48,959 |
10,301,687 | 2012-04-24T16:04:00.000 | 0 | 1 | 1 | 0 | python,compare | 10,301,739 | 4 | false | 0 | 0 | Don't know anything about python, but: how about sorting the file A into a particular order? Then you can go through file B line by line and do a binary search - more efficient. | 1 | 0 | 0 | I got txt file A with 300, 000+ lines and txt file B with 600, 000+ lines. Now what I want to do is to sift through file A line by line, if that line does not appear in file B then it will be appended to file C.
Well, the problem is if I program like what I said above, it literally takes ages to finish all the job. So... | What's the fastest way to find unique lines from huge file A as compared to huge file B using python? | 0 | 0 | 0 | 477 |
10,302,298 | 2012-04-24T16:45:00.000 | 9 | 0 | 1 | 1 | python,debugging | 10,302,538 | 1 | true | 0 | 0 | The bdb module implements the basic debugger facilities for pdb.Pdb, which is the concrete debugger class that is used to debug Python scripts from a terminal.
Unless you're planning to write your own debugger user interface, you shouldn't need to use anything from bdb. | 1 | 8 | 0 | I was looking through the Python standards libs and saw BDB the debugger framework. What is it for and can I get additional value from it?
At the moment I use Eclipse/PyDev with the internal debugger which also supports conditionals breakpoints. Can I get something new from BDB? | What is BDB for in Python? | 1.2 | 0 | 0 | 2,244 |
10,302,806 | 2012-04-24T17:18:00.000 | 0 | 0 | 1 | 0 | python,pyinstaller | 10,303,044 | 3 | false | 0 | 0 | Try downloading Pyinstaller's latest development code. There they trying to implement GUI toolkit for building executables. | 1 | 1 | 0 | My Problem is the following:
I want to create an script that can create other executables. These new executables have to be standalone, so they don't require any DLL's, etc.
I know this is possible with PyInstaller, but only from console/command line.
So essentially, what I want to do is make a python script that impor... | Is there a way to use PyInstaller inside another .py file? | 0 | 0 | 0 | 1,598 |
10,304,280 | 2012-04-24T18:56:00.000 | 1 | 0 | 0 | 0 | python,machine-learning,scikits,scikit-learn | 10,308,680 | 1 | true | 0 | 0 | We don't have that yet. You have to read the docstrings of the individual classes for now.
Anyway, non linear models do not tend to work better than linear model for high dim sparse data such as text documents (and they can overfit more easily). | 1 | 2 | 1 | I'm getting a memory error trying to do KernelPCA on a data set of 30.000 texts. RandomizedPCA works alright. I think what's happening is that RandomizedPCA works with sparse arrays and KernelPCA don't.
Does anyone have a list of learning methods that are currently implemented with sparse array support in scikits-lear... | python, scikits-learn: which learning methods support sparse feature vectors? | 1.2 | 0 | 0 | 691 |
10,304,363 | 2012-04-24T19:01:00.000 | 1 | 0 | 0 | 0 | python,django,web-deployment,source-code-protection | 10,304,687 | 4 | false | 1 | 0 | There is almost no scenario where your hosting provider would be interested in your source code. The source code of most websites just isn't worth very much.
If you really feel it is necessary to protect your source code, the best thing to do is serve it from a system that you own and control physically and have exclu... | 4 | 3 | 0 | I have picked up python/django just barely a year. Deployment of django site is still a subject that I have many questions about, though I have successfully manual deployed my site. One of my biggest questions around deployment is what measures can I take to safeguard the source code of my apps, including passwords in ... | What measures can I take to safeguard the source code of my django site from others? | 0.049958 | 0 | 0 | 2,223 |
10,304,363 | 2012-04-24T19:01:00.000 | 1 | 0 | 0 | 0 | python,django,web-deployment,source-code-protection | 10,304,555 | 4 | false | 1 | 0 | If someone has the privileges to access anything/anywhere on the server you can't do much, because what you can do others can do too, you can try some way of obfuscation but that will not work. Only solution is NOT to use such shared repository.
Edit: options
Keep working with shared repository if your data is not ver... | 4 | 3 | 0 | I have picked up python/django just barely a year. Deployment of django site is still a subject that I have many questions about, though I have successfully manual deployed my site. One of my biggest questions around deployment is what measures can I take to safeguard the source code of my apps, including passwords in ... | What measures can I take to safeguard the source code of my django site from others? | 0.049958 | 0 | 0 | 2,223 |
10,304,363 | 2012-04-24T19:01:00.000 | 0 | 0 | 0 | 0 | python,django,web-deployment,source-code-protection | 10,311,535 | 4 | false | 1 | 0 | Protecting source code is not that important IMHO. I would just deploy compiled files and not worry too much about it.
Protecting your config (specially passwords) is indeed important. Temia's point is good. | 4 | 3 | 0 | I have picked up python/django just barely a year. Deployment of django site is still a subject that I have many questions about, though I have successfully manual deployed my site. One of my biggest questions around deployment is what measures can I take to safeguard the source code of my apps, including passwords in ... | What measures can I take to safeguard the source code of my django site from others? | 0 | 0 | 0 | 2,223 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.