Q_Id
int64
337
49.3M
CreationDate
stringlengths
23
23
Users Score
int64
-42
1.15k
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
Tags
stringlengths
6
105
A_Id
int64
518
72.5M
AnswerCount
int64
1
64
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
6
11.6k
Available Count
int64
1
31
Q_Score
int64
0
6.79k
Data Science and Machine Learning
int64
0
1
Question
stringlengths
15
29k
Title
stringlengths
11
150
Score
float64
-1
1.2
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
8
6.81M
4,007,801
2010-10-24T10:06:00.000
5
0
1
1
python,macos
4,008,331
3
false
0
0
Yes, but the Python version may be different. OS X 10.5 shipped with Python 2.5, OS X 10.6 with Python 2.6.
3
2
0
Do all Mac OS X versions (above 10.4) have python preinstalled?
Do all Mac OS X versions (above 10.4) have python preinstalled?
0.321513
0
0
687
4,007,847
2010-10-24T10:22:00.000
1
0
0
0
python,click,screenshot
4,007,877
3
false
0
1
You can try to use Selenium RC + python driver for Selenium. There are means of making browser screenshot, and there is ClickAt method which takes coordinates.
2
2
0
Yes, that's what I need to achieve, don't ask why:) So, since this is mainly OS dependent stuff I will be using Windows or Linux (whatever is simpler) Every second my program will: 1. do a screenshot, analyze the board and other stuff (this I can do) 2. then move the mouse to some XY and do a left-click that's all My main concern is: is there any library for capturing screenshots and then left clicking somwhere on the screen?
python program that plays flash games for me
0.066568
0
0
784
4,007,847
2010-10-24T10:22:00.000
3
0
0
0
python,click,screenshot
4,700,444
3
false
0
1
I've done this very thing before - use PIL to get the screenshots, and pywinauto to generate the mouse clicks.
2
2
0
Yes, that's what I need to achieve, don't ask why:) So, since this is mainly OS dependent stuff I will be using Windows or Linux (whatever is simpler) Every second my program will: 1. do a screenshot, analyze the board and other stuff (this I can do) 2. then move the mouse to some XY and do a left-click that's all My main concern is: is there any library for capturing screenshots and then left clicking somwhere on the screen?
python program that plays flash games for me
0.197375
0
0
784
4,008,546
2010-10-24T14:01:00.000
24
0
1
0
python,string
4,008,567
6
false
0
0
It looks like you're only looking for pointers, not a complete solution. So here's one: You can multiply strings in python: >>> "A" * 4 'AAAA' Additionally I would use better names, instead of s I'd use text, which is much clearer. Even if your current professor (I suppose you're learning Python in university.) uses such horrible abbreviations.
1
40
0
I should define a function pad_with_n_chars(s, n, c) that takes a string 's', an integer 'n', and a character 'c' and returns a string consisting of 's' padded with 'c' to create a string with a centered 's' of length 'n'. For example, pad_with_n_chars(”dog”, 5, ”x”) should return the string "xdogx".
How to pad with n characters in Python
1
0
0
45,810
4,009,130
2010-10-24T16:28:00.000
0
0
1
1
python,windows
4,009,744
3
false
0
0
easy crossplatform/crosslanguage way of handling partial file saving: save to a temporary filename like "file.ext.part" after you're done saving, rename to "file.ext"
1
0
0
I'm working on a project for school where e-mails will be pulled from an inbox and downloaded to different locations depending on how things are parsed. The language I'm writing in is Python, and the environment it will be run on is Windows XP. The idea is that the program will run in the background with no interaction from the user until they basically shutdown their computer. A concern I had is what this will mean if they shut it down while a file is in the process of being saved, and what I can do to handle it. Will it just be a file.part thing? Will the shutdown throw the "Waiting to close X application" message and finish saving before terminating on its own?
process closing while saving a file - Python - Windows XP
0
0
0
124
4,009,251
2010-10-24T16:50:00.000
2
0
1
0
python,string,list,comparison,sequence
4,009,282
4
false
0
0
This sounds very much like homework. Try thinking about it for a bit. Would it suffice to traverse the list of correct words once, and check if the corresponding word in the second list is equal to the word in the correct list? I would probably zip the lists in python and compare the pairs for equality.
1
0
0
I was wondering what the most computationally efficient Python way of cracking this problem would be. Say you have two strings (or lists from splitting those strings--doesn't matter), "this is the right string" vs. "this is right the string." We're assuming that the first string is always right, and a score will be assigned to the second string based on which words were sequenced in the right order. For the above two strings, we would assign a score of 0.6 (as only 3 of the 5 words are in the right position). Best, Georgina
Python - Most efficient way to compare # of words sequenced in "right" order across two strings/lists
0.099668
0
0
457
4,009,781
2010-10-24T18:44:00.000
1
1
1
0
python
4,009,829
4
false
0
0
yes, and zip egg files are decompressed on the fly when you reference them making them slower than when you install it.
1
1
0
It seems like just adding a package path to your PYTHONPATH gives you access to all of its modules and functions, similar to installing an egg. Is the difference just that the egg is zip compressed?
How is a python egg different from a regular package?
0.049958
0
0
1,047
4,010,108
2010-10-24T19:52:00.000
0
0
0
1
python,windows,permissions,registry,winreg
4,010,127
4
false
0
0
You'll either need admin permissions to write to HKLM, or settle for non-global reg keys. Behavior is going to vary somewhat between different versions of windows.
4
0
0
I wrote an application that stores several things in the registry. When I first started, I added them to HKEY_LOCAL_MACHINE, but kept getting permission errors writing to the. So, it was suggested that I use HKEY_CURRENT_USER, that worked until I realized that I am not able to access them from another account. How can I write to the registry but allow all accounts to access read and write to it? I used the Python module _winreg.
Registry Entries for all users in Python
0
0
0
1,512
4,010,108
2010-10-24T19:52:00.000
0
0
0
1
python,windows,permissions,registry,winreg
4,010,134
4
false
0
0
If you want to write to the registry so that all users can read it, you will need to run your program with administrator privileges. You might be happier storing your information in a file instead, which will be easier to manage.
4
0
0
I wrote an application that stores several things in the registry. When I first started, I added them to HKEY_LOCAL_MACHINE, but kept getting permission errors writing to the. So, it was suggested that I use HKEY_CURRENT_USER, that worked until I realized that I am not able to access them from another account. How can I write to the registry but allow all accounts to access read and write to it? I used the Python module _winreg.
Registry Entries for all users in Python
0
0
0
1,512
4,010,108
2010-10-24T19:52:00.000
2
0
0
1
python,windows,permissions,registry,winreg
4,010,153
4
true
0
0
HKEY_LOCAL_MACHINE/Software/YourSoftware, needs Admin permissions and is for install-time data, or HKEY_CURRENT_USER/Software/YourSoftware, which is for data pertinent to this environment only (this user, this profile etc.) EDIT: An alternative would be storing a config file and setting the right permissions at install time. 2nd EDIT: I've read in another comment that you want to be sure only your application modified some file, so you store the modification times. Workarounds: encrypt the file-not-to-be-modified, best is with a user-generated key make a service, install with a special user under which it runs, and make the permissions so, that only this service can access the file My gut feeling says your requirement to modify a file only by your app, but under any account is very wrong but the more or less correct solutions have to impose additional complexity. Your decision: review your requirements and possibly your design, or add a layer of complexity and possibly cruft. 3rd EDIT: Split your app, have an admin application, which can with admin rights write to HKLM and set the settings. Normal user rights should suffice to read HKLM
4
0
0
I wrote an application that stores several things in the registry. When I first started, I added them to HKEY_LOCAL_MACHINE, but kept getting permission errors writing to the. So, it was suggested that I use HKEY_CURRENT_USER, that worked until I realized that I am not able to access them from another account. How can I write to the registry but allow all accounts to access read and write to it? I used the Python module _winreg.
Registry Entries for all users in Python
1.2
0
0
1,512
4,010,108
2010-10-24T19:52:00.000
0
0
0
1
python,windows,permissions,registry,winreg
5,973,100
4
false
0
0
One other possibility would be changing the security on your HKLM keys to R/W for anyone. Although the idea that this is somehow security against modification seems a bit of a stretch. Regedt32 has the ability to set the keys, so the underlying API must have it too. All that said, this is a screwed up way to run an application and shows a sever lack of understanding of security and security models. (In other words, typical windows development.) How did I get so cynical.....
4
0
0
I wrote an application that stores several things in the registry. When I first started, I added them to HKEY_LOCAL_MACHINE, but kept getting permission errors writing to the. So, it was suggested that I use HKEY_CURRENT_USER, that worked until I realized that I am not able to access them from another account. How can I write to the registry but allow all accounts to access read and write to it? I used the Python module _winreg.
Registry Entries for all users in Python
0
0
0
1,512
4,010,349
2010-10-24T20:40:00.000
0
0
0
1
python,django,google-app-engine
4,010,690
3
false
1
0
Another thing to consider is how you install. I'd be sure to install django from SVN, because it makes updating it MUCH easier. I have been using the dev version for a while on my site, and haven't encountered a single bug yet, aside from one that affected the admin site in a minor way (which a svn up fixed). I don't have a feel for whether people are using 1.2 or dev, but in my experience, dev is perfectly suitable. Any major errors that you may have in the code will get fixed very quickly, and svn up will get you to the latest code on the off chance that you get a revision with a major bug.
1
2
0
I am about to start ramping up on Django and develop a web app that I want to deploy on Google App Engine. I learn that Google has Django 0.96 already installed on the APP engine, but the latest "official" version of Django I see is at 1.2.3 and its a bit of an effort to install it there. I am curious which version of Django is most widely used. So, can you please guide me on which Django version I should ramp on and deploy based on the following criterion Stability and suitability for production release Availability for applications (or plugins) and which version is most supported by the community Thanks a lot!
Django development version vs stable release
0
0
0
1,216
4,010,507
2010-10-24T21:17:00.000
0
0
0
0
python,django
4,013,095
1
false
1
0
If, after you've cleaned your form with is_valid(), you render that cleaned form with your view, rather than redirect to a new page, you'll see the cleaned data in your page. (If you wanted the user to see this cleaned data and then properly submit it, you could use a hidden field to track whether the form data has already been cleaned, but this isn't without complications...)
1
3
0
How can I clean the data in a form and have the cleaned data redisplayed instead of the submitted data? There are several fields in my form, and every time the user submits it, it should be redisplayed with the values the user entered. However, some of the fields I would like to clean and update for the user. More specifically, I have a field FriendlyIntegerField(forms.CharField) in which I override to_python to not only call int(str(value)), but also set any negative number to 0 etc. I do not want to redisplay the form with the invalid data and have the user fix it himself (which is how Django wants me to do it). I don't have a problem cleaning the data and use it for the rest of my view-function, but how can I update the actual form with this data? By the way, the form does not reflect a structure in my data model, and so inherits from Form, not ModelForm. Edit: My Field (in a stripped down version) looks like this: class FriendlyIntegerField(forms.CharField): def to_python(self, value): try: return str(int(str(value).replace(' ',''))) except: raise forms.ValidationError('some error msg') My Form (in a stripped down version) looks like this: class SearchForm(forms.Form): price_from = FriendlyIntegerField() price_to = FriendlyIntegerField() And my view: def search(request, key): if request.method == 'POST': form = SearchForm(request.REQUEST) if not form.is_valid(): print "Form not valid" else: form = SearchForm() return render_to_response('path_to_template', {'form' : form}
How do I forcefully clean a field and redisplay it in Django?
0
0
0
220
4,011,245
2010-10-25T00:54:00.000
0
0
0
0
python,windows,passwords,runas
4,011,527
2
false
0
0
Have the user add whatever it is as a scheduled task with a specific name but no schedule, so it can only be invoked manually. They will need to enter the account credentials when creating the task, but only once. Then you can simply tell schtasks (Windows command line tool) to run it.
1
2
0
I need to run a file as another user without it prompting for a password, from my script. How is this done?
Pass Password to runas from Python
0
0
0
4,986
4,011,446
2010-10-25T02:07:00.000
1
0
1
0
python,list
4,011,481
4
false
0
0
I'm pretty sure its as simple as "alist.pop()"
1
0
0
I'm having some trouble with a couple of hmwk questions and i can't find th answer- How would you write an expression that removes the first or last element of a list? i.e. One of my questions reads "Given a list named 'alist' , write an expression that removes the last element of 'alist'"
A question about lists in Python
0.049958
0
0
1,098
4,011,855
2010-10-25T04:10:00.000
0
0
1
0
python,regex
6,064,682
8
false
0
0
I think people are taking this too far I suggest you first do this: ips = re.findall('(?:[\d]{1,3}).(?:[\d]{1,3}).(?:[\d]{1,3}).(?:[\d]{1,3})', page) then split the 4 numbers where there is a '.' and check and see if they are smaller than 256
1
1
0
I'm wondering if it's possible to compare values in regexps with the regexp system in Python. Matching the pattern of an IP is easy, but each 1-3 digits cannot be above 255 and that's where I'm a bit stumped.
Regexp to check if an IP is valid
0
0
0
5,875
4,012,340
2010-10-25T06:42:00.000
10
0
1
0
python
22,001,004
3
false
0
0
a[len(a):] - This gets you the length of a to the end. It selects a range. If you reverse a[:len(a)] it will get you the beginning to whatever is len(a).
1
154
0
I'm new to Python. I see : used in list indices especially when it's associated with function calls. Python 2.7 documentation suggests that lists.append translates to a[len(a):] = [x]. Why does one need to suffix len(a) with a colon? I understand that : is used to identify keys in dictionary.
Colon (:) in Python list index
1
0
0
304,307
4,012,571
2010-10-25T07:23:00.000
0
0
1
1
python,encoding,argv,sys
41,064,642
7
false
0
0
sys.getfilesystemencoding() works for me, at least on Windows. On Windows it is actually 'mbcs', and 'utf-8' on *nix.
2
24
0
In what encoding are the elements of sys.argv, in Python? are they encoded with the sys.getdefaultencoding() encoding? sys.getdefaultencoding(): Return the name of the current default string encoding used by the Unicode implementation. PS: As pointed out in some of the answers, sys.stdin.encoding would indeed be a better guess. I would love to see a definitive answer to this question, though, with pointers to solid sources! PPS: As Wim pointed out, Python 3 solves this issue by putting str objects in sys.argv (if I understand correctly). The question remains open for Python 2.x, though. Under Unix, the LC_CTYPE environment variable seems to be the correct thing to check, no? What should be done with Windows (so that sys.argv elements are correctly interpreted whatever the console)?
Python: Which encoding is used for processing sys.argv?
0
0
0
4,228
4,012,571
2010-10-25T07:23:00.000
6
0
1
1
python,encoding,argv,sys
4,013,349
7
false
0
0
A few observations: (1) It's certainly not sys.getdefaultencoding. (2) sys.stdin.encoding appears to be a much better bet. (3) On Windows, the actual value of sys.stdin.encoding will vary, depending on what software is providing the stdio. IDLE will use the system "ANSI" code page, e.g. cp1252 in most of Western Europe and America and former colonies thereof. However in the Command Prompt window, which emulates MS-DOS more or less, the corresponding old DOS code page (e.g. cp850) will be used by default. This can be changed by using the CHCP (change code page) command. (4) The documentation for the subprocess module doesn't provide any suggestions on what encoding to use for args and stdout. (5) One trusts that assert sys.stdin.encoding == sys.stdout.encoding never fails.
2
24
0
In what encoding are the elements of sys.argv, in Python? are they encoded with the sys.getdefaultencoding() encoding? sys.getdefaultencoding(): Return the name of the current default string encoding used by the Unicode implementation. PS: As pointed out in some of the answers, sys.stdin.encoding would indeed be a better guess. I would love to see a definitive answer to this question, though, with pointers to solid sources! PPS: As Wim pointed out, Python 3 solves this issue by putting str objects in sys.argv (if I understand correctly). The question remains open for Python 2.x, though. Under Unix, the LC_CTYPE environment variable seems to be the correct thing to check, no? What should be done with Windows (so that sys.argv elements are correctly interpreted whatever the console)?
Python: Which encoding is used for processing sys.argv?
1
0
0
4,228
4,013,046
2010-10-25T08:49:00.000
2
1
0
0
c#,c++,python,algorithm,performance
4,013,104
2
false
0
0
Compress the difference between successive images. Add some checksum. Provide some way for the receiver to request full image data for the case where things get out of synch. There are probably a host of protocols doing that already. So, search for live video stream protocols. Cheers & hth.,
2
0
0
I am solving a problem of transferring images from a camera in a loop from a client (a robot with camera) to a server (PC). I am trying to come up with ideas how to maximize the transfer speed so I can get the best possible FPS (that is because I want to create a live video stream out of the transferred images). Disregarding the physical limitations of WIFI stick on the robot, what would you suggest? So far I have decided: to use YUV colorspace instead of RGB to use UDP protocol instead of TCP/IP Is there anything else I could do to get the maximum fps possible?
How to speed up transfer of images from client to server
0.197375
0
1
375
4,013,046
2010-10-25T08:49:00.000
4
1
0
0
c#,c++,python,algorithm,performance
4,013,112
2
true
0
0
This might be quite a bit of work but if your client can handle the computations in real time you could use the same method that video encoders use. Send a key frame every say 5 frames and in between only send the information that changed not the whole frame. I don't know the details of how this is done, but try Googling p-frames or video compression.
2
0
0
I am solving a problem of transferring images from a camera in a loop from a client (a robot with camera) to a server (PC). I am trying to come up with ideas how to maximize the transfer speed so I can get the best possible FPS (that is because I want to create a live video stream out of the transferred images). Disregarding the physical limitations of WIFI stick on the robot, what would you suggest? So far I have decided: to use YUV colorspace instead of RGB to use UDP protocol instead of TCP/IP Is there anything else I could do to get the maximum fps possible?
How to speed up transfer of images from client to server
1.2
0
1
375
4,013,733
2010-10-25T10:38:00.000
0
0
0
0
python,django,django-models,django-admin
4,030,636
1
false
1
0
say you have a product model class Product(models.Model): name=models.CharField(max_length=20) cost=models.DecimalField(max_length=10) you can subclass the admin's Modeladmin to show a list display for the products or you can do a custom modelform for the product which you can call in the product's admin from django.contrib import admin from django import forms class PropertyInline(admin.TabularInine): model=Property extra=1 class PropertyForm(admin.ModelAdmin): inlines=(PropertyInline,)
1
0
0
Our product model can have multiple campaigns. Our customers change these campaigns frequently and generally on multiple products. So what we need right now seems that we need to show a multiple select widget on a change-list of Product model where our customers can easily change the campaigns. Any idea on this? Maybe another way to achieve this kind of UI interaction? Thanks,
django multiple select in admin change-list
0
0
0
559
4,014,242
2010-10-25T11:51:00.000
0
0
1
0
python,overlap,intervals
4,422,033
3
false
0
0
Maybe storing of all intersection intervals can help. You need: boundaries of union of all intervals, for each intersection left boundary and list of intervals from which intersection is made. Intersection intervals can be stored in a tree, because they are represented only with left boundary. Methods insert and delete interval look like (simplified): Insert: find intersection intervals for left and right boundary of new interval, split these intersection intervals in 2 or 3 new intersection intervals. For each intersection intervals between add pointer to new interval. Delete: find intersection intervals for left and right boundary, merge them to intersection intervals before. For each intersection intervals between remove pointer to deleted interval.
1
4
0
I am looking for some python code to efficiently compute interval overlaps. I've used the interval tree of the bx-python package before, but now need to delete intervals from the tree (or better yet, modify them). It seems the bx-python tree doesn't support this. Any pointers?
Python: Dynamic interval data structure
0
0
0
3,581
4,014,670
2010-10-25T12:48:00.000
1
1
0
1
java,php,javascript,python
4,014,696
6
false
0
0
You can write a WEB APPLICATION. The encryption part is solved by simple HTTPS usage. On the server side (your home computer with USB devices attached to it) you should use Python (since you're quite experienced with it) and a Python Web Framework you want (I.E. Django).
3
3
0
I wish to control my computer (and usb devices attached to the computer) at home with any computer that is connected to the internet. The computer at home must have a program installed that receives commands from any other computer that is connected to the internet. I thought it would be best if I do this with a web interface as it would not be necessary to install software on that computer. For obvious reasons it would require log in details. Extra details: The main part of the project is actually a device that I will develop that connects to the computer's usb port. Sorry if it was a bit vague in my original question. This device will perform simple functions such as turning lights on etc. At first I will just attempt to switch the lights remotely using the internet. Later on I will add commands that can control certain aspects of the computer such as the music player. I think doing a full remote desktop connection to control my device is therefore not quite necessary. Does anybody know of any open source projects that can perform these functions? So basically the problem is sending encrypted commands from a web interface to my computer at home. What would be the best method to achieve this and what programming languages should I use? I know Java, Python and C quite well, but have very little experience with web applications, such as Javascript and PHP. I have looked at web chat examples as it is sort of similar concept to what I wish to achieve, except the text can be replaced with commands. Is this a viable solution or are there better alternatives? Thank you
Send commands between two computers over the internet
0.033321
0
1
1,907
4,014,670
2010-10-25T12:48:00.000
0
1
0
1
java,php,javascript,python
4,014,765
6
false
0
0
Well, I think that java can work well, in fact you have to deal with system calls to manage usb devices and things like that (and as far as I know, PHP is not the best language to do this). Also shouldn't be so hard to create a basic server/client program, just use good encryption mechanism to not show commands around web.
3
3
0
I wish to control my computer (and usb devices attached to the computer) at home with any computer that is connected to the internet. The computer at home must have a program installed that receives commands from any other computer that is connected to the internet. I thought it would be best if I do this with a web interface as it would not be necessary to install software on that computer. For obvious reasons it would require log in details. Extra details: The main part of the project is actually a device that I will develop that connects to the computer's usb port. Sorry if it was a bit vague in my original question. This device will perform simple functions such as turning lights on etc. At first I will just attempt to switch the lights remotely using the internet. Later on I will add commands that can control certain aspects of the computer such as the music player. I think doing a full remote desktop connection to control my device is therefore not quite necessary. Does anybody know of any open source projects that can perform these functions? So basically the problem is sending encrypted commands from a web interface to my computer at home. What would be the best method to achieve this and what programming languages should I use? I know Java, Python and C quite well, but have very little experience with web applications, such as Javascript and PHP. I have looked at web chat examples as it is sort of similar concept to what I wish to achieve, except the text can be replaced with commands. Is this a viable solution or are there better alternatives? Thank you
Send commands between two computers over the internet
0
0
1
1,907
4,014,670
2010-10-25T12:48:00.000
0
1
0
1
java,php,javascript,python
4,015,151
6
false
0
0
I you are looking for solution you could use from any computer anywhere in the worls without the need to install any software on client pc, try logmein.com (http://secure.logmein.com). It is free, reliable, works in any modern browser, you don't have to remmeber IPs and hope they won't change, ... Or if this is a "for fun project" why not write a php script, open port 80 in your router so you can access you script from outside, possibly dynamically link some domain to your IP (http://www.dyndns.com/). In the script you would just login and then for example type the orders in textfield in some form in your script. Lets just say you want to do some command prompt stuf, so you will basically remotely construst a *.bat file for example. Then the script stores this a fromtheinternets.bat to a folder on your desktop that is being constantly monitored for changes. And when such a change is found you just activate the bat file. Insecure? Yes (It could be made secureER) Fun to write? Definitely PS: I am new here, hope it's not "illegal" to post link to actual services, instead of wiki lists. This is by no means and advertisement, I am just a happy user. :)
3
3
0
I wish to control my computer (and usb devices attached to the computer) at home with any computer that is connected to the internet. The computer at home must have a program installed that receives commands from any other computer that is connected to the internet. I thought it would be best if I do this with a web interface as it would not be necessary to install software on that computer. For obvious reasons it would require log in details. Extra details: The main part of the project is actually a device that I will develop that connects to the computer's usb port. Sorry if it was a bit vague in my original question. This device will perform simple functions such as turning lights on etc. At first I will just attempt to switch the lights remotely using the internet. Later on I will add commands that can control certain aspects of the computer such as the music player. I think doing a full remote desktop connection to control my device is therefore not quite necessary. Does anybody know of any open source projects that can perform these functions? So basically the problem is sending encrypted commands from a web interface to my computer at home. What would be the best method to achieve this and what programming languages should I use? I know Java, Python and C quite well, but have very little experience with web applications, such as Javascript and PHP. I have looked at web chat examples as it is sort of similar concept to what I wish to achieve, except the text can be replaced with commands. Is this a viable solution or are there better alternatives? Thank you
Send commands between two computers over the internet
0
0
1
1,907
4,014,706
2010-10-25T12:53:00.000
0
0
1
0
python
4,014,896
2
false
0
0
second problem: as the traceback says, aBuf is an int but it's expecting a string. You need to find out why. uhhhh ... just worked it out; you are feeding it a single byte, expressed as an integer (0xab) instead of a string ('\xab'). In any case, chardet requires much more than 1 byte to be able to guess an encoding. Feeding any charset detector one byte is utterly pointless.
1
0
0
I am testing chardet in one of my scripts. I wanted to identify the encoding type of a result variable and chardet seems to do fine here. So this is what I am doing: myvar1 <-- gets its value from other functions myvar2 = chardet.detect(myvar1) <-- to detect the encoding type of myvar1 Now when I do a print myvar2, I receive the output: {'confidence': 1.0, 'encoding': 'ascii'} Question 1: Can someone give pointer on how to collect only the encoding value part out of this, i.e. ascii. Edit: The scenario is as follows: I am using unicode(myvar1) to write all input as unicode. But as soon as myvar1 gets a value like 0xab, unicode(myvar1) fails with the error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xab in position xxx: ordinal not in range(128) Therefore, I am tring to: first identify the encoding type of the input which comes in myvar1, take the encoding type in myvar2, decode the input (myvar1) with this encoding (myvar2) using decode() [?] pass it on to unicode. The input coming in is variable and not in my control. I am sure there are other ways to do this, but I am new to this. And I am open to trying. Any pointer please. Many Thanks.
Splitting results from chardet output to collect encoding type
0
0
0
319
4,014,722
2010-10-25T12:56:00.000
0
0
1
0
python,introspection
4,014,972
4
false
0
0
A function object contains only compiled bytecode, the source text is not kept. The only way to retrieve source code is to read the script file it came from. There's nothing special about lambdas though: they still have a f.func_code.co_firstline and co_filename property which you can use to retrieve the source file, as long as the lambda was defined in a file and not interactive input.
1
13
0
Let's say I'm working in the Python shell and I'm given a function f. How can I access the string containing its source code? (From the shell, not by manually opening the code file.) I want this to work even for lambda functions defined inside other functions.
Viewing the code of a Python function
0
0
0
8,389
4,015,227
2010-10-25T13:53:00.000
0
0
0
0
python,streaming,p2p,vlc,instant-messaging
4,200,613
1
false
0
0
I think they were suggesting you run your program on a LAN which has no ports blocked.
1
0
0
I've have asked these questions before with no proper answer. I hope I'll get some response here. I'm developing an instant messenger in python and I'd like to handle video/audio streaming with VLC. Tha basic idea right now is that in each IM client I'm running one VLC instance that acts as a server that streams to all the users I want, and another VLC instance that's a client and recieves and displays all the streams that other users are sending to me. As you can see, it's kind of a P2P connection and I am having lots of problems. My first problem was VLC can handle only one stream per port, but I solved this using VLM, the Videolan Manager which allows multiple streams with one instance and on one port. My second problem was this kind of P2P take has several drawbacks as if someone is behind NAT or a router, you have to do manual configurations to forward the packages from the router to your PC, and it also has another drawback, you can only forward to 1 PC, so you would be able to use the program in only one workstation. Also, the streams were transported in HTTP protocol, which uses TCP and it's pretty slow. When I tried to do the same with RTSP, I wasn't able to get the stream outside my private LAN. So, this P2P take is very unlikely to be implemented successfully by an amateur like me, as it has all the typical NAT traversal problems, things that I don't want to mess with as this is not a commercial application, just a school project I must finish in order to graduate as a technician. Finally, I've been recommended to a use a server in a well known IP and that would solve the problem, only one router configuration and let both ends of the conversations be clients. I have no idea how to implement this idea, please any help is useful. Thanks in advance. Sorry for any error, I am not a programming/networking expert nor am I an english-speaking person.
Problems with VLC and instant messaging
0
0
1
224
4,016,151
2010-10-25T15:31:00.000
1
1
0
1
python,windows,easy-install
4,016,275
5
false
0
0
For one thing, it says you already have that module installed. If you need to upgrade it, you should do something like this: easy_install -U packageName Of course, easy_install doesn't work very well if the package has some C headers that need to be compiled and you don't have the right version of Visual Studio installed. You might try using pip or distribute instead of easy_install and see if they work better.
1
63
0
After installing Python 2.7 on Windows XP, then manually setting the %PATH% to python.exe (why won't the python installer do this?), then installing setuptools 0.6c11 (why doesn't the python installer do this?), then manually setting the %PATH% to easy_install.exe (why doesn't the installer do this?), I finally tried to install a python package with easy_install, but easy_install failed when it couldn't install the pywin32 package, which is a dependency. How can I make easy_install work properly on Windows XP? The failure follows: C:\>easy_install winpexpect Searching for winpexpect Best match: winpexpect 1.4 Processing winpexpect-1.4-py2.7.egg winpexpect 1.4 is already the active version in easy-install.pth Using c:\python27\lib\site-packages\winpexpect-1.4-py2.7.egg Processing dependencies for winpexpect Searching for pywin32>=214 Reading http://pypi.python.org/simple/pywin32/ Reading http://sf.net/projects/pywin32 Reading http://sourceforge.net/project/showfiles.php?group_id=78018 No local packages or download links found for pywin32>=214 Best match: None Traceback (most recent call last): File "C:\python27\scripts\easy_install-script.py", line 8, in load_entry_point('setuptools==0.6c11', 'console_scripts', 'easy_install')() File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 1712, in main with_ei_usage(lambda: File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 1700, in with_ei_usage return f() File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 1716, in distclass=DistributionWithoutHelpCommands, **kw File "C:\python27\lib\distutils\core.py", line 152, in setup dist.run_commands() File "C:\python27\lib\distutils\dist.py", line 953, in run_commands self.run_command(cmd) File "C:\python27\lib\distutils\dist.py", line 972, in run_command cmd_obj.run() File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 211, in run self.easy_install(spec, not self.no_deps) File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 446, in easy_install return self.install_item(spec, dist.location, tmpdir, deps) File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 481, in install_item self.process_distribution(spec, dists[0], deps, "Using") File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 519, in process_distribution [requirement], self.local_index, self.easy_install File "C:\python27\lib\site-packages\pkg_resources.py", line 563, in resolve dist = best[req.key] = env.best_match(req, self, installer) File "C:\python27\lib\site-packages\pkg_resources.py", line 799, in best_match return self.obtain(req, installer) # try and download/install File "C:\python27\lib\site-packages\pkg_resources.py", line 811, in obtain return installer(requirement) File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 434, in easy_install self.local_index File "C:\python27\lib\site-packages\setuptools\package_index.py", line 475, in fetch_distribution return dist.clone(location=self.download(dist.location, tmpdir)) AttributeError: 'NoneType' object has no attribute 'clone'
How to use Python's "easy_install" on Windows ... it's not so easy
0.039979
0
0
152,491
4,016,855
2010-10-25T16:44:00.000
7
0
1
0
python
4,016,865
4
true
0
0
It's where it's always been, under Tools/ in the source distribution.
2
10
0
Anyone know where freeze.py is installed for 2.6.5? I can't seem to find it anywhere. Did it get pulled out and replaced with something else?
Python: Where is freeze.py?
1.2
0
0
11,493
4,016,855
2010-10-25T16:44:00.000
0
0
1
0
python
4,020,422
4
false
0
0
Are you getting the error: "needed directory /usr/local/lib/python/lib not found"? You need to configure Freeze before you use it. Run "make libainstall" in your Python build tree.
2
10
0
Anyone know where freeze.py is installed for 2.6.5? I can't seem to find it anywhere. Did it get pulled out and replaced with something else?
Python: Where is freeze.py?
0
0
0
11,493
4,017,129
2010-10-25T17:19:00.000
2
0
0
0
python,linux,tkinter,option
4,018,335
3
true
0
1
Linux doesn't have those drive letters C:, D:, etc. In linux all filesystems of different drives are mounted on separate folders in the same tree structure, so you only have a single tree. Most distros use /media to mount pendrives etc, but hard drives can be configured to mount on any folder. So there's no such thing as "drive letter" in linux, your question doesn't apply.
3
0
0
I'm using "tkFileDialog.askopenfilename" to get a file name variable. I know that I can set the "initialdir" option, but not everyone who uses the program will have the target file on the same drive. For example: the file could be located on the C:, D:, E: etc... I don't see a way to view available drives with the dialog box they have open up. I'd like the user to be able to type something like "/h/cowsandstuff" and have it navigate to that directory instead of locking them in. I am programming in a Linux environment, BTW. The analogous function in Windows that I would like is the "My Computer" option in the drop down menu which would list all available drives...
tkFileDialog.askopenfilename How to specify a different drive?
1.2
0
0
1,219
4,017,129
2010-10-25T17:19:00.000
0
0
0
0
python,linux,tkinter,option
4,028,422
3
false
0
1
If you simply point to "/" it contains all mounted devices...
3
0
0
I'm using "tkFileDialog.askopenfilename" to get a file name variable. I know that I can set the "initialdir" option, but not everyone who uses the program will have the target file on the same drive. For example: the file could be located on the C:, D:, E: etc... I don't see a way to view available drives with the dialog box they have open up. I'd like the user to be able to type something like "/h/cowsandstuff" and have it navigate to that directory instead of locking them in. I am programming in a Linux environment, BTW. The analogous function in Windows that I would like is the "My Computer" option in the drop down menu which would list all available drives...
tkFileDialog.askopenfilename How to specify a different drive?
0
0
0
1,219
4,017,129
2010-10-25T17:19:00.000
1
0
0
0
python,linux,tkinter,option
4,028,563
3
false
0
1
As nosklo sais, in Linux you don't have drive letters. Everything are paths. If the file can be in any path, I would expect that the user will known the path, but I would consider the next options: Default to the user's home path. You can directly use the ´~´and tk will convert it to the Linux home folder or the Windows User/My Documents path Remember the last path so you can use it in the future.
3
0
0
I'm using "tkFileDialog.askopenfilename" to get a file name variable. I know that I can set the "initialdir" option, but not everyone who uses the program will have the target file on the same drive. For example: the file could be located on the C:, D:, E: etc... I don't see a way to view available drives with the dialog box they have open up. I'd like the user to be able to type something like "/h/cowsandstuff" and have it navigate to that directory instead of locking them in. I am programming in a Linux environment, BTW. The analogous function in Windows that I would like is the "My Computer" option in the drop down menu which would list all available drives...
tkFileDialog.askopenfilename How to specify a different drive?
0.066568
0
0
1,219
4,017,164
2010-10-25T17:23:00.000
0
0
0
0
sqlalchemy,python-elixir
4,025,154
1
true
0
0
After a day or so of deliberation, I'm attempting to load the new business module in IronPython. Although I don't really want to introduce to python interpreters into my environment, I think that this will be the glue I need to get this done efficiently.
1
0
0
A new requirement has come down from the top: implement 'proprietary business tech' with the awesome, resilient Elixir database I have set up. I've tried a lot of different things, such as creating an implib from the provided interop DLL (which apparently doesn't work like COM dlls) which didn't work at all. CPython doesn't like the MFC stuff either, so all attempts to create a Python lib have failed (using C anyway, not sure you can create a python library from .NET directly). The only saving grace is the developer saw fit to provide VBA, .NET and MFC Interop C++ hooks into his library, so there are "some" choices, though they all ultimately lead back to the same framework. What would be the best method to: A) Keep my model definitions in one place, in one language (Python/Elixir/SQLAlchemy) B) Have this new .NET access the models without resorting to brittle, hard-coded SQL. Any and all suggestions are welcome.
Loading Elixir/SQLAlchemy models in .NET?
1.2
1
0
502
4,019,571
2010-10-25T23:04:00.000
2
0
0
0
python,video,video-streaming
4,020,278
1
true
0
1
Or would that be just lame? No. It wouldn't work at all. There's a trick to getting video to work. Apple's QuickTime implements that trick. So does a bunch of Microsoft product. Plus some open source video playback tools. There are several closely-related tricks, all of which are a huge pain in the neck. Compression. Full-sized video is Huge. Do the math 640x480x24-bit color at 30 frames per second. It adds up quickly. Without compression, you can't read it in fast enough. Buffering and Timing. Sometimes the data rates and frame rates don't align well. You need a buffer of ready-to-display frames and you need a deadly accurate clock to get them do display at exactly the right intervals. Making a sequence of JPEG images into a movie is what iPhoto and iMovie are for. Usually, what we do is create the video file from the image and play the video file through a standard video player. Making a QuickTime movie or Flash movie from images isn't that hard. There are a lot of tools to help make movies from images. Almost any photo management solution can create a slide show and save it as a movie in some standard format. Indeed, I think that Graphic Converter can do this.
1
3
0
I have a camera that is taking pictures one by one (about 10 pictures per second) and sending them to PC. I need to show this incoming sequence of images as a live video in PC. Is it enough just to use some Python GUI framework, create a control that will hold a single image and just change the image in the control very fast? Or would that be just lame? Should I use some sort of video streaming library? If yes, what do you recommend?
The simplest video streaming?
1.2
0
0
5,351
4,019,611
2010-10-25T23:11:00.000
0
0
0
0
python,geospatial,kml,latitude-longitude
4,026,507
1
true
0
1
The overlay image referenced by the kml file was in standard geographic projection. This means that the latitudes and longitudes vary linearly within the image. Calculating the latitude and longitude of each pixel became a trivial case of interpolation given that we already known the lat/lon bounds of the image provided by the LatLonBox tag attributes.
1
0
0
I am using .kml file which points to an overlay image (presumably in UTM projection?). The KML file provides the latitudes and longitudes of the bounding box using the "LatLonBox" tag. I need to calculate the latitudes and longitudes of each pixel in this image. Are there any pre-existing libraries in Python that would do this for me?
How can I calculate the latitude and longitude of each pixel of an image in a kml file using Python?
1.2
0
0
744
4,022,049
2010-10-26T08:53:00.000
5
0
0
0
python,pyqt,qtableview
4,022,111
1
true
0
1
As you dont state what you canged in your model, ill assume the simplest form of change (changed data). For me model.select() works to update the data in the model and force the View to update itself.
1
1
0
I have a QTableView which displays data from a QSqlTableModel. I want my model to check for changes when a user hits a "refresh" button but I can't find a way to update the data. I tried the reset() and update() methods on the model without any result. Is it possible to "re-read" from the database and update the model? How?
Force Update QTableView + QSqlTableModel in PyQt
1.2
0
0
3,260
4,022,887
2010-10-26T10:42:00.000
0
0
0
0
python,csv,pytables
4,023,046
6
false
0
0
These are not "exclusive" choices. You need both. CSV is just a data exchange format. If you use pytables, you still need to import and export in CSV format.
3
8
1
I recently came across Pytables and find it to be very cool. It is clear that they are superior to a csv format for very large data sets. I am running some simulations using python. The output is not so large, say 200 columns and 2000 rows. If someone has experience with both, can you suggest which format would be more convenient in the long run for such data sets that are not very large. Pytables has data manipulation capabilities and browsing of the data with Vitables, but the browser does not have as much functionality as, say Excel, which can be used for CSV. Similarly, do you find one better than the other for importing and exporting data, if working mainly in python? Is one more convenient in terms of file organization? Any comments on issues such as these would be helpful. Thanks.
Pytables vs. CSV for files that are not very large
0
0
0
3,418
4,022,887
2010-10-26T10:42:00.000
2
0
0
0
python,csv,pytables
7,753,331
6
false
0
0
One big plus for PyTables is the storage of metadata, like variables etc. If you run the simulations more often with different parameters you the store the results as an array entry in the h5 file. We use it to store measurement data + experiment scripts to get the data so it is all self contained. BTW: If you need to look quickly into a hdf5 file you can use HDFView. It's a Java app for free from the HDFGroup. It's easy to install.
3
8
1
I recently came across Pytables and find it to be very cool. It is clear that they are superior to a csv format for very large data sets. I am running some simulations using python. The output is not so large, say 200 columns and 2000 rows. If someone has experience with both, can you suggest which format would be more convenient in the long run for such data sets that are not very large. Pytables has data manipulation capabilities and browsing of the data with Vitables, but the browser does not have as much functionality as, say Excel, which can be used for CSV. Similarly, do you find one better than the other for importing and exporting data, if working mainly in python? Is one more convenient in terms of file organization? Any comments on issues such as these would be helpful. Thanks.
Pytables vs. CSV for files that are not very large
0.066568
0
0
3,418
4,022,887
2010-10-26T10:42:00.000
1
0
0
0
python,csv,pytables
4,024,016
6
false
0
0
i think its very hard to comapre pytables and csv.. pyTable is a datastructure ehile CSV is an exchange format for data.
3
8
1
I recently came across Pytables and find it to be very cool. It is clear that they are superior to a csv format for very large data sets. I am running some simulations using python. The output is not so large, say 200 columns and 2000 rows. If someone has experience with both, can you suggest which format would be more convenient in the long run for such data sets that are not very large. Pytables has data manipulation capabilities and browsing of the data with Vitables, but the browser does not have as much functionality as, say Excel, which can be used for CSV. Similarly, do you find one better than the other for importing and exporting data, if working mainly in python? Is one more convenient in terms of file organization? Any comments on issues such as these would be helpful. Thanks.
Pytables vs. CSV for files that are not very large
0.033321
0
0
3,418
4,025,412
2010-10-26T15:49:00.000
0
1
0
1
buildout,python-egg-cache
4,026,496
2
true
0
0
I'm not sure what you mean. Three options that you normally have: Buildout, by default, stores the eggs in a directory called eggs/ inside your buildout directory. You can set the eggs-dir variable inside your buildout.cfg's [buildout] section to some directory. Just tell it where to place them. You can also set that very same option in .buildout/defaults.cfg inside your home directory. That way you can set a default for all your projects. Handy for storing all your eggs in one place: that can save a lot of download time, for instance. Does one of those (especially the last one) accomplish what you want? And: don't muck around with eggs in the generated bin/* files. Let buldout pick the eggs, that's its purpose.
1
1
0
We're having problems when trying to deploy a number of projects which use zc.buildout - specifically we're finding that they want to put their PYTHON_EGG_CACHE directories all over the show. We'd like to somehow set this directory to one at the same level as the built-out project, where eggs can be found. There is some mention online that this can be done for Plone projects, but is it possible to do this without Plone? Are there some recipes that can set up an environment variable so we can set the PYTHON_EGG_CACHE executable files in ./bin?
Specify a custom PYTHON_EGG_CACHE dir with zc.buildout?
1.2
0
0
1,434
4,026,026
2010-10-26T17:02:00.000
0
1
0
0
python,user-interface,sqlalchemy,cross-platform,python-elixir
9,863,280
2
false
0
1
In my opinion the best option for this would be to make a CGI program to run through a browser so that you do not have to worry about platform issues. Granted it might take a little bit more work, it may be better suited for cross platform deployment. :)
2
3
0
My needs : I need to develop an GUI application that is cross platform the chosen solution must be the fastest to implement it should be easy to extend The application is just a database front-end, mainly for CRUD operations, listing, filtering, exporting, charts and graphs etc. After reading about some solutions (Python Card, PyGUI, DABO, pygtkhelpers, kiwi, pyjamas, pure-mvc, PyQt/PySide, Wax, Tk-based frameworks, AVC, Fox etc.), I found myself interrested in two particular solutions, one of them is Camelot. Before jumping into it, I would like to have some opinions about Camelot users vs skeptics. Thanks for sharing :)
Feedback for Camelot
0
0
0
593
4,026,026
2010-10-26T17:02:00.000
1
1
0
0
python,user-interface,sqlalchemy,cross-platform,python-elixir
14,327,581
2
false
0
1
Disclaimer: I am a Camelot committer. If the question has been raised on the Programmers Stack Exchange, please link to it. This question is kind of old, but for any reference, i'll chime in. Camelot was and is developed for exactly the reasons you stated. It has matured a lot since this questions was asked and is about feature complete. Latest efforts have been made to use Declarative instead of Elixir. Stability and speed are strongpoints as well.
2
3
0
My needs : I need to develop an GUI application that is cross platform the chosen solution must be the fastest to implement it should be easy to extend The application is just a database front-end, mainly for CRUD operations, listing, filtering, exporting, charts and graphs etc. After reading about some solutions (Python Card, PyGUI, DABO, pygtkhelpers, kiwi, pyjamas, pure-mvc, PyQt/PySide, Wax, Tk-based frameworks, AVC, Fox etc.), I found myself interrested in two particular solutions, one of them is Camelot. Before jumping into it, I would like to have some opinions about Camelot users vs skeptics. Thanks for sharing :)
Feedback for Camelot
0.099668
0
0
593
4,027,508
2010-10-26T20:02:00.000
1
0
0
0
javascript,python,ajax,django
4,027,614
3
false
1
0
The reason to update all of the comments is to take in account other comments that other people may have also submitted in the meantime. to keep the site truly dynamic, you can do either that, or even, when the page is loaded, load up a variable with the newest submitted comment ID, and set a timer that goes back to check if there are more comments since then. if there are, return them as a JSON object and append them onto the current page a DIV at a time. That would be my preferred way to handle it, because you can then target actions based on each DIV's id or rel, which directly relates back to the comment's ID in the database...
3
2
0
This is a situation I've run into several times, not sure what the best approach is. Let's say I have some kind of dynamic content that users can add to via Ajax. For example, take Stack Overflow's comments - people can add comments directly on to the page using Ajax. The question is, how do I implement the addition itself of the new content. For example, it looks like the ajax call which Stack Overflow uses to add a comment, simply returns html which replaces all of the comments (not just the new one). This way saves redundant logic in the Javascript code which has to "know" what the html looks like. Is this the best approach? If so, how best to implement it in Django so that there is no redundancy (i.e., so that the view doesn't have to know what the html looks like?) Thanks! EDIT: In my specific case, there is no danger of other comments being added in the meantime - this is purely a question of the best implementation.
Loading New Content with Ajax
0.066568
0
0
261
4,027,508
2010-10-26T20:02:00.000
1
0
0
0
javascript,python,ajax,django
4,027,641
3
false
1
0
I am not proficient neither with Django nor Python but I suppose the basic logic is similar for all server-side languages. When weighing the pros and cons of either approach things depend on what you want to optimize. If bandwidth is important then obviously using pure JSON in communication reduces latency when compared to transmitting ready-made HTML. However, duplicating the server-side view functionality to Javascript is a tedious and error-prone process. It simply takes a lot of time. I personally feel that in most cases (for small and medium traffic sites) it's perfectly fine to put the HTML fragment together on server side and simply replace the contents of a container (e.g. contents of a div) inside an AJAX callback function. Of course, replacing the whole page would be silly, hence your Django application needs to support outputting specific regions of the document.
3
2
0
This is a situation I've run into several times, not sure what the best approach is. Let's say I have some kind of dynamic content that users can add to via Ajax. For example, take Stack Overflow's comments - people can add comments directly on to the page using Ajax. The question is, how do I implement the addition itself of the new content. For example, it looks like the ajax call which Stack Overflow uses to add a comment, simply returns html which replaces all of the comments (not just the new one). This way saves redundant logic in the Javascript code which has to "know" what the html looks like. Is this the best approach? If so, how best to implement it in Django so that there is no redundancy (i.e., so that the view doesn't have to know what the html looks like?) Thanks! EDIT: In my specific case, there is no danger of other comments being added in the meantime - this is purely a question of the best implementation.
Loading New Content with Ajax
0.066568
0
0
261
4,027,508
2010-10-26T20:02:00.000
4
0
0
0
javascript,python,ajax,django
4,029,103
3
true
1
0
If the content is simple, I would get JSON and build the HTML in jQuery. If it's complex, I would create a template and call render() on it on the server and return the HTML (which jQuery could either append to other content or replace existing content).
3
2
0
This is a situation I've run into several times, not sure what the best approach is. Let's say I have some kind of dynamic content that users can add to via Ajax. For example, take Stack Overflow's comments - people can add comments directly on to the page using Ajax. The question is, how do I implement the addition itself of the new content. For example, it looks like the ajax call which Stack Overflow uses to add a comment, simply returns html which replaces all of the comments (not just the new one). This way saves redundant logic in the Javascript code which has to "know" what the html looks like. Is this the best approach? If so, how best to implement it in Django so that there is no redundancy (i.e., so that the view doesn't have to know what the html looks like?) Thanks! EDIT: In my specific case, there is no danger of other comments being added in the meantime - this is purely a question of the best implementation.
Loading New Content with Ajax
1.2
0
0
261
4,027,975
2010-10-26T20:59:00.000
-1
0
1
0
php,python,math
4,028,047
6
false
0
0
($people * $breadSticksPerPerson) / $holders isn't correct? EDIT: Sorry, misread your question, posted the correct solution in comments
1
1
0
Feeling pretty brain-dead right now. I can, of course, brute-force this, but I feel like there has to be a simple function to return this number. Concerning native functions, I'm using PHP and/or Python. For example: there exists containers that hold X (5) breadsticks each, and I need to feed Y (25) people Z (3) breadsticks each. I need to return the number of containers I have to acquire to feed these people. (There may or may not be remainder breadsticks). EDIT: Clarified some intention.
Return minimum X (that can contain Y items) for arbitrary number of items
-0.033321
0
0
121
4,029,807
2010-10-27T03:42:00.000
0
0
0
0
python,django,polling
4,029,976
2
false
1
0
Hmm. You could do it two ways that I can think of off the bat - there are surely more. You can add a field called "already_retrieved" and set it to True for those fields that have already been retrieved, and then only grab Whatever.objects.filter(already_retrieved=False). Also, if they are in order by a pk, you could just keep track of how far you are in the list of pk's.
1
0
0
In ajax I am polling a django url to retrieve the latest records. I do not want to display any records I have retrieved previously and I only want to retrieve 1 record for each poll request. What would be the best way to do this?
Django Poll for new records
0
0
0
92
4,029,946
2010-10-27T04:21:00.000
40
0
1
0
python,configuration
4,057,933
2
true
0
0
After getting around to testing it, ConfigParser overwrites the keys with each successive file, the order in which the files are read is determined by the order of the file names in the list passed to ConfigParser.read
1
44
0
When calling ConfigParser.read you are allowed to pass a list of strings corresponding to potential locations for configuration files and the function returns a list of those files that were successfully read. What is the default behaviour when multiple configuration files are loaded that have overlapping sections/keys? Do later files in the list override values parsed by earlier ones? Is the entire section overridden or just conflicting keys?
Multiple configuration files with Python ConfigParser
1.2
0
0
20,141
4,030,026
2010-10-27T04:44:00.000
3
0
0
0
php,python,django,frameworks
4,030,033
5
false
1
0
I'd try Symfony. What you're referring to sounds like "scaffolding"
2
0
0
I am using python with django. There I can simply make form from models and also it had builtin Admin. I am eager to know corresponding framework for PHP with all this facilities. I have encountered lot some similar questions like this, but they had not compared the frameworks with django. Experts Please Suggest.
Any framework for PHP, as effective as Django for Python?
0.119427
0
0
3,514
4,030,026
2010-10-27T04:44:00.000
2
0
0
0
php,python,django,frameworks
4,030,038
5
false
1
0
I've had good success with Zend in the past. It has a lot of functionality in its libraries and it is all completely decoupled, so you can use whichever parts best fit your task, leaving out other things all together.
2
0
0
I am using python with django. There I can simply make form from models and also it had builtin Admin. I am eager to know corresponding framework for PHP with all this facilities. I have encountered lot some similar questions like this, but they had not compared the frameworks with django. Experts Please Suggest.
Any framework for PHP, as effective as Django for Python?
0.07983
0
0
3,514
4,030,277
2010-10-27T05:40:00.000
1
0
1
1
python,multiprocess
4,385,534
1
false
1
0
Main proc is waiting for all child procs to be terminated before exits itself so there's a blocking call (i.e. wait4) registered as at_exit handles. The signal you sent interrupts that blocking call thus the stack trace. The thing I'm not clear about is that if the signal sent to child would be redirected to the parent process, which then interrupted that wait4 call. This is something related to the Unix process group behaviors.
1
0
0
I have one multprocess demo here, and I met some problems with it. Researched for a night, I cannot resolve the reason. Any one can help me? I want to have one parent process acts as producer, when there are tasks come, the parent can fork some children to consume these tasks. The parent monitors the child, if any one exits with exception, it can be restarted by parent. #!/usr/bin/env python # -*- coding: utf-8 -*- from multiprocessing import Process, Queue from Queue import Empty import sys, signal, os, random, time import traceback child_process = [] child_process_num = 4 queue = Queue(0) def work(queue): signal.signal(signal.SIGINT, signal.SIG_DFL) signal.signal(signal.SIGTERM, signal.SIG_DFL) signal.signal(signal.SIGCHLD, signal.SIG_DFL) time.sleep(10) #demo sleep def kill_child_processes(signum, frame): #terminate all children pass def restart_child_process(signum, frame): global child_process for i in xrange(len(child_process)): child = child_process[i] try: if child.is_alive(): continue except OSError, e: pass child.join() #join this process to make sure there is no zombie process new_child = Process(target=work, args=(queue,)) new_child.start() child_process[i] = new_child #restart one new process child = None return if __name__ == '__main__': reload(sys) sys.setdefaultencoding("utf-8") for i in xrange(child_process_num): child = Process(target=work, args=(queue,)) child.start() child_process.append(child) signal.signal(signal.SIGINT, kill_child_processes) signal.signal(signal.SIGTERM, kill_child_processes) #hook the SIGTERM signal.signal(signal.SIGCHLD, restart_child_process) signal.signal(signal.SIGPIPE, signal.SIG_DFL) When this program runs, there will be errors as below: Error in atexit._run_exitfuncs: Error in sys.exitfunc: Traceback (most recent call last): File "/usr/local/python/lib/python2.6/atexit.py", line 30, in _run_exitfuncs traceback.print_exc() File "/usr/local/python/lib/python2.6/traceback.py", line 227, in print_exc print_exception(etype, value, tb, limit, file) File "/usr/local/python/lib/python2.6/traceback.py", line 124, in print_exception _print(file, 'Traceback (most recent call last):') File "/usr/local/python/lib/python2.6/traceback.py", line 12, in _print def _print(file, str='', terminator='\n'): File "test.py", line 42, in restart_child_process new_child.start() File "/usr/local/python/lib/python2.6/multiprocessing/process.py", line 99, in start _cleanup() File "/usr/local/python/lib/python2.6/multiprocessing/process.py", line 53, in _cleanup if p._popen.poll() is not None: File "/usr/local/python/lib/python2.6/multiprocessing/forking.py", line 106, in poll pid, sts = os.waitpid(self.pid, flag) OSError: [Errno 10] No child processes If I send signal to one child:kill –SIGINT {child_pid} I will get: [root@mail1 mail]# kill -SIGINT 32545 [root@mail1 mail]# Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/usr/local/python/lib/python2.6/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "/usr/local/python/lib/python2.6/multiprocessing/util.py", line 269, in _exit_function p.join() File "/usr/local/python/lib/python2.6/multiprocessing/process.py", line 119, in join res = self._popen.wait(timeout) File "/usr/local/python/lib/python2.6/multiprocessing/forking.py", line 117, in wait return self.poll(0) File "/usr/local/python/lib/python2.6/multiprocessing/forking.py", line 106, in poll pid, sts = os.waitpid(self.pid, flag) OSError: [Errno 4] Interrupted system call Error in sys.exitfunc: Traceback (most recent call last): File "/usr/local/python/lib/python2.6/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "/usr/local/python/lib/python2.6/multiprocessing/util.py", line 269, in _exit_function p.join() File "/usr/local/python/lib/python2.6/multiprocessing/process.py", line 119, in join res = self._popen.wait(timeout) File "/usr/local/python/lib/python2.6/multiprocessing/forking.py", line 117, in wait return self.poll(0) File "/usr/local/python/lib/python2.6/multiprocessing/forking.py", line 106, in poll pid, sts = os.waitpid(self.pid, flag) OSError: [Errno 4] Interrupted system call
One python multiprocess errors
0.197375
0
0
1,864
4,030,296
2010-10-27T05:44:00.000
0
0
1
0
python,signals,alarm,pyserial
4,030,308
2
false
0
0
The problem is that your alarm will interrupt the read from the serial port, which isn't at all what you want. It sounds like you probably want to break this into two threads that do work separately.
1
1
0
so i have a motion sensor connected to an avr micro that is communicating with my python app via usb. im using pyserial to do the comm. during my script i have an infinate loop checking for data from the avr micro. before this loop i start a timer with signal.alarm() that will call a function to end a subprocess. when this alarm goes it interrupts the pyserial comm and the program exits completly. i get the error that pyserial read() is interrupted. is there any way around this issue. any help would be awesome
signal.alarm() handler causing problem with pyserial
0
0
0
732
4,031,402
2010-10-27T08:52:00.000
13
0
0
1
python,asynchronous,twisted
4,033,221
4
true
0
0
In a comment on another answer, you say "Every library is supposed to have ...". "Supposed" by whom? Having use-cases is certainly a nice way to nail down your requirements, but it's not the only way. It also doesn't make sense to talk about the use-cases for all of Twisted at once. There is no use case that justifies every single API in Twisted. There are hundreds or thousands of different use cases, each which justifies a lesser or greater subdivision of Twisted. These came and went over the years of Twisted's development, and no attempt has been made to keep a list of them. I can say that I worked on part of Twisted Names so that I would have a topic for a paper I was presenting at the time. I implemented the vt102 parser in Twisted Conch because I am obsessed with terminals and wanted a fun project involving them. And I implemented the IMAP4 support in Twisted Mail because I worked at a company developing a mail server which required tighter control over the mail store than any other IMAP4 server at the time offered. So, as you can see, different parts of Twisted were written for widely differing reasons (and I've only given examples of my own reasons, not the reasons of any other developers). The initial reason for a program being written often doesn't matter much in the long run though. Now the code is written: Twisted Names now runs the DNS for many domain names on the internet, the vt102 parser helped me get a job, and the company that drove the IMAP4 development is out of business. What really matters is what useful things you can do with the code now. As MattH points out, the resulting plethora of functionality has resulted in a library that (perhaps uniquely) addresses a wide array of interesting problems.
1
12
0
I have been playing around with the twisted framework for about a week now(more because of curiosity rather than having to use it) and its been a lot of fun doing event driven asynchronous network programming. However, there is something that I fail to understand. The twisted documentation starts off with Twisted is a framework designed to be very flexible and let you write powerful servers. My doubt is :- Why do we need such an event-driven library to write powerful servers when there are already very efficient implementations of various servers out there? Surely, there must have been more than a couple of concrete implementations which the twisted developers had in mind while writing this event-driven I\O library. What are those? Why exactly was twisted made?
Why is there a need for Twisted?
1.2
0
0
3,010
4,031,453
2010-10-27T09:00:00.000
0
0
1
0
python,class,serialization
4,031,637
2
false
0
0
Use a dict instead of a class.
1
0
0
I have instance of the my class. I want to save implementation of class with instance's pickle copy in file. After, I want to use this instance to another computer where there is no implementation of the my class. I don't want to save text of implementation manually. How can I do this?
How save implement class in python?
0
0
0
294
4,032,925
2010-10-27T12:01:00.000
5
0
1
0
python,python-3.x
4,033,509
3
true
0
0
The capitalization of the class names is irrelevant, it doesn't signify anything. Except that Python has sometimes grown organically and the standard library doesn't have the same homogenous feel as other large libraries such as the Win32 API or the Java standard library.
1
5
0
Why do collection.defaultdict and collection.OrderedDict have different capitalizations? Is there some subtle difference that I should be aware of? (P3K)
capitalization of library class names
1.2
0
0
1,596
4,033,325
2010-10-27T12:45:00.000
1
0
0
0
javascript,python,html,ruby
4,036,760
2
true
1
0
If you meant "embed" rather than "extend" and you just want people to drop a little box on a page and that's it, then an iframe should be fine. However, if you want two-way communication or mashupability — rather than "opaque blob of HTML and hope for the best" communication — then a JavaScript or REST API might be a better call. More specifics would make for an easier answer. If the functionality you need is on the level of an embedded ad or stackoverlflow flair then an iframe would work, if the functionality is more along the lines of a Google Map then an API of some sort would work better.
2
1
0
I am about to build a web application and I want to allow other developers extend it with their own applications. Should I do this with iFrames like Facebook? Is this a good practice? Are there other alternatives that let other developers extend my application (that is for the user it looks like it's from my application). To be specific: I want developers to be able to code applications that is embedded on my web application. Eg. if I have a file on my application they could provide a way for the users to interact with that file. Maybe a "preview" application that let the users preview the file. Another application might draw a mindmap tree view of all the user's files. What is the best way of doing this? iFrame + Restful API on backend for data exchange? Let them insert javascript on backend + frontend + html + css on my web application? Other alternatives?
3rd party applications inside iFrames?
1.2
0
0
321
4,033,325
2010-10-27T12:45:00.000
0
0
0
0
javascript,python,html,ruby
4,033,372
2
false
1
0
It depends on what you mean by "extend". When you use iFrames with 3rd parties, presumably vended from different domains than the host page, then you are constrained by cross-domain issues and cannot interact with the contents of those iFrames. If that's not an issue for you, then you can go ahead and try that strategy, but I can't see how merely adding iFrames without interopability is "extending" your web application.
2
1
0
I am about to build a web application and I want to allow other developers extend it with their own applications. Should I do this with iFrames like Facebook? Is this a good practice? Are there other alternatives that let other developers extend my application (that is for the user it looks like it's from my application). To be specific: I want developers to be able to code applications that is embedded on my web application. Eg. if I have a file on my application they could provide a way for the users to interact with that file. Maybe a "preview" application that let the users preview the file. Another application might draw a mindmap tree view of all the user's files. What is the best way of doing this? iFrame + Restful API on backend for data exchange? Let them insert javascript on backend + frontend + html + css on my web application? Other alternatives?
3rd party applications inside iFrames?
0
0
0
321
4,033,492
2010-10-27T13:02:00.000
1
0
0
0
php,python,django
4,039,483
1
true
1
0
You should probably bundle Django with your project - or the parts of it that are needed. Users of your product will need to have python and the necessary libs installed. That is not something that you can do via PHP. Well, you could, but that would be like Webmin. When making a product for sale or for users to install, this is always something to think about before starting. In fact, at times, this very restriction is the most important deciding factor when choosing a technology and designing the system. Why is XYZ popular in the first place?
1
0
0
A simple question: Is this possible? Is it worth the time looking into it?
PHP front-end for installing Django
1.2
0
0
208
4,033,669
2010-10-27T13:19:00.000
2
0
1
0
python
4,033,706
1
true
0
0
The file is not run in a separate thread or process, it runs synchronously with the caller.
1
2
0
does the file which is sent as an argument to execfile runs as an independent process / thread or is the code imported and then executed ? . Also i wanted to know how efficient is it compared to running threads / process .
how does execfile() work in python?
1.2
0
0
793
4,033,735
2010-10-27T13:26:00.000
1
1
0
0
php,.net,python,ruby-on-rails
4,034,000
2
false
1
0
Write in assembler if you're comfortable with that. :) Some questions you should ask yourself: Are there hosting restrictions? No point in coding ASP.net when you have a PHP-only host/server. Are there technical restrictions? E.g. if you want to use SQL Server as a back-end, going with ASP.net may make your life easier. What other requirements do you have? Does it have to run on the JVM? Do you want to compile stuff all the time or do you want an interpreted language? etc. etc. What experience do you have? If you're already familiar with Python, why switch to Ruby? My best tip is: use what's best for the job at hand according to the above questions. For me, I'd use Ruby on Rails for the project you described. Rails offers all the tools I need for a large project like that. Please let us know when and what you've decided :)
2
1
0
I am developing a social networking website in the facebook/foursquare-ish space. I have gotten such varied feedback on what platform I should develop in. Of course it will be heavily influenced by who I hire, but i was hoping for a little additional feedback from the larger community. Thanks.
What do i build my alpha platform on, PHP, Ruby, Python, .NET, etc?
0.099668
0
0
156
4,033,735
2010-10-27T13:26:00.000
7
1
0
0
php,.net,python,ruby-on-rails
4,033,788
2
false
1
0
It doesn't matter. StackOverflow was written in ASP .NET MVC and it's awesome. Twitter was written in Rails and it's super popular. Facebook was written in PHP and half a billion people use it. It's not the technology, it's the community. That's the hard part. Just pick one and go. Your best bet might actually be to find the technology that the most smart people are using while still working for the least amount of money.
2
1
0
I am developing a social networking website in the facebook/foursquare-ish space. I have gotten such varied feedback on what platform I should develop in. Of course it will be heavily influenced by who I hire, but i was hoping for a little additional feedback from the larger community. Thanks.
What do i build my alpha platform on, PHP, Ruby, Python, .NET, etc?
1
0
0
156
4,034,169
2010-10-27T14:09:00.000
0
0
0
0
python,webkit
17,223,197
10
false
1
0
If you are thinking about real desktop applications that are multi-threaded and/or use multiple system component - forget about JavaScript. That requires a very good SDK (like PyQt4), and not a basic wrapper like Appcelerator Titanium. Note that developing such applications takes a lot of time. Second option is to drop the desktop binding and make a web application with an advanced frontend UI made with one of JavaScript frameworks & friends (Ember, Angular... up to things like dhtmlx and alike widgets). Those can't use system components (like access some hardware), but they can provide nice services.
2
22
0
I have been experimenting with Appcelerator Titanum yesterday and I think it's cool when it comes to Javascript. Python features on Appcelerator Titanum are so limited (can't use some modules for example). My question is How can I use html & javascript as a GUI tool for a real python application ? I am running windows 7 and i was thinking of using webkit for that purpose but couldn't know how to work with it in python. I am planning to make a standalone executable using py2exe as I don't know if the users always have python and the appropriate modules installed.
How can I use HTML + Javascript to build a python GUI?
0
0
0
24,264
4,034,169
2010-10-27T14:09:00.000
0
0
0
0
python,webkit
4,064,133
10
false
1
0
I assume you are mobilizing a web-application for cross platform access. If so have you considered abstracting the cross platform access at the web-app presentation layer ? Appcelerator / Webkit does not provide true native look-and-feel on mobile devices but this is where a new technology can help.
2
22
0
I have been experimenting with Appcelerator Titanum yesterday and I think it's cool when it comes to Javascript. Python features on Appcelerator Titanum are so limited (can't use some modules for example). My question is How can I use html & javascript as a GUI tool for a real python application ? I am running windows 7 and i was thinking of using webkit for that purpose but couldn't know how to work with it in python. I am planning to make a standalone executable using py2exe as I don't know if the users always have python and the appropriate modules installed.
How can I use HTML + Javascript to build a python GUI?
0
0
0
24,264
4,034,251
2010-10-27T14:18:00.000
7
0
0
1
python
4,036,149
1
true
0
0
Twisted's DNS library is cross platform. Whether or not it's the "fastest" is debateable but Twisted performs very well on the whole. I'd be surprised if it couldn't saturate your I/O link. One point of note though: Twisted uses asynchronous I/O rather than multi-tasking to achieve concurrency. Async I/O is a very good mechanism for handling concurrent queries but it requires a different programming style from the typcial threaded approach. The learning curve can be steep but it's fairly short and, in my opinion, it's well worth the effort.
1
1
0
What library is the fastest to make hundreds of DNS queries in multi-tasking. I've googled round DNS libraries for python. I found that adns is said to be fastest. But it's not Windows-compatible. Are there any cross-platform compatible DNS libraries for python?
Fastest DNS library for python
1.2
0
0
769
4,035,195
2010-10-27T16:00:00.000
0
0
0
0
python,django,geolocation
4,037,302
2
false
1
0
Geocoding datasets from yahoo and google can be a good starting poing, Also take a look at geopy library in django.
1
2
0
I would like to be able to associate various models (Venues, places, landmarks) with a City/Country. But I am not sure what some good ways of implementing this would be. I'm following a simple route, I have implemented a Country and City model. Whenever a new city or country is mentioned it is automatically created. Unfortunately I have various problems: The database can easily be polluted Django has no real knowledge of what those City/Countries really are Any tips or ideas? Thanks! :)
A good way to make Django geolocation aware? - Django/Geolocation
0
0
0
1,229
4,035,298
2010-10-27T16:12:00.000
0
0
0
0
python,django-models
4,045,209
2
false
1
0
What I have done is to inherit from a base class on all my models that will be related to tasks. Task models points to that base class on the ForeignKey with unique=True, and it seems like all subclasses inherit the relationship. Thanks.
1
0
0
I want to design a Task model that can be associated to Project Models, another X model, and other Task models. The obvious choice is a foreign key, but I want any particular instance of that Task model to only be associated to only one of those model types, that is, if a Task model has a relationship with a Project model, it cannot have a relationship with another Task model, and so on. Any advice in what would be the best way to represent this? Thanks.
Advice on designing django model with "exclusive" foreign key relationships
0
0
0
141
4,037,481
2010-10-27T20:36:00.000
-3
1
1
0
python,memoization
4,037,504
11
false
0
0
The most simple way of doing this would probably be to just write a method (instead of using an attribute) that wraps around the attribute (getter method). On the first call, this methods calculates, saves and returns the value; later it just returns the saved value.
1
114
0
I'm writing a class in python and I have an attribute that will take a relatively long time to compute, so I only want to do it once. Also, it will not be needed by every instance of the class, so I don't want to do it by default in __init__. I'm new to Python, but not to programming. I can come up with a way to do this pretty easily, but I've found over and over again that the 'Pythonic' way of doing something is often much simpler than what I come up with using my experience in other languages. Is there a 'right' way to do this in Python?
Caching class attributes in Python
-0.054491
0
0
54,820
4,038,517
2010-10-27T23:21:00.000
2
0
0
0
python,tkinter
4,039,444
2
true
0
1
There is nothing specifically built-in to Tkinter to solve this. It's really a simple problem to solve though: remove the callback, set the value, add the callback. Or, set a global flag and check for that flag in the callback. There are ways to solve the problem -- subclass the widget, for example -- but that doesn't really buy you anything. Just go with the simple solution and move on to more interesting problems.
1
4
0
I have a Tkinter GUI where there is a Scale object. I have a callback assigned (by the command constructor parameter) to perform an action when the user changes the scale position. However, there is also a case where the value represented by the scale is modified externally, and so I set the scale position using Scale.set(). In this case, I want to set the scale, but not trigger the callback, since the rest of the program already knows about the change. However, I notice that the callback is indeed triggered by set(). Is it possible to do one of: Set the scale value without triggering the callback. Differentiate in the callback whether it was triggered by user interaction or by Scale.set() being called. Thanks.
Tkinter: Set a 'scale' value without triggering callback?
1.2
0
0
2,247
4,039,278
2010-10-28T02:30:00.000
4
0
0
0
python,django
4,039,366
3
false
1
0
HTTP is a stateless protocol: you can't know at the server if the user has simply closed their browser without informing you.
2
0
0
Django, Python: How do I know if users have closed their browser without click logout? Really seriously question, because I need to analyse the user activities.
Django, Python: How do I know if users have closed their browser without click logout?
0.26052
0
0
982
4,039,278
2010-10-28T02:30:00.000
0
0
0
0
python,django
4,039,425
3
false
1
0
It's not pretty, but you could fire off ajax requests with the user's session info (or some cookie, or any way of identifying the user) every x seconds with javascript and if you haven't received anything from that user in 2*x seconds, then they're likely to have left the page/site.
2
0
0
Django, Python: How do I know if users have closed their browser without click logout? Really seriously question, because I need to analyse the user activities.
Django, Python: How do I know if users have closed their browser without click logout?
0
0
0
982
4,039,354
2010-10-28T02:44:00.000
4
0
1
0
python
4,039,361
1
true
0
0
Mixed-case is less common than underscores: is_verbose, and actually, the is- prefix isn't all that common. I guess there isn't a strong convention one way or the other.
1
1
0
Is it standard practice or convention in Python to prepend boolean instance variables with is? For example: "options.isVerbose"
Are boolean instance variables prepended with "is" in Python?
1.2
0
0
248
4,040,656
2010-10-28T07:21:00.000
1
0
0
0
python,django,django-models
4,040,743
2
false
1
0
fullhistory seems to do most of what you want - what part of the requirement does it not fulfil? It might be easier to enhance fullhistory. Another option is to do it at the database level, if your database supports logging at that level.
1
2
0
I have to implement an application in django which will track all the changes in the database with the previous values,current value,action,date,time, user(who performed the changes) etc. Is there any application/module available in python or django which can perform these actions with may be after some changes. I have seen "fullhistory" app in Django but it does not fits into the requirement. Please suggest. Thanks in advance
Django: tracking all the database changes with values
0.099668
0
0
1,840
4,040,825
2010-10-28T07:51:00.000
0
0
1
0
c#,asp.net-mvc,clr,ironpython,razor
4,040,871
2
false
1
0
Not test, try use assembly.FullName instead of assembly.Location.
1
2
0
In my AppDomain there are few dynamic assembly, when I try codeDom.CompileAssemblyFromSource to Compile another new assembly, I can't figure out a way to add those dynamic assemble to ReferencedAssemblies. foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { compilerParameters.ReferencedAssemblies.Add(assembly.Location); } Failed, as dynamic assembly doesn't have Location. Thanks in advance. PS: I'm actually trying to use ASP.Net MVC 3's new Razor template engine in IronPython.
How to add reference to a dynamic assembly for compiling another dynamic assembly?
0
0
0
2,123
4,041,543
2010-10-28T09:35:00.000
0
0
0
0
python,django
4,042,630
1
true
1
0
It seems that proxy objects don't have local_fields set, which would be logical. I've just found something in the existing code (exploiting the django python serializer) that works around the lack of local_fields... I think my question is void :-/
1
0
0
[python 2.6 - django 1.1.1] Hello. I'm writing a custom serializer for my django application. All the objects that I use are proxy objects derived from django model classes and implement special members that I must serialize (hence the custom serializer). So I've begun to implement a new abstract serializer that inherits django.core.serialiazer.base.Serializer and redifines the serialize(...) method. I've also begun a python concrete serializer (child-class of my own base Serializer), needed for custom construction of the dict. Problem is, when my queryset comes into the serialize() method, each individual obj in it has an empty list ([]) for obj._meta.local_fields. As a consequence, my serialized python dicts are almost empty (apart from primary key & model), because I rely on this list. I can't seem to find where this field is inited. I don't understand, also, why _meta.local_fields is inconsistent when I use my serializer and not when I use django's serializer (i pass the same querysets of proxy objects). Thanks. EDIT: i thought maybe some __init__ code somewhere in the django packages had an effect, but I can't find anything in that direction, either.
Django : ORM objects come with nothing in _meta.local_fields
1.2
0
0
280
4,042,286
2010-10-28T11:11:00.000
0
0
0
0
python,django,django-models,django-admin
4,042,305
2
false
1
0
Django doen't follow convention over configuration philosophy. you have to explicitly create the backing model for the table and in the meta tell it about the table name...
2
0
0
Django: If I added new tables to database, how can I query them? Do I need to create the relevant models first? Or django creates it by itself? More specifically, I installed another django app, it created several database tables in database, and now I want to get some specific data from them? What are the correct approaches? Thank you very much!
Django: If I added new tables to database, how can I query them?
0
1
0
78
4,042,286
2010-10-28T11:11:00.000
1
0
0
0
python,django,django-models,django-admin
4,042,337
2
true
1
0
I suppose another django app has all model files needed to access those tables, you should just try importing those packages and use this app's models.
2
0
0
Django: If I added new tables to database, how can I query them? Do I need to create the relevant models first? Or django creates it by itself? More specifically, I installed another django app, it created several database tables in database, and now I want to get some specific data from them? What are the correct approaches? Thank you very much!
Django: If I added new tables to database, how can I query them?
1.2
1
0
78
4,042,407
2010-10-28T11:27:00.000
3
0
1
0
python,django,constants
4,042,429
7
false
1
0
Consider putting it into settings.py of your application. Of course, in order to use it in template you will need to make it available to template as any other usual variable.
1
23
0
I want to have some constants in a Django Projects. For example, let's say a constant called MIN_TIME_TEST. I would like to be able to access this constant in two places: from within my Python code, and from within any Templates. What's the best way to go about doing this? EDIT: To clarify, I know about Template Context Processors and about just putting things in settings.py or some other file and just importing. My question is, how do I combine the two approaches without violating the "Don't Repeat Yourself" rule? Based on the answers so far, here's my approach: I'd like to create a file called global_constants.py, which will have a list of constants (things like MIN_TIME_TEST = 5). I can import this file into any module to get the constants. But now, I want to create the context processor which returns all of these constants. How can I go about doing this automatically, without having to list them again in a dictionary, like in John Mee's answer?
Defining Constants in Django
0.085505
0
0
31,657
4,042,905
2010-10-28T12:28:00.000
17
0
1
0
python
4,042,951
6
false
0
0
If your script is a directory or ZIP file rather than a single python file, __main__.py will be executed when the "script" is passed as an argument to the python interpreter.
1
458
0
What is the __main__.py file for, what sort of code should I put into it, and when should I have one?
What is __main__.py?
1
0
0
221,918
4,044,994
2010-10-28T16:24:00.000
0
0
0
0
python,widget,pyqt4
67,350,685
6
false
0
1
Just initialise your main window like this self.setWindowFlags(Qt.ToolTip)
1
12
0
I'm a beginner in PyQt. I was trying to create a simple app to try some of the toolkit's many features. My question is, how can I hide the app icon from the taskbar? I don't want the user to be able to see the icon in taskbar and to minimize it using this icon. Is there any window flags that I can use to achieve this?
Hide PyQt app from taskbar
0
0
0
7,171
4,045,189
2010-10-28T16:48:00.000
2
0
0
0
user-interface,python-3.x,widget,ncurses
4,993,662
1
true
0
1
Cython supports Python 3, and I was able to make Cython accept the pyx file by changing all __new__ to __cinit__. Note that the examples still needs some porting to Python 3 at that point. I get "TypeError: expected bytes, str found" when trying to run the examples. Switching all the strings to bytes worked. Possibly it would be better if the API accepted strings under Python 3 too, but that is definitely more work.
1
2
0
I'm looking for a terminal UI library providing widgets like buttons, checkboxes and so on, that is compatible with python3. I've tried: pycdk (pyrex does not work with python3, and porting it is a mess) urwid (does not work with python3, it has a port but not working well with new curses interface). Does anyone know such a library? Thanks!
Is there a terminal widget library compatible with Python 3?
1.2
0
0
537
4,046,021
2010-10-28T18:27:00.000
2
0
1
0
python,windows,windows-7,python-3.x,python-idle
8,859,539
3
false
0
1
This IDLE bug (3 series only) was fixed 30Jan11. The fix is in 3.1.4 and 3.2.
2
0
0
I am running Python 3.1.2 with IDLE 3.1.2 on Windows 7. When I try to use the Stack Viewer, blue text and a new window briefly appear before all open IDLE windows exit (I don't have time to read the text or new window). This is the first time I have used Stack Viewer. Is this normal behavior? How can I get the Stack Viewer to stay open? Thanks for your help, Alex
(Python, IDLE, Windows) Pressing Stack Viewer exits all IDLE windows
0.132549
0
0
1,247
4,046,021
2010-10-28T18:27:00.000
0
0
1
0
python,windows,windows-7,python-3.x,python-idle
4,047,313
3
false
0
1
I don't have Windows so I can't help you with hands-on experience, but I would do the following: see what is the exact command that runs when you click on the menu item for Idle (I think you can right-click and see its properties, or at least you could on earlier versions of Windows) open a command prompt, and run the command that opens Idle open the stack viewer and then note the traceback that (should!) appear in the command prompt window report said traceback here :) BTW, in my installation (neither Windows nor Python 3.x), an attempt to open the stack viewer without a traceback produces the following message box: Title: No stack trace Message: There is no stack trace yet. (sys.last_traceback is not defined)
2
0
0
I am running Python 3.1.2 with IDLE 3.1.2 on Windows 7. When I try to use the Stack Viewer, blue text and a new window briefly appear before all open IDLE windows exit (I don't have time to read the text or new window). This is the first time I have used Stack Viewer. Is this normal behavior? How can I get the Stack Viewer to stay open? Thanks for your help, Alex
(Python, IDLE, Windows) Pressing Stack Viewer exits all IDLE windows
0
0
0
1,247
4,046,242
2010-10-28T18:54:00.000
1
0
0
0
java,javascript,python,image
4,046,258
4
false
1
0
Data urls will definitely reduce the number of requests to the server, since the browser doesn't have to ask for the pixels in a separate request. But they are not supported in all browsers. You'll have to make the tradeoff.
1
3
0
Right now I'm base 64 encoding them and using data uris. The idea was that this will somehow lower the number of requests the browser needs to make. Does this bucket hold any water? What is the best way of serving images in general? DB, from FS, S3? I am most interested in python and java based answers, but all are welcome!
What is the best way to serve small static images?
0.049958
0
1
547
4,046,351
2010-10-28T19:09:00.000
1
1
0
0
python,immutability,stackless,python-stackless
9,828,193
1
true
0
0
Stackless sends a reference to the python object over the channel, so any changes the producer makes to the object will be "seen" by the consumer. No copying going on.
1
2
0
I have a typical producer, consumer pattern. If the producer sends an object over a channel, the producer is blocked until the consumer accepts the object. After the consumer accepts the object, the producer alters the object in some way. Does the consumer see the object get altered? Or was there an implicit copy when sending the data over the channel?
In stackless python, is data sent over a channel immutable?
1.2
0
0
135
4,046,853
2010-10-28T20:20:00.000
1
0
1
0
python,automated-tests,static-analysis,enforcement
4,047,303
3
true
0
0
You can't enforce that all strings are Unicode; even with from __future__ import unicode_literals in a module, byte strings can be written as b'...', as they can in Python 3. There was an option that could be used to get the same effect as unicode_literals globally: the command-line option -U. However it was abandoned early in the 2.x series because it basically broke every script. What is your purpose for this? It is not desirable to abolish byte strings. They are not “bad” and Unicode strings are not universally “better”; they are two separate animals and you will need both of them. Byte strings will certainly be needed to talk to binary files and network services. If you want to be prepared to transition to Python 3, the best tack is to write b'...' for all the strings you really mean to be bytes, and u'...' for the strings that are inherently Unicode. The default string '...' format can be used for everything else, places where you don't care and/or whether Python 3 changes the default string type.
1
5
0
How can I automate a test to enforce that a body of Python 2.x code contains no string instances (only unicode instances)? Eg. Can I do it from within the code? Is there a static analysis tool that has this feature? Edit: I wanted this for an application in Python 2.5, but it turns out this is not really possible because: 2.5 doesn't support unicode_literals kwargs dictionary keys can't be unicode objects, only strings So I'm accepting the answer that says it's not possible, even though it's for different reasons :)
Python 2.x: how to automate enforcing unicode instead of string?
1.2
0
0
213
4,047,049
2010-10-28T20:46:00.000
0
1
0
0
python,date,automated-tests,regression-testing
4,121,205
2
false
1
0
Answering my own question: Our current plan is to test on virtual machines and change the date/time on the VMs. This is a more complete solution as it gets the database and worker threads all at once. I'll post an update with some real world experience when we come to actual do it.
1
0
0
Hey, I am helping to set up a regression testing suite for our python web application. Many of our tests are scheduling style tests where the current date is important. For example: create a recurring event that runs every week for a month starting on Feb 1. In order to test this, what I really want to do is override the current date so I can move back and forward in time to check the state of the app. For example, I may add an test-only page that lets me set the 'current' date which gets passed to the python back end and is used for date calculations. In the past when I have done this, I engineered it into the application architecture from day 1. Unfortunately, I am coming in late to this project and there is no application support for this. So here's my question, is there any way I can override the current date on a web service call? For example, can I intercept calls for the current date (monkey patching possibly?). I would rather not have to do a whole IOC thing as it would mean changing hundreds of methods. - dave
Date sensitive regression testing using python
0
0
0
317
4,047,897
2010-10-28T23:16:00.000
9
1
0
0
python,sockets,testing,gevent
4,048,286
3
false
0
0
Mocking and stubbing are great, but sometimes you need to take it up to the next level of integration. Since spawning a server, even a fakeish one, can take some time, consider a separate test suite (call them integration tests) might be in order. "Test it like you are going to use it" is my guideline, and if you mock and stub so much that your test becomes trivial it's not that useful (though almost any test is better than none). If you are concerned about handling bad SSL certs, by all means make some bad ones and write a test fixture you can feed them to. If that means spawning a server, so be it. Maybe if that bugs you enough it will lead to a refactoring that will make it testable another way.
1
20
0
I'm writing a Python client+server that uses gevent.socket for communication. Are there any good ways of testing the socket-level operation of the code (for example, verifying that SSL connections with an invalid certificate will be rejected)? Or is it simplest to just spawn a real server? Edit: I don't believe that "naive" mocking will be sufficient to test the SSL components because of the complex interactions involved. Am I wrong in that? Or is there a better way to test SSL'd stuff?
Python: unit testing socket-based code?
1
0
1
14,758
4,047,899
2010-10-28T23:16:00.000
2
0
0
0
python,mysql,file-upload,apache2,fastcgi
4,047,955
1
true
1
0
If the web server/gateway layer were truncating incoming form submissions I'd expect an error from FieldStorage, since the truncation would not just interrupt the file upload but also the whole multipart/form-data structure. Even if cgi.py tolerated this, it would be very unlikely to have truncated the multipart at just the right place to leave exactly 2**16-1 bytes of file upload. So I would suspect MySQL. LONGBLOB should be fine up to 2**32-1, but 65535 would be the maximum length of a normal BLOB. Are you sure the types are what you think? Check with SHOW CREATE TABLE x. Which database layer are you using to get the data in?
1
3
0
I'm having a problem with file uploading. I'm using FastCGI on Apache2 (unix) to run a WSGI-compliant application. File uploads, in the form of images, are begin saved in a MySQL database. However, larger images are being truncated at 65535 bytes. As far as I can tell, nothing should be limiting the size of the files and I'm not sure which one of the pieces in my solution would be causing the problem. Is it FastCGI; can it limit file upload sizes? Is it Python? The cgi.FieldStorage object gives me a file handle to the uploaded file which I then read: file.read(). Does this limit file sizes in any way? Is it MySQL? The type of the column for saving the image data is a longblob. I figured this could store a couple of GB worth of data. So a few MB shouldn't be a problem, right? Is it the flups WSGIServer? I can't find any information regarding this. My file system can definitely handle huge files, so that's not a problem. Any ideas? UPDATE: It is MySQL. I got python to output the number of bytes uploaded and it's greater than 65535. So I looked into max_allowed_packet for mysqld and set it to 128M. Overkill, but wanting to be sure for the moment. My only problem now is getting python's MySQLdb to allow the transfer of more than 65535 bytes. Does anyone know how to do this? Might post as a separate question.
Does FastCGI or Apache2 limit upload sizes?
1.2
1
0
1,279
4,048,821
2010-10-29T03:42:00.000
1
1
0
1
java,python
4,048,850
1
false
0
0
I would bet dollars for donuts that under some conditions you are not restarting the JVM between tests. The other obvious thought is that the class is not being copied to the target system as expected, or not to the correct location. Or, of course, the program is not being run from where you expect (i.e. there is another copy of the class files, perhaps in a JAR, which is actually be run). Explicitly recheck all your assumptions.
1
0
0
I'm developing a Java program through Eclipse locally, and debugging on a remote machine. Whenever I make a change to my program, I copy the corresponding class file to the bin directory on the remote machine. I run my program (a simulator) through a python script via the OS.system command. The problem is that my program sometimes does not use the updated class files after they have been moved over. The problem persists even if I log out and back into the remote machine. What's really strange is that, as a test, I deleted the bin directory entirely on the remote machine, and was still able to run my program. Can anyone explain this?
Java: updated class files not used
0.197375
0
0
88
4,048,973
2010-10-29T04:26:00.000
8
0
0
0
python,django
4,048,987
8
false
1
0
Build something. Anything. Keep it relatively simple and short, but start building it and make sure you finish building it. The project you have in mind right there might be perfect. Reading documentation and books is extremely helpful, of course, but like any programming the only way to really learn Django is to practice with it. Building something tangible is pretty much the only way to get that practice.
2
54
0
I really want to build a web application; something simple, maybe a database of Pokémon cards for instance? I've heard excellent things about Django. Where would be the best place to start?
What's the best way to start learning django?
1
0
0
77,794
4,048,973
2010-10-29T04:26:00.000
7
0
0
0
python,django
4,050,115
8
false
1
0
If you don't know Python, start your learning with that. People tend to get very frustrated when they try to learn a framework without knowing at least something about its programming language.
2
54
0
I really want to build a web application; something simple, maybe a database of Pokémon cards for instance? I've heard excellent things about Django. Where would be the best place to start?
What's the best way to start learning django?
1
0
0
77,794
4,049,825
2010-10-29T07:24:00.000
0
0
1
0
python,datetime,timedelta
63,546,916
6
false
0
0
If you have a list of timedelta objects, you could try: datetime.timedelta(seconds=sum(td.total_seconds() for td in list_of_deltas))
1
28
0
Python: How to get the sum of timedelta? Eg. I just got a lot of timedelta object, and now I want the sum. That's it!
How to get the sum of timedelta in Python?
0
0
0
33,149
4,050,257
2010-10-29T08:36:00.000
1
0
0
0
python,mysql
4,051,531
1
true
0
0
You need to put max_allowed_packet into the [client] section of my.cnf on the machine where the client runs. If you want to, you can specify a different file or group in mysqldb.connect.
1
3
0
It seems as if MySQLdb is restricting the maximum transfer size for SQL statements. I have set the max_allowed_packet to 128M for mysqld. MySQL documentation says that this needs to be done for the client as well.
How do I set max_allowed_packet or equivalent for MySQLdb in python?
1.2
1
0
1,923
4,051,010
2010-10-29T10:32:00.000
1
0
0
0
python,django
4,051,518
2
false
1
0
use signals and dispatchers in your app create files.. -litseners.py -signals.py and then implement signals for your models and forms (views not so much) use the django plugins pattern ducktyping for your classes
1
0
0
What are your best practises for making your django application easily extendable for other developers? What are your approaches for enabling other to overwrite your views forms templates models classes In a way that enables a healthy environment for extensions to work well together?
Django Apps extendability - How to make your django apps easily extendable?
0.099668
0
0
238
4,052,691
2010-10-29T14:19:00.000
1
1
0
1
java,c++,python,jython,performance
4,053,156
4
false
0
0
These are difficult to do well. In many cases the operating system will cache files so the second time they are executed they suddenly perform much better. The other problem is you're comparing interpreted languages against compiled. The interpreted languages require an interpreter loaded into memory somewhere or they can't run. To be scrupulously fair you really should consider if memory usage and load time for the interpreter should be part of the test. If you're looking for performance in an environment where you can assume the interpreter is always preloaded then you can ignore that. Many setups for web servers will be able to keep an interpreter preloaded. If you're doing ad hoc client applications on a desktop then the start up can be very slow while the interpreter is loaded.
3
0
0
I want to perform a comparison of multiple implementations of basically the same algorithm, written in Java, C++ and Python, the latter executed using Pypy, Jython and CPython on a Mac OS X 10.6.4 Macbook Pro with normal (non-SSD) HDD. It's a "decode a stream of data from a file" type of algorithm, where the relevant measurement is total execution time, and I want to prevent bias through e.g. OS an HDD caches, other programs running simultaneously, too large/small sample file etc. What do I need to pay attention to to create a fair comparison?
Performing unbiased program/script performance comparison
0.049958
0
0
183
4,052,691
2010-10-29T14:19:00.000
0
1
0
1
java,c++,python,jython,performance
4,053,208
4
true
0
0
I would recommend that you simply run each program many times (like 20 or so) and take the lowest measurement of each set. This will make it so it is highly likely that the program will use the HD cache and other things like that. If they all do that, then it isn't biased.
3
0
0
I want to perform a comparison of multiple implementations of basically the same algorithm, written in Java, C++ and Python, the latter executed using Pypy, Jython and CPython on a Mac OS X 10.6.4 Macbook Pro with normal (non-SSD) HDD. It's a "decode a stream of data from a file" type of algorithm, where the relevant measurement is total execution time, and I want to prevent bias through e.g. OS an HDD caches, other programs running simultaneously, too large/small sample file etc. What do I need to pay attention to to create a fair comparison?
Performing unbiased program/script performance comparison
1.2
0
0
183
4,052,691
2010-10-29T14:19:00.000
0
1
0
1
java,c++,python,jython,performance
4,053,230
4
false
0
0
To get totally unbiased is impossible, you can do various stuff like running minimum processes etc but IMO best way is to run scripts in random order over a long period of time over different days and get average which will be as near to unbias as possible. Because ultimately code will run in such environment in random order and you are interested in average behavior not some numbers.
3
0
0
I want to perform a comparison of multiple implementations of basically the same algorithm, written in Java, C++ and Python, the latter executed using Pypy, Jython and CPython on a Mac OS X 10.6.4 Macbook Pro with normal (non-SSD) HDD. It's a "decode a stream of data from a file" type of algorithm, where the relevant measurement is total execution time, and I want to prevent bias through e.g. OS an HDD caches, other programs running simultaneously, too large/small sample file etc. What do I need to pay attention to to create a fair comparison?
Performing unbiased program/script performance comparison
0
0
0
183