Q_Id
int64
2.93k
49.7M
CreationDate
stringlengths
23
23
Users Score
int64
-10
437
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
DISCREPANCY
int64
0
1
Tags
stringlengths
6
90
ERRORS
int64
0
1
A_Id
int64
2.98k
72.5M
API_CHANGE
int64
0
1
AnswerCount
int64
1
42
REVIEW
int64
0
1
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
15
5.1k
Available Count
int64
1
17
Q_Score
int64
0
3.67k
Data Science and Machine Learning
int64
0
1
DOCUMENTATION
int64
0
1
Question
stringlengths
25
6.53k
Title
stringlengths
11
148
CONCEPTUAL
int64
0
1
Score
float64
-1
1.2
API_USAGE
int64
1
1
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
15
3.72M
3,110,166
2010-06-24T13:05:00.000
5
0
0
0
0
python,django,templates,ternary-operator
0
3,110,234
0
6
0
false
1
0
You don't. The Django {% if %} templatetag has only just started supporting ==, and, etc. {% if cond %}{% else %}{% endif %} is as compact as it gets for now.
1
70
0
0
I was wondering if there was a ternary operator (condition ? true-value : false-value) that could be used in a Django template. I see there is a python one (true-value if condition else false-value) but I'm unsure how to use that inside a Django template to display the html given by one of the values. Any ideas?
Django Template Ternary Operator
0
0.16514
1
0
0
35,699
3,118,008
2010-06-25T12:35:00.000
4
0
1
0
0
python,module
0
3,118,063
0
3
0
false
0
0
There are a lot of ways to factor code so it is reusable. It really depends on your specific situation as far as what will work best. Factoring your code into separate packages and modules is always a good idea, so related code stays bundled together and can be reused from other packages and modules. Factoring your code into classes within a module can also help in keeping related code grouped together. I would say that putting common code into a module or package that is on your PYTHONPATH and available to both applications would probably be your best solution.
1
19
0
0
I'm currently maintaining two of my own applications. They both share some common aspects, and as a result, share some code. So far, I've just copied the modules from one project to the other, but now it's becoming a maintenance issue. I'd rather have the common code in one place, outside of both of the projects, which they can both import. Then, any changes to the common code would be reflected in both project. My question is: how can I do this? Do I create a library out of this code? If so, how do the dependent projects use the library? I think one thing I struggle with here is that the common code isn't really useful to anyone else, or at least, I don't want to make it a supported modules that other people can use. If my question isn't clear, please let me know.
How can I use common code in python?
0
0.26052
1
0
0
10,091
3,122,291
2010-06-26T00:55:00.000
3
0
0
0
0
python,grid,tcl,rad
0
3,122,400
0
1
1
false
0
1
Tk has three methods. One is absolute positioning, the other two are called "grid" and "pack". grid is just what it sounds like: you lay out your widgets in a grid. There are options for spanning rows and columns, expanding (or not) to fill a cell, designating rows or columns which can grow, etc. You can accomplish probably 90% of all layout issues with the grid geometry manager. The other manager is "pack" and it works by requesting that widgets be placed on one side or another (top, bottom, left, right). It is remarkably powerful, and with the use of nested containers (called frames in tk) you can accomplish pretty much any layout as well. Pack is particularly handy when you have things stacked in a single direction, such as horizontally for a toolbar, vertically for a main app (toolbar, main area, statusbar). Both grid and pack are remarkably powerful and simple to use, and between them can solve any layout problem you have. It makes me wonder why Java and wxPython have so many and such complicated geometry managers when its possible to get by with no more than three.
1
0
0
0
I've been working with a few RAD gui builders lately. I absolutely despise CSS ( camel is a horse designed by committee etc.) What algorithms are used by packing managers(java/tk). Most GUI toolkits I've used have some alternative to absolute positioning, sorry for the ambiguity but how do you start thinking about implementing a packing manger in language X. Thanks for the replies, to clarify - I want to create a generic text file that defines a 'form' this form file can then be used to generated a native(ish) GUI form (eg tk) and also an HTML form. What I'm looking for is some pointers on how a grid based packing manager is implemented so I can formulate my generic text file based on some form of established logic. If this doesn't make sense to you then you understand me:). Some notes 1. XML lives in the same stable as the zebra and the camel but not the horse. 2. Think lightweight markup languages (Markdown/ReStructuredText) but for simple forms. 3. This has probably already been implemented, do you know where? 4. Yes, I have Googled it (many,many times),answer was not between G1 and o2 Thks
GUI layout -how?
0
0.53705
1
0
0
306
3,126,155
2010-06-27T02:19:00.000
2
0
0
0
0
python,sql,mysql,database
0
3,126,208
0
4
1
false
1
0
MySQL is really your best choice for the database unless you want to go proprietary. As for the actual language, pick whatever you are familiar with. While Youtube and Reddit are written in python, many of the other large sites use Ruby (Hulu, Twitter, Techcrunch) or C++ (Google) or PHP (Facebook, Yahoo, etc).
1
4
0
0
My two main requirements for the site are related to degrees of separation and graph matching (given two graphs, return some kind of similarity score). My first thought was to use MySql to do it, which would probably work out okay for storing how I want to manage 'friends' (similar to Twitter), but I'm thinking if I want to show users results which will make use of graphing algorithms (like shortest path between two people) maybe it isn't the way to go for that. My language of choice for the front end, would be Python using something like Pylons but I haven't committed to anything specific yet and would be willing to budge if it fitted well with a good backend solution. I'm thinking of using MySQL for storing user profile data, neo4j for the graph information of relations between users and then have a Python application talk to both of them. Maybe there is a simpler/more efficient way to do this kind of thing. At the moment for me it's more getting a suitable prototype done than worrying about scalability but I'm willing to invest some time learning something new if it'll save me time rewriting/porting in the future. PS: I'm more of a programmer than a database designer, so I'd prefer having rewrite the frontend later rather than say porting over the database, which is the main reason I'm looking for advice.
What should I use for the backend of a 'social' website?
1
0.099668
1
1
0
749
3,126,802
2010-06-27T08:17:00.000
0
0
0
0
1
python,gtk,pygtk
0
3,128,879
0
3
0
false
0
1
In most recent versions of PyGTK you can get/set those values via table.props.n_columns and table.props.n_rows, which is synonymous with the get_property() (mentioned in the other answers) and set_property() methods.
1
0
0
0
I am having a problem with widget Gtk.Table - I would like to know, if there is a way how to get a current size of the table (number of rows and columns). Thank you, very much for help, Tomas
Getting size of Gtk.Table in python
1
0
1
0
0
881
3,126,969
2010-06-27T09:36:00.000
2
0
0
0
0
python,django,url,post,django-views
1
3,127,296
0
4
0
true
1
0
A modified option #1 is the best approach. Consider this: suppose we weren't talking about a web app, but instead were just designing an inbox class. Which do you like better, a number of methods (delete_message(), mark_as_spam(), etc), or one big method (do_stuff(action))? Of course you would use the separate methods. A separate URL for each action, each with a separate view, is far preferable. If you don't like the redirect at the end, then don't use it. Instead, have a render_inbox(request) method that returns an HttpResponse, and call the method at the end of each of your views. Of course, redirecting after a POST is a good way to prevent double-actions, and always leaves the user with a consistent URL. Even better might be to use Ajax to hide the actions, but that is more involved.
4
4
0
0
I'm wondering if it's considered okay (particularly, in Django) to have a URL that's only intended for actions with side effects, that's only intended to be accessed by POST, and that is basically invisible to the user. Let's say, for the sake of making this concrete, I have a little messaging system on my site, and from their inbox, a user should be able to do a bunch of things like: Delete a message Mark a message as read Report a message as spam With all of those things causing a page refresh, but leading back to the same page. I'm wondering how to design my URLs and views around this. I see (at least) two options, and I have no idea which is more idiomatic. Option 1) Have a separate URL and view for each action. So, /inbox/delete-message/ maps to views.delete_message, and so on. At the end of each of those views, it redirects back to /inbox/. I like the way things are clearly separated with this option. If a user somehow finds themselves sending a GET request to /inbox/delete-message/, that presents a sort of weird situation though (do I throw up an error page? silently redirect them?). Option 2) Use the same URL and view for each action, and have a POST parameter that identifies the action. So I would have one rather long inbox view, which would have a bunch of if statements testing whether request.POST['action'] == 'delete', or request.POST['delete'] == 'true' or whatever. This option feels less clean to me, but I also feel like it's more common. Which would be preferred by Djangonauts? Or is there another option that's better than either of the above?
URLs and side effects (Django)
1
1.2
1
0
0
334
3,126,969
2010-06-27T09:36:00.000
1
0
0
0
0
python,django,url,post,django-views
1
3,127,290
0
4
0
false
1
0
If you're writing a web 2.0 messaging app, you would be using AJAX calls and wouldn't be loading a new page at all. The process would proceed like so: User clicks [delete] for a message. This button has a javascript action bound to it. This action does the following: i. Change the UI to indicate that something is happening (grey the message or put up an hourglass). ii. Send a request to /messages/inbox/1234/delete. (where 1234 is some identifier that indicates which message) iii. When the response from the server comes back, it should indicate success or failure. Reflect this status in the current UI. For example, on success, refresh the inbox view (or just remove the deleted item). On the server side, now you can create a URL handler for each desired action (i.e. /delete, /flag, etc.). If want to use an even more RESTful approach, you would use the HTTP action itself to indicate the action to perform. So instead of including delete in your URL, it would be in the action. So instead of GET or POST, use DELETE /messages/inbox/1234. To set a flag for having been read, use SET /messages/inbox/1234?read=true. I don't know how straightforward it is in Django to implement this latter recommendation, but in general, it's a good idea utilize the protocol (in this case HTTP), rather than work around it by encoding your actions into a URL or parameter.
4
4
0
0
I'm wondering if it's considered okay (particularly, in Django) to have a URL that's only intended for actions with side effects, that's only intended to be accessed by POST, and that is basically invisible to the user. Let's say, for the sake of making this concrete, I have a little messaging system on my site, and from their inbox, a user should be able to do a bunch of things like: Delete a message Mark a message as read Report a message as spam With all of those things causing a page refresh, but leading back to the same page. I'm wondering how to design my URLs and views around this. I see (at least) two options, and I have no idea which is more idiomatic. Option 1) Have a separate URL and view for each action. So, /inbox/delete-message/ maps to views.delete_message, and so on. At the end of each of those views, it redirects back to /inbox/. I like the way things are clearly separated with this option. If a user somehow finds themselves sending a GET request to /inbox/delete-message/, that presents a sort of weird situation though (do I throw up an error page? silently redirect them?). Option 2) Use the same URL and view for each action, and have a POST parameter that identifies the action. So I would have one rather long inbox view, which would have a bunch of if statements testing whether request.POST['action'] == 'delete', or request.POST['delete'] == 'true' or whatever. This option feels less clean to me, but I also feel like it's more common. Which would be preferred by Djangonauts? Or is there another option that's better than either of the above?
URLs and side effects (Django)
1
0.049958
1
0
0
334
3,126,969
2010-06-27T09:36:00.000
0
0
0
0
0
python,django,url,post,django-views
1
3,127,284
0
4
0
false
1
0
I agree that #2 is a better approach. But take care with overloading the submit <input /> with different methods -- if a user is using it with keyboard input and hits enter, it won't necessarily submit the <input /> you're expecting. Either disable auto-submit-on-enter, or code things up so that if there is more than one thing that submit can do, there's another field that sets what the action should be (eg a 'delete' checkbox, which is tested during a request.POST) If you went with #1 I'd say that a GET to a POST-only view should be met with a 405 (method not supported) - or, failing that, a 404.
4
4
0
0
I'm wondering if it's considered okay (particularly, in Django) to have a URL that's only intended for actions with side effects, that's only intended to be accessed by POST, and that is basically invisible to the user. Let's say, for the sake of making this concrete, I have a little messaging system on my site, and from their inbox, a user should be able to do a bunch of things like: Delete a message Mark a message as read Report a message as spam With all of those things causing a page refresh, but leading back to the same page. I'm wondering how to design my URLs and views around this. I see (at least) two options, and I have no idea which is more idiomatic. Option 1) Have a separate URL and view for each action. So, /inbox/delete-message/ maps to views.delete_message, and so on. At the end of each of those views, it redirects back to /inbox/. I like the way things are clearly separated with this option. If a user somehow finds themselves sending a GET request to /inbox/delete-message/, that presents a sort of weird situation though (do I throw up an error page? silently redirect them?). Option 2) Use the same URL and view for each action, and have a POST parameter that identifies the action. So I would have one rather long inbox view, which would have a bunch of if statements testing whether request.POST['action'] == 'delete', or request.POST['delete'] == 'true' or whatever. This option feels less clean to me, but I also feel like it's more common. Which would be preferred by Djangonauts? Or is there another option that's better than either of the above?
URLs and side effects (Django)
1
0
1
0
0
334
3,126,969
2010-06-27T09:36:00.000
1
0
0
0
0
python,django,url,post,django-views
1
3,127,022
0
4
0
false
1
0
I don't think there's anything wrong with either option, but #2 is potentially better from a performance standpoint. After the action is posted you can render the inbox without a redirect, so it cuts down on the HTTP traffic.
4
4
0
0
I'm wondering if it's considered okay (particularly, in Django) to have a URL that's only intended for actions with side effects, that's only intended to be accessed by POST, and that is basically invisible to the user. Let's say, for the sake of making this concrete, I have a little messaging system on my site, and from their inbox, a user should be able to do a bunch of things like: Delete a message Mark a message as read Report a message as spam With all of those things causing a page refresh, but leading back to the same page. I'm wondering how to design my URLs and views around this. I see (at least) two options, and I have no idea which is more idiomatic. Option 1) Have a separate URL and view for each action. So, /inbox/delete-message/ maps to views.delete_message, and so on. At the end of each of those views, it redirects back to /inbox/. I like the way things are clearly separated with this option. If a user somehow finds themselves sending a GET request to /inbox/delete-message/, that presents a sort of weird situation though (do I throw up an error page? silently redirect them?). Option 2) Use the same URL and view for each action, and have a POST parameter that identifies the action. So I would have one rather long inbox view, which would have a bunch of if statements testing whether request.POST['action'] == 'delete', or request.POST['delete'] == 'true' or whatever. This option feels less clean to me, but I also feel like it's more common. Which would be preferred by Djangonauts? Or is there another option that's better than either of the above?
URLs and side effects (Django)
1
0.049958
1
0
0
334
3,127,915
2010-06-27T16:07:00.000
0
0
1
1
0
python,google-app-engine
0
3,130,801
0
3
0
false
1
0
OK, I figured out the answer to my own question, partly with the help of Nicholas Knight who pointed out that you just install different Python version to different Python directories. I was left scratching my head on how to get Google App Engine to use Python 2.5 (the required version) instead of Python 2.6. This is the answer: 1) Install Python 2.5. 2) Install Python 2.6 (or a more recent version), afterwards. This will be the system default. 3) Install the Google App Engine SDK. 4) Launch, "Google App Engine Launcher" from the Start Menu 5) Click Edit > Preferences, and enter the path to the pythonw.exe executable. Usually c:\Python25\pythonw.exe
2
4
0
0
I've been learning Python for a couple of weeks, and although I've been successfully develop apps for Google App Engine with Python 2.6.5, it specifically requires Python 2.5. Being mindful of compatibility issues when uploading apps (it's a situation I'd rather avoid while learning Python), I wonder if it's possible to have 2.5 and 2.6.5 installed on the same machine. Ideally I'd like to use 2.6.5 as the default, and configure GAE to somehow use 2.5.
Is it possible to run two versions of Python side-by-side?
1
0
1
0
0
758
3,127,915
2010-06-27T16:07:00.000
5
0
1
1
0
python,google-app-engine
0
3,127,950
0
3
0
false
1
0
Absolutely. If you're on *nix, you'd usually just use make altinstall instead of make install, that way the "python" binary won't get installed/overwritten, but instead you'd have e.g. python2.5 or python2.6 installed. Using a separate --prefix with the configure script is also an option, of course. Some Linux distributions will have multiple versions available via their package managers. They'll similarly be installed as python2.5 etc. (With the distribution's blessed/native version also installed as the regular python binary.) Windows users generally just install to different directories.
2
4
0
0
I've been learning Python for a couple of weeks, and although I've been successfully develop apps for Google App Engine with Python 2.6.5, it specifically requires Python 2.5. Being mindful of compatibility issues when uploading apps (it's a situation I'd rather avoid while learning Python), I wonder if it's possible to have 2.5 and 2.6.5 installed on the same machine. Ideally I'd like to use 2.6.5 as the default, and configure GAE to somehow use 2.5.
Is it possible to run two versions of Python side-by-side?
1
0.321513
1
0
0
758
3,131,977
2010-06-28T11:38:00.000
0
0
0
1
0
python,c,printf,ctypes
0
3,133,108
0
2
0
false
0
0
Well printf simply writes its output to whatever the stdout file pointer refers to. Im not sure how you're executing the C program, but it should be possible to redirect the C program's stdout to something that you can read in Python.
1
5
0
1
I hope this is trivial and I just didn't find it in the tutorials. I am writing python code that 'supervises' c code, aka I run the c code with ctypes from python. Now I want to 'catch' the c 'printfs' to process the data that is output by the c code. Any idea how one would do this? Thanks
How to 'catch' c printf in python with ctypes?
0
0
1
0
0
2,287
3,136,423
2010-06-28T21:52:00.000
0
0
1
0
1
python,django
0
3,139,071
0
3
0
false
1
0
Just "throw" the django tarball within the site-packages (dist-packages in py2.6+) and you are done. What for do you need macports etc, with a pure python library?
1
2
0
0
I have Python 2.6 & 3.1 installed on Leopard via mac ports with no problems. I want to install Django 1.2 via mac ports for Python 2.6, but a google search of how to do it seems to point me in the wrong direction. Can anyone point me in the right direction? Thanks again.....
Trying to install Django via Macports on Leopard
0
0
1
0
0
936
3,147,213
2010-06-30T07:29:00.000
0
0
1
0
0
python,macports,installation
0
5,876,565
0
1
0
false
0
0
This answer is outdated, see Mark's response below I had trouble installing python and python libraries on osx, and this is what I ended up doing to fix it: Using macports I installed python26 and python_select. Then use python_select to change from the default python26-apple to python26 (which is from macports). Now when you use macports to install any python26 library it will just work. One of the main drawbacks of this approach is that macports installs everything from source, which is slow and buggy compared to using pre-build binaries, but for me it's worth it to be able to manage most of my FOSS software through macports.
1
0
0
0
I would like to install: A. Mod python on a regular Macbookpro (MacOSX 10.6.4) B. And MySQL for Python on the same computer. And the installation is constantly failing. Question 1: Is there a tutorial on how to achieve this on Mac OS? I also hoped that I could use Macports for this. I had bad experience with Macports and installing python. I am sure this is due to my not understanding the concept of: ports profile (pythonpath) Question 2: What would I have to write in the .profile to make packages be recognized by python? Question 3: What exactly is a port? In general it would be awesome to get an understanding on how to install packages in python quick and effectively. Also the build in version of Python by Apple seems to have settings, that, if changed can make your life difficult. Question 4: Any detailed experience or advice on this issues would he very helpful. For a quick start into programming. Thanks!
Python library installing macports
0
0
1
0
0
285
3,147,267
2010-06-30T07:38:00.000
0
1
0
1
0
python,google-app-engine,email
0
3,194,130
0
4
0
true
1
0
easiest is to encode an email address via base64 or simiar encoding and prefixed it to from address. all address from [email protected] are valid email address for from in gae. simply create a mail receive handler. decode the from string and get the email address to whom you send the email originally. sad thing is maximum 64 character length allowed for local part. in that case storing email address in datastore and using its key as a local part to email can be a option.
1
3
0
0
sometime due to wrong input from user side, mail bounce and did not reach the recipient. ( sent from google app engine.) How to detect such email ? edit: may be i was not clear in my question : I want to know to which mail i have sent the mail which was return ( so that i may alert the user or delete the email id ). this is more related to how email bounce works. normally the bounce mail does not come exactly same as sent but with different information, is there any particular header or something there to know which email id was that ? ... i think i have figure out while writing these, i am keeping this question so it might help somebody. i will simply mail from [email protected] and create a mail receive handler. :) so one more question : what is the maximum length does app-engine ( or any mail server ) allows for email address ?
how to detect bounce mail in google app engine?
1
1.2
1
0
0
1,227
3,148,483
2010-06-30T10:50:00.000
2
0
1
0
0
python,py2exe
0
5,093,220
0
1
0
true
0
0
An effective solution is to bundle everything in an standalone executable using bundle_files:1 in your setup.py py2exe options.
1
2
0
0
I use Py2exe to package a Python application with quite a few dependant packages. While Py2exe works flawlessly the resulting dist/ folder with the executable contains a large number (10-15) of support files (.dll, .pyd, .zip). Ideally I would like to be able to place all of these dependant files in a folder called support/ or lib/ or something to that effect. This way when people download the application and extract the archive they are only presented with an executable and some folders. Does Py2exe support placing dependant files in a sub-folder? If so, how can one accomplish this.
Py2exe Directory Structure
0
1.2
1
0
0
564
3,155,624
2010-07-01T06:52:00.000
1
0
0
0
0
python,django,django-admin,customization
0
33,733,949
0
4
0
false
1
0
Django Admin is easy to customize if your requirements match what is customizable in Django. If you need fancy features that are not out-of-the-box functionality you either need to find a plugin that does it, or implement it yourself by subclassing the appropriate classes. Which can be difficult, and requires good understanding of the internals of Django. So in summary: it makes it easier to setup an admin, but if you need anything special that's not out of the box: you got a steep learning curve. Depending on your requirements you can choose to use django or not. Anything that requires a lot of functional speccing is better of implemented manually.
2
25
0
0
I have been playing for a couple of days with Django Admin to explore it, but I am still clueless of how it can be customized in the way we need. Every time I look for any help for the customization in the admin panel, what I find is, a bunch of articles on various communities and forums, explaining how to customize the template, the lists items, the the column views etc. But that should not be called Django Customization. If I need to make even a small change in the User functionality or any modification to the auth module. It takes a lots of efforts even in figuring out how that can be done. Is Django that difficult to customize or its just lack of the help available over internet for this or its me who is moving in the wrong direction ?
Is Django admin difficult to customize?
0
0.049958
1
0
0
21,336
3,155,624
2010-07-01T06:52:00.000
3
0
0
0
0
python,django,django-admin,customization
0
11,705,960
0
4
0
false
1
0
Personally, if you want a site to look like the admin, why not pull the templates and styles and use them, build your own views for what you need. Gobs of documentation and forum help is there for that. I like the idea of customizing the admin, but honestly, I have been doing it for awhile on a project and time and time again I think to myself, if this was built in the standard MVC (or MTV) manner with free templates online, copied admin ones, or some professionally made ones, and built with the plethora of addons and my code, it would be much easier!!! And, when you decide that request/response isn't cutting it, and you want to add lots of JavaScript, you'll be glad. I know. I have had to put all sorts of JavaScript on our Admin project. Mostly because it's impossible to make the admin do what we want, so we fix it with JavaScript once it is on screen. When you find yourself writing an Ajax based system, you'll wonder why you have the admin at all. If I could start this project over, I might not even use Django, but I probably would. I most certainly won't used the Admin. Now, if you are building an basic CRUD type site that doesn't have style-eyed users, then Django with grappelli, and some elbow grease will get the job done. Remember, Django is a collection of Python scripts. Just override everything you can, and you'll get there, if you aren't too ambitious.
2
25
0
0
I have been playing for a couple of days with Django Admin to explore it, but I am still clueless of how it can be customized in the way we need. Every time I look for any help for the customization in the admin panel, what I find is, a bunch of articles on various communities and forums, explaining how to customize the template, the lists items, the the column views etc. But that should not be called Django Customization. If I need to make even a small change in the User functionality or any modification to the auth module. It takes a lots of efforts even in figuring out how that can be done. Is Django that difficult to customize or its just lack of the help available over internet for this or its me who is moving in the wrong direction ?
Is Django admin difficult to customize?
0
0.148885
1
0
0
21,336
3,157,875
2010-07-01T12:45:00.000
17
0
0
0
0
python,django,logging,django-admin
0
3,157,915
0
3
0
false
1
0
Log is in django_admin_log table in database used by django.
1
32
0
0
I need to track/log activity on the Django admin. I know there are messages stored by admin somewhere, but I don't know how to access them in order to use them as a simple log. I'm trying to track the following: User performing the action Action committed Datetime of action Thanks guys.
Logging activity on Django's admin - Django
0
1
1
0
0
30,210
3,160,699
2010-07-01T18:39:00.000
0
0
1
0
0
python,progress-bar
0
3,160,926
0
42
0
false
0
0
You should link the progress bar to the task at hand (so that it measures the progress :D). For example, if you are FTPing a file, you can tell ftplib to grab a certain size buffer, let's say 128K, and then you add to your progress bar whatever percentage of the filesize 128k represents. If you are using the CLI, and your progress meter is 20 characters long, you would add one character when 1/20th of the file had transferred.
1
476
0
0
How do I use a progress bar when my script is doing some task that is likely to take time? For example, a function which takes some time to complete and returns True when done. How can I display a progress bar during the time the function is being executed? Note that I need this to be in real time, so I can't figure out what to do about it. Do I need a thread for this? I have no idea. Right now I am not printing anything while the function is being executed, however a progress bar would be nice. Also I am more interested in how this can be done from a code point of view.
Python Progress Bar
0
0
1
0
0
744,169
3,167,469
2010-07-02T16:27:00.000
0
0
0
1
0
c#,java,python,hostname
0
3,167,542
0
3
1
false
0
0
In Windows you have to modify registry keys and the reboot the system. You actually have to change two entries: HostName under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TcpIp\Parameters and ComputerName under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName Please note that if the computer ha joined an NT Domain this change could be harmful (and in this case you have an additional entry to change under TcpIp\Parameters).
1
1
0
0
I need to automate the changing of the hostname of a computer, but I can't figure out how to do it inside a program. My options are open; I would be happy with a solution in any of the following: Command line Java Python C# (would prefer one of the other 3, but this is ok) It would be helpful to learn how to do this on both Linux and Windows.
Rename a computer programmatically
0
0
1
0
0
2,734
3,171,824
2010-07-03T14:40:00.000
10
0
1
0
0
python,super
0
3,171,872
0
4
0
false
0
0
Simply remember that the self is optional - super(Type) gives access to unbound superclass methods - and optional arguments always come last.
1
7
0
0
As the title says, how do you remember the order of super's arguments? Is there a mnemonic somewhere I've missed? After years of Python programming, I still have to look it up :( (for the record, it's super(Type, self))
Python: how do you remember the order of `super`'s arguments?
0
1
1
0
0
631
3,172,535
2010-07-03T19:03:00.000
0
0
0
0
0
python,blender
0
3,172,669
0
2
0
false
0
1
One cheap and easy method for doing this would be to create the triangle and subdivide the faces down to the level of detail you want, then normalize all the vertices to the radius you want.
1
3
0
0
Suppose you know the three vertices for a spherical triangle. Then how do you draw the sides on a sphere in 3D? I need some python code to use in Blender 3d modelisation software. I already have the sphere done in 3D in Blender. Thanks & happy blendering. note 1: i have the 3 points / vertices (p1,p2,p3 ) on the sphere for a spherical triangle but i need to trace the edges on the sphere in 3D so what would be the equations needed to determine all vertices between each points pair of the triangle on the sphere 3 edges from p1 to p2 - p2 to p3 and o3 to p1 i know it has something to do with the Great circle for Geodesic on a sphere but cannot find the proper equations to do the calculations in spherical coordinates! Thanks Great circles it would have been interesting to see a solution with great circle and see tehsolution in spherical coordinates directly ! but still interesting to do it in the euclidiens space Thanks ok i used this idea of line segment between 2 points but did not do it as indicated before i used an alternative method - Bezier line interpolation** i parametrize the line with a bezier line then subdivided and calculated as shonw ealier the ratio and angle for each of the subdivided bezier point on the chord and it works very well and very precise but it would be interesting to see how it is done whit the earlier method but not certain how to do the iteration loop? how do you load up the python code here just past it with Ctrl-V? Thanks and happy 2.5 i do use the blenders' forum but no guaranti to get a clear answer all the time! that's why i tried here - took a chance i did the first edge seems to work now got to make a loop to get multi segment for first edge and then do the other edges also 2- other subject i open here a post on bezier triangle patch i know it's not a usfull tool but just to show how it is done have youeseen a python sript to do theses triangel patch and i did ask this questin on blender's foum and no answer also on IRC python and sems to be dead right now probably guys are too busy finishing the 2.5 Beta vesion which should come out in a week or 2 Hey Thanks a lot for this math discussion if i have problem be back tomorrow happy math and 2.5
How to draw a spherical triangle on a sphere in 3D?
0
0
1
0
0
3,171
3,173,047
2010-07-03T22:26:00.000
1
0
0
0
0
python,macos,qt
0
4,022,382
0
3
0
false
0
1
I've tried the same for some weeks now. Finally i have to say py2app just wont do. I was lucky with pyinstaller1.4. Although you need to add some minor modifications to run flawlessly on OS X. Furthermore the apps it creates are only 1/4 of the size compared to py2app. And most important it works :) And yet another goodie ... it works with the python framework which ships with OS X so there is no need to install python via MacPorts etc.
1
2
0
0
I've recently started using a mac, and I'm curious about how to make a mac app that uses PyQt and is self-contained. Can anyone give me any pointers on where to start and what I'll need?
How to create a self contained Python Qt app on mac
0
0.066568
1
0
0
1,222
3,173,154
2010-07-03T23:14:00.000
1
0
1
0
0
python,list
0
62,608,192
0
8
0
false
0
0
I profiled a few methods to move an item within the same list with timeit. Here are the ones to use if j>i: ┌──────────┬──────────────────────┐ │ 14.4usec │ x[i:i]=x.pop(j), │ │ 14.5usec │ x[i:i]=[x.pop(j)] │ │ 15.2usec │ x.insert(i,x.pop(j)) │ └──────────┴──────────────────────┘ and here the ones to use if j<=i: ┌──────────┬───────────────────────────┐ │ 14.4usec │ x[i:i]=x[j],;del x[j] │ │ 14.4usec │ x[i:i]=[x[j]];del x[j] │ │ 15.4usec │ x.insert(i,x[j]);del x[j] │ └──────────┴───────────────────────────┘ Not a huge difference if you only use it a few times, but if you do heavy stuff like manual sorting, it's important to take the fastest one. Otherwise, I'd recommend just taking the one that you think is most readable.
1
126
0
0
In Python, how do I move an item to a definite index in a list?
Move an item inside a list?
0
0.024995
1
0
0
162,145
3,174,374
2010-07-04T10:28:00.000
0
0
0
1
0
python,twisted
0
3,175,439
0
1
0
false
0
0
I don't think this really provides the direction the user requires - the question seems to be clear in how to use Twisted to achieve this - the answer implies reasonable knowledge of Twisted.
1
2
0
0
How do I download a remote file into several chunks using twisted? Lets say if the file is 100 bytes, I want to spawn 10 connection which will read 10 bytes each but in no particular order and then later on merge them all. I was able to do this using threads in Python but I don't have any idea how to use twisted's reactor + manager + protocol to achieve the same. Any advice as to how should I design this?
How to design a twisted solution to download a file by reading on certain portion?
1
0
1
0
0
427
3,177,057
2010-07-05T03:02:00.000
1
0
0
1
0
python,gnome,vala,compiz
0
3,185,814
0
1
0
false
0
0
You want to look into gnome-compiz especially into gtk-window-decorator and gnome-xgl-settings.
1
0
0
0
Several laptops on the market have problems with Linux for brightness controls. However, recently I found out that you can use CompizConfig settings to dim at least a particular window. Many people, however, want to dim all windows. I know Compiz can do this in the API somewhere because look what happens when you do Super + Tab in Compiz. So this got me thinking...what I need to build is a GNOME applet in either Python, or perhaps this new Vala language, that interfaces with the Compiz API and lets me dim the entire screen. Does anyone know where I might find some programming resources to learn how to use Compiz API in Python or Vala to dim the screen?
Controlling Linux Compiz Brightness Programmatically with Python or Vala
0
0.197375
1
0
0
579
3,179,469
2010-07-05T12:34:00.000
0
0
1
0
0
python,qt,pyqt,paint
0
3,497,327
0
3
0
false
0
1
Have you looked at the scribble example included in PyQt? It does basic drawing, saving, loading, etc.
1
0
0
0
i have just received a task to implement a software that paints over pictures (pretty much like microsoft paint ) i have no idea where to start or how to do that. do anyone have a good reference or idea for painting in qt or pyqt ? this will be highly appreciated thanks in advance
making paint in pyqt or qt
0
0
1
0
0
1,562
3,183,431
2010-07-06T04:03:00.000
1
0
1
0
0
python,design-patterns
0
3,183,465
0
2
0
true
1
0
It really depends on how you interact with the structures in question. Do you manipulate Form and Field objects prior to assigning them values? Do you need to frequently iterate over all the given Fields? Do you need Form once it's been submitted? Etc. I'd suggest writing some/all of the code that uses Form and figure out how you want to interact with Form data, and what your ideal interface would look like.
1
1
0
0
Forms have Fields, Fields have a value. However, they only get a value after the form has been submitted. How should I store this value? Should I give every field a value attribute, field.value, leave it as None prior to posting, and fill it in afterwords? Omit it completely, and dynamically add it? Store it on the form instead, like form.data['field']. Create a a wrapper class FieldWithData to avoid any inconsistent states (if you have an object of this type, you know it has data) and allows me to set the data in the initializer rather than accessing attributes directly (although I guess this isn't so different from using a setter) How should I provide access to the field data through the Form object? Options: form.fields['name'].value (how it's presently being stored internally) form.data['field'] (create a proxy "data" class that retrieves the real data off the field, or re-arrange the internals to actually store the data like this) form.field.value - looks fairly nice, but then I'd have two references to the same field, one as form.field and one as form.fields['field'] which I need internally so that I can iterate over them Too many design decisions. Driving me nuts. This is what sucks about solo'ing a project.
Where to store field data and how to provide access to it?
0
1.2
1
0
0
91
3,190,122
2010-07-06T20:51:00.000
1
0
1
0
0
python,string,list,range,ascii
0
3,190,229
0
18
0
false
0
0
This is your 2nd question: string.lowercase[ord('a')-97:ord('n')-97:2] because 97==ord('a') -- if you want to learn a bit you should figure out the rest yourself ;-)
1
142
0
0
1. Print a-n: a b c d e f g h i j k l m n 2. Every second in a-n: a c e g i k m 3. Append a-n to index of urls{hello.com/, hej.com/, ..., hallo.com/}: hello.com/a hej.com/b ... hallo.com/n
Python: how to print range a-z?
0
0.011111
1
0
0
323,159
3,193,756
2010-07-07T10:07:00.000
2
0
0
0
0
python,machine-learning,adaboost
0
3,207,845
0
2
0
true
0
0
Thanks a million Steve! In fact, your suggestion had some compatibility issues with MacOSX (a particular library was incompatible with the system) BUT it helped me find out a more interesting package : icsi.boost.macosx. I am just denoting that in case any Mac-eter finds it interesting! Thank you again! Tim
1
5
1
0
Is there anyone that has some ideas on how to implement the AdaBoost (Boostexter) algorithm in python? Cheers!
AdaBoost ML algorithm python implementation
0
1.2
1
0
0
4,289
3,199,702
2010-07-07T23:40:00.000
12
0
0
1
1
python,eclipse,twisted,pydev
0
3,199,728
0
1
0
true
1
0
go to preferences->Pydev->Interpreter - Python and hit the apply button. That will rescan your modules directory and add any missing modules. That should fix any normal import errors. Some modules do some runtime magic that PyDev cant follow.
1
5
0
0
It seems like my Eclipse PyDev does not recognize that Twisted is installed on my system. I can't make auto suggest working. Does anyone know how to solve it?
pydev and twisted framework
0
1.2
1
0
0
1,684
3,215,062
2010-07-09T17:26:00.000
0
1
0
0
0
python,flash,forms,mechanize,code-injection
0
3,849,851
0
2
0
false
1
0
Nice question but seems unfortunately mechanize can't be used for flash objects
1
2
0
0
I am trying to create an automated program in Python that deals with Flash. Right now I am using Python Mechanize, which is great for filling forms, but when it comes to flash I don't know what to do. Does anyone know how I can interact with flash forms (set and get variables, click buttons, etc.) via Python mechanize or some other python library?
Interact with Flash using Python Mechanize
0
0
1
0
0
1,702
3,219,772
2010-07-10T15:25:00.000
1
0
1
1
0
python,diff,patch
0
3,219,785
1
2
0
false
0
0
Your update manager can know which version the current app is, and which version is the most recent one and apply only the relevant patches. Suppose the user runs 0.38, and currently there is 0.42 available. The update for 0.42 contains patches for 0.39, 0.40, 0.41 and 0.42 (and probably farther down the history). The update manager downloads the 0.42 update, knows it's at 0.38 and applies all the relevant patches. If it currently runs 0.41, it only applies the latest patch, and so on.
1
3
0
0
Currently my program updates itself by downloading the latest .tar.gz file containing the source code, and extracting it over the current directory where the program lives. There are 2 "modes" of update - one for users running the Python source, and one if the user is running the program as a Windows exe. Over time my program's filesize is becoming larger with each release, due to new images, libraries, documentation and code. However, sometimes only code changes occur from one release to another, so the user ends up re-downloading all the images, documentation etc over and over, when only there are only small code changes. I was thinking that a more efficient approach would be to use a patch/diff based system where the program incrementally updates itself from one version to another by only downloading small change sets. However, how should I do this? If the user is running version 0.38, and there is a 0.42 available, do they download 0.38->39; 0.39->40; 0.40->41, 0.41->42? How would I handle differences in binary files? (images, in my case). I'd also have to maintain some repository containing all the patches, which isn't too bad. I'd just generate the diffs with each new release. But I guess it would be harder to do this to executables than to pure python code? Any input is appreciated. Many thanks.
Updating my program, using a diff-based patch approach
0
0.099668
1
0
0
535
3,220,280
2010-07-10T17:55:00.000
2
0
1
0
0
python,django,setuptools,virtualenv
0
66,091,958
0
5
0
false
1
0
pip install "django>=2.2,<3" To install djnago 2.2
1
96
0
0
I want to install some specific version of a package (in this case Django) inside the virtual environment. I can't figure it out. I'm on Windows XP, and I created the virtual environment successfully, and I'm able to run it, but how am I supposed to install the Django version I want into it? I mean, I know to use the newly-created easy_install script, but how do I make it install Django 1.0.7? If I do easy_install django, it will install the latest version. I tried putting the version number 1.0.7 into this command in various ways, but nothing worked. How do I do this?
How do I install an old version of Django on virtualenv?
0
0.07983
1
0
0
80,239
3,229,102
2010-07-12T13:44:00.000
1
0
1
0
0
python,compiler-construction,parsing,stack-trace,abstract-syntax-tree
0
3,498,493
0
3
0
false
0
0
From what I have figured out in the meantime, this is not possible. At least not block-wise. It is possible to recompile the code per function but not per code-block because Python generates the code objects per function. So the only way is to write an own Python compiler.
1
3
0
1
Sorry for the kind of general question. More details about what I want: I want the user to be able to write some Python code and execute it. Once there is an exception which is not handled, I want the debugger to pause the execution, show information about the current state/environment/stack/exception and make it possible to edit the code. I only want to have the special code block editable where the exception occurred and nothing else (for now). I.e. if it occurred inside a for loop, I only want to have the code block inside the for loop editable. It should be the latest/most recent code block which is in the user editor scope (and not inside some other libs or the Python libs). Under this conditions, it is always clear what code block to edit. I already tried to investigate a bit how to do this, though I feel a bit lost. The Python traceback doesn't give me directly the code block, just the function and the code line. I could calculate that back but that seems a bit hacky to me. Better (and more natural) would be if I could somehow get a reference to the code block in the AST of the code. To get the AST (and operate on it, i.e. manipulate/edit), I probably will use the compiler (which is deprecated?) and/or the parser module. Or the ast module. Not sure though how I could recompile special nodes / code blocks in the AST. Or if I only can recompile whole functions.
how to write a Python debugger/editor
1
0.066568
1
0
0
2,309
3,247,202
2010-07-14T14:35:00.000
1
0
1
0
0
python,file
0
3,247,393
0
5
0
false
0
0
I'm not sure this is even possible. Even at the VFS or filesystem level, there is no guarantee that a directory entry count is even maintained. For instance many filesystems simply record the combined byte size of the directory entry structures contained in a given directory. Estimation may be made if directory entries are fixed size structures, but this is uncommon now (consider LFN for FAT32). Even if a given filesystem did provide an entry count without needing to iterate through a directory, or if the VFS cached a record of a directories length, these would definitely be operating system, filesystem, and kernel specific.
1
12
0
0
I have a directory with a large number of files (~1mil). I need to choose a random file from this directory. Since there are so many files, os.listdir naturally takes an eternity to finish. Is there a way I can circumvent this problem? Maybe somehow get to know the number of files in the directory (without listing it) and choose the 'n'th file where n is randomly generated? The files in the directory are randomly named.
Choosing a random file from a directory (with a large number of files) in Python
0
0.039979
1
0
0
1,774
3,252,725
2010-07-15T05:34:00.000
0
0
1
0
0
python
0
3,252,763
0
4
0
false
0
0
The code you listed above is a list of tuples - which pretty much matches what you're asking for. From the example above, list[0][0] returns the state from the first tuple, list[0][1] the action, and list[0][2] the cost. You can extract the values with something like (state, action, cost)= list[i] too.
1
2
0
0
I need to put 3 items in the list. state..eg(1,2) action...eg..west cost....5 list=[(state,action,cost), (state,action,cost).........] how can i make it in a form of list. For a particular state , action and cost is there. Moreover, if i need only state from the list, i should be able to extract it from the list.same thing goes for action too.
List formation in python
0
0
1
0
0
390
3,263,769
2010-07-16T10:06:00.000
0
0
1
0
1
python,installation,windows-installer
0
3,264,133
0
2
0
false
0
0
Based on one of your comments, it looks like you don't actually need to install it, you just need it on the computer so your program can run. In that case you can take a page from Dropbox's book and include the interpreter, DLL, and standard library in one of your directories, and just use it from there.
1
4
0
0
I want to install the new Python 2.7 on my Windows XP 32bit PC. having CDO (thats OCD with initials sorted in alphabetical order) I want to install it multiple times on the same computer (to different TARGETDIRs). how do i do that ? double clicking on the installer, or running msiexec multiple times did not work for me Coincidentally, I noticed that the windows python installation does not ask me if I want to add a Start Menu option. I want my installations of python not to show up on the Start Menu. How do I do that? be well
Multiple Python Installations of the same python version on a single computer
0
0
1
0
0
479
3,267,081
2010-07-16T16:40:00.000
1
0
0
0
1
python,django,events,mongodb,tracking
0
3,267,422
0
3
0
false
1
0
If by click, you mean a click on a link that loads a new page (or performs an AJAX request), then what you aim to do is fairly straightforward. Web servers tend to keep plain-text logs about requests - with information about the user, time/date, referrer, the page requested, etc. You could examine these logs and mine the statistics you need. On the other hand, if you have a web application where clicks don't necessarily generate server requests, then collecting click information with javascript is your best bet.
2
7
0
0
I'm looking into way to track events in a django application (events would generally be clicks tied to a specific unique user id). These events would essentially contain an event type like "click" and then each click event would be assigned to a unique id (many events can go to one id) and each event would have a data set including items like referrer etc... I have tried mixpanel, but for now the data api they are offering seems too limiting as I can't seem to find a way to get all of my data out by a unique id (apart from the event itself). I'm looking into using django-eventracker, but curious about any others thought on the best way to do this. Mongo or CouchDb seem like a great choice here, but the celery/rabbitmq looks really attractive with mongo. Pumping these events into the existing applications db seems limiting at this point. Anyways, this is just a thread to see what others thoughts are on this and how they have implemented something like this... shoot
Recommendation for click/event tracking mechanisms (python, django, celery, mongo etc)
0
0.066568
1
0
0
3,366
3,267,081
2010-07-16T16:40:00.000
3
0
0
0
1
python,django,events,mongodb,tracking
0
3,267,157
0
3
0
false
1
0
I am not familiar with the pre-packaged solutions you mention. Were I to design this from scratch, I'd have a simple JS collecting info on clicks and posting it back to the server via Ajax (using whatever JS framework you're already using), and on the server side I'd simply append that info to a log file for later "offline" processing -- so that would be independent of django or other server-side framework, essentially. Appending to a log file is a very light-weight action, while DBs for web use are generally way optimized for read-intensive (not write-intensive) operation, so I agree with you that force fitting that info (as it trickes in) into the existing app's DB is unlikely to offer good performance.
2
7
0
0
I'm looking into way to track events in a django application (events would generally be clicks tied to a specific unique user id). These events would essentially contain an event type like "click" and then each click event would be assigned to a unique id (many events can go to one id) and each event would have a data set including items like referrer etc... I have tried mixpanel, but for now the data api they are offering seems too limiting as I can't seem to find a way to get all of my data out by a unique id (apart from the event itself). I'm looking into using django-eventracker, but curious about any others thought on the best way to do this. Mongo or CouchDb seem like a great choice here, but the celery/rabbitmq looks really attractive with mongo. Pumping these events into the existing applications db seems limiting at this point. Anyways, this is just a thread to see what others thoughts are on this and how they have implemented something like this... shoot
Recommendation for click/event tracking mechanisms (python, django, celery, mongo etc)
0
0.197375
1
0
0
3,366
3,270,952
2010-07-17T09:38:00.000
2
0
0
0
0
python,django,sqlite
0
3,275,298
0
6
0
false
1
0
You asked what the create(**dict(zip(fields, row))) line did. I don't know how to reply directly to your comment, so I'll try to answer it here. zip takes multiple lists as args and returns a list of their correspond elements as tuples. zip(list1, list2) => [(list1[0], list2[0]), (list1[1], list2[1]), .... ] dict takes a list of 2-element tuples and returns a dictionary mapping each tuple's first element (key) to its second element (value). create is a function that takes keyword arguments. You can use **some_dictionary to pass that dictionary into a function as keyword arguments. create(**{'name':'john', 'age':5}) => create(name='john', age=5)
1
13
0
0
I am trying to setup a website in django which allows the user to send queries to a database containing information about their representatives in the European Parliament. I have the data in a comma seperated .txt file with the following format: Parliament, Name, Country, Party_Group, National_Party, Position 7, Marta Andreasen, United Kingdom, Europe of freedom and democracy Group, United Kingdom Independence Party, Member etc.... I want to populate a SQLite3 database with this data, but so far all the tutorials I have found only show how to do this by hand. Since I have 736 observations in the file I dont really want to do this. I suspect this is a simple matter, but I would be very grateful if someone could show me how to do this. Thomas
Populating a SQLite3 database from a .txt file with Python
0
0.066568
1
1
0
7,034
3,284,289
2010-07-19T19:24:00.000
0
0
0
0
0
python,xml
0
3,284,880
0
7
0
false
1
0
If the document is endless why not add end tag (of main element) manually before opening it in parser? I don't know Python but why not add </endtag> to string?
1
5
0
0
I am working on a application, and my job just is to develop a sample Python interface for the application. The application can provide XML-based document, I can get the document via HTTP Get method, but the problem is the XML-based document is endless which means there will be no end element. I know that the document should be handled by SAX, but how to deal with the endless problem? Any idea, sample code?
python handle endless XML
0
0
1
0
1
1,933
3,289,430
2010-07-20T11:30:00.000
31
0
1
0
0
python,recursion
0
3,289,437
0
2
0
true
0
0
The default is 1000 levels deep and you can change that using the setrecursionlimit function in the sys module. Warning: Beware that some operating systems may start running into problems if you go much higher due to limited stack space.
1
27
0
0
What's the maximum level of recursion and how do I change it in Python?
Maximum level of recursion in Python
0
1.2
1
0
0
9,205
3,289,584
2010-07-20T11:50:00.000
0
0
0
0
0
python
0
3,289,731
0
3
0
false
1
0
Your task sounds interesting. :-) A scenario that just came into mind: You continuosly scrape the resources with your home-brew scripts, and push the results into your persistent database and a caching system -- like Redis -- simultanously. Your caching system/layer serves as primary data source when serving client requests. Redis f.e. is a high-performant key-value-store that is capable to handle 100k connections per second. Though only the n latest (say f.e. 50k entries) matter the caching system will only hold these entries and let you solely focus on developing the server-side API (handling connections, processing requests, reading from Redis) and the frontend. The communication between frontend and backend-API could be driven by WebSocket connections. A pretty new part of the HTML5 spec. Though, however, already supported by many browser versions released these days. Alternatively you could fallback on some asynchronous Flash Socket-stuff. Websockets basically allow for persistent connections between a client and a server; you can register event listener that are called for every incoming data/-packet -- no endless polling or other stuff.
1
8
0
0
This is my first questions here, so I hope it will be done correctly ;) I've been assigned the task to give a web interface to some "home made" python script. This script is used to check some web sites/applications availability, via curl commands. A very important aspect of this script is that it gives its results in real-time, writing line by line to the standard output. By giving a web interface to this script, the main goal is that the script can be easily used from anywhere, for example via a smartphone. So the web interface must be quite basic, and work "plugin-free". My problem is that most solutions I thought or found on the web (ajax, django, even a simple post) seem to be needing a full generation of the page before sending it to the browser, losing this important "real-time" aspect. Any idea on how to do this properly ? Thanks in advance.
Web-ifing a python command line script?
0
0
1
0
1
3,095
3,290,443
2010-07-20T13:31:00.000
0
0
0
0
1
python,textures,blender
0
5,252,616
0
1
0
false
0
0
What you could do is (if you are using Blender 2.49b) set the image of the Texture object and the uvlayer property of the MTex object.
1
0
0
1
I'm trying to access UV Layer in Blender from Python and basically API returns UV Layer only as a string. Thing is I want to assign new Image object to current UV Layer ( I use TexFace on the side of material ) and then just bake lighting. All meshes are currently unwrapped, the only thing which is missing is an Image and I have no idea how to add image I will bake lighting to from Python level. Thanks, J
Blender, UV Layer, Image and Python
0
0
1
0
0
1,058
3,294,682
2010-07-20T21:50:00.000
5
0
0
0
0
python,django,cron
0
3,294,995
0
2
0
true
1
0
Running a scheduled task to perform updates in your game, at any interval, will give you a spike of heavy database use. If your game logic relies on all of those database values to be up to date at the same time (which is very likely, if you're running an interval based update), you'll have to have scheduled downtime for as long as that cronjob is running. When that time becomes longer, as your player base grows, this becomes extremely annoying. If you're trying to reduce database overhead, you should store values with their last update time and growth rates, and only update those rows when the quantity or rate of growth changes. For example, a stash of gold, that grows at 5 gold per minute, only updates when a player withdraws gold from it. When you need to know the current amount, it is calculated based on the last update time, the current time, the amount stored at the last update, and the rate of growth. Data that changes over time, without requiring interaction, does not belong in the database. It belongs in the logic end of your game. When a player performs an activity you need to remember, or a calculation becomes too cumbersome to generate again, that's when you store it.
1
3
0
0
I am developing an online browser game, based on google maps, with Django backend, and I am getting close to the point where I need to make a decision on how to implement the (backend) timed events - i.e. NPC possession quantity raising (e.g. city population should grow based on some variables - city size, application speed). The possible solutions I found are: Putting the queued actions in a table and processing them along with every request. Problems: huge overhead, harder to implement Using cron or something similar Problem: this is an external tool, and I want as little external tools as possible. Any other solutions?
Browser-based MMO best-practice
0
1.2
1
0
1
770
3,298,464
2010-07-21T10:59:00.000
1
0
1
0
0
python,python-3.x,internals
0
3,299,533
0
6
0
false
0
0
should I go for a top-down or a bottom-up approach? Both! Seriously.
1
57
0
0
I have been programming using Python for slightly more than half an year now and I am more interested in Python internals rather than using Python to develop applications. Currently I am working on porting a few libraries from Python2 to Python3. However, I have a rather abstract view on how to make port stuff over from Python2 to Python3 as most of the changes deal with design issues in Python2.x I'd like to learn more about Python internals; should I go for a top-down or a bottom-up approach? Are there any references you could recommend?
How can I learn more about Python’s internals?
0
0.033321
1
0
0
22,228
3,300,665
2010-07-21T14:59:00.000
8
0
1
0
0
python,python-idle
0
3,301,128
0
1
0
true
0
0
start IDLE open eggs, open ham set desired breakpoints in both files go to IDLE's shell, select Debug=>Debugger go back to eggs and to run. You should stop at break points in each file. (It works, I just tested it.)
1
5
0
0
If I edit two modules, eggs and ham, and module eggs imports ham, how do I run module eggs such that IDLE stops at breakpoints set in ham? So far, I have only been able to get IDLE to recognize breakpoints set in the module actually being run, not those being imported.
How do I set a breakpoint in a module other than the one I am running in Python IDLE?
0
1.2
1
0
0
5,900
3,309,695
2010-07-22T14:05:00.000
3
0
0
1
0
python,google-app-engine,feedparser
0
3,309,766
0
3
0
false
1
0
It is not possible to get the 'final' URL by parsing, in order to resolve it, you would need to at least perform an HTTP HEAD operation
2
1
0
0
i am using google app engine for fetching the feed url bur few of the urls are 301 redirect i want to get the final url which returns me the result i am usign the universal feed reader for parsing the url is there any way or any function which can give me the final url.
how to get final redirected url
1
0.197375
1
0
1
1,704
3,309,695
2010-07-22T14:05:00.000
0
0
0
1
0
python,google-app-engine,feedparser
0
3,309,853
0
3
0
false
1
0
You can do this by handling redirects manually. When calling fetch, pass in follow_redirects=False. If your response object's HTTP status is a redirect code, either 301 or 302, grab the Location response header and fetch again until the HTTP status is something else. Add a sanity check (perhaps 5 redirects max) to avoid redirect loops.
2
1
0
0
i am using google app engine for fetching the feed url bur few of the urls are 301 redirect i want to get the final url which returns me the result i am usign the universal feed reader for parsing the url is there any way or any function which can give me the final url.
how to get final redirected url
1
0
1
0
1
1,704
3,311,973
2010-07-22T18:13:00.000
4
0
0
0
0
python,django,url,reverse
1
3,312,255
0
1
0
true
1
0
The problem will be in whatever regex you are using in your urls.py to match feed_user. Presumably you are using something like r'(?P<username>\w+)/$', which only matches on alphanumeric characters and doesn't match on punctuation. Instead, use this: r'(?P<username>[\w.]+)/$'
1
2
0
0
I didn't expect this to occur [since I didn't know when django changed to allow _ and . in usernames], but when I attempt {% url feed_user entry.username %} I will get a 500 error when the username contains a '.' In this case rob.e as a username will fail. Any ideas how to deal with this?
django URL reverse: When URL reversig a username it fails when username has a '.' literal in it
0
1.2
1
0
0
216
3,324,108
2010-07-24T06:41:00.000
6
0
0
1
0
python,deployment,dependency-management
0
4,560,558
0
5
0
false
1
0
It's good to use virtualenv to create standalone project environment and use pip/easy_install to management dependencies.
1
162
0
0
I'm a java developer/python beginner, and I'm missing my maven features, particularly dependency management and build automation (I mean you don't build, but how to create a package for deployment?) Is there a python equivalent to achieve these features? Note: I use python 2.x Thanks.
Maven equivalent for python
0
1
1
0
0
113,883
3,325,602
2010-07-24T15:12:00.000
6
0
1
1
0
python,c,posix,gnu,limits
0
3,325,616
0
1
0
true
0
0
PATH_MAX is the maximum length of a filesystem path. NAME_MAX is the maximum length of a filename (in a particular spot). So, /foo/bar is restricted by PATH_MAX, and only the bar portion has its length limited by NAME_MAX. You can get these at run time via pathconf, as _PC_PATH_MAX and _PC_NAME_MAX, although standard practice is generally just to use the static macros at compile time. I suppose it would be better to use the run-time option because you could potentially support longer values that way, but I'm not sure what (if any) systems actually provide a return from pathconf which is greater than the value of the POSIX_FOO_MAX values.
1
6
0
0
In limits.h, and in various places in the POSIX manpages, there are references to PATH_MAX and NAME_MAX. How do these relate to one another? Where is the official documentation for them? How can I obtain them at run time, and (where relevant) compile time for the C, Python, and GNU (shell) environments?
What is the relation between PATH_MAX and NAME_MAX, and how do I obtain?
1
1.2
1
0
0
2,365
3,327,590
2010-07-25T01:12:00.000
2
0
0
0
0
python,django,django-cms
0
3,356,666
0
1
0
false
1
0
Sounds like you need to modify your urls.py, not your settings or middleware.
1
2
0
0
hey guys, im trying to internationalize my site, so i have the django cms multilingual middleware class in my settings.py , when viewed from brasil, the url changes to www.ashtangayogavideo.com/pt/ash/homepage/ resulting in a 404, because my site is in www.ashtangayogavideo.com/ash/en/homepage, how can i configure the middleware, or settings.py, so that the language code is added after the /ash/ ? .
How to modify django cms multilingual middleware
0
0.379949
1
0
0
444
3,327,799
2010-07-25T02:49:00.000
2
0
0
0
0
python,radio-button,toggle,tkinter
0
3,327,963
0
2
0
true
0
1
Use a checkbutton with "indicatoron" set to False. This will turn off the little checkbox so you only see the image (or text), and the relief will toggle between raised and sunken each time it is clicked. Another way is to use a label widget and manage the button clicks yourself. Add a binding for <1> and change the relief to sunken if raised, and raised if sunken. It's easier to use the built-in features of the checkbutton, since it also handles keyboard traversal, activation, etc.
1
0
0
0
I know how to make an image a button in Tkinter, now how do I make th image a toggle button similar to a radio button?
Making a Toggle Button with an image in Tkinter
0
1.2
1
0
0
1,795
3,328,241
2010-07-25T06:03:00.000
0
0
0
0
0
python,gtk,pygtk
0
8,647,405
0
1
0
false
0
1
(Friendly reminder, please stop putting answers in the comments, people.) To summarize: It depends on the size of the TextView, size of the window, size of the font, and as Alex Martelli said, the particular font and the usage of letters..."i" is a narrow letter, "m" is a wide letter, thus you can fit more "i"s than you can "m"s in a given space. So, in short, there is no way to know for sure.
1
0
0
0
I have a gtk TextView in a maximized window and I want to know how many characters a line can fit before you have to scroll.
Get the length in characters of a PyGTK TextView
0
0
1
0
0
214
3,332,263
2010-07-26T04:48:00.000
0
0
0
0
0
user-interface,wxpython,real-time
0
5,598,605
0
1
0
false
0
1
If you can connect to this mysterious device and receive data from it from Python, then you can display said data with wxPython or any other GUI toolkit. You don't really say what kind of data it is or what you want to display? Lines? Graphs? Or what? If it's just tabular data, use the wx.ListCtrl (or ObjectListView) widget. If you need graphs, see the Plot widget or Matplotlib.
1
0
0
0
I am new to this post as well as to python GUI programming.I want to make a realtime graphical GUI in wxpython.My requirement is that i have to catch signals from a device and i have to display the data in graphical as well as in textual form.The system should be accurate and be specific with the time constraints.Please can any one guide me in this,and if this be possible in wxpython and if yes how can i and if no what i can use for this is python. Hoping someone will help me out soon.Thanks in advance and for your concern. regards, Anil ph
Help : Realtime graphical interface in wxpython
1
0
1
0
0
179
3,333,095
2010-07-26T07:54:00.000
6
0
1
0
0
python,build,linker,sqlite
0
3,341,117
0
3
0
false
0
0
download the latest version of sqlite3.dll from sqlite website and replace the the sqlite3.dll in the python dir.
2
9
0
0
I was using Python 2.6.5 to build my application, which came with sqlite3 3.5.9. Apparently though, as I found out in another question of mine, foreign key support wasn't introduced in sqlite3 until version 3.6.19. However, Python 2.7 comes with sqlite3 3.6.21, so this work -- I decided I wanted to use foreign keys in my application, so I tried upgrading to python 2.7. I'm using twisted, and I couldn't for the life of me get it to build. Twisted relies on zope.interface and I can't find zope.interface for python 2.7 -- I thought it might just "work" anyway, but I'd have to just copy all the files over myself, and get everything working myself, rather than just using the self-installing packages. So I thought it might be wiser to just re-build python 2.6 and link it against a new version of sqlite3. But I don't know how-- How would I do this? I have Visual Studio 2008 installed as a compiler, I read that that is the only one that is really supported for Windows, and I am running a 64 bit operating system
How can I upgrade the sqlite3 package in Python 2.6?
0
1
1
1
0
4,281
3,333,095
2010-07-26T07:54:00.000
1
0
1
0
0
python,build,linker,sqlite
0
3,333,348
0
3
0
false
0
0
I decided I'd just give this a shot when I realized that every library I've ever installed in python 2.6 resided in my site-packages folder. I just... copied site-packages to my 2.7 installation, and it works so far. This is by far the easiest route for me if this works -- I'll look further into it but at least I can continue to develop now. I won't accept this answer, because it doesn't even answer my question, but it does solve my problem, as far as I can tell so far.
2
9
0
0
I was using Python 2.6.5 to build my application, which came with sqlite3 3.5.9. Apparently though, as I found out in another question of mine, foreign key support wasn't introduced in sqlite3 until version 3.6.19. However, Python 2.7 comes with sqlite3 3.6.21, so this work -- I decided I wanted to use foreign keys in my application, so I tried upgrading to python 2.7. I'm using twisted, and I couldn't for the life of me get it to build. Twisted relies on zope.interface and I can't find zope.interface for python 2.7 -- I thought it might just "work" anyway, but I'd have to just copy all the files over myself, and get everything working myself, rather than just using the self-installing packages. So I thought it might be wiser to just re-build python 2.6 and link it against a new version of sqlite3. But I don't know how-- How would I do this? I have Visual Studio 2008 installed as a compiler, I read that that is the only one that is really supported for Windows, and I am running a 64 bit operating system
How can I upgrade the sqlite3 package in Python 2.6?
0
0.066568
1
1
0
4,281
3,336,787
2010-07-26T16:21:00.000
4
1
0
0
0
python,webserver,mod-wsgi
0
3,339,594
0
6
0
false
1
0
Don't get carried away with trying to work out what is the fastest web server. All you will do in doing that is waste your time. This is because the web server is nearly never the bottleneck if you set them up properly. The real bottleneck is your web application, database access etc. As such, choose whatever web hosting system you think meets your general requirements and which you find easy to setup and manage. Using something you understand and which doesn't require lots of time devoted to it, means you can then focus your valuable time on making your application perform better, thus reducing the real bottleneck.
2
2
0
0
I am leasing a dedicated web server. I have a Python web-application. Which configuration option (CGI, FCGI, mod_python, Passenger, etc) would result in Python being served the fastest on my web server and how do I set it up that way? UPDATE: Note, I'm not using a Python framework such as Django or Pylons.
Python/Web: What's the best way to run Python on a web server?
0
0.132549
1
0
0
5,769
3,336,787
2010-07-26T16:21:00.000
-1
1
0
0
0
python,webserver,mod-wsgi
0
3,336,816
0
6
0
false
1
0
You don't usually just serve Python, you serve a specific web server or framework based on Python. eg. Zope, TurboGears, Django, Pylons, etc. Although they tend to be able to operate on different web server back-ends (and some provide an internal web server themselves), the best solution will depend on which one you use.
2
2
0
0
I am leasing a dedicated web server. I have a Python web-application. Which configuration option (CGI, FCGI, mod_python, Passenger, etc) would result in Python being served the fastest on my web server and how do I set it up that way? UPDATE: Note, I'm not using a Python framework such as Django or Pylons.
Python/Web: What's the best way to run Python on a web server?
0
-0.033321
1
0
0
5,769
3,339,263
2010-07-26T21:50:00.000
1
0
0
0
0
python,wxpython,refresh
0
3,339,765
0
2
0
false
0
1
Call the SetLabel method in your static text instance. So you don't run into conflict with the size, make sure your StaticText instance is created with enough space to write the future labels you'll want to write to it.
1
5
0
0
i was wondering how to update a StaticText dynamically in wxpython? I have a script that goes every five minutes and reads a status from a webpage, then prints using wxpython the status in a static input. How would i dynamically, every 5 minutes update the statictext to reflect the status? thanks alot -soule
Dynamically update wxPython staticText
0
0.099668
1
0
0
12,769
3,340,803
2010-07-27T04:44:00.000
2
0
1
0
0
python
0
3,340,981
0
3
0
false
0
0
The "asking" part, as @Zonda's answer says, could use raw_input (or Python 3's input) at a terminal ("command window" in Windows); but it could also use a web application, or a GUI application -- you don't really tell us enough about where the users will be (on the same machine you're using to run your code, or at a browser while your code runs on a server?) and whether GUI or textual interfaces are preferred, so it's impossible to give more precise advice. For storing and retrieving the data, a SQL engine as mentioned in @aaron's answer is a possibility (though some might consider it overkill if this is all you want to save), but his suggested alternative of using pickle directly makes little sense -- I would instead recommend the shelf module, which offers (just about) the equivalent of a dictionary persisted to disk. (Keys, however, can only be strings -- but even if your IDs are integers instead, that's no problem, just use str(someid) as the key both to store and to retrieve). In a truly weird comment I see you ask...: is there any way to do it by making a class? and using the __init__ method? Of course there is a way to do "in a class, using the __init__ method" most anything you can do in a function -- at worst, you write all the code that would (in a sensible program) be in the function, in the __init__ method instead (in lieu of return, you stash the result in self.result and then get the .result attribute of the weirdly useless instance you have thus created). But it makes any sense to use a class only when you need special methods, or want to associate state and behavior, and you don't at all explain why either condition should apply here, which is why I call your request "weird" -- you provide absolutely no context to explain why you would at all want that in lieu of functions. If you can clarify your motivations (ideally by editing your question, or, even better, asking a separate one, but not by extending your question in sundry comments!-) maybe it's possible to help you further.
1
0
0
0
say i want to ask the many users to give me their ID number and their name, than save it. and than i can call any ID and get the name. can someone tell me how i can do that by making a class and using the _ _ init _ _ method?
saving data and calling data python
0
0.132549
1
0
0
250
3,343,082
2010-07-27T11:25:00.000
0
0
0
0
0
python,soap,xml-rpc,xmlrpclib
0
3,343,497
0
2
0
false
0
0
Whether or not possible support of multicall makes any difference to you depends on where the 700ms is going. How did you measure your 700ms? Run a packet capture of a query and analyse the results. It should be possible to infer roughly round-trip-time, bandwidth constraints, whether it's the application layer of the server or even the name resolution of your client machine.
1
0
0
0
Can I ask for few question in one post to XML-RPC server? If yes, how can I do it in python and xmlrpclib? I'm using XML-RPC server on slow connection, so I would like to call few functions at once, because each call costs me 700ms.
Does XML-RPC in general allows to call few functions at once?
0
0
1
0
1
231
3,343,793
2010-07-27T12:54:00.000
3
0
1
1
0
python,user-interface,windows-services
0
3,343,894
0
2
0
true
0
0
If you give your Service the Allow service to interact with desktop permission it will be able to create windows without the need to launch a subprocess.
1
0
0
0
I am creating Windows service class in Python that will eventually display a Window when certain conditions are met. Since (as I understand it) services cannot have GUIs, I'm trying to start up a GUI in a seperate process (using subprocess.Popen) when the conditions are right. This isn't working, presumably because the child process has the same privileges as the service. So how do I start a process from a Python Windows Service that has the ability to display GUIs on the screen?
Starting a GUI process from a Python Windows Service
0
1.2
1
0
0
1,456
3,345,785
2010-07-27T16:32:00.000
0
0
1
0
0
python,iterator
0
19,849,720
0
19
0
false
0
0
This is against the very definition of an iterator, which is a pointer to an object, plus information about how to get to the next object. An iterator does not know how many more times it will be able to iterate until terminating. This could be infinite, so infinity might be your answer.
5
192
0
0
Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting?
Getting number of elements in an iterator in Python
0
0
1
0
0
184,194
3,345,785
2010-07-27T16:32:00.000
0
0
1
0
0
python,iterator
0
3,346,287
0
19
0
false
0
0
It's common practice to put this type of information in the file header, and for pysam to give you access to this. I don't know the format, but have you checked the API? As others have said, you can't know the length from the iterator.
5
192
0
0
Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting?
Getting number of elements in an iterator in Python
0
0
1
0
0
184,194
3,345,785
2010-07-27T16:32:00.000
3
0
1
0
0
python,iterator
0
3,345,950
0
19
0
false
0
0
There are two ways to get the length of "something" on a computer. The first way is to store a count - this requires anything that touches the file/data to modify it (or a class that only exposes interfaces -- but it boils down to the same thing). The other way is to iterate over it and count how big it is.
5
192
0
0
Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting?
Getting number of elements in an iterator in Python
0
0.031568
1
0
0
184,194
3,345,785
2010-07-27T16:32:00.000
9
0
1
0
0
python,iterator
0
3,345,902
0
19
0
false
0
0
An iterator is just an object which has a pointer to the next object to be read by some kind of buffer or stream, it's like a LinkedList where you don't know how many things you have until you iterate through them. Iterators are meant to be efficient because all they do is tell you what is next by references instead of using indexing (but as you saw you lose the ability to see how many entries are next).
5
192
0
0
Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting?
Getting number of elements in an iterator in Python
0
1
1
0
0
184,194
3,345,785
2010-07-27T16:32:00.000
8
0
1
0
0
python,iterator
0
3,505,917
0
19
0
false
0
0
Regarding your original question, the answer is still that there is no way in general to know the length of an iterator in Python. Given that you question is motivated by an application of the pysam library, I can give a more specific answer: I'm a contributer to PySAM and the definitive answer is that SAM/BAM files do not provide an exact count of aligned reads. Nor is this information easily available from a BAM index file. The best one can do is to estimate the approximate number of alignments by using the location of the file pointer after reading a number of alignments and extrapolating based on the total size of the file. This is enough to implement a progress bar, but not a method of counting alignments in constant time.
5
192
0
0
Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting?
Getting number of elements in an iterator in Python
0
1
1
0
0
184,194
3,350,972
2010-07-28T08:06:00.000
0
0
0
0
0
python,model-view-controller,design-patterns,pylons
0
3,410,261
0
2
1
false
1
0
Model is for your db-related code. All queries go there, including adding new records/updating existing ones. Controllers are somewhat ambigous, different projects use different approaches to it. Reddit for example does fair bit of what should be View in controllers. I, for one, prefer to limit my controllers to request processing and generation of some result object collections, which are then delivered to XHTML/XML/JSON views, depending on the type of request (so each controller should be used for both static page generation and AJAX handling). I really want to start using Pylons but I think in a few months time I'll come back to my code and think "...what the F was I thinking :/" Well, thats inevitable, you should try different approaches to find the one which suits you best.
1
0
0
1
I've been getting more and more interested in using Pylons as my Python web framework and I like the idea of MVC but, coming from a background of never using 'frameworks/design patterns/ what ever it\'s called', I don't really know how to approach it. From what I've read in the Pylons Book, so far, it seems I do the following: Create my routes in ./config/routes.py This is where I map URLs to controllers. Create a controller for the URL This is where the main body of the code lies. It does all the work and prepares it for viewing Create my template I create a template and assign the data from the controller to it Models... I have no idea what they're for :/ So my question is, can you recommend any reading materials for someone who clearly has no idea what they're doing? I really want to start using Pylons but I think in a few months time I'll come back to my code and think "...what the F was I thinking :/" EDIT: A better, summarized, question came to mind: What code should be placed in the Controller? What code should I put in the Model? The view is just the templating, right? And, in terms of Pylons, the 'lib' folder will contain code shared among Controllers or misc code that doesn't fit anywhere else - Right?
Getting started with Pylons and MVC - Need some guidance on design
0
0
1
0
0
155
3,351,110
2010-07-28T08:28:00.000
2
1
1
0
0
c++,python,visual-studio,eclipse
0
3,776,671
0
2
0
false
0
0
If the C++ app runs as a separate process then its pretty easy. You can run the process yourself or attach visual studio to existing running process and put break points. If C++ code is an embedded DLL/LIB then you can use python as debug/launch process. As soon as python will load the DLL/LIB into your python code visual studio will activate your break points. Alternatively you can also add windows debugger launcher calls to your code. As soon as your code gets executed, you will see a dialog box asking if you want to attach a debugger.
1
4
0
0
Does any one know how we can do this? I have python code in eclipse and whenever it calls c++ functions, i want the break point to go to the visual studio c++ project.
Debug C++ code in visual studio from python code running in eclipse
0
0.197375
1
0
0
1,619
3,362,859
2010-07-29T13:18:00.000
6
0
0
0
0
javascript,python,screen-scraping
0
3,364,608
0
6
0
false
1
0
I would actually suggest using Selenium. Its mainly designed for testing Web-Applications from a "user perspective however it is basically a "FireFox" driver. I've actually used it for this purpose ... although I was scraping an dynamic AJAX webpage. As long as the Javascript form has a recognizable "Anchor Text" that Selenium can "click" everything should sort itself out. Hope that helps
1
17
0
0
I'm trying to scrape and submit information to websites that heavily rely on Javascript to do most of its actions. The website won't even work when i disable Javascript in my browser. I've searched for some solutions on Google and SO and there was someone who suggested i should reverse engineer the Javascript, but i have no idea how to do that. So far i've been using Mechanize and it works on websites that don't require Javascript. Is there any way to access websites that use Javascript by using urllib2 or something similar? I'm also willing to learn Javascript, if that's what it takes.
Scraping websites with Javascript enabled?
0
1
1
0
1
23,351
3,363,167
2010-07-29T13:47:00.000
3
1
0
0
0
python,error-handling,bottle
1
3,393,377
0
2
0
false
1
0
in the error500 function written after the @error decorator to serve my customized error page, wrote error.exception and error.traceback, these two give the exception and complete traceback of the error message.
1
2
0
0
I am using the Bottle framework. I have set the @error decorator so I am able to display my customized error page, and i can also send email if any 500 error occurs, but I need the complete traceback to be sent in the email. Does anyone know how to have the framework include that in the e-mail?
E-mail traceback on errors in Bottle framework
0
0.291313
1
0
0
894
3,367,986
2010-07-30T00:37:00.000
0
0
0
0
0
python,wxpython,hide
0
22,358,518
0
3
0
false
0
1
statictext.Show to show and statictext.Hide to hide
3
4
0
0
I was wondering how to hide/delete a StaticText in wxPython?
Hide/Delete a StaticText in wxPython
0
0
1
0
0
3,670
3,367,986
2010-07-30T00:37:00.000
5
0
0
0
0
python,wxpython,hide
0
3,368,074
0
3
0
true
0
1
Have you tried control.Hide() or control.Show(False)?
3
4
0
0
I was wondering how to hide/delete a StaticText in wxPython?
Hide/Delete a StaticText in wxPython
0
1.2
1
0
0
3,670
3,367,986
2010-07-30T00:37:00.000
5
0
0
0
0
python,wxpython,hide
0
3,371,640
0
3
0
false
0
1
The widget's Hide/Show methods should work. If the widget is in a sizer, then you can use the sizer's Detach method to "hide" it but not destroy it. Otherwise, the sizer has a Remove method that will remove the widget and destroy it. And there's the widget's own Destroy method.
3
4
0
0
I was wondering how to hide/delete a StaticText in wxPython?
Hide/Delete a StaticText in wxPython
0
0.321513
1
0
0
3,670
3,368,740
2010-07-30T04:43:00.000
6
0
0
0
0
python,image-processing,python-imaging-library
0
3,368,847
0
2
0
true
0
0
You would be much better off using the EXTENT rather than the AFFINE method. You only need to calculate two things: what part of the input you want to see, and how large it should be. For example, if you want to see the whole image scaled down to half size (i.e. zooming out by 2), you'd pass the data (0, 0, im.size[0], im.size[1]) and the size (im.size[0]/2, im.size[1]/2).
1
7
1
0
I'm writing a simple application in Python which displays images.I need to implement Zoom In and Zoom Out by scaling the image. I think the Image.transform method will be able to do this, but I'm not sure how to use it, since it's asking for an affine matrix or something like that :P Here's the quote from the docs: im.transform(size, AFFINE, data, filter) => image Applies an affine transform to the image, and places the result in a new image with the given size. Data is a 6-tuple (a, b, c, d, e, f) which contain the first two rows from an affine transform matrix. For each pixel (x, y) in the output image, the new value is taken from a position (a x + b y + c, d x + e y + f) in the input image, rounded to nearest pixel. This function can be used to scale, translate, rotate, and shear the original image.
Zooming With Python Image Library
0
1.2
1
0
0
7,941
3,369,080
2010-07-30T06:17:00.000
1
1
0
1
0
python,centos
0
3,369,157
0
3
0
false
0
0
you can use cgi, but that will not have great performance as it starts a new process for each request. More efficient alternatives are to use fastcgi or wsgi A third option is to run a mini Python webserver and proxy the requests from apache using rewrite rules
1
0
0
0
I'm a LAMP developer trying out Python for the first time.. I'm okay with picking up the syntax, but I can't figure out how to run it on the server! I've tried the following uploading filename.py to a regular web/public directory. chmod 777, 711, 733, 773... (variations of execute) putting the filename.py in cgi-bin, chmod same as above.. Typing up example.com/filename.py simply loads a textfile - nothing appears to have been compiled/parsed/etc! (I believe python is installed, as whereis python on my server shows /usr/bin/python among several other directories) Many words for a simple question - how do you run a python file on a CentOS server?
Running a .py file on LAMP (CentOS) server - from a PHP developer's perspective
0
0.066568
1
0
0
5,711
3,371,255
2010-07-30T12:10:00.000
3
1
1
0
0
python,unit-testing,testing
0
3,371,690
0
7
0
false
0
0
nosetests is a brilliant solution for unit testing in Python. It supports both unittest based testcases and doctests, and gets you started with it with just a simple configuration file.
1
545
0
0
I completed my first proper project in Python and now my task is to write tests for it. Since this is the first time I did a project, this is the first time I would be writing tests for it. The question is, how do I start? I have absolutely no idea. Can anyone point me to some documentation/ tutorial/ link/ book that I can use to start with writing tests (and I guess unit testing in particular) Any advice will be welcomed on this topic.
Writing unit tests in Python: How do I start?
0
0.085505
1
0
0
258,822
3,371,549
2010-07-30T12:51:00.000
0
0
0
0
0
python,facebook,webkit,pyqt
0
5,099,848
0
1
0
true
1
1
I don't believe you can open an "authentication page" in a separate window under Facebook's terms (I used to work for Zynga, and we couldn't then, so I don't know how you'd achieve this now legally). Second, you're looking into the QWebkit backwards I believe. From a UI perspective this is supposed to provide access to websites, and interact with them. If you want a good looking page, with all the bells and whistle, it pains me to say it ~ but use Actionscript 3, or Ajax and it's bundle. This post would probably be answered better if tagged in the javascript, php, and as3 sections. As the php guys will know the correct hacks to get your intended result, if possible
1
4
0
0
Are there any examples how to authenticate your desktop Facebook application using PyQT and embedded webkit? This is to provide better user experience than opening Facebook authentication page in a separate browser window.
pyqt, webkit and facebook authentication?
0
1.2
1
0
0
640
3,376,479
2010-07-31T02:08:00.000
0
0
0
0
1
python,django,inheritance,inline,admin
1
3,376,487
1
2
0
false
1
0
All fields in the superclass also exist on the subclass, so having an explicit relation is unnecessary. Model inheritance in Django is terrible. Don't use it. Python doesn't need it anyway.
2
2
0
0
Howdy. I'm working on migrating an internal system to Django and have run into a few wrinkles. Intro Our current system (a billing system) tracks double-entry bookkeeping while allowing users to enter data as invoices, expenses, etc. Base Objects So I have two base objects/models: JournalEntry JournalEntryItems defined as follows: class JournalEntry(models.Model): gjID = models.AutoField(primary_key=True) date = models.DateTimeField('entry date'); memo = models.CharField(max_length=100); class JournalEntryItem(models.Model): journalEntryID = models.AutoField(primary_key=True) gjID = models.ForeignKey(JournalEntry, db_column='gjID') amount = models.DecimalField(max_digits=10,decimal_places=2) So far, so good. It works quite smoothly on the admin side (inlines work, etc.) On to the next section. We then have two more models InvoiceEntry InvoiceEntryItem An InvoiceEntry is a superset of / it inherits from JournalEntry, so I've been using a OneToOneField (which is what we're using in the background on our current site). That works quite smoothly too. class InvoiceEntry(JournalEntry): invoiceID = models.AutoField(primary_key=True, db_column='invoiceID', verbose_name='') journalEntry = models.OneToOneField(JournalEntry, parent_link=True, db_column='gjID') client = models.ForeignKey(Client, db_column='clientID') datePaid = models.DateTimeField(null=True, db_column='datePaid', blank=True, verbose_name='date paid') Where I run into problems is when trying to add an InvoiceEntryItem (which inherits from JournalEntryItem) to an inline related to InvoiceEntry. I'm getting the error: <class 'billing.models.InvoiceEntryItem'> has more than 1 ForeignKey to <class 'billing.models.InvoiceEntry'> The way I see it, InvoiceEntryItem has a ForeignKey directly to InvoiceEntry. And it also has an indirect ForeignKey to InvoiceEntry through the JournalEntry 1->M JournalEntryItems relationship. Here's the code I'm using at the moment. class InvoiceEntryItem(JournalEntryItem): invoiceEntryID = models.AutoField(primary_key=True, db_column='invoiceEntryID', verbose_name='') invoiceEntry = models.ForeignKey(InvoiceEntry, related_name='invoiceEntries', db_column='invoiceID') journalEntryItem = models.OneToOneField(JournalEntryItem, db_column='journalEntryID') I've tried removing the journalEntryItem OneToOneField. Doing that then removes my ability to retrieve the dollar amount for this particular InvoiceEntryItem (which is only stored in journalEntryItem). I've also tried removing the invoiceEntry ForeignKey relationship. Doing that removes the relationship that allows me to see the InvoiceEntry 1->M InvoiceEntryItems in the admin inline. All I see are blank fields (instead of the actual data that is currently stored in the DB). It seems like option 2 is closer to what I want to do. But my inexperience with Django seems to be limiting me. I might be able to filter the larger pool of journal entries to see just invoice entries. But it would be really handy to think of these solely as invoices (instead of a subset of journal entries). Any thoughts on how to do what I'm after?
Django object extension / one to one relationship issues
0
0
1
0
0
709
3,376,479
2010-07-31T02:08:00.000
1
0
0
0
1
python,django,inheritance,inline,admin
1
3,396,991
1
2
0
true
1
0
First, inheriting from a model creates an automatic OneToOneField in the inherited model towards the parents so you don't need to add them. Remove them if you really want to use this form of model inheritance. If you only want to share the member of the model, you can use Meta inheritance which will create the inherited columns in the table of your inherited model. This way would separate your JournalEntry in 2 tables though but it would be easy to retrieve only the invoices.
2
2
0
0
Howdy. I'm working on migrating an internal system to Django and have run into a few wrinkles. Intro Our current system (a billing system) tracks double-entry bookkeeping while allowing users to enter data as invoices, expenses, etc. Base Objects So I have two base objects/models: JournalEntry JournalEntryItems defined as follows: class JournalEntry(models.Model): gjID = models.AutoField(primary_key=True) date = models.DateTimeField('entry date'); memo = models.CharField(max_length=100); class JournalEntryItem(models.Model): journalEntryID = models.AutoField(primary_key=True) gjID = models.ForeignKey(JournalEntry, db_column='gjID') amount = models.DecimalField(max_digits=10,decimal_places=2) So far, so good. It works quite smoothly on the admin side (inlines work, etc.) On to the next section. We then have two more models InvoiceEntry InvoiceEntryItem An InvoiceEntry is a superset of / it inherits from JournalEntry, so I've been using a OneToOneField (which is what we're using in the background on our current site). That works quite smoothly too. class InvoiceEntry(JournalEntry): invoiceID = models.AutoField(primary_key=True, db_column='invoiceID', verbose_name='') journalEntry = models.OneToOneField(JournalEntry, parent_link=True, db_column='gjID') client = models.ForeignKey(Client, db_column='clientID') datePaid = models.DateTimeField(null=True, db_column='datePaid', blank=True, verbose_name='date paid') Where I run into problems is when trying to add an InvoiceEntryItem (which inherits from JournalEntryItem) to an inline related to InvoiceEntry. I'm getting the error: <class 'billing.models.InvoiceEntryItem'> has more than 1 ForeignKey to <class 'billing.models.InvoiceEntry'> The way I see it, InvoiceEntryItem has a ForeignKey directly to InvoiceEntry. And it also has an indirect ForeignKey to InvoiceEntry through the JournalEntry 1->M JournalEntryItems relationship. Here's the code I'm using at the moment. class InvoiceEntryItem(JournalEntryItem): invoiceEntryID = models.AutoField(primary_key=True, db_column='invoiceEntryID', verbose_name='') invoiceEntry = models.ForeignKey(InvoiceEntry, related_name='invoiceEntries', db_column='invoiceID') journalEntryItem = models.OneToOneField(JournalEntryItem, db_column='journalEntryID') I've tried removing the journalEntryItem OneToOneField. Doing that then removes my ability to retrieve the dollar amount for this particular InvoiceEntryItem (which is only stored in journalEntryItem). I've also tried removing the invoiceEntry ForeignKey relationship. Doing that removes the relationship that allows me to see the InvoiceEntry 1->M InvoiceEntryItems in the admin inline. All I see are blank fields (instead of the actual data that is currently stored in the DB). It seems like option 2 is closer to what I want to do. But my inexperience with Django seems to be limiting me. I might be able to filter the larger pool of journal entries to see just invoice entries. But it would be really handy to think of these solely as invoices (instead of a subset of journal entries). Any thoughts on how to do what I'm after?
Django object extension / one to one relationship issues
0
1.2
1
0
0
709
3,377,439
2010-07-31T08:52:00.000
2
0
0
0
0
python,qt,qt4,pyqt
0
12,565,371
0
2
0
false
0
1
setDefaultTextColor(col) "Sets the color for unformatted text to col." The documentation is not clear about what "unformatted text" means. I think it means: "all portions of the contents of the item that have not been styled." The contents is a QTextDocument. You style a part of a document using a QTextCursor. You can't style the QTextDocument per se, only a part that is selected by a QTextCursor (but you can select the whole document.) You can style a QTextCursor using method mergeCharFormat(QTextCharFormat) The QTextCharFormat has methods: foreground().setColor(QColor) setForeground(QBrush) setTextOutline(QPen) Foreground is a QBrush that paints several things including "text" (but better said: the fill of characters?) One nuance is that certain newly constructed QBrush have (default to) QBrushStyle.NoBrush, which is transparent, even if you setColor().
1
10
0
0
i have a scene with a multiple (QGraphicsTextItem)s, and i need to have control over their colors , so how to change a color of a QGraphicsTextItem ? is it possible anyway? i've been trying for 3 days until now . please help thanks in advance
how to change the color of a QGraphicsTextItem
1
0.197375
1
0
0
8,684
3,379,032
2010-07-31T17:03:00.000
0
0
0
1
0
python,deployment
0
3,379,058
0
2
0
false
0
0
How do people usually deploy such apps? 2 choices. With instructions. All bundled up. You write simple instructions like this. Folks can follow these pretty reliably, unless they don't have enough privileges. Sometimes they need to sudo in linux environments. Download easy_install (or pip) easy_install this, easy_install that (or pip this, pip that) easy_install whatever package you wrote. It works really well. If you download some Python packages you'll see this in action. Sphinx requires docutils. Django requires docutils and PIL. It works out really well to simply document the dependencies. Other folks seem to do it without serious problems. Follow their lead. Bundling things up means you have to (a) provide the entire original distribution (as required by most open source licenses) (b) provide a compatible open source license with the licenses of the things you bundled. This can be easy if you depend on things that all of the same license. Otherwise, you basically can't redistribute them and have to resort to installation instructions.
1
2
0
0
I've written an app in python that depends on wxPython and some other python libraries. I know about pyexe for making python scripts executable on Windows, but what would be the easiest way to share this with my Mac using friends who wouldn't know how to install the required dependencies? One option would be to bundle my dependencies in the same package, but that seems kind of clunky. How do people usually deploy such apps? For once I miss Java...
Deploying python app to Mac and Windows users
0
0
1
0
0
523
3,380,986
2010-08-01T06:20:00.000
0
0
0
0
0
python,user-interface,windows-xp,wxpython
0
3,380,995
0
1
0
false
0
1
If you have python win32 installed, then look under the directory <PYTHON>/lib/site-packages/win32comext/shell/demos/servers. This contains a file context_menu.py which has sample code for creating a shell extension. Update: I think you want the folder_view.py sample.
1
0
0
0
I have a WxPython app that, among other things, has a integrated file-browser. I want to be able to create a system-default file context menu (e.g. what you get if you right-click on a file in windows explorer) when a user right clicks on one of the items within my application. Note: I already know how to create my own context menu (e.g. wx.EVT_LIST_ITEM_RIGHT_CLICK), I want the Windows context menu. To clarify, I do not want, or need to modify the existing system context menu, I want to be able to display it for a specific file within my application. Basically, I know what was right clicked on, and where the mouse pointer is (if it's needed). I want to create the system context menu there, just like it works in windows explorer.
Create Explorer.exe's File - Context Menu in WxPython application
1
0
1
0
0
741
3,386,098
2010-08-02T08:20:00.000
0
0
0
0
0
python,user-interface,tkinter,ttk
0
3,389,225
0
2
0
false
0
1
I've never used these widgets so I have no idea how possible this is, but what I would try is something akin to the grid_remove() method. If you can move the tabs to an invisible widget, or just make them invisible without losing content, that's what I'd look for/try.
2
1
0
0
I'm working on a project using Tkinter and Python. In order to have native theming and to take advantage of the new widgets I'm using ttk in Python 2.6. My problem is how to allow the user to scroll through the tabs in the notebook widget (a la firefox). Plus, I need a part in the right edge of the tabs for a close button. The frame for the active tab would need to fill the available horizontal space (including under the scroll arrows). I thought I could do this using the Place geometry manager, but I was wondering if there was a better way? The ttk python docs don't have any methods to deal with this that I could see. Edit: looks like there are difficulties for even trying to implement this using place. For one, I'd still need the tabs to scroll and the active panel to stay in the one place.
Using the ttk (tk 8.5) Notebook widget effectively (scrolling of tabs)
0
0
1
0
0
1,350
3,386,098
2010-08-02T08:20:00.000
2
0
0
0
0
python,user-interface,tkinter,ttk
0
3,650,157
0
2
0
true
0
1
The notebook widget doesn't do scrolling of tabs (or multiple layers of them either) because the developer doesn't believe that they make for a good GUI. I can see his point; such GUIs tend to suck. The best workaround I've seen is to have a panel on the side that allows the selection of which pane to display. You can then apply tricks to that panel to manage the amount of information there (e.g., by making it a treeview widget and holding the info hierarchically, much like most email clients handle mail folders; treeview widgets are scrollable).
2
1
0
0
I'm working on a project using Tkinter and Python. In order to have native theming and to take advantage of the new widgets I'm using ttk in Python 2.6. My problem is how to allow the user to scroll through the tabs in the notebook widget (a la firefox). Plus, I need a part in the right edge of the tabs for a close button. The frame for the active tab would need to fill the available horizontal space (including under the scroll arrows). I thought I could do this using the Place geometry manager, but I was wondering if there was a better way? The ttk python docs don't have any methods to deal with this that I could see. Edit: looks like there are difficulties for even trying to implement this using place. For one, I'd still need the tabs to scroll and the active panel to stay in the one place.
Using the ttk (tk 8.5) Notebook widget effectively (scrolling of tabs)
0
1.2
1
0
0
1,350
3,388,911
2010-08-02T14:53:00.000
0
1
0
0
0
python,linux,ipv6
0
3,388,966
0
3
0
false
0
0
You could just simply run 'ifconfig' with a subprocess.* call and parse the output.
1
6
0
0
Do you know how I could get one of the IPv6 adress of one of my interface in python2.6. I tried something with the socket module which lead me nowhere. Thanks.
How to get the IPv6 address of an interface under linux
0
0
1
0
1
3,133
3,391,558
2010-08-02T20:40:00.000
3
0
0
0
1
python,image
0
3,391,578
0
3
0
false
0
0
Look at PyMagick, the python interface for the ImageMagick libraries. It's fairly simple to resize an image, retaining proportion, while limiting the longest side. edit: when I say fairly simple, I mean you can describe your resize in terms of the longest acceptable values for each side, and ImageMagick will preserve the proportions automatically.
1
1
0
0
I want to create a thumbnail, and the width has to be either fixed or no bigger than 200 pixels wide (the length can be anything). The images are either .jpg or .png or .gif I am using python. The reason it has to be fixed is so that it fits inside a html table cell.
Need to create thumbnail, how to ensure proportions and set fixed width?
0
0.197375
1
0
0
405
3,391,692
2010-08-02T20:58:00.000
1
1
1
0
1
python,objective-c,unicode,pyobjc
1
3,391,733
0
1
0
true
0
0
I misread the documentation. I need to do this: NSWorkspace.sharedWorkspace().setIcon_forFile_options_(NSImage.alloc().initWithContentsOfFile_(icon),target,0) Unfortunately the error is what confused me.
1
0
0
0
I have this line: NSWorkspace.sharedWorkspace().setIcon_forFile_options_(unicode(icon),unicode(target),0) Why does it give that error and how do I fix it? Thank you.
PyObjC giving strange error - [OC_PythonUnicode representations]: unrecognized selector sent to instance 0x258ae2a0
0
1.2
1
0
0
318
3,392,333
2010-08-02T22:34:00.000
4
0
0
1
0
python,fabric
0
5,531,404
0
4
0
true
0
0
If you don't want to have to iterate through all open connections, fabric.network.disconnect_all() is what you're looking for. The docstring reads """ Disconnect from all currently connected servers. Used at the end of fab's main loop, and also intended for use by library users. """
1
6
0
0
The website says: Closing connections: Fabric’s connection cache never closes connections itself – it leaves this up to whatever is using it. The fab tool does this bookkeeping for you: it iterates over all open connections and closes them just before it exits (regardless of whether the tasks failed or not.) Library users will need to ensure they explicitly close all open connections before their program exits, though we plan to makes this easier in the future. I have searched everywhere, but I can't find out how to disconnect or close the connections. I am looping through my hosts and setting env.host_string. It is working, but hangs when exiting. Any help on how to close? Just to reiterate, I am using the library, not a fabfile.
Disconnecting from host with Python Fabric when using the API
0
1.2
1
0
0
4,881
3,393,314
2010-08-03T02:57:00.000
2
0
0
0
0
python,windows,passwords,download
0
3,393,326
0
2
0
false
0
0
This is best implemented at the web server level. If you are using Apache, this can be done by placing the files you desire to protect in a directory with an htaccess file which requires user authentication. Then, implement HTTP Basic Auth in your Python script to download the files. Make sure to use an SSL connection; basic auth sends the user's password over the wire in the clear.
1
0
0
0
I am working on a project that requires password protected downloading, but I'm not exactly sure how to implement that. If the target file has a specific extension (.exe, .mp3, .mp4, etc), I want to prompt the user for a username and password. Any ideas on this? I am using Python 26 on Windows XP.
Prevent A User From Downloading Files from Python?
0
0.197375
1
0
0
450
3,397,599
2010-08-03T14:38:00.000
17
0
0
0
0
python,django,amazon-s3,thumbnails
0
5,262,932
0
2
0
false
1
0
easy_thumbnails will do S3-based image thumbnailing for you - you just need to set settings.THUMBNAIL_DEFAULT_STORAGE, so that easy_thumbnails knows which storage to use (in your case, you probably want to set it to the same storage you're using for your ImageFields).
1
5
0
0
I'm making a website where files are uploaded through the admin and this will then store them on Amazon S3. I'm using django-storages and boto for this, and it seems to be working just fine. Thing is, I'm used to use my easy_thumbnails (the new sorl.thumbnail) on the template side to create thumbnails on the fly. I prefer this approach, rather than the model side, as it allows for easier maintenance if ever I decide to change the thumbnail size at a later date etc. But I'm realising that easy_thumbnails doesn't seem to like reading the image now it's stored on Amazon S3. Also, I realised, where exactly would it be putting the thumbnails once made anyhow? Obviously, I'd prefer these to be on Amazon S3 as well. But how do I get these two technologies to play nice? How would I get easy_thumbnails to store the thumb it creates back on Amazon S3? Or am I just looking at this all wrong?! Thanks!
In Django, how to get django-storages, boto and easy_thumbnail to work nicely?
0
1
1
0
0
1,958
3,397,850
2010-08-03T15:05:00.000
0
0
0
0
0
python,testing,black-box
0
3,397,887
0
4
0
false
1
0
What exactly is "Testing links"? If it means they lead to non-4xx URIs, I'm afraid You must visit them. As for existence of given links (like "Contact"), You may look for them using xpath.
2
2
0
0
I'm tryng to verify if all my page links are valid, and also something similar to me if all the pages have a specified link like contact. i use python unit testing and selenium IDE to record actions that need to be tested. So my question is can i verify the links in a loop or i need to try every link on my own? i tried to do this with __iter__ but it didn't get any close ,there may be a reason that i'm poor at oop, but i still think that there must me another way of testing links than clicking them and recording one by one.
how can i verify all links on a page as a black-box tester
0
0
1
0
1
412
3,397,850
2010-08-03T15:05:00.000
0
0
0
0
0
python,testing,black-box
0
3,399,490
0
4
0
false
1
0
You could (as yet another alternative), use BeautifulSoup to parse the links on your page and try to retrieve them via urllib2.
2
2
0
0
I'm tryng to verify if all my page links are valid, and also something similar to me if all the pages have a specified link like contact. i use python unit testing and selenium IDE to record actions that need to be tested. So my question is can i verify the links in a loop or i need to try every link on my own? i tried to do this with __iter__ but it didn't get any close ,there may be a reason that i'm poor at oop, but i still think that there must me another way of testing links than clicking them and recording one by one.
how can i verify all links on a page as a black-box tester
0
0
1
0
1
412
3,400,381
2010-08-03T20:08:00.000
5
0
0
1
0
python,linux,shell,command-line
0
3,400,402
0
6
0
false
0
0
You want a shebang. #!/path/to/python. Put that on the first line of your python script. The #! is actually a magic number that tells the operating system to interpret the file as a script for the program named. You can supply /usr/bin/python or, to be more portable, /usr/bin/env python which calls the /usr/bin/env program and tells it you want the system's installed Python interpreter. You'll also have to put your script in your path, unless you're okay with typing ./SQLsap args.
2
12
0
0
Question: In command line, how do I call a python script without having to type python in front of the script's name? Is this even possible? Info: I wrote a handy script for accessing sqlite databases from command line, but I kind of don't like having to type "python SQLsap args" and would rather just type "SQLsap args". I don't know if this is even possible, but it would be good to know if it is. For more than just this program.
Calling a python script from command line without typing "python" first
1
0.16514
1
0
0
14,699
3,400,381
2010-08-03T20:08:00.000
4
0
0
1
0
python,linux,shell,command-line
0
3,400,404
0
6
0
false
0
0
Assuming this is on a unix system, you can add a "shebang" on the top of the file like this: #!/usr/bin/env python And then set the executable flag like this: chmod +x SQLsap
2
12
0
0
Question: In command line, how do I call a python script without having to type python in front of the script's name? Is this even possible? Info: I wrote a handy script for accessing sqlite databases from command line, but I kind of don't like having to type "python SQLsap args" and would rather just type "SQLsap args". I don't know if this is even possible, but it would be good to know if it is. For more than just this program.
Calling a python script from command line without typing "python" first
1
0.132549
1
0
0
14,699
3,402,574
2010-08-04T04:31:00.000
0
0
1
0
1
python,puzzle,iterator
0
3,402,637
0
3
0
false
0
0
I assume you are trying to find out what is the longest word that can be made from your 10 arbitrary letters. You can keep your 10 arbitrary letters in a dict along with the frequency they occur. e.g., your 4 (using 4 instead of 10 for simplicity) arbitrary letters are: e, w, l, l. This would be in a dict as: {'e':1, 'w':1, 'l':2} Then for each word in the text file, see if all of the letters for that word can be found in your dict of arbitrary letters. If so, then that is one of your candidate words. So: we wall well all of the letters in well would be found in your dict of arbitrary letters so save it and its length for comparison against other words.
1
0
0
0
I have 10 arbitrary letters and need to check the max length match from words file I started to learn RE just some time ago, and can't seem to find suitable pattern first idea that came was using set: [10 chars] but it also repeats included chars and I don't know how to avoid that I stared to learn Python recently but before RE and maybe RE is not needed and this can be solved without it using "for this in that:" iterator seems inappropriate, but maybe itertools can do it easily (with which I'm not familiar) I guess solution is known even to novice programmers/scripters, but not to me Thanks
Find max length word from arbitrary letters
0
0
1
0
0
1,499