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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
12,272,856 |
2012-09-04T23:59:00.000
| 9 | 0 | 1 | 0 |
python,ruby
| 12,272,872 | 7 | true | 0 | 0 |
When you do something like "hi".print(), you are implying that the string object "hi" has a method print. This is not the case. Instead, print is a function that takes a string (or other types) as input.
| 3 | 7 | 0 |
My understanding of the print() in both Python and Ruby (and other languages) is that it is a method on a string (or other types). Because it is so commonly used the syntax:
print "hi"
works.
So why doesn't "hi".print() in Python or "hi".print in Ruby work?
|
Why can't I "string".print()?
| 1.2 | 0 | 0 | 671 |
12,273,201 |
2012-09-05T00:55:00.000
| 2 | 0 | 1 | 0 |
python,regex
| 12,273,291 | 2 | false | 0 | 0 |
re.findall(pattern, string) will return a list with all matches for pattern in string. len(...) will return the number of items in a list.
| 1 | 0 | 0 |
I have a string and I need match that string with an sequence and determine the number of times the matched sequence is found in that sequence
But it has following conditions
Sequence can contain only ACGT valid chars so seq could be ACGTGTCTG
the string could be ACGnkG
where n could be replaced by A or G
k could be replaced by C or T
how can we find if the string matches the sequence by substituting valid values for n and k
Is there any regular expression ?
|
string matching with substitution using PYTHON
| 0.197375 | 0 | 0 | 118 |
12,274,060 |
2012-09-05T03:20:00.000
| 26 | 0 | 1 | 0 |
python
| 12,274,070 | 5 | true | 0 | 0 |
Python uses a linear list layout in memory so that indexing is fast (O(1)).
| 2 | 15 | 0 |
Just learning Python. Reading through the official tutorials. I ran across this:
While appends and pops from the end of list are fast, doing inserts or pops from the beginning of a list is slow (because all of the other elements have to be shifted by one).
I would have guessed that a mature language like Python would have all sorts of optimizations, so why doesn't Python [seem to] use linked lists so that inserts can be fast?
|
Does Python use linked lists for lists? Why is inserting slow?
| 1.2 | 0 | 0 | 6,808 |
12,274,060 |
2012-09-05T03:20:00.000
| 5 | 0 | 1 | 0 |
python
| 12,274,109 | 5 | false | 0 | 0 |
list is implemented as an arraylist. If you want to insert frequently, you can use a deque (but note that traversal to the middle is expensive).
Alternatively, you can use a heap. It's all there if you take the time to look at the docs.
| 2 | 15 | 0 |
Just learning Python. Reading through the official tutorials. I ran across this:
While appends and pops from the end of list are fast, doing inserts or pops from the beginning of a list is slow (because all of the other elements have to be shifted by one).
I would have guessed that a mature language like Python would have all sorts of optimizations, so why doesn't Python [seem to] use linked lists so that inserts can be fast?
|
Does Python use linked lists for lists? Why is inserting slow?
| 0.197375 | 0 | 0 | 6,808 |
12,274,600 |
2012-09-05T04:44:00.000
| 2 | 0 | 0 | 0 |
python,django,web
| 12,274,626 | 4 | false | 1 | 0 |
Easiest way to do that is to find a host online (such as pythonanywhere.com) to host your app on there, following their instructions, and your app will be online. They handle most of the issues with piggybacking a django project on a server.
| 1 | 3 | 0 |
I developed a simple Django/Python poll application(Following step by step tutorial from the Django Official Documentation). I used the in build server to test the application. Now, I want to host my application in the web. I heard WSGI is the best way to expose Python/Django application to the web? What would be the best way to expose Python/Django code into the web? Thank you
P.S: I already have a domain name and a shared web hosting from justhost.com. While I chat to their support, they told me that they support WSGI.
|
How to expose Django/Python application to the web?
| 0.099668 | 0 | 0 | 1,111 |
12,277,864 |
2012-09-05T09:02:00.000
| 1 | 0 | 1 | 0 |
python,csv
| 12,277,912 | 3 | false | 0 | 0 |
The Python csv module is only for reading and writing whole CSV files but not for manipulating them. If you need to filter data from file then you have to read it, create a new csv file and write the filtered rows back to new file.
| 1 | 8 | 1 |
how can I clear a complete csv file with python. Most forum entries that cover the issue of deleting row/columns basically say, write the stuff you want to keep into a new file. I need to completely clear a file - how can I do that?
|
python clear csv file
| 0.066568 | 0 | 0 | 41,353 |
12,285,858 |
2012-09-05T16:27:00.000
| 1 | 1 | 0 | 0 |
python,search,artificial-intelligence,computer-science,heuristics
| 12,287,399 | 5 | false | 0 | 0 |
A simple approach is to build the minimum spanning tree for your graph and do a (depth-first) walk over it, skipping nodes already visited.
This is proven to be no more than twice as long as the optimal TSP path. You can definitely do better with heuristics, but it's a starter (and easy to implement too).
| 1 | 4 | 0 |
My problem is the following:
I have an undirected graph. Each edge has a cost (or weight). One of the nodes is labelled S. I want to start from S and visit every node at least once. Visiting a node multiple times is allowed. Travelling along an edge multiple times is allowed, although that would make the solution more expensive -- travelling an edge with cost of 3 twice will add 6 to the cost of the total path. The graph has some "dead-end" nodes, so sometimes we have to travel an edge more than once.
What is a fast algorithm to do this? Is this a well known problem?
What I'm looking for:
Reasonably fast -- The relative size of the graph we are talking about here is order of 40 - 50 nodes. So the algorithm hopefully won't take longer than 10 - 15 seconds.
Reasonably optimal -- I'm not looking for absolute optimality. Any interesting heuristic to guide the search so that the solution will be near optimal is good enough.
I will be writing this in python. So if you know of any python implementation of the algorithm, that's best.
Thanks for any help.
|
What's a fast algorithm that can find a short path to traverse each node of a weighted undirected graph at least once?
| 0.039979 | 0 | 0 | 4,388 |
12,286,987 |
2012-09-05T17:45:00.000
| 1 | 0 | 0 | 1 |
python,google-app-engine,app-engine-ndb
| 21,434,751 | 1 | false | 1 | 0 |
This seems to happen if you have async operations in progress before you enter the ndb.toplevel function.
My guess is that this warns you that theses async operations will not be waited for at the end of the request. This could be an issue if you expected them to be included in your "toplevel" function and they are tasklets waiting for an operation to complete before executing some more.
| 1 | 4 | 0 |
I'm using Google App Engine NDB with a lot of async operations and yields. The console shows me this message:
tasklets.py:119] all_pending: clear set([Future 106470190 created by
dispatch(webapp2.py:570) for tasklet post(sync.py:387); pending])
Is this a warning of some sort? Should it be ignored? It doesn't cause any unusual behavior.
(sync.py is one of my files, but the other stuff aren't mine)
|
What does this console message mean in Google App Engine
| 0.197375 | 0 | 0 | 177 |
12,289,700 |
2012-09-05T21:00:00.000
| 0 | 0 | 0 | 0 |
python,selenium
| 60,626,053 | 5 | false | 1 | 0 |
I think username might be a variable in the python library you are using. Try calling it something else like Username1 and see if it works??
| 2 | 7 | 0 |
I'm trying to use Selenium for some app testing, and I need it to plug a variable in when filling a form instead of a hardcoded string. IE:
this works
name_element.send_keys("John Doe")
but this doesnt
name_element.send_keys(username)
Does anyone know how I can accomplish this? Pretty big Python noob, but used Google extensively to try and find out.
|
Passing variables through Selenium send.keys instead of strings
| 0 | 0 | 1 | 9,992 |
12,289,700 |
2012-09-05T21:00:00.000
| 1 | 0 | 0 | 0 |
python,selenium
| 47,662,083 | 5 | false | 1 | 0 |
Try this.
username = r'John Doe'
name_element.send_keys(username)
I was able to pass the string without casting it just fine in my test.
| 2 | 7 | 0 |
I'm trying to use Selenium for some app testing, and I need it to plug a variable in when filling a form instead of a hardcoded string. IE:
this works
name_element.send_keys("John Doe")
but this doesnt
name_element.send_keys(username)
Does anyone know how I can accomplish this? Pretty big Python noob, but used Google extensively to try and find out.
|
Passing variables through Selenium send.keys instead of strings
| 0.039979 | 0 | 1 | 9,992 |
12,290,336 |
2012-09-05T21:53:00.000
| 2 | 1 | 0 | 0 |
python,unit-testing,selenium-webdriver
| 12,290,574 | 5 | false | 1 | 0 |
Override fail() to generate the screenshot and then call TestCase.fail(self)?
| 1 | 12 | 0 |
I have some class-based unit tests running in python's unittest2 framework. We're using Selenium WebDriver, which has a convenient save_screenshot() method. I'd like to grab a screenshot in tearDown() for every test failure, to reduce the time spent debugging why a test failed.
However, I can't find any way to run code on test failures only. tearDown() is called regardless of whether the test succeeds, and I don't want to clutter our filesystem with hundreds of browser screenshots for tests that succeeded.
How would you approach this?
|
How to execute code only on test failures with python unittest2?
| 0.07983 | 0 | 0 | 1,958 |
12,290,694 |
2012-09-05T22:29:00.000
| 0 | 0 | 0 | 0 |
python,scrapy,portable-python
| 20,853,931 | 1 | false | 1 | 0 |
you can easily download scrapy executable, extract it with python, copy scrapy folder and content to c:\Portable Python 2.7.5.1\App\Lib\site-packages\ and you'll have scrapy in your portable python.
I just had my similar problem with SciKit this way.
| 1 | 1 | 0 |
I need to create a portable python install on a usb but also install the scrapy framework on it, so I can work on and run my spiders on any computer.
Has anyone else done this? Is it even possible?
If so how do you add scrapy onto the portable python usb and then run the spiders?
Thanks
|
How do you add the scrapy framework to portable python?
| 0 | 0 | 0 | 658 |
12,292,277 |
2012-09-06T02:42:00.000
| 4 | 0 | 0 | 0 |
python,session,sqlalchemy,session-state,pyramid
| 12,320,928 | 2 | true | 1 | 0 |
Unless you're being really careful, serializing the entire object into redis is going to cause problems. You're effectively treating it like a cache, so you have to be careful that those values are expired if the user changes something about themselves. You also have to make sure that all of the values are serializable (likely via pickle). You didn't specify whether this is a premature optimization so I'm going to say that it probably is and recommend that you just track the user id and reload his information when you need it from your database.
| 1 | 1 | 0 |
I have a few a few model classes such as a user class which is passed a dictionary, and wraps it providing various methods, some of which communicate with the database when a value needs to be changed. The dictionary itself is made from an sqlalchemy RowProxy, so all its keys are actually attribute names taken directly from the sql user table. (attributes include user_id, username, email, passwd, etc)
If a user is logged in, should I simply save this dictionary to a redis key value store, and simply call a new user object when needed and pass it this dictionary from redis(which should be faster than only saving a user id in a session and loading the values again from the db based on that user_id)?
Or should I somehow serialize the entire object and save it in redis? I'd appreciate any alternate methods of managing model and session objects that any of you feel would be better as well.
In case anyone is wondering I'm only using the sqlalchemy expression language, and not the orm. I'm using the model classes as interfaces, and coding against those.
|
How do I go about storing session objects?
| 1.2 | 1 | 0 | 241 |
12,292,723 |
2012-09-06T03:53:00.000
| 2 | 0 | 0 | 0 |
python,django,testing,twisted,twisted.web
| 12,486,382 | 1 | false | 0 | 0 |
When it comes to testing, you sould always use code, so that if you change something in the future or if you have to fix a bug, testing your changes will be a matter of seconds:
python mytestsuite.py
| 1 | 0 | 0 |
Are there any Tools / Chrome plugins like "Advanced REST Plugin" for Chrome that I can use to Test Twisted RPC JSON calls?
Or do I have to write some Python code to do this?
|
Tools to Test RPC twisted calls?
| 0.379949 | 0 | 1 | 76 |
12,293,603 |
2012-09-06T05:39:00.000
| -2 | 0 | 1 | 0 |
python,lxml,scrapy
| 12,313,354 | 1 | false | 0 | 0 |
maybe you need to install libxml2-dev and libxslt-dev
in ubuntu do
sudo apt-get install libxml2-dev libxslt-dev
| 1 | 1 | 0 |
I have tried several ways to install lxml (actually I need to install Scrapy, which depend on lxml installed), easy_install, pip, build from source, but they didn't work out.
Now I use: STATIC_DEPS=true easy_install lxml. But got the following error:
/usr/bin/ld:
/tmp/easy_install-mptFTT/lxml-3.0alpha2/build/tmp/libxml2/lib/libexslt.a(exslt.o):
relocation R_X86_64_32 against `a local symbol' can not be used when
making a shared object; recompile with -fPIC
/tmp/easy_install-mptFTT/lxml-3.0alpha2/build/tmp/libxml2/lib/libexslt.a:
could not read symbols: Bad value
Not sure what does the error mean. I use Python 2.7.3.
|
easy_install lxml error on Redhat
| -0.379949 | 0 | 0 | 954 |
12,293,643 |
2012-09-06T05:43:00.000
| 1 | 0 | 1 | 0 |
python,twisted
| 12,297,692 | 1 | false | 0 | 0 |
The session is basically a dictionary. Adapters are the values you can put into it, and interfaces are the keys you use with them.
Subclassing comes with a bunch of problems, none of them specific to the web or session state handling. It mixes lots of implementation concerns together that don't need to be mixed. A dictionary, on the other hand, is just a collection of state - exactly what is called for when it comes to tracking the state needed for a session.
Your alternate idea, to "just subclass or wrap the session and use this subclass to generate sessions" is very general and somewhat ambiguous, so I can't explain in detail why the current system might be better than it. If you want to describe your idea in complete detail (perhaps by providing an implementation), then perhaps someone can critique it.
| 1 | 1 | 0 |
It feels to me that using components/adapters is just adding extra bloat to handling sessions without much obvious benefit. It feels simpler to just subclass or wrap the session and use this subclass to generate sessions.
Maybe I am not seeing some obvious benefits of using components and adapters, so if anyone could explain this to me, please do.
|
What's the benefit of using Adaptors over subclassing/wrapping Session in twisted.web?
| 0.197375 | 0 | 0 | 89 |
12,295,834 |
2012-09-06T08:20:00.000
| 4 | 0 | 0 | 0 |
php,javascript,python,xml,perl
| 12,295,930 | 1 | true | 1 | 0 |
You could try to reverse engineer the javascript code. Maybe it's making an ajax request to a service, that delivers the data as json. Use your browsers developer tools/network tab to see what's going on.
| 1 | 1 | 0 |
I need to export a website(.html page) to a XML file. The website contains a table with some data which i require for using in my web project. The table in the website is formed using some javascript, so i cannot get the data by getting the page source. Please tell me how I can export the table in the website to a XML file using php/python/javascript/perl.
|
Export a website to an XML Page
| 1.2 | 0 | 1 | 2,036 |
12,296,563 |
2012-09-06T09:03:00.000
| 1 | 0 | 0 | 0 |
python,excel,win32com
| 13,086,152 | 4 | false | 0 | 0 |
Documentation for win32com is next to non-existent as far I know. However, I use the following method to understand the commands.
MS-Excel
In Excel, record a macro of whatever action you intend to, say plotting a chart. Then go to the Macro menu and use View Macro to get the underlying commands. More often than not, the commands used would guide you to the corresponding commands in python that you need to use.
Pythonwin
You can use pythonwin to browse the underlying win32com defined objects (in your case Microsoft Excel Objects). In pythonwin (which can be found at \Lib\site-packages\pythonwin\ in your python installation), go to Tools -> COM Makepy Utility, select your required Library (in this case, Microsoft Excel 14.0 Object Library) and press Ok. Then when the process is complete, go to Tools -> COM Browser and open the required library under Registered Libraries. Note the ID no. as this would correspond to the source file. You can browse the various components of the library in the COM Browser.
Source
Go to \Lib\site-packages\win32com\ in your python installation folder. Run makepy.py and choose the required library. After this, the source file of the library can be found at \Lib\site-packages\win32com\gen_py . It is one of those files with the wacky name. The name corresponds to that found in Pythonwin. Open the file, and search for the commands you saw in the Excel Macro. (#2 and #3 maybe redundant, I am not sure)
| 1 | 0 | 0 |
Hi I intend to draw a chart with data in an xlsx file.
In order to keep the style, I HAVE TO draw it within excel.
I found a package named win32com, which can give a support to manipulate excel file with python on win32 platform, but I don't know where is the doc.....
Another similar question is how to change the style of cells, such as font, back-color ?
So maybe all I wanna know is the doc, you know how to fish is more useful than fishes.... and an example is better.
|
How to draw a chart with excel using python?
| 0.049958 | 1 | 0 | 2,868 |
12,297,847 |
2012-09-06T10:17:00.000
| 3 | 0 | 0 | 0 |
python,sqlalchemy,cassandra
| 12,302,894 | 3 | false | 0 | 0 |
playOrm supports JOIN on noSQL so that you CAN put relational data into noSQL but it is currently in java. We have been thinking of exposing a S-SQL language from a server for programs like yours. Would that be of interest to you?
The S-SQL would look like this(if you don't use partitions, you don't even need anything before the SELECT statement piece)...
PARTITIONS t(:partId) SELECT t FROM TABLE as t INNER JOIN t.security as s WHERE s.securityType = :type and t.numShares = :shares")
This allows relational data in a noSQL environment AND IF you partition your data, you can scale as well very nicely with fast queries and fast joins.
If you like, we can quickly code up a prototype server that exposes an interface where you send in S-SQL requests and we return some form of json back to you. We would like it to be different than SQL result sets which was a very bad idea when left joins and inner joins are in the picture.
ie. we would return results on a join like so (so that you can set a max results that actually works)...
tableA row A - tableB row45
- tableB row65
- tableB row 78
tableA row C - tableB row46
- tableB row93
NOTICE that we do not return multiple row A's so that if you have max results 2 you get row A and row C where as in ODBC/JDBC, you would get ONLY rowA two times with row45 and row 65 because that is what the table looks like when it is returned (which is kind of stupid when you are in an OO language of any kind).
just let playOrm team know if you need anything on the playOrm github website.
Dean
| 1 | 6 | 0 |
I use Python with SQLAlchemy for some relational tables. For the storage of some larger data-structures I use Cassandra. I'd prefer to use just one technology (cassandra) instead of two (cassandra and PostgreSQL). Is it possible to store the relational data in cassandra as well?
|
Can I use SQLAlchemy with Cassandra CQL?
| 0.197375 | 1 | 0 | 8,349 |
12,298,811 |
2012-09-06T11:12:00.000
| 2 | 1 | 0 | 0 |
python,openerp
| 12,298,831 | 2 | true | 0 | 0 |
To debug your Openerp+python code in eclipse, start eclipse in debug perspective and follow the given steps:
1: Stop your openERP running server by pressing "ctr+c".
2: In eclipse go to Menu "Run/Debug Configurations". In configuration window under "Python Run", create new debug configuration(Double click on 'Python Run').
3: After creating new debug configuration follow the given steps:
3.1: In "Main" tab under "Project", select the "server" project or folder (in which Openerp Server resides) from your workspace.
3.2: Write location of 'openerp-server' under "Main Module".
Ex: ${workspace_loc:server/openerp-server}.
3.3: In "Arguments" tab under "Program Arguments", click on button "Variables" and new window will appear.
3.4: Then create new "Variable" by clicking on "Edit Variables" button and new window will appear.
3.5: Press on "New" button and give your addons path as value.
Ex: --addons ../addons,../your_module_path
3.6: Press Ok in all the opened windows and then "Apply".
4: Now into "PyDev Package Explorer" view go to 6.1/server and right click on "openerp-server" file, Select 'Debug As --> Python Run'.
5: Now in "Console" you can see your server has been started.
6: Now open your .py file which you want to debug and set a break-point.
7: Now start your module's form from 'gtk' or 'web-client' and execution will stop when execution will reach to break-point.
8: Now enjoy by debugging your code by pressing "F5, F6, F7" and you can see value of your variables.
| 1 | 2 | 0 |
how can I debug python code in to the eclipse.if it will be done then we face less effort and fast do our work.can any one tell me???
|
how can i debug openerp code in to the eclipse
| 1.2 | 0 | 0 | 3,051 |
12,299,602 |
2012-09-06T11:58:00.000
| 2 | 0 | 0 | 0 |
python,html
| 12,299,906 | 2 | false | 1 | 0 |
I won't go so far as to say it's impossible, but this is an extremely tall order. The reason is that an HTML parser will usually not attempt to preserve HTML-irrelevant characters like line endings, but anything other than an HTML parser will not be very good at telling what is or isn't a tag according to the strict definitions of the format.
If you really need to do this and do this well, I would look at dissecting an existing python HTML parser and modifying it to your needs. This is a fairly advanced programming project. It would be better to seriously consider why you need to do this and if this is strictly the right thing to do.
Edit: An additional problem is that it's not really possible to parse HTML without checking the validity of the HTML and either reforming it to be valid, or choking on invalid HTML. So if you potentially have validity problems with your HTML, your result is undefined. For instance, if the input includes a grossly invalid tag like <font="courier">, would that be considered an HTML tag for the purposes of this exercise, or just a string of parser-killing characters? Likewise with a valid-looking tag in the wrong place in the document.
| 1 | 0 | 0 |
How can I convert all HTML tags and attributes in a string to lowercase in python? Nothing else should be changed, e.g. attribute values should not be changed, no indentation, line wrapping etc.
Sorry if it's too obvious :)
|
How to convert all HTML tags and attributes in a string to lowercase in python?
| 0.197375 | 0 | 0 | 807 |
12,302,155 |
2012-09-06T14:16:00.000
| 0 | 1 | 0 | 0 |
python,buffer,pyserial
| 45,513,398 | 4 | false | 1 | 0 |
pySerial uses the native OS drivers for serial receiving. In the case of Windows, the size of the input driver is based on the device driver.
You may be able to increase the size in your Device Manager settings if it is possible, but ultimately you just need to read the data in fast enough.
| 2 | 10 | 0 |
I want to communicate with the phone via serial port. After writing some command to phone, I used ser.read(ser.inWaiting()) to get its return value, but I always got total 1020 bytes of characters, and actually, the desired returns is supposed to be over 50KB.
I have tried to set ser.read(50000), but the interpreter will hang on.
How would I expand the input buffer to get all of the returns at once?
|
How to expand input buffer size of pyserial
| 0 | 0 | 0 | 21,578 |
12,302,155 |
2012-09-06T14:16:00.000
| 1 | 1 | 0 | 0 |
python,buffer,pyserial
| 12,920,183 | 4 | false | 1 | 0 |
I'm guessing that you are reading 1020 bytes because that is all there is in the buffer, which is what ser.inWaiting() is returning. Depending on the baud rate 50 KB may take a while to transfer, or the phone is expecting something different from you. Handshaking?
Inspect the value of ser.inWaiting, and then the contents of what you are receiving for hints.
| 2 | 10 | 0 |
I want to communicate with the phone via serial port. After writing some command to phone, I used ser.read(ser.inWaiting()) to get its return value, but I always got total 1020 bytes of characters, and actually, the desired returns is supposed to be over 50KB.
I have tried to set ser.read(50000), but the interpreter will hang on.
How would I expand the input buffer to get all of the returns at once?
|
How to expand input buffer size of pyserial
| 0.049958 | 0 | 0 | 21,578 |
12,302,385 |
2012-09-06T14:30:00.000
| 1 | 0 | 0 | 0 |
python,django,oauth
| 12,322,503 | 1 | true | 1 | 0 |
I ended up creating a table with a single row, updated to contain the latest valid token.
Main reason: I know that wherever I deploy this application, and no matter how many processes across how many machines are serving, the database will work as storage. It's not that much extra code either, and goes well with Django's application packaging.
| 1 | 1 | 0 |
I'm running a Django app that needs to interact with an external API to make requests in behalf of its users.
Before making any calls, I have to obtain an access token through an OAuth-like interface. This token is mine, my users won't have one each. I have tested the entry points and methods with curl, and everything seems to work fine, so I'm ready to integrate the service.
How should I go about requesting, storing, reusing and renewing this token when it expires? Also, which parts of the process should run on the client's browser, and which parts on the Django backend?
|
Django: OAuth token storage and renewal
| 1.2 | 0 | 0 | 343 |
12,304,035 |
2012-09-06T16:02:00.000
| 4 | 0 | 1 | 0 |
python,dictionary
| 12,304,058 | 1 | true | 0 | 0 |
Nope, python dicts will not see any difference in what characters you use in the key string.
They are optimized to deal with strings only versus arbitrary key objects, but if you use only string values for keys you won't see any difference between using keys without and with non-alphanumeric characters.
The string-only codepath is an optimization for the most common usecase for python dicts: namespaces and function definitions. This is the default mode for a dict; as soon as you store a non-string key in it, the lookup method is switched and you'll have a teensy-weensy slower dict on your hands. This won't matter much in most Python applications though.
| 1 | 0 | 0 |
All my keys are strings, but I'm considering to use non-alphanumeric characters such as +, :, _, etc as part of the key.
Is there any performance (or any other) impact of using them?
|
Is there any performance impact of using non-alphanumeric characters in string keys for dictionary
| 1.2 | 0 | 0 | 96 |
12,305,045 |
2012-09-06T17:07:00.000
| 1 | 0 | 0 | 1 |
python,io,subprocess
| 12,306,605 | 1 | true | 0 | 0 |
Check this out: http://pypi.python.org/pypi/async_subprocess/0.2.1
"Provides an asynchronous version of Popen.communicate"
| 1 | 0 | 0 |
I use Windows XP and Python 2.5. I am trying to make a way for my python programs to secretly communicate with each other, I think the STARTUPOPTIONS class could hide the window, but I can't find out how I could communicate with them. On my python subprocess I tried using raw_input and on the parent I tried writing to the Popen.stdin and flushing it, but it diden't seam to work. I would use Popen.communicate, but that waits for the process to exit. Is there a way to do this? Thanks!
EDIT:
I am going to only make my program available for windows users so if there is a module that is only available for windows, I will not mind it can't run on other Operating Systems.
|
Is there a way to use the python subprocess module's Popen.communicate() without waiting for the process to exit?
| 1.2 | 0 | 0 | 112 |
12,305,146 |
2012-09-06T17:14:00.000
| 0 | 1 | 0 | 0 |
python,python-2.7,mod-wsgi,web.py,flup
| 12,314,167 | 2 | false | 0 | 0 |
I use nginx and uwsgi to deploy my own web.py apps, seems faster and consumes less ram than apache+mod_wsgi, the setup is not as easy though. I have to run supervisord to ensure that all uwsgi processes are on.
Don't use flup, I think its considered to be a bit outdated way of deploying python web apps.
| 1 | 1 | 0 |
I am unsure which of the two I should go for. Flup or modwsgi.
Flup seems to have very little documentation and even less people adding to the code. modwsgi on the other hand seems to be widely supported.
I just want to start running my webpy environmental so that I can utilize Python scripts online. But this thing stops me from moving ahead. Any suggestions?
|
Python 2.7 with Webpy - flup or modwsgi?
| 0 | 0 | 0 | 813 |
12,307,173 |
2012-09-06T19:38:00.000
| 10 | 0 | 0 | 1 |
python,rabbitmq,celery,distributed-computing,django-celery
| 12,355,563 | 1 | true | 0 | 0 |
There is no one-size-fits-all answer to this
Dividing a big task A into many small parts (A¹, A², A³, …) will increase potential concurrency.
So if you have 1 worker instance with 10 worker threads/processes,
A can now run in parallel using the 10 threads instead of sequentially
on one thread.
The number of parts is called the tasks granularity (fine or coarsely grained).
If the task is too finely grained the overhead of messaging will drag performance down.
Each part must have enough computation/IO to offset the overhead of sending the task
message to the broker, possibly writing it to disk if there are no workers to take it, the worker to receive the message, and so on (do note that messaging overhead can be tweaked, e.g. you can have a queue that is transient (not persisting messages to disk), and send tasks that are not so important there).
A busy cluster may make all of this moot
Maximum parallelism may already have been achieved if you have a busy cluster (e.g. 3 worker instances with 10 threads/processes each, all running tasks).
Then you many not get much benefit by dividing the task, but tasks doing I/O have a greater chance of improvement than CPU-bound tasks (split by I/O operations).
Long running tasks are fine
The worker is not allergic to long running tasks, be that 10 minutes or an hour.
But it's not ideal either because any long running task will block that slot from
finishing any waiting tasks. To mitigate this people use routing, so that you have a dedicated queue, with dedicated workers for tasks that must run ASAP.
-
| 1 | 6 | 0 |
In my solution I use distributed tasks to monitor hardware instances for a period of time (say, 10 minutes). I have to do some stuff when:
I start this monitoring session
I finish this monitoring session
(Potentially) during the monitoring session
Is it safe to have a single task run for the whole session (10 minutes) and perform all these, or should I split these actions into their own tasks?
The advantages of a single task, as I see it, are that it would be easier to manage and enforce timing constraints. But:
Is it a good idea to run a large pool of (mostly) asleep workers? For example, if I know that at most I will have 200 sessions open, I have a pool of 500 workers to ensure there are always available "session" seats?
|
Celery: long dedicated monolithic task vs short multiple tasks
| 1.2 | 0 | 0 | 1,293 |
12,314,245 |
2012-09-07T08:13:00.000
| 1 | 1 | 0 | 0 |
python,nginx,uwsgi
| 12,314,652 | 3 | false | 0 | 0 |
First, consider those questions:
On which port is uWSGI running?
Is uWSGI running on your or on a remote machine?
If it's running on a remote machine, is the port accessible from your computer? (iptables rules might forbid external access)
If you made sure you have access, you can just call http://hostname:port/path/to/uWSGI for direct API access.
| 1 | 3 | 0 |
Here's a data flow:
http <--> nginx <--> uWSGI <--> python webapp
I guess there's http2uwsgi transfer in nginx, and uwsgi2http in uWSGI.
What if I want to directly call uWSGI to test an API in a webapp?
actually i'm using pyramid. just config [uwsgi] in .ini and run uWSGI. but i want to test if uWSGI hold webapp function normally, the uWSGI socket is not directly reachable by http.
|
Can I use the uwsgi protocol to call http?
| 0.066568 | 0 | 0 | 5,693 |
12,315,398 |
2012-09-07T09:30:00.000
| 18 | 1 | 1 | 0 |
python,base64
| 12,317,005 | 11 | true | 0 | 0 |
This isn't possible. The best you could do would be to verify that a string might be valid Base 64, although many strings consisting of only ASCII text can be decoded as if they were Base 64.
| 1 | 47 | 0 |
Is there a good way to check if a string is encoded in base64 using Python?
|
Check if a string is encoded in base64 using Python
| 1.2 | 0 | 0 | 50,919 |
12,317,388 |
2012-09-07T11:38:00.000
| 4 | 0 | 0 | 0 |
python,networkx
| 12,317,478 | 1 | true | 0 | 0 |
Found it, there is a property node_shape that allows changing shape.
| 1 | 4 | 0 |
I need nodes in different shapes in NetworkX, some rectangle and triangle nodes. Does anybody know if it is possible?
regards
|
changing node shape in NetworkX
| 1.2 | 0 | 1 | 1,795 |
12,318,264 |
2012-09-07T12:37:00.000
| 5 | 0 | 1 | 1 |
python,windows,installation-path
| 12,318,294 | 1 | true | 0 | 0 |
the default installation folder is c:/python27
| 1 | 2 | 0 |
When using windows MSI installation from python.org/download (current version is 2.7.3), python by default installs in some folder but it is nowhere documented what is this default. Can someone check that on windows?
Also does this MSI installation recognizes is it 32 or 64bit windows and installs appropriate version or it assumes that it shall always be 32bit version of python?
Particularly I am interested what happens on Windows 7 when this installer is used.
|
What is the default installation directory with an MSI install of Python 2.7?
| 1.2 | 0 | 0 | 3,491 |
12,318,437 |
2012-09-07T12:46:00.000
| 9 | 0 | 1 | 0 |
python,python-3.x,python-2.x
| 12,318,539 | 6 | false | 0 | 0 |
If you're looking to learn new things, and aren't looking to make a "must work today" type project, try Python3. It will be easier to move forward into the future with Python3, as it will become the standard over time.
If you're making something quick and dirty, you'll typically get better library support with Python 2.7.
Finally, if anything you are using includes full unicode support, don't sell yourself short -- go with Python3. The simplification of unicode alone is worth it.
| 2 | 9 | 0 |
I am coming from Ruby, and am having trouble deciding between installing and using Python 2.x or Python 3.x I am guessing that this choice this depends on what platforms and frameworks I want to use, but how can I find a list of programs that are or are not Python 3 compatible? This might help me get past this dilemma.
|
Confused about the choice between Python 2 vs Python 3
| 1 | 0 | 0 | 7,661 |
12,318,437 |
2012-09-07T12:46:00.000
| 1 | 0 | 1 | 0 |
python,python-3.x,python-2.x
| 12,318,536 | 6 | false | 0 | 0 |
Nowadays, quite a number of libraries support Python 3. There is not a single list of these, so you'll have to check the frameworks you'd like to use for Python 3 compatibility. Some support Python 3 only in some beta stage, but that doesn't mean those are bad.
I would start off nowadays with Python 3, and see where you get. Only if you know you need to support whatever you are developing on other platforms that you don't control, it may be better to start with Python 2.
| 2 | 9 | 0 |
I am coming from Ruby, and am having trouble deciding between installing and using Python 2.x or Python 3.x I am guessing that this choice this depends on what platforms and frameworks I want to use, but how can I find a list of programs that are or are not Python 3 compatible? This might help me get past this dilemma.
|
Confused about the choice between Python 2 vs Python 3
| 0.033321 | 0 | 0 | 7,661 |
12,319,957 |
2012-09-07T14:19:00.000
| 0 | 0 | 0 | 0 |
python,openerp
| 13,524,808 | 1 | false | 1 | 0 |
All it means is the directive shown has a syntax error. If you look at it it is fairly clear. One set of parentheses is not closed. The other common cause is missing the closing > tag
| 1 | 2 | 0 |
I got the following Error after I hit the print button, the report was full functional in openerp6.1 with aeroo:
Aeroo Reports: Error while generating the report.
unexpected EOF while parsing in expression "__filter(get_label("report.account.account.balance","chart_account_id")" of "replace" directive (, line 1) (, line 1)
unexpected EOF while parsing in expression "__filter(get_label("report.account.account.balance","chart_account_id")" of "replace" directive (, line 1) (, line 1)
For more reference inspect error logs.
(, Exception(u'Aeroo Reports: Error while generating the report.', TemplateSyntaxError('unexpected EOF while parsing in expression "__filter(get_label("report.account.account.balance","chart_account_id")" of "replace" directive (, line 1) (, line 1)',), 'unexpected EOF while parsing in expression "__filter(get_label("report.account.account.balance","chart_account_id")" of "replace" directive (, line 1) (, line 1)', u'For more reference inspect error logs.'), )
Please help me..
Thanks
|
have bug with aeroo reports in openerp version 6.1
| 0 | 0 | 0 | 629 |
12,320,273 |
2012-09-07T14:39:00.000
| 1 | 0 | 0 | 0 |
python,selenium,tinymce
| 22,871,270 | 3 | false | 0 | 0 |
Use command: runScript
Target: tinyMCE.get('text_area_id').setContent('Your text here')
or you can use tinyMCE.activeEditor.setContent('Your text here') which will select either the first or the last mceEditor, I forget..
| 1 | 1 | 0 |
In selenium i am trying to enter text into the tinymce text area, but i am having trouble selecting the text area to input the text. Is there a way to select the text area behind tinymce or anyway to select tinymce so i can enter text. thanks
|
Having trouble inputting into tinymce via selenium
| 0.066568 | 0 | 1 | 525 |
12,321,301 |
2012-09-07T15:39:00.000
| 1 | 1 | 0 | 0 |
python,websocket,broadcasting,autobahn
| 14,835,403 | 2 | false | 0 | 0 |
Well it is purely your logic in the code. When you receive the message you are simply broadcasting it, what you have to do is to pass this onto a custom function, and there, do a check:
Create a temporary array that contains list of active authenticated users. when user logs on, it should send this special string, match it, if OK, add this user to this active user list array, if not don't add it. Later, call the bradcast function but rather then taking all online users, use this custom array instead.
That is all that you have to do.
Make sure when someone logs out, remove him from this array.
| 1 | 1 | 0 |
I have read this example from AutobahnPython: https://github.com/tavendo/AutobahnPython/tree/master/examples/websocket/broadcast
It looks pretty easy to understand and practice. But I want to add a little more. Members who submit the correct secret string can send the messages, anyone else can only view the information transmitted. Any idea?
Thanks!
|
Python - Broadcasting with WebSocket using AutobahnPython
| 0.099668 | 0 | 1 | 1,310 |
12,323,833 |
2012-09-07T18:53:00.000
| 6 | 0 | 1 | 0 |
python,pyramid
| 12,324,667 | 2 | true | 0 | 0 |
After the request object has gotten to the view it's recommended that you do not pass "as-is" to any non-web-specific code. Any code dealing with databases, etc shouldn't be coupled to pyramid's concept of a request. This pattern is easier to follow in Pyramid as it avoids a global request object.
The request object encompasses everything about why your view is being invoked, and making more code than necessary coupled to that object will cause you to write functions further down the pipeline that perhaps do "too much".
| 1 | 2 | 0 |
My assumption is that the correct request object is not the guaranteed result, but I would like to know exactly why it's ill advised, and the recommended way is to pass the request object down the pipeline from a view function.
|
Why is it ill advised to use pyramid.threadlocal.get_current_request?
| 1.2 | 0 | 0 | 980 |
12,332,975 |
2012-09-08T17:33:00.000
| 5 | 0 | 1 | 0 |
python,pip,python-module,pypi
| 12,333,019 | 11 | false | 0 | 0 |
You define the dependent module inside the setup.py of your own package with the "install_requires" option.
If your package needs to have some console script generated then you can use the "console_scripts" entry point in order to generate a wrapper script that will be placed
within the 'bin' folder (e.g. of your virtualenv environment).
| 1 | 430 | 0 |
I need to install a package from PyPi straight within my script.
Maybe there's some module or distutils (distribute, pip etc.) feature which allows me to just execute something like pypi.install('requests') and requests will be installed into my virtualenv.
|
Installing python module within code
| 0.090659 | 0 | 0 | 412,031 |
12,333,831 |
2012-09-08T19:34:00.000
| 1 | 0 | 0 | 0 |
python,sockets,port
| 12,333,846 | 2 | false | 0 | 0 |
Bind to 0.0.0.0 or the outside IP address instead, obviously.
| 1 | 0 | 0 |
I currently have the problem that I have a server script running on one computer as localhost:12123. I can connect to it using the same computer but using another computer in the same network does not connect to it (says it does not exist). Firewall is disabled.
Does it have to do with permissions?
The socket is created by a python file using BaseHTTPServer.
|
How to make HTTP server with port not 80 available for network?
| 0.099668 | 0 | 1 | 1,991 |
12,335,114 |
2012-09-08T22:53:00.000
| 2 | 1 | 0 | 1 |
python,rsync,fabric
| 12,335,299 | 2 | true | 0 | 0 |
If rsync using ssh as a remote shell transport is an option and you can setup public key authentication for the users, that would provide you a secure way of doing the rsync without requiring passwords to be entered.
| 1 | 1 | 0 |
I'd like to pass somehow user password for rsync_project() function (that is wrapper for regular rsync command) from Fabric library.
I've found the option --password-file=FILE of rsync command that requires password stored in FILE. This could somehow work but I am looking for better solution as I have (temporarily) passwords stored as plain-text in database.
Please provide me any suggestions how should I work with it.
|
Putting password for fabric rsync_project() function
| 1.2 | 0 | 0 | 1,763 |
12,335,127 |
2012-09-08T22:56:00.000
| 1 | 0 | 0 | 0 |
jquery,python,google-app-engine,autocomplete,submit
| 12,335,176 | 1 | false | 1 | 0 |
You could add a keystroke event listener and simply listen to the backspace keypress event.
When that happens, save and ajax the form field value to your server for storage.
EDIT: On basis of Scott Selby's anser:
To cover all bases:
Event listener for keypress backspace
Event listener for selection start and end. Save and ajax the selected part if if the form field has changed on the next keypress.
Catch onunload event, safe form data if exists.
That way you always get what the users deleted. This also helps making your search query window "typo" proof because you'll be able to spot "common" mistakes over time.
It's also a good way to collect data on what products or services your potential clients expect from you.
| 1 | 0 | 0 |
I'm using Jquery autocomplete on an input field. So, as users type out a word, they can see a drop-down list showing fewer and fewer choices to select from.
The thing is, sometimes the user's input will not be among the choices in that list. I believe that when users see that list go empty, they will give up on their original search term and either enter a different one, or simply delete it and leave the field blank.
When that happens, I want to know what was the original search term entered?
(Because after collecting that info over time, I plan to add the most popular ones to the list, for future users to choose from)
So my question is, what is the best way to find out what users typed in, but didn't submit?
My idea so far is to listen for when the user takes the focus off the input field, and get it's value on change. That will tell me about users who deleted and left it blank, but it still doesnt tell me anything for the users who deleted and then entered a new term.
Is there a better solution?
PS - My site is on GAE, so if using python opens any relevant doors... there's that too.
|
Find out what users DIDN'T submit in input field.
| 0.197375 | 0 | 0 | 84 |
12,335,424 |
2012-09-08T23:53:00.000
| 19 | 1 | 0 | 1 |
python,eclipse,pydev
| 12,774,197 | 2 | false | 0 | 0 |
press CTRL+ALT+ENTER to send the selected lines to the interactive console
| 1 | 19 | 0 |
Is there a command in Eclipse Pydev which allows me to only run a few selected (highlighted) lines of code within a larger script?
If not, is it possible to run multiple lines of code in the PyDev console at once?
|
Eclipse Pydev: Run selected lines of code
| 1 | 0 | 0 | 11,174 |
12,335,801 |
2012-09-09T01:20:00.000
| 0 | 0 | 1 | 0 |
python,video,encoding
| 12,336,353 | 1 | true | 0 | 0 |
Not 100% clear on what you mean by 'make a video'. You can run use mencoder if say you do not like using ffmpeg for some reason.
Whatever that may be, you need a video source and video encoder to generate a video. Of course you could write your own video encoder in python if you wanted but that would leave you doing only that for next few months and it would run very slowly.
You need a raw YUV input to encode or another stream to transcode and 'make a video'. The input can come from a hardware or a file or stream on a socket.
| 1 | 1 | 0 |
I have python 2.5 on a Windows XP computer. I want to create a video (preferably a AVI) from a list of images. I would also like to be able to add sound to the video. I have tried modules like pymedia (keeps crashing), pyFFMPEG (gived DLL NOT FOUND ImportError), pyglet (only displays videos), and OpenCV (would not install). I am want to compile my program into a windows executable with py2exe and I would be willing to use an external program if that program could be redistributed through my program and it could be Popened when the program is compiled. It would be nice if the program was compatible with PIL or pygame images, but if not I could probably work around that. If there is one out there like this, or if you can help me get PyFFMPEG to work with python 2.5, that would be great. Thanks!
|
Is there a way to make a video with python?
| 1.2 | 0 | 0 | 218 |
12,336,611 |
2012-09-09T04:57:00.000
| 2 | 0 | 0 | 0 |
python,sockets
| 12,336,669 | 2 | false | 0 | 0 |
The socket is closed when the process exits. The port it was using may hang around for a couple of minutes, that's normal, then it will disappear. If you need to re-use the port immediately, set SO_REUSEADDR before binding or connecting.
| 1 | 0 | 0 |
I created a program which listens to particular socket in python, however I ctrl+c'd script which resulted in .close() nor called, however how can I free the socket now.
|
closing a previously opened socket
| 0.197375 | 0 | 1 | 142 |
12,337,318 |
2012-09-09T07:36:00.000
| -2 | 0 | 0 | 0 |
python,django,web-applications,django-admin
| 12,337,353 | 2 | false | 1 | 0 |
How secure is a Google Login ;) ? You can't tell as you can't look behind the scenes (Update: Of Google Login of course.). I would guess that Django's admin code is pretty safe, as it's used in lots of production systems. Still, beside the code, it also matters how you set it up. In the end, it depends on the level of security you need.
| 2 | 0 | 0 |
I have couple of apps on internet and want to serve static files for those apps using another Django App. I simply can't afford to use Amazon Web Services for my pet-projects.
So, I want to setup an Admin interface where I can manage static files easily. The following are the actions I am thinking to include in admin.
Upload, delete static files
Grouping static files (creating new folders, adding new/ existing files to it); I am not sure If it is possible.
checking my models
Thus, I would like to know how secure is Django-Admin interface!
How secure it is when compared to our famous sites like Yahoo, Facebook, Google Login's.. (at least in terms of "cracking".. is django admin can be cracked easily?)
|
How secure is Django Admin interface
| -0.197375 | 0 | 0 | 2,419 |
12,337,318 |
2012-09-09T07:36:00.000
| 0 | 0 | 0 | 0 |
python,django,web-applications,django-admin
| 12,337,841 | 2 | false | 1 | 0 |
Besides serving static files through django is considered a bad idea, the django admin itself is pretty safe. You can take additional measure by securing it via .htaccess and force https access on it. You could also restrict access to a certain IP. If the admin is exposed to the whole internet you should at least be careful when choosing credentials. Since I don't know how secure Google and Yahoo really are, I can't compare to them.
| 2 | 0 | 0 |
I have couple of apps on internet and want to serve static files for those apps using another Django App. I simply can't afford to use Amazon Web Services for my pet-projects.
So, I want to setup an Admin interface where I can manage static files easily. The following are the actions I am thinking to include in admin.
Upload, delete static files
Grouping static files (creating new folders, adding new/ existing files to it); I am not sure If it is possible.
checking my models
Thus, I would like to know how secure is Django-Admin interface!
How secure it is when compared to our famous sites like Yahoo, Facebook, Google Login's.. (at least in terms of "cracking".. is django admin can be cracked easily?)
|
How secure is Django Admin interface
| 0 | 0 | 0 | 2,419 |
12,340,250 |
2012-09-09T15:12:00.000
| 0 | 0 | 1 | 0 |
comments,ipython
| 68,532,960 | 4 | false | 0 | 0 |
For me Ctrl + ^/~. The other solutions didn't work for me.
I'm using windows 10 and Jupyter Notebook.
| 1 | 3 | 0 |
Is there a way to comment multiple lines of code in an ipython cell in one go?
|
Commenting multiple lines in an ipython cell
| 0 | 0 | 0 | 7,337 |
12,340,456 |
2012-09-09T15:39:00.000
| 1 | 0 | 0 | 1 |
python,google-app-engine,dkim
| 12,340,517 | 1 | false | 1 | 0 |
How long ago did you create your DNS TXT record? Since DKIM is a DNS controlled service, and DNS often takes up to days to propagate across the Internet, you may need to wait for that to happen before Google will recognize it as valid.
| 1 | 0 | 0 |
Am confused why emails sent by my appengine app are not being signed with DKIM.
Enabled DKIM signing on Google Apps dashboard. Confirmed that my domain is "Authenticating email"
Have setup DNS TXT record using the values indicated in the apps domain. Have confirmed, using 3rd party validation tool, that the DNS is correct. Also, I assume that having a green-light indicator for authenticating email in my Google Apps domain means this record has been validated by Google Apps.
Email-send is being triggered by a click by a user browsing my application via my custom url. The custom url matches the domain for the return address of the sender. The sender return address is an owner of the account.
As far as I know, these are the requirements for emails to be signed automatically. Yet, alas, they are not being signed. Any help or ideas will be greatly appreciated. Thanks -
|
Google Appengine not signing emails with DKIM code
| 0.197375 | 0 | 0 | 441 |
12,340,468 |
2012-09-09T15:41:00.000
| 0 | 0 | 0 | 1 |
python,google-app-engine
| 37,780,181 | 3 | false | 1 | 0 |
For those using windows change the open line to:
raw = open('path_to_datastore_export_file', 'rb')
The file must be opened in binary mode!
| 1 | 3 | 0 |
I'm experimenting with the Google cloud storage backup feature for an application.
After downloading the backup files using gsutil, how can they be loaded into a local development server?
Is there a parser available for these formats (eg, protocol buffers)?
|
How can one load an AppEngine cloud storage backup to a local development server?
| 0 | 0 | 0 | 1,341 |
12,341,496 |
2012-09-09T17:58:00.000
| 8 | 0 | 0 | 0 |
python,template-engine,jinja2
| 43,586,175 | 4 | false | 1 | 0 |
For anyone coming here looking to use the safe filter programmatically: wrap it in a markupsafe.Markup class, on which Jinja2 depends on.
| 1 | 30 | 0 |
I have a little problem understanding what an expression like {{ something.render() | safe }} does .
From what I have seen, without the safe keyword it outputs the entire html document, not just the true content.
What I would like to know, is what it actually does, how it functions .
|
Jinja 2 safe keyword
| 1 | 0 | 0 | 32,304 |
12,341,610 |
2012-09-09T18:12:00.000
| 0 | 1 | 0 | 0 |
python,python-2.7,mod-wsgi
| 12,444,455 | 2 | false | 1 | 0 |
You have Apache 2.2 core package installed, but possibly have the devel package for Apache 1.3 instead of that for 2.2 installed. This isn't certain though, as for some Apache distributions, such as when compiled from source code, 'apxs' is still called 'apxs'. It is only certain Linux distros that have changed the name of 'apxs' in Apache 2.2 distros to be 'apxs2'. This is why the mod_wsgi configure script checks for 'apxs2' as well as 'apxs'.
So, do the actual make and see if that fails before assuming you have the wrong apxs.
| 2 | 0 | 0 |
When installing mod_wsgi I get stuck after doing ./config
Apparently I am missing the apxs2
Here is the result:
checking for apxs2... no
checking for apxs... /usr/sbin/apxs
checking Apache version... 2.2.22
checking for python... /usr/bin/python
configure: creating ./config.status
config.status: creating Makefile
What I am not sure of now is how I get apxs2 working and installed. Any solution anyone? This is so that I can later on install Django and finally get a Python/Django environment up and running on my VPS.
|
Error when installing mod_wsgi
| 0 | 0 | 0 | 314 |
12,341,610 |
2012-09-09T18:12:00.000
| 2 | 1 | 0 | 0 |
python,python-2.7,mod-wsgi
| 12,341,622 | 2 | false | 1 | 0 |
checking for apxs... /usr/sbin/apxs
...
config.status: creating Makefile
It succeeded. Go on to the next step.
| 2 | 0 | 0 |
When installing mod_wsgi I get stuck after doing ./config
Apparently I am missing the apxs2
Here is the result:
checking for apxs2... no
checking for apxs... /usr/sbin/apxs
checking Apache version... 2.2.22
checking for python... /usr/bin/python
configure: creating ./config.status
config.status: creating Makefile
What I am not sure of now is how I get apxs2 working and installed. Any solution anyone? This is so that I can later on install Django and finally get a Python/Django environment up and running on my VPS.
|
Error when installing mod_wsgi
| 0.197375 | 0 | 0 | 314 |
12,342,207 |
2012-09-09T19:24:00.000
| 3 | 0 | 1 | 0 |
python,text
| 12,342,216 | 5 | false | 0 | 0 |
Use a dictionary - basically letters[char]++
| 2 | 6 | 0 |
In python, how can I iterate through a text file and count the number of occurrences of each letter? I realise I could just use a 'for x in file' statement to go through it and then set up 26 or so if elif statements, but surely there is a better way to do it?
Thanks.
|
Count frequency of letters in a text file
| 0.119427 | 0 | 0 | 29,198 |
12,342,207 |
2012-09-09T19:24:00.000
| 0 | 0 | 1 | 0 |
python,text
| 12,342,298 | 5 | false | 0 | 0 |
Counter is a good way to do this, but Counter is only available in 3.1 and up, plus 2.7.
If you're on 3.0 or 2.[56], you probably should use collections.defaultdict(int) instead.
| 2 | 6 | 0 |
In python, how can I iterate through a text file and count the number of occurrences of each letter? I realise I could just use a 'for x in file' statement to go through it and then set up 26 or so if elif statements, but surely there is a better way to do it?
Thanks.
|
Count frequency of letters in a text file
| 0 | 0 | 0 | 29,198 |
12,342,807 |
2012-09-09T20:44:00.000
| 1 | 0 | 0 | 0 |
python,pyqt4,pjsip
| 12,426,092 | 1 | true | 1 | 0 |
himself answer :-)
in my case it was so
# call window
################
self.MuteMic = False
self.MuteSpeaker = False
################
#btn signals
self.connect(self.MuteUnmuteMicButton, QtCore.SIGNAL("clicked()"), self.MuteUnmuteMic)
self.connect(self.MuteUnmuteSpeakerButton, QtCore.SIGNAL("clicked()"), self.MuteUnmuteSpeaker)
def MuteUnmuteMic(self):
try:
if self.MuteMic:
self.MuteMic = False
self.parent().unmute_mic()
else:
self.MuteMic = True
self.parent().mute_mic()
except:
debug ("ошибка при вызове функции включение или отключение микрофона (call Window).")
def MuteUnmuteSpeaker(self):
try:
if self.MuteSpeaker:
self.MuteSpeaker = False
self.parent().unmute_speaker()
else:
self.MuteSpeaker = True
self.parent().mute_speaker()
except:
debug ("ошибка при вызове функции включение или отключение микрофона (call Window).")
# other code
----------
# ----------------------core of the my app
# ---import PJUA lib----
def mute_mic(self):
#this that you need in my case my app connected to pjua "self.lib"
self.lib.conf_set_rx_level(0,0)
debug ("вызвана функция выключение микрофона")
def unmute_mic(self):
self.lib.conf_set_rx_level(0,1)
debug ("вызвана функция включение микрофона")
def mute_speaker(self):
self.lib.conf_set_tx_level(0,0)
debug ("вызвана функция выключение динамиков")
def unmute_speaker(self):
self.lib.conf_set_tx_level(0,1)
debug ("вызвана функция включение динамиков")
| 1 | 0 | 0 |
Hello friends and colleagues
I am trying to make a function mute / un mute microphone and also speakers for my program softphone on pyt4 and using library PJSIP
I found this in the code pjsip
pjsip:
def conf_set_tx_level(self, slot, level):
"""Adjust the signal level to be transmitted from the bridge to
the specified port by making it louder or quieter.
Keyword arguments:
slot -- integer to identify the conference slot number.
level -- Signal level adjustment. Value 1.0 means no level
adjustment, while value 0 means to mute the port.
"""
lck = self.auto_lock()
err = _pjsua.conf_set_tx_level(slot, level)
self._err_check("conf_set_tx_level()", self, err)
def conf_set_rx_level(self, slot, level):
"""Adjust the signal level to be received from the specified port
(to the bridge) by making it louder or quieter.
Keyword arguments:
slot -- integer to identify the conference slot number.
level -- Signal level adjustment. Value 1.0 means no level
adjustment, while value 0 means to mute the port.
"""
lck = self.auto_lock()
err = _pjsua.conf_set_rx_level(slot, level)
self._err_check("conf_set_rx_level()", self, err)
well I understand I need to send a parameter 0, but how to do?
And to return back work the sound device and microphone.
Maybe it """""pjsua_conf_adjust_tx_level(slot_number, 0 )"""""
|
pyqt4, function Mute / Un mute microphone and also speakers [PJSIP]
| 1.2 | 0 | 0 | 1,239 |
12,342,820 |
2012-09-09T20:45:00.000
| 2 | 0 | 0 | 0 |
python,django,session,cookies
| 12,343,112 | 1 | true | 1 | 0 |
You're confusing things a bit.
The only thing stored inside "Django's session cookie" is an ID. That ID refers to the data which is stored inside the session backend: this is usually a database table, but could be a file or cache location depending on your Django configuration.
Now the only time that data is updated is when it is modified by Django. You can't expire data automatically, except by either the cookie itself expiring (in which case the entire set of data persists in the session store, but is no longer associated with the client) or by running a process on the server that modifies sessions programmatically.
There's no way of telling from the server end when a user leaves a website or closes his browser. So the only way of managing this would be to run a cron job on your server that gets sessions that were last modified (say) two hours ago, and iterate through them deleting the data you want to remove.
| 1 | 1 | 0 |
I am going to be storing a significant amount of information inside Django's session cookie. I want this data to persist for the entire time the user is on the website. When he leaves, the data should be deleted, but the session MUST persist. I do not want to user to need to log in every time he returns to the website.
I found ways to purge the entire session cookie every time a user leaves the website, but ideally I would like to only delete select pieces of the cookie which I explicitly set. Does anyone know how to do this?
|
Delete pieces of Session on browser close
| 1.2 | 0 | 0 | 1,943 |
12,344,187 |
2012-09-10T00:44:00.000
| 0 | 0 | 1 | 0 |
python,windows-7
| 12,344,713 | 5 | false | 0 | 0 |
I suggest that you run your code in some sort of editor (pretty much any will do: Eclipse, Geany, Spyder, IDLE, etc.). The reason for this is that when the program is executed, you are most likely getting a fatal error in your code somewhere. Python IDEs have a tendency to keep the windows used to execute the code open even if there is an error, so you can see the error callback for reference. That will tell you where you are getting the error, and will allow you to fix the code accordingly. of course, you could always just tack on input() or time.sleep() to the end and hope that helps, but that's up to you. I recommend using an IDE like one I mentioned above.
| 1 | 0 | 0 |
I have that issue with python interpreter - it's closing immediately after script execution. I'm trying to learn pygtk; I wrote "hello world" after tutorial and all I can see is a quick flash of two windows, one interpreter's and one gtk's. I tried to run the script from command.com instead of by double-click - didn't help much.
In older Windows I'd simply check the checkbox on apropriate tab, but how do I do it on this frelling eye candy?
|
How to stop python interpreter from closing on Windows 7?
| 0 | 0 | 0 | 1,943 |
12,344,193 |
2012-09-10T00:44:00.000
| 0 | 0 | 0 | 0 |
python,performance,google-app-engine,google-cloud-datastore,scalability
| 12,345,364 | 2 | false | 1 | 0 |
Here are some suggestions:
Save the user preferences/settings on the Server too, so that you can have their preferences synced to multiple clients/devices in the future.
Having the data stored locally on the client is also recommended, so that the calls are not made to the server everytime to get some preferences. In offline situations, having the relevant data available locally within the client is very critical.
In terms of Storage options on GAE - there are various ones. Since you are using Datastore I suggest that you go with that. In terms of storage size of each entity and in/out bandwidth, it is something that you can calculate approximately and if you feel that you can achieve the same logic via a few numbers or combined number (in a single Datastore entity attribute) rather than multiple entity attributes, it is preferable and will help.
| 2 | 1 | 0 |
I want to minimize traffic/storage costs on GAE.
Users fill out a form, checking boxes to select options which are lines of text, eg "I wake up two or more times during the night." or "I sleep less than 7 hours per night." or "I usually have trouble falling asleep."
I want to store the user's selections using the datastore. I suppose I can save on storage space by giving each selection a unique identifier. Then I'll just store (for example) "342, 554, 106" instead of three long lines of text... Then retrieve those numbers and translate them back into sentences next time loading the page for each user.
My question is, will it be better to do that conversion on the client side, or the server side?
Obviously, doing the conversion on the client side will mean sending LESS data from client to server for storage - which is good. However, it would mean sending MORE data from server to client, considering the additional lines of client-side javascript necessary to facilitate the conversion, which they will be downloaded as part of the page source - and that could be bad.
|
Most efficient/cheap way to send/store data on GAE
| 0 | 0 | 0 | 118 |
12,344,193 |
2012-09-10T00:44:00.000
| 1 | 0 | 0 | 0 |
python,performance,google-app-engine,google-cloud-datastore,scalability
| 12,352,966 | 2 | false | 1 | 0 |
Sounds like you already figured out how best to store the data.
In terms of translating it to HTML on the server or client side, it'll depend on the complexity of your page. Analyzing it will probably be more time than it's worth, and it might change if your page changes. It's most likely a wash unless it's an extreme situation. Use whichever is simpler and get your project done and out the door. If you're using a framework that handles generating forms on the server side, use that. If you have hundreds of thousands of views and it's adding up to a significant cost, revisit the pages in particular that are causing you the problem.
An extreme situation might be if your form needs to appear many, many times on a page, in which case it may be easier to have the actual form in javascript once and reproduce it many many times.
| 2 | 1 | 0 |
I want to minimize traffic/storage costs on GAE.
Users fill out a form, checking boxes to select options which are lines of text, eg "I wake up two or more times during the night." or "I sleep less than 7 hours per night." or "I usually have trouble falling asleep."
I want to store the user's selections using the datastore. I suppose I can save on storage space by giving each selection a unique identifier. Then I'll just store (for example) "342, 554, 106" instead of three long lines of text... Then retrieve those numbers and translate them back into sentences next time loading the page for each user.
My question is, will it be better to do that conversion on the client side, or the server side?
Obviously, doing the conversion on the client side will mean sending LESS data from client to server for storage - which is good. However, it would mean sending MORE data from server to client, considering the additional lines of client-side javascript necessary to facilitate the conversion, which they will be downloaded as part of the page source - and that could be bad.
|
Most efficient/cheap way to send/store data on GAE
| 0.099668 | 0 | 0 | 118 |
12,344,481 |
2012-09-10T01:42:00.000
| 0 | 0 | 1 | 0 |
python
| 12,344,677 | 2 | false | 0 | 0 |
Python is a "dynamically-typed" programming language, that meaning that the odds are against the IDE in providing code-intelligence.
That said, Wing-IDE is the very best for Python, and there are a few things you can do: first be sure to have open the "Source Assistant" panel, i.e., press F2 and locate it to your right. Second, be sure to inform the IDE of what Python interpreter are you using, as well as any particular Python path that your project might be using; all of that you can do in Project/Project Properties. Finally, you still might need to give hints sometimes to the IDE about your instances with "assert isinstance(x,SomeType)".
Admittedly, is not as straightforward as using Visual Studio, but the good reasons to use Python and its very capable ecosystem, or the easy integration with C/C++ more than compensate.
| 1 | 0 | 0 |
in visual studio all you had to do was type the first parenthesis and it showed you the parameters required.
It's not doing that in python / wingware, what is the best / easiest way to do this?
|
how do i know what parameters a python function takes with wingware IDE
| 0 | 0 | 0 | 468 |
12,346,337 |
2012-09-10T06:26:00.000
| 0 | 1 | 0 | 0 |
python-module,monkeyrunner
| 12,348,061 | 1 | false | 0 | 0 |
Try to name your script something.py. This way you have a python script where you can import the modules. When you run the script with monkeyrunner, some python modules are not recognized. Monkeyrunner does not equal python 100%. It does not have all the power and functionality.
| 1 | 1 | 0 |
I have installed psutil module.
It works well if run by the python interpreter but when I try to import the module in a monkeyrunner script,it gives
No such module.
Is there any way through which i use psutil module in monkeyrunner?
Note-i am using the monkeyrunner with the android ics-x86 version
|
Monkeyrunner doesnt find my module
| 0 | 0 | 0 | 258 |
12,346,831 |
2012-09-10T07:10:00.000
| 1 | 0 | 0 | 1 |
python,google-app-engine,download,email-attachments
| 12,349,722 | 1 | false | 1 | 0 |
You cannot write a File to your web application directory in App Engine.
Possible choices for you are:
Save the content in the Datastore.
Use the Blobstore
Use the Google Storage facility.
Alternately, you might want to post the content away to an external server that can store the data, either your own or some 3rd party like Amazon S3.
| 1 | 0 | 0 |
I am able to receive an email to app engine. I see the data in an attachment is payload base64 encoded data. Can I download the attachment as it is to file system without processing it or without storing it to blobstore?
|
google app engine email attachment: download it to file system
| 0.197375 | 0 | 0 | 218 |
12,348,291 |
2012-09-10T08:56:00.000
| 1 | 0 | 1 | 1 |
python,windows-7,command-line,tags,command-line-arguments
| 12,348,372 | 2 | true | 0 | 0 |
You cannot using standard Windows cmd shell. You can use something like bash from Cygwin, maybe PowerShell.
If you want to open *.py from application like vim but in Python, then you can use glob module.
| 1 | 0 | 0 |
I'm not able to do this
ptags.py *.py
or
python *.py
i'm getting an error saying "Cannot open file named *.py"
but i'm able to open all the python files in vim using this command
vim *.py
python 2.7 in windows 7 command prompt
|
how do i pass multiple files as arguments in command line for python using regular expressions?
| 1.2 | 0 | 0 | 1,629 |
12,348,500 |
2012-09-10T09:09:00.000
| 1 | 1 | 0 | 0 |
python,wsgi,gevent
| 15,670,806 | 1 | false | 1 | 0 |
If your library uses threading.local to provide thread-isolated "global" request variable then all you need is to call gevent.monkey.patch_thread BEFORE you use threading.local. That should turn all threading.local objects into "greenlet.local" ones.
| 1 | 1 | 0 |
I'd like to test my WSGI library with gevent's WSGI Servers to ensure that request parameters aren't leaked/overwritten with those from another request/greenlet - in my library request is "global", though it should be thread-safe... which is what I'd like to test using gevent.
What approaches can I use? Are there any open-source projects which already have unittests which achieve this from which I could learn?
|
How can I unittest wsgi code which uses gevent?
| 0.197375 | 0 | 0 | 563 |
12,349,086 |
2012-09-10T09:44:00.000
| 0 | 0 | 0 | 1 |
java,android,python,google-app-engine
| 12,349,313 | 1 | true | 1 | 0 |
The communication with your server can be totally independent of the languages used on the server and client end.
Typically web applications use principles such as REST to communicate. This is why your browser runs using HTML and JavaScript and your server can be using anything, including python.
It really depends on what you need your server to do for your app.
| 1 | 0 | 0 |
I'm a newbie Android Developer, and my app requires that it interacts with a server.
I came across Google AppEngine, and find it to be a good choice for this app.
If I code my Android app in Java, and do the server coding for Google AppEngine in Python, will my Android App be able to communicate with the server?
I mean will this Java (client) + Python (server) combination work well?
|
Python AppEngine coding for Android app?
| 1.2 | 0 | 0 | 130 |
12,349,118 |
2012-09-10T09:45:00.000
| 14 | 0 | 1 | 0 |
python,regex
| 12,349,512 | 4 | true | 0 | 0 |
You can use r"[^\W\d]", ie. invert the union of non-alphanumerics and numbers.
| 1 | 8 | 0 |
Special sequences (character classes) in Python RegEx are escapes like \w or \d that matches a set of characters.
In my case, I need to be able to match all alpha-numerical characters except numbers.
That is, \w minus \d.
I need to use the special sequence \w because I'm dealing with non-ASCII characters and need to match symbols like "Æ" and "Ø".
One would think I could use this expression: [\w^\d] but it doesn't seem to match anything and I'm not sure why.
So in short, how can I mix (add/subtract) special sequences in Python Regular Expressions?
EDIT: I accidentally used [\W^\d] instead of [\w^\d]. The latter does indeed match something, including parentheses and commas which are not alpha-numerical characters as far as I'm concerned.
|
Can I mix character classes in Python RegEx?
| 1.2 | 0 | 0 | 4,458 |
12,349,295 |
2012-09-10T09:57:00.000
| 0 | 0 | 0 | 0 |
python,web-scraping
| 12,349,430 | 2 | false | 1 | 0 |
I assume you use some library like urllib to do the scraping. You already know the website's content changes dynamically. I also assume that the dynamic content uses server-side interaction. This means, using javascript (ajax) the browser requests new data from the server, based on the value from the selection).
If so, then you could try to emulate the ajax call to the server in your web scraping library.
First, using a browser debugging tool find out the url to the server that is being invoked.
Split the parameters parts in the ajax call
Perform the same call to lookup the options in the select tag.
| 2 | 3 | 0 |
I want to scrape a webpage that changes its content via a <select> tag. When I select a different option, the content of the page dynamically changes. I want to know if there is a way that I can change the option from a python script so I can get the content from all different pages of all different options in <select> tag.
|
How to scrape a webpage that changes content from tag
| 0 | 0 | 1 | 2,430 |
12,349,295 |
2012-09-10T09:57:00.000
| 0 | 0 | 0 | 0 |
python,web-scraping
| 12,349,434 | 2 | false | 1 | 0 |
As @Tichodroma said, when the select is changed, either:
Some content previously hidden on the page is made visible, or:
An ajax call is made to retrieve some additional content and add it to the DOM
In both cases, JavaScript is involved. Have a look at it, and depending on what is happening (case #1 or #2), you should:
Scrape the whole page, since all the content you want is already in it, or:
Make several calls to the file usually called using ajax to retrieve the content you want for each value of the <select>
| 2 | 3 | 0 |
I want to scrape a webpage that changes its content via a <select> tag. When I select a different option, the content of the page dynamically changes. I want to know if there is a way that I can change the option from a python script so I can get the content from all different pages of all different options in <select> tag.
|
How to scrape a webpage that changes content from tag
| 0 | 0 | 1 | 2,430 |
12,349,970 |
2012-09-10T10:39:00.000
| 0 | 1 | 1 | 0 |
python,algorithm,caching
| 12,350,058 | 2 | false | 0 | 0 |
You can have a metadata file that will hold a list of all cached entities together with their creation times
| 2 | 4 | 0 |
My python script does some heavy computation. To boost performance, it caches the computed data on the disk so that next time I'll run it, it doesn't waste time in computing the same thing. However, before extracting data from the cache, it needs to do some checking to make sure that the cache is not stale. This is the part where I am stuck.
My first idea was to compare the creation time of cache and modification time of python script and if the later is larger (ie more recent) than the former, I would consider the cache as stale, else not. However, since linux kernel does not store creation times of files, I am stuck at this point.
Similar situation:
When python interpreter creates .pyc files from .py files, it does something similar --> creates a new .pyc file if I'll modify my .py file after the .pyc file was created, else it does not. How does it do that? I wish to know the algorithm. Thank you.
|
Algorithm to check if cache is stale
| 0 | 0 | 0 | 591 |
12,349,970 |
2012-09-10T10:39:00.000
| 2 | 1 | 1 | 0 |
python,algorithm,caching
| 12,356,214 | 2 | true | 0 | 0 |
Just check the last-modified time of your cache file instead.
Even better, that's what you really want to check in any case, because when you update your cache to store the new computed value, you want to know when that was done last, not when that was done the first time. :-)
| 2 | 4 | 0 |
My python script does some heavy computation. To boost performance, it caches the computed data on the disk so that next time I'll run it, it doesn't waste time in computing the same thing. However, before extracting data from the cache, it needs to do some checking to make sure that the cache is not stale. This is the part where I am stuck.
My first idea was to compare the creation time of cache and modification time of python script and if the later is larger (ie more recent) than the former, I would consider the cache as stale, else not. However, since linux kernel does not store creation times of files, I am stuck at this point.
Similar situation:
When python interpreter creates .pyc files from .py files, it does something similar --> creates a new .pyc file if I'll modify my .py file after the .pyc file was created, else it does not. How does it do that? I wish to know the algorithm. Thank you.
|
Algorithm to check if cache is stale
| 1.2 | 0 | 0 | 591 |
12,350,693 |
2012-09-10T11:25:00.000
| 0 | 0 | 0 | 0 |
python,matplotlib
| 12,363,743 | 1 | false | 0 | 0 |
I post here a schematic approach how to solve your problem with out any real python code, it might help though.
When actually plotting you need to store all in some kind of two lists, which will enable you to access them later.
For each element, bar and marker you can get the color.
For each marker you can find if it overlapping or inside a bar, for example you could usenxutils.pntpoly() [point in polygon test] from matplotlib itself.
Now you can decide on the best color. If you know the color of the bar in RGB format you can
calculate the completing color of the marker using some simple rules you can define.
When you got the color use the method set_color() or the appropriate method the object has.
| 1 | 1 | 1 |
I am using matplotlib to draw a bar chart with many different colors. I also draw a number of markers on the plot with scatter.
Since I am already using many different colors for the bars, I do not want to use a separate contrasting color for the marks, as that would add a big limit to the color space I can choose my bars from.
Therefore, the question is whether it is possible to have scatter draw marks, not with a given color, but with a color that is the inverse of the color that happens to be behind any given mark, wherever it is placed.
Also, note that the marks may fully overlap bars, partly overlap bars, or not overlap a bar at all.
|
Inverted color marks in matplotlib
| 0 | 0 | 0 | 385 |
12,351,786 |
2012-09-10T12:30:00.000
| -2 | 0 | 0 | 0 |
python,tkinter
| 12,351,926 | 5 | false | 0 | 1 |
The function which normally prints to stdout should instead put the text into text widget.
| 1 | 18 | 0 |
I have a Python program which performs a set of operations and prints the response on STDOUT. Now I am writing a GUI which will call that already existing code and I want to print the same contents in the GUI instead of STDOUT. I will be using the Text widget for this purpose. I do not want to modify my existing code which does the task (This code is used by some other programs as well).
Can someone please point me to how I can use this existing task definition and use its STDOUT result and insert it into a text widget? In the main GUI program I want to call this task definition and print its results to STDOUT. Is there a way to use this information?
|
How to redirect print statements to Tkinter text widget
| -0.07983 | 0 | 0 | 23,774 |
12,354,189 |
2012-09-10T14:50:00.000
| 1 | 0 | 0 | 0 |
python,django,shopify,webhooks
| 12,423,594 | 2 | true | 1 | 0 |
Thanks for the answers guys, but I found out that the issue was something else.
I forgot to make a CSRF exemption for the POST request URL that Shopify calls and also forgot to add a trailing slash '/' at the end of the URL I told the webhook to call.
I guess I would have caught these errors if I used something like postcatcher.in as suggested in the comments above. I din't bother doing that as it looked like too much of a hassle.
| 2 | 2 | 0 |
Backdrop: Am building a shopify app using a test store provided by shopify. #Python #Django-
Problem: I have setup shopify webhooks for my test store using the python API for the topics "products/update" and "products/delete". But my endpoints are not called by shopify when I manually update or delete a product on my test store.
My detective work so far: I have checked the following:
I have confirmed that the webhooks were successfully created using the API. I simply listed all the existing webhooks using the API for the store and mine are there.
The address/URL I specified in the webhook for shopify to call in the event of a product update or delete is a public url, as in it is not on my localhost. (not 127.0.0.1:8000 etc.)
My webhook endpoint is fine. When I manually call my endpoint in a test case, it does what it should.
I contacted the shopify apps support guys, and I was asked to post this issue here.
Another minor issue is that I cannot find in the shopify API docs exactly what JSON/XML the webhook will POST to my URL in the event it should. So I do not know what that JSON will look like...
Any help would be appreciated!
|
Shopify webhook not working when product updated/deleted
| 1.2 | 0 | 1 | 2,272 |
12,354,189 |
2012-09-10T14:50:00.000
| 1 | 0 | 0 | 0 |
python,django,shopify,webhooks
| 12,389,770 | 2 | false | 1 | 0 |
I don't have the creds to comment apparently, so I'll put this in an "answer" - to use the term very loosely - instead. I ran into something similar with the Python API, but soon realized that I was doing it wrong. In my case, it was toggling the fulfillment status, which then fires off an email notifying customers of a download location for media.
What I was doing wrong was this: I was modifying the fulfillment attribute of the order object directly. Instead, the correct method was to fetch / create a fulfillment object, modify that, point the order attribute to this object, than save() it. This worked.
I don't know if this is your issue as there's no code posted, but I hope this helps.
--Matt
| 2 | 2 | 0 |
Backdrop: Am building a shopify app using a test store provided by shopify. #Python #Django-
Problem: I have setup shopify webhooks for my test store using the python API for the topics "products/update" and "products/delete". But my endpoints are not called by shopify when I manually update or delete a product on my test store.
My detective work so far: I have checked the following:
I have confirmed that the webhooks were successfully created using the API. I simply listed all the existing webhooks using the API for the store and mine are there.
The address/URL I specified in the webhook for shopify to call in the event of a product update or delete is a public url, as in it is not on my localhost. (not 127.0.0.1:8000 etc.)
My webhook endpoint is fine. When I manually call my endpoint in a test case, it does what it should.
I contacted the shopify apps support guys, and I was asked to post this issue here.
Another minor issue is that I cannot find in the shopify API docs exactly what JSON/XML the webhook will POST to my URL in the event it should. So I do not know what that JSON will look like...
Any help would be appreciated!
|
Shopify webhook not working when product updated/deleted
| 0.099668 | 0 | 1 | 2,272 |
12,354,515 |
2012-09-10T15:09:00.000
| 5 | 0 | 1 | 0 |
python,list,set
| 46,170,559 | 7 | false | 0 | 0 |
Set represents a collection of distinct elements. In python, sets are mainly used for two reasons (Book: Data Science from Scratch, Joel Gruce):
For faster operation: in is a very fast operation on sets. If we have a large collection of elements and if we wish to perform membership test, in that case it is appropriate to use set instead of a list.
To find a distinct items in a collections. Programmers use sets much less frequently than dicts and lists.
| 2 | 54 | 0 |
Is the only difference between sets and lists in Python the fact that you can use the union, intersect, difference, symmetric difference functions to compare two sets? Why can't these functions simply be applied to lists? In what situations are sets more useful than lists?
|
What is the difference between sets and lists in Python?
| 0.141893 | 0 | 0 | 92,780 |
12,354,515 |
2012-09-10T15:09:00.000
| 5 | 0 | 1 | 0 |
python,list,set
| 39,240,481 | 7 | false | 0 | 0 |
Some more differences are:
List can be 2-D whereas a set can't.
As list are ordered (IE. have serial number) list are comparatively slow to execute whereas sets are fast.
List in python is like Array of java or c.
Printing a set almost always provide different sequence of output.
Set uses hash function to find an element whereas list is an array. Hence finding element in Set is faster than in list.
| 2 | 54 | 0 |
Is the only difference between sets and lists in Python the fact that you can use the union, intersect, difference, symmetric difference functions to compare two sets? Why can't these functions simply be applied to lists? In what situations are sets more useful than lists?
|
What is the difference between sets and lists in Python?
| 0.141893 | 0 | 0 | 92,780 |
12,355,416 |
2012-09-10T16:05:00.000
| 0 | 0 | 0 | 0 |
python,numpy,scipy,data-mining
| 12,369,285 | 2 | false | 0 | 0 |
An SQL database should work fine in your case. In fact, you can store all the training examples in just one database, each row representing a particular training set and each column representing a feature. You can add features by adding collumns as and when required. In a relational database, you might come across access errors when querying for your data for various inconsistency reasons. Try using a NoSQL database. I personally user MongoDB and Pymongo on python to store the training examples as dicts in JSON format. (Easier for web apps this way).
| 2 | 1 | 0 |
I'm looking to expand my recommender system to include other features (dimensions). So far, I'm tracking how a user rates some document, and using that to do the recommendations. I'm interested in adding more features, such as user location, age, gender, and so on.
So far, a few mysql tables have been enough to handle this, but i fear it will quickly become messy as i add more features.
My question: how can i best represent and persist this kind of multi dimensional data?
Python specific tips would be helpful.
Thank you
|
Multi feature recommender system representation
| 0 | 1 | 0 | 289 |
12,355,416 |
2012-09-10T16:05:00.000
| 0 | 0 | 0 | 0 |
python,numpy,scipy,data-mining
| 24,491,488 | 2 | false | 0 | 0 |
I recommend using tensors, which is multidimensional arrays. You can use any data table or simply text files to store a tensor. Each line or row is a record / transaction with different features all listed.
| 2 | 1 | 0 |
I'm looking to expand my recommender system to include other features (dimensions). So far, I'm tracking how a user rates some document, and using that to do the recommendations. I'm interested in adding more features, such as user location, age, gender, and so on.
So far, a few mysql tables have been enough to handle this, but i fear it will quickly become messy as i add more features.
My question: how can i best represent and persist this kind of multi dimensional data?
Python specific tips would be helpful.
Thank you
|
Multi feature recommender system representation
| 0 | 1 | 0 | 289 |
12,356,348 |
2012-09-10T17:07:00.000
| 1 | 0 | 0 | 1 |
python,vim,autocomplete,refactoring,rename
| 12,357,914 | 3 | false | 0 | 0 |
The . register contains the last inserted text. See :help quote_..
The help doesn't specifically mention any caveats of when this register is populated, however it does mention that it doesn't work when editing the command line. This shouldn't be an issue for you.
| 1 | 3 | 0 |
As a secondary task to a Python auto-completion (https://github.com/davidhalter/jedi), I'm writing a VIM plugin with the ability to do renaming (refactoring).
The most comfortable way to do renaming is to use cw and autocommand InsertLeave :call do_renaming_func(). To do this I need to access the redo-register (see help redo-register) or something similar, which would record the written text.
If possible, I like to do this without macros, because I don't want to mess up anything.
|
VIM: How to access the redo-register
| 0.066568 | 0 | 0 | 194 |
12,356,728 |
2012-09-10T17:34:00.000
| 1 | 0 | 1 | 0 |
python,ruby,outline
| 12,360,884 | 1 | true | 1 | 0 |
As far as I know there is no such library. You could create it yourself though.
A pragmatic way would be to follow the indentation levels in Python. For other languages, you could either follow the indentation level, or use regular expression matching and a stack to keep track your outline.
| 1 | 2 | 0 |
Is there a python or ruby library to create a code outline for the given code? The library should support multiple languages.
I am looking for something like outline view in Eclipse. I don't need the UI, and i can write my own. But I am looking for a library which parses the given language and creates an outline datastructure.
|
Library to create code outline
| 1.2 | 0 | 0 | 361 |
12,360,279 |
2012-09-10T22:23:00.000
| 2 | 0 | 0 | 1 |
python,linux,sqlite,ubuntu
| 12,360,397 | 1 | true | 0 | 0 |
Are you putting the DB file name in the command ?
$ sqlite3 test.db
| 1 | 1 | 0 |
Trying to set up some basic data I/O scripts in python that read and write from a local sqlite db. I'd like to use the command line to verify that my scripts work as expected, but they don't pick up on any of the databases or tables I'm creating.
My first script writes some data from a dict into the table, and the second script reads it and prints it.
Write:
# first part of script creates a dict called 'totals'
import sqlite3 as lite
con = lite.connect('test.db')
with con:
cur = con.cursor()
cur.execute("DROP TABLE IF EXISTS testtbl")
cur.execute("CREATE TABLE testtbl(Date TEXT PRIMARY KEY, Count INT, AverageServerTime REAL, TotalServerTime REAL, AverageClientTime REAL, TotalClientTime REAL)")
cur.execute('INSERT INTO testtbl VALUES("2012-09-08", %s, %s, %s, %s, %s)' % (float(totals['count()']), float(totals['serverTime/count()']), float(totals['serverTime']), float(totals['totalLoadTime/count()']), float(totals['totalLoadTime'])))
Read:
import sqlite3 as lite
con = lite.connect('test.db')
with con:
cur = con.cursor()
cur.execute("SELECT * FROM testtbl")
rows = cur.fetchall()
for row in rows:
print row
These scripts are separate and both work fine. However, if I navigate to the directory in the command line and activate sqlite3, nothing further works. I've tried '.databases', '.tables', '.schema' commands and can't get it to respond to this particular db. I can create dbs within the command line and view them, but not the ones created by my script. How do I link these up?
Running stock Ubuntu 12.04, Python 2.7.3, SQLite 3.7.9. I also installed libsqlite3-dev but that hasn't helped.
|
sqlite3 command line tools don't work in Ubuntu
| 1.2 | 1 | 0 | 1,252 |
12,364,981 |
2012-09-11T07:41:00.000
| 1 | 0 | 0 | 0 |
python,tkinter
| 60,425,005 | 8 | false | 0 | 1 |
You say that you have a list of widgets to change dynamically. Do you want to reuse and reconfigure existing widgets, or create all new widgets and delete the old ones? It affects the answer.
If you want to reuse the existing widgets, just reconfigure them. Or, if you just want to hide some of them temporarily, use the corresponding "forget" method to hide them. If you mapped them with pack() calls, you would hide with pack_forget() (or just forget()) calls. Accordingly, grid_forget() to hide gridded widgets, and place_forget() for placed widgets.
If you do not intend to reuse the widgets, you can destroy them with a straight destroy() call, like widget.destroy(), to free up resources.
| 1 | 61 | 0 |
I have a list of tkinter widgets that I want to change dynamically.
How to delete the widgets from the window?
|
How to delete Tkinter widgets from a window?
| 0.024995 | 0 | 0 | 201,947 |
12,367,009 |
2012-09-11T09:48:00.000
| 0 | 1 | 0 | 0 |
python,nose,nosetests
| 12,367,042 | 2 | false | 0 | 0 |
I am only answering my question. It is really very strange. I found that the test files previously were in executable mode. And as soon as i changed there modes, it started working like a charm. :-) chmod -x *_test.py worked for me. Can anybody explain this behaviour of nosetests ???
| 2 | 0 | 0 |
I am having a hierarchy of directories and inside every directory there is one 'test/' directory which has all the test files. nosetests is not able to collect these test files somehow.
I have followed naming convention used for filenames and class names as well. All the classes defined in those files are subclass of unittest:TestCase. Still no luck. What must be the problem ?
|
'nosetests' was unable to collect test files from directory
| 0 | 0 | 0 | 379 |
12,367,009 |
2012-09-11T09:48:00.000
| 1 | 1 | 0 | 0 |
python,nose,nosetests
| 12,418,833 | 2 | true | 0 | 0 |
If you carefully see the python nose usage, you will get it
--exe Look for tests in python modules that are executable.
Normal behavior is to exclude executable modules,
Thanks.
| 2 | 0 | 0 |
I am having a hierarchy of directories and inside every directory there is one 'test/' directory which has all the test files. nosetests is not able to collect these test files somehow.
I have followed naming convention used for filenames and class names as well. All the classes defined in those files are subclass of unittest:TestCase. Still no luck. What must be the problem ?
|
'nosetests' was unable to collect test files from directory
| 1.2 | 0 | 0 | 379 |
12,367,082 |
2012-09-11T09:52:00.000
| 1 | 0 | 0 | 0 |
python,django,project
| 12,367,541 | 2 | false | 1 | 0 |
It doesn't matter if database is involved or not, but for overall web development, it's an easy to use framework.
| 1 | 0 | 0 |
I am going to develop a auto text summarization tool as my FYP. I am going to use Python and it's going to be a web application. Since, there would be no database involved in my tool is it a good idea to use Django? Can anyone recommend any other framework? Thanks.
|
Auto Text Summarization: Web application using Django/python?
| 0.099668 | 0 | 0 | 421 |
12,367,891 |
2012-09-11T10:40:00.000
| 0 | 1 | 1 | 0 |
python,mime-types,content-type
| 55,849,444 | 2 | false | 0 | 0 |
Yes, you should evaluate the hex signature.
| 1 | 2 | 0 |
Is it possible to determine the type of a file-like object in Python?
For instance, if I were to read the contents of a file into a StringIO container and store it in a database, could I later work-out the original file-/content-/mime-type from the data? Eg. are there any common headers I could search for?
If not, are there any ways to determine "common" files (images, office docs, etc)?
|
Determine file-/content-/mime-type from file-like?
| 0 | 0 | 0 | 584 |
12,367,904 |
2012-09-11T10:41:00.000
| 2 | 0 | 0 | 1 |
google-app-engine,python-2.7,google-cloud-datastore
| 12,378,411 | 2 | true | 1 | 0 |
Pretty sure you are running into the HRD feature where queries are "eventually consistent". NDB's caching has nothing to do with this behavior.
| 1 | 2 | 0 |
So I have been reading a lot of documentation on HRD and NDB lately, yet I still have some doubts regarding how NDB caches things.
Example case:
Imagine a case where a users writes data and the app needs to fetch it immediately after the write. E.g. A user creates a "Group" (similar to a Facebook/Linkedin group) and is redirected to the group immediately after creating it. (For now, I'm creating a group without assigning it an ancestor)
Result:
When testing this sort of functionality locally (having enabled high replication), the immediate fetch of the newly created group fails. A NoneType is returned.
Question:
Having gone through the High Replication docs and Google IO videos, I understand that there is a higher write latency, however, shouldn't NDB caching take care of this? I.e. A write is cached, and then asynchronously actually written on disk, therefore, an immediate read would be reading from cache and thus there should be no problem. Do I need to enforce some other settings?
|
Write/Read with High Replication Datastore + NDB
| 1.2 | 0 | 0 | 863 |
12,368,120 |
2012-09-11T10:54:00.000
| 2 | 0 | 0 | 0 |
python,zeromq
| 12,396,881 | 1 | true | 0 | 0 |
You could simply implement an counter with a second socket.
Each time you have an active client or you close your socket, send a message on your "socket counter".
ZeroMQ is made to combine sockets.
| 1 | 3 | 0 |
Is there any way to count the number of currently connected clients in a zeromq socket? If that's not possible, is there any way to determine whether the socket has no client connected to it?
Thanks.
|
Counting The Number of Connection in a ZeroMQ Socket
| 1.2 | 0 | 1 | 1,053 |
12,372,258 |
2012-09-11T14:39:00.000
| 0 | 0 | 0 | 0 |
javascript,python,tags
| 12,372,353 | 2 | false | 1 | 0 |
Agree with @unwind , it depends on the content length of the text and your algorithm to grab the tags(scalability)
| 2 | 0 | 0 |
I'm thinking if a user submits a message and they click a 'suggest tags' button, their message would be analyzed and a form field populated wIthaca random words from their post.
Is it possible to do this on a scalable level? Would JavaScript be able to handle it or better to Ajax back to python?
I'm thinking certain common words would be excluded (a, the, and, etc) and maybe the 10 longest words or just random not common words would be added to a form field like "tag1, tag2, tag3"
|
Is it possible to automatically pull random "tags" from a long string of text?
| 0 | 0 | 1 | 60 |
12,372,258 |
2012-09-11T14:39:00.000
| 0 | 0 | 0 | 0 |
javascript,python,tags
| 12,372,295 | 2 | false | 1 | 0 |
Of course it's possible, you pretty much described the algorithm to test, and it doesn't seem to contain any obviously non-computable steps:
Split the message into words
Filter out the common words
Sort the words by length
Pick the top ten and present them as tags
Not sure what you mean by "scalable level", this sounds client-side to me. Unless the messages are very long, i.e. not typed in by a human, I don't think there will be any problems just doing it.
| 2 | 0 | 0 |
I'm thinking if a user submits a message and they click a 'suggest tags' button, their message would be analyzed and a form field populated wIthaca random words from their post.
Is it possible to do this on a scalable level? Would JavaScript be able to handle it or better to Ajax back to python?
I'm thinking certain common words would be excluded (a, the, and, etc) and maybe the 10 longest words or just random not common words would be added to a form field like "tag1, tag2, tag3"
|
Is it possible to automatically pull random "tags" from a long string of text?
| 0 | 0 | 1 | 60 |
12,375,113 |
2012-09-11T17:43:00.000
| 2 | 1 | 0 | 0 |
python,gmail,gmail-imap,imaplib
| 12,375,120 | 2 | false | 0 | 0 |
IMAP server is still imap.gmail.com -- try with that?
| 1 | 1 | 0 |
I am trying to download emails using imaplib with Python. I have tested the script using my own email account, but I am having trouble doing it for my corporate gmail (I don't know how the corporate gmail works, but I go to gmail.companyname.com to sign in). When I try running the script with imaplib.IMAP4_SSL("imap.gmail.companyname.com", 993), I get an error gaierror name or service not known. Does anybody know how to connect to a my company gmail with imaplib?
|
IMAP in Corporate Gmail
| 0.197375 | 0 | 1 | 321 |
12,375,173 |
2012-09-11T17:48:00.000
| 0 | 0 | 1 | 0 |
python,windows
| 42,477,949 | 19 | false | 0 | 0 |
I think I am too late to answer this question but anyways here goes nothing.
I have run in to the same problem before and I think there are two alternative solutions you can choose from.
using sleep(_sometime)
from time import *
sleep(10)
using a prompt message (note that I am using python 2.7)
exit_now = raw_input("Do you like to exit now (Y)es (N)o ? ")'
if exit_now.lower() = 'n'
//more processing here
Alternatively you can use a hybrid of those two methods as well where you can prompt for a message and use sleep(sometime) to delay the window closing as well. choice is yours.
please note the above are just ideas and if you want to use any of those in practice you might have to think about your application logic a bit.
| 8 | 42 | 0 |
I have just started college and we are going to be using python. We really have done nothing so I have downloaded the program and done some print commands, and that's it.
When I run my .py file (a print command) it immediately closes after appearing. I understand why it does this - it's given the output, so it's done what it needs to do - but I also understand that you can stop this from happening.
I looked around this website and none of the solutions given to this question worked, either that or I didn't understand them.
Is there a simple command I can input to my IDLE editor that will put the program on hold or something? I have tried input("prompt: ") as suggested by someone, and that made no difference.
If there isn't a command for this, is there a way to change the settings on the computer so that programs don't auto close?
|
How to stop Python closing immediately when executed in Microsoft Windows
| 0 | 0 | 0 | 225,642 |
12,375,173 |
2012-09-11T17:48:00.000
| 0 | 0 | 1 | 0 |
python,windows
| 50,656,710 | 19 | false | 0 | 0 |
Late in here, but in case someone comes here from google---
Go to the location of your .py file. Press SHIFT then right click anywhere and choose open command prompt from here. Once it's up, Just add
"python NameOfTheProg.py" to the cmd line
| 8 | 42 | 0 |
I have just started college and we are going to be using python. We really have done nothing so I have downloaded the program and done some print commands, and that's it.
When I run my .py file (a print command) it immediately closes after appearing. I understand why it does this - it's given the output, so it's done what it needs to do - but I also understand that you can stop this from happening.
I looked around this website and none of the solutions given to this question worked, either that or I didn't understand them.
Is there a simple command I can input to my IDLE editor that will put the program on hold or something? I have tried input("prompt: ") as suggested by someone, and that made no difference.
If there isn't a command for this, is there a way to change the settings on the computer so that programs don't auto close?
|
How to stop Python closing immediately when executed in Microsoft Windows
| 0 | 0 | 0 | 225,642 |
12,375,173 |
2012-09-11T17:48:00.000
| 0 | 0 | 1 | 0 |
python,windows
| 71,677,769 | 19 | false | 0 | 0 |
just put this line of code
input("")
It worked for me and it's show blank
Thanks!
| 8 | 42 | 0 |
I have just started college and we are going to be using python. We really have done nothing so I have downloaded the program and done some print commands, and that's it.
When I run my .py file (a print command) it immediately closes after appearing. I understand why it does this - it's given the output, so it's done what it needs to do - but I also understand that you can stop this from happening.
I looked around this website and none of the solutions given to this question worked, either that or I didn't understand them.
Is there a simple command I can input to my IDLE editor that will put the program on hold or something? I have tried input("prompt: ") as suggested by someone, and that made no difference.
If there isn't a command for this, is there a way to change the settings on the computer so that programs don't auto close?
|
How to stop Python closing immediately when executed in Microsoft Windows
| 0 | 0 | 0 | 225,642 |
12,375,173 |
2012-09-11T17:48:00.000
| 0 | 0 | 1 | 0 |
python,windows
| 41,017,183 | 19 | false | 0 | 0 |
Well I got similar issue,
It is solved by adding Environment Variable.
Add System Variables in Window
Name : PYTHONPATH
Value : C:\Python27;
Your Python path.
| 8 | 42 | 0 |
I have just started college and we are going to be using python. We really have done nothing so I have downloaded the program and done some print commands, and that's it.
When I run my .py file (a print command) it immediately closes after appearing. I understand why it does this - it's given the output, so it's done what it needs to do - but I also understand that you can stop this from happening.
I looked around this website and none of the solutions given to this question worked, either that or I didn't understand them.
Is there a simple command I can input to my IDLE editor that will put the program on hold or something? I have tried input("prompt: ") as suggested by someone, and that made no difference.
If there isn't a command for this, is there a way to change the settings on the computer so that programs don't auto close?
|
How to stop Python closing immediately when executed in Microsoft Windows
| 0 | 0 | 0 | 225,642 |
12,375,173 |
2012-09-11T17:48:00.000
| 0 | 0 | 1 | 0 |
python,windows
| 64,017,306 | 19 | false | 0 | 0 |
Just add an line of code in idle "input()"
| 8 | 42 | 0 |
I have just started college and we are going to be using python. We really have done nothing so I have downloaded the program and done some print commands, and that's it.
When I run my .py file (a print command) it immediately closes after appearing. I understand why it does this - it's given the output, so it's done what it needs to do - but I also understand that you can stop this from happening.
I looked around this website and none of the solutions given to this question worked, either that or I didn't understand them.
Is there a simple command I can input to my IDLE editor that will put the program on hold or something? I have tried input("prompt: ") as suggested by someone, and that made no difference.
If there isn't a command for this, is there a way to change the settings on the computer so that programs don't auto close?
|
How to stop Python closing immediately when executed in Microsoft Windows
| 0 | 0 | 0 | 225,642 |
12,375,173 |
2012-09-11T17:48:00.000
| -2 | 0 | 1 | 0 |
python,windows
| 62,414,792 | 19 | false | 0 | 0 |
Very simple:
Open command prompt as an administrator.
Type python.exe (provided you have given path of it in environmental variables)
Then, In the same command prompt window the python interpreter will start with >>>
This worked for me.
| 8 | 42 | 0 |
I have just started college and we are going to be using python. We really have done nothing so I have downloaded the program and done some print commands, and that's it.
When I run my .py file (a print command) it immediately closes after appearing. I understand why it does this - it's given the output, so it's done what it needs to do - but I also understand that you can stop this from happening.
I looked around this website and none of the solutions given to this question worked, either that or I didn't understand them.
Is there a simple command I can input to my IDLE editor that will put the program on hold or something? I have tried input("prompt: ") as suggested by someone, and that made no difference.
If there isn't a command for this, is there a way to change the settings on the computer so that programs don't auto close?
|
How to stop Python closing immediately when executed in Microsoft Windows
| -0.02105 | 0 | 0 | 225,642 |
12,375,173 |
2012-09-11T17:48:00.000
| 1 | 0 | 1 | 0 |
python,windows
| 51,530,192 | 19 | false | 0 | 0 |
The reason why it is closing is because the program is not running anymore, simply add any sort of loop or input to fix this (or you could just run it through idle.)
| 8 | 42 | 0 |
I have just started college and we are going to be using python. We really have done nothing so I have downloaded the program and done some print commands, and that's it.
When I run my .py file (a print command) it immediately closes after appearing. I understand why it does this - it's given the output, so it's done what it needs to do - but I also understand that you can stop this from happening.
I looked around this website and none of the solutions given to this question worked, either that or I didn't understand them.
Is there a simple command I can input to my IDLE editor that will put the program on hold or something? I have tried input("prompt: ") as suggested by someone, and that made no difference.
If there isn't a command for this, is there a way to change the settings on the computer so that programs don't auto close?
|
How to stop Python closing immediately when executed in Microsoft Windows
| 0.010526 | 0 | 0 | 225,642 |
12,375,173 |
2012-09-11T17:48:00.000
| 3 | 0 | 1 | 0 |
python,windows
| 65,952,963 | 19 | false | 0 | 0 |
I know a simple answer!
Open your cmd, the type in: cd C:\directory your file is in and then type python your progam.py
| 8 | 42 | 0 |
I have just started college and we are going to be using python. We really have done nothing so I have downloaded the program and done some print commands, and that's it.
When I run my .py file (a print command) it immediately closes after appearing. I understand why it does this - it's given the output, so it's done what it needs to do - but I also understand that you can stop this from happening.
I looked around this website and none of the solutions given to this question worked, either that or I didn't understand them.
Is there a simple command I can input to my IDLE editor that will put the program on hold or something? I have tried input("prompt: ") as suggested by someone, and that made no difference.
If there isn't a command for this, is there a way to change the settings on the computer so that programs don't auto close?
|
How to stop Python closing immediately when executed in Microsoft Windows
| 0.031568 | 0 | 0 | 225,642 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.