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
2,313,053
2010-02-22T18:17:00.000
2
0
0
1
python,linux,path
2,313,168
4
false
0
0
It's important to remember: use of the tilde ~ expands the home directory as per Poke's answer use of the forward slash / is the separator for linux / *nix directories by default, *nix systems such as linux for example has a wild card globbing in the shell, for instance echo *.* will return back all files that match the asterisk dot asterisk (as per Will McCutcheon's answer!)
1
3
0
Using Python, how does one parse/access files with Linux-specific features, like "~/.mozilla/firefox/*.default"? I've tried this, but it doesn't work. Thanks
Python: How to Access Linux Paths
0.099668
0
1
7,357
2,313,307
2010-02-22T18:54:00.000
1
0
0
0
python,mysql,macos
9,170,459
4
false
0
0
If the problem is the inability, as so many people have mentioned, that the msqldb module is a problem a simpler way is 1. install the mysql db 2. install the pyodbc module 3. Load and configure the odbc mysql driver 4. perform sql manipulations with pyodbc, which is very mature and full functional. hope this helps
1
3
0
Is there another way to connect to a MySQL database with what came included in the version of Python (2.5.1) that is bundled with Mac OS 10.5.x? I unfortunately cannot add the the MySQLdb module to the client machines I am working with...I need to work with the stock version of Python that shipped with Leopard.
Python: Access a MySQL db without MySQLdb module
0.049958
1
0
3,698
2,314,178
2010-02-22T21:04:00.000
1
0
0
0
python,sql,sql-server
2,314,282
4
false
0
0
ODBC + freetds + a python wrapper library for ODBC.
1
26
0
What is the best way to access sql server from python is it DB-API ? Also could someone provide a such code using the DB-API how to connect to sql server from python and excute query ?
Python & sql server
0.049958
1
0
28,195
2,314,181
2010-02-22T21:05:00.000
1
0
1
0
python,operators
2,314,211
5
false
0
0
Bit shifting an integer gives another integer. For instance, the number 12 is written in binary as 0b1100. If we bit shift by 1 to the right, we get 0b110 = 6. If we bit shift by 2, we get 0b11 = 3. And lastly, if we bitshift by 3, we get 0b1 = 1 rather than 1.5. This is because the bits that are shifted beyond the register are lost. One easy way to think of it is bitshifting to the right by N is the same as dividing by 2^N and then truncating the result.
1
3
0
I've never used the >> and << operators, not because I've never needed them, but because I don't know if I could have used them, or where I should have. 100 >> 3 outputs 12 instead of 12.5. Why is this. Perhaps learning where to best use right shift will answer that implicitly, but I'm curious.
Python: Why does right shift >> round down and where should it be used?
0.039979
0
0
5,773
2,314,307
2010-02-22T21:22:00.000
2
0
0
0
python,database,logging
46,617,613
5
false
0
0
Old question, but dropping this for others. If you want to use python logging, you can add two handlers. One for writing to file, a rotating file handler. This is robust, and can be done regardless if the dB is up or not. The other one can write to another service/module, like a pymongo integration. Look up logging.config on how to setup your handlers from code or json.
1
48
0
I'm seeking a way to let the python logger module to log to database and falls back to file system when the db is down. So basically 2 things: How to let the logger log to database and how to make it fall to file logging when the db is down.
python logging to database
0.07983
1
0
48,780
2,315,032
2010-02-22T23:18:00.000
1
0
1
0
python
2,315,052
9
false
0
0
Put the dates in a set and then iterate from the first date to the last using datetime.timedelta(), checking for containment in the set each time.
1
23
0
In Python how do I find all the missing days in a sorted list of dates?
How do I find missing dates in a list of sorted dates?
0.022219
0
0
16,151
2,315,151
2010-02-22T23:43:00.000
2
0
0
0
python,http,asynchronous,cookies
2,317,612
1
true
0
0
Using httplib and urllib2, the requests are synchronous unless I use thread, in which case the order is not guaranteed to be respected How would you know that the order has been respected unless you get your response back from the first connection before you send the response to the second connection? After all, you don't care what order the responses come in, so it's very possible that the responses come back in the order you expect but that your requests were processed in the wrong order! The only way you can guarantee the ordering is by waiting for confirmation that the first request has successfully arrived (eg. you start receiving the response for it) before beginning the second request. You can do this by not launching the second thread until you reach the response handling part of the first thread.
1
1
0
I am coding a python (2.6) interface to a web service. I need to communicate via http so that : Cookies are handled automatically, The requests are asynchronous, The order in which the requests are sent is respected (the order in which the responses to these requests are received does not matter). I have tried what could be easily derived from the build-in libraries, facing different problems : Using httplib and urllib2, the requests are synchronous unless I use thread, in which case the order is not guaranteed to be respected, Using asyncore, there was no library to automatically deal with cookies send by the web service. After some googling, it seems that there are many examples of python scripts or libraries that match 2 out of the 3 criteria, but not the 3 of them. I am thinking of reading through the cookielib sources and adapting what I need of it to asyncore (or only to my application in a ad hoc manner), but it seems strange that nothing like this exists yet, as I guess I am not the only one interested. If anyone knows of pointers about this problem, it would be greatly appreciated. Thank you. Edit to clarify : What I am doing is a local proxy that interfaces my IRC client with a webchat. It creates a socket that listens to IRC connections, then upon receiving one, it logs in the webchat via http. I don't have access to the behaviour of the webchat, and it uses cookies for session IDs. When client sends several IRC requests to my python proxy, I have to forward them to the webchat's server via http and with cookies. I also want to do this asynchronously (I don't want to wait for the http response before I send the next request), and currently what happens is that the order in which the http requests are sent is not the order in which the IRC commands were received. I hope this clarifies the question, and I will of course detail more if it doesn't.
Python: Asynchronous http requests sent in order with automatic handling of cookies?
1.2
0
1
1,531
2,315,187
2010-02-22T23:51:00.000
3
0
0
0
python,django,django-comments
3,269,190
4
false
1
0
I just ran into this problem. Just re-implementing the logic in comments app's delete view would couple your implementation to that specific version of the comments app. For example the comment app actual also handles signals when you mark something as deleted and the provided version doesn't do that. Fortunately the comments app provides a function which implement the core delete logic with out any permissions. Using it ties yourself to the internal details, but it does so in a very specific way which will either break or work, it won't ever half work. You can create your own view with its own security model and then call the provided comment app function (from django.contrib.comments.views.moderation import perform_delete) The code would look something like this: @login_required def delete_my_comment(request, comment_id, next=None): comment = get_object_or_404(comments.get_model(), pk=comment_id) if comment.user == request.user: if request.method == "POST": perform_delete(request, comment) return redirect("your_view", comment.content_object.id) else: return render_to_response('comments/delete.html', {'comment': comment, "next": next}, RequestContext(request)) else: raise Http404 You details will vary base on your use case. I have gone through a few variations (which you can see in this comment's history), and I think this one is better in all ways than the original solution offered here.
1
7
0
I am using the delete() function from django.contrib.comments.views.moderation module. The staff-member is allowed to delete ANY comment posts, which is completely fine. However, I would also like to give registered non-staff members the privilege to delete their OWN comment posts, and their OWN only. How can I accomplish this?
Allowing users to delete their own comments in Django
0.148885
0
0
5,562
2,316,368
2010-02-23T05:41:00.000
-1
0
1
1
python,printing,python-3.x
68,132,714
2
false
0
0
With the OS module you can print files in Windows or higher.
1
15
0
I have a Python 3 script that is going to be doing some regex substitution on some Rich Text Files (rtf) and I would like to be able to print out a whole directory's files on Windows, Linux, and Mac. Is there a way to print to the OS's default printer so that it works in all platforms?
How do I print to the OS's default printer in Python 3 (cross platform)?
-0.099668
0
0
13,805
2,317,653
2010-02-23T11:27:00.000
2
0
1
0
asp.net,ironpython
2,323,354
2
true
0
0
When you compile IronPython code it doesn't get compiled to normal .NET code where you'd have a class at the IL level for each class you have at the source level. Instead it gets compiled into the same form that we compile to internally using the DLR. For user code this is just a bunch of executable methods. There's one method for each module, function definition, and class definition. When the module code runs it executes against a dictionary. Depending on what you do in the module the .NET method may publish into the dictionary a: PythonType for new-style classes An OldClass for old-style classes A PythonFunction object for function definitions Any values that you assign to (e.g. Foo=42) Any side effects of doing exec w/o providing a dictionary (e.g. exec "x=42") etc... The final piece of the puzzle is where is this dictionary stored and how do you get at it? The dictionary is stored in a PythonModule object and we create it when the user imports the pre-compiled module and then we execute the module against it. Therefore this code is only available via Python's import statement (or the extension method on ScriptEngine "ImportModule" which is exposed via IronPython.Hosting.Python class). So all of the layout of the code is considered an internal implementation detail which we reserve the right to change at any point in time. Finally the name DLRCachedCode comes because the DLR (outer layer) saves this code for us. Multiple languages can actually be saved into a single DLL if someone really wanted to.
1
2
0
when I compile some .py codefiles with no class definitions into dlls , the compiled dll is created with a "DRLCachedCode" class inside. Why is that?
why are some IronPython dlls generated with a DLRCachedCode class inside?
1.2
0
0
477
2,317,921
2010-02-23T12:08:00.000
2
1
0
0
php,python,object,ipython
2,317,942
4
false
0
0
dir(object) will give you all its attribute names.
1
1
0
Is there a way to get PHP-like print_r(object) funcionality in iPython? I know I can use '?' to get info about an object, but how do I view the values of the object?
print_r functionality in iPython
0.099668
0
0
497
2,318,044
2010-02-23T12:29:00.000
0
1
1
0
python,ruby,module,metaprogramming
2,318,065
3
false
0
0
Classes are not added to a global registry in Python by default. You'll need to iterate over all imported modules and look for it.
1
1
0
I've a name of a class stored in var, which I need to create an object from. However I do not know in which module it is defined (if I did, I would just call getattr(module,var), but I do know it's imported. Should I go over every module and test if the class is defined there ? How do I do it in python ? What if I have the module + class in the same var, how can I create an object from it ? (ie var = 'module.class') Cheers, Ze
Python equivalent for Ruby's ObjectSpace?
0
0
0
389
2,318,335
2010-02-23T13:16:00.000
2
0
0
0
wpf,nltk,ironpython
2,320,322
1
false
0
1
It definitely is possible, as long as NLTK doesn't use any C extensions. It will be much easier if you use VS2010 though, because of the dynamic keyword. Look at the Microsoft.Scripting.Hosting library from IronPython, it will get you started towards loading the NLTK code and executing methods on it.
1
5
0
I would like to use NLTK (Natural Language Toolkit) for Python using IronPython and call from an exisiting WPF/c# project. Is it possible to reference NLTK from within WPF in this way. For example to use Named Entity Recognition from NTLK? Any advice or guidance appreciated.
NLTK in IronPython from WPF
0.379949
0
0
1,242
2,319,909
2010-02-23T16:37:00.000
3
0
0
0
python,m2crypto
2,321,344
2
true
0
0
Setting SSL.Connection.clientPostConnectionCheck = None does bypass the WrongHost check, but it also bypasses many other checks that you probably don't want to bypass (such as checking if there is any certificate at all). I would recommend using a try/except combo to catch the WrongHost because there isn't really anything else that is checked or performed before the end of the connect function. In other words, nothing is left undone (as far as I can see in the source) by just catching this exception, and therefore I say that it is a better route than using SSL.Connection.clientPostConnectionCheck = None which gets rid of a lot of other valuable checks. As far as the error when making the xmlrpc call, I can't say for sure without knowing what the error is. I'm guessing that it is the ProtocolError exception and if that is the case you can just edit m2xmlrpclib.py to not raise an exception with the errcode that is listed in the ProtocolError exception you are getting.
1
3
0
I am using M2Crypto 0.20.2 and python 2.4.3. I connect to the server with the fully qualified domain name. The common name in the server certificate does not use the FQDN so I get this error: M2Crypto.SSL.Checker.WrongHost: Peer certificate commonName does not match host How do I override the post connection check of the host name? Thanks!
M2Crypto: Override Post Connection Check of HostName
1.2
0
0
2,431
2,320,210
2010-02-23T17:20:00.000
0
1
1
0
python,unit-testing,testing,dependency-injection
2,320,900
6
false
0
0
I know it's the typical use case for mock objects, but that's also an old argument... are Mock objects necessary at all or are they evil ? I'm on the side of those who believe mocks are evil and would try to avoid changing tested code at all. I even believe such need to modify tested code is a code smell... If you wish to change or intercept an internal function call for testing purpose you could also make this function an explicit external dependency set at instanciation time that would be provided both by your production code and test code. If you do that the problem disappear and you end up with a cleaner interface. Note that doing that there is not need to change the tested code at all neither internally nor by the test being performed.
1
10
0
In general I want to disable as little code as possible, and I want it to be explicit: I don't want the code being tested to decide whether it's a test or not, I want the test to tell that code "hey, BTW, I'm running a unit test, can you please not make your call to solr, instead can you please stick what you would send to solr in this spot so I can check it". I have my ideas but I don't like any of them, I am hoping that there's a good pythonic way to do this.
In Python, what's a good pattern for disabling certain code during unit tests?
0
0
0
2,347
2,321,813
2010-02-23T21:19:00.000
0
1
0
0
python,post,get,webserver,simplehttpserver
8,673,542
3
false
1
0
have you considered using CGIHTTPServer instead of SimpleHTTPServer? Then you can toss your scripts in cgi-bin and they'll execute. You have to include content-type header and whatnot but if you're looking for quick and dirty it's real convenient
1
1
0
I know that with the SimpleHTTPServer I can make my directories accessible by web-browsers via Internet. So, I run just one line of the code and, as a result, another person working on another computer can use his/her browser to see content of my directories. But I wander if I can make more complicated things. For example, somebody uses his/her browser to load my Python program with a set of parameter (example.py?x=2&y=2) and, as a result, he/she sees the HTML page generated by the Python program (not the Python program). I also wander if I can process html form submitted to the SimpleHTTPServer.
Is it possible to write dynamic web pages in Python with the Really Simple HTTP Server?
0
0
0
7,811
2,322,176
2010-02-23T22:15:00.000
1
0
0
0
python,portability,forward-compatibility
2,322,212
4
false
0
0
"2.6 would be better, but it seems like lots of libraries are still porting over to that" What? What libraries -- that you need -- are "still porting over to that"? "3.1 would be the best" "but I'm finding that lots of libraries/frameworks don't support" Correct. You've stated that twice in the question. That's very clear. "Should I just use 2.6 and deal with any issues" What issues? Do you have any specific concerns? It seems to work really, really well. What are your specific concerns?
4
3
0
Currently I have Python 3.1.1 installed on my system, same version on my server with WSGI 3.0 running on Apache 2.2. I want to keep using Python 3.1, but I'm finding that lots of libraries/frameworks don't support it yet, namely Django, Pylons, MySQLdb, etc. I also checked an account I have on a friend's server, and it is running Python 2.3.4... I want to write a sort of blog/forum type application that I can expand into a CMS, and eventually write related desktop applications for, as sort of a long-term pet project. I'd like to use the newest version of Python possible for best security and highest consistency with the desktop-applications-to-be, while still maintaining a good level of portability, and supporting most of the frameworks and libraries I will use. But I'm lost on which one I should pick. It seems like 2.4 would have the greatest amount of portability but it's sort of old, and I don't want to wind up using a bunch of post-2.4 features that won't compile, and having to re-write with messier code to compensate for it. 2.6 would be better, but it seems like lots of libraries are still porting over to that, and 3.1 would be the best since it eliminates a lot of cruft from the language. One thing I'd like to highlight is that it'd be nice to know what I will be missing if I choose an older version of Python. For example, if I were to need my application to run on my old Python 2.3.4 account on my friend's server, what libraries/features would I be lacking that exist in newer versions? What problems would I surely run into that would make me wish I was using Python 2.6 or 3.1? Which of these features would be available via __future__ imports? So, what would be the best direction to go? Should I just use 2.6 and deal with any issues? Should I go for 2.4 to maximize my ability to possibly distribute it to shared hosting environments? Or should I just jump into 3.1 and have a slightly-crippled application until libraries like MySQLdb catch up?
What version of Python should I be using to develop web applications?
0.049958
0
0
209
2,322,176
2010-02-23T22:15:00.000
2
0
0
0
python,portability,forward-compatibility
2,322,228
4
true
0
0
Begin with Python 2.5 if you're not sure. Have a look at Google App Engine (based on Django). It's using Python 2.5 and it's free. However, you will not be able to call scipy (for example) or any libraries with "C" inside. You will have the greatest amount of portability with Python2.5. Moreover, python3k is not really used in the industry.
4
3
0
Currently I have Python 3.1.1 installed on my system, same version on my server with WSGI 3.0 running on Apache 2.2. I want to keep using Python 3.1, but I'm finding that lots of libraries/frameworks don't support it yet, namely Django, Pylons, MySQLdb, etc. I also checked an account I have on a friend's server, and it is running Python 2.3.4... I want to write a sort of blog/forum type application that I can expand into a CMS, and eventually write related desktop applications for, as sort of a long-term pet project. I'd like to use the newest version of Python possible for best security and highest consistency with the desktop-applications-to-be, while still maintaining a good level of portability, and supporting most of the frameworks and libraries I will use. But I'm lost on which one I should pick. It seems like 2.4 would have the greatest amount of portability but it's sort of old, and I don't want to wind up using a bunch of post-2.4 features that won't compile, and having to re-write with messier code to compensate for it. 2.6 would be better, but it seems like lots of libraries are still porting over to that, and 3.1 would be the best since it eliminates a lot of cruft from the language. One thing I'd like to highlight is that it'd be nice to know what I will be missing if I choose an older version of Python. For example, if I were to need my application to run on my old Python 2.3.4 account on my friend's server, what libraries/features would I be lacking that exist in newer versions? What problems would I surely run into that would make me wish I was using Python 2.6 or 3.1? Which of these features would be available via __future__ imports? So, what would be the best direction to go? Should I just use 2.6 and deal with any issues? Should I go for 2.4 to maximize my ability to possibly distribute it to shared hosting environments? Or should I just jump into 3.1 and have a slightly-crippled application until libraries like MySQLdb catch up?
What version of Python should I be using to develop web applications?
1.2
0
0
209
2,322,176
2010-02-23T22:15:00.000
4
0
0
0
python,portability,forward-compatibility
2,322,329
4
false
0
0
For now, Python 3 is not widely deployed in production. Depends on what you use Python for. If it's just for one off scripts, it will be ok either way, if the idea is to use third party modules, C modules and or deploy painlessly, then settle for any of the 2.4+ versions. Many projects strive to keep 2.3 compativility, but you shouldn't have any problems to use 2.4-2.6, as the changes in the language are minor. If you can, use 2.6, as it's the closest to Python 3, as it has some features backported to it. The problem with Python 3 is a Catch 22: most useful third party modules are still not ported to 3, as developers are waiting for wide usage, people can't migrate because modules they rely on haven't migrated yet, keeping the sage low. You should not have any problems using any of the 2.4-2.6, give 3, some time. Use Python 2.6
4
3
0
Currently I have Python 3.1.1 installed on my system, same version on my server with WSGI 3.0 running on Apache 2.2. I want to keep using Python 3.1, but I'm finding that lots of libraries/frameworks don't support it yet, namely Django, Pylons, MySQLdb, etc. I also checked an account I have on a friend's server, and it is running Python 2.3.4... I want to write a sort of blog/forum type application that I can expand into a CMS, and eventually write related desktop applications for, as sort of a long-term pet project. I'd like to use the newest version of Python possible for best security and highest consistency with the desktop-applications-to-be, while still maintaining a good level of portability, and supporting most of the frameworks and libraries I will use. But I'm lost on which one I should pick. It seems like 2.4 would have the greatest amount of portability but it's sort of old, and I don't want to wind up using a bunch of post-2.4 features that won't compile, and having to re-write with messier code to compensate for it. 2.6 would be better, but it seems like lots of libraries are still porting over to that, and 3.1 would be the best since it eliminates a lot of cruft from the language. One thing I'd like to highlight is that it'd be nice to know what I will be missing if I choose an older version of Python. For example, if I were to need my application to run on my old Python 2.3.4 account on my friend's server, what libraries/features would I be lacking that exist in newer versions? What problems would I surely run into that would make me wish I was using Python 2.6 or 3.1? Which of these features would be available via __future__ imports? So, what would be the best direction to go? Should I just use 2.6 and deal with any issues? Should I go for 2.4 to maximize my ability to possibly distribute it to shared hosting environments? Or should I just jump into 3.1 and have a slightly-crippled application until libraries like MySQLdb catch up?
What version of Python should I be using to develop web applications?
0.197375
0
0
209
2,322,176
2010-02-23T22:15:00.000
0
0
0
0
python,portability,forward-compatibility
6,686,801
4
false
0
0
For intranet web apps I had to install python 2.5 (due to combination of wiki, bug tracker, and httpd WSGI compatibility). For custom web apps I standardized on python 3.2. Thus I have both installed simultaneously. I write for 3.2 and bring specific libraries up to spec as needed. However large packages which I don't want to modify use their own 2.5. Compatibility between 3.2 and 3rd party packages is still an issue at this time, and so is the lack of proper python recipes. In summary: Install two versions.
4
3
0
Currently I have Python 3.1.1 installed on my system, same version on my server with WSGI 3.0 running on Apache 2.2. I want to keep using Python 3.1, but I'm finding that lots of libraries/frameworks don't support it yet, namely Django, Pylons, MySQLdb, etc. I also checked an account I have on a friend's server, and it is running Python 2.3.4... I want to write a sort of blog/forum type application that I can expand into a CMS, and eventually write related desktop applications for, as sort of a long-term pet project. I'd like to use the newest version of Python possible for best security and highest consistency with the desktop-applications-to-be, while still maintaining a good level of portability, and supporting most of the frameworks and libraries I will use. But I'm lost on which one I should pick. It seems like 2.4 would have the greatest amount of portability but it's sort of old, and I don't want to wind up using a bunch of post-2.4 features that won't compile, and having to re-write with messier code to compensate for it. 2.6 would be better, but it seems like lots of libraries are still porting over to that, and 3.1 would be the best since it eliminates a lot of cruft from the language. One thing I'd like to highlight is that it'd be nice to know what I will be missing if I choose an older version of Python. For example, if I were to need my application to run on my old Python 2.3.4 account on my friend's server, what libraries/features would I be lacking that exist in newer versions? What problems would I surely run into that would make me wish I was using Python 2.6 or 3.1? Which of these features would be available via __future__ imports? So, what would be the best direction to go? Should I just use 2.6 and deal with any issues? Should I go for 2.4 to maximize my ability to possibly distribute it to shared hosting environments? Or should I just jump into 3.1 and have a slightly-crippled application until libraries like MySQLdb catch up?
What version of Python should I be using to develop web applications?
0
0
0
209
2,322,342
2010-02-23T22:47:00.000
11
0
1
0
python
2,322,387
2
true
0
0
The only time I know that you have to manually raise StopIteration is when you are implementing a next() method on a class to signal that the iterator is terminated. For generators (functions with yield statements in them), the end of the function or a return statement will properly trigger the StopIteration for you.
1
8
0
Should a Python generator raise an exception when there are no more elements to yield? Which one?
Should a Python generator raise an exception when there are no more elements to yield?
1.2
0
0
2,366
2,322,355
2010-02-23T22:48:00.000
-1
0
1
0
python,operators,splat
5,942,664
9
false
0
0
I call *args "star args" or "varargs" and **kwargs "keyword args".
3
247
0
What is the correct name for operator *, as in function(*args)? unpack, unzip, something else?
proper name for python * operator?
-0.022219
0
0
139,156
2,322,355
2010-02-23T22:48:00.000
18
0
1
0
python,operators,splat
2,322,491
9
false
0
0
I say "star-args" and Python people seem to know what i mean. ** is trickier - I think just "qargs" since it is usually used as **kw or **kwargs
3
247
0
What is the correct name for operator *, as in function(*args)? unpack, unzip, something else?
proper name for python * operator?
1
0
0
139,156
2,322,355
2010-02-23T22:48:00.000
124
0
1
0
python,operators,splat
2,323,312
9
false
0
0
I call it "positional expansion", as opposed to ** which I call "keyword expansion".
3
247
0
What is the correct name for operator *, as in function(*args)? unpack, unzip, something else?
proper name for python * operator?
1
0
0
139,156
2,322,868
2010-02-24T00:34:00.000
3
0
1
0
python,python-2.6,python-2.x
2,322,892
3
false
0
0
As the other people say, just ask for input to get it to hold. However, I would recommend running your Python scripts in a different manner in Windows. Using the IDLE IDE (should have come with your distribution), just open the script you want to run and press F5. Then, not only can you see the output for as long as you like, but you can also examine any variables that were assigned interactively. This is very handy especially when you are just starting to program in Python. You can also run scripts from the command line, but I would recommend use IDLE if you're just starting out.
3
3
0
I'm new to programming, especially Python. I'm trying to make an application that converts Fahrenheit to Celsius, but I don't know how to make the program stay open. Whenever it reaches the end of the code, it automatically closes before the user can see his or her results. I'm using Python 2.6.
How do I prevent my Python application from automatically closing once reaching the end of code?
0.197375
0
0
25,629
2,322,868
2010-02-24T00:34:00.000
0
0
1
0
python,python-2.6,python-2.x
2,322,884
3
false
0
0
ask user to enter one more variable and print "Press enter to exit..."
3
3
0
I'm new to programming, especially Python. I'm trying to make an application that converts Fahrenheit to Celsius, but I don't know how to make the program stay open. Whenever it reaches the end of the code, it automatically closes before the user can see his or her results. I'm using Python 2.6.
How do I prevent my Python application from automatically closing once reaching the end of code?
0
0
0
25,629
2,322,868
2010-02-24T00:34:00.000
10
0
1
0
python,python-2.6,python-2.x
2,322,878
3
false
0
0
Well, I guess you mean the terminal that Windows opens for you when you run a python file is closed too fast. You can add raw_input('Press Enter to exit') right before your program would exit. It tells Python to wait for input before exiting.
3
3
0
I'm new to programming, especially Python. I'm trying to make an application that converts Fahrenheit to Celsius, but I don't know how to make the program stay open. Whenever it reaches the end of the code, it automatically closes before the user can see his or her results. I'm using Python 2.6.
How do I prevent my Python application from automatically closing once reaching the end of code?
1
0
0
25,629
2,323,332
2010-02-24T02:47:00.000
3
0
1
0
python,floating-accuracy
2,323,355
4
false
0
0
If you want to compare two floats, you can compare on abs(a-b) < epsilon where epsilon is your precision requirement.
1
2
0
Using numpy or python's standard library, either or. How can I take a value with several decimal places and truncate it to 4 decimal places? I only want to compare floating point numbers to their first 4 decimal points.
How to calculate a value to a certain number of decimal places?
0.148885
0
0
863
2,323,371
2010-02-24T02:59:00.000
1
0
0
0
python,django,actionscript-3
2,323,428
1
true
1
0
I've used firebug to debug the flex side of things. But I've been using json or XML for communication between the two. Since flash uses the browser to do the network stuff, the request should be visible in the net tab of firebug. To debug the django side of things, you have a few options. If you're using the django dev server, you can add print statements to find out what's going on. You can write a unit test to see if the django side of things is doing what you expect it to, given known data. You can use the pyDev debugger to run the django dev server and step through your code. I use a combination of these to debug my code.
1
0
0
I love django, and I like flex. Django for it's cool debugging system (those yellow pages helps a lot to find bugs in my code), and flex for it possibilities. Recently I come across a problem. If I create a form in flex and then communicate with the django server, I can't see any debugging info (when the exception happens in django). Not sure, if there is a way to get the debugging info, because it is not accessible in command line (no error output), or in firebug.... Also I tried to create a quick html form, and post same data as I send from flex form, but it's a bit of pain to be honest. Will be happy to listen how do you solve the problem
django+flex: Debugging strategies
1.2
0
0
111
2,325,150
2010-02-24T10:19:00.000
1
0
0
0
python,django,permissions,django-admin,admin
2,325,199
1
true
1
0
If you make sure that User 2 has no permissions for any model related to the app you want to hide away (so no change, add or delete powers for any of the models in that app), then it won't appear in the admin for User 2.
1
0
0
I'm starting to learn Django and I have a question. Is there any way to restric views in the administration interface? I see there are "change, "add" and "delete" permissions, but I wanted to restrict views also. For example: Two users, "User 1" is superuser and "User 2" is in the editor group. User 1 has access to everything, but User 2 can't view a determined application in the administration. Is that possible?
Django admin - Restrict user view by permission
1.2
0
0
2,577
2,325,938
2010-02-24T12:32:00.000
0
1
0
0
python,chat,irc
2,325,967
3
false
0
0
My guess is that you are looking for a IRC channel? well this is not related to programming so you should not be posting that question here? any way quakenet has a python channel
1
1
0
Is there an active Python-Chat?
Is there an active Python-Chat?
0
0
0
465
2,325,971
2010-02-24T12:37:00.000
1
1
0
0
asp.net,ironpython
2,326,011
1
true
1
0
since iron python compiles to IL I would imagine you can use the same obfuscations tools such as DotFuscator. Are you using the pyc tool included in iron pythons tool folder?
1
0
0
do you know/have you tried any code protection system which works with IronPython assemblies? Can you list it/them here?
Code protection system which works with IronPython assemblies?
1.2
0
0
159
2,326,359
2010-02-24T13:42:00.000
3
0
1
0
python
2,326,647
5
false
0
0
You can't add a constant to a tuple because tuples are immutable. You can however create a new tuple from the old one by incrementing it's values. See jae's answer for the basics of how to do this. You should note however that you will be creating a lot of new tuples in this loop and this may not be a very efficient way of handling this. You should investigate numpy (as suggested by nikow) or perhaps using lists or coordinate objects instead of tuples.
1
1
0
I have a list of tuples (each tuple item is a pair of integers) and I would like to add a constant value to each tuple in the list. For example [(x0,y0),(x1,y1),...] -> [(x0+xk,y0+yk),(x1+xk,y1+yk)....] xk,yk are constants How do I do this Thanks
Adding a constant tuple value to a list of tuples
0.119427
0
0
6,851
2,326,671
2010-02-24T14:29:00.000
3
0
0
0
java,python,ruby-on-rails,django,enterprise
4,030,459
7
false
1
0
My company uses Python/Django as a base for our Intramas Platform. An entreprise grade web application platform that is deployed to about a dozen large clients. Built in features include central contact management, document generator, extra security layers, default GUI for rapid application design (no messing with Django admin interface!). Overall we are very pleased with Django as a base for our development, it is very extensible and the release cycle produces solid code (we upgrade often). While our site (http://www.sinax.be) is in Dutch and not very extensive at the moment you can always contact me for more information.
4
34
0
I know that the word “enterprise” gives some people the creeps, but I am curious to know if anyone has experience creating enterprise applications, similar to something like say… Java EE applications, which are highly concurrent, distributed applications with Django? I know Java has its own issues but its kind of viewed as THE enterprise framework and I think that’s unfortunate. Some people say that Rails is a good replacement for Java EE but what about Django? Has anyone ever used it in this context? You only ever see pretty standard websites on djangosites.org and it seems like its capable of so much more. I am planning on scrapping some of our old systems which are written mostly on ASP.NET and some Java for something more easily maintainable. I started using Django for some other applications and find it to be fantastic for what I am using it for (Corporate news, intranet, etc.) internally but what about something like… an accounts receivable system, or a billing system, etc. I would hate to see a framework such as this pigeon-holed into a category it doesn't need to be. It seems to be used for social media/networking, content-heavy sites, not so much data processing, etc. I feel that it has all the elements needed to start down this path. Anyone have any thoughts?
Anyone using Django in the "Enterprise"
0.085505
0
0
17,637
2,326,671
2010-02-24T14:29:00.000
11
0
0
0
java,python,ruby-on-rails,django,enterprise
9,905,892
7
false
1
0
My Company uses Django for at least six large scale enterprises such as mercedes, adidas. we often use the Jython wrapper. The advantages are reduced development cost compared to Java/C# runs stable via wrappers in IIS or Tomcat/Java environments protects our software from copycats Therefore we are well satisfied with Django and are promoting it to all our customers due to the dev cost advantage.
4
34
0
I know that the word “enterprise” gives some people the creeps, but I am curious to know if anyone has experience creating enterprise applications, similar to something like say… Java EE applications, which are highly concurrent, distributed applications with Django? I know Java has its own issues but its kind of viewed as THE enterprise framework and I think that’s unfortunate. Some people say that Rails is a good replacement for Java EE but what about Django? Has anyone ever used it in this context? You only ever see pretty standard websites on djangosites.org and it seems like its capable of so much more. I am planning on scrapping some of our old systems which are written mostly on ASP.NET and some Java for something more easily maintainable. I started using Django for some other applications and find it to be fantastic for what I am using it for (Corporate news, intranet, etc.) internally but what about something like… an accounts receivable system, or a billing system, etc. I would hate to see a framework such as this pigeon-holed into a category it doesn't need to be. It seems to be used for social media/networking, content-heavy sites, not so much data processing, etc. I feel that it has all the elements needed to start down this path. Anyone have any thoughts?
Anyone using Django in the "Enterprise"
1
0
0
17,637
2,326,671
2010-02-24T14:29:00.000
14
0
0
0
java,python,ruby-on-rails,django,enterprise
6,459,735
7
false
1
0
One of the biggest drawbacks in django is that although in theory the concept of applications being self-contained sounds nice, in practice it really doesn't work that well; even if you find some app that provides functionality that you need - it is not always easy to plug it in and go - you will always need to edit/hack at it. Evaluating django as a central platform at my work for developing pluggable apps led to a few roadblocks: ORM - yes, its great - but it is very specific and tailored. I have used it when I need some quick data processing done, but other than that you need to dive into something proper like SQLAlchemy. One thing we can't do easily is fetch random samples. This became a problem for us on a small data set (538,000+ rows approx.) with postgres. Template system - again, very specific to django-styled apps. No real concept of pluggable theme components unless you grow it yourself; and this means developing things that are already provided by other platforms. Not really a point against django per-se but lack of a central place to provide common services turned out to be a big issue for us. For example, no central authentication provider which we can plug into, no abstracted way of providing data credentials (separating of roles). So when we move things to production servers; the database credentials can't be edited on the server (as in the case with Java) and the db guys have to mess with my code base. All these things have led me to look at Java portal servers as my "platform" and specifically Liferay as it has Python support. I suggest you look at the big picture first before you commit yourself to django. I really love the framework, and I use it all the time on one-off projects, but as a central platform for developing all that we may need - django is not the answer for us. I have now delegated django for self contained projects - like some specific mini-site for a department. If we need to use Python for something else, I now evaluate Pyramid as its more pluggable. For anything that needs integration beyond our department, I look at Java. If all that fails - only then do we go to .NET.
4
34
0
I know that the word “enterprise” gives some people the creeps, but I am curious to know if anyone has experience creating enterprise applications, similar to something like say… Java EE applications, which are highly concurrent, distributed applications with Django? I know Java has its own issues but its kind of viewed as THE enterprise framework and I think that’s unfortunate. Some people say that Rails is a good replacement for Java EE but what about Django? Has anyone ever used it in this context? You only ever see pretty standard websites on djangosites.org and it seems like its capable of so much more. I am planning on scrapping some of our old systems which are written mostly on ASP.NET and some Java for something more easily maintainable. I started using Django for some other applications and find it to be fantastic for what I am using it for (Corporate news, intranet, etc.) internally but what about something like… an accounts receivable system, or a billing system, etc. I would hate to see a framework such as this pigeon-holed into a category it doesn't need to be. It seems to be used for social media/networking, content-heavy sites, not so much data processing, etc. I feel that it has all the elements needed to start down this path. Anyone have any thoughts?
Anyone using Django in the "Enterprise"
1
0
0
17,637
2,326,671
2010-02-24T14:29:00.000
7
0
0
0
java,python,ruby-on-rails,django,enterprise
2,327,568
7
false
1
0
For the systems you want to replace, you may find that it is desirable to use something more powerful than Django's ORM like SQLAlchemy. It's not a question of scaling, but the fact is that Django's ORM makes it hard to build complex queries and often pushes you to do in Python what should be done by your RDBMS — when you don't have to resort to raw SQL. Although SQLAlchemy has a steeper learning curve, it has more features and is better suited to complex database operations. It's certainly worth your time to have a look at it before deciding on a web stack to build on. This is probably less relevant to your questions but all the functionality in Django is also provided by other libraries that I find to be superior : Jinja2 for templating (it has the same syntax as Django templates without the mess that is the template tags system and better performance), WTForms for forms and modelforms, Babel for i18n (with many features not present in Django's own i18n library) and Werkzeug to provide a complete WSGI interface with URL routing.
4
34
0
I know that the word “enterprise” gives some people the creeps, but I am curious to know if anyone has experience creating enterprise applications, similar to something like say… Java EE applications, which are highly concurrent, distributed applications with Django? I know Java has its own issues but its kind of viewed as THE enterprise framework and I think that’s unfortunate. Some people say that Rails is a good replacement for Java EE but what about Django? Has anyone ever used it in this context? You only ever see pretty standard websites on djangosites.org and it seems like its capable of so much more. I am planning on scrapping some of our old systems which are written mostly on ASP.NET and some Java for something more easily maintainable. I started using Django for some other applications and find it to be fantastic for what I am using it for (Corporate news, intranet, etc.) internally but what about something like… an accounts receivable system, or a billing system, etc. I would hate to see a framework such as this pigeon-holed into a category it doesn't need to be. It seems to be used for social media/networking, content-heavy sites, not so much data processing, etc. I feel that it has all the elements needed to start down this path. Anyone have any thoughts?
Anyone using Django in the "Enterprise"
1
0
0
17,637
2,326,753
2010-02-24T14:40:00.000
0
0
0
0
python,printing,tkinter-canvas
2,326,802
1
false
0
1
AFAIK it can only be done using the postscript method from the Canvas. This generates a postscript file with the canvas contents. Check the documentation for details about this method.
1
1
0
How would I print contents of a Python Tkinter.Canvas widget? I've read that it's possible to print to a postscript printer from this control but examples are hard to come by. So, any ideas what is needed to print the contents (including images)? If you've got a cross-platform method all the better!
How to print contents of a tkinter.Canvas widget?
0
0
0
1,143
2,327,322
2010-02-24T15:51:00.000
4
0
1
0
python,coding-style
2,327,804
5
false
0
0
One reason this isn't mentioned in PEP 8 or other good Python style guides is that modifying sys.path isn't something you want to do in a real program; it makes your program less robust and portable. A better solution might be to put your package somewhere that would already be in sys.path or to define PYTHONPATH systemwide to include your package.
3
3
0
Just after standard pythonmodule imports? If I postpone it to the main function and do my specific module imports before it, it gives error (which is quite obvious). Python Style guide no where mentions the correct location for it.
Where should sys.path.append('...') statement go?
0.158649
0
0
5,554
2,327,322
2010-02-24T15:51:00.000
1
0
1
0
python,coding-style
2,327,364
5
false
0
0
I often use a shell script to launch my python applications: I put my sys.path.insert (append) statement just after the "standard" python module imports in my "launch python script". Using sys.path.insert(0, ...) gets your "imports" in priority in the path list.
3
3
0
Just after standard pythonmodule imports? If I postpone it to the main function and do my specific module imports before it, it gives error (which is quite obvious). Python Style guide no where mentions the correct location for it.
Where should sys.path.append('...') statement go?
0.039979
0
0
5,554
2,327,322
2010-02-24T15:51:00.000
0
0
1
0
python,coding-style
2,327,360
5
false
0
0
I generally do it before importing anything. If you're worried that your module names might conflict with the Python stdlib names, then change your module names!
3
3
0
Just after standard pythonmodule imports? If I postpone it to the main function and do my specific module imports before it, it gives error (which is quite obvious). Python Style guide no where mentions the correct location for it.
Where should sys.path.append('...') statement go?
0
0
0
5,554
2,327,355
2010-02-24T15:54:00.000
15
0
0
0
python,django,mod-wsgi,wsgi,django-wsgi
2,327,403
3
true
1
0
wsgi is usually preferred because it decouples your choice of framework from your choice of web server: if tomorrow you want to move, say, from Apache to nginx, or whatever, the move is trivially easy with wsgi, not so easy otherwise. Furthermore, using wsgi affords you the option to add some middleware that's framework-independent, rather than having to rely on every possible functionality you want having already been implemented and made available for your framework of choice.
2
7
0
We are deploying django application, I found in the documentation that it is recommended to use WSGI appoach for doing that. Before deploying I wanted to know, why it is recommended over other two approaches i.e. using mod_python and fastcgi... Thanks a lot.
It is said best way to deploy django is using wsgi, I am wondering why?
1.2
0
0
1,155
2,327,355
2010-02-24T15:54:00.000
5
0
0
0
python,django,mod-wsgi,wsgi,django-wsgi
2,327,392
3
false
1
0
We tried mod_python. It's slower and harder to configure. It doesn't offer the daemon feature. We couldn't get fast_cgi built for our combination of Apache, Red Hat and Python. I'm not sure specifically what was wrong, but we couldn't get it built properly. It wouldn't dispatch requests to Django properly, and we couldn't diagnose the problem. We tried mod_wsgi third. It built nicely. It has the daemon option. It's very easy to configure. It allows trivial restart of the Django applications without restarting all of Apache.
2
7
0
We are deploying django application, I found in the documentation that it is recommended to use WSGI appoach for doing that. Before deploying I wanted to know, why it is recommended over other two approaches i.e. using mod_python and fastcgi... Thanks a lot.
It is said best way to deploy django is using wsgi, I am wondering why?
0.321513
0
0
1,155
2,327,813
2010-02-24T16:57:00.000
9
0
1
0
python,android,gps,filtering
2,327,837
1
true
0
0
Except using rather complicated data signal processing techniques, or by using an accelerometer and dead reckoning (which is highly inaccurate), a GPS device cannot measure its own velocity. Due to this, the velocity data provided by a GPS unit is interpolated using the exact same method you want to use. The two probably have similar precision excluding minor errors introduced from whatever algorithms both you and the GPS chip manufacturer use. There are more advanced filtering / data processing techniques for interpolating velocity across multiple points, not just the most recent two. In all likelihood, your GPS chip is already implementing one of these and so will be more accurate than your more rudimentary implementation.
1
7
0
I am currently developing an application that receives GPS data gathered using and android phone. I need to analyze that data in terms of speed, acceleration, etc... My question is: Can I trust the speed values returned by the phone? Or should I use the difference in position and time between two points to get the values I want? Also, is there any "standard" method for filtering input data? Or any library (python welcomed) that does that kind of task? Thank you in advance! :)
How to best use GPS data?
1.2
0
0
1,316
2,328,185
2010-02-24T17:45:00.000
0
0
0
0
python,django,translation,gettext,django-multilingual
17,742,639
9
false
1
0
Another cause can be a wrong directory structure. Read well the manage command's error message about which directory to create before running the makemassages command for the app translation. (It must be locale for an app, not conf/locale.) Note that the management commands work fine even with the wrong directory structure.
5
26
0
I am making a multilingual Django website. I created a messages file, populated and compiled it. I checked the site (the admin in this case,) in my wanted language (Hebrew) and most phrases appear in Hebrew like they should, but some don't. I checked the source and these still appear as _('Whatever') like they should, also they are translated on the messages file, and yes, I remembered to do compilemessages. What are some common causes for translations not to appear like that?
Django i18n: Common causes for translations not appearing
0
0
0
9,733
2,328,185
2010-02-24T17:45:00.000
0
0
0
0
python,django,translation,gettext,django-multilingual
18,593,863
9
false
1
0
I noticed that when I had % in my text, the translated text was not being used. There may be other characters that can cause this problem. I fixed the problem by escaping the % as %%.
5
26
0
I am making a multilingual Django website. I created a messages file, populated and compiled it. I checked the site (the admin in this case,) in my wanted language (Hebrew) and most phrases appear in Hebrew like they should, but some don't. I checked the source and these still appear as _('Whatever') like they should, also they are translated on the messages file, and yes, I remembered to do compilemessages. What are some common causes for translations not to appear like that?
Django i18n: Common causes for translations not appearing
0
0
0
9,733
2,328,185
2010-02-24T17:45:00.000
0
0
0
0
python,django,translation,gettext,django-multilingual
65,446,782
9
false
1
0
My answer here, all my translations were working except for 2 DateFields that I was using in a ModelForm. Turns out that I had a widget in my forms.py that was not working well with the translations. I just removed it for now so I can enjoy Xmas =D
5
26
0
I am making a multilingual Django website. I created a messages file, populated and compiled it. I checked the site (the admin in this case,) in my wanted language (Hebrew) and most phrases appear in Hebrew like they should, but some don't. I checked the source and these still appear as _('Whatever') like they should, also they are translated on the messages file, and yes, I remembered to do compilemessages. What are some common causes for translations not to appear like that?
Django i18n: Common causes for translations not appearing
0
0
0
9,733
2,328,185
2010-02-24T17:45:00.000
37
0
0
0
python,django,translation,gettext,django-multilingual
2,381,694
9
true
1
0
Maybe the translated strings are marked as fuzzy?
5
26
0
I am making a multilingual Django website. I created a messages file, populated and compiled it. I checked the site (the admin in this case,) in my wanted language (Hebrew) and most phrases appear in Hebrew like they should, but some don't. I checked the source and these still appear as _('Whatever') like they should, also they are translated on the messages file, and yes, I remembered to do compilemessages. What are some common causes for translations not to appear like that?
Django i18n: Common causes for translations not appearing
1.2
0
0
9,733
2,328,185
2010-02-24T17:45:00.000
8
0
0
0
python,django,translation,gettext,django-multilingual
4,087,770
9
false
1
0
Hi just attach some fixes I had to do in the past: Restart the webserver! In the setting file - USE_I18N = True is needed django.middleware.locale.LocaleMiddleware among middleware modules (but this is not your case for sure as long as Django will not care about your local at all) django.core.context_processors.i18n among TEMPLATE_CONTEXT_PROCESSORS for sure I had other issues related to translations but I don't remember them all... hope this can help!
5
26
0
I am making a multilingual Django website. I created a messages file, populated and compiled it. I checked the site (the admin in this case,) in my wanted language (Hebrew) and most phrases appear in Hebrew like they should, but some don't. I checked the source and these still appear as _('Whatever') like they should, also they are translated on the messages file, and yes, I remembered to do compilemessages. What are some common causes for translations not to appear like that?
Django i18n: Common causes for translations not appearing
1
0
0
9,733
2,328,230
2010-02-24T17:53:00.000
0
0
1
0
java,python
2,328,658
12
false
0
0
Charlie, being a new hire and all, you shouldn't really decide on which technology to code the project. This is a management decision. In fact, even though team skill can be used to determine the technology of choice for one or other project, there are many other, more important, things to take into account. Which technology serves your purposes well? Assuming it can really be done in python and java: Is time-to-market really important? If you need to expand your team (i.e., extend the project), will you be able to hire more Python programmers? Are they more or less expensive than Java programmers? Are there other projects in Python at your enterprise (or your clients enterprise)? A homogeneous environment is easier to administrate. Learn the differences between Java and Python and see which one applies better to the problem. For example, Python probably performs worse than Java... But Python programs can be programmed and tested way more quickly. And, of course, yes you can take into account that there's a learning curve. As another answer put it, Python is very simple, and so is Java and almost every common language out there. What kills you is learning API's, SDK's, debugging tools, environment differences, etc. Another thing, that I draw from experience: never believe that a project is done when its done. Everything changes, so when you deliver the product, either your manager or your client (whoever will use it) will ask you to change something, and once you're done with that change, there will be more. Software are living things... they only stop changing when they are dead.
11
13
0
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.
How much leeway do I have to leave myself to learn a new language?
0
0
0
670
2,328,230
2010-02-24T17:53:00.000
0
0
1
0
java,python
3,258,221
12
false
0
0
My personal preference is to learn new languages on personal projects, and use tools I already understand on professional projects. So if it was me, I'd do the project in Java, and do a few little Python projects at home. But of course, you learn a lot more a lot faster when you are using a new language "for real" forty hours a week, so if you have adequate support from management and co-workers, then take advantage of the opportunity.
11
13
0
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.
How much leeway do I have to leave myself to learn a new language?
0
0
0
670
2,328,230
2010-02-24T17:53:00.000
1
0
1
0
java,python
2,328,518
12
false
0
0
Generally, if I'm not familiar with a language, I allow at least a month to get somewhat comfortable with it. Two or three months if it's outside my "comfort zone" of C-like languages. Having said that, I think Java and Python are similar enough that you might trim that a bit. Also, based on your own history, how good are your estimates when you're familiar with a language? If you think it will take two weeks to do it in Java, how well can you rely on that estimate? Personally, I'm sometimes way under, even when I think I'm being pessimistic, but maybe you're better at estimating than me. A part of me is tempted to say "Go for Python". That's at least partly because I'm a Python fan. However, as a new hire, you probably ought to make a good impression, and I think you'll do that better by delivering on time (or early) than by learning Python. However, if there are parts that can be cleanly separated out and done in Python, maybe you could do some parts in Java and other parts in Python.
11
13
0
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.
How much leeway do I have to leave myself to learn a new language?
0.016665
0
0
670
2,328,230
2010-02-24T17:53:00.000
1
0
1
0
java,python
2,328,430
12
false
0
0
I'd say if you want to avoid possible headaches, do it in Java and learn Python at home, by trying to re-create a similar application to the one you do at work, if you want something which feels real. It's likely that if you arent familiar with Python you arent going to take advantage of its capabilities anyway. Once I took a look at the first Python application I made, and it looked like I wrote an Object Pascal application in Python syntax
11
13
0
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.
How much leeway do I have to leave myself to learn a new language?
0.016665
0
0
670
2,328,230
2010-02-24T17:53:00.000
5
0
1
0
java,python
2,328,250
12
false
0
0
My boss's rule of thumb is any time there's a learning curve, it can triple the time to write the application. So, if Java would take you two weeks, then Python may take about 6.
11
13
0
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.
How much leeway do I have to leave myself to learn a new language?
0.083141
0
0
670
2,328,230
2010-02-24T17:53:00.000
7
0
1
0
java,python
2,328,364
12
false
0
0
You have roughly 5 weeks to complete the project. If you're confident the Java version would take 2 weeks, that leaves 3 weeks to flail around with the Python version until you have to give up. I say go for it. Python is relatively easy to pick up. I think three weeks of work is enough to time to know whether you can finish by the deadline. IMHO, this is a great excuse for you to learn a new language. Keep updating your manager regularly with your progress. I think the right decision will become apparent as time goes on.
11
13
0
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.
How much leeway do I have to leave myself to learn a new language?
1
0
0
670
2,328,230
2010-02-24T17:53:00.000
4
0
1
0
java,python
2,328,292
12
false
0
0
It always take longer than you think. Try writing a small program doing just a bit of what you need. If you are to write a program with a GUI then make small program showing a frame with Hello World and an Ok-button and see how hard that is.
11
13
0
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.
How much leeway do I have to leave myself to learn a new language?
0.066568
0
0
670
2,328,230
2010-02-24T17:53:00.000
0
0
1
0
java,python
2,328,316
12
false
0
0
Are you just programming or are you designing/architecting? If you are coding according to a design that an experienced Python resource has layed-out then I'd give myself 3-4 times as long since you've described this as a small, fairly simple project. If you are designing/architecting this yourself then you're taking on a big risk by trying to learn a new language at the same time. There's too much chance that you could design something at the onset that is core to your design, only to figure-out later that it doesn't work and you need to rewrite alot of stuff because of it. That being said I would present the risks and such to your manager (showing your obvious enthusiasm for learning Python) and let him make the call.
11
13
0
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.
How much leeway do I have to leave myself to learn a new language?
0
0
0
670
2,328,230
2010-02-24T17:53:00.000
2
0
1
0
java,python
2,328,426
12
false
0
0
If you Google for "Pythonic", you'll find a lot of discussion about how to do things in ways that fit well in Python, will be easy to understand by other Python users, and so on. It always takes a while to progress from code that simply works in a language to using that language well -- and in the case of Python, that learning curve is a bit longer than normal. In the end, I'd say the answer depends on your age and personality (and your perception of the "personality" of your employer). Relatively speaking, Java is the conservative approach -- it reduces risks and probably gives the best chance of finishing the job on time and within budget. Using a language you don't know increases the risk of not delivering what's needed. Chances are that you'll end up writing it (at least) twice, once in a form that's pretty similar to what you would have done in Java, and then again in a form that's more Pythonic. That may well mean some late nights, especially if you get down to a week to go (or something on that order) and realize you need (or badly want) to rewrite almost everything you've done so far. It mostly comes down to a question of whether you're comfortable with assuming that risk.
11
13
0
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.
How much leeway do I have to leave myself to learn a new language?
0.033321
0
0
670
2,328,230
2010-02-24T17:53:00.000
3
0
1
0
java,python
2,328,275
12
false
0
0
Python is like baby java, you'll pick it up in a breeze.
11
13
0
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.
How much leeway do I have to leave myself to learn a new language?
0.049958
0
0
670
2,328,230
2010-02-24T17:53:00.000
2
0
1
0
java,python
2,328,330
12
false
0
0
Well I would say how fast you pick up Python also depends on what other languages you know(or comfortable) apart from Java. If the only language you know is Java then I don't think the switch from Java to Python would be intuitive or smooth. To start with Java is statically typed and Python is dynamically typed, and it takes some time to get used to OO programming with Python even if you are skilled in using OO techniques using Java. So I would say honor the timeline and finish the project in time (or earlier :) using Java since this is what your work demands. Keep learning Python and automate some of the routine activities you do using Python so that you get a reasonable level of confidence to work on new project using Python.
11
13
0
I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.
How much leeway do I have to leave myself to learn a new language?
0.033321
0
0
670
2,328,767
2010-02-24T19:15:00.000
4
0
0
0
python,django
2,328,803
3
false
1
0
Use forms for all data validation. Bulk loading, batch processing, web services, everything. At first, it seems odd to read a CSV file, populate a Form, and then have the Form validate the data and build the database object. But that's the way it's supposed to work. Use the Forms for all validation no matter what the data source.
2
2
0
In other words, what did you not know when you started with Django that you wish someone had told you? I've dabbled some in Django but nothing really serious. However, I'm hoping to change that, and I'm wondering if there's any gotchas/shortcomings/whatever that I need to be aware of as I go.
Any potential gotchas or things to be aware of for a newcomer to Django?
0.26052
0
0
145
2,328,767
2010-02-24T19:15:00.000
4
0
0
0
python,django
2,328,793
3
false
1
0
You can't process data in templates. There are a fair number of questions in SO from people trying to do "real" processing in the templates. The Django template language is -- intentionally -- not JSP or ASP or PHP. It just does presentation and retrieval of values computed in view functions. If you can't figure out how to do it in the template, you may be trying to do too much. Use the view functions as much as possible.
2
2
0
In other words, what did you not know when you started with Django that you wish someone had told you? I've dabbled some in Django but nothing really serious. However, I'm hoping to change that, and I'm wondering if there's any gotchas/shortcomings/whatever that I need to be aware of as I go.
Any potential gotchas or things to be aware of for a newcomer to Django?
0.26052
0
0
145
2,329,417
2010-02-24T20:51:00.000
0
1
0
0
python,optimization
2,330,250
9
false
0
0
I think there was a somewhat similar if not exactly the same type of question asked here. Reading (and writing) line by line is slow, but you can read a bigger chunk into memory at once, go through that line by line skipping lines you don't want, then writing this as a single chunk to a new file. Repeat until done. Finally replace the original file with the new file. The thing to watch out for is when you read in a chunk, you need to deal with the last, potentially partial line you read, and prepend that into the next chunk you read.
2
25
0
I am working with a very large (~11GB) text file on a Linux system. I am running it through a program which is checking the file for errors. Once an error is found, I need to either fix the line or remove the line entirely. And then repeat... Eventually once I'm comfortable with the process, I'll automate it entirely. For now however, let's assume I'm running this by hand. What would be the fastest (in terms of execution time) way to remove a specific line from this large file? I thought of doing it in Python...but would be open to other examples. The line might be anywhere in the file. If Python, assume the following interface: def removeLine(filename, lineno): Thanks, -aj
Fastest Way to Delete a Line from Large File in Python
0
0
0
16,660
2,329,417
2010-02-24T20:51:00.000
1
1
0
0
python,optimization
2,329,515
9
false
0
0
If the lines are variable length then I don't believe that there is a better algorithm than reading the file line by line and writing out all lines, except for the one(s) that you do not want. You can identify these lines by checking some criteria, or by keeping a running tally of lines read and suppressing the writing of the line(s) that you do not want. If the lines are fixed length and you want to delete specific line numbers, then you may be able to use seek to move the file pointer... I doubt you're that lucky though.
2
25
0
I am working with a very large (~11GB) text file on a Linux system. I am running it through a program which is checking the file for errors. Once an error is found, I need to either fix the line or remove the line entirely. And then repeat... Eventually once I'm comfortable with the process, I'll automate it entirely. For now however, let's assume I'm running this by hand. What would be the fastest (in terms of execution time) way to remove a specific line from this large file? I thought of doing it in Python...but would be open to other examples. The line might be anywhere in the file. If Python, assume the following interface: def removeLine(filename, lineno): Thanks, -aj
Fastest Way to Delete a Line from Large File in Python
0.022219
0
0
16,660
2,329,627
2010-02-24T21:20:00.000
2
0
0
0
python,ajax,django,session,reverse-ajax
2,329,704
2
true
1
0
A database table for this would put a load on your server, as you said, but might be useful if you want to keep a record of these requests for whatever reason. Using something like memcached or an AMQP server might give you better performance. If you like you could even use a higher-performance key-value-store such as Tokyo Cabinet / Tokyo Tyrant.
1
0
0
I want to make it that one user on the site can chat request another user on my Django site. I want the requestee to get a realtime box that say: "Do you want to chat?" How does the following client polling approach sound: user1 clicks on users2 nickname, generating a POST request to some /message/requests, which creates a Message of type CHAT_REQUEST in the database. Meanwhile, a Javascript piece at user2's browser, repeatedly queries the server for message updates. When it receives a Message of type CHAT_REQUEST it opens a popup... The problem with this approach seems to be the database access. If the client is polling every 10 seconds, and 100 users leave their browser windows open, that is 10 database requests per seconds. Would it be better to store these messages not in the database, but in Django RAM or session information? Or will this database table be cached in RAM with PostgreSQL, and the retrieval fast?
Client polling (reverse AJAX) for chat requests in Django?
1.2
0
0
1,063
2,330,278
2010-02-24T22:51:00.000
3
0
0
0
python,mysql,database,stored-procedures,sqlalchemy
2,338,360
1
true
0
0
SQLAlchemy doesn't have any good way to convert inserts, updates and deletes to stored procedure calls. It probably wouldn't be that hard to add the capability to have instead_{update,insert,delete} extensions on mappers, but no one has bothered yet. I consider the requirement to have simple DML statements go through stored procedures rather silly. It really doesn't offer anything that you couldn't do with triggers. If you can't avoid the silliness, there are some ways that you can use SQLAlchemy to go along with it. You'll lose some of the ORM functionality though. You can build ORM objects from stored procedure results using query(Obj).from_statement(text("...")), just have the column labels in the statement match the column names that you told SQLAlchemy to map. One option to cope with DML statements is to turn autoflush off and instead of flushing go through the sessions .new, .dirty and .deleted attributes to see what has changed, issue corresponding statements as stored procedure calls and expunge the objects before committing. Or you can just forgo SQLAlchemy state tracking and issue the stored procedure calls directly.
1
4
0
I am developing a Python web app using sqlalchemy to communicate with mysql database. So far I have mostly been using sqlalchemy's ORM layer to speak with the database. The greatest benefit to me of ORM has been the speed of development, not having to write all these sql queries and then map them to models. Recently, however, I've been required to change my design to communicate with the database through stored procedures. Does any one know if there is any way to use sqlalchemy ORM layer to work with my models through the stored procedures? Is there another Python library which would allow me to do this? The way I see it I should be able to write my own select, insert, update and delete statements, attach them to the model and let the library do the rest. I've gone through sqlalchemy's documentation multiple times but can't seem to find a way to do this. Any help with this would be great!
Keeping ORM with stored procedures
1.2
1
0
1,754
2,330,344
2010-02-24T23:02:00.000
13
0
0
0
python,sqlite
2,330,380
8
false
0
0
You're not obliged to call close() on the cursor; it can be garbage collected like any other object. But even if waiting for garbage collection sounds OK, I think it would be good style still to ensure that a resource such as a database cursor gets closed whether or not there is an exception.
3
48
0
Here is the scenario. In your function you're executing statements using a cursor, but one of them fails and an exception is thrown. Your program exits out of the function before closing the cursor it was working with. Will the cursor float around taking up space? Do I have to close the cursor? Additionally, the Python documentation has an example of cursor use and says: "We can also close the cursor if we are done with it." The keyword being "can," not "must." What do they mean precisely by this?
In Python with sqlite is it necessary to close a cursor?
1
1
0
27,863
2,330,344
2010-02-24T23:02:00.000
7
0
0
0
python,sqlite
2,416,354
8
false
0
0
I haven't seen any effect for the sqlite3.Cursor.close() operation yet. After closing, you can still call fetch(all|one|many) which will return the remaining results from the previous execute statement. Even running Cursor.execute() still works ...
3
48
0
Here is the scenario. In your function you're executing statements using a cursor, but one of them fails and an exception is thrown. Your program exits out of the function before closing the cursor it was working with. Will the cursor float around taking up space? Do I have to close the cursor? Additionally, the Python documentation has an example of cursor use and says: "We can also close the cursor if we are done with it." The keyword being "can," not "must." What do they mean precisely by this?
In Python with sqlite is it necessary to close a cursor?
1
1
0
27,863
2,330,344
2010-02-24T23:02:00.000
0
0
0
0
python,sqlite
71,683,829
8
false
0
0
Yes, we should close our cursor. I once encountered an error when I used my cursor to configure my connection object: 'PRAGMA synchronous=off' and 'PRAGMA journal_mode=off' for faster insertion. Once I closed the cursor, the error went away. I forgot what type of error I encountered.
3
48
0
Here is the scenario. In your function you're executing statements using a cursor, but one of them fails and an exception is thrown. Your program exits out of the function before closing the cursor it was working with. Will the cursor float around taking up space? Do I have to close the cursor? Additionally, the Python documentation has an example of cursor use and says: "We can also close the cursor if we are done with it." The keyword being "can," not "must." What do they mean precisely by this?
In Python with sqlite is it necessary to close a cursor?
0
1
0
27,863
2,330,393
2010-02-24T23:11:00.000
3
0
1
0
python,macos,title,menubar
2,330,448
2
false
0
0
Since your program is interpreted by Python, then what actually is run is Python itself - the interpreter program. You would have to have your Python script merged with Python into a single executable and that would be able to have a separate name. For windows there is py2exe, that does that, but I have no idea if there is a similar tool for Mac OS (and if there is any need for that, there is some BSD under the hood right?).
1
9
0
I have been building a large python program for a while, and would like to know how I would go about setting the title of the program? On a mac the title of program, which has focus, is shown in the top left corner of the screen, next the apple menu. Currently this only shows the word "Python", but I would of course like to my program's title there instead.
How to set the program title in python
0.291313
0
0
12,479
2,330,587
2010-02-24T23:53:00.000
9
0
1
0
python,ctypes
2,330,623
3
false
0
0
Use the 'value' attribute of c_long object. c_long(1).value or i = c_long(1) print i.value
1
33
0
int(c_long(1)) doesn't work.
How to convert ctypes' c_long to Python's int?
1
0
0
27,835
2,330,857
2010-02-25T01:00:00.000
0
1
0
0
python
2,330,884
3
false
0
0
For a simple-to-code method, I suggest using ast.parse() or eval() to create a dictionary from your string, and then accessing the fields as usual. The difference between the two functions above is that ast.parse can only evaluate base types, and is therefore more secure if someone can give you a string that could contain "bad" code.
1
1
0
i have a string ''' {"session_key":"3.KbRiifBOxY_0ouPag6__.3600.1267063200-16423986","uid":164 23386,"expires":12673200,"secret":"sm7WM_rRtjzXeOT_jDoQ__","sig":"6a6aeb66 64a1679bbeed4282154b35"} ''' how to get the value . thanks
which is the best way to get the value of 'session_key','uid','expires'
0
0
1
115
2,334,402
2010-02-25T13:54:00.000
0
0
0
0
python,django,django-multilingual
2,336,824
2
true
1
0
Maybe you don't have to override anything. You can just check on the first page, (or maybe every page) if the user already has a language cookie and otherwise redirect him to the set_language redirect view. In that way you could force the language to Hebrew. If the user decides to change back to English, he can do it very easily.
1
0
0
I'm developing a multilingual Django website. It has two languages, English and Hebrew. I want the default language for every first-time visitor to be Hebrew, regardless of what his browser's Accept-Language is. Of course, if he changes language to English (and thus gets the language cookie or the key in the session), it should remain at English. I think I can program this algorithm myself, but where do I "plug it in"? How do I make my project use it?
Customizing the language-guessing algorithm in Django
1.2
0
0
269
2,334,754
2010-02-25T14:41:00.000
1
0
0
1
python,windows,dll,distutils,dllexport
2,334,890
1
false
0
0
You can pass ['-Wl,--export-all-symbols'] as extra_link_args if you're using Mingw's GCC. There's probably a similar setting for Visual, somewhere in the IDE. This works only if distutils chooses to use "gcc -mdll" as a linker instead of "dllwrap". It does so if your ld version is later than 2.10.90, which should be the case if you're using a recent Mingw. At first it didn't work for me because I used Python 2.2 which has a small bug related to version parsing: it expects 3 dot-separated numbers so it falls back to dllwrap if the ld version is 2.20...
1
0
0
I'm abusing distutils to compile an extension module for Python, but rather than using the Python C API I'm using ctypes to talk to the resulting shared library. This works fine in Linux because it automatically exports all symbols in a shared library, but in Windows distutils provides a .def to export only the Python module init function. How do I extend distutils to provide my own .def on Windows so it will export the symbols I need?
Can distutils use a custom .def to expose extra symbols when it compiles a Windows .dll?
0.197375
0
0
207
2,335,384
2010-02-25T15:56:00.000
2
1
0
0
python,django,email
2,335,399
5
false
1
0
So how does PHP do it? By magic? If you don't have an SMTP server, sign up for a GMail account and use that.
1
8
0
As far as I read, Django only supports sending mails using SMTP. I would like to send Emails from my script in Django, but do not want to setup SMTP server (it's too complex for me, I'm a linux newbie). Is it possible, to send mails in Django in the same way like I do it in PHP, without providing SMTP login, password and etc?
Send Email in Django without SMTP server. Like php mail() function does
0.07983
0
0
7,844
2,336,822
2010-02-25T19:10:00.000
3
0
0
0
python,amazon-simpledb
2,336,902
1
true
0
0
I've found boto to be effective and straight forward and I've never had any trouble with queries with limits. Although I've never used the sixapart module.
1
4
0
I'm writing a python script to select, insert, update, and delete data in SimpleDB. I've been using the simpledb module written by sixapart so far, and it's working pretty well. I've found one potential bug/feature that is problematic for me when running select queries with "limit", and I'm thinking of trying it with the boto module to see if it works better. Has anyone used these two modules? Care to offer an opinion on which is better? Thanks!
What's the best module to access SimpleDB in python?
1.2
1
0
833
2,338,951
2010-02-26T01:32:00.000
0
0
1
1
python,windows,py2exe
2,338,973
4
false
0
0
Not really understand your requirement, but you can try start /MIN. type start /? on the command line to see its help page.
1
6
0
Could someone explain to me how can I run my py2exe program, a console program, without the terminal on Windows? I'm trying to make a program that re-sizes windows and it supposed to start with windows, so I want it hide out but still running...
How can I run a py2exe program in windows without the terminal?
0
0
0
3,511
2,339,436
2010-02-26T04:08:00.000
-3
0
0
0
python,django,url,friendly-url,slug
2,340,258
3
false
1
0
With all due respect to Stackoverflow, this is the wrong way to do it. You shouldn't need to have two elements in the URL that identify the page. The ID is irrelevant - it's junk. You should be able to uniquely identify a page from the slug alone.
1
6
0
I'm creating a video site. I want my direct urls to a video to look like example.com/watch/this-is-a-slug-1 where 1 is the video id. I don't want the slug to matter though. example.com/watch/this-is-another-slug-1 should point to the same page. On SO, /questions/id is the only part of the url that matters. How can I do that?
How can I make URLs in Django similar to stackoverflow?
-0.197375
0
0
826
2,339,725
2010-02-26T05:46:00.000
1
0
0
1
python,linux,django,ubuntu
2,339,784
4
false
0
0
The problem with a cron job is that it will start every so often regardless of whether the previous instance is finished. What I would recommend is to have your script start a new instance of itself after a certain amount of time, then exit.
1
4
0
Hi I have a Django script that I need to run, I think the commands could be called through bash. Thing is the script causes memory leaks after a long a period of time, so I would like to create an external cron job which calls the Python script. So the script would terminate and restart while retaking the lost memory. Can someone point me in the right direction? I know quite little on the subject, and feel a bit lost.
Creating a Cron Job - Linux / Python
0.049958
0
0
8,197
2,339,742
2010-02-26T05:51:00.000
0
0
0
0
python,http,post,cgi,get
2,790,879
3
true
0
0
Yes, there is only one transmission of data between server and client. The context of the passage was referring to communication between web server and cgi application. Server communication between the web server and the cgi application using POST happens in two separate transfers. The request for the python script is sent by the server in a single transfer and then the POST data is sent separately over stdin (two transfers). Whereas with GET the input data is passed as env vars or command line args in one transfer.
2
2
0
I found the quoted text in Programming Python 3rd edition by Mark Lutz from Chapter 16: Server-Side Scripting (page 987): Forms also include a method option to specify the encoding style to be used to send data over a socket to the target server machine. Here, we use the post style, which contacts the server and then ships it a stream of user input data in a separate transmission. An alternative get style ships input information to the server in a single transmission step, by adding user inputs to the end of the URL used to invoke the script, usually after a ? character (more on this soon). I read this with some puzzlement. As far as I know post data is sent in the same transmission as a part of the same http header. I have never heard of this extra step for post data transmission. I quickly looked over the relevant HTTP rfc's and didn't notice any distinction in version 1.0 or 1.1. I also used wireshark for some analysis and didn't notice multiple transmissions for post. Am I missing something fundamental or is this an error in the text?
HTTP POST Requests require multiple transmissions?
1.2
0
1
372
2,339,742
2010-02-26T05:51:00.000
1
0
0
0
python,http,post,cgi,get
2,339,754
3
false
0
0
Simple POST request is in single step. but when you are uploading a file, than the form is posted in multiple parts. In that case, the content type application/x-www-form-urlencoded is changed to multipart/form-data.
2
2
0
I found the quoted text in Programming Python 3rd edition by Mark Lutz from Chapter 16: Server-Side Scripting (page 987): Forms also include a method option to specify the encoding style to be used to send data over a socket to the target server machine. Here, we use the post style, which contacts the server and then ships it a stream of user input data in a separate transmission. An alternative get style ships input information to the server in a single transmission step, by adding user inputs to the end of the URL used to invoke the script, usually after a ? character (more on this soon). I read this with some puzzlement. As far as I know post data is sent in the same transmission as a part of the same http header. I have never heard of this extra step for post data transmission. I quickly looked over the relevant HTTP rfc's and didn't notice any distinction in version 1.0 or 1.1. I also used wireshark for some analysis and didn't notice multiple transmissions for post. Am I missing something fundamental or is this an error in the text?
HTTP POST Requests require multiple transmissions?
0.066568
0
1
372
2,340,150
2010-02-26T07:47:00.000
6
0
1
1
python,windows,ruby,default
2,340,173
7
true
0
0
Microsoft makes it pretty obvious they want you to use their version of everything. So what is in it for them to have Python or any other language as part of their Windows operating system? They want you to program for Microsoft Internet Explorer using Microsoft Active Server Pages with Microsoft Visual Basic on Microsoft Internet Information Server, back-ended by Microsoft SQL Server running on top of Microsoft Windows. It goes on and on like this... It makes perfect sense from a business perspective when you think about it. So... Will we see competing "products"--even open source ones--installed by default on Windows? Not gonna happen anytime soon.
4
2
0
Or any other normal scripting language for that matter. I know there is VBScript and JScript. But I don't really like those for any kind of computing. I would really love to have python or ruby (or perl) interpreter installed with windows by default so when I write small console applications I wouldn't need to distribute whole python installation with it via py2exe(or similar). Do you know if there is such incentive? Do you think this would be possible? Or it's not acceptable for Microsoft?
Why isn't Python installed on Windows by default?
1.2
0
0
2,554
2,340,150
2010-02-26T07:47:00.000
1
0
1
1
python,windows,ruby,default
2,340,241
7
false
0
0
Firstly, Windows doesn't need them to run, and to be honest, most people buying Windows have no knowledge of - let alone interest in - scripting languages. It then comes down to ownership and support. There's nothing ships as part of a default Windows installation which isn't owned, designed and developed by Microsoft. They own everything, so the buck stops with them. If they shipped any third-party packages as part of the installer who would pick up support if something goes wrong? Finally, there's the competitive advantage of providing your own products over third-party tools or packages in a default installation.
4
2
0
Or any other normal scripting language for that matter. I know there is VBScript and JScript. But I don't really like those for any kind of computing. I would really love to have python or ruby (or perl) interpreter installed with windows by default so when I write small console applications I wouldn't need to distribute whole python installation with it via py2exe(or similar). Do you know if there is such incentive? Do you think this would be possible? Or it's not acceptable for Microsoft?
Why isn't Python installed on Windows by default?
0.028564
0
0
2,554
2,340,150
2010-02-26T07:47:00.000
2
0
1
1
python,windows,ruby,default
2,340,169
7
false
0
0
You could create your own Windows Installation-Disc with the wished script or programming language installed on default.. Perhaps search on SuperUser.com (or Google) for this matter.
4
2
0
Or any other normal scripting language for that matter. I know there is VBScript and JScript. But I don't really like those for any kind of computing. I would really love to have python or ruby (or perl) interpreter installed with windows by default so when I write small console applications I wouldn't need to distribute whole python installation with it via py2exe(or similar). Do you know if there is such incentive? Do you think this would be possible? Or it's not acceptable for Microsoft?
Why isn't Python installed on Windows by default?
0.057081
0
0
2,554
2,340,150
2010-02-26T07:47:00.000
1
0
1
1
python,windows,ruby,default
2,340,164
7
false
0
0
Because Windows doesn't need those languages to run, by default ? (While, for instance, many basic Linux utilities depend on some script-languages, like Perl) I would add that JScript and VBScript have been implemted by Microsoft -- so Microsoft can distribute their implementation ; on the other hand, there is no Microsoft implementation of either Python, PHP, or Perl, ...
4
2
0
Or any other normal scripting language for that matter. I know there is VBScript and JScript. But I don't really like those for any kind of computing. I would really love to have python or ruby (or perl) interpreter installed with windows by default so when I write small console applications I wouldn't need to distribute whole python installation with it via py2exe(or similar). Do you know if there is such incentive? Do you think this would be possible? Or it's not acceptable for Microsoft?
Why isn't Python installed on Windows by default?
0.028564
0
0
2,554
2,341,011
2010-02-26T10:52:00.000
2
0
1
0
python,svn,pre-commit-hook
2,341,097
2
false
0
0
The preferred tab usage in Python is no tab usage at all (use four spaces for indentation). If that is your coding style then the problem may be reduced to checking if there are any tabs in the code. And this can be easily done with simple regexp, even with 'grep', so there is no even need to run the interpreter. The 'py_compile' way have other advantage, though: it also checks Python code syntax, which may be desirable (though costs a bit of computation power of the SVN server).
1
4
0
The Python interpreter can be started with -tt to raise a TabError exception if the interpreted file has inconsistent tab usage. I'm trying to write a pre-commit hook for SVN that rejects files that raise this exception. I can pass the file being committed to python -tt but my problem is that the file is also executed, besides being checked. Is there a way to tell Python "just analyze the file, don't run it"? Or maybe some other approach would be better for accomplishing what I want.
SVN pre-commit hook to reject Python files with inconsistent tab usage
0.197375
0
0
1,290
2,342,033
2010-02-26T13:50:00.000
0
0
0
0
python,ruby-on-rails,model-view-controller
2,342,211
4
false
1
0
It depends on how you are planning on implementing the scraper. If you are going to have a UI where you click a button to scrape a screen then it is going to be in all three (M, V, and C). If it is going to be a background process (like mentioned before) it should be in M and C.
3
1
0
In a MVC patterned framework where would a screen-scraping module most logically be located? In the model or the controller? Or is it completely outside of this pattern?
In a MVC patterned framework where would a screen-scraping module be located?
0
0
0
643
2,342,033
2010-02-26T13:50:00.000
0
0
0
0
python,ruby-on-rails,model-view-controller
2,342,064
4
false
1
0
In a sense, the screen-scraper is the user of the application -- I'd think it would be a piece outside the MVC that interacts with the controller, just like a web page sends information to the controller. This would make it easy to put a web page over it if the interface changes.
3
1
0
In a MVC patterned framework where would a screen-scraping module most logically be located? In the model or the controller? Or is it completely outside of this pattern?
In a MVC patterned framework where would a screen-scraping module be located?
0
0
0
643
2,342,033
2010-02-26T13:50:00.000
0
0
0
0
python,ruby-on-rails,model-view-controller
2,342,101
4
false
1
0
I presume the scraper is only used to collect data. if the data is scraped and stored, this process does not simply drop into either M V or C. You could run this scrapping process as a cron job on intervals you define, store the data and then define models to access the data. i wouldn't recommend calling the scrapping process every-time the controller requests the model, unless you are caching the scrap request. EDIT: the cron could be a controller, but not publicly callable.
3
1
0
In a MVC patterned framework where would a screen-scraping module most logically be located? In the model or the controller? Or is it completely outside of this pattern?
In a MVC patterned framework where would a screen-scraping module be located?
0
0
0
643
2,343,053
2010-02-26T16:24:00.000
1
0
0
0
python,django,django-models,django-south
2,344,046
3
true
1
0
You seem to be very confused, unfortunately. Of course Django reads the code in models.py - otherwise what would be the point of it? Django uses that code initially to define the model SQL when doing syncdb, but it doesn't modify existing database tables in subsequent calls to syncdb - hence the need for South. But naturally, Django uses models.py and admin.py and all the other Python code to define its own configuration and state. (And note that admin classes are not defined in models.py but in admin.py.) If you are not seeing changes, you will need to restart your server.
3
0
0
I added some models in my models.py and I want to add an admin class to use a wysiwyg-editor in text-fields. Well, I know that Django itself doesn't support migrations and I've used South, but it doesn't work either. South doesn't "see" the change. Could it be, that South just detects changes to fields, but not if I add a new class? How can I tweak Django to detect such changes?
How to add an Admin class to a model after syncdb?
1.2
0
0
187
2,343,053
2010-02-26T16:24:00.000
1
0
0
0
python,django,django-models,django-south
2,343,100
3
false
1
0
I'm fairly sure that if you follow the steps as outlined in the tutorial to create an admin app it'll just work. Migration isn't an issue as the admin app creates new tables rather than altering the existing one.
3
0
0
I added some models in my models.py and I want to add an admin class to use a wysiwyg-editor in text-fields. Well, I know that Django itself doesn't support migrations and I've used South, but it doesn't work either. South doesn't "see" the change. Could it be, that South just detects changes to fields, but not if I add a new class? How can I tweak Django to detect such changes?
How to add an Admin class to a model after syncdb?
0.066568
0
0
187
2,343,053
2010-02-26T16:24:00.000
2
0
0
0
python,django,django-models,django-south
2,343,087
3
false
1
0
syncdb and South are only concerned with descendants of Model in apps listed in INSTALLED_APPS. Everything else is handled by Django directly.
3
0
0
I added some models in my models.py and I want to add an admin class to use a wysiwyg-editor in text-fields. Well, I know that Django itself doesn't support migrations and I've used South, but it doesn't work either. South doesn't "see" the change. Could it be, that South just detects changes to fields, but not if I add a new class? How can I tweak Django to detect such changes?
How to add an Admin class to a model after syncdb?
0.132549
0
0
187
2,343,311
2010-02-26T16:58:00.000
3
0
1
0
python,import,packages
2,343,376
2
false
0
0
Your problem is that your top package is not in your sys.path.
1
0
0
I am about at wits end with what should be an extremely simple issue. Here is the format of a simple example that I wrote to try to fix my problem. I have a folder top with __all__ = ["p1","p2"] in __init__.py . I then have sub-folders p1 and p2 with __init__.py in both of them with __all__ again defined with the names of two simple module quick1 and quick 2 with quick1 in p1 and quick2 in p2. If I import top.p1.quick1 from a script outside of top then the import works fine. However, trying to import top.p1.quick1 from quick2 gives the error File "quick1.py", line 1, in <module> import top.p2.quick2 ImportError: No module named top.p2.quick2 How can I import a module from another sub-package? This is supposed to work according to the python documentation as far as I can tell. Does anyone see an obvious, trivial mistake that I made? Edit: It appears that I need to add the directory with top to my search path. I can do this temporarily by setting PYTHONPATH. However, is there a better way to do this from a distutils script?
Python sub-package references
0.291313
0
0
1,581
2,344,081
2010-02-26T18:56:00.000
0
1
0
0
c++,python,boost,nlp
7,779,679
5
false
0
0
IMO go for C/C++ simply because of the 'familiar' factor. Though LOC's will be more in C/C++ you will save time in understanding and testing.
2
3
0
We are working on Arabic Natural Language Processing project, we have limited our choices to either write the code in Python or C++ (and Boost library). We are thinking of these points: Python Slower than C++ (There is ongoing work to make Python faster) Better UTF8 support Faster in writing tests and trying different algorithms C++ Faster than Python Familiar code, every programmer knows C or C-like code After the project is done, it should be not very hard to port the project to another programming languages. What do you think is better and suitable for the project?
NLP project, python or C++
0
0
0
4,180
2,344,081
2010-02-26T18:56:00.000
2
1
0
0
c++,python,boost,nlp
2,344,099
5
false
0
0
Familiar code, every programmer knows C or C-like code Many devs are familiar with C or C-like code, it doesn't make them C++ compliant. Unexperienced C++ devs can do a lot of harm to such a complex project and you would have to take extra care. I can't speak for python but I heard it's more beginner-friendly. I'd say, once again, you should go for the language you (as a team) know best.
2
3
0
We are working on Arabic Natural Language Processing project, we have limited our choices to either write the code in Python or C++ (and Boost library). We are thinking of these points: Python Slower than C++ (There is ongoing work to make Python faster) Better UTF8 support Faster in writing tests and trying different algorithms C++ Faster than Python Familiar code, every programmer knows C or C-like code After the project is done, it should be not very hard to port the project to another programming languages. What do you think is better and suitable for the project?
NLP project, python or C++
0.07983
0
0
4,180
2,345,257
2010-02-26T22:24:00.000
2
0
0
0
python,django,persistence
2,345,334
2
false
1
0
Consider running it in another process. You could have your Django application submit samples via a socket that the classifier process listens on, or you could run a queue and have Django submit requests to the queue.
1
6
0
I have a Python-based maximum entropy classifier. It's large, stored as a Pickle, and takes about a minute to unserialize. It's also not thread safe. However, it runs fast and can classify a sample (a simple Python dictionary) in a few milliseconds. I'd like to create a basic Django web app, so users can submit samples to classify in realtime. How would I load the classifier into persistent memory once, and then regulate it so that each request can access the object without conflicting with other requests?
Creating a Persistent Data Object In Django
0.197375
0
0
5,288
2,345,607
2010-02-26T23:57:00.000
0
0
1
1
python,windows,python-idle
29,289,580
7
false
0
0
Just add IDLE's path to your PATH environment variable. For example I created an environment variable called IDLE_PATH and set the value to C:\Python27\Lib\idlelib Then in my PATH variable I added ;%IDLE_PATH%; and open a new cmd prompt or in console2 just open a new tab and run idle <file_name> to open the file, you will be able to do this from any directory. In IPython console add an ! before the command, for example !idle test.py. Congrates, Now you're a python pimp!
2
10
0
I've tried many variations of this command: idle.py -e filepath, but it simply starts IDLE like normal, not opening any extra windows for editing, and not throwing any errors. So how can I do the equivalent of opening IDLE, file>open>filepath via the command line (or perhaps even a Python module)?
starting Python IDLE from command line to edit scripts
0
0
0
58,831
2,345,607
2010-02-26T23:57:00.000
2
0
1
1
python,windows,python-idle
39,559,184
7
false
0
0
first make sure you have location of idle in path I am using "python3.5".So mine looks like this: C:\Program Files\Python35\Lib\idlelib.Yours may differ. use this following command:idle -r file_name.py to run the file or just idle file_name.py to edit or start idle -r file_name.py ^&exit
2
10
0
I've tried many variations of this command: idle.py -e filepath, but it simply starts IDLE like normal, not opening any extra windows for editing, and not throwing any errors. So how can I do the equivalent of opening IDLE, file>open>filepath via the command line (or perhaps even a Python module)?
starting Python IDLE from command line to edit scripts
0.057081
0
0
58,831
2,348,443
2010-02-27T18:22:00.000
4
0
1
0
python,django,python-imaging-library
2,348,473
1
true
0
0
Unfortunately file-likes from network functions such as urllib2.urlopen() don't support all the necessary methods, so you'll need to read the data into a StringIO or cStringIO in order to be able to pass them to Image.open().
1
2
0
I'm trying to download images from URLs and pass them to PIL. I would like to use as few resources as possible, especially RAM. What would the best way of dealing with this? I've had suggestions to use cStringIO.
Python PIL and StringIO
1.2
0
0
990
2,348,927
2010-02-27T20:53:00.000
4
0
1
0
python,configuration-files
2,348,941
4
false
0
0
The approach you describe is ok. If you want to add support for user config files, you can use execfile(os.path.expanduser("~/.yourprogram/config.py")).
3
23
0
I am developing a project that requires a single configuration file whose data is used by multiple modules. My question is: what is the common approach to that? should i read the configuration file from each of my modules (files) or is there any other way to do it? I was thinking to have a module named config.py that reads the configuration files and whenever I need a config I do import config and then do something like config.data['teamsdir'] get the 'teamsdir' property (for example). response: opted for the conf.py approach then since it it is modular, flexible and simple I can just put the configuration data directly in the file, latter if i want to read from a json file a xml file or multiple sources i just change the conf.py and make sure the data is accessed the same way. accepted answer: chose "Alex Martelli" response because it was the most complete. voted up other answers because they where good and useful too.
python single configuration file
0.197375
0
1
6,382