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 application, and the user needs to specify a name of a field that is going to be updated by my app. | 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 will break things, e.g. you can install different versions of Python side-by-side but only one of them can have the .py file association, so if you give that to Python 2.5 then B and C won't work, etc.
The ideal state of affairs would be if program A could live in C:\A along with its own Python interpreter, Qt/Wx/MySQL driver/whatever and never touch anything outside that directory, ditto for B and C.
Is there any way to accomplish this, other than going the full virtual box route?
edit: I tried the batch file solution, but it doesn't work. That is, it works on simple test scripts but e.g. OpenRPG fails at some point in its loading process if its required version of Python doesn't own the file association. | 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 will break things, e.g. you can install different versions of Python side-by-side but only one of them can have the .py file association, so if you give that to Python 2.5 then B and C won't work, etc.
The ideal state of affairs would be if program A could live in C:\A along with its own Python interpreter, Qt/Wx/MySQL driver/whatever and never touch anything outside that directory, ditto for B and C.
Is there any way to accomplish this, other than going the full virtual box route?
edit: I tried the batch file solution, but it doesn't work. That is, it works on simple test scripts but e.g. OpenRPG fails at some point in its loading process if its required version of Python doesn't own the file association. | 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 will break things, e.g. you can install different versions of Python side-by-side but only one of them can have the .py file association, so if you give that to Python 2.5 then B and C won't work, etc.
The ideal state of affairs would be if program A could live in C:\A along with its own Python interpreter, Qt/Wx/MySQL driver/whatever and never touch anything outside that directory, ditto for B and C.
Is there any way to accomplish this, other than going the full virtual box route?
edit: I tried the batch file solution, but it doesn't work. That is, it works on simple test scripts but e.g. OpenRPG fails at some point in its loading process if its required version of Python doesn't own the file association. | 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 helps.
The funny part is that I'm starting with PowerShell on the sending end and Linux at the receiving end. I can use Perl or Python there, with a preference for Python. I don't actually need answers in each language, I'm most interested in a PowerShell (C# also good) example for going both ways. | 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 Python. There are some templating libraries which allow you to go the other way around, somewhat, but that's a completely different issue.
With things like Django or TurboGears or all the other web-frameworks, you essentially set up a small, stand-alone web-server (which comes bundled with the framework so you don't have to do anything), tell the server which function should handle what URL and then write those functions. In the simplest case, each URL you specify has its own function.
That 'handler function' (or 'view function' in Django terminology) receives a request object in which interesting info about the just-received request is contained. It then does whatever processing is required (a DB query for example). Finally, it produces some output, which is returned to the client. A typical way to get the output is to have some data passed to a template where it is rendered together with some HTML.
So, the HTML is separated in a template (in the typical case) and is not in the Python code.
About Python 3: I think you will find that the vast majority of all Python development going on in the world is still with Python 2.*. As others have pointed out here, Python 3 is just coming out, most of the good stuff is not available for it yet, and you shouldn't be bothered about that.
My advise: Grab yourself Python 2.6 and Django 1.1 and dive in. It's fun. | 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 engines for that?)
What modules do I need to install to run .py from my localhost? Googling a bit, it seems there're various methods — mod_python, FastCGI etc.. which one should I use and how to install it with MAMP Pro 1.8.2?
Many thanks | 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 to do your search.
Definitely do compile your regular expressions and do a timing test comparing that with the plain string functions. Check the documentation for the string class for a full list. | 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 matching these words/phrases in the text. My concern, however, is that this will take a lot of time.
My question is how fast is the process of repeatedly compiling regular expressions, and then searching through a small body of text to find matches? Would I be better off using some string method?
Edit: So, I guess an example of my question would be: How expensive would it be to compile and search with one regular expression versus say, iterating 'if "word" in string' say, 5 times? | 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 that.
Furthermore, if you are worried about the speed of actual regex compilation rather than matching, you might benefit from creating a daemon that compiles all the regexes then goes through all the pieces of text in a big loop or runs as a service. This way you will only have to compile the regexes once. | 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 matching these words/phrases in the text. My concern, however, is that this will take a lot of time.
My question is how fast is the process of repeatedly compiling regular expressions, and then searching through a small body of text to find matches? Would I be better off using some string method?
Edit: So, I guess an example of my question would be: How expensive would it be to compile and search with one regular expression versus say, iterating 'if "word" in string' say, 5 times? | 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 matching these words/phrases in the text. My concern, however, is that this will take a lot of time.
My question is how fast is the process of repeatedly compiling regular expressions, and then searching through a small body of text to find matches? Would I be better off using some string method?
Edit: So, I guess an example of my question would be: How expensive would it be to compile and search with one regular expression versus say, iterating 'if "word" in string' say, 5 times? | 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 this includes docs and a lot of non-essential things.
Do you know if there exists a small package of a minimal Python interpreter I can include with my program ? Include a folder of 80MB is a bit big ;) | 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 you can just plunk down and start running. Twisted might meet your needs, though there's a bit more of a learning curve on that. I'm not sure how other python or ruby apps stand up on this front. | 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 (say setup.exe). I want it to be small in size and also should be able to pack all required components in it.
Which one among Python/Django and Ruby On Rails is suitable for me? | 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 have to install Ruby and any required ruby gems. The Ruby install is going to be machine specific- different for Windows/Linux. Everything else should be easily scripted. If you go with an Apache Passenger (mod_ruby) solution, you will need to get that installed as well.
In reality, I haven't run into many server applications with simple, compact installs. | 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 (say setup.exe). I want it to be small in size and also should be able to pack all required components in it.
Which one among Python/Django and Ruby On Rails is suitable for me? | 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 (say setup.exe). I want it to be small in size and also should be able to pack all required components in it.
Which one among Python/Django and Ruby On Rails is suitable for me? | 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 (say setup.exe). I want it to be small in size and also should be able to pack all required components in it.
Which one among Python/Django and Ruby On Rails is suitable for me? | 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) but the application's size is naturally larger given you have to install other gems and Ruby On Rails plugins. | 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 (say setup.exe). I want it to be small in size and also should be able to pack all required components in it.
Which one among Python/Django and Ruby On Rails is suitable for me? | 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 so, retrain the SVM using all the old support vectors, and the new training data that falls in the margin.
Of course, the results can be slightly different compared to batch training on all your data, as some points can be discarded that would be support vectors later on. So again, why do you want to perform online training of you SVM? | 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 creating new objects:
var foo = { bar: "baz" };
Accessing associative array keys in JavaScript can be done using dot notation, in addition to brace notation. That is, these are the same:
foo.bar; //returns "baz"
foo["bar"]; // returns "baz"
Python's anonymous function (lambda) syntax is not as flexible as JavaScript's anonymous functions.
Python has, like, a standard library and stuff. (And yes, I know about Rhino et al., but the libraries they give you are not standard. There's no standardized way to read a file in JavaScript... that I know of.)
You can run JavaScript in a browser. Python... not so much. ;) | 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 floating-point numbers and strings as built-in data types.
These seem like fairly shallow differences to me, so these things aside, what are some more important differences between them? | 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 floating-point numbers and strings as built-in data types.
These seem like fairly shallow differences to me, so these things aside, what are some more important differences between them? | 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 floating-point numbers and strings as built-in data types.
These seem like fairly shallow differences to me, so these things aside, what are some more important differences between them? | 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 libraries and such. | 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 floating-point numbers and strings as built-in data types.
These seem like fairly shallow differences to me, so these things aside, what are some more important differences between them? | 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. JavaScript is all the way unicode, GAE's Python 2.5 not so much (having Latin 1 as the default character set). So having the need to support non-latin characters can be a real PITA if your'e not sure what you are doing. | 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 floating-point numbers and strings as built-in data types.
These seem like fairly shallow differences to me, so these things aside, what are some more important differences between them? | 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 these things? | 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 these things? | 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 these things? | 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 in Python anymore.
- Python is opened to anything. It's really hard to protect / obfuscate / limit Python code.
- Python is not hype. Unlike Ruby, there is no "cool wave" around Python, and it's still much harder to find a experienced Python coder, than, let's say, a Java or a PHP pro.
- After using Python, a lot of languages seems to be a pain to use. You'd think it's good, but believe me, not always. When you have to go Javascript after a Python project, your eyes are in tears for at least 3 days. Really hard to get started.
- It's harder to find web hosting than for popular solutions, such as PHP.
- As a dynamic language, you don't have the very handy refactoring tools you could get with Java and Eclipse or C# and VS.
- For the same reason, you can't rely on type checking as a safety net. This is why pythonistas tend to follow best practice and write unit tests more often than others.
- It seems I just can't find an IDE with a decent code completion. PyDev, Gedit, Komodo, SPE, etc. just don't do it as good as it could be.
With Python 3 types hints and tools like PyCharm or Sublime Text+Anaconda, the situation has changed a lot.
- The best docs are still in English only. Some people don't deal well with it.
- You have to get use to the syntax. Not only you get spaces and line breaks instead of bracets, but you can forget about long lambdas, --i, and ternary operation.
Now, to me, these are not reasons to not learn a tool that will make you produce more while having more fun. But maybe it's just me :-)
Honestly, given that :
C++ much harder to learn;
You can do pretty much any thing you want with Python;
You will get quicker result with Python in your projects.
Unless you have professional issues involving C++, you'd better learn Python first, it's more motivating. You still can learn C++ later, it's a useful language for system programming, embedded devices and such.
Don't try to learn both at the same times, multitasking rarely ends well. | 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 practise, though, when you're working in that context it usually means dropping all the way down C (in its role as portable assembler) rather than being able to use C++ (and its runtime libraries), for much if not all of the code. | 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 address used for memory-mapped I/O might change even though this program doesn’t change it, or to specify the exact layout of an object in memory. It’s designed to run as fast as possible, with as little wasted memory, rather than be safe.
That’s what the comments about “letting you shoot yourself in the foot” are mostly referring to. | 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 abstractions while still having a functional prototype. | 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 learn python then go back to C++, then you will be able to write good C++ code. Of course, that won't mean you will understand bad C++, or C++ code that was written in a non-pythonic way.
Limits to python?
It's interpreted, so you have to ship the source and the interpreter; and processes will take much longer to start up.
It's not C++, so it won't play with existing C++ code.
It's a bit slower (even if you wrap the hot loops in C).*
It encourages you to be "pythonic", and some problems are easier if you are not "pythonic".
*Python might be faster:
Automatic GC. C++ is only faster if it doesn't leak too much.
Dictionaries. Lots of code runs in O(N plus a bit), rather than O(N^2) if you use a dictionary. Sure, you can use a hash table in C++, but not everbody does.
Memory management - the python interpreter caches some of the basic data structures' memory, then reallocates them, rather than hitting the system for new memory. This reduces system calls, which is a very good thing.
Profiling new algorithms is waaaay easier on python. In lots of problems, a better algorithm is more important than a linear speedup (which is what C++ gives you).
If you are making a program that "only runs once" (scientific analysis, data migration, etc), then the compile-build-test cycle should be faster in python. That's what really counts ;) | 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 advanced will require C++.
That being said, go for Python. | 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, has good mileage, cheap to maintain, relatively safe), there is
no logical reason to trade it in for another one. None. Whatsoever.
Drive it to the ground before you even consider what make or model to
get next. But if you are already looking around thinking what car to
get, just go get it, stop asking everybody you know whether you should
do it. If you need to ask, you need to change it. It's as simple as
that. | 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 encoding. If it has to throw away all the trash it does not understand, then that is perfectly fine and is in fact the most desirable result. Why try to salvage all the junk? Just discard the junk. Tell the user he's not merely a moron for using Microsoft anything, but a non-standard moron for using non-standard Microsoft anything...or for attempting to send in binary data!
I have just precisely this same need (though my need is in PHP), and I also have users who are at least as moronic as I am, sometimes moreso; however, they are definitely nicer and no doubt more patient.
The best, bottom-line thing I've found so far is (in PHP 5.3):
$fixed_string = iconv( 'ISO-8859-1', 'UTF-8//IGNORE//TRANSLATE', $in_string );
This attempts to translate whatever it can and simply throws away all the junk, resulting in a legal UTF-8 string output. I've also not been able to break it or cause it to fail or reject any incoming text or data, even by feeding it gobs of binary junk data.
Finding the iconv() and getting it to work is easy; what's so maddening and wasteful is reading through all the total garbage and bend-over-backwards idiocy that so many programmers seem to espouse when dealing with this encoding fiasco. What's become of the enviable (and respectable) "Flail and Burn The Idiots" mentality of old school programming? Let's get back to basics. Use iconv() and throw away their garbage, and don't be bashful when telling them you threw away their garbage -- in short, don't fail to flail the morons who feed you garbage. And you can tell them I told you so. | 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 the leading / must also be ignored -- if the leading piece must be special-cased, that's also feasible of course;-). | 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 this case I know I am targeting the web, not the local file system.
Is there a best alternative when you are working with paths you know will be used in URLs? Will os.path.join work well enough? Should I just roll my own? | 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 difficult to translate to Python? | 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 good old xterm's -e, to specify what program they should run!-). | 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. However, I need to run each instance of node.py on different terminal(shell) so that I can easily debug what is happening inside each node.
How can we do that? Please help.
EDIT : I am working on linux and using python 2.5 and
I want to run all processes on the same box | 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 to RML parser to the project. | 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) determine which Django you'll use. | 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 need to recompile, or find a packaged version for your distribution that uses the updated Python. | 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 able to ignore it.
I'm Ok with writing these checks but I'm curious about where the best place to put them is. How do I get them to execute as part of django's startup process? I thought there might be a signal I could listen too, but I can't find a relevant one in the docs. | 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 able to ignore it.
I'm Ok with writing these checks but I'm curious about where the best place to put them is. How do I get them to execute as part of django's startup process? I thought there might be a signal I could listen too, but I can't find a relevant one in the docs. | 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 able to ignore it.
I'm Ok with writing these checks but I'm curious about where the best place to put them is. How do I get them to execute as part of django's startup process? I thought there might be a signal I could listen too, but I can't find a relevant one in the docs. | 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 the first request made to the we server leading to a potentially long wait for the first user to visit your site.
It is standard practise to call a 'warming' page when bringing large web applications back online so I don't see that calling a start up function from a CLEARLY identified location in the urls.py should be a problem. | 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 able to ignore it.
I'm Ok with writing these checks but I'm curious about where the best place to put them is. How do I get them to execute as part of django's startup process? I thought there might be a signal I could listen too, but I can't find a relevant one in the docs. | 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
LaunchServices is used to open the specified files. | 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 trick. | 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 trick. | 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 runs (again, i don't know windows specific details, but in unix it's possible for everything to work when you run it from your account by hand, but still not work when run as a batch job because the environment is different). | 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.
(translation: It was not possible to find the specified procedure)
*for kinterbasdb:
Traceback (most recent call last):
File "C:\", line 1, in
File "c:\Python26\Lib\site-packages\kinterbasdb__init__.py", line 119, in
import _kinterbasdb as _k
ImportError: DLL load failed: Não foi possível encontrar o módulo especificado.
(translation: It was not possible to find the specified procedure)
I'm using python 2.6.4 in windows XP. cx_Oracle's version is 5.0.2. kinterbasdb's version is 3.3.0.
Edit: I've solved it for cx_Oracle, it was a wrong version problem. But I believe I'm using the correct version, and I downloaded it from the Firebird site ( kinterbasdb-3.3.0.win32-setup-py2.6.exe ). Still need assistance with this, please.
Can anyone lend me a hand here?
Many Thanks
Dante | 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 how amounts are to be rounded in various situations and you should have tests covering each scenario. | 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 up numbers are coming from. | 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","three"]*1000' 'map(lambda x:x.upper(),s)'
1000 loops, best of 3: 1.77 msec per loop | 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 based on this criterion. Basically, if most users of A also need B and vice versa, A and B should probably be in the same module; but if many users will only need one of them and not the other, then they should probably be in distinct modules (perhaps in the same package, i.e., directory with an __init__.py file in it).
The standard Python library, while far from perfect, tends to reflect (mostly) reasonably good practices -- so you can mostly learn from it by example. E.g., the threading module of course defines a Thread class... but it also holds the synchronization-primitive classes such as locks, events, conditions, and semaphores, and an exception-class that can be raised by threading operations (and a few more things). It's at the upper bound of reasonable size (800 lines including whitespace and docstrings), and some crucial thread-related functionality such as Queue has been placed in a separate module, nevertheless it's a good example of what maximum amount of functionality it still makes sense to pack into a single module. | 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 they are formal modules. It doesn't seem right to just have one class in a module --- most classes are useless by themselves. If I have a automobile.py and an Automobile class, it seems silly to always reference it as automobile.Automobile as well.
But, at the same time, it doesn't seem right to throw a ton of code into one file and call it a day. Obviously, a very complex application should have more than 5 files.
What is the correct---or pythonic---way? (Or if there is no correct way, what is your preferred way and why?) How much code should I be throwing in a Python module? | 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 they are formal modules. It doesn't seem right to just have one class in a module --- most classes are useless by themselves. If I have a automobile.py and an Automobile class, it seems silly to always reference it as automobile.Automobile as well.
But, at the same time, it doesn't seem right to throw a ton of code into one file and call it a day. Obviously, a very complex application should have more than 5 files.
What is the correct---or pythonic---way? (Or if there is no correct way, what is your preferred way and why?) How much code should I be throwing in a Python module? | 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 start down that path from a one-class-per-file history is to take the classes that you would normally place in the same directory, and instead keep them in the same file. If that file starts looking too large, split it. | 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 they are formal modules. It doesn't seem right to just have one class in a module --- most classes are useless by themselves. If I have a automobile.py and an Automobile class, it seems silly to always reference it as automobile.Automobile as well.
But, at the same time, it doesn't seem right to throw a ton of code into one file and call it a day. Obviously, a very complex application should have more than 5 files.
What is the correct---or pythonic---way? (Or if there is no correct way, what is your preferred way and why?) How much code should I be throwing in a Python module? | 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 appropriate code for the operation you requested. It's a very general kind of problem; if you're familiar with Ruby at all, the equivalent might be 'rake'.
In particular, PasteDeploy is a configuration format to serve Python webapps using paster. Both PasteScript and PasteDeploy are important for the Pylons web framework. | 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 seems to be able to create pre-made layouts for setuptools/distutils enabled packages.
What is the problem (or set of problems) it's trying to solve? | 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()
File "C:\Documents and Settings\naresh\Desktop\MySQL-python-1.2.3c1
\setup_windows.py", line 7, in get_config
serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key'])
WindowsError: [Error 2] The system cannot find the file specified
What can I do to address this? | 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 usually has error details which is different to the HTML error code) | 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 plaintext solution, as it means the files will be easily readable, and you won't have to mess with different kinds of details (endianity, default double sizes).
But, there are cases where binary is better (for example, if you have a really big list of doubles and space is of importance, or if it is easier for you to parse it and you need the optimization) - but this is likely not your case. | 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 certainly I am missing something. | 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 minutes, step two can add a significant amount of time).
This isn't necessarily the reason python|ruby designers thought of, but keep in mind that "How efficiently does the machine run this?" is only half the software development problem.
It also seems like it would be easier to compile code in a language that's interpreted naturally than it would be to add an interpreter to a language that's compiled by default. | 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 certainly I am missing something. | 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 only advantages of a compiler are type checking (difficult to do in a dynamic language) and speed, there's not much incentive to write compilers for most interpreted languages. | 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 certainly I am missing something. | 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 certainly I am missing something. | 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 interpreted. Say you used translation-to-C as the mechanism. The compiled code would periodically have to check if it had been superseded by metaprogramming. A similar situation arises with eval()-type functions. In those cases, it would have to run the compiler again, an outrageously slow process, or it would have to also have the interpreter around at run-time anyway.
The only alternative here is a JIT compiler. These systems are highly complex and sophisticated and have even bigger run-time footprints than all the other alternatives. They start up very slowly, making them impractical for scripting. Ever seen a Java script? I haven't.
So, you have two choices:
all the disadvantages of both a compiler and an interpreter
just the disadvantages of an interpreter
It's not surprising that generally the primary implementation just goes with the second choice. It's quite possible that some day we may see secondary implementations like compilers appearing. Ruby 1.9 and Python have bytecode VM's; those are ½-way there. A compiler might target just non-dynamic code, or it might have various levels of language support declarable as options. But since such a thing can't be the primary implementation, it represents a lot of work for a very marginal benefit. Ruby already has 200,000 lines of C in it...
I suppose I should add that one can always add a compiled C (or, with some effort, any other language) extension. So, say you have a slow numerical operation. If you add, say Array#newOp with a C implementation then you get the speedup, the program stays in Ruby (or whatever) and your environment gets a new instance method. Everybody wins! So this reduces the need for a problematic secondary implementation. | 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 certainly I am missing something. | 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, or is native machine code - the difference, while not quite negligible, will be dwarfed by lookup overhead.
To really improve performance, you need optimizing compilers. And optimization techniques here are very different from what you have with C++, or even Java JIT - an optimizing compiler for a dynamically typed / duck typed language such as Python needs to do some very creative type inference (including probabilistic - i.e. "90% chance of it being T" and then generating efficient machine code for that case with a check/branch before it) and escape analysis. This is hard. | 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 certainly I am missing something. | 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 dynamic type system in an interpreted language. I think the creators of the language were thinking having a language where programmers can be more productive due to automatic memory management, dynamic type system and meta programming wins over any performance loss due to the language being interpreted. If you are concerned about performance you can always compile the language to native machine code employing a technique like JIT compilation. | 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 certainly I am missing something. | 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 use in any other language (2d array that is).
I'm not that experienced with Python so could someone give me a suggestion? | 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 rate (several hundred per second), since all the new entities have IDs in the same range, they will all be written to the same Bigtable tablet, and can cause contention and increased timeouts. The vast majority of apps never have to worry about this, though.
There's no performance impact to allocating as many IDs as you want - App Engine simply increases the ID counter by the number you request. (This is a simplification, but generally accurate).
In answer to your concerns, App Engine doesn't randomly generate keys. It either uses an auto-allocated id, which is allocated using a counter, and thus guaranteed unique, or it uses the key you supplied. So in answer to your last 3 bullet points:
No.
Only in storage for the (potentially) longer keys
No, and the cost is roughly O(1) regardless of how many you ask for. | 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 used by Google App Engine as auto generated keys? Would generating a large number of these keys result in reduced performance?
These questions both bother me for the following reason. Let us say Google App Engine was attempting to persist entity A, and as such it is creating a key for A. It would seem intuitively, that when a new key is randomly generated, Google App Engine would need to first check if the key was already in existence. If the key already existed, then Google App Engine might need to generate another randomly generated new key. It would continue to do this until it succeeded in generating a unique new key. It would then assign this key to entity A. Alright, that is fine and good.
My problem with this is it seems to imply that keys cause some sort of application level lock? This would be neccesary when Google App Engine is checking if the randomly generated key already exist. This can't be right, as it isn't scalable at all? What is wrong about my reasoning?
So, since this was long, I will re-iterate my 3 questions:
Does Google App Engine create an application level lock when generating new keys?
Do named keys incur any additional cost over automatically generated keys? If so, what cost (constant, linear, exponential,...)?
Does asking app engine for keys that app engine promises not to use cause a degradation in key creation performance? If so, what would the cost for this be? | 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 is to run your application via strace (it is a command line tool, see man strace) and try to search for such an error (13) in its output. It'll show you the exact path involved in the problem. | 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: (13, 'Permission denied')
It points to this line:
{% if results %}
Changing or omitting the line will yield the next (same) error at whichever line that references a field from "results".
The stacktrace shows this exception:
OSError(13, 'Permission denied')
in:
/usr/local/lib/python2.6/dist-packages/django/template/debug.py in render_node
django-debug-toolbar shows for results:
<djapian.resultset.ResultSet object at 0x7f7142affcd0>
Is this an issue with Djapian? In any case, why would it yield a "Permission denied" error? | "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 or is it to general because it depends on what the threads work on? | 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 or is it to general because it depends on what the threads work on? | 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. That won't make your code much slower in the worst case (just one thread) but it can make it much faster if a user has a more powerful PC.
In the worst case, your program will complete less than 100ms later -> people won't notice the slowdown but they will notice the speedup with 8 cores. | 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 or is it to general because it depends on what the threads work on? | 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 impression that NHibernate is glue code between C# and the DB, so can not be exported to other languages.
Alternative question: can somebody recommend a good python compatible replacement of NHibernate ? The backend DB is Oracle something. | 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 impression that NHibernate is glue code between C# and the DB, so can not be exported to other languages.
Alternative question: can somebody recommend a good python compatible replacement of NHibernate ? The backend DB is Oracle something. | 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 what you are looking for.
There is a Java version of NHibernate (said tongue in cheek) called Hibernate and there are integration points between Java and Python where Linux is very much supported.
I know the Python community has its own ORMs, but as far as I'm aware, those options are not as mature and feature rich as Hibernate/NHibernate.
I would imagine that almost all of the options available to you would support Oracle. | 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 impression that NHibernate is glue code between C# and the DB, so can not be exported to other languages.
Alternative question: can somebody recommend a good python compatible replacement of NHibernate ? The backend DB is Oracle something. | 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 are on a Rackspace cloud with 256 MB memory. Nothing else is running. | 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 are on a Rackspace cloud with 256 MB memory. Nothing else is running. | 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 on my Mac. Ideas? | 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 your first widgets, then notice the problems with your current architecture, and re factor. Start again, until you have something stable and usable.
Eventually, find out this was nice as training experience, but useless as a contribution to the software communities since you will never reach out the qualities of existing tools.
Then give up and try to code your own MMORPG. | 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 dirty buffer writes.
At no time is anything lost or corruptable. The only glitch can happen during the renames. But you haven't lost anything or corrupted anything. The original is recoverable right up until the final rename. | 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 way.
Overwriting the existing file (starting to write to the original file) is obviously not safe. If the write method fails before it is done you end up with a half written file and you have lost data.
A better option would be to write to a temporary file somewhere, and when the write method has finished, you copy the temporary file to the original file.
Now, if the copy somehow fails, you still have correctly saved data in the temporary file. And if the copy succeeds, you can remove the temporary file.
On POSIX systems I guess you can use the rename system call which is an atomic operation. But how would you do this best on a Windows system? In particular, how do you handle this best using Python?
Also, is there another scheme for safely writing to files? | 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
rename abc.xml to abc.xml.bak
rename abc.xml.tmp to abc.xml
after new abc.xml is properly put in place, remove abc.xml.bak
As you can see that you have the abc.xml.bak with you which you can use to restore if there are any issues related with the tmp file and of copying it back. | 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 way.
Overwriting the existing file (starting to write to the original file) is obviously not safe. If the write method fails before it is done you end up with a half written file and you have lost data.
A better option would be to write to a temporary file somewhere, and when the write method has finished, you copy the temporary file to the original file.
Now, if the copy somehow fails, you still have correctly saved data in the temporary file. And if the copy succeeds, you can remove the temporary file.
On POSIX systems I guess you can use the rename system call which is an atomic operation. But how would you do this best on a Windows system? In particular, how do you handle this best using Python?
Also, is there another scheme for safely writing to files? | 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 them? I would guess that the modification you're making to the delete function in webdriver-read-only\firefox\src\extension\components\firefoxDriver.js could break the delete function. Are you doing it just for debugging or do you actually want the browser itself to show a pop up when the driver tells it to delete cookies? It wouldn't surprise me if this modification broke.
My real advice though would be actually to start using Selenium instead of Webdriver since it's being discontinued in it's current incarnation, or morphed into Selenium. Selenium is more actively developed and has pretty active and responsive forms. It will continue to be developed and stable while the merge is happening, while I take it Webdriver might not have as many bugfixes going forward. I've had success using the Selenium commands that control cookies. They seem to be revamping their documentation and for some reason there isn't any link to the Python API, but if you download selenium rc, you can find the Python API doc in selenium-client-driver-python, you'll see there are a good 5 or so useful methods for controlling cookies, which you use in your own custom Python methods if you want to, say, delete all the cookies with a name matching a certain regexp. If for some reason you do want the browser to alert() some info about the deleted cookies too, you could do that by getting the cookie names/values from the python method, and then passing them to selenium's getEval() statement which will execute arbitrary js you feed it (like "alert()"). ... If you do go the selenium route feel free to contact me if you get a blocker, I might be able to assist. | 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-d547-43a8-a01e-a504e617cfc1}", "parameters": [], "commandName": "getCookie"}
response:Length: 266
{"commandName":"getCookie","isError":true,"response":{"lineNumber":576,"message":"Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMLocation.host]","name":"NS_ERROR_FAILURE"},"elementId":"null","context":"{9b44672f-d547-43a8-a01e-a504e617cfc1} "}
How can I fix it?
Update:
This happens with clean installation of webdriver with no modifications. The changes I've mentioned in another post were made later than this post being posted (I was trying to fix the issue myself). | 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 (authentication/authorisation, session stuff, caching, filtering)
ease of deployment on non-Apache webservers either via native WSGI support or flup
[1] - compared to a preforking Apache, which maintains a separate Python interpreter in each process | 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 another user than the web server. This can be valuable for security, if used right.
b) The web server processes does not need to contain the python runtime. This can be a major boost for performance if the server runs a lot of "other" requests (static files, etc) and some heavy python requests. | 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 separation of web server and web application code and a system administrator can change the web server as long as the web application is WSGI compliant. If you are developing in one of these frameworks, you would anyway be satisfying this condition.
If you are a web framework developer (that is developing DJango or Zope itself), then you have to understand WSGI in more depth. | 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 in grave danger.
Beyond the obvious os.chmod, what techniques folks use to keep your compiled python secure on disk? | 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 database, add a field "session_id" and then when the user logs in, set that to their current session_id. On every page load check to see if their current session matches the session_id in the users table. Remember whenever you regenerate their session_id in your application, you'll need to update the database so they don't get logged out.
Some people when a user logs in, just store all the users details into a session and never re-call the database on a new page load. So for some this "extra" SQL query might seem wrong. For me, I always do a new query on each page load to re-authenticate the user and make sure their account wasn't removed/suspended and to make sure their username/password combo is still the same. (What if someone from another location changed the password, or an administrator?) | 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 prefix r -- that's exactly what denotes a raw string literal, the specific syntax that identifies such a constant to the Python compiler), or else double up any backslashes in them (an alternative way to specify constant strings including backslash characters), but that has nothing to do with "getting" them one way or another. | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.