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,779,464
2009-11-22T18:10:00.000
7
0
0
0
python,django,http
1,779,475
2
true
1
0
Do you have any kind of proxy, gateway, or load balancer running on that remote host? That's the sort of thing that would cause connections to appear to be from 127.0.0.1 (because that's where the immediate connection is from, as far as the web server is concerned).
1
2
0
I have an application running with debug=True on a remote host somewhere. Now somehow every time I access REMOTE_ADDR it returns 127.0.0.1 no matter where the request is from. I'm not sure where to start and why this is happening.
Django: request.META['REMOTE_ADDR'] is always '127.0.0.1'
1.2
0
0
4,509
1,779,567
2009-11-22T18:45:00.000
5
0
0
0
python,django,django-models
1,779,579
1
true
1
0
You can use: setattr(obj, fieldname, 'new name').
1
1
0
I want to do something like this: # models.py class Model(models.Model): name_in_my_model = models.CharField(max_length=100) # later fieldname = 'name_in_my_model' # this is what I want to do somehow: obj = Model.objects.get(pk=1) obj.fieldname = 'new name' obj.save() Is this possible? I'm making a reusable ...
How do I save to a field that is specified in a variable?
1.2
0
0
161
1,779,630
2009-11-22T19:02:00.000
1
0
1
1
python,windows
1,779,645
6
false
0
0
One solution would be to craft a batch file that invokes the correct interpreter for a given application. THis way, you can install additional interpreters in separate folders. Probably not perfect but it works.
3
3
0
I'm looking for a way to let multiple Python programs coexist on the same Windows machine. Here's the problem: suppose program A needs Python 2.5, B needs 2.6, C needs 3, and each of them needs its own version of Qt, Wx or whatever other modules or whatever. Trying to install all these dependencies on the same machine ...
Python programs coexisting on Windows
0.033321
0
0
512
1,779,630
2009-11-22T19:02:00.000
0
0
1
1
python,windows
1,779,665
6
false
0
0
write a python script that mimics the way unix shells handle scirpts -- look at the first line and see if it matches #!(name-of-shell). Then have your python script exec that interpreter and feed it the rest of its arguments. Then, associate .py with your script.
3
3
0
I'm looking for a way to let multiple Python programs coexist on the same Windows machine. Here's the problem: suppose program A needs Python 2.5, B needs 2.6, C needs 3, and each of them needs its own version of Qt, Wx or whatever other modules or whatever. Trying to install all these dependencies on the same machine ...
Python programs coexisting on Windows
0
0
0
512
1,779,630
2009-11-22T19:02:00.000
2
0
1
1
python,windows
1,779,655
6
false
0
0
Use batch files to run scripts, write in notepad for example: c:\python26\python.exe C:\Script_B\B.py and save it as runB.bat (or anything .bat). It will run with interpreter in c:\python26\python.exe file specified after a whitespace.
3
3
0
I'm looking for a way to let multiple Python programs coexist on the same Windows machine. Here's the problem: suppose program A needs Python 2.5, B needs 2.6, C needs 3, and each of them needs its own version of Qt, Wx or whatever other modules or whatever. Trying to install all these dependencies on the same machine ...
Python programs coexisting on Windows
0.066568
0
0
512
1,780,266
2009-11-22T22:34:00.000
3
0
0
0
ironpython,pdb
1,781,255
1
false
1
0
Yes, IronPython 2.6 supports this. By default this switches on when sys.settrace is called so frames already on the stack above the caller won't be available. But with the -X:Tracing option it's available all the time.
1
6
0
Does anyone know if IronPython 2.6 is planned to have support for pdb.set_trace() to enable setting breakpoints in an ironpython module? If not does anyone have a suggestion for accomplishing this without pdb?
IronPython and pdb.set_trace()
0.53705
0
0
1,056
1,780,922
2009-11-23T03:09:00.000
2
1
0
0
c#,python,algorithm,powershell
1,780,938
6
false
0
0
Please take a look at the struct standard library module in Python's Manual. It has two functions for this: struct.pack and struct.unpack. You can use the 'L' (unsigned long) format character for this.
1
2
0
First, a disclaimer. I'm not a CS grad nor a math major, so simplicity is important. I have a four-character string (e.g. "isoy") that I need to pass as a single 32-bit integer field. Of course at the other end, I need to decode it back to a string. The string will only contain A-Z, and case is not important, if that ...
How do I encode a 4-byte string as a single 32-bit integer?
0.066568
0
0
3,087
1,781,431
2009-11-23T06:28:00.000
2
1
0
0
python,html,web-applications,fastcgi,template-engine
1,784,843
3
false
1
0
You asked whether HTML is allowed within Python, which indicates that you still think too much in PHP terms about it. Contrary to PHP, Python was not designed to create dynamic web-pages. Instead, it was designed as a stand-alone, general-purpose programming language. Therefore you will not be able to put HTML into Pyt...
1
1
0
I'm just starting out with Python and have practiced so far in the IDLE interface. Now I'd like to configure Python with MAMP so I can start creating really basic webapps — using Python inside HTML, or well, vice-versa. (I'm assuming HTML is allowed in Python, just like PHP? If not, are there any modules/template engin...
Python for web scripting
0.132549
0
0
756
1,782,586
2009-11-23T11:32:00.000
5
0
1
0
python,regex,performance
1,782,614
9
true
0
0
If speed is of the essence, you are better off running some tests before you decide how to code your production application. First of all, you said that you are searching for words which suggests that you may be able to do this using split() to break up the string on whitespace. And then use simple string comparisons t...
3
5
0
I'm writing a python program that deals with a fair amount of strings/files. My problem is that I'm going to be presented with a fairly short piece of text, and I'm going to need to search it for instances of a fairly broad range of words/phrases. I'm thinking I'll need to compile regular expressions as a way of matchi...
Speed of many regular expressions in python
1.2
0
0
17,655
1,782,586
2009-11-23T11:32:00.000
0
0
1
0
python,regex,performance
1,782,600
9
false
0
0
Depending on what you're doing it might be better to use a tokenizer and loop through the tokens to find matches. However, when it comes to short pieces of text regexes have incredibly good performance. Personally I remember only coming into problems when text sizes became ridiculous like 100k words or something like t...
3
5
0
I'm writing a python program that deals with a fair amount of strings/files. My problem is that I'm going to be presented with a fairly short piece of text, and I'm going to need to search it for instances of a fairly broad range of words/phrases. I'm thinking I'll need to compile regular expressions as a way of matchi...
Speed of many regular expressions in python
0
0
0
17,655
1,782,586
2009-11-23T11:32:00.000
6
0
1
0
python,regex,performance
1,782,712
9
false
0
0
You should try to compile all your regexps into a single one using the | operator. That way, the regexp engine will do most of the optimizations for you. Use the grouping operator () to determine which regexp matched.
3
5
0
I'm writing a python program that deals with a fair amount of strings/files. My problem is that I'm going to be presented with a fairly short piece of text, and I'm going to need to search it for instances of a fairly broad range of words/phrases. I'm thinking I'll need to compile regular expressions as a way of matchi...
Speed of many regular expressions in python
1
0
0
17,655
1,782,680
2009-11-23T11:52:00.000
1
0
1
0
python,windows,installation
3,212,744
4
false
0
0
..involve code import on the fly by xmlrpc process so it is not suitable for py2exe Py2exe can deal with situations like this. You just have to tell it which modules are being imported at runtime, so that it includes them in the distribution. Your code should then be able to import from these modules dynamically.
1
9
0
I want to distribute a Python application to windows users who don't have Python or the correct Python version. I have tried py2exe conversion but my Python program is really complex and involve code import on the fly by xmlrpc process so it is not suitable for py2exe. The complete Python folder takes around 80MB but t...
Distribute a Python program with a minimal environment
0.049958
0
0
2,021
1,783,431
2009-11-23T14:26:00.000
0
0
0
0
python,ruby-on-rails,django
1,784,061
7
false
1
0
With the cheeseshop, any python application can be made installable with a single command. I'm a big fan of Django, but it will require you to hook into an external webserver, as the built in server is for development only. You might look for something that has a more robust builtin web server if you want something y...
5
3
0
I am planning to do a small web application that will be distributed as a single installable. I have plans to develop this application in either Python/Django or Ruby On Rails. (I am a Java/C++ programmer, hence both these languages are new to me). My main concern is about the size and simplicity of final installable ...
Python Vs Ruby On Rails : on Size
0
0
0
746
1,783,431
2009-11-23T14:26:00.000
1
0
0
0
python,ruby-on-rails,django
1,783,732
7
false
1
0
One option with Ruby on Rails is to go with a JRuby deployment which would allow you to pack it all into a single .war file. This would require the person deploying the web application to have a java web application server (Jetty is probably the smallest and easiest to bundle). With Rails, you are generally going to ha...
5
3
0
I am planning to do a small web application that will be distributed as a single installable. I have plans to develop this application in either Python/Django or Ruby On Rails. (I am a Java/C++ programmer, hence both these languages are new to me). My main concern is about the size and simplicity of final installable ...
Python Vs Ruby On Rails : on Size
0.028564
0
0
746
1,783,431
2009-11-23T14:26:00.000
4
0
0
0
python,ruby-on-rails,django
1,783,478
7
false
1
0
I personally prefer Python/django. Size is small given u have necessary things installed.
5
3
0
I am planning to do a small web application that will be distributed as a single installable. I have plans to develop this application in either Python/Django or Ruby On Rails. (I am a Java/C++ programmer, hence both these languages are new to me). My main concern is about the size and simplicity of final installable ...
Python Vs Ruby On Rails : on Size
0.113791
0
0
746
1,783,431
2009-11-23T14:26:00.000
3
0
0
0
python,ruby-on-rails,django
1,783,473
7
false
1
0
With disk space at the current price, size shouldn't matter. Give both a try and figure out which will be easier for you to learn and maintain. Despite the fact that people believe that when you know one language, you know all, that's only true as long as you write code on the "hello world" level.
5
3
0
I am planning to do a small web application that will be distributed as a single installable. I have plans to develop this application in either Python/Django or Ruby On Rails. (I am a Java/C++ programmer, hence both these languages are new to me). My main concern is about the size and simplicity of final installable ...
Python Vs Ruby On Rails : on Size
0.085505
0
0
746
1,783,431
2009-11-23T14:26:00.000
1
0
0
0
python,ruby-on-rails,django
1,786,648
7
false
1
0
I don't think you can get them both. I'm sorry to say this but you have to choose which one is more important to you. Django application is smaller in size because many things is already provided out of the box, but deployment is not as easy. On the other hand, RoR apps deployment is easier (both Ruby MRI or JRuby) b...
5
3
0
I am planning to do a small web application that will be distributed as a single installable. I have plans to develop this application in either Python/Django or Ruby On Rails. (I am a Java/C++ programmer, hence both these languages are new to me). My main concern is about the size and simplicity of final installable ...
Python Vs Ruby On Rails : on Size
0.028564
0
0
746
1,783,669
2009-11-23T15:03:00.000
0
0
0
0
python,artificial-intelligence,machine-learning,svm
1,816,714
5
false
0
0
Why would you want to train it online? Adding trainings instances would usually require to re-solve the quadratic programming problem associated with the SVM. A way to handle this is to train a SVM in batch mode, and when new data is available, check if these data points are in the [-1, +1] margin of the hyperplane. If...
1
10
1
I do know there are some libraries that allow to use Support vector Machines from python code, but I am looking specifically for libraries that allow one to teach it online (this is, without having to give it all the data at once). Are there any?
Any python Support Vector Machine library around that allows online learning?
0
0
0
5,533
1,785,227
2009-11-23T18:57:00.000
3
0
0
0
wxpython,static-text
1,786,334
3
false
0
1
Depending on which color you would need to set, look into SetForegroundColour() or SetBackgroundColour() method.
1
23
0
I need to make a StaticText red, what should I use?
Change the colour of a StaticText, wxPython
0.197375
0
0
28,120
1,785,428
2009-11-23T19:32:00.000
2
0
1
0
python,pypy
1,791,637
1
true
0
0
You could try compiling it in a chroot.
1
4
0
Pypy's JIT will compile on 64-bit Linux ever since it grew 64-bit support, but what if I wanted to compile a 32-bit version? How should I cross-compile a 32-bit JITting pypy on that machine?
How do I build the 32-bit pypy JIT in 64-bit Linux?
1.2
0
0
561
1,785,607
2009-11-23T20:06:00.000
1
0
0
0
python,firefox,proxy,webdriver
1,790,122
1
true
0
0
The simplest thing to do is to poll the page looking for an element you know will be present once the download is complete. The Java webdriver bindings offer a "Wait" class for just this purpose, though there isn't (yet) an analogue for this in the python bindings.
1
1
0
when I set the Firefox proxy with python webdriver, it doesn't wait until the page is fully downloaded, this doesn't happen when I don't set one. How can I change this behavior? Or how can I check that the page download is over?
Python Webdriver doesn't wait until the page is downloaded in Firefox when used with proxy
1.2
0
1
1,062
1,786,522
2009-11-23T22:30:00.000
5
0
1
0
javascript,python,semantics
1,787,630
6
false
0
0
I'll add a few I haven't seen mentioned yet: JavaScript supports object-literal notation. Python doesn't exactly work the same way, but Python dictionaries are similar to JavaScript associative arrays. JavaScript objects/arrays support that cool feature where you don't need to quote (single-word) strings when creat...
5
27
0
Both these languages seem extremely similar to me. Although Python supports actual classes instead of being prototype-based, in Python classes are not all that different from functions that generate objects containing values and functions, just as you'd do in JavaScript. On the other hand, JavaScript only supports fl...
How different are the semantics between Python and JavaScript?
0.16514
0
0
16,999
1,786,522
2009-11-23T22:30:00.000
5
0
1
0
javascript,python,semantics
1,786,753
6
false
0
0
In python, "self" is explicitly passed to a member function, and is not a special keyword or anything. In javascript, "this" is dynamically scoped. you can fiddle with the scope of a member function by calling apply() on it.
5
27
0
Both these languages seem extremely similar to me. Although Python supports actual classes instead of being prototype-based, in Python classes are not all that different from functions that generate objects containing values and functions, just as you'd do in JavaScript. On the other hand, JavaScript only supports fl...
How different are the semantics between Python and JavaScript?
0.16514
0
0
16,999
1,786,522
2009-11-23T22:30:00.000
6
0
1
0
javascript,python,semantics
1,786,635
6
false
0
0
Typing: Javascript and Python are both dynamically typed, whereas javascript is weakly, python strongly typed.
5
27
0
Both these languages seem extremely similar to me. Although Python supports actual classes instead of being prototype-based, in Python classes are not all that different from functions that generate objects containing values and functions, just as you'd do in JavaScript. On the other hand, JavaScript only supports fl...
How different are the semantics between Python and JavaScript?
1
0
0
16,999
1,786,522
2009-11-23T22:30:00.000
1
0
1
0
javascript,python,semantics
1,786,550
6
false
0
0
In Python, whitespace is part of the language. In Javascript, braces define code blocks and spaces are ignored. Furthermore, Python has bindings for the Java API, .net, and other cool fancy libraries. Javascript is pretty limited in the library department when compared to Python, but it has some neat windowing librarie...
5
27
0
Both these languages seem extremely similar to me. Although Python supports actual classes instead of being prototype-based, in Python classes are not all that different from functions that generate objects containing values and functions, just as you'd do in JavaScript. On the other hand, JavaScript only supports fl...
How different are the semantics between Python and JavaScript?
0.033321
0
0
16,999
1,786,522
2009-11-23T22:30:00.000
2
0
1
0
javascript,python,semantics
1,786,573
6
false
0
0
Being a JavaScript developer and done some Python stuff (thanks to Google App Engine) I would say that the two major differences between JavaScript and Python would be Formatting. JavaScript doesn't care about the looks of your code (think of all the code minimizers and what the resulting looks like) Unicode support. ...
5
27
0
Both these languages seem extremely similar to me. Although Python supports actual classes instead of being prototype-based, in Python classes are not all that different from functions that generate objects containing values and functions, just as you'd do in JavaScript. On the other hand, JavaScript only supports fl...
How different are the semantics between Python and JavaScript?
0.066568
0
0
16,999
1,788,432
2009-11-24T07:25:00.000
3
0
0
0
python,django
1,788,452
6
false
1
0
http://example.com/my%20home/ is a valid URL where space character is escaped and Django will do all escaping/unescaping for you.
3
2
0
How can I have URLs like example.com/category/catename-operation/ in Django? Also in some cases the user enters a space separated category, how can I handle that? E.g if the user enters the category as "my home", then the URL for this category will become example.com/my home/ which is not a valid URL. How can I handle...
How to have a URL like this in Django?
0.099668
0
0
712
1,788,432
2009-11-24T07:25:00.000
0
0
0
0
python,django
1,788,715
6
false
1
0
How can I handle these things? If you want to handle this thing, to obtain my-url, then use the form field clean method to return the valid url. Thats what it is meant for.
3
2
0
How can I have URLs like example.com/category/catename-operation/ in Django? Also in some cases the user enters a space separated category, how can I handle that? E.g if the user enters the category as "my home", then the URL for this category will become example.com/my home/ which is not a valid URL. How can I handle...
How to have a URL like this in Django?
0
0
0
712
1,788,432
2009-11-24T07:25:00.000
0
0
0
0
python,django
1,788,459
6
false
1
0
You could consider adding a URL-friendly name to your category and using that in the URL instead. As another example you could have example.com/tv/ and have the category called "Televisions."
3
2
0
How can I have URLs like example.com/category/catename-operation/ in Django? Also in some cases the user enters a space separated category, how can I handle that? E.g if the user enters the category as "my home", then the URL for this category will become example.com/my home/ which is not a valid URL. How can I handle...
How to have a URL like this in Django?
0
0
0
712
1,792,360
2009-11-24T19:26:00.000
41
1
1
0
c++,python
1,793,767
11
true
0
0
Some Python limits : - Python is slow. It can be improved in many ways (see other answers) but the bare bone cPython is 100 times slower that C/C++. This problem is getter more and more mitigated. With Numpy, Pypy and asyncio, most performance problems are not covered, and only very specific use cases are a bottleneck...
8
12
0
I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn. So I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead? What can C++ do and Python can't ?
What are the limits of Python?
1.2
0
0
10,696
1,792,360
2009-11-24T19:26:00.000
32
1
1
0
c++,python
1,794,560
11
false
0
0
Here's why it's worth learning Python: A comparatively small number of problems are constrained by the speed of the algorithm. A comparatively large number of problems are bounded by the speed of the developer.
8
12
0
I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn. So I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead? What can C++ do and Python can't ?
What are the limits of Python?
1
0
0
10,696
1,792,360
2009-11-24T19:26:00.000
0
1
1
0
c++,python
1,795,473
11
false
0
0
One significant difference not so far mentioned is the difference between a language like C++ that builds to native code, and a language like Python which by default puts a VM between you and the hardware. For doing low-level work, like coding against the OS kernel, the native language will be the preferred option. In...
8
12
0
I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn. So I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead? What can C++ do and Python can't ?
What are the limits of Python?
0
0
0
10,696
1,792,360
2009-11-24T19:26:00.000
0
1
1
0
c++,python
53,662,323
11
false
0
0
One thing that people often use C for, and never (to my knowledge) Python, is low-level code such as operating-system kernels and embedded software. C has a lot of of constructs that make it very easy to, for example, convert an arbitrary machine address into a pointer and dereference it, or tell the compiler that an a...
8
12
0
I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn. So I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead? What can C++ do and Python can't ?
What are the limits of Python?
0
0
0
10,696
1,792,360
2009-11-24T19:26:00.000
0
1
1
0
c++,python
1,795,061
11
false
0
0
As others have suggested: learn Python to study algorithms and higher level concepts and use it for prototyping and for places where you can. Learn C/C++ and/or Java for the job market and for cases where you must use it. Python's vastly easier syntax and high level libraries allow you to focus on interfaces and abstr...
8
12
0
I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn. So I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead? What can C++ do and Python can't ?
What are the limits of Python?
0
0
0
10,696
1,792,360
2009-11-24T19:26:00.000
1
1
1
0
c++,python
1,794,856
11
false
0
0
From what I've been told, 1% of learning C++ is learning C. 1% is learning the extra basic features. 98% is learning to use the features in a safe, maintainable way, and coping with the dark hairy corners of the language. Learning python will teach you to write code that is safe, and maintainable. I think that if you l...
8
12
0
I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn. So I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead? What can C++ do and Python can't ?
What are the limits of Python?
0.01818
0
0
10,696
1,792,360
2009-11-24T19:26:00.000
0
1
1
0
c++,python
1,793,871
11
false
0
0
Learn a statically typed language and a scripting language. You can do whatever you want in either language. A well-written C++ code base is easier to maintain/debug than a Python code base written with the same level of competency. If your goal is to do web stuff or scripting, Python is for you. Anything more advance...
8
12
0
I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn. So I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead? What can C++ do and Python can't ?
What are the limits of Python?
0
0
0
10,696
1,792,360
2009-11-24T19:26:00.000
3
1
1
0
c++,python
1,792,387
11
false
0
0
if you are trying to find out whether you are still going to be employed some time later using C++ or Python, don't concern yourself with a single language's longevity. Learn to program. Don't learn to program in <insert a language here>. Here is an analogy: If your car is running fine (gets you where you're going, ha...
8
12
0
I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn. So I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead? What can C++ do and Python can't ?
What are the limits of Python?
0.054491
0
0
10,696
1,792,602
2009-11-24T20:08:00.000
2
1
1
0
python,utf-8,ascii,decode
5,642,048
5
false
0
0
What's meant by "foolproof" is that the function does not fail with even the most obscure, impossible input -- meaning, you could feed the function random binary data and IT WOULD NEVER FAIL, NO MATTER WHAT. That's what "foolproof" means. The function should then proceed do its best to convert to the destination encod...
2
5
0
Inside my python scrip, I get some string back from a function which I didn't write. The encoding of it varies. I need to convert it to ascii format. Is there some fool-proof way of doing this? I don't mind replacing the non-ascii chars with blanks or something else...
What is the fool proof way to convert some string (utf-8 or else) to a simple ASCII string in python
0.07983
0
0
11,358
1,792,602
2009-11-24T20:08:00.000
9
1
1
0
python,utf-8,ascii,decode
1,793,902
5
true
0
0
If you want an ASCII string that unambiguously represents what you have got, without losing any information, the answer is simple: Don't muck about with encode/decode, use the repr() function (Python 2.X) or the ascii() function (Python 3.x).
2
5
0
Inside my python scrip, I get some string back from a function which I didn't write. The encoding of it varies. I need to convert it to ascii format. Is there some fool-proof way of doing this? I don't mind replacing the non-ascii chars with blanks or something else...
What is the fool proof way to convert some string (utf-8 or else) to a simple ASCII string in python
1.2
0
0
11,358
1,793,261
2009-11-24T22:06:00.000
74
0
1
0
python,url
1,794,540
14
true
0
0
Since, from the comments the OP posted, it seems he doesn't want to preserve "absolute URLs" in the join (which is one of the key jobs of urlparse.urljoin;-), I'd recommend avoiding that. os.path.join would also be bad, for exactly the same reason. So, I'd use something like '/'.join(s.strip('/') for s in pieces) (if ...
1
147
0
For example, I want to join a prefix path to resource paths like /js/foo.js. I want the resulting path to be relative to the root of the server. In the above example if the prefix was "media" I would want the result to be /media/js/foo.js. os.path.join does this really well, but how it joins paths is OS dependent. In...
How to join components of a path when you are constructing a URL in Python
1.2
0
1
128,395
1,794,179
2009-11-25T01:56:00.000
14
1
0
0
python,ruby-on-rails,metaprogramming,code-translation
1,794,205
4
false
1
0
I think one of the things that people like about RoR is the domain-specific language (DSL) style of programming. This is something that Ruby is much better at than Python.
1
23
0
Would it be possible to translate the Ruby on Rails code base to Python? I think many people like Python more than Ruby, but find Ruby on Rails features better (as a whole) than the ones in Python web frameworks. So that, would it be possible? Or does Ruby on Rails utilize language-specific features that would be diffi...
Python on Rails?
1
0
0
23,732
1,794,536
2009-11-25T04:04:00.000
1
0
0
1
python,process
1,794,679
2
true
0
0
If you want "real" (pseudo-;-) terminals, and are using X11 (almost every GUI interface on Linux does;-), you could exec xterm -e python node.py instead of just python node.py -- substitute for xterm whatever terminal emulator program you prefer, of course (I'm sure they all have command-line switches equivalent to goo...
1
1
0
I am trying to simulate a a network consisting of several clients and servers. I have written node.py which contains client-server code. I want to run multiple instances node.py. But I don't want to do it manually so I have written another file spawn.py which spawns multiple instances of node.py using fork and exec. Ho...
Python : fork and exec a process to run on different terminal
1.2
0
0
1,575
1,795,349
2009-11-25T07:59:00.000
1
0
0
0
python,reportlab
1,842,295
2
true
1
0
You shouldn't have much trouble doing this. Aside from some differences in element names, it's pretty straightforward: just ignore any HTML elements that can't be easily converted/you don't care about converting to RML and do the rest. I'm sure the ReportLab folks would be glad if you contributed even a basic HTML t...
1
2
0
Is there any Python library or some sample code which demonstrates how to convert basic HTML into RML (Reportlab Markup Language www.reportlab.org)? I can think of using a regular HTML parser and adding some home grown code to generate the RML, but I guess there will be a lot of cases to handle in such a conversion.
converting basic HTML to RML (Reportlab Markup Language)
1.2
0
0
2,613
1,796,105
2009-11-25T10:46:00.000
6
0
1
0
python,django,path
1,796,427
3
true
1
0
You have it backwards. Django is added to Python's environment. When you install a new Python, you must reinstall everything -- including Django -- for the new Python. Once you have the new Django in the new Python, your PATH settings determine which Python you're using. The version of Python (and the PYTHONPATH) det...
3
3
0
Django application requires a later version of Python. I just installed it to 2.5 (from 2.4) and now when I do a python at the command line, it says 2.5.2. Having said that, Django still says Python Version: 2.4.3. How do I correct this? I've rebooted / restarted / redeployed to no avail.
Point Django at different Python version
1.2
0
0
4,848
1,796,105
2009-11-25T10:46:00.000
4
0
1
0
python,django,path
1,796,381
3
false
1
0
How are you running Django? If it's via the development server, you can explicitly choose the version of Python you're using - python2.5 manage.py runserver. However, if you're using mod_python or mod_wsgi these are fixed to the version of Python that was used when they were compiled. If you need to change this, you'll...
3
3
0
Django application requires a later version of Python. I just installed it to 2.5 (from 2.4) and now when I do a python at the command line, it says 2.5.2. Having said that, Django still says Python Version: 2.4.3. How do I correct this? I've rebooted / restarted / redeployed to no avail.
Point Django at different Python version
0.26052
0
0
4,848
1,796,105
2009-11-25T10:46:00.000
0
0
1
0
python,django,path
1,796,228
3
false
1
0
django uses /usr/bin/env python IIRC. So, wherever your path points (which python) is the python that gets used. dependent upon your system, you can point your path to the python that you want to use. However, on some OS (CentOS for example) this is a bad idea.
3
3
0
Django application requires a later version of Python. I just installed it to 2.5 (from 2.4) and now when I do a python at the command line, it says 2.5.2. Having said that, Django still says Python Version: 2.4.3. How do I correct this? I've rebooted / restarted / redeployed to no avail.
Point Django at different Python version
0
0
0
4,848
1,797,046
2009-11-25T13:52:00.000
4
0
0
0
python,django
1,797,198
7
false
1
0
If you don't want to use settings module, then try project's __init__.py.
4
7
0
I would like to run some environment checks when my django process starts and die noisily in the case of an error. I'm thinking things like the database has an incorrect encoding or the machine has a python version we don't support. I'd rather our team be faced with a fatal error that they have to fix, rather than be a...
Correct place to put extra startup code in django?
0.113791
0
0
5,120
1,797,046
2009-11-25T13:52:00.000
4
0
0
0
python,django
1,798,361
7
false
1
0
We use the top-level urls.py for this.
4
7
0
I would like to run some environment checks when my django process starts and die noisily in the case of an error. I'm thinking things like the database has an incorrect encoding or the machine has a python version we don't support. I'd rather our team be faced with a fatal error that they have to fix, rather than be a...
Correct place to put extra startup code in django?
0.113791
0
0
5,120
1,797,046
2009-11-25T13:52:00.000
0
0
0
0
python,django
3,154,109
7
false
1
0
You can put it in settings.py as mentioned by others, but having code in the settings is not ideal. There is also the option of adding a handler for django.db.models.signals.class_prepared that does the desired start up checks after a specific model class is prepared.
4
7
0
I would like to run some environment checks when my django process starts and die noisily in the case of an error. I'm thinking things like the database has an incorrect encoding or the machine has a python version we don't support. I'd rather our team be faced with a fatal error that they have to fix, rather than be a...
Correct place to put extra startup code in django?
0
0
0
5,120
1,797,046
2009-11-25T13:52:00.000
3
0
0
0
python,django
13,517,044
7
false
1
0
I have tested all three __init__.py Settings.py and urls.py methods and this is what I have found. When code is run from either __init__.py or Settings.py, the start up functions are run twice upon web server start up; when the start up functions are run from urls.py the code is run once, however it is run only upon th...
4
7
0
I would like to run some environment checks when my django process starts and die noisily in the case of an error. I'm thinking things like the database has an incorrect encoding or the machine has a python version we don't support. I'd rather our team be faced with a fatal error that they have to fix, rather than be a...
Correct place to put extra startup code in django?
0.085505
0
0
5,120
1,798,351
2009-11-25T16:56:00.000
1
0
0
1
python,subprocess
1,798,364
3
false
1
0
Do you know about the open command in Mac OS X? I think you can solve your problem by calling it from Python. man open for details: The open command opens a file (or a directory or URL), just as if you had double-clicked the file's icon. If no application name is specified, the default application as determined via Lau...
2
2
0
I'm writing a python script that generates html file. Every time I run this script I'd like at the end to open default system browser for this file. It's all in OS X environment. What python code can launch Safari/Firefox/whatever is system default html viewer and open given file? subprocess.call doesn't seem to do the...
Launching default application for given type of file, OS X
0.066568
0
0
576
1,798,351
2009-11-25T16:56:00.000
0
0
0
1
python,subprocess
1,799,054
3
false
1
0
import ic ic.launchurl('file:///somefile.html')
2
2
0
I'm writing a python script that generates html file. Every time I run this script I'd like at the end to open default system browser for this file. It's all in OS X environment. What python code can launch Safari/Firefox/whatever is system default html viewer and open given file? subprocess.call doesn't seem to do the...
Launching default application for given type of file, OS X
0
0
0
576
1,799,475
2009-11-25T19:43:00.000
-1
0
0
0
python,cx-oracle,kinterbasdb
1,803,407
1
false
0
1
oracle is a complete pain. i don't know the details for windows, but for unix you need ORACLE_HOME and LD_LIBRARY_PATH to both be defined before cx_oracle will work. in windows this would be your environment variables, i guess. so check those. also, check that they are defined in the environment in which the program...
1
2
0
Greetings, everybody. I'm trying to import the following libraries in python: cx_Oracle and kinterbasdb. But, when I try, I get a very similar message error. *for cx_Oracle: Traceback (most recent call last): File "", line 1, in ImportError: DLL load failed: Não foi possível encontrar o procedimento especificado. (t...
importing cx_Oracle and kinterbasdb returns error
-0.197375
1
0
767
1,801,271
2009-11-26T02:40:00.000
4
1
0
0
python,c,smtplib
1,801,277
3
true
0
0
smtplib itself is implemented in python but socket is based on C, so its means both.
2
5
0
Is smtplib pure python or implemented in C?
Is smtplib pure python or implemented in C?
1.2
0
0
355
1,801,271
2009-11-26T02:40:00.000
2
1
0
0
python,c,smtplib
1,801,281
3
false
0
0
Basically pure Python (as the underlying implementation if you go down far enough is C). You can find the source under the Lib\ directory in your Python root.
2
5
0
Is smtplib pure python or implemented in C?
Is smtplib pure python or implemented in C?
0.132549
0
0
355
1,801,307
2009-11-26T02:55:00.000
1
0
0
0
python,sqlite,floating-point
1,801,521
6
false
0
0
Most people would probably use Decimal for this, however if this doesn't map onto a database type you may take a performance hit. If performance is important you might want to consider using Integers to represent an appropriate currency unit - often cents or tenths of cents is ok. There should be business rules about h...
1
4
0
I'm creating a financial app and it seems my floats in sqlite are floating around. Sometimes a 4.0 will be a 4.000009, and a 6.0 will be a 6.00006, things like that. How can I make these more exact and not affect my financial calculations? Values are coming from Python if that matters. Not sure which area the messed ...
How to deal with rounding errors of floating types for financial calculations in Python SQLite?
0.033321
1
0
3,672
1,801,668
2009-11-26T05:15:00.000
7
0
1
0
python,list
1,801,789
13
false
0
0
For this sample the comprehension is fastest $ python -m timeit -s 's=["one","two","three"]*1000' '[x.upper for x in s]' 1000 loops, best of 3: 809 usec per loop $ python -m timeit -s 's=["one","two","three"]*1000' 'map(str.upper,s)' 1000 loops, best of 3: 1.12 msec per loop $ python -m timeit -s 's=["one","two","th...
1
341
0
I have a Python list variable that contains strings. Is there a function that can convert all the strings in one pass to lowercase and vice versa, uppercase?
Convert a list with strings all to lowercase or uppercase
1
0
0
666,757
1,801,878
2009-11-26T06:28:00.000
39
1
1
0
python,module,package,project-organization
1,801,992
5
true
0
0
Think in terms of a "logical unit of packaging" -- which may be a single class, but more often will be a set of classes that closely cooperate. Classes (or module-level functions -- don't "do Java in Python" by always using static methods when module-level functions are also available as a choice!-) can be grouped bas...
3
47
0
I come from a background where I normally create one file per class. I organize common classes under directories as well. This practice is intuitive to me and it has been proven to be effective in C++, PHP, JavaSript, etc. I am having trouble bringing this metaphor into Python: files are not just files anymore, but th...
The Pythonic way of organizing modules and packages
1.2
0
0
22,658
1,801,878
2009-11-26T06:28:00.000
7
1
1
0
python,module,package,project-organization
1,802,001
5
false
0
0
If you are coming from a c++ point of view, you could view python modules akin to a .so or .dll. Yeah they look like source files, because python is scripted, but they are actually loadable libraries of specific functionality. Another metaphor that may help is you might look python modules as namespaces.
3
47
0
I come from a background where I normally create one file per class. I organize common classes under directories as well. This practice is intuitive to me and it has been proven to be effective in C++, PHP, JavaSript, etc. I am having trouble bringing this metaphor into Python: files are not just files anymore, but th...
The Pythonic way of organizing modules and packages
1
0
0
22,658
1,801,878
2009-11-26T06:28:00.000
4
1
1
0
python,module,package,project-organization
1,801,981
5
false
0
0
In a mid-sized project, I found myself with several sets of closely related classes. Several of those sets are now grouped into files; for example, the low-level network classes are all in a single network module. However, a few of the largest classes have been split out into their own file. Perhaps the best way to s...
3
47
0
I come from a background where I normally create one file per class. I organize common classes under directories as well. This practice is intuitive to me and it has been proven to be effective in C++, PHP, JavaSript, etc. I am having trouble bringing this metaphor into Python: files are not just files anymore, but th...
The Pythonic way of organizing modules and packages
0.158649
0
0
22,658
1,802,282
2009-11-26T08:26:00.000
4
1
0
0
python,paste,paster
1,802,443
2
false
0
0
PasteScript (and its companion PasteDeploy) are tools for running Python code using 'entry points'. Basically, a python library can specify in metadata that it knows how to create a certain kind of Python project, or perform certain operations on those projects. paster is a commandline tool that looks up the appropriat...
1
21
0
I'm trying to understand what paste script and paster are. The website is far from clear. I used paster to generate pre-made layouts for projects, but I don't get the big picture. As far as I understand, and from the wikipedia entry, it says it's a framework for web frameworks, but that seems reductive. paster create ...
What is paste script?
0.379949
0
0
6,425
1,803,233
2009-11-26T11:46:00.000
0
0
0
0
python,mysql
6,616,901
2
false
0
0
You need to fire up regedit and make HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath and HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath\InstallGroup to look like HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.7\InstallPath\InstallGroup.
1
7
0
I have downloaded mysqlDb, and while installing it I am getting errors like: C:\Documents and Settings\naresh\Desktop\MySQL-python-1.2.3c1>setup.py build Traceback (most recent call last): File "C:\Documents and Settings\naresh\Desktop\MySQL-python-1.2.3c1 \setup.py",line15, in metadata, options = get_config()...
How to install mysql connector
0
1
0
6,706
1,803,516
2009-11-26T12:54:00.000
0
0
1
0
python
72,299,692
4
false
0
0
import numpy alpha = numpy.array([1,2,3,numpy.nan,4]) n = numpy.nan_to_num(alpha) print(n) output : array([1., 2., 3., 0., 4.])
1
10
1
how can I replace the NaN value in an array, zero if an operation is performed such that as a result instead of the NaN value is zero operations as 0 / 0 = NaN can be replaced by 0
replace the NaN value zero after an operation with arrays
0
0
0
32,496
1,803,741
2009-11-26T13:43:00.000
1
0
0
0
python,error-handling
1,803,796
2
false
0
0
In urllib2 HTTPError exception is also a valid HTTP response, so you can treat an HTTP error as an exceptional event or valid response. But in urllib you have to subclass URLopener and define http_error_<code> method[s] or redefine http_error_default to handle them all.
1
4
0
the normal behavior of urllib/urllib2 is if an error code is sent in the header of the response (i.e 404) an Exception is raised. How do you look for specific errors i.e (40x, or 50x) based on the different errors, do different things. Also, how do you read the actual data being returned HTML/JSON etc (The data usuall...
Error codes returned by urllib/urllib2 and the actual page
0.099668
0
1
5,703
1,804,049
2009-11-26T14:40:00.000
2
0
1
0
python,file,double,numbers
1,804,085
4
false
0
0
I don't know fortran, so it's hard to tell what is easy for you to perform on that side for parsing. It sounds like your options are either saving the doubles in plaintext (meaning, 'converting' them to string), or in binary (using struct and the likes). The decision for which one is better depends. I would go with the...
1
3
0
Let's say I need to save a matrix(each line corresponds one row) that could be loaded from fortran later. What method should I prefer? Is converting everything to string is the only one approach?
How to save double to file in python?
0.099668
0
0
3,535
1,805,148
2009-11-26T18:47:00.000
1
1
1
0
python,ruby,compiler-construction
1,805,155
12
false
0
0
By design. The authors wanted something where they can write scripts into. Python gets compiled the first time it is executed though
7
18
0
What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So...
Why is (python|ruby) interpreted?
0.016665
0
0
2,514
1,805,148
2009-11-26T18:47:00.000
2
1
1
0
python,ruby,compiler-construction
1,805,169
12
false
0
0
In a compiled language, the loop you get into when making software is Make a change Compile changes Test changes goto 1 Interpreted languages tend to be faster to make stuff in because you get to cut out step two of that process (and when you're dealing with a large system where compile times can be upwards of two mi...
7
18
0
What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So...
Why is (python|ruby) interpreted?
0.033321
0
0
2,514
1,805,148
2009-11-26T18:47:00.000
1
1
1
0
python,ruby,compiler-construction
1,928,816
12
false
0
0
Raw compute performance is probably not a goal of most interpreted languages. Interpreted languages are typically more concerned about programmer productivity than raw speed. In most cases these languages are plenty fast enough for the tasks the languages were designed to tackle. Given that, and that just about the on...
7
18
0
What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So...
Why is (python|ruby) interpreted?
0.016665
0
0
2,514
1,805,148
2009-11-26T18:47:00.000
2
1
1
0
python,ruby,compiler-construction
1,805,157
12
false
0
0
Well, isn't one of the strengths of these languages that they are so easily scriptable? They wouldn't be if they were compiled. And on the other hand, dynamic languages are easier to intereprete than to compile.
7
18
0
What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So...
Why is (python|ruby) interpreted?
0.033321
0
0
2,514
1,805,148
2009-11-26T18:47:00.000
32
1
1
0
python,ruby,compiler-construction
1,805,172
12
false
0
0
Several reasons: faster development loop, write-test vs write-compile-link-test easier to arrange for dynamic behavior (reflection, metaprogramming) makes the whole system portable (just recompile the underlying C code and you are good to go on a new platform) Think of what would happen if the system was not interpre...
7
18
0
What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So...
Why is (python|ruby) interpreted?
1
0
0
2,514
1,805,148
2009-11-26T18:47:00.000
8
1
1
0
python,ruby,compiler-construction
1,805,899
12
false
0
0
Merely replacing an interpreter with a compiler won't give you as big a performance boost as you might think for a language like Python. When most time is actually spend doing symbolic lookups of object members in dictionaries, it doesn't really matter if the call to the function performing such lookup is interpreted, ...
7
18
0
What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So...
Why is (python|ruby) interpreted?
1
0
0
2,514
1,805,148
2009-11-26T18:47:00.000
6
1
1
0
python,ruby,compiler-construction
1,805,158
12
false
0
0
I think the biggest reason for the languages being interpreted is portability. As a programmer you can write code that will run in an interpreter not a specific OS. So your programs behave more uniformly across platforms (more so than compiled languages). Another advantage I can think of is it's easier to have a dynami...
7
18
0
What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So...
Why is (python|ruby) interpreted?
1
0
0
2,514
1,805,480
2009-11-26T20:17:00.000
1
0
1
0
python,data-structures
1,806,045
7
false
0
0
I think there are basically two layers of data: 1) map data: does square have a bomb (e.g represented by -1) or how many bombs are around it, 2) display data, what is shown on the square: bomb count, bomb, flag, question mark, empty, unopened. So two nested lists (or one nested list of tuples) might be enough.
1
4
0
What datastructure would you use in Python to represent the internal state of a MineSweeper grid? Each x,y position will hold a numerical value which represents its current cell state (unexplored, mine, flag, ?). Should I use nested lists? This seems like the closest thing to a 2D array and it is what I would probably...
How would you represent a MineSweeper grid in Python?
0.028564
0
0
4,778
1,805,555
2009-11-26T20:38:00.000
4
0
0
1
python,google-app-engine
1,805,774
1
true
1
0
There is no intrinsic penalty to using a key name instead of an auto-generated ID, except the overhead of a (potentially) longer key on the entity and any ReferenceProperties that reference it. In certain cases, in fact, using auto-allocated IDs can have a performance penalty: If you insert new entities at a very high ...
1
2
0
If you used named keys in Google App Engine, does this incur any additional cost? Put another way, is it any more expensive to create a new entity with a named key rather than a randomly generated id? In a similar line of reasoning, I note that you can ask Google App Engine to give you a set of keys that will not be us...
What is the performance cost of named keys or "pre-generated" keys in Google App Engine?
1.2
0
0
198
1,806,449
2009-11-27T01:56:00.000
2
0
0
0
python,django,search,django-templates,xapian
1,806,773
1
true
1
0
Please figure out what is the exact file path involved in this error. I guess it involves a write operation to some template cache, but you should make sure. Then you just need to check the UNIX permissions on the file accessed or on the directory for that file in the case of a newly created file. Another possibility i...
1
0
0
I've followed the Djapian tutorial and setup everything "by the book" so that the indexshell commandline supplied by Djapian shows successful queries. However, when integrating the sample search from the Djapian tutorial I get this nonsense error: TemplateSyntaxError at /search/ Caught an exception while rendering: (1...
"Permission Denied" in Django template using Djapian
1.2
0
0
2,652
1,808,721
2009-11-27T13:16:00.000
0
0
0
0
php,python,drupal,data-entry
1,808,788
5
false
0
0
CCK or otherwise, it's just a wellformed POST query (presumably), so sure, go for it.
1
3
0
I'm planning on putting a store's inventory on a Drupal site and I'm wondering if it's possible to create a script (maybe in python/php?) to enter the data automatically to Drupal with CCK? Thanks in advance!
Is it possible to script for data entry with Drupal?
0
0
0
1,208
1,808,806
2009-11-27T13:33:00.000
3
0
1
0
python,math,multithreading
1,808,851
4
false
0
0
Rule of thumb: if a thread is going to do input/output, it may be worth separating it. If it's doing number-crunching then optimum number of threads is number of CPUs.
3
0
0
Is there an algorithm that checks whether creating a new thread pays off performance wise? I'll set a maximum of threads that can be created anyway but if I add just one task it wouldn't be an advantage to start a new thread for that. The programming language I use is python. Edit 1# Can this question even be answered ...
Algorithm should I create a new thread?
0.148885
0
0
177
1,808,806
2009-11-27T13:33:00.000
0
0
1
0
python,math,multithreading
1,808,813
4
false
0
0
Testing will tell you. Basicly try, and benchmark.
3
0
0
Is there an algorithm that checks whether creating a new thread pays off performance wise? I'll set a maximum of threads that can be created anyway but if I add just one task it wouldn't be an advantage to start a new thread for that. The programming language I use is python. Edit 1# Can this question even be answered ...
Algorithm should I create a new thread?
0
0
0
177
1,808,806
2009-11-27T13:33:00.000
0
0
1
0
python,math,multithreading
1,808,864
4
false
0
0
There is no general answer for this ... yet. But there is a trend. Since computers get more and more CPU cores (try to buy a new single CPU PC ...), using threads becomes the de-facto standard. So if you have some work which can be parallelized, then by all means use the threading module and create a pool of workers. T...
3
0
0
Is there an algorithm that checks whether creating a new thread pays off performance wise? I'll set a maximum of threads that can be created anyway but if I add just one task it wouldn't be an advantage to start a new thread for that. The programming language I use is python. Edit 1# Can this question even be answered ...
Algorithm should I create a new thread?
0
0
0
177
1,809,201
2009-11-27T14:50:00.000
0
0
0
0
python,nhibernate,orm
1,809,219
4
false
0
0
Check out Django. They have a nice ORM and I believe it has tools to attempt a reverse-engineer from the DB schema.
3
0
0
We have an existing C# project based on NHibernate and WPF. I am asked to convert it to Linux and to consider other implementation like Python. But for some reason, they like NHibernate a lot and want to keep it. Do you know if it's possible to keep the NHibernate stuff and make it work with Python ? I am under the im...
NHibernate and python
0
1
0
1,382
1,809,201
2009-11-27T14:50:00.000
2
0
0
0
python,nhibernate,orm
1,809,238
4
false
0
0
What about running your project under Mono on Linux? Mono seems to support NHibernate, which means you may be able to get away with out rewriting large chunks of your application. Also, if you really wanted to get Python in on the action, you could use IronPython along with Mono.
3
0
0
We have an existing C# project based on NHibernate and WPF. I am asked to convert it to Linux and to consider other implementation like Python. But for some reason, they like NHibernate a lot and want to keep it. Do you know if it's possible to keep the NHibernate stuff and make it work with Python ? I am under the im...
NHibernate and python
0.099668
1
0
1,382
1,809,201
2009-11-27T14:50:00.000
5
0
0
0
python,nhibernate,orm
1,809,266
4
false
0
0
NHibernate is not specific to C#, but it is specific to .NET. IronPython is a .NET language from which you could use NHibernate. .NET and NHibernate can run on Linux through Mono. I'm not sure how good Mono's support is for WPF. I'm not sure if IronPython runs on Linux, but that would seem to be the closest thing to w...
3
0
0
We have an existing C# project based on NHibernate and WPF. I am asked to convert it to Linux and to consider other implementation like Python. But for some reason, they like NHibernate a lot and want to keep it. Do you know if it's possible to keep the NHibernate stuff and make it work with Python ? I am under the im...
NHibernate and python
0.244919
1
0
1,382
1,811,173
2009-11-28T00:47:00.000
1
0
0
0
python,mysql,url
1,811,196
5
false
1
0
Is it possible that it's hitting an uncaught exception? Are you running this from a shell, or is it being run from cron or in some other automated way? If it's automated, the output may not be displayed anywhere.
2
17
0
Basically, i have a list of 30,000 URLs. The script goes through the URLs and downloads them (with a 3 second delay in between). And then it stores the HTML in a database. And it loops and loops... Why does it randomly get "Killed."? I didn't touch anything. Edit: this happens on 3 of my linux machines. The machines a...
Why does my python script randomly get killed?
0.039979
0
1
20,694
1,811,173
2009-11-28T00:47:00.000
1
0
0
0
python,mysql,url
1,811,350
5
false
1
0
Are you using some sort of queue manager or process manager of some sort ? I got apparently random killed messages when the batch queue manager I was using was sending SIGUSR2 when the time was up. Otherwise I strongly favor the out of memory option.
2
17
0
Basically, i have a list of 30,000 URLs. The script goes through the URLs and downloads them (with a 3 second delay in between). And then it stores the HTML in a database. And it loops and loops... Why does it randomly get "Killed."? I didn't touch anything. Edit: this happens on 3 of my linux machines. The machines a...
Why does my python script randomly get killed?
0.039979
0
1
20,694
1,811,236
2009-11-28T01:24:00.000
0
0
1
0
python,regex
1,811,244
5
false
0
0
Install Python on your Mac, then copy the script over? It should work fine on any Python installation.
1
4
0
In the Python installation on my PC there is a sweet script in C:\python26\tools\scripts called redemo.py. It's a simple tk application for testing regular expressions. I wish I could get it--or something like it--running on my Mac, but I don't know how. The script doesn't appear to be part of the Python installation o...
How can I run redemo.py (or equivalent) on a Mac?
0
0
0
898
1,811,940
2009-11-28T08:04:00.000
2
0
0
0
python,frameworks,desktop
1,813,171
4
true
0
1
Well the best way to start is to look at the source code of the framework the other answers are talking about. First, try to use them all to build the same application with the functionalities you expect from a framework. Them, look at how it works under the hood. Secondly, build your framework, starting by writing you...
1
2
0
I want to develop a desktop application framework in Python, much like QT, but how to go about it? Any tutorials or links related to it would be helpful!
I want to develop a framework in Python for desktop based applications. How should I go about it?
1.2
0
0
813
1,812,115
2009-11-28T09:46:00.000
4
0
1
1
python,windows,file
1,812,351
8
false
0
0
The standard solution is this. Write a new file with a similar name. X.ext# for example. When that file has been closed (and perhaps even read and checksummed), then you two two renames. X.ext (the original) to X.ext~ X.ext# (the new one) to X.ext (Only for the crazy paranoids) call the OS sync function to force d...
2
21
0
Imagine you have a library for working with some sort of XML file or configuration file. The library reads the whole file into memory and provides methods for editing the content. When you are done manipulating the content you can call a write to save the content back to file. The question is how to do this in a safe w...
How to safely write to a file?
0.099668
0
0
9,770
1,812,115
2009-11-28T09:46:00.000
17
0
1
1
python,windows,file
1,812,604
8
true
0
0
If you see Python's documentation, it clearly mentions that os.rename() is an atomic operation. So in your case, writing data to a temporary file and then renaming it to the original file would be quite safe. Another way could work like this: let original file be abc.xml create abc.xml.tmp and write new data to it re...
2
21
0
Imagine you have a library for working with some sort of XML file or configuration file. The library reads the whole file into memory and provides methods for editing the content. When you are done manipulating the content you can call a write to save the content back to file. The question is how to do this in a safe w...
How to safely write to a file?
1.2
0
0
9,770
1,813,044
2009-11-28T16:59:00.000
0
0
0
0
python,firefox,webdriver
1,814,160
1
true
0
0
Hmm, I actually haven't worked with Webdriver so this may be of no help at all... but in your other post you mention that you're experimenting with modifying the delete cookie webdriver js function. Did get_cookies fail before you were modifying the delete function? What happens when you get cookies before deleting the...
1
0
0
when I can't delete FF cookies from webdriver. When I use the .delete_all_cookies method, it returns None. And when I try to get_cookies, I get the following error: webdriver_common.exceptions.ErrorInResponseException: Error occurred when processing packet:Content-Length: 120 {"elementId": "null", "context": "{9b44672f...
How to delete Firefox cookies from webdriver in python?
1.2
0
1
2,862
1,813,394
2009-11-28T18:54:00.000
13
1
1
0
python,wsgi
1,813,471
6
true
0
0
mod_wsgi vs. mod_python: mod_wsgi is a little faster (internally there's more C, less Python) mod_wsgi processes can be isolated from Apache, which improves security/stability with lower memory use[1] mod_python gives you access to some of Apache's internals WSGI in general: lots of reusable middleware (authenticati...
4
23
0
Been using mod_python for a while, I read more and more articles about how good WSGI is, without really understanding why. So why should I switch to it? What are the benefits? Is it hard, and is the learning curve worth it?
Why should I use WSGI?
1.2
0
0
10,494
1,813,394
2009-11-28T18:54:00.000
1
1
1
0
python,wsgi
1,813,431
6
false
0
0
You shouldn't have to relearn much, since the difference from a developer perspective is just a small wrapper and some server configuration. From a deployment perspective, the difference is that your python code lives in a separate process from the web browser, which means a) The python process can be running as anothe...
4
23
0
Been using mod_python for a while, I read more and more articles about how good WSGI is, without really understanding why. So why should I switch to it? What are the benefits? Is it hard, and is the learning curve worth it?
Why should I use WSGI?
0.033321
0
0
10,494
1,813,394
2009-11-28T18:54:00.000
2
1
1
0
python,wsgi
1,813,462
6
false
0
0
Most Python frameworks implement wsgi. There is mod_wsgi for apache and a SCGI/FastCGI/AJP module + Flup for the others. That way you can have all the advantages of a separate Python process, without being tied to one webserver.
4
23
0
Been using mod_python for a while, I read more and more articles about how good WSGI is, without really understanding why. So why should I switch to it? What are the benefits? Is it hard, and is the learning curve worth it?
Why should I use WSGI?
0.066568
0
0
10,494
1,813,394
2009-11-28T18:54:00.000
15
1
1
0
python,wsgi
1,813,470
6
false
0
0
For developing sophisticated web applications in Python, you would probably use a more comprehensive web development framework like DJango, Zope, Turbogears etc. As an application developer, you don't have to worry about WSGI much. All you have to be aware about is that these frameworks support WSGI. The WSGI allows se...
4
23
0
Been using mod_python for a while, I read more and more articles about how good WSGI is, without really understanding why. So why should I switch to it? What are the benefits? Is it hard, and is the learning curve worth it?
Why should I use WSGI?
1
0
0
10,494
1,814,053
2009-11-28T23:00:00.000
1
0
0
0
python,security
1,814,092
2
false
1
0
To add a little bit to S.Lott's comment: The code portion of your blog should be stored in a location where it can be executed (e.g. via a web request), but not read directly. Any reasonable web server providing CGI support will allow this to be set up.
1
1
0
I set django's settings.py file to chmod 600 to keep felonious folks from spying my database connection info, but on import python compiles this file and writes out settings.pyc as mode 644. It doesn't take much sleuthing for the bad guys to get the info they need from this compiled version. I fear my blog entries are ...
python and securing pyc files on disk
0.099668
0
0
1,262
1,814,393
2009-11-29T02:00:00.000
1
0
0
1
python,linux,fileserver,flock
1,814,406
1
false
0
0
If this happens intermittently, you might just want to try waiting a short period and retrying. Other than that... log the error and fail. Maybe throw an exception that someone higher up can catch and deal with more gracefully.
1
0
0
If I've got a global disk resource (mount point on an isilon file server) that multiple servers use to access a lock file. What is a good way to handle the situation if that global disk becomes unavailable and the servers can't access the global lock file? Thanks, Doug
Global disk resource becomes unavailable
0.197375
0
0
65
1,814,437
2009-11-29T02:20:00.000
0
0
0
0
python,django
1,814,465
4
false
1
0
I'm going to assume that you mean logged in at once, and not one "login" at the same time. I've never written a Django application before. But one method I've used in other languages, is to store the session ID of the logged in user in their user row in the database. For example, if you have a users table in your datab...
1
2
0
is it possible to allow only one concurrent login per user in django application? if yes, how do you approach?
Allow only one concurrent login per user in django app
0
0
0
13,565
1,815,165
2009-11-29T10:16:00.000
6
0
1
0
python,text,fonts,python-imaging-library,draw
1,815,170
6
false
0
0
Many fonts use different TTF files for their bold/italic versions, so I'd imagine if you just specify that file it would work.
2
28
0
How to draw bold/italic text with PIL? ImageFont.truetype(file, size) has an option to specify font size only.
Draw bold/italic text with PIL?
1
0
0
24,930
1,815,165
2009-11-29T10:16:00.000
25
0
1
0
python,text,fonts,python-imaging-library,draw
1,815,171
6
true
0
0
Use the bold/italic version of the font
2
28
0
How to draw bold/italic text with PIL? ImageFont.truetype(file, size) has an option to specify font size only.
Draw bold/italic text with PIL?
1.2
0
0
24,930
1,817,064
2009-11-29T22:54:00.000
2
0
1
0
python,pydoc
1,817,070
3
false
0
0
No, you have to add the r. If you don't add the r, there's no way you can be sure to get back the original string no matter what you do. If you don't like raw strings the other alternative is to escape your backslashes in the strings with an extra backslash.
2
0
0
Is there a way to get object.__doc__ as a raw string, apart from adding an 'r' in-front of the doctring itself in the source code? I have latex code inside and the '\r's, '\f's etc are creating problems.
get `object.__doc__` as raw string
0.132549
0
0
250
1,817,064
2009-11-29T22:54:00.000
7
0
1
0
python,pydoc
1,817,081
3
true
0
0
There's no such Python type as "raw string" -- there are raw string literals, which are just one syntax approach (out of many) to specify constants (i.e., literals) that are of string types. So "getting" something "as a raw string" just makes no sense. You can write docstrings as raw string literals (i.e., with the p...
2
0
0
Is there a way to get object.__doc__ as a raw string, apart from adding an 'r' in-front of the doctring itself in the source code? I have latex code inside and the '\r's, '\f's etc are creating problems.
get `object.__doc__` as raw string
1.2
0
0
250