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
1,705,955
2009-11-10T06:16:00.000
3
0
0
0
python,django,packaging,pinax,external-dependencies
1,706,213
4
true
0
0
I meant to mention that the solution I had considered before asking was to put up a Pinax PyPI and make development releases on it. We could put up an instance of chishop. We are already using pip's --find-links to point at pypi.pinaxproject.com for packages we've had to release ourselves.
3
6
0
One issue that comes up during Pinax development is dealing with development versions of external apps. I am trying to come up with a solution that doesn't involve bringing in the version control systems. Reason being I'd rather not have to install all the possible version control systems on my system (or force that upon contributors) and deal the problems that might arise during environment creation. Take this situation (knowing how Pinax works will be beneficial to understanding): We are beginning development on a new version of Pinax. The previous version has a pip requirements file with explicit versions set. A bug comes in for an external app that we'd like to get resolved. To get that bug fix in Pinax the current process is to simply make a minor release of the app assuming we have control of the app. Apps we don't have control we just deal with the release cycle of the app author or force them to make releases ;-) I am not too fond of constantly making minor releases for bug fixes as in some cases I'd like to be working on new features for apps as well. Of course branching the older version is what we do and then do backports as we need. I'd love to hear some thoughts on this.
How might I handle development versions of Python packages without relying on SCM?
1.2
0
0
347
1,706,309
2009-11-10T08:05:00.000
3
0
0
0
python,django,zope,zodb,acquisition
1,707,165
6
false
1
0
ZODB is a OO-style database that doesn't need a schema definition. You can simply create (nearly) all kinds of objects, and persist them. The TTW is sometimes annoying, but you can mount the ZOPE-object-tree using webdav. Then you can edit the templates and scripts using your favorite editor. ZOPE is especially powerful for creating CMS-like systems, IMHO there it is still unmatched - you'd have to go through a lot to make it work equally well in Django. And through the TTW, actually non-developers like designers have a good chance of developing e.g. templates and CSS without need for developer interaction.
1
8
0
I am a newbie to zope and I previously worked on Django for about 2.5 years. So when I first jumped into Zope(v2) (only because my new company is using it since 7 years), I faced these questions. Please help me in understanding them. What is the "real" purpose of zodb as such? I know what it does, but tell me one great thing that zodb does and a framework like Django (which doesn't have zodb) misses. Update: Based on the answers, Zodb replaces the need for ORM. You can directly store the object inside the db(zodb itself). It is said one of the zope's killer feature is the TTW(Through the Web or Developing using ZMI) philosophy. But I(and any developer) prefers File-System based development(using Version control, using Eclipse, using any favorite tool outside Zope). Then where is this TTW actually used? This is the big one. What "EXTRA Stuff" does Zope's Acquistion gain when compared to Python/Django Inheritance. Is it really a good move to come to Zope, from Django ? Any site like djangosnippets.org for Zope(v2)?
Understanding Zope internals, from Django eyes
0.099668
0
0
3,052
1,706,644
2009-11-10T09:29:00.000
1
0
0
0
python,authentication,urllib2,digest
1,717,241
1
false
0
0
Although it's not available out of the box, urllib2 is flexible enough to add it yourself. Subclass HTTPDigestAuthHandler, hack it (retry_http_digest_auth method I think) to remember authentication information and define an http_request(self, request) method to use it for all subsequent requests (add WWW-Authenticate header).
1
1
0
I am trying to use Python to write a client that connects to a custom http server that uses digest authentication. I can connect and pull the first request without problem. Using TCPDUMP (I am on MAC OS X--I am both a MAC and a Python noob) I can see the first request is actually two http requests, as you would expect if you are familiar with RFC2617. The first results in the 401 UNAUTHORIZED. The header information sent back from the server is correctly used to generate headers for a second request with some custom Authorization header values which yields a 200 OK response and the payload. Everything is great. My HTTPDigestAuthHandler opener is working, thanks to urllib2. In the same program I attempt to request a second, different page, from the same server. I expect, per the RFC, that the TCPDUMP will show only one request this time, using almost all the same Authorization Header information (nc should increment). Instead it starts from scratch and first gets the 401 and regenerates the information needed for a 200. Is it possible with urllib2 to have subsequent requests with digest authentication recycle the known Authorization Header values and only do one request? [Re-read that a couple times until it makes sense, I am not sure how to make it any more plain] Google has yielded surprisingly little so I guess not. I looked at the code for urllib2.py and its really messy (comments like: "This isn't a fabulous effort"), so I wouldn't be shocked if this was a bug. I noticed that my Connection Header is Closed, and even if I set it to keepalive, it gets overwritten. That led me to keepalive.py but that didn't work for me either. Pycurl won't work either. I can hand code the entire interaction, but I would like to piggy back on existing libraries where possible. In summary, is it possible with urllib2 and digest authentication to get 2 pages from the same server with only 3 http requests executed (2 for first page, 1 for second). If you happen to have tried this before and already know its not possible please let me know. If you have an alternative I am all ears. Thanks in advance.
Client Digest Authentication Python with URLLIB2 will not remember Authorization Header Information
0.197375
0
1
1,902
1,706,945
2009-11-10T10:24:00.000
11
0
1
0
python
11,110,661
3
false
0
0
Try loading the readline module (import readline). That will make things work for you.
1
8
0
When I do a raw_input() and enter values, I am not able to use my arrow-keys to change stuff... is there any way for doing that? Thanx readline module helps in line editing features. How to use the readline module? Just importing the readline module works!
How to get interactive input from user and to be able to use arrowkeys while entering input?
1
0
0
21,299
1,707,065
2009-11-10T10:48:00.000
2
0
1
0
python,extended-ascii
1,707,510
5
true
0
0
I would like to say that I've found a solution in Unix systems, exporting a environment var, with this: export LC_CTYPE="es:ES.UTF-8" This way, all files are in utf-8, so I can make prints or whatever and it works fine
2
6
0
I have a problem when I'm printing (or writing to a file) the non-ASCII characters in Python. I've resolved it by overriding the str method in my own objects, and making "x.encode('utf-8')" inside it, where x is a property inside the object. But, if I receive a third-party object, and I make "str(object)", and this object has a non-ASCII character inside, it will fail. So the question is: is there any way to tell the str method that the object has an UTF-8 codification, generically? I'm working with Python 2.5.4.
How to print non-ASCII characters in Python
1.2
0
0
25,810
1,707,065
2009-11-10T10:48:00.000
3
0
1
0
python,extended-ascii
1,707,088
5
false
0
0
How about you use unicode(object) and define __unicode__ method on your classes? Then you know its unicode and you can encode it anyway you want into to a file.
2
6
0
I have a problem when I'm printing (or writing to a file) the non-ASCII characters in Python. I've resolved it by overriding the str method in my own objects, and making "x.encode('utf-8')" inside it, where x is a property inside the object. But, if I receive a third-party object, and I make "str(object)", and this object has a non-ASCII character inside, it will fail. So the question is: is there any way to tell the str method that the object has an UTF-8 codification, generically? I'm working with Python 2.5.4.
How to print non-ASCII characters in Python
0.119427
0
0
25,810
1,707,390
2009-11-10T11:46:00.000
0
0
1
0
asp.net,visual-studio,visual-studio-2008,ironpython
1,728,528
2
false
1
0
I had to uninstall IronPython and install ASP.NET future releases to solve it
1
1
0
I'm trying IronPython for asp.net, I got a simple CRUD screen to work. I've read IntelliSense doesnt work for IronPython, but is there any way to get rid of Visual Studio underlining all the lines' starting tokens with blue and a message of "expected declaration"?
IronPython asp.net IntelliSense
0
0
0
198
1,707,780
2009-11-10T12:57:00.000
3
0
0
0
python,matlab,language-interoperability
50,057,490
13
false
0
0
Like Daniel said you can run python commands directly from Matlab using the py. command. To run any of the libraries you just have to make sure Malab is running the python environment where you installed the libraries: On a Mac: Open a new terminal window; type: which python (to find out where the default version of python is installed); Restart Matlab; type: pyversion('/anaconda2/bin/python'), in the command line (obviously replace with your path). You can now run all the libraries in your default python installation. For example: py.sys.version; py.sklearn.cluster.dbscan
1
76
1
I need to call a Python function from MATLAB. how can I do this?
Call Python function from MATLAB
0.046121
0
0
132,733
1,708,103
2009-11-10T13:49:00.000
10
1
1
0
python,ironpython
1,708,382
13
false
0
1
Rewrite any small C# app in IronPython, and show them how many lines of code it took you. If that's not impressing, I don't know what is. I'm referring to one of your internal apps.
2
10
0
I need an IronPython\Python example that would show C#/VB.NET developers how awesome this language really is. I'm looking for an easy to understand code snippet or application I can use to demo Python's capabilities. Any thoughts?
How to impress developers with IronPython/Python
1
0
0
1,848
1,708,103
2009-11-10T13:49:00.000
3
1
1
0
python,ironpython
1,711,358
13
false
0
1
I have to agree Geo. Show a C# or VB app next to the same app written in IronPython. When I've done my IronPython talks, I've had a lot of success morphing C# code into Python. It makes for a very dramatic presentation. I'm also a big fan of showing off how duck typing makes your code more testable.
2
10
0
I need an IronPython\Python example that would show C#/VB.NET developers how awesome this language really is. I'm looking for an easy to understand code snippet or application I can use to demo Python's capabilities. Any thoughts?
How to impress developers with IronPython/Python
0.046121
0
0
1,848
1,708,392
2009-11-10T14:32:00.000
0
0
1
0
python,set
1,708,407
5
false
0
0
If you are using python 3.0, you can subclass collections.Set
2
4
0
I'm trying to write some Python code that includes union/intersection of sets that potentially can be very large. Much of the time, these sets will be essentially set(xrange(1<<32)) or something of the kind, but often there will be ranges of values that do not belong in the set (say, 'bit 5 cannot be clear'), or extra values thrown in. For the most part, the set contents can be expressed algorithmically. I can go in and do the dirty work to subclass set and create something, but I feel like this must be something that's been done before, and I don't want to spend days on wheel reinvention. Oh, and just to make it harder, once I've created the set, I need to be able to iterate over it in random order. Quickly. Even if the set has a billion entries. (And that billion-entry set had better not actually take up gigabytes, because I'm going to have a lot of them.) Is there code out there? Anyone have neat tricks? Am I asking for the moon?
Is there code out there to subclass set in Python for big xranges?
0
0
0
191
1,708,392
2009-11-10T14:32:00.000
1
0
1
0
python,set
1,708,575
5
false
0
0
You are trying to make a set containing all the integer values in from 0 to 4,294,967,295. A byte is 8 bits, which gets you to 255. 99.9999940628% of your values are over one byte in size. A crude minimum size for your set, even if you are able to overcome the syntactic issues, is 4 billion bytes, or 4 GB. You are never going to be able to hold an instance of that set in less than a GB of memory. Even with compression, it's likely to be a tough squeeze. You are going to have to get much more clever with your math. You may be able to take advantage of some properties of the set. After all, it's a very special set. What you are trying to do?
2
4
0
I'm trying to write some Python code that includes union/intersection of sets that potentially can be very large. Much of the time, these sets will be essentially set(xrange(1<<32)) or something of the kind, but often there will be ranges of values that do not belong in the set (say, 'bit 5 cannot be clear'), or extra values thrown in. For the most part, the set contents can be expressed algorithmically. I can go in and do the dirty work to subclass set and create something, but I feel like this must be something that's been done before, and I don't want to spend days on wheel reinvention. Oh, and just to make it harder, once I've created the set, I need to be able to iterate over it in random order. Quickly. Even if the set has a billion entries. (And that billion-entry set had better not actually take up gigabytes, because I'm going to have a lot of them.) Is there code out there? Anyone have neat tricks? Am I asking for the moon?
Is there code out there to subclass set in Python for big xranges?
0.039979
0
0
191
1,709,201
2009-11-10T16:22:00.000
0
0
0
0
python,django,django-cms
1,709,285
2
false
1
0
You may need to {% load %} the template tag library at the top of your file.
2
1
0
I am getting started with django-cms and I am facing an exception when I try to edit a page in the admin inteface. A TemplateSyntaxError exception is raised due to the {% page_submit_row %} templatetag. TemplateSyntaxError at /admin/cms/page/1/ Caught an exception while rendering: admin/page_submit_line.html Request Method: GET Request URL: http://127.0.0.1:8082/admin/cms/page/1/ Exception Type: TemplateSyntaxError Exception Value: Caught an exception while rendering: admin/page_submit_line.html Exception Location: C:\Program Files\Python26\lib\site-packages\django\template\debug.py in render_node, line 81 Does anybody know also a good tutorial of django-cms? Update: It seems that the installation of django-cms is not fully sucessful. The admin/page_submit_line.html template was missing. I've try to reinstall several time with similar result. A manual copy of the file fix the problem. How can I be sure that the install has be done properly? I guess that some other files are missing. Is it safe to copy the missing files manually?
getting started with django-cms: error on page_submit_row
0
0
0
462
1,709,201
2009-11-10T16:22:00.000
0
0
0
0
python,django,django-cms
1,709,611
2
true
1
0
It seems that the problem comes from the django-cms installer. It was with RC2 and RC3 is out now. Moreover, It is recommended to use easy_install for the installation easy_instaling RC3 fixed the problem Best
2
1
0
I am getting started with django-cms and I am facing an exception when I try to edit a page in the admin inteface. A TemplateSyntaxError exception is raised due to the {% page_submit_row %} templatetag. TemplateSyntaxError at /admin/cms/page/1/ Caught an exception while rendering: admin/page_submit_line.html Request Method: GET Request URL: http://127.0.0.1:8082/admin/cms/page/1/ Exception Type: TemplateSyntaxError Exception Value: Caught an exception while rendering: admin/page_submit_line.html Exception Location: C:\Program Files\Python26\lib\site-packages\django\template\debug.py in render_node, line 81 Does anybody know also a good tutorial of django-cms? Update: It seems that the installation of django-cms is not fully sucessful. The admin/page_submit_line.html template was missing. I've try to reinstall several time with similar result. A manual copy of the file fix the problem. How can I be sure that the install has be done properly? I guess that some other files are missing. Is it safe to copy the missing files manually?
getting started with django-cms: error on page_submit_row
1.2
0
0
462
1,709,528
2009-11-10T17:03:00.000
0
0
0
0
python,qt,pyqt,translation,button
4,627,449
4
false
0
1
If you want to have Yes/No translated into the current language, usually setting the system language should be enough. Otherwise try with Natim's suggestion. If you want custom texts: The static methods like question() etc. don't allow custom button texts. That's unfortunate, as "Yes"/"No" dialogs are considered bad style (they are not descriptive, one has to read the whole message, and its easy to misunderstand what means Yes and what means No and accidentally negating them). For custom texts, you have to use QMessageBox directly. I'd suggest to write your own static methods accepting optional button texts.
2
4
0
How can I easily translate standard buttons (Yes, No) from QMessageBox? I can't use self.tr on those arguments, so I would like to achieve it in some other simple way. Do I have to use whole translation system?
PyQt: translating standard buttons
0
0
0
5,231
1,709,528
2009-11-10T17:03:00.000
3
0
0
0
python,qt,pyqt,translation,button
1,709,930
4
false
0
1
Are you sure you have to translate them yourself? In other toolkits, standard buttons are automatically translated to the language that the user is using.
2
4
0
How can I easily translate standard buttons (Yes, No) from QMessageBox? I can't use self.tr on those arguments, so I would like to achieve it in some other simple way. Do I have to use whole translation system?
PyQt: translating standard buttons
0.148885
0
0
5,231
1,710,363
2009-11-10T19:01:00.000
16
0
1
0
python
1,710,405
29
false
0
0
Don't have variable names that are types. For example, don't name a variable "file" or "dict"
14
47
0
I've decided to learn Python 3. For those that have gone before, what did you find most useful along the way and wish you'd known about sooner?
What do you wish you'd known about when you started learning Python?
1
0
0
6,846
1,710,363
2009-11-10T19:01:00.000
13
0
1
0
python
1,710,498
29
false
0
0
Decorators. Writing your own is not something you might want to do right away, but knowing that @staticmethod and @classmethod are available from the beginning (and the difference between what they do) is a real plus.
14
47
0
I've decided to learn Python 3. For those that have gone before, what did you find most useful along the way and wish you'd known about sooner?
What do you wish you'd known about when you started learning Python?
1
0
0
6,846
1,710,363
2009-11-10T19:01:00.000
20
0
1
0
python
1,711,824
29
false
0
0
What enumerate is for. That seq = seq.append(item) and seq = seq.sort() both set seq to None. Using set to remove duplicates. Pretty much everything in the itertools and collections modules. How the * and ** prefixes for function arguments work. How default arguments to functions work internally (i.e. what f.func_defaults is). How (why, really) to design functions so that they are useful in conjunction with map and zip. The role of __dict__ in classes. What import actually does.
14
47
0
I've decided to learn Python 3. For those that have gone before, what did you find most useful along the way and wish you'd known about sooner?
What do you wish you'd known about when you started learning Python?
1
0
0
6,846
1,710,363
2009-11-10T19:01:00.000
7
0
1
0
python
1,711,839
29
false
0
0
using help() in the shell on any object, class or path you can run import code; code.interact(local=locals()) anywhere in your code and it will start a python shell at that exact point you can run python -i yourscript.py to start a shell at the end of yourscript.py
14
47
0
I've decided to learn Python 3. For those that have gone before, what did you find most useful along the way and wish you'd known about sooner?
What do you wish you'd known about when you started learning Python?
1
0
0
6,846
1,710,363
2009-11-10T19:01:00.000
0
0
1
0
python
6,389,037
29
false
0
0
Functional programming tools, like all and any
14
47
0
I've decided to learn Python 3. For those that have gone before, what did you find most useful along the way and wish you'd known about sooner?
What do you wish you'd known about when you started learning Python?
0
0
0
6,846
1,710,363
2009-11-10T19:01:00.000
2
0
1
0
python
1,742,631
29
false
0
0
Maybe a touch more advanced, but I wish I'd known that you don't use threads to take advantage of multiple cores in (C)python. You use the multiprocessing library.
14
47
0
I've decided to learn Python 3. For those that have gone before, what did you find most useful along the way and wish you'd known about sooner?
What do you wish you'd known about when you started learning Python?
0.013792
0
0
6,846
1,710,363
2009-11-10T19:01:00.000
57
0
1
0
python
1,710,411
29
true
0
0
I learned Python back before the 1.5.2 release, so the things that were key for me back then may not be the key things today. That being said, a crucial thing that took me a little bit to realize, but I now consider crucial: much functionality that other languages would make intrinsic is actually made available by the standard library and the built-ins. The language itself is small and simple, but until you're familiar with the built-ins and the "core parts" of the standard library (e.g., nowadays, sys, itertools, collections, copy, ...), you'll be reinventing the wheel over and over. So, the more time you invest in getting familiar with those parts, the smoother your progress will be. Every time you have a task you want to do, that doesn't seem to be directly supported by the language, first ask yourself: what built-ins or modules in the standard library will make the task much simpler, or even do it all for me? Sometimes there won't be any, but more often than not you'll find excellent solutions by proceeding with this mindset.
14
47
0
I've decided to learn Python 3. For those that have gone before, what did you find most useful along the way and wish you'd known about sooner?
What do you wish you'd known about when you started learning Python?
1.2
0
0
6,846
1,710,363
2009-11-10T19:01:00.000
4
0
1
0
python
1,711,463
29
false
0
0
I implemented plenty of recursive directory walks by hand before I learned about os.walk()
14
47
0
I've decided to learn Python 3. For those that have gone before, what did you find most useful along the way and wish you'd known about sooner?
What do you wish you'd known about when you started learning Python?
0.027579
0
0
6,846
1,710,363
2009-11-10T19:01:00.000
1
0
1
0
python
1,711,444
29
false
0
0
I wish I knew well a functional language. After playing a bit with Clojure, I realized that lots of Python's functional ideas are borrowed from Lisp or other functional langs
14
47
0
I've decided to learn Python 3. For those that have gone before, what did you find most useful along the way and wish you'd known about sooner?
What do you wish you'd known about when you started learning Python?
0.006896
0
0
6,846
1,710,363
2009-11-10T19:01:00.000
0
0
1
0
python
1,711,023
29
false
0
0
What I really liked: List comprehensions, closures (and high-order functions), tuples, lambda functions, painless bignumbers. What I wish I had known about sooner: The fact that using Python idioms in code (e.g. list comprehensions instead of loops over lists) was faster.
14
47
0
I've decided to learn Python 3. For those that have gone before, what did you find most useful along the way and wish you'd known about sooner?
What do you wish you'd known about when you started learning Python?
0
0
0
6,846
1,710,363
2009-11-10T19:01:00.000
4
0
1
0
python
1,710,428
29
false
0
0
Closures. Clean and concise, without having to resort to using a Strategy Pattern unlike languages such as Java
14
47
0
I've decided to learn Python 3. For those that have gone before, what did you find most useful along the way and wish you'd known about sooner?
What do you wish you'd known about when you started learning Python?
0.027579
0
0
6,846
1,710,363
2009-11-10T19:01:00.000
0
0
1
0
python
1,710,389
29
false
0
0
I really like list comprehension and all other semifunctional constructs. I wish I had known those when I was in my first Python project.
14
47
0
I've decided to learn Python 3. For those that have gone before, what did you find most useful along the way and wish you'd known about sooner?
What do you wish you'd known about when you started learning Python?
0
0
0
6,846
1,710,363
2009-11-10T19:01:00.000
33
0
1
0
python
1,710,378
29
false
0
0
I wished I didn't know Java. More functional programming. (see itertools module, list comprehension, map(), reduce() or filter())
14
47
0
I've decided to learn Python 3. For those that have gone before, what did you find most useful along the way and wish you'd known about sooner?
What do you wish you'd known about when you started learning Python?
1
0
0
6,846
1,710,363
2009-11-10T19:01:00.000
0
0
1
0
python
1,711,478
29
false
0
0
That multi-core was the future. Still love Python. It's writes a fair bit of my code for me.
14
47
0
I've decided to learn Python 3. For those that have gone before, what did you find most useful along the way and wish you'd known about sooner?
What do you wish you'd known about when you started learning Python?
0
0
0
6,846
1,711,200
2009-11-10T21:08:00.000
0
0
1
1
python,linux,debian
1,711,271
4
false
0
0
Your safest bet is to put Python 2.6 in /opt (./configure --prefix=/opt), and modify /etc/profile so that /opt/bin is searched first.
2
0
0
I am building python2.6 from source on Debian Lenny. ( ./configure make make altinstall ) I don't want it to conflict with anything existing, but I want it to be in the default search path for bash. Suggestions? (ps, I'm using a vm, so I can trash it and rebuild.)
Python 2.6 on Debian Lenny. Where should the executable go?
0
0
0
6,560
1,711,200
2009-11-10T21:08:00.000
3
0
1
1
python,linux,debian
1,711,264
4
false
0
0
I strongly recommend you do one of these two options. Build a .deb package, and then install the .deb package; the installed then go in the usual places (/usr/bin/python26 for the main interpreter). Build from source, and install from source into /usr/local/bin. I think it is a very bad idea to start putting files in the usual places, but not known or understood by the package manager. If you built it by hand and installed it by hand, it should be confined in the /usr/local tree.
2
0
0
I am building python2.6 from source on Debian Lenny. ( ./configure make make altinstall ) I don't want it to conflict with anything existing, but I want it to be in the default search path for bash. Suggestions? (ps, I'm using a vm, so I can trash it and rebuild.)
Python 2.6 on Debian Lenny. Where should the executable go?
0.148885
0
0
6,560
1,711,483
2009-11-10T21:50:00.000
7
1
1
0
python,web-hosting
1,711,705
3
false
0
0
Python is a compiled language; the compiled byte code is cached by the Python process for later use, to improve performance. PHP, by default, is interpreted. It's a tradeoff between usability and speed. If you're using a standard WSGI module, such as Apache's mod_wsgi, then you don't have to restart the server -- just touch the .wsgi file and the code will be reloaded. If you're using some weird server which doesn't support WSGI, you're sort of on your own usability-wise.
1
6
0
We currently run a small shared hosting service for a couple of hundred small PHP sites on our servers. We'd like to offer Python support too, but from our initial research at least, a server restart seems to be required after each source code change. Is this really the case? If so, we're just not going to be able to offer Python hosting support. Giving our clients the ability to upload files is easy, but we can't have them restart the (shared) server process! PHP is easy -- you upload a new version of a file, the new version is run. I've a lot of respect for the Python language and community, so find it hard to believe that it really requires such a crazy process to update a site's code. Please tell me I'm wrong! :-)
Python web hosting: Why are server restarts necessary?
1
0
0
1,525
1,712,768
2009-11-11T03:11:00.000
0
0
0
0
python,symbian,xmpp,pys60
1,716,884
1
true
1
0
It's fairly easy to add native extensions to Python and there are lots of C/C++ libraries for XMPP that would port easily. The previous pyexpat module is just bindings for native expat on Symbian, which is ported to S60 3rd Edition, so you should be able to get pyexpat working too. Of course you need some ability with native development to do that... You could try getting started and then ask for help in developer.symbian.org if you get stuck.
1
2
0
I'm interested in developing a XMPP client on the mobile S60 Symbian platform using the Python interpreter PyS60. I've done a search on Google for possible libraries, but turned up empty. I'm hoping that by asking this on SO, I can get a definite answer on whether there is actually an existing library that I just hadn't had the luck to find, or if it doesn't really exist. Failing that, I'm thinking of writing my own library. If there is any XML library within PyS60 to make this task easier (I know the normal interpreter has libraries, but they don't appear to be portable to PyS60), that would be good. The target device is a Nokia N78, Symbian 3rd Edition FP (Feature Pack) 2
What Jabber/XMPP libraries are available for PyS60 (Python for Symbian S60) interpreter?
1.2
0
0
912
1,712,883
2009-11-11T03:50:00.000
2
1
0
0
python,apache,deployment,apache2,pylons
1,712,913
1
true
1
0
mod_wsgi. It's more efficient. FastCGI can be troublesome to setup, whereas I've never known anyone to have a problem using mod_wsgi with a supported version of Python (2.5, 2.6, 3.1 included). WSGI exists for Python (by Python, &c.) and so it makes for a more "Pythonic" experience. Prior to WSGI I used to serve small Pylons apps via paste behind mod_proxy (due to massive issues with fastcgi). Anywhere is fine, any user is fine. If you're worried about security, you may wish to add another user. You could create a home folder in /www/ if you were so inclined :) Static binary files, images, etc., should be served separately if you can, but Pylons had (actually, I believe still does have) a method of serving these (this should be the 'public' folder). I would still use a separate mount as Apache is more efficient at serving these than passing them through Pylons.
1
0
0
I'm a beginner with Pylons and I've mostly developed on my localhost using the built-in web server. I think it's time to start deployment for my personal blog, I have a Debian Lenny server with apache2-mpm-prefork module and mod_wsgi - I've never really used mod_wsgi or fastcgi and I hear either of these are the way to go. My questions: Should I go with mod_wsgi or fastcgi and why? Where should I be creating my web application? Should I create an entirely new user for it? Should I store it in /home/meder/web-app ? I currently have some php websites being hosted on my server and they live in /www/ which is a directory I created. Is there any sorta gotcha with static binary files such as images, as there is with django?
Pylons deployment questions
1.2
0
0
450
1,713,398
2009-11-11T06:20:00.000
4
0
1
0
python,linux,unix
1,713,411
5
true
0
0
Then it fails. You can't import a python 2.5 library while you're running python 2.4. It won't work. Why can't you run python 2.5+?
1
0
0
Then how do I import that? I run everything in python 2.4, but one of my scripts import xml.etree.ElementTree...which is only Python 2.5
What if one of my programs runs in python 2.4, but IMPORTS something that requires python 2.5?
1.2
0
1
1,923
1,714,624
2009-11-11T11:33:00.000
6
0
0
0
java,python,serialization
1,714,644
7
false
1
0
Java binary serialization is really designed to be used with Java. To do it in Python you'd have to have all the relevant Java classes available for inspection, and create Python objects appropriately - it would be pretty hideous and fragile. You're better off using a cross-platform serialization format such as Thrift, Protocol Buffers, JSON or XML. If you can't change which serialization format is used in the Java code, I'd suggest writing new Java code which deserializes from the binary format and then reserializes to a cross-platform format.
2
13
0
Is there any library to deserialize with python which is serialized with java?
Is there any library to deserialize with python which is serialized with java
1
0
1
8,371
1,714,624
2009-11-11T11:33:00.000
0
0
0
0
java,python,serialization
1,714,862
7
false
1
0
If you are using Java classes, then I don't even know what it would mean to deserialize a Java class in a Python environment. If you are only using simple primitives (ints, floats, strings), then it probably wouldn't be too hard to build a Python library that could deserialize the Java format. But as others have said, there are better cross-platform solutions.
2
13
0
Is there any library to deserialize with python which is serialized with java?
Is there any library to deserialize with python which is serialized with java
0
0
1
8,371
1,715,098
2009-11-11T13:12:00.000
1
0
0
0
python,pyqt,pyqt4
1,715,113
2
false
0
1
You can run the algorithm in a separate thread, placing the data into a Queue when finished. The main thread (GUI) will periodically sample the queue and display the data when it arrives.
1
1
0
I have a couple of questions. I have an algorithm that will generate a couple of pictures in python that must be displayed on a form. I am using PyGt for this. My question is: where should I run my code? Right from the initializer? In that case from what I tested, the form won't show up. Should I set up a timer in the constructor that starts my algorithm half a second later? Will running the algorithm freeze my form making it impossible to see the picture itself? I don't mind that the buttons, checkboxes, etc freeze while it is computing, as long as the current picture is still visible. Should I use something like c#'s OnFormLoad()? If yes, how can I set it? Through connect()? How does threading work on python? I've heard, but I'm not too sure about it, that it was a pain to deal with. Is it? In c# it is as easy as writing 4 lines. I'd like to use it if possible, but if it is going to be hard to implement it I can live without it. Thanks
Couple of questions regarding PyQt
0.099668
0
0
155
1,716,247
2009-11-11T16:15:00.000
1
0
0
0
python,django,forms,wizard,preview
2,152,059
2
false
1
0
I do a similar thing at my first Django project. Using session-based FormWizard, I customized it so user can stop subbmiting data at any form. At that point you can use FormPreview probably to show information or just dynamically generate form and show it to user. Data stays in the session.
1
9
0
I have a large Django model (73 fields) that will will be connected to a ModelForm. I'd like to use a combination of the functionality found the Form Wizard and Form Preview contrib apps. I.e., the form fields would be split over multiple pages, and the user would have a chance to review/preview the data before the model instance is created. Are there any best-practices for this type of thing, or example code?
Django Form Wizard and Preview with ModelForm
0.099668
0
0
2,727
1,718,343
2009-11-11T21:56:00.000
6
0
0
0
python,django,upload,file-upload
1,718,362
5
true
1
0
You are probably using the development version of Django, which includes quite a lot of extra CRSF security. However it's not released yet so external products probably aren't compatible. You should use the 1.1 version of Django instead.
2
10
0
I have installed filebrowser for Django (not filebrowser3) and when I try to upload a file I recieve the following error: 403 Forbidden CSRF verification failed. Request aborted. More information is available with DEBUG=True. The same error occurs when I try to create a new folder which shows that the problem is that filebrowser cannot create files/direcories within my uploads directory. I am using the default settings and have manually created the /media/uploads directory with it's permissions set as 755. If I upload a file to the directory then file-browser admin page states: 1 Item Folder: 0 Image: 1 I cannot view the image that I have uploaded. I have the PIL and sorl.thumbnail modules installed.
"CSRF verification failed" when attempting to upload a file or create a folder with filebrowser for Django
1.2
0
0
16,007
1,718,343
2009-11-11T21:56:00.000
4
0
0
0
python,django,upload,file-upload
4,137,086
5
false
1
0
Add to you settings.py this 2 lines: ‘django.middleware.csrf.CsrfViewMiddleware’, ‘django.middleware.csrf.CsrfResponseMiddleware’,
2
10
0
I have installed filebrowser for Django (not filebrowser3) and when I try to upload a file I recieve the following error: 403 Forbidden CSRF verification failed. Request aborted. More information is available with DEBUG=True. The same error occurs when I try to create a new folder which shows that the problem is that filebrowser cannot create files/direcories within my uploads directory. I am using the default settings and have manually created the /media/uploads directory with it's permissions set as 755. If I upload a file to the directory then file-browser admin page states: 1 Item Folder: 0 Image: 1 I cannot view the image that I have uploaded. I have the PIL and sorl.thumbnail modules installed.
"CSRF verification failed" when attempting to upload a file or create a folder with filebrowser for Django
0.158649
0
0
16,007
1,718,681
2009-11-11T22:55:00.000
3
0
1
0
python,fibonacci
1,718,688
2
true
0
0
To invoke your function, you have to use parens: appendNextFib(). It looks like you simply used appendNextFib, which would show you its value, which is that function object.
1
1
0
My apologies in advance should I butcher any Python vocabulary, this is my first programming class and we are not permitted to post or share our code. I will do my best to explain the problem. I am defining my function as variable one and variable two. I then gave values to both variables. I used a for statement with a range value; created a new variable to handle the sum of the two previous Fib. values; and redefine my original variables for the program to iterate through until I reached my maximum. I am receiving an error message: <function appendNextFib at 0x01FB14B0> I cannot find an explanation for what the error message means. From either the message itself or from what I have written, does the fatal flaw jump out at anyone?
Understanding an error message while writing code for a Fibonacci program
1.2
0
0
159
1,718,784
2009-11-11T23:18:00.000
3
0
0
0
javascript,python,ajax,django
1,718,808
3
true
1
0
I think option 2 is best. It's incremental (only renders one more comment when a comment is added), and re-uses the rendering. If you don't like returning just HTML from an Ajax request, then have the response be a JSON structure which includes the HTML as just one component. Then you can also carry status (or whatever) without an extra request to get the HTML. Option 1 is wasteful: the server should render the page as it should first appear. Option 3 is also wasteful: why make two requests to add a single comment?
2
10
0
Let's say you have a view called "View Story" which is just a web page rendered on the backend via Python/Django. On that page there's a list of comments at the bottom rendered as part of the "View Story" template using Django's templating system (in a loop). This page also allows you to add a comment to the list. This is done through AJAX and the page is updated with the new comment (without sending a new full page request). Now, when adding the new comment to the end of the list I want the HTML that's generated for this new comment (something inside an <li>) to use the exact same code that was used to generate the original comments sent to the client via the original request. There's multiple ways to do this: Have the initial rendering throw the comment data into a javascript variable and once the page is rendered add the content via javascript. Then when new comments are added that same javascript can be used to render the new one. The problem: from a search engine perspective I'm not sure google would be able to index the comments if they're generated after the page has been rendered - I'm guessing not Each time a new comment is added via AJAX, have the ajax request return the actual HTML to put on the page rather than just the JSON data of the new comment. The HTML can be generated using the same template snippet that was used to render the original page. The problem with this is that it ties that AJAX request to a particular view or a way of rendering it which I don't like. Similar to #2 except that a separate request is made to retrieve the HTML for the new comment or maybe all the comments and the list is just wiped and re-rendered. Don't like that cause it's deeply inefficient and unnecessarily time-consuming. So, to summarize, I want a way to avoid duplicating Template/HTML code for a single view. And I would like some advice on what has worked for others because I'm pretty sure this is a common case irregardless of the technology on the back-end. Thanks!
Render page initially and update via AJAX using the same template HTML
1.2
0
0
2,693
1,718,784
2009-11-11T23:18:00.000
1
0
0
0
javascript,python,ajax,django
3,067,371
3
false
1
0
There is also option 4: Copy an existing element in the list and change its values. This is of course less flexible than templates. You can copy a hidden element instead to handle the case where the list is empty. You could also try option 2b: Generate the HTML on the server like option 2, but instead of directly accessing the database, pass the generation routine the JSON (or an object that can easily be converted to JSON). This involves more work, but means that you are effectively writing an API at the same time you are writing your own website. Option 1 is what any non-web application would use. Even though search engines are improving in their ability to handle AJAX, it is still strongly recommended to return all the content in HTML. I think Javascript is fast enough in all modern browsers that except for huge pages 1 would be quite reasonable except for the SEO issue. There is also option 5 - use Javascript on the server to generate the page and use the same code on the client. This is probably the most complicated approach and I wouldn't recommend it unless you really have a good reason.
2
10
0
Let's say you have a view called "View Story" which is just a web page rendered on the backend via Python/Django. On that page there's a list of comments at the bottom rendered as part of the "View Story" template using Django's templating system (in a loop). This page also allows you to add a comment to the list. This is done through AJAX and the page is updated with the new comment (without sending a new full page request). Now, when adding the new comment to the end of the list I want the HTML that's generated for this new comment (something inside an <li>) to use the exact same code that was used to generate the original comments sent to the client via the original request. There's multiple ways to do this: Have the initial rendering throw the comment data into a javascript variable and once the page is rendered add the content via javascript. Then when new comments are added that same javascript can be used to render the new one. The problem: from a search engine perspective I'm not sure google would be able to index the comments if they're generated after the page has been rendered - I'm guessing not Each time a new comment is added via AJAX, have the ajax request return the actual HTML to put on the page rather than just the JSON data of the new comment. The HTML can be generated using the same template snippet that was used to render the original page. The problem with this is that it ties that AJAX request to a particular view or a way of rendering it which I don't like. Similar to #2 except that a separate request is made to retrieve the HTML for the new comment or maybe all the comments and the list is just wiped and re-rendered. Don't like that cause it's deeply inefficient and unnecessarily time-consuming. So, to summarize, I want a way to avoid duplicating Template/HTML code for a single view. And I would like some advice on what has worked for others because I'm pretty sure this is a common case irregardless of the technology on the back-end. Thanks!
Render page initially and update via AJAX using the same template HTML
0.066568
0
0
2,693
1,719,127
2009-11-12T00:44:00.000
1
0
1
0
python,dreamweaver
1,719,141
3
false
1
0
Assuming that any functionality needs to remain intact… no.
3
0
0
I am comfortable in Adobe Dreamweaver CS3. Is there a way to convert a website written in the Python language into Dreamweaver for those who aren't familiar with writing in code?
Python website convert into Adobe Dreamweaver CS3
0.066568
0
0
458
1,719,127
2009-11-12T00:44:00.000
0
0
1
0
python,dreamweaver
1,719,178
3
false
1
0
Well, you can simply copy the HTML that Python generates to make a static copy of the website, but you'll lose any interactivity. In other words, you won't be able to use the website's administrative panel to modify anything. It will let you modify the style of the website, however.
3
0
0
I am comfortable in Adobe Dreamweaver CS3. Is there a way to convert a website written in the Python language into Dreamweaver for those who aren't familiar with writing in code?
Python website convert into Adobe Dreamweaver CS3
0
0
0
458
1,719,127
2009-11-12T00:44:00.000
1
0
1
0
python,dreamweaver
1,719,759
3
false
1
0
If you mean a tool which can convert a python site into dreamweaver, not possible yet, such intelligent machines are not yet invented, but evolution has produced you, so what you can do is see the site page by page, and make it again in dreamweaver. If you have specs and designs of python site handy that would speed up the things. offcourse you can easily copy css etc, you can use tools like firbug/chrome inspector to see how css is being used.
3
0
0
I am comfortable in Adobe Dreamweaver CS3. Is there a way to convert a website written in the Python language into Dreamweaver for those who aren't familiar with writing in code?
Python website convert into Adobe Dreamweaver CS3
0.066568
0
0
458
1,719,279
2009-11-12T01:27:00.000
4
1
0
0
python,database,testing,sqlalchemy
1,719,347
1
true
0
0
Follow the design pattern that Django uses. Create a disposable copy of the database. Use SQLite3 in-memory, for example. Create the database using the SQLAlchemy table and index definitions. This should be a fairly trivial exercise. Load the test data fixture into the database. Run your unit test case in a database with a known, defined state. Dispose of the database. If you use SQLite3 in-memory, this procedure can be reasonably fast.
1
4
0
Are there database testing tools for python (like sqlunit)? I want to test the DAL that is built using sqlalchemy
Are there database testing tools for python (like sqlunit)?
1.2
1
0
601
1,719,742
2009-11-12T03:42:00.000
2
0
1
0
python,dictionary,grouping
1,719,762
4
false
0
0
First off, the data, needn't be be replicated. You can well have 3 dictionaries each using a different key, but having the same reference as its value. Doing so you only need to change the value object once and this will be reflected in all dictionaries (or more precisely since the the dictionaries only store a reference, they'll be up to date). Next you need to ensure "referencial integrity" i.e. if a particular record is deleted, corresponding dictionary entry needs to be be deleted in all 3 dictionaries, and, if the record gets modified, the dictionaries with a key that is now changed also need to be have the record removed and re-added under the new key. This can be done with a class that holds all 3 dictionaries and has Add(), Remove() and (if applicable) Update() methods.
1
3
0
I am trying to create a small server type application and have a question regarding organizing data with dicts. Right now I am grouping the data using the connection socket (mainly to verify where it's coming from and for sending data back out). Something like this: connected[socket] = account_data. Basically, each connected person will have account data. Since certain fields will be used a lot for comparing and checking information, such as an account ID, I want to speed things up with another dict. For example: to find an accountID with the above method, I would have to use a for loop to go through all available connections in connected, look at the accountID in account_data for each, and then compare it. This seems to be a slow way to do it. If I could create a dict and use the accountID as the key, I think it could speed things up a little. The problem is, I plan on using 3 different dicts all ordered differently. Some data may change frequently and it seems more of a hassle to update every single dict once information changes; is there anyway to link them together? Maybe an easier way of trying to explain what I am asking is: You have Dict A, Dict B, Dict C, and Data. Dict A, B, and C all contain the same Data. I want it so if something changes in Data, the Data in Dict A, B, and C all change. I can of course always do dict A = data, dict B = data, etc but would get repetitive in the code after awhile. I know the data is set once the dict is created so I'm not really sure if there is a solution to this. I am just looking for advice on the best way to organize data in this situation.
Python organizing data with multiple dictionaries
0.099668
0
0
1,572
1,719,898
2009-11-12T04:33:00.000
2
0
0
0
python,command-line,windows-vista,pylint,errorlevel
1,720,007
3
true
0
0
I just tried this on XP: t.bat: exit Running this closes the window! Maybe the command line for pylint uses a batch file which contains an exit?
1
0
0
Pylint is doing something odd on my Windows box - something that shouldn't be possible. This isn't a question about fixing pylint, so much as fixing my understanding. I have a typical install of the latest version of pylint, Python 2.6 and Windows Vista. If I open a Command Prompt, and run pylint from the command line, it executes successfully, then when it gets to the end of the program, it doesn't merely exit to the command line again, but closes the entire Command Prompt window. I had a brief look at the code online (which I assume is the code that is actually being run) and they are calling sys.exit() with various error levels, but my reading and testing suggests that should still just return to the command line with the appropriate error-level set. Pylint is also run as part of my project's testing regime, and it works there, suggesting to me that if it is called as a Python method rather from the command-line, it doesn't have the same problem (probably no call to sys.exit() in this code path.) By what mechanism could pylint close the "shell" that contained it? If this a bug in Pylint? I don't see how. A bug in Python? A bug in Windows?
How does pylint quit the Windows command box it is running in?
1.2
0
0
635
1,720,816
2009-11-12T08:47:00.000
2
0
0
1
python,twisted
44,355,634
5
false
0
0
The fdesc module might be useful for asynchronously talking to a socket or pipe, but when given an fd that refers to an ordinary filesystem file, it does blocking io (and via a rather odd interface at that). For disk io, fdesc is effectively snake oil; don't use it. As of May 2017, the only reasonable way to get async disk io in twisted is by wrapping synchronous io calls in a deferToThread.
2
27
0
I'm trying to figure out if there is a defacto pattern for file access using twisted. Lots of examples I've looked at (twisted.python.log, twisted.persisted.dirdbm, twisted.web.static) actually don't seem to worry about blocking for file access. It seems like there should be some obvious interface, probably inheriting from abstract.FileDescriptor, that all file access should be going through it as a producer/consumer. Have I missed something or is it just that the primary use for twisted in asynchronous programming is for networking and it hasn't really been worked out for other file descriptor operations, not worrying about the purity of non-blocking IO ?
Non-blocking file access with Twisted
0.07983
0
0
8,205
1,720,816
2009-11-12T08:47:00.000
-8
0
0
1
python,twisted
1,720,836
5
false
0
0
I'm not sure what you want to achieve. When you do logging, then Python will make sure (by the global interpreter log) that log messages from several threads go into the file one after the other. If you're concerned about blocking IO, then the OS adds default buffers for your files (usually 4KB), and you can pass a buffer size in the open() call. If you're concerned about something else, then please clarify your question.
2
27
0
I'm trying to figure out if there is a defacto pattern for file access using twisted. Lots of examples I've looked at (twisted.python.log, twisted.persisted.dirdbm, twisted.web.static) actually don't seem to worry about blocking for file access. It seems like there should be some obvious interface, probably inheriting from abstract.FileDescriptor, that all file access should be going through it as a producer/consumer. Have I missed something or is it just that the primary use for twisted in asynchronous programming is for networking and it hasn't really been worked out for other file descriptor operations, not worrying about the purity of non-blocking IO ?
Non-blocking file access with Twisted
-1
0
0
8,205
1,720,867
2009-11-12T09:01:00.000
2
0
0
0
python,linux,unix,installation
1,720,904
3
true
0
0
Have you installed python-mysqldb? If not install it using apt-get install python-mysqldb. And how are you importing mysql.Is it import MySQLdb? Python is case sensitive.
1
1
0
But, they were unable to be found!? How do I install both of them?
I just installed a Ubuntu Hardy server. In Python, I tried to import _mysql and MySQLdb
1.2
1
0
730
1,720,893
2009-11-12T09:07:00.000
0
0
1
0
python,dll,compilation,py2exe
1,721,713
4
false
0
0
From what I understand, it is possible to statically link python into an executable, but then you lose your ability to load other dynamic modules (.pyd files) like os and zlib and math. Unless you are able to statically compile those as well into your main program. And as far as I know, the only compiler that can do this is the C compiler that is compiling python from source. :) I'm not sure its worth the effort at all. Better just use p2exe and create a directory of files that can be zipped and shipped.
2
0
0
It's my understanding that py2exe can only dynamically link a python2x.dll file. Are there any Python "compilers" out there that can package it all into one standalone .exe file for easier portability? If so or if not, which is the best compiler z0mg!
Any python "compiler" that can statically link the python2x.dll dependency?
0
0
0
875
1,720,893
2009-11-12T09:07:00.000
0
0
1
0
python,dll,compilation,py2exe
1,720,966
4
false
0
0
py2exe can package it all in single executable, without needing any python installation on target system, it may include python2x.dll with it, but for the end user how does it matter
2
0
0
It's my understanding that py2exe can only dynamically link a python2x.dll file. Are there any Python "compilers" out there that can package it all into one standalone .exe file for easier portability? If so or if not, which is the best compiler z0mg!
Any python "compiler" that can statically link the python2x.dll dependency?
0
0
0
875
1,721,037
2009-11-12T09:35:00.000
1
0
0
0
python,django,django-admin
51,260,433
12
false
1
0
I'm using Django 2.x and I think I found best solution, at least for my case. The HTML file to the "Save and Add Another" button is on your_python_installation\Lib\site-packages\django\contrib\admin\templates\admin\subtmit_line.html. Copy that html file and paste to your project like so your_project\templates\admin\submit_line.html. Open it and comment/delete the button code as desired: {#{% if show_save_and_add_another %}<input type="submit" value="{% trans 'Save and add another' %}" name="_addanother" />{% endif %}#} I know this problem is already answered. But maybe someone in the future have a similar case with me.
1
35
0
Whenever I'm editing object A with a foreign key to object B, a plus option "add another" is available next to the choices of object B. How do I remove that option? I configured a user without rights to add object B. The plus sign is still available, but when I click on it, it says "Permission denied". It's ugly. I'm using Django 1.0.2
Remove "add another" in Django admin screen
0.016665
0
0
24,607
1,721,699
2009-11-12T11:55:00.000
6
1
0
1
python,console,twisted
1,721,715
2
false
0
0
Take a look at twisted.manhole
1
5
0
I am developing a twisted server. I need to control the memory usage. It is not a good idea to modify code, insert some memory logging command and restart the server. I think it is better to use a "remote console", so that I can type heapy command and see the response from the server directly. All I need is a remote console, I can build one by myself, but I don't like to rebuild a wheel. My question is: is there already any remote console for twisted? Thanks.
Is there any "remote console" for twisted server?
1
0
0
1,027
1,721,761
2009-11-12T12:09:00.000
1
0
1
0
asp.net,vb.net,ironpython
1,747,832
2
true
1
0
The code between <script /> tags is compiled dynamically when the page is first run. This enables you to mix languages. However, the classes in your code-behind files are statically compiled into an assembly by VS.NET ... and a VS.NET project can only support one language at a time. One solution is to put your VB.NET code-behinds in a separate assembly. For example: Add a new VB Class Library project to your existing solution Add a reference to System.Web Create your VB.NET code-behinds. They should be normal classes inheriting from System.Web.UI.Page. In your ASP.NET website project, add a reference to the new project Edit the @ Page directives in your *.aspx files to inherit the classes in the new project e.g. <%@ Page Inherits="YourNewVBClassLibraryProject.MyVBCodeBehinds" ... /> where the Inherits attribute contains the relevant namespace-qualified class name
1
0
0
I tried to bring a previously done webform made in vb.net to an IronPython asp.net website with no luck. After seeing it didnt work, I tried to write the simplest codebehind vb.net webform to see if there was a problem with vb.net in an IronPython website and I got the following usual error "be sure that the defined class in this file matchs with the one in the attribute inherits and that it extends the right base page (page or control)" (sorry if the translation isnt the most accurate I get that message in spanish) but if I create a vb.net webform in the same website, with the sourcecode in the same file (with the vb.net code between script runat="server" tags in the same page) I get no problem. Do I have to configure something for both kind of sourcecode languages to run in such way in the same IronPython website, like configuring something in the webconfig file or is there some compatibility issue for doing that which can't be resolved?
VB webform in IronPython asp.net website
1.2
0
0
312
1,722,901
2009-11-12T15:12:00.000
1
0
1
1
python,pythonpath,sys.path
1,722,943
2
false
0
0
You can get the current directory with os.getcwd().
1
1
0
I had always assumed that the first entry in sys.path by default was the current working directory. But as it turns out, on my system the first entry is the path on which the script resides. So if I'm executing a script that's in /usr/bin from /some/directory, the first entry in sys.path is /usr/bin. Is something misconfigured on my system, or is this the expected behavior?
Is the first entry in sys.path supposed to represent the current working directory?
0.099668
0
0
550
1,722,993
2009-11-12T15:22:00.000
1
0
0
1
python,udp,communication,daemon,ports
1,723,643
2
false
0
0
I'm pretty sure this is possible on Linux; I don't know about other UNIXes. There are two ways to propagate a file descriptor from one process to another: When a process fork()s, the child inherits all the file descriptors of the parent. A process can send a file descriptor to another process over a "UNIX Domain Socket". See sendmsg() and recvmsg(). In Python, the _multiprocessing extension module will do this for you; see _multiprocessing.sendfd() and _multiprocessing.recvfd(). I haven't experimented with multiple processes listening on UDP sockets. But for TCP, on Linux, if multiple processes all listen on a single TCP socket, one of them will be randomly chosen when a connection comes in. So I suspect Linux does something sensible when multiple processes are all listening on the same UDP socket. Try it and let us know!
2
0
0
I currently have a small Python script that I'm using to spawn multiple executables, (voice chat servers), and in the next version of the software, the servers have the ability to receive heartbeat signals on the UDP port. (There will be possibly thousands of servers on one machine, ranging from ports 7878 and up) My problem is that these servers might (read: will) be running on the same machine as my Python script and I had planned on opening a UDP port, and just sending the heartbeat, waiting for the reply, and voila...I could restart servers when/if they weren't responding by killing the task and re-loading the server. Problem is that I cannot open a UDP port that the server is already using. Is there a way around this? The project lead is implementing the heartbeat still, so I'm sure any suggestions in how the heartbeat system could be implemented would be welcome also. -- This is a pretty generic script though that might apply to other programs so my main focus is still communicating on that UDP port.
Multiple programs using the same UDP port? Possible?
0.099668
0
1
5,210
1,722,993
2009-11-12T15:22:00.000
2
0
0
1
python,udp,communication,daemon,ports
1,723,017
2
true
0
0
This isn't possible. What you'll have to do is have one UDP master program that handles all UDP communication over the one port, and communicates with your servers in another way (UDP on different ports, named pipes, ...)
2
0
0
I currently have a small Python script that I'm using to spawn multiple executables, (voice chat servers), and in the next version of the software, the servers have the ability to receive heartbeat signals on the UDP port. (There will be possibly thousands of servers on one machine, ranging from ports 7878 and up) My problem is that these servers might (read: will) be running on the same machine as my Python script and I had planned on opening a UDP port, and just sending the heartbeat, waiting for the reply, and voila...I could restart servers when/if they weren't responding by killing the task and re-loading the server. Problem is that I cannot open a UDP port that the server is already using. Is there a way around this? The project lead is implementing the heartbeat still, so I'm sure any suggestions in how the heartbeat system could be implemented would be welcome also. -- This is a pretty generic script though that might apply to other programs so my main focus is still communicating on that UDP port.
Multiple programs using the same UDP port? Possible?
1.2
0
1
5,210
1,725,758
2009-11-12T22:07:00.000
0
0
1
0
python
1,725,784
3
false
0
0
Clearly, you must sleep according to real, elapsed time. The alternative (sleeping according to some other clock that "somehow" started and stopped) would be unmanageable. How would your application (which is sleeping) be notified of all this starting and stopping activity? Right, it would have to be woken up to be told that it was not supposed to run because the system was hibernating. Or, perhaps, some super-sophisticated OS-level scheduler could be used to determine if some time the system was "busy" vs. "hibernating" counted against the schedules of various sleeping processes. All too complex. Indeed, if you check carefully, sleep is pretty approximate and any Unix Signal will interrupt it. So it's possible to wake early for lots of reasons. Control-C being the big example.
1
2
0
For example, if I do time.sleep(100) and immediately hibernate my computer for 99 seconds, will the next statement be executed in 1 second or 100 seconds after waking up? If the answer is 1 second, how do you "sleep" 100 seconds, regardless of the length of hibernate/standby?
time.sleep and suspend (ie. standby and hibernate)
0
0
0
2,094
1,727,564
2009-11-13T06:46:00.000
0
0
0
0
python,django,profile,django-forms
1,876,244
7
false
1
0
Why not have two model forms on the back-end and just present them as a single form in your template? Drop the name fields from your UserProfileForm and create a second model form for the user object?
2
25
0
If think my question is pretty obvious and almost every developer working with UserProfile should be able to answer it. However, I could not find any help on the django documentation or in the Django Book. When you want to do a UserProfile form in with Django Forms, you'd like to modify the profile fields as well as some User field. But there is no forms.UserProfileForm (yet?)! How do you do that?
How to create a UserProfile form in Django with first_name, last_name modifications?
0
0
0
25,783
1,727,564
2009-11-13T06:46:00.000
0
0
0
0
python,django,profile,django-forms
1,727,895
7
false
1
0
I take it normal that you don't find any information in the docs as you merge two models into a single form. Alternatively and maybe very obviously you can: Create two modelforms, one for the user and the other for the userprofile. Set the userprofile modelform to display only firstname and lastname. Put both forms in the same template within a single <form> tag. When it is submitted, call the save methods of each form.
2
25
0
If think my question is pretty obvious and almost every developer working with UserProfile should be able to answer it. However, I could not find any help on the django documentation or in the Django Book. When you want to do a UserProfile form in with Django Forms, you'd like to modify the profile fields as well as some User field. But there is no forms.UserProfileForm (yet?)! How do you do that?
How to create a UserProfile form in Django with first_name, last_name modifications?
0
0
0
25,783
1,727,594
2009-11-13T06:56:00.000
0
1
0
0
c++,python,embedded,playstation
1,727,732
4
false
0
1
Consider storing your data as BLOBs in a SQLite DB. SQLite is extremely portable and lighweight, ANSI C, has both C++ and Python interfaces. This will take care of large files, no fragmentation, variable-length records with fast access, and so on. The rest is just serialization of structs to these BLOBs.
3
3
0
I need to load large models and other structured binary data on an older CD-based game console as efficiently as possible. What's the best way to do it? The data will be exported from a Python application. This is a pretty elaborate hobby project. Requierements: no reliance on fully standard compliant STL - i might use uSTL though. as little overhead as possible. Aim for a solution so good. that it could be used on the original Playstation, and yet as modern and elegant as possible. no backward/forward compatibility necessary. no copying of large chunks around - preferably files get loaded into RAM in background, and all large chunks accessed directly from there later. should not rely on the target having the same endianness and alignment, i.e. a C plugin in Python which dumps its structs to disc would not be a very good idea. should allow to move the loaded data around, as with individual files 1/3 the RAM size, fragmentation might be an issue. No MMU to abuse. robustness is a great bonus, as my attention span is very short, i.e. i'd change saving part of the code and forget the loading one or vice versa, so at least a dumb safeguard would be nice. exchangeability between loaded data and runtime-generated data without runtime overhead and without severe memory management issues would be a nice bonus. I kind of have a semi-plan of parsing in Python trivial, limited-syntax C headers which would use structs with offsets instead of pointers, and convenience wrapper structs/classes in the main app with getters which would convert offsets to properly typed pointers/references, but i'd like to hear your suggestions. Clarification: the request is primarily about data loading framework and memory management issues.
Optimal datafile format loading on a game console
0
0
0
270
1,727,594
2009-11-13T06:56:00.000
3
1
0
0
c++,python,embedded,playstation
1,728,074
4
false
0
1
I note that nowhere in your description do you ask for "ease of programming". :-) Thus, here's what comes to mind for me as a way of creating this: The data should be in the same on-disk format as it would be in the target's memory, such that it can simply pull blobs from disk into memory with no reformatting it. Depending on how much freedom you want in putting things into memory, the "blobs" could be the whole file, or could be smaller bits within it; I don't understand your data well enough to suggest how to subdivide it but presumably you can. Because we can't rely on the same endianness and alignment on the host, you'll need to be somewhat clever about translating things when writing the files on the host-side, but at least this way you only need the cleverness on one side of the transfer rather than on both. In order to provide a bit of assurance that the target-side and host-side code matches, you should write this in a form where you provide a single data description and have some generation code that will generate both the target-side C code and the host-side Python code from it. You could even have your generator generate a small random "version" number in the process, and have the host-side code write this into the file header and the target-side check it, and give you an error if they don't match. (The point of using a random value is that the only information bit you care about is whether they match, and you don't want to have to increment it manually.)
3
3
0
I need to load large models and other structured binary data on an older CD-based game console as efficiently as possible. What's the best way to do it? The data will be exported from a Python application. This is a pretty elaborate hobby project. Requierements: no reliance on fully standard compliant STL - i might use uSTL though. as little overhead as possible. Aim for a solution so good. that it could be used on the original Playstation, and yet as modern and elegant as possible. no backward/forward compatibility necessary. no copying of large chunks around - preferably files get loaded into RAM in background, and all large chunks accessed directly from there later. should not rely on the target having the same endianness and alignment, i.e. a C plugin in Python which dumps its structs to disc would not be a very good idea. should allow to move the loaded data around, as with individual files 1/3 the RAM size, fragmentation might be an issue. No MMU to abuse. robustness is a great bonus, as my attention span is very short, i.e. i'd change saving part of the code and forget the loading one or vice versa, so at least a dumb safeguard would be nice. exchangeability between loaded data and runtime-generated data without runtime overhead and without severe memory management issues would be a nice bonus. I kind of have a semi-plan of parsing in Python trivial, limited-syntax C headers which would use structs with offsets instead of pointers, and convenience wrapper structs/classes in the main app with getters which would convert offsets to properly typed pointers/references, but i'd like to hear your suggestions. Clarification: the request is primarily about data loading framework and memory management issues.
Optimal datafile format loading on a game console
0.148885
0
0
270
1,727,594
2009-11-13T06:56:00.000
4
1
0
0
c++,python,embedded,playstation
1,728,071
4
false
0
1
On platforms like the Nintendo GameCube and DS, 3D models are usually stored in a very simple custom format: A brief header, containing a magic number identifying the file, the number of vertices, normals, etc., and optionally a checksum of the data following the header (Adler-32, CRC-16, etc). A possibly compressed list of 32-bit floating-point 3-tuples for each vector and normal. A possibly compressed list of edges or faces. All of the data is in the native endian format of the target platform. The compression format is often trivial (Huffman), simple (Arithmetic), or standard (gzip). All of these require very little memory or computational power. You could take formats like that as a cue: it's quite a compact representation. My suggestion is to use a format most similar to your in-memory data structures, to minimize post-processing and copying. If that means you create the format yourself, so be it. You have extreme needs, so extreme measures are needed.
3
3
0
I need to load large models and other structured binary data on an older CD-based game console as efficiently as possible. What's the best way to do it? The data will be exported from a Python application. This is a pretty elaborate hobby project. Requierements: no reliance on fully standard compliant STL - i might use uSTL though. as little overhead as possible. Aim for a solution so good. that it could be used on the original Playstation, and yet as modern and elegant as possible. no backward/forward compatibility necessary. no copying of large chunks around - preferably files get loaded into RAM in background, and all large chunks accessed directly from there later. should not rely on the target having the same endianness and alignment, i.e. a C plugin in Python which dumps its structs to disc would not be a very good idea. should allow to move the loaded data around, as with individual files 1/3 the RAM size, fragmentation might be an issue. No MMU to abuse. robustness is a great bonus, as my attention span is very short, i.e. i'd change saving part of the code and forget the loading one or vice versa, so at least a dumb safeguard would be nice. exchangeability between loaded data and runtime-generated data without runtime overhead and without severe memory management issues would be a nice bonus. I kind of have a semi-plan of parsing in Python trivial, limited-syntax C headers which would use structs with offsets instead of pointers, and convenience wrapper structs/classes in the main app with getters which would convert offsets to properly typed pointers/references, but i'd like to hear your suggestions. Clarification: the request is primarily about data loading framework and memory management issues.
Optimal datafile format loading on a game console
0.197375
0
0
270
1,727,950
2009-11-13T08:43:00.000
1
0
0
0
python,c,numpy,gesture-recognition
1,730,684
3
false
0
0
I think the answer depends on three things: how well you code in Matlab, how well you code in Python/Numpy, and your algorithm. Both Matlab and Python can be fast for number crunching if you're diligent about vectorizing everything and using library calls. If your Matlab code is already very good I would be surprised if you saw much performance benefit moving to Numpy unless there's some specific idiom you can use to your advantage. You might not even see a large benefit moving to C. I this case your effort would likely be better spent tuning your algorithm. If your Matlab code isn't so good you could 1) write better Matlab code, 2) rewrite in good Numpy code, or 3) rewrite in C.
1
2
1
i 'm just finish labs meeting with my advisor, previous code is written in matlab and it run offline mode not realtime mode, so i decide to convert to python+numpy (in offline version) but after labs meeting, my advisor raise issue about speed of realtime recognition, so i have doubt about speed of python+numpy to do this project. or better in c? my project is about using electronic glove (2x sensors) to get realtime data and do data processing, recognition process
Just Curious about Python+Numpy to Realtime Gesture Recognition
0.066568
0
0
914
1,728,266
2009-11-13T09:55:00.000
0
0
0
0
java,python,sockets
1,728,302
4
false
0
0
High-level on one side and raw binary sockets on the other won't work. Sorry, but you'll need to go low-level on the server side too. EDIT: in response to the OP's comment. I am not aware of any "high level" interface of the nature that you are talking about for Java. And frankly I don't think it makes a lot of sense. If you are going to talk bytes over Socket streams you really do need to understand the standard JDK Socket / ServerSocket APIs; e.g. timeouts, keep-alive, etc.
1
10
0
In short I'm creating a Flash based multiplayer game and I'm now starting to work on the server-side code. Well I'm the sole developer of the project so I'm seeking a high-level socket library that works well with games to speed up my development time. I was trying to use the Twisted Framework (for Python) but I'm having some personal issues with it so I'm looking for another solution. I'm open to either Java or a Python based library. The main thing is that the library is stable enough for multiplayer games and the library needs to be "high-level" (abstract) since I'm new to socket programming for games. I want to also note that I will be using the raw binary socket for my Flash game (Actionscript 3.0) since I assume it will be faster than the traditional Flash XML socket.
Seeking a High-Level Library for Socket Programming (Java or Python)
0
0
1
8,269
1,728,330
2009-11-13T10:13:00.000
0
0
0
1
python,linux,process,subprocess
1,728,361
7
false
0
0
I do not think you can do this portably in the general case. You need to get this information from the process list (e.g. through the ps command), which is obtained in a system-specific way.
1
7
0
How can i get process id of the current process's parent? In general given a process id how can I get its parent process id? e.g. os.getpid() can be used to get the proccess id, and os.getppid() for the parent, how do I get grandparent, My target is linux(ubuntu) so platform specific answers are ok.
How to get process's grandparent id
0
0
0
14,912
1,728,350
2009-11-13T10:18:00.000
1
0
0
0
python,linux,performance,postgresql,out-of-memory
1,729,623
2
false
0
0
This sounds a bit like your DB server might have some problems, especially if your database server literally crashes. I'd start by trying to figure out from logs what is the root cause of the problems. It could be something like running out of memory, but it could also happen because of faulty hardware. If you're opening all the connections at start and keep them open, max_connections isn't the culprit. The way you're handling the DB connections should be just fine and your server shouldn't do that no matter how it's configured.
1
2
0
I'm writing an application in Python with Postgresql 8.3 which runs on several machines on a local network. All machines 1) fetch huge amount of data from the database server ( lets say database gets 100 different queries from a machine with in 2 seconds time) and there are about 10 or 11 machines doing that. 2) After processing data machines have to update certain tables (about 3 or 4 update/insert queries per machine per 1.5 seconds). What I have noticed is that database goes down some times by giving server aborted process abnormally or freezes the server machine (requiring a hard reset). By the way all machines maintain a constant connection to the database at all times i.e. once a connection is made using Psycopg2 (in Python) it remains active until processing finishes (which could last hours). What's the best / optimal way for handling large number of connections in the application, should they be destroyed after each query ? Secondly should I increase max_connections ? Would greatly appreciate any advice on this matter.
Optimal / best pratice to maintain continuos connection between Python and Postgresql using Psycopg2
0.099668
1
0
1,607
1,729,791
2009-11-13T15:09:00.000
1
1
1
0
c#,.net,unit-testing,ironpython
1,731,244
10
false
0
0
I agree with the other answers that there are disadvantages, but I'm surprised that so few have talked about advantages. TDD'ing across languages is a great way to learn new languages: write the tests in a language you know well, and the implementation in the language you are learning. As you are learning, you will discover better ways of writing the code than you first did, but refactoring is easy because you have a test suite. Having to master multiple languages keeps you (and your team) sharp. You get better verification that your API is interoperable across languages.
9
10
0
Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code. Perhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests. As I see it, using IronPython and IronRuby have several advantages over C# code as a testing language: Mocking can be simpler in dynamically typed languages IronPython has less verbose type annotations that are not needed in unit tests Experimental invocation of tests without recompilation by typing commands at the interpreter What are the tradeoffs in using two different languages for tests and production code?
What are the (dis)advantages of writing unit tests in a different language to the code?
0.019997
0
0
1,494
1,729,791
2009-11-13T15:09:00.000
2
1
1
0
c#,.net,unit-testing,ironpython
1,730,103
10
false
0
0
I think that this is an excellent question and an idea worthy of consideration - particularly in an environment like Visual Studio/.NET where this is easily supported The plus side - as you suggest - is that you can choose to use a language/tool to create tests that is more suited to creating tests than perhaps the code you are using to create code and for this reason alone its worth a thought. The down side is, as suggested, that your developers - those creating the tests (and we must remember not to confuse Unit Testing with Test Driven Design) probably ought to be fluent in more than one language (I'd suggest that the ability to be so is fairly important to a good developer but I'm biased!) - and more importantly that you may have to worry about structural differences between the two (though again, if you're talking about .NET languages that should be covered for you). It gets even more interesting if you go beyond "unit" tests to tests at all levels where the specific capabilities of particular languages may give advantages in building up a test case. The ultimate question is whether the advantages outweigh the disadvantages... and that's probably somewhat case specific.
9
10
0
Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code. Perhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests. As I see it, using IronPython and IronRuby have several advantages over C# code as a testing language: Mocking can be simpler in dynamically typed languages IronPython has less verbose type annotations that are not needed in unit tests Experimental invocation of tests without recompilation by typing commands at the interpreter What are the tradeoffs in using two different languages for tests and production code?
What are the (dis)advantages of writing unit tests in a different language to the code?
0.039979
0
0
1,494
1,729,791
2009-11-13T15:09:00.000
1
1
1
0
c#,.net,unit-testing,ironpython
1,729,896
10
false
0
0
The biggest disadvantage is that you are also testing compiler dependencies in your unit tests. In a sense, this also makes them integration tests. That might make them preferable if you expect your code to be usable from multiple languages, but it's adding one level of complexity that you may not need if your code will only be used in production with the language that it's developed in. One advantage that I can see is that it further isolates that code being developed from the test itself. By separating the act of writing the test even further from the actual code under development, it forces you to really consider how the code should be written to pass the test rather than simply moving the initial development of the code into the test itself.
9
10
0
Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code. Perhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests. As I see it, using IronPython and IronRuby have several advantages over C# code as a testing language: Mocking can be simpler in dynamically typed languages IronPython has less verbose type annotations that are not needed in unit tests Experimental invocation of tests without recompilation by typing commands at the interpreter What are the tradeoffs in using two different languages for tests and production code?
What are the (dis)advantages of writing unit tests in a different language to the code?
0.019997
0
0
1,494
1,729,791
2009-11-13T15:09:00.000
1
1
1
0
c#,.net,unit-testing,ironpython
1,729,874
10
false
0
0
When building an API or library, I often deliver unit tests as a form of documentation on how best to use the API or library. Most of the time I build a C# library, I'm delivering to a client who will be writing C# code to use the library. For documentation sake, at least some of my tests will always be written in the target language.
9
10
0
Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code. Perhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests. As I see it, using IronPython and IronRuby have several advantages over C# code as a testing language: Mocking can be simpler in dynamically typed languages IronPython has less verbose type annotations that are not needed in unit tests Experimental invocation of tests without recompilation by typing commands at the interpreter What are the tradeoffs in using two different languages for tests and production code?
What are the (dis)advantages of writing unit tests in a different language to the code?
0.019997
0
0
1,494
1,729,791
2009-11-13T15:09:00.000
1
1
1
0
c#,.net,unit-testing,ironpython
1,729,838
10
false
0
0
The biggest tradeoff would be if someone was looking at using Unit Tests to figure out how a certain action may be performed, writing it in a different language would make it harder to use. Also you would have to make your C# code CLS compliant.
9
10
0
Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code. Perhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests. As I see it, using IronPython and IronRuby have several advantages over C# code as a testing language: Mocking can be simpler in dynamically typed languages IronPython has less verbose type annotations that are not needed in unit tests Experimental invocation of tests without recompilation by typing commands at the interpreter What are the tradeoffs in using two different languages for tests and production code?
What are the (dis)advantages of writing unit tests in a different language to the code?
0.019997
0
0
1,494
1,729,791
2009-11-13T15:09:00.000
0
1
1
0
c#,.net,unit-testing,ironpython
9,560,983
10
false
0
0
Experience 1 In the past year I worked on a project that had two main pieces: A Grails web application and a Java Swing application we wrote our Java unit tests using Groovy and it worked out well. Unit testing with groovy took a lot less time verbosity wise and also made it possible to fake static methods and so forth. Although there were a couple places where we ran into unexpected results due to Groovy's dynamic typing, on the whole it was a positive experience. Experience 2 Another recent project I worked on was a C# ASP.NET MVC 3 web application where I wrote all the unit tests with F#. I chose C# for the web app because I felt it worked better with MVC 3. I chose F# for unit tests because it is my favorite language. The only issues I ran into were minor annoyances with types like null vs. option. Conclusion When we have two languages targeting the same runtime (well, C# / F# and Java / Groovy on CLR and JRE respectively) where one is used for production code and one for unit tests, there isn't too much to worry about regarding compatibility at least. Then I think it's really a questions of whether you and your team feel comfortable enough in both languages (and I suppose you might be kind enough to consider future maintainers as well). Indeed, I think the times you'd be compelled to use a different language for unit testing is when the unit testing language is actually your language of comfort or choice over your production language. There are some exceptions I'd admit to this liberal attitude. If you're are designing a library to be consumed by language X then it may be a smart idea to write your unit tests in language X (some at least). But for application code, I've never found writing unit tests in the same language as your production code particularly advantageous.
9
10
0
Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code. Perhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests. As I see it, using IronPython and IronRuby have several advantages over C# code as a testing language: Mocking can be simpler in dynamically typed languages IronPython has less verbose type annotations that are not needed in unit tests Experimental invocation of tests without recompilation by typing commands at the interpreter What are the tradeoffs in using two different languages for tests and production code?
What are the (dis)advantages of writing unit tests in a different language to the code?
0
0
0
1,494
1,729,791
2009-11-13T15:09:00.000
7
1
1
0
c#,.net,unit-testing,ironpython
1,729,848
10
false
0
0
One obvious potential problem is a confusing debugging experience. I haven't personally tried to debug across languages in .NET - what happens if you step into C# code from IronPython? The other problem is that anyone wanting to develop on your code base has to know both languages.
9
10
0
Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code. Perhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests. As I see it, using IronPython and IronRuby have several advantages over C# code as a testing language: Mocking can be simpler in dynamically typed languages IronPython has less verbose type annotations that are not needed in unit tests Experimental invocation of tests without recompilation by typing commands at the interpreter What are the tradeoffs in using two different languages for tests and production code?
What are the (dis)advantages of writing unit tests in a different language to the code?
1
0
0
1,494
1,729,791
2009-11-13T15:09:00.000
11
1
1
0
c#,.net,unit-testing,ironpython
1,729,849
10
true
0
0
Disadvantages that come to my mind: Depending on the language, you need another development environment (additional dependency of the project, additional effort to setup a development machine, additional licenses, additional training ...) Refactoring is sometimes supported by the IDE - but most probably not for this other language. So you have to refactor them manually. Unit tests can also be used as programming examples. Tests show how the tested classes are intended to be used. This does not work so well if the tests are written in a different language.
9
10
0
Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code. Perhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests. As I see it, using IronPython and IronRuby have several advantages over C# code as a testing language: Mocking can be simpler in dynamically typed languages IronPython has less verbose type annotations that are not needed in unit tests Experimental invocation of tests without recompilation by typing commands at the interpreter What are the tradeoffs in using two different languages for tests and production code?
What are the (dis)advantages of writing unit tests in a different language to the code?
1.2
0
0
1,494
1,729,791
2009-11-13T15:09:00.000
2
1
1
0
c#,.net,unit-testing,ironpython
1,729,845
10
false
0
0
Main disadvantage as I see it is maintainablity. If you code in C#, your development team are competent in that language, as will new hires be. You need a multi-functional dev team. I think that it's also worth noting that you probably don't want people writing their tests in a language that is maybe not their strongest. Your test code needs to be robust. You also need to be switching between syntaxes whilst writing codes/tests - this is a bit of a nuisance.
9
10
0
Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code. Perhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests. As I see it, using IronPython and IronRuby have several advantages over C# code as a testing language: Mocking can be simpler in dynamically typed languages IronPython has less verbose type annotations that are not needed in unit tests Experimental invocation of tests without recompilation by typing commands at the interpreter What are the tradeoffs in using two different languages for tests and production code?
What are the (dis)advantages of writing unit tests in a different language to the code?
0.039979
0
0
1,494
1,731,025
2009-11-13T18:30:00.000
6
0
1
0
python
1,731,044
6
false
0
0
I'm not american, but this works with russian phone numbers... maybe it applies to american ones too? Discard all non-number characters Validate amount of the numbers left Insert several dashes in appropriate places
1
0
0
I'm reading in lots of user entered data that represent phone numbers from files. They are all slightly entered in differently: 5555555555 555-555-5555 555-555/5555 1555-555-5555 etc... How could I easily parse in all of these phone numbers in Python and produce a canonical output like: 555-555-5555?
Python code to accept many different formats of US phone numbers?
1
0
0
1,409
1,731,102
2009-11-13T18:47:00.000
0
0
1
0
python,string
1,731,133
6
false
0
0
12340 is not any data (in sense that there are much bigger data to process on the market). Even better approach would use build in sqlite module. If not use some simple format like CSV for example. This is a structure organized. If not use threads, you could process two files simultaneously.
1
4
0
I have information about 12340 cars. This info is stored sequentially in two different files: car_names.txt, which contains one line for the name of each car car_descriptions.txt, which contains the descriptions of each car. So 40 lines for each one, where the 6th line reads @CAR_NAME I would like to do in python: to add for each car in the car_descriptions.txt file the name of each car (which comes from the other file) in the 7th line (it is empty), just after @CAR_NAME I thought about: 1) read 1st file and store car names in a matrix/list 2) start to read 2nd file and each time it finds the string @CAR_NAME, just write the name on the next line But I wonder if there is a faster approach, so the program reads each time one line from each file and makes the modification. Thanks
Process two files at the same time in Python
0
0
0
9,121
1,731,986
2009-11-13T21:18:00.000
0
0
1
0
python,tkinter
1,731,994
2
false
0
0
Can you be more specific? This could be done in pygame, but you'd need to open a graphical window.
1
0
0
First thought of implementing this using threads but python doesnt have a way for killing threads. I have read the other topic on killing threads. Is there any proper platform independent way of doing this?
How to play sound till the user hits a key?
0
0
0
234
1,732,452
2009-11-13T23:03:00.000
2
0
0
0
python,django,rest
1,791,400
6
false
1
0
Regarding your comment about not liking 3rd party code - that's too bad because the pluggable apps are one of django's greatest features. Like others answered, piston will do most of the work for you.
2
10
0
I'm looking for an excuse to learn Django for a new project that has come up. Typically I like to build RESTful server-side interfaces where a URL maps to resources that spits out data in some platform independent context, such as XML or JSON. This is rather straightforward to do without the use of frameworks, but some of them such as Ruby on Rails conveniently allow you to easily spit back XML to a client based on the type of URL you pass it, based on your existing model code. My question is, does something like Django have support for this? I've googled and found some 'RESTful' 3rd party code that can go on top of Django. Not sure if I'm too keen on that. If not Django, any other Python framework that's already built with this in mind so I do not have to reinvent the wheel as I already have in languages like PHP?
Django ease of building a RESTful interface
0.066568
0
0
6,277
1,732,452
2009-11-13T23:03:00.000
1
0
0
0
python,django,rest
1,732,636
6
false
1
0
A little over a year ago, I wrote a REST web service in Django for a large Seattle company that does streaming media on the Internet. Django was excellent for the purpose. As "a paid nerd" observed, the Django URL config is wonderful: you can set up your URLs just the way you want them, and have it serve up the appropriate objects. The one thing I didn't like: the Django ORM has absolutely no support for binary BLOBs. If you want to serve up photos or something, you will need to keep them in a file system, and not in a database. Because we were using multiple servers, I had to choose between writing my own BLOB support or finding some replication framework that would keep all the servers up to date with the latest binary data. (I chose to write my own BLOB support. It wasn't very hard, so I was actually annoyed that the Django guys didn't do that work. There should be one, and preferably only one, obvious way to do something.) I really like the Django ORM. It makes the database part really easy; you don't need to know any SQL. (I don't like SQL and I do like Python, so it's a double win.) The "admin interface", which you get for free, gives you a great way to look through your data, and to poke data in during testing and development. I recommend Django without reservation.
2
10
0
I'm looking for an excuse to learn Django for a new project that has come up. Typically I like to build RESTful server-side interfaces where a URL maps to resources that spits out data in some platform independent context, such as XML or JSON. This is rather straightforward to do without the use of frameworks, but some of them such as Ruby on Rails conveniently allow you to easily spit back XML to a client based on the type of URL you pass it, based on your existing model code. My question is, does something like Django have support for this? I've googled and found some 'RESTful' 3rd party code that can go on top of Django. Not sure if I'm too keen on that. If not Django, any other Python framework that's already built with this in mind so I do not have to reinvent the wheel as I already have in languages like PHP?
Django ease of building a RESTful interface
0.033321
0
0
6,277
1,732,761
2009-11-14T00:30:00.000
2
1
1
0
python,png
1,732,962
2
true
0
1
Getting data out of a PNG requires unpacking data and decompressing it. These are likely going to be too slow in Python for your application. One possibility is to start with PyPNG and get rid of anything in it that you don't need. For example, it is probably storing all of the data it reads from the PNG, and some of the slow speed you see may be due to the memory allocations.
1
1
0
I am having an issue with an embedded 64bit Python instance not liking PIL. Before i start exhausting more methods to get a compiled image editor to read the pixels for me (such as ImageMagick) i am hoping perhaps anyone here can think of a purely Python solution that will be comparable in speeds to the compiled counterparts. Now i am aware that the compiled friends will always be much faster, but i am hoping that because i "just" want to read the alpha of a group of pixels, that perhaps a fast enough pure Python solution can be conjured up. Anyone have any bright ideas? Though, i have tried PyPNG and that is far too slow, so i'm not expecting any magic solutions. None the less, i had to ask. Thanks to any replies! And just for reference, the images i'll be reading will be on average around 512*512 to 2048*2048, and i'll be reading anywhere from one to all of the pixels alpha (multiplied by a few million times, but the values can be stored so reading twice isn't done).
Reading Alpha of a PNG Pixel. Fast way via pure Python?
1.2
0
0
955
1,732,935
2009-11-14T01:36:00.000
9
0
0
0
python,pyqt,screenshot,fullscreen
1,733,241
2
true
0
1
Passing QtCore.Qt.FramelessWindowHint to the QWidget constructor in symphony with self.showFullScreen() in the image widget's code achieves this.
1
4
0
I'm using PyQt to capture my screen with QPixmap.grabWindow(QApplication.desktop().winId()) and I was wondering if there was a way I could display my screengrab fullscreen (no window borders, etc.) I'm trying to find a way to desaturate my display with PyQt
PyQt display fullscreen image
1.2
0
0
3,562
1,732,957
2009-11-14T01:49:00.000
5
0
0
1
python,networking,udp,twisted,multiplayer
1,732,990
2
true
0
0
It's almost certainly a reasonable protocol to start with. Remember the cardinal rule of optimization: don't do it. Working with any TCP-based protocol is going to be considerably easier than working with any UDP-based protocol. This is initially much more important to the success of your project than whether it takes 30 milliseconds or 45 milliseconds to send a message between your client and server. Eventually, when you've gotten to the point where it's clear your project might actually succeed and you really need to make up those 15 (or however many) milliseconds, you can revisit the network layer and consider whether the performance bottleneck (be it latency or some other metric) is due to your choice of protocol. If so, that is the time to spend time evaluating various alternatives. It's only at that point that the effort of selecting the ideal protocol might pay off (since you're that much closer to a completed project) and by then you will have a significantly improved understanding of the problem and should have nailed down your requirements very specifically, two more things which will make the task of selecting the appropriate protocol (be it TCP- or UDP-based) that much easier and more likely to be correct.
1
2
0
Do you think that Twisted Spread may be suitable (in terms of performance) for a multiplayer racing simulator? The rest of the application is based on Python-Ogre. Can Perspective Broker run upon (reliable?) UDP?
Twisted Spread suitable for multiplayer racing sim?
1.2
0
0
708
1,733,364
2009-11-14T05:23:00.000
1
0
1
1
python,ubuntu,installation
1,733,409
4
false
0
0
Sounds like they're an accident from some package(s) you have installed. The Python version in use determines the locations searched to find installed Python packages/modules, and the "system version" of Python in Ubuntu 9.10 is 2.6, so that's what practically everything should be using. If you were to install the python2.5 package (or it gets installed as a dependency of something else), then it would use /usr/lib/python2.5/*. Try running which python and python --version; also which python2.6 and which python2.5. From what I understand, though I'm not sure exactly why at all, Debian (from which Ubuntu is derived) uses a dist-packages naming scheme instead of site-packages. Terminology: Python has packages and Debian (and so Ubuntu) has packages. They aren't the same kind of package, though individual Debian packages will install specific Python packages.
1
3
0
In ubuntu 9.10, in usr/lib/ there are the directories python2.4, python2.5, python2.6 and python3.0 Only python 2.6 is actually working. python2.4 has only a lib-dynload directory, python2.5 has only lib-dynload and site-packages, python3.0 has only a dist-packages directory. Now i'm wondering what is the idea behind this? Because when i install python2.5 with ./configure, make, make install | altinstall this goes into usr/local/lib and not usr/lib/ so why were these directories added tu ubuntu, how am i supposed to install python to use them?
ubuntu9.10 : how to use python's lib-dynload and site-packages directories?
0.049958
0
0
10,075
1,733,619
2009-11-14T07:42:00.000
24
0
1
0
python,key-value-store
1,733,720
7
false
0
0
It all depends on the level of complexity you want to dive into. Starting with a simple Python dict serialized to a file in a myriad of possible ways (of which pickle is probably the simplest), you can go as far as implementing a complete database system. Look up redis - it's a key/value store written in C and operating as a server "DB". It has some good documentation and easy to read code, so you can borrow ideas for your Python implementation. To go even farther, you can read about B-trees. For your specific questions: above some DB size, you can never keep it all in memory, so you need some robust way of loading data from disk. Also consider whether the store is single-client or multi-client. This has serious consequences for its implementation.
1
13
0
I am looking to write a Key/value store (probably in python) mostly just for experience, and because it's something I think that is a very useful product. I have a couple of questions. How, in general, are key/value pairs normally stored in memory and on disk? How would one go about loading the things stored on disk, back into memory? Do key/value stores keep all the key/value pairs in memory at once? or is it read from the disk? I tried to find some literature on the subject, but didn't get very far and was hoping someone here could help me out.
Writing a key-value store
1
0
0
6,016
1,734,373
2009-11-14T14:30:00.000
5
0
1
0
python,distribution,setuptools,distribute
1,738,049
2
true
0
0
I've change that behavior in Distutils (in Python trunk (2.7/3.2) ) Now all files mentioned in package_data will be included by default without having to write a MANIFEST.in file, and without having to use the magic behavior based on DVCS. Until then, I would recommend using an explicit MANIFEST.in and stick with plain Distutils options, so you don't rely on any VCS, and you don't add files by accidents, that are in your repository, but that you don't want to see added in your release. Distribute 0.7.x will probably stick with Distutils upcoming default behavior. Look for the MANIFEST.in template language in the Distutils doc, it's quite simple. Tarek
1
2
0
I'm trying to use Distribute for my project's setup.py. I want it to include all the files in the package folder, which are text and image files, but not .pyc files of course. I read that the files should either be tracked by CVS and SVN, or there should be a MAINFEST.in. So: I use neither CVS nor SVN, I use git. I know that it's possible to write a plugin for git, and perhaps someone has, but I'm not going to use some plugin that I don't know if it will be maintained and supported. Also, git is tracking more than the source folder, the repo includes other files which shouldn't be packed in the distribution. I thought that one of the perks of Distribute is not having to deal with a MANIFEST.in file. Do I really have to? If so, where do I see a guide? I've never written a MANIFEST.in. Is there any nicer solution?
Including package data with Distribute
1.2
0
0
415
1,734,575
2009-11-14T15:34:00.000
2
0
0
0
python,screen,buffer
1,737,577
2
false
0
1
Instead of "graying out" the desktop, try to overlay a gray, semi-transparent image over the entire screen and then make sure your window is on top of that. You may face a couple of minor limitations; for example, I don't know off the top of my head if it's possible to overlay the mac menubar (and I'm not sure you'd want to).
1
1
0
I know this is a long shot, but I was wondering if Python had a way to manipulate the screen buffer. Specifically, I want to be able to gray-out my desktop and highlight my windows when I press a key combination. Is this in the realm of possibility?
Manipulate screen buffer in python
0.197375
0
0
1,923
1,734,918
2009-11-14T17:22:00.000
1
0
0
0
python,mysql,django,macos,xampp
1,734,939
1
true
1
0
You could change the listening port of one of the installations and they shouldn't conflict anymore with each other. Update: You need to find the mysql configuration file my.cnf of the server which should get a new port (the one from xampp should be somewhere in the xampp folder). Find the line port=3306 in the [mysqld] section. You could change it to something like 3307. You will also need to specify the new port when connecting to the server from your applications.
1
0
0
i recently switched to mac. first and foremost i installed xampp. then for django-python-mysql connectivity, i "somehow" ended up installing a seperate MySQL. now the seperate mysql installation is active all the time and the Xampp one doesnt switch on unless i kill the other one. what i wanted to know is it possible to make xampp work with the seperate mysql installation? because that way i wouldnt have to tinker around with the mysqlDB adapter for python? any help would be appreciated.
2 mysql instances in MAC
1.2
1
0
150
1,735,109
2009-11-14T18:18:00.000
7
0
1
1
python,eclipse,macos
1,735,193
4
false
0
0
Running $which python should help locate your Python installation.
2
10
0
How do I direct Eclipse to the Python interpreter on my Mac? I've looked in Library which contains the directory 'Python' then '2.3' and '2.5', however they contain nothing except 'Site-packages' - Which is weird considering I can go into the terminal and type python. I then installed the latest 2.6 version with package manager and still can't find it. Can anyone help?
Setting Python Interpreter in Eclipse (Mac)
1
0
0
20,985
1,735,109
2009-11-14T18:18:00.000
7
0
1
1
python,eclipse,macos
1,735,148
4
true
0
0
An alias to the python interpreter was likely installed into /usr/local/bin. So, to invoke python2.6, type /usr/local/bin/python2.6 or, most likely, just python2.6. If you want python to invoke python2.6, try rearranging your $PATH so that /usr/local/bin precedes /usr/bin.
2
10
0
How do I direct Eclipse to the Python interpreter on my Mac? I've looked in Library which contains the directory 'Python' then '2.3' and '2.5', however they contain nothing except 'Site-packages' - Which is weird considering I can go into the terminal and type python. I then installed the latest 2.6 version with package manager and still can't find it. Can anyone help?
Setting Python Interpreter in Eclipse (Mac)
1.2
0
0
20,985
1,735,561
2009-11-14T20:52:00.000
5
0
1
0
python,code-golf,shuffle
1,735,584
11
false
0
0
After shuffling the list of numbers, let the [i]th person write a poem (and buy a present!) for the [i+1]th person in the list: that way, there can never be someone who draws him- or herself. Of course, the last one should point to the first...
1
2
0
It's that time of year again that programmers want to shuffle a list such that no element resides on its original position (at least in the Netherlands, we celebrate Sinterklaas and pick straws for deciding who writes who a poem). Does anyone have a nice Python single statement for that? So, input example: range(10) Output example: [2,8,4,1,3,7,5,9,6,0] Wrong output would be [2,8,4,1,3,5,7,9,6,0] because the 5 is at its original position. This would mean that person 5 must write a poem to himself and that is less fun. edit Many people repeat the assignment just as long as needed to get lucky and find that in fact the solution is satisfactory. This is a bad approach as in theory this can take infinitely long. The better approach is indeed suggested by Bart, but I can't get that into a oneliner for one reason or another... edit By oneliner, I mean single statement. As it appears, Python is also able to compress multiple statements on a single line. I didn't know that. There are currently very nice solutions only using the semicolon to mimic multiline behaviour on a single line. Hence: "can you do it in a single statement?"
oneliner scramble program
0.090659
0
0
936
1,736,348
2009-11-15T02:20:00.000
1
0
1
0
python,diff
1,736,587
3
false
0
0
Also, the SequenceMatcher class (from the Python standard library) can be helpful. Check out the other contents of the difflib module as well.
1
4
0
I'm trying to use bsdiff (or any binary diff implementation you come up with) to compute and apply diff onto random binary data. I would like to use it on data from a database, so it would be better not to have to write those onto disk and pass them to bsdiff.exe. Is there any wrapper library or way in python to do that?
Python binary diff
0.066568
0
0
6,993
1,736,451
2009-11-15T03:19:00.000
0
0
1
1
python,macos,ide,editor,python-idle
4,642,775
12
false
0
0
going to vote for Fraise. handles almost anything, has indentations, and uses color! its free too.
6
2
0
I'm currently using IDLE, its decent, but I'd like to know if there're better lightweight IDEs built especially for Mac — free or commercial.
Native Python Editor for Mac?
0
0
0
9,940
1,736,451
2009-11-15T03:19:00.000
0
0
1
1
python,macos,ide,editor,python-idle
1,736,831
12
false
0
0
vim, emacs, BBEdit, WingIDE, or my favorite - eclipse (although, I don't think this is very lightweight)
6
2
0
I'm currently using IDLE, its decent, but I'd like to know if there're better lightweight IDEs built especially for Mac — free or commercial.
Native Python Editor for Mac?
0
0
0
9,940