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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
250,151 | 2008-10-30T13:21:00.000 | 3 | 1 | 1 | 0 | python,scripting,lua | 781,316 | 11 | false | 0 | 0 | In order for Lua to be easy to embed it has to have few dependencies and be small. That makes it poorly suited as a general purpose scripting language. Because using it as a general purpose script language would require a lot of standard libraries. But if Lua had a lot of standard libraries it would be harder to embed (due to dependencies and memory footprint.) | 4 | 37 | 0 | When I see Lua, the only thing I ever read is "great for embedding", "fast", "lightweight" and more often than anything else: "World of Warcraft" or in short "WoW".
Why is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?
Lua seems to be doing great in aspects like speed and memory-usage (The fastest scripting language afaik) so why is it that I never see Lua being used as a "Desktop scripting-language" to automate tasks? For example:
Renaming a bunch of files
Download some files from the web
Webscraping
Is it the lack of the standard library? | Lua as a general-purpose scripting language? | 0.054491 | 0 | 0 | 12,626 |
250,151 | 2008-10-30T13:21:00.000 | 4 | 1 | 1 | 0 | python,scripting,lua | 253,659 | 11 | false | 0 | 0 | I think the answer about it being a "marketing" thing is probably correct, along with the lack of a large set of libraries to choose from. I would like to point out another case of this: Ruby. Ruby is meant to be a general purpose scripting language. The problem is that since Ruby on Rails has risen to be so popular, it is becoming hard to find something that is unrelated to Rails. I'm afraid Lua will suffer this as well, being popular because of a few major things using it, but never able to break free of that stigma. | 4 | 37 | 0 | When I see Lua, the only thing I ever read is "great for embedding", "fast", "lightweight" and more often than anything else: "World of Warcraft" or in short "WoW".
Why is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?
Lua seems to be doing great in aspects like speed and memory-usage (The fastest scripting language afaik) so why is it that I never see Lua being used as a "Desktop scripting-language" to automate tasks? For example:
Renaming a bunch of files
Download some files from the web
Webscraping
Is it the lack of the standard library? | Lua as a general-purpose scripting language? | 0.072599 | 0 | 0 | 12,626 |
250,151 | 2008-10-30T13:21:00.000 | 6 | 1 | 1 | 0 | python,scripting,lua | 251,372 | 11 | false | 0 | 0 | Definitely a lack of standard libraries. It's also lesser known than Python, Perl or Ruby. | 4 | 37 | 0 | When I see Lua, the only thing I ever read is "great for embedding", "fast", "lightweight" and more often than anything else: "World of Warcraft" or in short "WoW".
Why is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?
Lua seems to be doing great in aspects like speed and memory-usage (The fastest scripting language afaik) so why is it that I never see Lua being used as a "Desktop scripting-language" to automate tasks? For example:
Renaming a bunch of files
Download some files from the web
Webscraping
Is it the lack of the standard library? | Lua as a general-purpose scripting language? | 1 | 0 | 0 | 12,626 |
252,703 | 2008-10-31T05:55:00.000 | 15 | 0 | 1 | 0 | python,list,data-structures,append,extend | 25,144,368 | 20 | false | 0 | 0 | An interesting point that has been hinted, but not explained, is that extend is faster than append. For any loop that has append inside should be considered to be replaced by list.extend(processed_elements).
Bear in mind that apprending new elements might result in the realloaction of the whole list to a better location in memory. If this is done several times because we are appending 1 element at a time, overall performance suffers. In this sense, list.extend is analogous to "".join(stringlist). | 2 | 3,113 | 0 | What's the difference between the list methods append() and extend()? | What is the difference between Python's list methods append and extend? | 1 | 0 | 0 | 3,183,036 |
252,703 | 2008-10-31T05:55:00.000 | 7 | 0 | 1 | 0 | python,list,data-structures,append,extend | 42,171,373 | 20 | false | 0 | 0 | I hope I can make a useful supplement to this question. If your list stores a specific type object, for example Info, here is a situation that extend method is not suitable: In a for loop and and generating an Info object every time and using extend to store it into your list, it will fail. The exception is like below:
TypeError: 'Info' object is not iterable
But if you use the append method, the result is OK. Because every time using the extend method, it will always treat it as a list or any other collection type, iterate it, and place it after the previous list. A specific object can not be iterated, obviously. | 2 | 3,113 | 0 | What's the difference between the list methods append() and extend()? | What is the difference between Python's list methods append and extend? | 1 | 0 | 0 | 3,183,036 |
252,859 | 2008-10-31T08:13:00.000 | 1 | 0 | 0 | 0 | c,windows-mobile,extending,pythonce | 253,562 | 3 | false | 0 | 1 | MSDN has plenty of samples for C++ development on Windows Mobile, and the SDK comes with several sample application. Unfortunately VS Express editions (the free ones) do not come with compilers for Smart Devices. The only free option is the older eMbedded Visual C++ (eVC), which is now something like 8 years old and not supported (though it can still create apps for devices at least up through CE 5.0). | 1 | 1 | 0 | As it seems there is no scripting language for Windows mobile devices that gives access to phone (sms, mms, make a call, take photo). I wonder how complex it would be to make a Python library that would enable that (write something in C, compile, and import in PythonCE).
Question: Where shall start to understand how to compile a PythonCE module that will give additional functionality to Python on Windows mobile. Also, what is the required toolkit. Is it at all possible on Mac (Leopard)? | Extending PythonCE to Access gsm/camera/gps Easily from PythonCE | 0.066568 | 0 | 0 | 871 |
254,350 | 2008-10-31T17:47:00.000 | 2 | 0 | 1 | 0 | python,file,compare | 254,362 | 9 | false | 0 | 0 | f = open(filename1, "r").read()
f2 = open(filename2,"r").read()
print f == f2 | 1 | 70 | 0 | I don't care what the differences are. I just want to know whether the contents are different. | In Python, is there a concise way of comparing whether the contents of two text files are the same? | 0.044415 | 0 | 0 | 36,226 |
254,635 | 2008-10-31T19:20:00.000 | 3 | 0 | 1 | 0 | python,executable,pyinstaller | 4,902,830 | 3 | false | 0 | 0 | Using a earlier Python version will also decrease the size considerably if your really needing a small file size. I don't recommend using a very old version, Python2.3 would be the best option. I got my Python executable size to 700KB's! Also I prefer Py2Exe over Pyinstaller. | 3 | 9 | 0 | I plan to use PyInstaller to create a stand-alone python executable. PythonInstaller comes with built-in support for UPX and uses it to compress the executable but they are still really huge (about 2,7 mb).
Is there any way to create even smaller Python executables? For example using a shrinked python.dll or something similiar? | Tiny python executable? | 0.197375 | 0 | 0 | 3,991 |
254,635 | 2008-10-31T19:20:00.000 | 10 | 0 | 1 | 0 | python,executable,pyinstaller | 254,723 | 3 | true | 0 | 0 | If you recompile pythonxy.dll, you can omit modules that you don't need. Going by size, stripping off the unicode database and the CJK codes creates the largest code reduction. This, of course, assumes that you don't need these. Remove the modules from the pythoncore project, and also remove them from PC/config.c | 3 | 9 | 0 | I plan to use PyInstaller to create a stand-alone python executable. PythonInstaller comes with built-in support for UPX and uses it to compress the executable but they are still really huge (about 2,7 mb).
Is there any way to create even smaller Python executables? For example using a shrinked python.dll or something similiar? | Tiny python executable? | 1.2 | 0 | 0 | 3,991 |
254,635 | 2008-10-31T19:20:00.000 | 1 | 0 | 1 | 0 | python,executable,pyinstaller | 255,582 | 3 | false | 0 | 0 | You can't go too low in size, because you obviously need to bundle the Python interpreter in, and only that takes a considerable amount of space.
I had the same concerns once, and there are two approaches:
Install Python on the computers you want to run on and only distribute the scripts
Install Python in the internal network on some shared drive, and rig the users' PATH to recognize where Python is located. With some installation script / program trickery, users can be completely oblivious to this, and you'll get to distribute minimal applications. | 3 | 9 | 0 | I plan to use PyInstaller to create a stand-alone python executable. PythonInstaller comes with built-in support for UPX and uses it to compress the executable but they are still really huge (about 2,7 mb).
Is there any way to create even smaller Python executables? For example using a shrinked python.dll or something similiar? | Tiny python executable? | 0.066568 | 0 | 0 | 3,991 |
255,157 | 2008-10-31T22:37:00.000 | 3 | 0 | 0 | 1 | python,google-app-engine,rest,metaclass | 255,906 | 2 | false | 1 | 0 | Calling the handler from initialize isn't the right way anyway - if you do that, the webapp will then call the original handler as well.
Instead, you have a couple of options:
You can subclass webapp.WSGIApplication and override call to select the method based on _method when it exists.
You can check for the existence of _method in initialize, and if it exists, modify the request object's 'REQUEST_METHOD' environment variable accordingly. That will cause the WSGIApplication class to execute the method you choose.
Either way, take a look at google/appengine/ext/webapp/init.py in the SDK so you can see how it works. | 2 | 1 | 0 | In the context of a Google App Engine Webapp framework application:
I want to changed the request verb of a request in the case a
parameter _method is provided, for example if a POST request comes in
with a parameter _method=PUT, I need to change the request to call the
put method of the handler. This is to cope with the way prototype.js
works with verbs like PUT and DELETE(workaround for IE). Here is my
first attempt:
class MyRequestHandler(webapp.RequestHandler):
def initialize(self, request, response):
m = request.get('_method')
if m:
request.method = m.upper()
webapp.RequestHandler.initialize(self, request, response)
The problem is, for some reason whenever the redirect is done, the
self.request.params are emptied by the time the handling method(put or
delete) is called, even though they were populated when initialize was
called. Anyone have a clue why this is? As a workaround I thought I
could clone the params at initialize() time, but .copy() did not work,
and I haven't found a way to do that either.
Update: I received a very helpful response from Arachnid. The solution I ended up with uses a metaclass. It is found below. | How to override HTTP request verb in GAE | 0.291313 | 0 | 0 | 1,104 |
255,157 | 2008-10-31T22:37:00.000 | 2 | 0 | 0 | 1 | python,google-app-engine,rest,metaclass | 257,094 | 2 | false | 1 | 0 | Thats Arachnid for your response. Pointing me to the source of the framework was really helpful. Last I looked the source wasn't there(there was only .pyc), maybe it changed with the new version of the SDK. For my situation I think overriding WSGIApplication would have been the right thing to do. However, I chose to use a metaclass instead, because it didn't require me to cargo-cult(copy) a bunch of the framework code into my code and then modifying it. This is my solution:
class RequestHandlerMetaclass(type):
def __init__(cls, name, bases, dct):
super(RequestHandlerMetaclass, cls).__init__(name, bases, dct)
org_post = getattr(cls, 'post')
def post(self, *params, **kws):
verb = self.request.get('_method')
if verb:
verb = verb.upper()
if verb == 'DELETE':
self.delete(*params, **kws)
elif verb == 'PUT':
self.put(*params, **kws)
else:
org_post(self, *params, **kws)
setattr(cls, 'post', post)
class MyRequestHandler(webapp.RequestHandler):
__metaclass__ = RequestHandlerMetaclass | 2 | 1 | 0 | In the context of a Google App Engine Webapp framework application:
I want to changed the request verb of a request in the case a
parameter _method is provided, for example if a POST request comes in
with a parameter _method=PUT, I need to change the request to call the
put method of the handler. This is to cope with the way prototype.js
works with verbs like PUT and DELETE(workaround for IE). Here is my
first attempt:
class MyRequestHandler(webapp.RequestHandler):
def initialize(self, request, response):
m = request.get('_method')
if m:
request.method = m.upper()
webapp.RequestHandler.initialize(self, request, response)
The problem is, for some reason whenever the redirect is done, the
self.request.params are emptied by the time the handling method(put or
delete) is called, even though they were populated when initialize was
called. Anyone have a clue why this is? As a workaround I thought I
could clone the params at initialize() time, but .copy() did not work,
and I haven't found a way to do that either.
Update: I received a very helpful response from Arachnid. The solution I ended up with uses a metaclass. It is found below. | How to override HTTP request verb in GAE | 0.197375 | 0 | 0 | 1,104 |
256,021 | 2008-11-01T19:52:00.000 | 0 | 0 | 0 | 0 | python,web-applications,browser | 256,028 | 4 | false | 1 | 0 | You would have to write the web page in Python. There are many Python web frameworks out there (e.g. Django) that are easy to work with. You could convert your entire scripting framework to a web application that has a worker thread going and crawling through html pages, saving them to a particular location, indexing them for you to see and providing a delete button that calls the system's delete function on the particular file. | 2 | 2 | 0 | I have written a script that goes through a bunch of files and snips out a portion of the files for further processing. The script creates a new directory and creates new files for each snip that is taken out. I have to now evaluate each of the files that were created to see if it is what I needed. The script also creates an html index file with links to each of the snips. So I can click the hyperlink to see the file, make a note in a spreadsheet to indicate if the file is correct or not and then use the back button in the browser to take me back to the index list.
I was sitting here wondering if I could somehow create a delete button in the browser next to the hyperlink. My thought is I would click the hyperlink, make a judgment about the file and if it is not one I want to keep then when I get back to the main page I just press the delete button and it is gone from the directory.
Does anyone have any idea if this is possible. I am writing this in python but clearly the issue is is there a way to create an htm file with a delete button-I would just use Python to write the commands for the deletion button. | Can I Use Python to Make a Delete Button in a 'web page' | 0 | 0 | 1 | 1,222 |
256,021 | 2008-11-01T19:52:00.000 | 1 | 0 | 0 | 0 | python,web-applications,browser | 256,040 | 4 | false | 1 | 0 | You could make this even simpler by making it all happen in one main page. Instead of having a list of hyperlinks, just have the main page have one frame that loads one of the autocreated pages in it. Put a couple of buttons at the bottom - a "Keep this page" and a "Delete this page." When you click either button, the main page refreshes, this time with the next autocreated page in the frame.
You could make this as a cgi script in your favorite scripting language. You can't just do this in html because an html page only does stuff client-side, and you can only delete files server-side. You will probably need as cgi args the page to show in the frame, and the last page you viewed if the button click was a "delete". | 2 | 2 | 0 | I have written a script that goes through a bunch of files and snips out a portion of the files for further processing. The script creates a new directory and creates new files for each snip that is taken out. I have to now evaluate each of the files that were created to see if it is what I needed. The script also creates an html index file with links to each of the snips. So I can click the hyperlink to see the file, make a note in a spreadsheet to indicate if the file is correct or not and then use the back button in the browser to take me back to the index list.
I was sitting here wondering if I could somehow create a delete button in the browser next to the hyperlink. My thought is I would click the hyperlink, make a judgment about the file and if it is not one I want to keep then when I get back to the main page I just press the delete button and it is gone from the directory.
Does anyone have any idea if this is possible. I am writing this in python but clearly the issue is is there a way to create an htm file with a delete button-I would just use Python to write the commands for the deletion button. | Can I Use Python to Make a Delete Button in a 'web page' | 0.049958 | 0 | 1 | 1,222 |
257,398 | 2008-11-02T21:22:00.000 | 11 | 0 | 0 | 0 | python,user-controls,user-interface | 257,403 | 4 | true | 0 | 1 | Your best bet is the tkMessageBox module, which should work on all systems (as Python will typically come with Tkinter).
If you can restrict yourself to a specific operating system, better choices might be available. | 2 | 6 | 0 | Is there a UI library to create a message box or input box in python? | Message Box in Python | 1.2 | 0 | 0 | 6,196 |
257,398 | 2008-11-02T21:22:00.000 | 2 | 0 | 0 | 0 | python,user-controls,user-interface | 257,532 | 4 | false | 0 | 1 | I've heard good things about wx python, which is also multi-platform. | 2 | 6 | 0 | Is there a UI library to create a message box or input box in python? | Message Box in Python | 0.099668 | 0 | 0 | 6,196 |
257,409 | 2008-11-02T21:31:00.000 | 3 | 0 | 0 | 0 | python,screen-scraping | 257,413 | 7 | false | 1 | 0 | Use htmllib to extract all img tags (override do_img), then use urllib2 to download all the images. | 2 | 47 | 0 | I am writing a scraper that downloads all the image files from a HTML page and saves them to a specific folder. all the images are the part of the HTML page. | Download image file from the HTML page source using python? | 0.085505 | 0 | 1 | 97,893 |
257,409 | 2008-11-02T21:31:00.000 | 8 | 0 | 0 | 0 | python,screen-scraping | 257,412 | 7 | false | 1 | 0 | You have to download the page and parse html document, find your image with regex and download it.. You can use urllib2 for downloading and Beautiful Soup for parsing html file. | 2 | 47 | 0 | I am writing a scraper that downloads all the image files from a HTML page and saves them to a specific folder. all the images are the part of the HTML page. | Download image file from the HTML page source using python? | 1 | 0 | 1 | 97,893 |
257,481 | 2008-11-02T22:22:00.000 | 12 | 1 | 0 | 0 | python,wsgi,scgi | 778,530 | 3 | false | 0 | 0 | SCGI (like FastCGI) is a (serialized) protocol suitable for inter-process communication between a web-server and a web-application.
WSGI is a Python API, connecting two (or more) Python WSGI-compatible modules inside the same process (Python interpreter). One module represents the web-server (being either a Python in-process web-server implementation or a gateway to a web-server in another process via e.g. SCGI). The other module is or represents the web application. Additionally, zero or more modules between theses two modules, may serve as WSGI "middleware" modules, doing things like session/cookie management, content caching, authentication, etc. The WSGI API uses Python language features like iteration/generators and passing of callable objects between the cooperating WSGI-compatible modules. | 2 | 19 | 0 | What's the difference between these two?
Which is better/faster/reliable? | What's the difference between scgi and wsgi? | 1 | 0 | 0 | 16,163 |
257,481 | 2008-11-02T22:22:00.000 | 27 | 1 | 0 | 0 | python,wsgi,scgi | 257,642 | 3 | true | 0 | 0 | SCGI is a language-neutral means of connecting a front-end web server and a web application. WSGI is a Python-specific interface standard for web applications.
Though they both have roots in CGI, they're rather different in scope and you could indeed quite reasonably use both at once, for example having a mod_scgi on the webserver talk to a WSGI app run as an SCGI server. There are multiple library implementations that will run WSGI applications as SCGI servers for you (eg. wsgitools, cherrypy).
They are both 'reliable', in as much as you can consider a specification reliable as opposed to a particular implementation. These days you would probably write your application as a WSGI callable, and consider the question of deployment separately.
Maybe an Apache+mod_wsgi (embedded) interface might be a bit faster than an Apache+mod_scgi+(SCGI wrapper lib), but in all likelihood it's not going to be hugely different. More valuable is the ability to run the application on a variety of servers, platforms and connection standards. | 2 | 19 | 0 | What's the difference between these two?
Which is better/faster/reliable? | What's the difference between scgi and wsgi? | 1.2 | 0 | 0 | 16,163 |
257,730 | 2008-11-03T01:31:00.000 | 3 | 1 | 0 | 0 | python,ruby,scripting,groovy | 257,770 | 10 | false | 1 | 0 | This sort of adding-up-scores-by-features is not a good way to choose a programming language. You'd be better off choosing whichever you know the best. If you don't know any of them, try them out for a little while. If you have a really specific project in mind, then maybe some programming languages would be better, but if you just have general preferences you will never come to a consensus.
That said, Python is pretty flexible, it's the most popular on your list so the easiest to solve whatever sorts of problems you have by searching, so I'd recommend Python. | 7 | 35 | 0 | Considering the criteria listed below, which of Python, Groovy or Ruby would you use?
Criteria (Importance out of 10, 10 being most important)
Richness of API/libraries available (eg. maths, plotting, networking) (9)
Ability to embed in desktop (java/c++) applications (8)
Ease of deployment (8)
Ability to interface with DLLs/Shared Libraries (7)
Ability to generate GUIs (7)
Community/User support (6)
Portability (6)
Database manipulation (3)
Language/Semantics (2) | Python vs Groovy vs Ruby? (based on criteria listed in question) | 0.059928 | 0 | 0 | 36,111 |
257,730 | 2008-11-03T01:31:00.000 | 33 | 1 | 0 | 0 | python,ruby,scripting,groovy | 257,746 | 10 | true | 1 | 0 | I think it's going to be difficult to get an objective comparison. I personally prefer Python. To address one of your criteria, Python was designed from the start to be an embeddable language. It has a very rich C API, and the interpreter is modularized to make it easy to call from C. If Java is your host environment, you should look at Jython, an implementation of Python inside the Java environment (VM and libs). | 7 | 35 | 0 | Considering the criteria listed below, which of Python, Groovy or Ruby would you use?
Criteria (Importance out of 10, 10 being most important)
Richness of API/libraries available (eg. maths, plotting, networking) (9)
Ability to embed in desktop (java/c++) applications (8)
Ease of deployment (8)
Ability to interface with DLLs/Shared Libraries (7)
Ability to generate GUIs (7)
Community/User support (6)
Portability (6)
Database manipulation (3)
Language/Semantics (2) | Python vs Groovy vs Ruby? (based on criteria listed in question) | 1.2 | 0 | 0 | 36,111 |
257,730 | 2008-11-03T01:31:00.000 | 28 | 1 | 0 | 0 | python,ruby,scripting,groovy | 1,401,616 | 10 | false | 1 | 0 | Having worked with all 3 of them, this is what I can say:
Python
has very mature libraries
libraries are documented
documentation can be accessed from your debugger/shell at runtime through the docstrings
you can develop code without an IDE
Ruby
has some great libraries ( even though some are badly documented )
Ruby's instrospection mechanisms are great. They make writing code pretty easy ( even if documentation is not available )
you can develop code without an IDE
Groovy
you can benefit from everything Java has to offer
syntax is somewhat inspired from Ruby
it's hard to write code without an IDE. You have no way to debug stuff from your console ( this is something you can easily do in Python/Ruby ) and the available Groovy plugins have a lot of catching up to do. I wrote some apps using Groovy and as they get bigger I regret not going with Ruby/Python ( debugging would have been WAY more easier ). If you'll only develop from an IDE, Groovy's a cool language. | 7 | 35 | 0 | Considering the criteria listed below, which of Python, Groovy or Ruby would you use?
Criteria (Importance out of 10, 10 being most important)
Richness of API/libraries available (eg. maths, plotting, networking) (9)
Ability to embed in desktop (java/c++) applications (8)
Ease of deployment (8)
Ability to interface with DLLs/Shared Libraries (7)
Ability to generate GUIs (7)
Community/User support (6)
Portability (6)
Database manipulation (3)
Language/Semantics (2) | Python vs Groovy vs Ruby? (based on criteria listed in question) | 1 | 0 | 0 | 36,111 |
257,730 | 2008-11-03T01:31:00.000 | 8 | 1 | 0 | 0 | python,ruby,scripting,groovy | 326,962 | 10 | false | 1 | 0 | try Groovy .. it has all features that you need there. You can use existing java lib without any modification on its classes.
basically .. groovy is java++, it is more dynamic and fun to learn (just like ruby)
I dont like ruby or python syntax so I will put them behind. Groovy is just like C/C++ syntax so I like him lol :) | 7 | 35 | 0 | Considering the criteria listed below, which of Python, Groovy or Ruby would you use?
Criteria (Importance out of 10, 10 being most important)
Richness of API/libraries available (eg. maths, plotting, networking) (9)
Ability to embed in desktop (java/c++) applications (8)
Ease of deployment (8)
Ability to interface with DLLs/Shared Libraries (7)
Ability to generate GUIs (7)
Community/User support (6)
Portability (6)
Database manipulation (3)
Language/Semantics (2) | Python vs Groovy vs Ruby? (based on criteria listed in question) | 1 | 0 | 0 | 36,111 |
257,730 | 2008-11-03T01:31:00.000 | 7 | 1 | 0 | 0 | python,ruby,scripting,groovy | 257,831 | 10 | false | 1 | 0 | Python has all nine criteria. It scores a 56.
I'm sure Ruby has everything Python has. It seems to have fewer libraries. So it scores a 51.
I don't know if Groovy has every feature.
Since Python is 56 and Ruby is a 51, Python just barely edges out Ruby.
However, I think this kind of decision can still boil down to some subjective issues outside these nine criteria. | 7 | 35 | 0 | Considering the criteria listed below, which of Python, Groovy or Ruby would you use?
Criteria (Importance out of 10, 10 being most important)
Richness of API/libraries available (eg. maths, plotting, networking) (9)
Ability to embed in desktop (java/c++) applications (8)
Ease of deployment (8)
Ability to interface with DLLs/Shared Libraries (7)
Ability to generate GUIs (7)
Community/User support (6)
Portability (6)
Database manipulation (3)
Language/Semantics (2) | Python vs Groovy vs Ruby? (based on criteria listed in question) | 1 | 0 | 0 | 36,111 |
257,730 | 2008-11-03T01:31:00.000 | 24 | 1 | 0 | 0 | python,ruby,scripting,groovy | 257,776 | 10 | false | 1 | 0 | Just to muddy the waters...
Groovy give you access to Java. Java has an extremely rich set of APIs/Libraries, applications, etc.
Groovy is embeddable, although easiest in Java.
DLLs/Libraries (if you're talking about non-Groovy/Java) may be somewhat problematic, although there are ways and some APIs to help.
I've done some Python programming, but being more familiar with Java, Groovy comes a lot easier to me. | 7 | 35 | 0 | Considering the criteria listed below, which of Python, Groovy or Ruby would you use?
Criteria (Importance out of 10, 10 being most important)
Richness of API/libraries available (eg. maths, plotting, networking) (9)
Ability to embed in desktop (java/c++) applications (8)
Ease of deployment (8)
Ability to interface with DLLs/Shared Libraries (7)
Ability to generate GUIs (7)
Community/User support (6)
Portability (6)
Database manipulation (3)
Language/Semantics (2) | Python vs Groovy vs Ruby? (based on criteria listed in question) | 1 | 0 | 0 | 36,111 |
257,730 | 2008-11-03T01:31:00.000 | 0 | 1 | 0 | 0 | python,ruby,scripting,groovy | 257,738 | 10 | false | 1 | 0 | I know it's not on your list, but at least look at perl.
Richness of Api/Libraries to sink a ship.
Runs on more systems than most people realise exists.
Works well with Binary libraries.
Has a huge community.
Portability, See above.
Database manipulation: more ways to do it. ( Pick your favorite module )
And one of the most expressive/terse languages around. | 7 | 35 | 0 | Considering the criteria listed below, which of Python, Groovy or Ruby would you use?
Criteria (Importance out of 10, 10 being most important)
Richness of API/libraries available (eg. maths, plotting, networking) (9)
Ability to embed in desktop (java/c++) applications (8)
Ease of deployment (8)
Ability to interface with DLLs/Shared Libraries (7)
Ability to generate GUIs (7)
Community/User support (6)
Portability (6)
Database manipulation (3)
Language/Semantics (2) | Python vs Groovy vs Ruby? (based on criteria listed in question) | 0 | 0 | 0 | 36,111 |
258,775 | 2008-11-03T14:28:00.000 | 5 | 0 | 0 | 0 | python,sqlalchemy | 261,191 | 3 | true | 0 | 0 | I think you could look at the child's __dict__ attribute dictionary to check if the data is already there or not. | 1 | 16 | 0 | With SQLAlchemy, is there a way to know beforehand whether a relation would be lazy-loaded?
For example, given a lazy parent->children relation and an instance X of "parent", I'd like to know if "X.children" is already loaded, without triggering the query. | How to find out if a lazy relation isn't loaded yet, with SQLAlchemy? | 1.2 | 1 | 0 | 3,701 |
260,165 | 2008-11-03T22:08:00.000 | 14 | 1 | 1 | 0 | python,uml,diagram | 260,196 | 10 | false | 0 | 0 | Certain classes of well-behaved programs may be diagrammable, but in the general case, it can't be done. Python objects can be extended at run time, and objects of any type can be assigned to any instance variable. Figuring out what classes an object can contain pointers to (composition) would require a full understanding of the runtime behavior of the program.
Python's metaclass capabilities mean that reasoning about the inheritance structure would also require a full understanding of the runtime behavior of the program.
To prove that these are impossible, you argue that if such a UML diagrammer existed, then you could take an arbitrary program, convert "halt" statements into statements that would impact the UML diagram, and use the UML diagrammer to solve the halting problem, which as we know is impossible. | 2 | 355 | 0 | A colleague is looking to generate UML class diagrams from heaps of Python source code.
He's primarily interested in the inheritance relationships, and mildly interested in compositional relationships, and doesn't care much about class attributes that are just Python primitives.
The source code is pretty straightforward and not tremendously evil--it doesn't do any fancy metaclass magic, for example. (It's mostly from the days of Python 1.5.2, with some sprinklings of "modern" 2.3ish stuff.)
What's the best existing solution to recommend? | What's the best way to generate a UML diagram from Python source code? | 1 | 0 | 0 | 274,257 |
260,165 | 2008-11-03T22:08:00.000 | 5 | 1 | 1 | 0 | python,uml,diagram | 6,606,829 | 10 | false | 0 | 0 | Umbrello does that too. in the menu go to Code -> import project and then point to the root deirectory of your project. then it reverses the code for ya... | 2 | 355 | 0 | A colleague is looking to generate UML class diagrams from heaps of Python source code.
He's primarily interested in the inheritance relationships, and mildly interested in compositional relationships, and doesn't care much about class attributes that are just Python primitives.
The source code is pretty straightforward and not tremendously evil--it doesn't do any fancy metaclass magic, for example. (It's mostly from the days of Python 1.5.2, with some sprinklings of "modern" 2.3ish stuff.)
What's the best existing solution to recommend? | What's the best way to generate a UML diagram from Python source code? | 0.099668 | 0 | 0 | 274,257 |
260,738 | 2008-11-04T03:11:00.000 | -1 | 1 | 0 | 1 | python,audio | 22,689,253 | 25 | false | 0 | 0 | If you're on OSX, you can use the "os" module or "subprocess" etc. to call the OSX "play" command. From the OSX shell, it looks like
play "bah.wav"
It starts to play in about a half-second on my machine. | 1 | 135 | 0 | How can I play audio (it would be like a 1 second sound) from a Python script?
It would be best if it was platform independent, but firstly it needs to work on a Mac.
I know I could just execute the afplay file.mp3 command from within Python, but is it possible to do it in raw Python? I would also be better if it didn't rely on external libraries. | Play audio with Python | -0.008 | 0 | 0 | 259,664 |
261,638 | 2008-11-04T11:57:00.000 | 318 | 0 | 1 | 0 | python,licensing,obfuscation,copy-protection | 261,817 | 28 | false | 0 | 0 | Python is not the tool you need
You must use the right tool to do the right thing, and Python was not designed to be obfuscated. It's the contrary; everything is open or easy to reveal or modify in Python because that's the language's philosophy.
If you want something you can't see through, look for another tool. This is not a bad thing, it is important that several different tools exist for different usages.
Obfuscation is really hard
Even compiled programs can be reverse-engineered so don't think that you can fully protect any code. You can analyze obfuscated PHP, break the flash encryption key, etc. Newer versions of Windows are cracked every time.
Having a legal requirement is a good way to go
You cannot prevent somebody from misusing your code, but you can easily discover if someone does. Therefore, it's just a casual legal issue.
Code protection is overrated
Nowadays, business models tend to go for selling services instead of products. You cannot copy a service, pirate nor steal it. Maybe it's time to consider to go with the flow... | 12 | 729 | 0 | I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time-restricted license file.
If we distribute the .py files or even .pyc files it will be easy to (decompile and) remove the code that checks the license file.
Another aspect is that my employer does not want the code to be read by our customers, fearing that the code may be stolen or at least the "novel ideas".
Is there a good way to handle this problem? | How do I protect Python code from being read by users? | 1 | 0 | 0 | 386,257 |
261,638 | 2008-11-04T11:57:00.000 | 10 | 0 | 1 | 0 | python,licensing,obfuscation,copy-protection | 261,797 | 28 | false | 0 | 0 | Depending in who the client is, a simple protection mechanism, combined with a sensible license agreement will be far more effective than any complex licensing/encryption/obfuscation system.
The best solution would be selling the code as a service, say by hosting the service, or offering support - although that isn't always practical.
Shipping the code as .pyc files will prevent your protection being foiled by a few #s, but it's hardly effective anti-piracy protection (as if there is such a technology), and at the end of the day, it shouldn't achieve anything that a decent license agreement with the company will.
Concentrate on making your code as nice to use as possible - having happy customers will make your company far more money than preventing some theoretical piracy.. | 12 | 729 | 0 | I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time-restricted license file.
If we distribute the .py files or even .pyc files it will be easy to (decompile and) remove the code that checks the license file.
Another aspect is that my employer does not want the code to be read by our customers, fearing that the code may be stolen or at least the "novel ideas".
Is there a good way to handle this problem? | How do I protect Python code from being read by users? | 1 | 0 | 0 | 386,257 |
261,638 | 2008-11-04T11:57:00.000 | 5 | 0 | 1 | 0 | python,licensing,obfuscation,copy-protection | 2,987,179 | 28 | false | 0 | 0 | Idea of having time restricted license and check for it in locally installed program will not work. Even with perfect obfuscation, license check can be removed. However if you check license on remote system and run significant part of the program on your closed remote system, you will be able to protect your IP.
Preventing competitors from using the source code as their own or write their inspired version of the same code, one way to protect is to add signatures to your program logic (some secrets to be able to prove that code was stolen from you) and obfuscate the python source code so, it's hard to read and utilize.
Good obfuscation adds basically the same protection to your code, that compiling it to executable (and stripping binary) does. Figuring out how obfuscated complex code works might be even harder than actually writing your own implementation.
This will not help preventing hacking of your program. Even with obfuscation code license stuff will be cracked and program may be modified to have slightly different behaviour (in the same way that compiling code to binary does not help protection of native programs).
In addition to symbol obfuscation might be good idea to unrefactor the code, which makes everything even more confusing if e.g. call graphs points to many different places even if actually those different places does eventually the same thing.
Logical signature inside obfuscated code (e.g. you may create table of values which are used by program logic, but also used as signature), which can be used to determine that code is originated from you. If someone decides to use your obfuscated code module as part of their own product (even after reobfuscating it to make it seem different) you can show, that code is stolen with your secret signature. | 12 | 729 | 0 | I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time-restricted license file.
If we distribute the .py files or even .pyc files it will be easy to (decompile and) remove the code that checks the license file.
Another aspect is that my employer does not want the code to be read by our customers, fearing that the code may be stolen or at least the "novel ideas".
Is there a good way to handle this problem? | How do I protect Python code from being read by users? | 0.035699 | 0 | 0 | 386,257 |
261,638 | 2008-11-04T11:57:00.000 | 4 | 0 | 1 | 0 | python,licensing,obfuscation,copy-protection | 261,723 | 28 | false | 0 | 0 | I have looked at software protection in general for my own projects and the general philosophy is that complete protection is impossible. The only thing that you can hope to achieve is to add protection to a level that would cost your customer more to bypass than it would to purchase another license.
With that said I was just checking google for python obsfucation and not turning up a lot of anything. In a .Net solution, obsfucation would be a first approach to your problem on a windows platform, but I am not sure if anyone has solutions on Linux that work with Mono.
The next thing would be to write your code in a compiled language, or if you really want to go all the way, then in assembler. A stripped out executable would be a lot harder to decompile than an interpreted language.
It all comes down to tradeoffs. On one end you have ease of software development in python, in which it is also very hard to hide secrets. On the other end you have software written in assembler which is much harder to write, but is much easier to hide secrets.
Your boss has to choose a point somewhere along that continuum that supports his requirements. And then he has to give you the tools and time so you can build what he wants. However my bet is that he will object to real development costs versus potential monetary losses. | 12 | 729 | 0 | I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time-restricted license file.
If we distribute the .py files or even .pyc files it will be easy to (decompile and) remove the code that checks the license file.
Another aspect is that my employer does not want the code to be read by our customers, fearing that the code may be stolen or at least the "novel ideas".
Is there a good way to handle this problem? | How do I protect Python code from being read by users? | 0.028564 | 0 | 0 | 386,257 |
261,638 | 2008-11-04T11:57:00.000 | 13 | 0 | 1 | 0 | python,licensing,obfuscation,copy-protection | 11,315,793 | 28 | false | 0 | 0 | I think there is one more method to protect your Python code; part of the Obfuscation method. I believe there was a game like Mount and Blade or something that changed and recompiled their own python interpreter (the original interpreter which i believe is open source) and just changed the OP codes in the OP code table to be different then the standard python OP codes.
So the python source is unmodified but the file extensions of the *.pyc files are different and the op codes don't match to the public python.exe interpreter. If you checked the games data files all the data was in Python source format.
All sorts of nasty tricks can be done to mess with immature hackers this way. Stopping a bunch of inexperienced hackers is easy. It's the professional hackers that you will not likely beat. But most companies don't keep pro hackers on staff long I imagine (likely because things get hacked). But immature hackers are all over the place (read as curious IT staff).
You could for example, in a modified interpreter, allow it to check for certain comments or doc strings in your source. You could have special OP codes for such lines of code. For example:
OP 234 is for source line "# Copyright I wrote this"
or compile that line into op codes that are equivalent to "if False:" if "# Copyright" is missing. Basically disabling a whole block of code for what appears to be some obscure reason.
One use case where recompiling a modified interpreter may be feasible is where you didn't write the app, the app is big, but you are paid to protect it, such as when you're a dedicated server admin for a financial app.
I find it a little contradictory to leave the source or opcodes open for eyeballs, but use SSL for network traffic. SSL is not 100% safe either. But it's used to stop MOST eyes from reading it. A wee bit precaution is sensible.
Also, if enough people deem that Python source and opcodes are too visible, it's likely someone will eventually develop at least a simple protection tool for it. So the more people asking "how to protect Python app" only promotes that development. | 12 | 729 | 0 | I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time-restricted license file.
If we distribute the .py files or even .pyc files it will be easy to (decompile and) remove the code that checks the license file.
Another aspect is that my employer does not want the code to be read by our customers, fearing that the code may be stolen or at least the "novel ideas".
Is there a good way to handle this problem? | How do I protect Python code from being read by users? | 1 | 0 | 0 | 386,257 |
261,638 | 2008-11-04T11:57:00.000 | 20 | 0 | 1 | 0 | python,licensing,obfuscation,copy-protection | 554,565 | 28 | false | 0 | 0 | Shipping .pyc files has its problems - they are not compatible with any other python version than the python version they were created with, which means you must know which python version is running on the systems the product will run on. That's a very limiting factor. | 12 | 729 | 0 | I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time-restricted license file.
If we distribute the .py files or even .pyc files it will be easy to (decompile and) remove the code that checks the license file.
Another aspect is that my employer does not want the code to be read by our customers, fearing that the code may be stolen or at least the "novel ideas".
Is there a good way to handle this problem? | How do I protect Python code from being read by users? | 1 | 0 | 0 | 386,257 |
261,638 | 2008-11-04T11:57:00.000 | 6 | 0 | 1 | 0 | python,licensing,obfuscation,copy-protection | 262,895 | 28 | false | 0 | 0 | The best you can do with Python is to obscure things.
Strip out all docstrings
Distribute only the .pyc compiled files.
freeze it
Obscure your constants inside a class/module so that help(config) doesn't show everything
You may be able to add some additional obscurity by encrypting part of it and decrypting it on the fly and passing it to eval(). But no matter what you do someone can break it.
None of this will stop a determined attacker from disassembling the bytecode or digging through your api with help, dir, etc. | 12 | 729 | 0 | I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time-restricted license file.
If we distribute the .py files or even .pyc files it will be easy to (decompile and) remove the code that checks the license file.
Another aspect is that my employer does not want the code to be read by our customers, fearing that the code may be stolen or at least the "novel ideas".
Is there a good way to handle this problem? | How do I protect Python code from being read by users? | 1 | 0 | 0 | 386,257 |
261,638 | 2008-11-04T11:57:00.000 | 12 | 0 | 1 | 0 | python,licensing,obfuscation,copy-protection | 263,314 | 28 | false | 0 | 0 | The reliable only way to protect code is to run it on a server you control and provide your clients with a client which interfaces with that server. | 12 | 729 | 0 | I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time-restricted license file.
If we distribute the .py files or even .pyc files it will be easy to (decompile and) remove the code that checks the license file.
Another aspect is that my employer does not want the code to be read by our customers, fearing that the code may be stolen or at least the "novel ideas".
Is there a good way to handle this problem? | How do I protect Python code from being read by users? | 1 | 0 | 0 | 386,257 |
261,638 | 2008-11-04T11:57:00.000 | 6 | 0 | 1 | 0 | python,licensing,obfuscation,copy-protection | 261,704 | 28 | false | 0 | 0 | You should take a look at how the guys at getdropbox.com do it for their client software, including Linux. It's quite tricky to crack and requires some quite creative disassembly to get past the protection mechanisms. | 12 | 729 | 0 | I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time-restricted license file.
If we distribute the .py files or even .pyc files it will be easy to (decompile and) remove the code that checks the license file.
Another aspect is that my employer does not want the code to be read by our customers, fearing that the code may be stolen or at least the "novel ideas".
Is there a good way to handle this problem? | How do I protect Python code from being read by users? | 1 | 0 | 0 | 386,257 |
261,638 | 2008-11-04T11:57:00.000 | 16 | 0 | 1 | 0 | python,licensing,obfuscation,copy-protection | 264,450 | 28 | false | 0 | 0 | Though there's no perfect solution, the following can be done:
Move some critical piece of startup code into a native library.
Enforce the license check in the native library.
If the call to the native code were to be removed, the program wouldn't start anyway. If it's not removed then the license will be enforced.
Though this is not a cross-platform or a pure-Python solution, it will work. | 12 | 729 | 0 | I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time-restricted license file.
If we distribute the .py files or even .pyc files it will be easy to (decompile and) remove the code that checks the license file.
Another aspect is that my employer does not want the code to be read by our customers, fearing that the code may be stolen or at least the "novel ideas".
Is there a good way to handle this problem? | How do I protect Python code from being read by users? | 1 | 0 | 0 | 386,257 |
261,638 | 2008-11-04T11:57:00.000 | 18 | 0 | 1 | 0 | python,licensing,obfuscation,copy-protection | 261,728 | 28 | false | 0 | 0 | In some circumstances, it may be possible to move (all, or at least a key part) of the software into a web service that your organization hosts.
That way, the license checks can be performed in the safety of your own server room. | 12 | 729 | 0 | I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time-restricted license file.
If we distribute the .py files or even .pyc files it will be easy to (decompile and) remove the code that checks the license file.
Another aspect is that my employer does not want the code to be read by our customers, fearing that the code may be stolen or at least the "novel ideas".
Is there a good way to handle this problem? | How do I protect Python code from being read by users? | 1 | 0 | 0 | 386,257 |
261,638 | 2008-11-04T11:57:00.000 | 35 | 0 | 1 | 0 | python,licensing,obfuscation,copy-protection | 261,719 | 28 | false | 0 | 0 | Is your employer aware that he can "steal" back any ideas that other people get from your code? I mean, if they can read your work, so can you theirs. Maybe looking at how you can benefit from the situation would yield a better return of your investment than fearing how much you could lose.
[EDIT] Answer to Nick's comment:
Nothing gained and nothing lost. The customer has what he wants (and paid for it since he did the change himself). Since he doesn't release the change, it's as if it didn't happen for everyone else.
Now if the customer sells the software, they have to change the copyright notice (which is illegal, so you can sue and will win -> simple case).
If they don't change the copyright notice, the 2nd level customers will notice that the software comes from you original and wonder what is going on. Chances are that they will contact you and so you will learn about the reselling of your work.
Again we have two cases: The original customer sold only a few copies. That means they didn't make much money anyway, so why bother. Or they sold in volume. That means better chances for you to learn about what they do and do something about it.
But in the end, most companies try to comply to the law (once their reputation is ruined, it's much harder to do business). So they will not steal your work but work with you to improve it. So if you include the source (with a license that protects you from simple reselling), chances are that they will simply push back changes they made since that will make sure the change is in the next version and they don't have to maintain it. That's win-win: You get changes and they can make the change themselves if they really, desperately need it even if you're unwilling to include it in the official release. | 12 | 729 | 0 | I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time-restricted license file.
If we distribute the .py files or even .pyc files it will be easy to (decompile and) remove the code that checks the license file.
Another aspect is that my employer does not want the code to be read by our customers, fearing that the code may be stolen or at least the "novel ideas".
Is there a good way to handle this problem? | How do I protect Python code from being read by users? | 1 | 0 | 0 | 386,257 |
262,460 | 2008-11-04T16:53:00.000 | 2 | 0 | 1 | 0 | python,time,key,indefinite | 262,490 | 7 | true | 0 | 0 | The simplest way is just to write a program with an infinite loop, and then hit control-C to stop it. Without more description it's hard to know if this works for you.
If you do it time-based, you don't need a generator. You can just have it pause for user input, something like a "Continue? [y/n]", read from stdin, and depending on what you get either exit the loop or not. | 1 | 1 | 0 | Is there any way to make a function (the ones I'm thinking of are in the style of the simple ones I've made which generate the fibonnacci sequence from 0 to a point, and all the primes between two points) run indefinitely. E.g. until I press a certain key or until a time has passed, rather than until a number reaches a certain point?
Also, if it is based on time then is there any way I could just extend the time and start it going from that point again, rather than having to start again from 0? I am aware there is a time module, i just don't know much about it. | making a programme run indefinitely in python | 1.2 | 0 | 0 | 3,719 |
263,773 | 2008-11-04T22:47:00.000 | 4 | 0 | 0 | 1 | python,linux,ubuntu | 263,859 | 3 | false | 0 | 0 | Instead of chmod u+sing the shutdown command, allowing passwordless sudo access to that command would be better..
As for allowing shutdown at the end of the script, I suppose you could run the entire script with sudo, then drop privileges to the initial user at the start of the script? | 3 | 7 | 0 | I have a python script that I would like to add a "Shutdown when done" feature to.
I know I can use gksudo (when the user clicks on "shutdown when done") to ask the user for root privileges but how can I use those privileges at a later time (when the script is actually finished).
I have thought about chmod u+s on the shutdown command so I don't need a password but I really don't want to do that.
Any ideas how I can achieve this?
Thanks in advance,
Ashy. | How can I ask for root password but perform the action at a later time? | 0.26052 | 0 | 0 | 552 |
263,773 | 2008-11-04T22:47:00.000 | 1 | 0 | 0 | 1 | python,linux,ubuntu | 263,851 | 3 | false | 0 | 0 | Escalate priority, spawn (fork (2)) a separate process that will wait (2), and drop priority in the main process. | 3 | 7 | 0 | I have a python script that I would like to add a "Shutdown when done" feature to.
I know I can use gksudo (when the user clicks on "shutdown when done") to ask the user for root privileges but how can I use those privileges at a later time (when the script is actually finished).
I have thought about chmod u+s on the shutdown command so I don't need a password but I really don't want to do that.
Any ideas how I can achieve this?
Thanks in advance,
Ashy. | How can I ask for root password but perform the action at a later time? | 0.066568 | 0 | 0 | 552 |
263,773 | 2008-11-04T22:47:00.000 | 3 | 0 | 0 | 1 | python,linux,ubuntu | 263,804 | 3 | true | 0 | 0 | gksudo should have a timeout, I believe it's from the time you last executed a gksudo command.
So I think I'd just throw out a "gksudo echo meh" or something every minute. Should reset the timer and keep you active until you reboot. | 3 | 7 | 0 | I have a python script that I would like to add a "Shutdown when done" feature to.
I know I can use gksudo (when the user clicks on "shutdown when done") to ask the user for root privileges but how can I use those privileges at a later time (when the script is actually finished).
I have thought about chmod u+s on the shutdown command so I don't need a password but I really don't want to do that.
Any ideas how I can achieve this?
Thanks in advance,
Ashy. | How can I ask for root password but perform the action at a later time? | 1.2 | 0 | 0 | 552 |
264,154 | 2008-11-05T01:56:00.000 | 0 | 0 | 0 | 0 | python,google-app-engine,google-cloud-datastore | 1,000,121 | 16 | false | 1 | 0 | The proposed solution only works if entries are sorted by key... If you are sorting by another column first, you still have to use a limit(offset, count) clause, then the 1000 entries limitation still apply. It is the same if you use two requests : one for retrieving indexes (with conditions and sort) and another using where index in () with a subset of indexes from the first result, as the first request cannot return more than 1000 keys ? (The Google Queries on Keys section does not state clearly if we have to sort by key to remove the 1000 results limitation) | 1 | 51 | 0 | How can I fetch more than 1000 record from data store and put all in one single list to pass to django? | How to fetch more than 1000? | 0 | 0 | 0 | 32,035 |
265,687 | 2008-11-05T16:23:00.000 | 12 | 0 | 1 | 0 | python,multithreading,scripting,locking,bytecode | 266,111 | 6 | false | 0 | 0 | Python, like perl 5, was not designed from the ground up to be thread safe. Threads were grafted on after the fact, so the global interpreter lock is used to maintain mutual exclusion to where only one thread is executing code at a given time in the bowels of the interpreter.
Individual Python threads are cooperatively multitasked by the interpreter itself by cycling the lock every so often.
Grabbing the lock yourself is needed when you are talking to Python from C when other Python threads are active to 'opt in' to this protocol and make sure that nothing unsafe happens behind your back.
Other systems that have a single-threaded heritage that later evolved into mulithreaded systems often have some mechanism of this sort. For instance, the Linux kernel has the "Big Kernel Lock" from its early SMP days. Gradually over time as multi-threading performance becomes an issue there is a tendency to try to break these sorts of locks up into smaller pieces or replace them with lock-free algorithms and data structures where possible to maximize throughput. | 1 | 91 | 0 | What is exactly the function of Python's Global Interpreter Lock?
Do other languages that are compiled to bytecode employ a similar mechanism? | Why the Global Interpreter Lock? | 1 | 0 | 0 | 17,616 |
266,849 | 2008-11-05T21:50:00.000 | 1 | 1 | 0 | 0 | python,smtp,tor | 275,164 | 2 | true | 0 | 0 | Because of abuse by spammers, many Tor egress nodes decline to emit port 25 (SMTP) traffic, so you may have problems. | 1 | 2 | 0 | I'm conducting experiments regarding e-mail spam. One of these experiments require sending mail thru Tor. Since I'm using Python and smtplib for my experiments, I'm looking for a way to use the Tor proxy (or other method) to perform that mail sending.
Ideas how this can be done? | Using Python's smtplib with Tor | 1.2 | 0 | 1 | 2,405 |
267,660 | 2008-11-06T04:44:00.000 | 2 | 0 | 0 | 0 | python,image,graphics,animation,drawing | 267,698 | 3 | false | 0 | 1 | The client will present this as a slide in a presentation in a windows machine
I think this is the key to your answer. Before going to a 3d implementation and writing all the code in the world to create this feature, you need to look at the presentation software. Chances are, your options will boil down to two things:
Animated Gif
Custom Presentation Scripts
Obviously, an animated gif is not ideal due to the fact that it repeats when it is done rendering, and to make it last a long time would make a large gif.
Custom Presentation Scripts would probably be the other way to allow him to bring it up in a presentation without running any side-programs, or doing anything strange. I'm not sure which presentation application is the target, but this could be valuable information.
He sounds like he's more non-technical and requesting something he doesn't realize will be difficult. I think you should come up with some options, explain the difficulty in implementing them, and suggest another solution that falls into the 'bang for your buck' range. | 2 | 1 | 0 | Background
I have been asked by a client to create a picture of the world which has animated arrows/rays that come from one part of the world to another.
The rays will be randomized, will represent a transaction, will fade out after they happen and will increase in frequency as time goes on. The rays will start in one country's boundary and end in another's. As each animated transaction happens a continuously updating sum of the amounts of all the transactions will be shown at the bottom of the image. The amounts of the individual transactions will be randomized. There will also be a year showing on the image that will increment every n seconds.
The randomization, summation and incrementing are not a problem for me, but I am at a loss as to how to approach the animation of the arrows/rays.
My question is what is the best way to do this? What frameworks/libraries are best suited for this job?
I am most fluent in python so python suggestions are most easy for me, but I am open to any elegant way to do this.
The client will present this as a slide in a presentation in a windows machine. | How to create a picture with animated aspects programmatically | 0.132549 | 0 | 0 | 902 |
267,660 | 2008-11-06T04:44:00.000 | 1 | 0 | 0 | 0 | python,image,graphics,animation,drawing | 267,676 | 3 | false | 0 | 1 | It depends largely on the effort you want to expend on this, but the basic outline of an easy way. Would be to load an image of an arrow, and use a drawing library to color and rotate it in the direction you want to point(or draw it using shapes/curves).
Finally to actually animate it interpolate between the coordinates based on time.
If its just for a presentation though, I would use Macromedia Flash, or a similar animation program.(would do the same as above but you don't need to program anything) | 2 | 1 | 0 | Background
I have been asked by a client to create a picture of the world which has animated arrows/rays that come from one part of the world to another.
The rays will be randomized, will represent a transaction, will fade out after they happen and will increase in frequency as time goes on. The rays will start in one country's boundary and end in another's. As each animated transaction happens a continuously updating sum of the amounts of all the transactions will be shown at the bottom of the image. The amounts of the individual transactions will be randomized. There will also be a year showing on the image that will increment every n seconds.
The randomization, summation and incrementing are not a problem for me, but I am at a loss as to how to approach the animation of the arrows/rays.
My question is what is the best way to do this? What frameworks/libraries are best suited for this job?
I am most fluent in python so python suggestions are most easy for me, but I am open to any elegant way to do this.
The client will present this as a slide in a presentation in a windows machine. | How to create a picture with animated aspects programmatically | 0.066568 | 0 | 0 | 902 |
267,977 | 2008-11-06T08:50:00.000 | -1 | 0 | 1 | 1 | python | 268,348 | 5 | false | 0 | 0 | "I often find a need to put paths in my code" -- this isn't very Pythonic to begin with.
Ideally, your code lives in some place like site-packages and that's the end of that.
Often, we have an installed "application" that uses a fairly fixed set of directories for working files. In linux, we get this information from environment variables and configuration files owned by the specific userid that's running the application.
I don't think that you should be putting paths in your code. I think there's a better way.
[I just wrote our app installation tool, which does create all the config files for a fairly complex app. I used the Mako templates tool to generate all four files from templates.] | 2 | 2 | 0 | I often find a need to put paths in my code in order to find data or in some cases tool-specific modules. I've so far always used autotools because of this--it's just so easy to call sed to replace a few strings at build time. However, I'd like to find a more Pythonic way of doing this, i.e. use distutils or some other blessed way of building/installing. I've never managed to find anything relating to this in distutils documentation though so how do other people solve this problem? | Python distutils and replacing strings in code | -0.039979 | 0 | 0 | 283 |
267,977 | 2008-11-06T08:50:00.000 | 0 | 0 | 1 | 1 | python | 348,082 | 5 | false | 0 | 0 | The OP here, I've not finally managed to log in using my OpenID.
@S.Lott
Point well taken, but for some Linux distros it seems to be standard to install application-specific data and application-specific modules in specific locations. I think that making these locations configurable at build/install time is a nice thing to do for people packaging my application. AFAICS “the pythonic way” in this case would force these packagers to apply patches to my code.
I'm also in the habit of writing applications where the executable part is a tiny wrapper around a main function in an application-specific module. To me it doesn't seem right to stick this application-specific module in /usr/lib/python2.5/site-packages. | 2 | 2 | 0 | I often find a need to put paths in my code in order to find data or in some cases tool-specific modules. I've so far always used autotools because of this--it's just so easy to call sed to replace a few strings at build time. However, I'd like to find a more Pythonic way of doing this, i.e. use distutils or some other blessed way of building/installing. I've never managed to find anything relating to this in distutils documentation though so how do other people solve this problem? | Python distutils and replacing strings in code | 0 | 0 | 0 | 283 |
268,089 | 2008-11-06T09:39:00.000 | 3 | 0 | 0 | 0 | python,django,database-connection | 272,522 | 10 | false | 1 | 0 | If you read a few of the many (many) threads on this subject in django-dev, you will see that what looks straightforward, isn't. If you pick a single use case, then it looks easy, but as soon as you start to generalize in any way you start to run into trouble.
To use the above-referenced thread as an example, when you say "multiple databases", which of the following are you talking about?
All DB on the same machine under the same engine.
All DB on same machine, different engines (E.g. MySQL + PostgreSQL)
One Master DB with N read-only slaves on different machines.
Sharding of tables across multiple DB servers.
Will you need:
Foreign keys across DBs
JOINs across machines and/or engines
etc. etc.
One of the problems with a slick ORM like Django's is that it hides all of those messy details under a nice paint job. To continue to do that, but to then add in any of the above, is Not Easy (tm). | 1 | 10 | 0 | From some forum I came to know that Multiple database support is added in Django at lower level, but the higher level apis are not added yet.
Can anyone please tell me how one can achieve multiple database connections in Django.
Does anyone have any idea by when Django will fully/officially support Multiple database connections. | Multiple database support in django | 0.059928 | 0 | 0 | 9,347 |
268,629 | 2008-11-06T13:10:00.000 | 15 | 0 | 0 | 0 | python,http,basehttpserver | 4,020,093 | 11 | false | 0 | 0 | I think you can use [serverName].socket.close() | 1 | 58 | 0 | I am running my HTTPServer in a separate thread (using the threading module which has no way to stop threads...) and want to stop serving requests when the main thread also shuts down.
The Python documentation states that BaseHTTPServer.HTTPServer is a subclass of SocketServer.TCPServer, which supports a shutdown method, but it is missing in HTTPServer.
The whole BaseHTTPServer module has very little documentation :( | How to stop BaseHTTPServer.serve_forever() in a BaseHTTPRequestHandler subclass? | 1 | 0 | 1 | 87,640 |
269,060 | 2008-11-06T15:18:00.000 | 1 | 1 | 1 | 0 | python,email,character-encoding,invalid-characters | 271,058 | 3 | false | 0 | 0 | The best way to do this that I've found is to iteratively try decoding a prospective with each of the most common encodings inside of a try except block. | 1 | 18 | 0 | I'm writing some mail-processing software in Python that is encountering strange bytes in header fields. I suspect this is just malformed mail; the message itself claims to be us-ascii, so I don't think there is a true encoding, but I'd like to get out a unicode string approximating the original one without throwing a UnicodeDecodeError.
So, I'm looking for a function that takes a str and optionally some hints and does its darndest to give me back a unicode. I could write one of course, but if such a function exists its author has probably thought a bit deeper about the best way to go about this.
I also know that Python's design prefers explicit to implicit and that the standard library is designed to avoid implicit magic in decoding text. I just want to explicitly say "go ahead and guess". | Is there a Python library function which attempts to guess the character-encoding of some bytes? | 0.066568 | 0 | 0 | 12,045 |
269,292 | 2008-11-06T16:19:00.000 | 8 | 1 | 1 | 0 | python,http,mime-types | 269,364 | 2 | false | 0 | 0 | I doubt there's an established MIME type. Have you considered using JSON instead, it is almost the same as a Python dict, and has a better established culture of tools and techniques. | 1 | 3 | 0 | I have a web API that returns python dictionaries or lists as a response that I eval() in python scripts that use the API, for completness I wanted to set a proper content-type but not sure what would be best to use "text/x-python" or maybe "application/python", or something else?
[edit] I'm also outputting JSON, I'm doing Python as an option mainly for internal use.[/edit] | What mime-type should I return for a python string | 1 | 0 | 0 | 3,601 |
269,676 | 2008-11-06T18:06:00.000 | 1 | 0 | 0 | 0 | python,mysql,database,deadlock | 270,449 | 5 | false | 0 | 0 | you can always run LOCK TABLE tablename from another session (mysql CLI for instance). That might do the trick.
It will remain locked until you release it or disconnect the session. | 1 | 10 | 0 | I want to make my Python library working with MySQLdb be able to detect deadlocks and try again. I believe I've coded a good solution, and now I want to test it.
Any ideas for the simplest queries I could run using MySQLdb to create a deadlock condition would be?
system info:
MySQL 5.0.19
Client 5.1.11
Windows XP
Python 2.4 / MySQLdb 1.2.1 p2 | How can I Cause a Deadlock in MySQL for Testing Purposes | 0.039979 | 1 | 0 | 7,080 |
269,795 | 2008-11-06T18:36:00.000 | 1 | 0 | 1 | 1 | python,module | 269,814 | 20 | false | 0 | 0 | Not all python modules are written in python. Datetime happens to be one of them that is not, and (on linux) is datetime.so.
You would have to download the source code to the python standard library to get at it. | 5 | 564 | 0 | How do I learn where the source file for a given Python module is installed? Is the method different on Windows than on Linux?
I'm trying to look for the source of the datetime module in particular, but I'm interested in a more general answer as well. | How do I find the location of Python module sources? | 0.01 | 0 | 0 | 717,501 |
269,795 | 2008-11-06T18:36:00.000 | 103 | 0 | 1 | 1 | python,module | 32,784,452 | 20 | false | 0 | 0 | If you're using pip to install your modules, just pip show $module the location is returned. | 5 | 564 | 0 | How do I learn where the source file for a given Python module is installed? Is the method different on Windows than on Linux?
I'm trying to look for the source of the datetime module in particular, but I'm interested in a more general answer as well. | How do I find the location of Python module sources? | 1 | 0 | 0 | 717,501 |
269,795 | 2008-11-06T18:36:00.000 | 1 | 0 | 1 | 1 | python,module | 27,230,006 | 20 | false | 0 | 0 | For those who prefer a GUI solution: if you're using a gui such as Spyder (part of the Anaconda installation) you can just right-click the module name (such as "csv" in "import csv") and select "go to definition" - this will open the file, but also on the top you can see the exact file location ("C:....csv.py") | 5 | 564 | 0 | How do I learn where the source file for a given Python module is installed? Is the method different on Windows than on Linux?
I'm trying to look for the source of the datetime module in particular, but I'm interested in a more general answer as well. | How do I find the location of Python module sources? | 0.01 | 0 | 0 | 717,501 |
269,795 | 2008-11-06T18:36:00.000 | -1 | 0 | 1 | 1 | python,module | 72,396,307 | 20 | false | 0 | 0 | as written above
in python just use help(module)
ie
import fractions
help(fractions)
if your module, in the example fractions, is installed then it will tell you location and info about it, if its not installed it says module not available
if its not available it doesn't come by default with python in which case you can check where you found it for download info | 5 | 564 | 0 | How do I learn where the source file for a given Python module is installed? Is the method different on Windows than on Linux?
I'm trying to look for the source of the datetime module in particular, but I'm interested in a more general answer as well. | How do I find the location of Python module sources? | -0.01 | 0 | 0 | 717,501 |
269,795 | 2008-11-06T18:36:00.000 | 5 | 0 | 1 | 1 | python,module | 61,095,592 | 20 | false | 0 | 0 | Another way to check if you have multiple python versions installed, from the terminal.
$ python3 -m pip show pyperclip
Location: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-
$ python -m pip show pyperclip
Location: /Users/umeshvuyyuru/Library/Python/2.7/lib/python/site-packages | 5 | 564 | 0 | How do I learn where the source file for a given Python module is installed? Is the method different on Windows than on Linux?
I'm trying to look for the source of the datetime module in particular, but I'm interested in a more general answer as well. | How do I find the location of Python module sources? | 0.049958 | 0 | 0 | 717,501 |
271,625 | 2008-11-07T09:34:00.000 | 0 | 0 | 1 | 1 | python,debugging,console,pydev,interactive | 1,116,728 | 5 | false | 0 | 0 | When I set a break point and hit F11 Eclipse launches the debugger and prompts to open the "Debug Perspective". You can then open the Window-->Show View --> Expressions which opens the expressions view, you can then right click in the Expressions view windows and choose "Add Watch Expression" to add any expression(such as dir)
Conversely I was also able to type in dir(some expression) in the PyDev console and get the same effect.
I'm using PyDev 1.4.6.2788 | 3 | 36 | 0 | I'm debugging my Python code in Eclipse using the Pydev plugin. I'm able to open a Pydev console and it gives me two options: "Console for currently active editor" and "Python console". However none of them is useful to inspect current variable status after a breakpoint.
For example, the code stopped at a breakpoint and I want to inspect an "action" variable using the console. However my variables are not available. How can I do things like "dir(action)", etc? (even if it is not using a console). | Interactive console using Pydev in Eclipse? | 0 | 0 | 0 | 27,430 |
271,625 | 2008-11-07T09:34:00.000 | 0 | 0 | 1 | 1 | python,debugging,console,pydev,interactive | 31,548,800 | 5 | false | 0 | 0 | On a small monitor, you may not realize that the debug interactive console is different from the regular interactive console: it has a second command prompt at the bottom where you type, not at the top like the normal console. | 3 | 36 | 0 | I'm debugging my Python code in Eclipse using the Pydev plugin. I'm able to open a Pydev console and it gives me two options: "Console for currently active editor" and "Python console". However none of them is useful to inspect current variable status after a breakpoint.
For example, the code stopped at a breakpoint and I want to inspect an "action" variable using the console. However my variables are not available. How can I do things like "dir(action)", etc? (even if it is not using a console). | Interactive console using Pydev in Eclipse? | 0 | 0 | 0 | 27,430 |
271,625 | 2008-11-07T09:34:00.000 | 1 | 0 | 1 | 1 | python,debugging,console,pydev,interactive | 271,692 | 5 | false | 0 | 0 | Double click on "action" or any other variable.
ctrl+shift+D
And if you're using watches, I cant imagine better interaction. You are able to see every change. | 3 | 36 | 0 | I'm debugging my Python code in Eclipse using the Pydev plugin. I'm able to open a Pydev console and it gives me two options: "Console for currently active editor" and "Python console". However none of them is useful to inspect current variable status after a breakpoint.
For example, the code stopped at a breakpoint and I want to inspect an "action" variable using the console. However my variables are not available. How can I do things like "dir(action)", etc? (even if it is not using a console). | Interactive console using Pydev in Eclipse? | 0.039979 | 0 | 0 | 27,430 |
271,825 | 2008-11-07T11:35:00.000 | 5 | 1 | 0 | 0 | python,database,client-server,load-testing,stress-testing | 271,918 | 5 | false | 0 | 0 | For performance you are looking at two things: latency (the responsiveness of the application) and throughput (how many ops per interval). For latency you need to have an acceptable benchmark. For throughput you need to have a minimum acceptable throughput.
These are you starting points. For telling a client how many xyz's you can do per interval then you are going to need to know the hardware and software configuration. Knowing the production hardware is important to getting accurate figures. If you do not know the hardware configuration then you need to devise a way to map your figures from the test hardware to the eventual production hardware.
Without knowledge of hardware then you can really only observe trends in performance over time rather than absolutes.
Knowing the software configuration is equally important. Do you have a clustered server configuration, is it load balanced, is there anything else running on the server? Can you scale your software or do you have to scale the hardware to meet demand.
To know how many clients you can support you need to understand what is a standard set of operations. A quick test is to remove the client and write a stub client and the spin up as many of these as you can. Have each one connect to the server. You will eventually reach the server connection resource limit. Without connection pooling or better hardware you can't get higher than this. Often you will hit a architectural issue before here but in either case you have an upper bounds.
Take this information and design a script that your client can enact. You need to map how long your script takes to perform the action with respect to how long it will take the expected user to do it. Start increasing your numbers as mentioned above to you hit the point where the increase in clients causes a greater decrease in performance.
There are many ways to stress test but the key is understanding expected load. Ask your client about their expectations. What is the expected demand per interval? From there you can work out upper loads.
You can do a soak test with many clients operating continously for many hours or days. You can try to connect as many clients as you can as fast you can to see how well your server handles high demand (also a DOS attack).
Concurrent searches should be done through your standard behaviour searches acting on behalf of the client or, write a script to establish a semaphore that waits on many threads, then you can release them all at once. This is fun and punishes your database. When performing searches you need to take into account any caching layers that may exist. You need to test both caching and without caching (in scenarios where everyone makes unique search requests).
Database storage is based on physical space; you can determine row size from the field lengths and expected data population. Extrapolate this out statistically or create a data generation script (useful for your load testing scenarios and should be an asset to your organisation) and then map the generated data to business objects. Your clients will care about how many "business objects" they can store while you will care about how much raw data can be stored.
Other things to consider: What is the expected availability? What about how long it takes to bring a server online. 99.9% availability is not good if it takes two days to bring back online the one time it does go down. On the flip side a lower availablility is more acceptable if it takes 5 seconds to reboot and you have a fall over. | 2 | 13 | 0 | I develop a client-server style, database based system and I need to devise a way to stress / load test the system. Customers inevitably want to know such things as:
• How many clients can a server support?
• How many concurrent searches can a server support?
• How much data can we store in the database?
• Etc.
Key to all these questions is response time. We need to be able to measure how response time and performance degrades as new load is introduced so that we could for example, produce some kind of pretty graph we could throw at clients to give them an idea what kind of performance to expect with a given hardware configuration.
Right now we just put out fingers in the air and make educated guesses based on what we already know about the system from experience. As the product is put under more demanding conditions, this is proving to be inadequate for our needs going forward though.
I've been given the task of devising a method to get such answers in a meaningful way. I realise that this is not a question that anyone can answer definitively but I'm looking for suggestions about how people have gone about doing such work on their own systems.
One thing to note is that we have full access to our client API via the Python language (courtesy of SWIG) which is a lot easier to work with than C++ for this kind of work.
So there we go, I throw this to the floor: really interested to see what ideas you guys can come up with! | How should I stress test / load test a client server application? | 0.197375 | 0 | 1 | 10,487 |
271,825 | 2008-11-07T11:35:00.000 | 0 | 1 | 0 | 0 | python,database,client-server,load-testing,stress-testing | 271,891 | 5 | false | 0 | 0 | If you have the budget, LoadRunner would be perfect for this. | 2 | 13 | 0 | I develop a client-server style, database based system and I need to devise a way to stress / load test the system. Customers inevitably want to know such things as:
• How many clients can a server support?
• How many concurrent searches can a server support?
• How much data can we store in the database?
• Etc.
Key to all these questions is response time. We need to be able to measure how response time and performance degrades as new load is introduced so that we could for example, produce some kind of pretty graph we could throw at clients to give them an idea what kind of performance to expect with a given hardware configuration.
Right now we just put out fingers in the air and make educated guesses based on what we already know about the system from experience. As the product is put under more demanding conditions, this is proving to be inadequate for our needs going forward though.
I've been given the task of devising a method to get such answers in a meaningful way. I realise that this is not a question that anyone can answer definitively but I'm looking for suggestions about how people have gone about doing such work on their own systems.
One thing to note is that we have full access to our client API via the Python language (courtesy of SWIG) which is a lot easier to work with than C++ for this kind of work.
So there we go, I throw this to the floor: really interested to see what ideas you guys can come up with! | How should I stress test / load test a client server application? | 0 | 0 | 1 | 10,487 |
272,042 | 2008-11-07T13:21:00.000 | 4 | 0 | 0 | 0 | python,django | 272,470 | 2 | false | 1 | 0 | A site I did last year was concerned that usernames/passwords might be posted to a forum. I dealt with this by adding a model and a check to the login view that looked at how many unique IPs the name had been used from in the last X hours. I gave the site admins two values in settings.py to adjust the number of hours and the number of unique IPs. If a name was being "overused" it was blocked for logins from new IPs until enough time had passed to fall below the threshold.
Much to their surprise, they have had only one name trigger the blocking in the last year and that turned out to be the company president who was on a business trip and kept logging in from new locations.
Ps. The code is straightforward. Email me at peter at techbuddy dot us if you would like it. | 2 | 2 | 0 | is there any way of making sure that, one user is logged in only once?
I would like to avoid two different persons logging into the system with the same login/password.
I guess I could do it myself by checking in the django_session table before logging in the user, but I rather prefer using the framework, if there is already such functionality.
Cheers,
Thanks for the responses! | User Authentication in Django | 0.379949 | 0 | 0 | 1,232 |
272,042 | 2008-11-07T13:21:00.000 | 5 | 0 | 0 | 0 | python,django | 272,071 | 2 | true | 1 | 0 | Logged in twice is ambiguous over HTTP. There's no "disconnecting" signal that's sent. You can frustrate people if you're not careful.
If I shut down my browser and drop the cookies -- accidentally -- I might be prevented from logging in again.
How would the server know it was me trying to re-login vs. me trying to login twice?
You can try things like checking the IP address. And what if the accidental disconnect was my router crashing, releasing my DHCP lease? Now I'm trying to re-login, but I have a new address and no established cookie. I'm not trying to create a second session, I'm just trying to get back on after my current session got disconnected.
the point is that there's no well-established rule for "single session" that can be installed in a framework. You have to make up a rule appropriate to your application and figure out how to enforce it. | 2 | 2 | 0 | is there any way of making sure that, one user is logged in only once?
I would like to avoid two different persons logging into the system with the same login/password.
I guess I could do it myself by checking in the django_session table before logging in the user, but I rather prefer using the framework, if there is already such functionality.
Cheers,
Thanks for the responses! | User Authentication in Django | 1.2 | 0 | 0 | 1,232 |
273,043 | 2008-11-07T18:13:00.000 | 0 | 0 | 1 | 1 | python,linux,debugging,openssl | 273,204 | 4 | false | 0 | 0 | If you're using CDLL to wrap a C library in python, and this is 64-bit linux, there's a good chance that you're CDLL wrapper is misconfigured. CDLL defaults to int return types on all platforms (should be a long long on 64-bit systems) and just expects you to pass the right arguments in. You may need to verify the CDLL wrapper in this case... | 1 | 4 | 0 | We have a Linux application that makes use of OpenSSL's Python bindings and I suspect it is causing random crashes. Occasionally, we see it crash with the message:
Python Fatal Error: GC Object already tracked
which would appear to be either a programming error on the part of the library, or a symptom of memory corruption. Is there any way to know the last line of Python source code it executed, given a core file? Or if it is attached in GDB? I realize it is probably all compiled bytecode, but I'm hoping there someone out there may have dealt with this. Currently it is running with the trace module active and we're hoping it will happen again, but it could be a long while. | Python memory debugging with GDB | 0 | 0 | 0 | 4,500 |
273,524 | 2008-11-07T20:23:00.000 | 4 | 0 | 1 | 0 | python,programming-languages,python-3.x | 273,543 | 12 | false | 0 | 0 | C# and the .NET framework broke compatibility between versions 1.0 and 1.1 as well as between 1.1 and 2.0. Running applications in different versions required having multiple versions of the .NET runtime installed.
At least they did include an upgrade wizard to upgrade source from one version to the next (it worked for most of our code). | 9 | 12 | 0 | Python 3.0 breaks backwards compatibility with previous versions and splits the language into two paths (at least temporarily). Do you know of any other language that went through such a major design phase while in maturity?
Also, do you believe that this is how programming languages should evolve or is the price to pay simply too high? | Python 3.0 and language evolution | 0.066568 | 0 | 0 | 1,474 |
273,524 | 2008-11-07T20:23:00.000 | 2 | 0 | 1 | 0 | python,programming-languages,python-3.x | 273,646 | 12 | false | 0 | 0 | In the Lisp world it has happened a few times. of course, the language is so dynamic that usually evolution is simply deprecating part of the standard library and making standard another part.
also, Lua 4 to 5 was pretty significant; but the language core is so minimal that even wide-reaching changes are documented in a couple of pages. | 9 | 12 | 0 | Python 3.0 breaks backwards compatibility with previous versions and splits the language into two paths (at least temporarily). Do you know of any other language that went through such a major design phase while in maturity?
Also, do you believe that this is how programming languages should evolve or is the price to pay simply too high? | Python 3.0 and language evolution | 0.033321 | 0 | 0 | 1,474 |
273,524 | 2008-11-07T20:23:00.000 | 4 | 0 | 1 | 0 | python,programming-languages,python-3.x | 273,994 | 12 | false | 0 | 0 | Wouldn't VB6 to VB.net be the biggest example of this? Or do you all consider them two separate languages? | 9 | 12 | 0 | Python 3.0 breaks backwards compatibility with previous versions and splits the language into two paths (at least temporarily). Do you know of any other language that went through such a major design phase while in maturity?
Also, do you believe that this is how programming languages should evolve or is the price to pay simply too high? | Python 3.0 and language evolution | 0.066568 | 0 | 0 | 1,474 |
273,524 | 2008-11-07T20:23:00.000 | 0 | 0 | 1 | 0 | python,programming-languages,python-3.x | 427,917 | 12 | false | 0 | 0 | The new version of the Ruby programming language will also break compatibility.
And think of the libraries one might use: gtk, Qt, and so on (they also have incompatible versions).
I think incompatibility is necessary sometimes (but not too often) to support progress. | 9 | 12 | 0 | Python 3.0 breaks backwards compatibility with previous versions and splits the language into two paths (at least temporarily). Do you know of any other language that went through such a major design phase while in maturity?
Also, do you believe that this is how programming languages should evolve or is the price to pay simply too high? | Python 3.0 and language evolution | 0 | 0 | 0 | 1,474 |
273,524 | 2008-11-07T20:23:00.000 | 9 | 0 | 1 | 0 | python,programming-languages,python-3.x | 273,576 | 12 | false | 0 | 0 | The python team has worked very hard to make the lack of backward compatibility as painless as possible, to the point where the 2.6 release of python was created with a mind towards a painless upgrade process. Once you have upgraded to 2.6 there are scripts that you can run that will move you to 3.0 without issue. | 9 | 12 | 0 | Python 3.0 breaks backwards compatibility with previous versions and splits the language into two paths (at least temporarily). Do you know of any other language that went through such a major design phase while in maturity?
Also, do you believe that this is how programming languages should evolve or is the price to pay simply too high? | Python 3.0 and language evolution | 1 | 0 | 0 | 1,474 |
273,524 | 2008-11-07T20:23:00.000 | 7 | 0 | 1 | 0 | python,programming-languages,python-3.x | 273,661 | 12 | false | 0 | 0 | It's worth mentioning that backward compatibility incurs costs of its own. In some cases it's almost impossible to evolve a language in the ideal way if 100% backward compatibility is required. Java's implementation of generics (which erases type information at compile-time in order to be backwardly-compatible) is a good example of how implementing features with 100% backward compatibility can result in a sub-optimal language feature.
So loosely speaking, it can come down to a choice between a poorly implemented new feature that's backwardly compatible, or a nicely implemented new feature that's not. In many cases, the latter is a better choice, particularly if there are tools that can automatically translate incompatible code. | 9 | 12 | 0 | Python 3.0 breaks backwards compatibility with previous versions and splits the language into two paths (at least temporarily). Do you know of any other language that went through such a major design phase while in maturity?
Also, do you believe that this is how programming languages should evolve or is the price to pay simply too high? | Python 3.0 and language evolution | 1 | 0 | 0 | 1,474 |
273,524 | 2008-11-07T20:23:00.000 | 13 | 0 | 1 | 0 | python,programming-languages,python-3.x | 273,688 | 12 | false | 0 | 0 | The price of insisting on near-absolute backwards compatibility is just too high. Spend two minutes programming in C++ if you want to see why. | 9 | 12 | 0 | Python 3.0 breaks backwards compatibility with previous versions and splits the language into two paths (at least temporarily). Do you know of any other language that went through such a major design phase while in maturity?
Also, do you believe that this is how programming languages should evolve or is the price to pay simply too high? | Python 3.0 and language evolution | 1 | 0 | 0 | 1,474 |
273,524 | 2008-11-07T20:23:00.000 | 16 | 0 | 1 | 0 | python,programming-languages,python-3.x | 273,571 | 12 | false | 0 | 0 | The only language I can think of to attempt such a mid-stream change would be Perl. Of course, Python is beating Perl to that particular finish line by releasing first. It should be noted, however, that Perl's changes are much more extensive than Python's and likely will be harder to detangle.
(There's a price for Perl's "There's More Than One Way To Do It" philosophy.)
There are examples like the changes from version to version of .NET-based languages (ironic, considering the whole point of .NET was supposed to be API stability and cross-platform compatibility). However, I would hardly call those languages "mature"; it's always been more of a design-on-the-go, build-the-plane-as-we-fly approach to things.
Or, as I tend to think of it, most languages come from either "organic growth" or "engineered construction." Perl is the perfect example of organic growth; it started as a fancy text processing tool ala awk/sed and grew into a full language.
Python, on the other hand, is much more engineered. Spend a bit of time wandering around the extensive whitepapers on their website to see the extensive debate that goes into every even minor change to the language's syntax and implementation.
The idea of making these sorts of far-reaching changes is somewhat new to programming languages because programming languages themselves have changed in nature. It used to be that programming methodologies changed only when a new processor came out that had a new instruction set. The early languages tended to either be so low-level and married to assembly language (e.g. C) or so utterly dynamic in nature (Forth, Lisp) that such a mid-stream change wouldn't even come up as a consideration.
As to whether or not the changes are good ones, I'm not sure. I tend to have faith in the people guiding Python's development, however; the changes in the language thus far have been largely for the better.
I think in the days to come the Global Interpreter Lock will prove more central than syntax changes. Though the new multiprocessor library might alleviate most of that. | 9 | 12 | 0 | Python 3.0 breaks backwards compatibility with previous versions and splits the language into two paths (at least temporarily). Do you know of any other language that went through such a major design phase while in maturity?
Also, do you believe that this is how programming languages should evolve or is the price to pay simply too high? | Python 3.0 and language evolution | 1 | 0 | 0 | 1,474 |
273,524 | 2008-11-07T20:23:00.000 | 0 | 0 | 1 | 0 | python,programming-languages,python-3.x | 274,338 | 12 | false | 0 | 0 | gcc regularly changes how it handles C++ almost every minor release. Of course, this is more a consequence of gcc tightening how they follow the rules, and less of C++ itself changing. | 9 | 12 | 0 | Python 3.0 breaks backwards compatibility with previous versions and splits the language into two paths (at least temporarily). Do you know of any other language that went through such a major design phase while in maturity?
Also, do you believe that this is how programming languages should evolve or is the price to pay simply too high? | Python 3.0 and language evolution | 0 | 0 | 0 | 1,474 |
275,572 | 2008-11-09T03:46:00.000 | 2 | 0 | 0 | 0 | python,mysql,database,sqlite,sqlobject | 275,676 | 3 | false | 0 | 0 | Your success with createTable() will depend on your existing underlying table schema / data types. In other words, how well SQLite maps to the database you choose and how SQLObject decides to use your data types.
The safest option may be to create the new database by hand. Then you'll have to deal with data migration, which may be as easy as instantiating two SQLObject database connections over the same table definitions.
Why not just start with the more full-featured database? | 1 | 1 | 0 | I'm starting a web project that likely should be fine with SQLite. I have SQLObject on top of it, but thinking long term here -- if this project should require a more robust (e.g. able to handle high traffic), I will need to have a transition plan ready. My questions:
How easy is it to transition from one DB (SQLite) to another (MySQL or Firebird or PostGre) under SQLObject?
Does SQLObject provide any tools to make such a transition easier? Is it simply take the objects I've defined and call createTable?
What about having multiple SQLite databases instead? E.g. one per visitor group? Does SQLObject provide a mechanism for handling this scenario and if so, what is the mechanism to use?
Thanks,
Sean | Database change underneath SQLObject | 0.132549 | 1 | 0 | 876 |
276,679 | 2008-11-09T23:40:00.000 | 7 | 0 | 1 | 0 | python | 276,696 | 4 | false | 0 | 0 | You most probably should not use import for what you are trying to do.
Without further information I can only guess, but you should move the code in the module you import from the top level into a function, do the import once and than simply call the function from you loop. | 2 | 2 | 0 | Is it possible to import a python file more than once in a python script because i run a loop back to my driver file in a function by using the import command but it only works once? thanks
edit: Resolved myself thanks | How to import a python file in python script more than once | 1 | 0 | 0 | 7,985 |
276,679 | 2008-11-09T23:40:00.000 | 1 | 0 | 1 | 0 | python | 276,694 | 4 | false | 0 | 0 | The import statement -- by definition -- only imports once.
You can, if you want, try to use execfile() (or eval()) to execute a separate file more than once. | 2 | 2 | 0 | Is it possible to import a python file more than once in a python script because i run a loop back to my driver file in a function by using the import command but it only works once? thanks
edit: Resolved myself thanks | How to import a python file in python script more than once | 0.049958 | 0 | 0 | 7,985 |
276,761 | 2008-11-10T00:34:00.000 | 23 | 1 | 0 | 0 | c++,python,boost,swig | 277,306 | 5 | true | 0 | 1 | I've used both (for the same project): Boost is better integrated with the STL, and especially C++ exceptions. Also, its memory management mechanism (which tries to bridge C++ memory management and Python GC) is way more flexible than SWIG's. However, SWIG has much better documentation, no external dependencies, and if you get the library wrapped in SWIG for Python you're more than half-way there to getting a Java/Perl/Ruby wrapper as well.
I don't think there's a clear-cut choice: for smaller projects, I'd go with Boost.Python again, for larger long-lived projects, the extra investment in SWIG is worth it. | 2 | 41 | 0 | I'm currently working on a project were I had to wrap the C++ classes with Python to be able to script the program. So my specific experience also involved embedding the Python interpreter in our program.
The alternatives I tried were:
Boost.Python
I liked the cleaner API produced by Boost.Python, but the fact that it would have required that users install an additional dependency made us switch to SWIG.
SWIG
SWIG's main advantage for us was that it doesn't require end users to install it to use the final program.
What have you used to do this, and what has been your experience with it? | Exposing a C++ API to Python | 1.2 | 0 | 0 | 12,800 |
276,761 | 2008-11-10T00:34:00.000 | 2 | 1 | 0 | 0 | c++,python,boost,swig | 847,688 | 5 | false | 0 | 1 | A big plus for Boost::Python is that it allows for tab completion in the ipython shell: You import a C++ class, exposed by Boost directly, or you subclass it, and from then on, it really behaves like a pure Python class.
The downside: It takes so long to install and use Boost that all the Tab-completion time-saving won't ever amortize ;-(
So I prefer Swig: No bells and whistles, but works reliably after a short introductory example. | 2 | 41 | 0 | I'm currently working on a project were I had to wrap the C++ classes with Python to be able to script the program. So my specific experience also involved embedding the Python interpreter in our program.
The alternatives I tried were:
Boost.Python
I liked the cleaner API produced by Boost.Python, but the fact that it would have required that users install an additional dependency made us switch to SWIG.
SWIG
SWIG's main advantage for us was that it doesn't require end users to install it to use the final program.
What have you used to do this, and what has been your experience with it? | Exposing a C++ API to Python | 0.07983 | 0 | 0 | 12,800 |
279,094 | 2008-11-10T20:41:00.000 | 2 | 0 | 0 | 0 | python,windows,scripting,activex,ole | 363,885 | 5 | false | 0 | 0 | win32com is a good package to use if you want to use the IDispatch interface to control your objects, but it's slow.
comtypes is a better, native Python, package that uses the raw COM approach to talk to your controls.
WxPython uses comtypes to give you an ActiveX container window from Python. | 1 | 9 | 0 | I would like to use Python to script an application that advertises itself as providing an OLE component. How should I get started?
I don't yet know what methods I need to call on the COMponents I will be accessing. Should I use win32com to load those components, and then start pressing 'tab' in IPython? | How to script an OLE component using Python | 0.07983 | 0 | 0 | 15,172 |
279,434 | 2008-11-10T22:41:00.000 | 0 | 1 | 0 | 1 | python,keypress,popen | 279,627 | 3 | false | 0 | 0 | What platform is this on?
You may have to actually feed events into the event loop, if it's running on Win32. | 2 | 1 | 0 | I am opening a process (with os.popen() ) that, for some commands, detects certain keypresses (e.g. ESC - not the character, the key). Is there a way to send keypress events to the process? | Python: How do I generate a keypress? | 0 | 0 | 0 | 2,607 |
279,434 | 2008-11-10T22:41:00.000 | 0 | 1 | 0 | 1 | python,keypress,popen | 279,460 | 3 | false | 0 | 0 | The obvious way would be to start the process in it's own shell.
something like os.popen("sh command") | 2 | 1 | 0 | I am opening a process (with os.popen() ) that, for some commands, detects certain keypresses (e.g. ESC - not the character, the key). Is there a way to send keypress events to the process? | Python: How do I generate a keypress? | 0 | 0 | 0 | 2,607 |
279,707 | 2008-11-11T00:56:00.000 | 0 | 0 | 1 | 0 | python,user-interface | 279,754 | 4 | false | 0 | 0 | We started down the path of wxPython a few years ago and found it to be quite easy to do for simple, quick and dirty app. However, you are not going to get something you can put on the modern desktop. So we switched to WinForms and Python.Net and haven't looked back since. It's fairly easy to get going and you get all the power and support of rich windows UI with .NET. | 1 | 2 | 0 | How do I make a GUI for my python program because now it only runs in Idle and a command line and what software packages can I use and where can I get them? Thanks. | making a python GUI | 0 | 0 | 0 | 4,584 |
279,912 | 2008-11-11T03:17:00.000 | 32 | 0 | 0 | 0 | python,pyglet,pyopengl | 4,246,325 | 9 | false | 0 | 1 | Start with pyglet. It contains the best high-level API, which contains all you need to get started, from opening a window to drawing sprites and OpenGL primitives using their friendly and powerful Sprite and Batch classes.
Later, you might also want to write your own lower-level code, that makes calls directly to OpenGL functions such as glDrawArrays, etc. You can do this using pyglet's OpenGL bindings, or using PyOpenGL's. The good news is that whichever you use, you can insert such calls right into the middle of your existing pyglet application, and they will 'just work'. Transitioning your code from Pyglet to PyOpenGL is fairly easy, so this is not a decision you need to worry about too much upfront. The trades-off between the two are:
PyOpenGL's bindings make the OpenGL interface more friendly and pythonic. For example, you can pass vertex arrays in many different forms, ctypes arrays, numpy arrays, plain lists, etc, and PyOpenGL will convert them into something OpenGL can use. Things like this make PyOpenGL really easy and convenient.
pyglet's OpenGL bindings are automatically generated, and are not as friendly to use as PyOpenGL. For example, sometimes you will have to manually create ctypes objects, in order to pass 'C pointer' kinds of args to OpenGL. This can be fiddly. The plus side though, is pyglet's bindings tends to be significantly faster.
This implies that there is an optimal middle ground: Use pyglet for windowing, mouse events, sound, etc. Then use PyOpenGL's friendly API when you want to make direct OpenGL function calls. Then when optimising, replace just the small percentage of performance-critical PyOpenGL calls that lie within your inner render loop with the pyglet equivalents. For me, this gives me between 2 and 4 times faster framerates, with PyOpenGL's convenience for 90% of my code. | 5 | 25 | 0 | I am looking to do some tinkering with openGL and Python and haven't been able to find good reasons for using PyOpenGl versus pyglet
Which would you recommend and why? | PyOpenGl or pyglet? | 1 | 0 | 0 | 18,513 |
279,912 | 2008-11-11T03:17:00.000 | 4 | 0 | 0 | 0 | python,pyglet,pyopengl | 2,396,038 | 9 | false | 0 | 1 | pyglet's GL API is nowhere near as nice as PyOpenGL's - pyglet's is at the raw ctypes layer which means you'll need to learn ctypes as well. If you're planning on doing a bunch of OpenGL programming you'll want to use PyOpenGL.
The nice thing is you can mix the two just fine. Use pyglet to provide the GL context, sounds, events, image loading and texture management, text rendering, etc, etc. Use PyOpenGL for the actual OpenGL programming you need to do. | 5 | 25 | 0 | I am looking to do some tinkering with openGL and Python and haven't been able to find good reasons for using PyOpenGl versus pyglet
Which would you recommend and why? | PyOpenGl or pyglet? | 0.088656 | 0 | 0 | 18,513 |
279,912 | 2008-11-11T03:17:00.000 | 4 | 0 | 0 | 0 | python,pyglet,pyopengl | 279,942 | 9 | false | 0 | 1 | pyglet has a lot of nice extras included with it (like image loading and sound). If you're starting out, I'd try pyglet first, and then switch to PyOpenGL if you feel like you want to get closer to the metal.
The real important question though is: what are you trying to accomplish? | 5 | 25 | 0 | I am looking to do some tinkering with openGL and Python and haven't been able to find good reasons for using PyOpenGl versus pyglet
Which would you recommend and why? | PyOpenGl or pyglet? | 0.088656 | 0 | 0 | 18,513 |
279,912 | 2008-11-11T03:17:00.000 | 4 | 0 | 0 | 0 | python,pyglet,pyopengl | 281,395 | 9 | false | 0 | 1 | I promote pyglet because it has the nicest API I've yet seen on stuff like this.
Pyglet has opengl API as well. But it's often nicer to use the recently added vertex list support.
pyglet.gl | 5 | 25 | 0 | I am looking to do some tinkering with openGL and Python and haven't been able to find good reasons for using PyOpenGl versus pyglet
Which would you recommend and why? | PyOpenGl or pyglet? | 0.088656 | 0 | 0 | 18,513 |
279,912 | 2008-11-11T03:17:00.000 | 3 | 0 | 0 | 0 | python,pyglet,pyopengl | 397,041 | 9 | false | 0 | 1 | I would recommend Pyglet because it is very easy to get started and have something basic running, and then you can add more advanced techniques at your own pace. | 5 | 25 | 0 | I am looking to do some tinkering with openGL and Python and haven't been able to find good reasons for using PyOpenGl versus pyglet
Which would you recommend and why? | PyOpenGl or pyglet? | 0.066568 | 0 | 0 | 18,513 |
282,907 | 2008-11-12T03:15:00.000 | 1 | 0 | 1 | 1 | python,windows,linux,cygwin,turbogears | 282,939 | 5 | false | 0 | 0 | Add python to the firewall exceptions list. Just make sure you don't run any questionable code made in python, of course. | 2 | 1 | 0 | I'm going to try out turbogears however I'm on windows vista.
however due to firewall proxy problems, it seems i can't download .egg files which is required for setup turbogears to get installed in my windows environment.
I do have a bootable, or I can make a bootable Linux USB, I can try cygwin but I am not sure where to start with cygwin, so I was wondering what would solve my firewall / proxy problem of installing something like turbogears.
if it's possible, is there some non-online version of turbogears that i could just download from visiting a site and then somehow importing that non-online version into my python environment?
thanks so much!:) | How can I download python .egg files, when behind a firewall | 0.039979 | 0 | 0 | 1,615 |
282,907 | 2008-11-12T03:15:00.000 | 2 | 0 | 1 | 1 | python,windows,linux,cygwin,turbogears | 283,271 | 5 | false | 0 | 0 | You could use the old firewall hack... try throwing "?file.jpg" or "#file.jpg" on the end (sans quotes). The firewall may see this as you're trying to download an image file which it'll allow, the responding server probably won't care that you've attached a query string, and (I think) python will just see an egg. | 2 | 1 | 0 | I'm going to try out turbogears however I'm on windows vista.
however due to firewall proxy problems, it seems i can't download .egg files which is required for setup turbogears to get installed in my windows environment.
I do have a bootable, or I can make a bootable Linux USB, I can try cygwin but I am not sure where to start with cygwin, so I was wondering what would solve my firewall / proxy problem of installing something like turbogears.
if it's possible, is there some non-online version of turbogears that i could just download from visiting a site and then somehow importing that non-online version into my python environment?
thanks so much!:) | How can I download python .egg files, when behind a firewall | 0.07983 | 0 | 0 | 1,615 |
283,431 | 2008-11-12T09:38:00.000 | 0 | 0 | 0 | 1 | python,windows | 286,436 | 2 | false | 0 | 0 | The suggested answer seems to have fixed the problem. I also realized that I needed to use os.name to determine which OS is being used, then I can use the correct path format for loading the external Python file. | 1 | 1 | 0 | My record sheet app has a menu option for creating a new, blank record sheet. When I open a sheet window, I can open new windows without a problem, using subprocess.Popen() to do it.
However, under Windows (I haven't tested it on other OSes yet), if I open a new window then use the "open file" dialog to populate the fields with data from a file, I'm no longer able to create new windows. Once it's populated, Windows gives me the
'foo.py' is not recognized as an internal or external command, operable
program or batch file.
I don't understand what would cause Windows to suddenly not recognize the Popen() call. I don't have any code that would affect it in any way that I'm aware of. | Why would an "command not recognized" error occur only when a window is populated? | 0 | 0 | 0 | 1,123 |
283,707 | 2008-11-12T11:49:00.000 | 7 | 0 | 1 | 0 | python,file,file-io,filesize,tarfile | 283,718 | 5 | false | 0 | 0 | If you have the file descriptor, you can use fstat to find out the size, if any. A more generic solution is to seek to the end of the file, and read its location there. | 1 | 71 | 0 | Is there a way to find the size of a file object that is currently open?
Specifically, I am working with the tarfile module to create tarfiles, but I don't want my tarfile to exceed a certain size. As far as I know, tarfile objects are file-like objects, so I imagine a generic solution would work. | Size of an open file object | 1 | 0 | 0 | 74,503 |
284,115 | 2008-11-12T14:35:00.000 | -4 | 0 | 0 | 0 | python,cross-platform,filesystems | 284,363 | 5 | false | 0 | 0 | "Is there a standard way to deal with this?" Yes. Use a standard (i.e., POSIX-compliant) OS.
Since Windows is non-standard -- well -- there's no applicable standard. Wouldn't it be great if there was? I feel your pain.
Anything you try to do that's cross-platform like that will have Win32 oddities.
Your solution is -- for the present state of affairs -- excellent. At some point in the future, Microsoft may elect to write a POSIX-compliant OS. Until then, you're coping well with the situation. | 1 | 21 | 0 | What is the best way to do cross-platform handling of hidden files?
(preferably in Python, but other solutions still appreciated)
Simply checking for a leading '.' works for *nix/Mac, and file attributes work on Windows. However, this seems a little simplistic, and also doesn't account for alternative methods of hiding things (.hidden files, etc.). Is there a standard way to deal with this? | Cross platform hidden file detection | -1 | 0 | 0 | 21,243 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.