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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3,038,661 | 2010-06-14T15:50:00.000 | 0 | 0 | 0 | 0 | python,graph,shortest-path,dijkstra,breadth-first-search | 3,042,109 | 7 | false | 0 | 0 | Depending on what kind of additional information you have, A* may be extremely efficient. In particular, if given a node you can compute an estimate of the cost from that node to the goal, A* is optimally efficient. | 1 | 16 | 0 | I'm looking to find a way to in real-time find the shortest path between nodes in a huge graph. It has hundreds of thousands of vertices and millions of edges. I know this question has been asked before and I guess the answer is to use a breadth-first search, but I'm more interested in to know what software you can use to implement it. For example, it would be totally perfect if it already exist a library (with python bindings!) for performing bfs in undirected graphs. | Efficiently finding the shortest path in large graphs | 0 | 0 | 1 | 24,381 |
3,039,889 | 2010-06-14T18:38:00.000 | 4 | 0 | 1 | 0 | python,oop,scripting | 3,039,925 | 17 | false | 0 | 0 | Use the right tool for the right job. For small scripts that don't require complex data structures and algorithms, there is likely no use for object oriented concepts. | 15 | 28 | 0 | I mostly write small scripts in python, about 50 - 250 lines of code. I usually don't use any objects, just straightforward procedural programming.
I know OOP basics and I have used object in other programming languages before, but for small scripts I don't see how objects would improve them. But maybe that is just my limited experience with OOP.
Am I missing something by not trying harder to use objects, or does OOP just not make a lot of sense for small scripts? | Does OOP make sense for small scripts? | 0.047024 | 0 | 0 | 5,102 |
3,039,889 | 2010-06-14T18:38:00.000 | 33 | 0 | 1 | 0 | python,oop,scripting | 3,039,967 | 17 | true | 0 | 0 | I use whatever paradigm best suits the issue at hand -- be it procedural, OOP, functional, ... program size is not a criterion, though (by a little margin) a larger program may be more likely to take advantage of OOP's strengths -- multiple instances of a class, subclassing and overriding, special method overloads, OOP design patterns, etc. Any of these opportunities can perfectly well occur in a small script, there's just a somewhat higher probability that it will occur in a larger one.
In addition, I detest the global statement, so if the natural procedural approach would require it, I will almost invariably switch to OOP instead -- even if the only advantage is the ability to use a qualified name instead of the barename which would require global.
There's definitely no need to "try harder" in general -- just ask yourself "is there an opportunity here to use (a) multiple instances (etc etc)" and it will soon become second nature, i.e., you'll spot the opportunities without needing to consciously remind yourself every time to look for them, and your programming will improve as a result. | 15 | 28 | 0 | I mostly write small scripts in python, about 50 - 250 lines of code. I usually don't use any objects, just straightforward procedural programming.
I know OOP basics and I have used object in other programming languages before, but for small scripts I don't see how objects would improve them. But maybe that is just my limited experience with OOP.
Am I missing something by not trying harder to use objects, or does OOP just not make a lot of sense for small scripts? | Does OOP make sense for small scripts? | 1.2 | 0 | 0 | 5,102 |
3,039,889 | 2010-06-14T18:38:00.000 | 9 | 0 | 1 | 0 | python,oop,scripting | 3,041,386 | 17 | false | 0 | 0 | One of the unfortunate habits developed with oop is Objectophrenia - the delusion of seeing objects in every piece of code we write.
The reason why that happens is due our delusion of believing in the existence of a unified objects theorem.
Every piece of code you write, you begin to see it as a template for objects and how they fit into our personal scheme of things. Even though it might be a small task at hand, we get tempted by the question - is this something I could place into my class repository which I could also use for the future? Do I see a pattern here with code I have previously written and with code which my object clairvoyance tells me that I will one day write? Can I structure my present task into one of these patterns.
It is an annoying habit. Frequently, it is better not to have it. But when you find that every bit of code you write somehow falls into patterns and you refactor/realign those patterns until it covers most of your needs, you tend to get a feeling of satisfaction and accomplishment.
Problems begins to appear when a programmer gets delusional (compulsive obsessive object oriented disorder) and does not realise that there are exceptions to patterns and trying to over-manipulate patterns to cover more cases is wrong. It's like my childhood obsession with trying to cover a piece of bread completely with butter or jam spread every morning I had breakfast. That sometimes, it is just better to leave the object oriented perception behind and just perform the task at hand quick and dirty.
The accepted industrial adage of 80-20 might be a good measure. Using this adage in a different manner than it is normally perceived, we could say 80% of the time have an object oriented perception. 20% of the time - code it quick and dirty.
Be immersed by objects but eventually you have to resist its consuming you.
You probably have not done enough programming yet because if you have, you would see all the patterns that you had done and you will also begin to believe in patterns that you have yet to apply. When you begin to see such objectophrenia visions, it's time to be careful not to be consumed by them. | 15 | 28 | 0 | I mostly write small scripts in python, about 50 - 250 lines of code. I usually don't use any objects, just straightforward procedural programming.
I know OOP basics and I have used object in other programming languages before, but for small scripts I don't see how objects would improve them. But maybe that is just my limited experience with OOP.
Am I missing something by not trying harder to use objects, or does OOP just not make a lot of sense for small scripts? | Does OOP make sense for small scripts? | 1 | 0 | 0 | 5,102 |
3,039,889 | 2010-06-14T18:38:00.000 | 8 | 0 | 1 | 0 | python,oop,scripting | 3,039,934 | 17 | false | 0 | 0 | If you plan to use the script independently, then no. However if you plan to import it and reuse some of it, then yes. In the second case, it's best to write some classes providing the functionality that's required and then have a conditional run (if __name__=='__main__':) with code to execute the "script" version of the script. | 15 | 28 | 0 | I mostly write small scripts in python, about 50 - 250 lines of code. I usually don't use any objects, just straightforward procedural programming.
I know OOP basics and I have used object in other programming languages before, but for small scripts I don't see how objects would improve them. But maybe that is just my limited experience with OOP.
Am I missing something by not trying harder to use objects, or does OOP just not make a lot of sense for small scripts? | Does OOP make sense for small scripts? | 1 | 0 | 0 | 5,102 |
3,039,889 | 2010-06-14T18:38:00.000 | 4 | 0 | 1 | 0 | python,oop,scripting | 3,039,923 | 17 | false | 0 | 0 | OOP is a tool to manage complexity in code, 50-250 lines of code are rarely complicated. Most scripts I have written are primarily procedural. So yes, for small scripts just go with procedural programming.
Note that for significantly complicated scripts OOP may be more relevant, but there is still not hard and fast rule that says use OOP for them. It is a matter of personal preference then. | 15 | 28 | 0 | I mostly write small scripts in python, about 50 - 250 lines of code. I usually don't use any objects, just straightforward procedural programming.
I know OOP basics and I have used object in other programming languages before, but for small scripts I don't see how objects would improve them. But maybe that is just my limited experience with OOP.
Am I missing something by not trying harder to use objects, or does OOP just not make a lot of sense for small scripts? | Does OOP make sense for small scripts? | 0.047024 | 0 | 0 | 5,102 |
3,039,889 | 2010-06-14T18:38:00.000 | 4 | 0 | 1 | 0 | python,oop,scripting | 3,041,936 | 17 | false | 0 | 0 | Am I missing something by not trying harder to use objects, or does OOP just not make a lot of sense for small scripts?
Objects buy you encapsulation and reuse (through inheritance). Neither is likely to be terribly useful when writing small scripts. When you have written a collection of similar scripts or you find yourself repeatedly changing your scripts, then maybe you should consider where objects might help. | 15 | 28 | 0 | I mostly write small scripts in python, about 50 - 250 lines of code. I usually don't use any objects, just straightforward procedural programming.
I know OOP basics and I have used object in other programming languages before, but for small scripts I don't see how objects would improve them. But maybe that is just my limited experience with OOP.
Am I missing something by not trying harder to use objects, or does OOP just not make a lot of sense for small scripts? | Does OOP make sense for small scripts? | 0.047024 | 0 | 0 | 5,102 |
3,039,889 | 2010-06-14T18:38:00.000 | 0 | 0 | 1 | 0 | python,oop,scripting | 3,040,679 | 17 | false | 0 | 0 | as someone who does a lot of scripts, if you get the idea that your code may at some point go beyond 250 line start to go oop. I use a lot of vba and vbscript and I would agree that anything under 100 lines is usually pretty straightforward and taking the time to plan a good oop design is just a waste.
That being said I have one script that came to about 500 line + and looking back on it, because i didn't do it oop it quickly turned into an unholy mess of spaghetti. so now anything over 200 lines I make sure i have a good oop plan ahead of time | 15 | 28 | 0 | I mostly write small scripts in python, about 50 - 250 lines of code. I usually don't use any objects, just straightforward procedural programming.
I know OOP basics and I have used object in other programming languages before, but for small scripts I don't see how objects would improve them. But maybe that is just my limited experience with OOP.
Am I missing something by not trying harder to use objects, or does OOP just not make a lot of sense for small scripts? | Does OOP make sense for small scripts? | 0 | 0 | 0 | 5,102 |
3,039,889 | 2010-06-14T18:38:00.000 | 2 | 0 | 1 | 0 | python,oop,scripting | 3,039,913 | 17 | false | 0 | 0 | In your case I'd say that OOP would be helpful only if it makes the scripts more readable and understandable. If not, you probably don't need to bother. | 15 | 28 | 0 | I mostly write small scripts in python, about 50 - 250 lines of code. I usually don't use any objects, just straightforward procedural programming.
I know OOP basics and I have used object in other programming languages before, but for small scripts I don't see how objects would improve them. But maybe that is just my limited experience with OOP.
Am I missing something by not trying harder to use objects, or does OOP just not make a lot of sense for small scripts? | Does OOP make sense for small scripts? | 0.023525 | 0 | 0 | 5,102 |
3,039,889 | 2010-06-14T18:38:00.000 | 2 | 0 | 1 | 0 | python,oop,scripting | 3,040,375 | 17 | false | 0 | 0 | Using OOP for few hundred lines of code rarely makes sense. But if your script is useful, it will probably grow rather quickly because new features will be added. If this is the case, it is better to start coding OOP way it will pay in the long run. | 15 | 28 | 0 | I mostly write small scripts in python, about 50 - 250 lines of code. I usually don't use any objects, just straightforward procedural programming.
I know OOP basics and I have used object in other programming languages before, but for small scripts I don't see how objects would improve them. But maybe that is just my limited experience with OOP.
Am I missing something by not trying harder to use objects, or does OOP just not make a lot of sense for small scripts? | Does OOP make sense for small scripts? | 0.023525 | 0 | 0 | 5,102 |
3,039,889 | 2010-06-14T18:38:00.000 | 0 | 0 | 1 | 0 | python,oop,scripting | 3,040,355 | 17 | false | 0 | 0 | "Script" means "sequential" and "procedural". It's a definition.
All of the objects your script deals with are -- well -- objects. All programming involves objects. The objects already exist in the context in which you're writing your script.
Some languages allow you to clearly identify the objects. Some languages don't clearly identify the objects. The objects are always there. It's a question of whether the language makes it clear or obscure.
Since the objects are always there, I find it helps to use a language that allows clear identification of the objects, their attributes, methods and relationships. Even for short "scripts", I find that explicit objects and an OO language helps.
The point is this.
There's no useful distinction between "procedural", "script" and "OO".
It's merely a shift in emphasis. The objects are always there. The world is inherently object-oriented. The real question is "Do you use a language that makes the objects explicit?" | 15 | 28 | 0 | I mostly write small scripts in python, about 50 - 250 lines of code. I usually don't use any objects, just straightforward procedural programming.
I know OOP basics and I have used object in other programming languages before, but for small scripts I don't see how objects would improve them. But maybe that is just my limited experience with OOP.
Am I missing something by not trying harder to use objects, or does OOP just not make a lot of sense for small scripts? | Does OOP make sense for small scripts? | 0 | 0 | 0 | 5,102 |
3,039,889 | 2010-06-14T18:38:00.000 | 1 | 0 | 1 | 0 | python,oop,scripting | 3,040,435 | 17 | false | 0 | 0 | OOP is about what you get if you add polymorphism on top of modular programming.
The latter of both promotes low coupling, encapsulation, separation of responsibility and some other concepts, that usually produce code, that is short, expressive, maintainable, flexible, extensible, reusable and robust.
This is not so much a question about size, but about length of the software's life cycle. If you write any code, as short as it may be, as long as it is complex enough that you don't want to rewrite it, when your requirements change, it is important that it meets the aforementioned criteria.
OOP makes modular programming easier in that it has established solutions for implementing the concepts promoted by modular programming, and that polymorphism allows really low coupling through dependency injection.
I personally find it simpler to use OOP to achieve modularity (and reusability in particular), but I guess, that is a matter of habit.
To put it in one sentence. OOP will not help you in solving a given problem better, than procedural programming, but instead yields a solution, that is easier to apply to other problems. | 15 | 28 | 0 | I mostly write small scripts in python, about 50 - 250 lines of code. I usually don't use any objects, just straightforward procedural programming.
I know OOP basics and I have used object in other programming languages before, but for small scripts I don't see how objects would improve them. But maybe that is just my limited experience with OOP.
Am I missing something by not trying harder to use objects, or does OOP just not make a lot of sense for small scripts? | Does OOP make sense for small scripts? | 0.011764 | 0 | 0 | 5,102 |
3,039,889 | 2010-06-14T18:38:00.000 | 2 | 0 | 1 | 0 | python,oop,scripting | 3,040,319 | 17 | false | 0 | 0 | Another benefit of OOP is to communicate intent (whether to other developers, managers, or yourself some point in the future). If the script is small enough where it can be fully communicated in a couple of sentences then OOP is probably not necessary, in my opinion. | 15 | 28 | 0 | I mostly write small scripts in python, about 50 - 250 lines of code. I usually don't use any objects, just straightforward procedural programming.
I know OOP basics and I have used object in other programming languages before, but for small scripts I don't see how objects would improve them. But maybe that is just my limited experience with OOP.
Am I missing something by not trying harder to use objects, or does OOP just not make a lot of sense for small scripts? | Does OOP make sense for small scripts? | 0.023525 | 0 | 0 | 5,102 |
3,039,889 | 2010-06-14T18:38:00.000 | 1 | 0 | 1 | 0 | python,oop,scripting | 3,039,984 | 17 | false | 0 | 0 | First of all - what do you mean by objects? In Python functions are objects and you're most likely using them. :)
If by objects you mean classes and instances thereof, then I would say something obvious: no, there is no reason to saying that using them is making your code better by itself. In small scripts there is not going to be any leverage coming from sophisticated OO design. | 15 | 28 | 0 | I mostly write small scripts in python, about 50 - 250 lines of code. I usually don't use any objects, just straightforward procedural programming.
I know OOP basics and I have used object in other programming languages before, but for small scripts I don't see how objects would improve them. But maybe that is just my limited experience with OOP.
Am I missing something by not trying harder to use objects, or does OOP just not make a lot of sense for small scripts? | Does OOP make sense for small scripts? | 0.011764 | 0 | 0 | 5,102 |
3,039,889 | 2010-06-14T18:38:00.000 | 2 | 0 | 1 | 0 | python,oop,scripting | 3,039,939 | 17 | false | 0 | 0 | OOP is just another paradigm. A lot of problems can be solved using both procedural or OOP.
I use OOP when I see clear need of inheritance in the code i am writing, its easier to manage common behaviour and common attributes.
It sometimes makes it easy to understand, and manage. Even if the code is small. | 15 | 28 | 0 | I mostly write small scripts in python, about 50 - 250 lines of code. I usually don't use any objects, just straightforward procedural programming.
I know OOP basics and I have used object in other programming languages before, but for small scripts I don't see how objects would improve them. But maybe that is just my limited experience with OOP.
Am I missing something by not trying harder to use objects, or does OOP just not make a lot of sense for small scripts? | Does OOP make sense for small scripts? | 0.023525 | 0 | 0 | 5,102 |
3,039,889 | 2010-06-14T18:38:00.000 | 6 | 0 | 1 | 0 | python,oop,scripting | 3,039,957 | 17 | false | 0 | 0 | My experience is that any purely procedural script longer than a few dozen lines becomes difficult to maintain. For one thing, if I'm setting or modifying a variable in one place and using it in another place, and those two places can't fit on a single screen, trouble will follow.
The answer, of course, is to tighten the scope and make the different parts of your application more encapsulated. OOP is one way to do that, and can be a useful way to model your environment. I like OOP, as I find I can mentally jump from thinking about how the inside of a particular object will work, to thinking about how the objects will work together, and I stay saner.
However, OOP is certainly not the only way to make your code better encapsulated; another approach would be a set of small, well-named functions with carefully defined inputs and outputs, and a master script that calls those functions as appropriate. | 15 | 28 | 0 | I mostly write small scripts in python, about 50 - 250 lines of code. I usually don't use any objects, just straightforward procedural programming.
I know OOP basics and I have used object in other programming languages before, but for small scripts I don't see how objects would improve them. But maybe that is just my limited experience with OOP.
Am I missing something by not trying harder to use objects, or does OOP just not make a lot of sense for small scripts? | Does OOP make sense for small scripts? | 1 | 0 | 0 | 5,102 |
3,040,290 | 2010-06-14T19:32:00.000 | 3 | 0 | 0 | 0 | python,file,architecture,file-upload | 3,040,346 | 1 | false | 0 | 0 | There is no reliable way to do what you're asking, because fundamentally, your server has no control over the user's browser, computer, or internet connection. If you don't care about reliability, you might try writing a bunch of javascript to trigger the upload at a scheduled time, but it just wouldn't work if the user closed his browser, navigated away from your web page, turned off his computer, walked away from his wifi signal, etc.
If your web site is really so heavily loaded that it buckles when lots of users upload files at once, it might be time to profile your code, use multiple servers, or perhaps use a separate upload server to accept files and then schedule transfer to your main server later. | 1 | 0 | 0 | I have a python script that accepts a file from the user and saves it.
Is it possible to not upload the file immediately but to que it up and when the server has less load to upload it then.
Can this be done by transferring the file to the browsers storage area or taking the file from the Harddrive and transferring to the User's RAM? | Python timed file upload | 0.53705 | 0 | 1 | 100 |
3,041,077 | 2010-06-14T21:27:00.000 | 2 | 0 | 0 | 0 | python,django,deployment | 3,041,911 | 2 | true | 1 | 0 | I doubt the amount of code reuse you can get between the two projects, given your organizational situation, is worth the headaches, organizational risks, and delay risks that it would entail -- after all your team can never rely on the other, since
the ACME product needs to be rock
solid, and therefore needs to be
somewhat isolated of whatever
mistakes/code bloopers the consultants
make in their marketing side of the
site.
This being the case, I would, at most, have the ACME team sometimes release a few little underlying libraries for the other team's use... but even that is fraught, unless used with wildly severe constraints, since one of the bloopers the consultants may make is to code with dependencies on the library's implementation, so ACME basically cannot keep maintaining the library after releasing it for the consultants' use (ACME might think that keeping APIs constraints would be fine, but they can't deal with the other team's reuse-bloopers).
Although one would need to know many specific details, it doesn't appear that the deep underlying commonality between the two teams' projects, at application layer, is all that much anyway (third party stable open-source projects providing common application-independent functionality can of course be used by either or both teams), so the costs of encouraging reuse would not correspond to commensurate returns anyway, from what we can judge looking from "out here". | 2 | 1 | 0 | I know this sounds kind of vague, but please let me explain-
I'm starting work on a brand new project, it will have two main components: "ACME PRODUCT" (think Gmail, Meebo, etc), and "THE SITE" (help, information, marketing stuff, promotional landing pages, etc lots of marketing-induced cruft).
So basically the url /acme/* will load stuff in the uber cool ajaxy application, and every other URI will load stuff in the other site.
Problem: "THE SITE" component is out of my hands, and will be handled by a consultants team that will work closely with marketing, And I and my team will work solely on the ACME PRODUCT.
Question: How to set up the django project in such a way that we can have:
Seperate releases. (They can push new marketing pages and functionality without having to worry about the state of our code. Maybe even separate Subversion "projects")
Minimize impact (on our product) of whatever flying-unicorns-hocus-pocus the other team codes into the site.
Still allow some code reusal.
My main concern is that the ACME product needs to be rock solid, and therefore needs to be somewhat isolated of whatever mistakes/code bloopers the consultants make in their marketing side of the site.
How have you handled this? Any ideas?
Thanks! | Best practice- How to team-split a django project while still allowing code reusal | 1.2 | 0 | 0 | 351 |
3,041,077 | 2010-06-14T21:27:00.000 | 3 | 0 | 0 | 0 | python,django,deployment | 3,041,105 | 2 | false | 1 | 0 | Django's componentization of apps means that you can have independent teams working on the various apps, with template tags and filters (and of course, normal Python functions) used for cross-app coupling. | 2 | 1 | 0 | I know this sounds kind of vague, but please let me explain-
I'm starting work on a brand new project, it will have two main components: "ACME PRODUCT" (think Gmail, Meebo, etc), and "THE SITE" (help, information, marketing stuff, promotional landing pages, etc lots of marketing-induced cruft).
So basically the url /acme/* will load stuff in the uber cool ajaxy application, and every other URI will load stuff in the other site.
Problem: "THE SITE" component is out of my hands, and will be handled by a consultants team that will work closely with marketing, And I and my team will work solely on the ACME PRODUCT.
Question: How to set up the django project in such a way that we can have:
Seperate releases. (They can push new marketing pages and functionality without having to worry about the state of our code. Maybe even separate Subversion "projects")
Minimize impact (on our product) of whatever flying-unicorns-hocus-pocus the other team codes into the site.
Still allow some code reusal.
My main concern is that the ACME product needs to be rock solid, and therefore needs to be somewhat isolated of whatever mistakes/code bloopers the consultants make in their marketing side of the site.
How have you handled this? Any ideas?
Thanks! | Best practice- How to team-split a django project while still allowing code reusal | 0.291313 | 0 | 0 | 351 |
3,042,304 | 2010-06-15T03:15:00.000 | 1 | 1 | 0 | 1 | python,unix,permissions | 3,042,340 | 3 | false | 0 | 0 | os.getgid() and os.getuid() can be useful. For other environment variables, look into os.getenv. For example, os.getenv('USER') on my Mac OS X returns the username. os.getenv('USERNAME') would return the username on Windows machines. | 1 | 31 | 0 | I have a CGI script that is getting an "IOError: [Errno 13] Permission denied" error in the stack trace in the web server's error log.
As part of debugging this problem, I'd like to add a little bit of code to the script to print the user and (especially) group that the script is running as, into the error log (presumably STDERR).
I know I can just print the values to sys.stderr, but how do I figure out what user and group the script is running as?
(I'm particularly interested in the group, so the $USER environment variable won't help; the CGI script has the setgid bit set so it should be running as group "list" instead of the web server's "www-data" - but I need code to see if that's actually happening.) | How to determine what user and group a Python script is running as? | 0.066568 | 0 | 0 | 29,300 |
3,043,085 | 2010-06-15T06:54:00.000 | 2 | 0 | 1 | 0 | python | 3,043,222 | 7 | false | 1 | 0 | Many websites uses Django or Zope/Plone web framework, these are written in Python.
Python is used a lot for writing system administration software, usually when bash scripts (shell script) isn't up to the job, but going C/C++ is an overkill. This is also the spectrum where perl, awk, etc stands. Gentoo's emerge/portage is one example. Mercurial/HG is a distributed version control system (DVCS) written in python.
Many desktop applications are also written in Python. The original Bittorrent was written in python.
Python is also used as the scripting languages for GIMP, Inkscape, Blender, OpenOffice, etc. Python allows advanced users to write plugins and access advanced functionalities that cannot typically be used through a GUI. | 2 | 45 | 0 | I am a web developer and usually use PHP, JavaScript or MySQL.
I have heard lot about Python. But I have no idea where it is used and why it is used.
Just like PHP, ASP, ColdFusion, .NET are used to build websites, and
C, C++, Java are used to build software or desktop apps.
Where does Python fit in this?
What can Python do that these other languages cannot do? | Where is Python language used? | 0.057081 | 0 | 0 | 123,495 |
3,043,085 | 2010-06-15T06:54:00.000 | 1 | 0 | 1 | 0 | python | 3,043,192 | 7 | false | 1 | 0 | Python is used for developing sites. It's more highlevel than php.
Python is used for linux dekstop applications. For example, the most of Ubuntu configurations utilites are pythonic. | 2 | 45 | 0 | I am a web developer and usually use PHP, JavaScript or MySQL.
I have heard lot about Python. But I have no idea where it is used and why it is used.
Just like PHP, ASP, ColdFusion, .NET are used to build websites, and
C, C++, Java are used to build software or desktop apps.
Where does Python fit in this?
What can Python do that these other languages cannot do? | Where is Python language used? | 0.028564 | 0 | 0 | 123,495 |
3,043,597 | 2010-06-15T08:27:00.000 | 2 | 0 | 1 | 1 | python,eclipse,debugging,pydev | 5,732,993 | 2 | false | 0 | 0 | There are known issues with Python 2.4 (so, if possible, get a newer version), still, if you're unable to get a newer version, at least use threadframe extension (http://pypi.python.org/pypi/threadframe). If None of that's possible, it's really expected that the debugger doesn't work as well as it could (as the debugger needs features that are not available in that version). | 2 | 4 | 0 | I've found that under some circumstances the Eclipse python debugger can be unreliable. For example, when stepping through a memory-hungry Python program I've found that after a certain point the debugger fails to respond. The entire process hangs with 100% cpu load.
I've heard (unconfirmed) reports from developers that when this occurs it might actually not be a hang but very slow, for example a step which usually takes a micro-second might be taking five minutes.
I've observed this with both the regular eclipse debugger (e.g. when you do debug as->python run) and the pydev network debugger. The point at which things stop working seems quite arbitrary but re-producable. I'm debugging purely numerical functions so there's no obvious socket or tcp activity which could disrupt a network debugger. Nevertheless, the point at which the failure occurs seems to be quite consistent for a given workstation & task.
I get almost exactly the same effect whether I debug using debug as->python run as I might if I use the pydev's network debugger ('import pydevd;pydevd.settrace()') - where one fails the other is also likely to fail.
If I were to run the script normally (no debugger) it executes without any hangs. Furthermore, if I replace the eclipse debugger with the old-skool inline break-point ('import pdb;pdb.set_trace()') everything works just fine. Pdb almost never goes wrong, however there are times I simply cannot use it, for example when I am debugging a python function invoked from Excel - as there is no console present.
I've noticed that this failure never seems to occur with trivial programs, hence I've tentatively concluded that the fault may be memory related.
So - is anybody aware of what might be causing this unreliability. Are there any tweaks I can make to the debugger or environment that might make the debugger work more reliably?
FYI, running Python 2.4.4 on Windows XP 32bit with the latest Eclipse & Pydev. Psyco (JIT Compiler) is not available. | How can I make the Eclipse Python debugger more reliable? | 0.197375 | 0 | 0 | 1,295 |
3,043,597 | 2010-06-15T08:27:00.000 | 0 | 0 | 1 | 1 | python,eclipse,debugging,pydev | 5,637,371 | 2 | false | 0 | 0 | Not sure if its related, but I had a scenario where too many debug messages will cause my PC to become very slow. You can try go to Window -> Preferences -> Run/Debug -> Console... tick Limit console output, and reduce Console buffer size (mine is set to 40000). | 2 | 4 | 0 | I've found that under some circumstances the Eclipse python debugger can be unreliable. For example, when stepping through a memory-hungry Python program I've found that after a certain point the debugger fails to respond. The entire process hangs with 100% cpu load.
I've heard (unconfirmed) reports from developers that when this occurs it might actually not be a hang but very slow, for example a step which usually takes a micro-second might be taking five minutes.
I've observed this with both the regular eclipse debugger (e.g. when you do debug as->python run) and the pydev network debugger. The point at which things stop working seems quite arbitrary but re-producable. I'm debugging purely numerical functions so there's no obvious socket or tcp activity which could disrupt a network debugger. Nevertheless, the point at which the failure occurs seems to be quite consistent for a given workstation & task.
I get almost exactly the same effect whether I debug using debug as->python run as I might if I use the pydev's network debugger ('import pydevd;pydevd.settrace()') - where one fails the other is also likely to fail.
If I were to run the script normally (no debugger) it executes without any hangs. Furthermore, if I replace the eclipse debugger with the old-skool inline break-point ('import pdb;pdb.set_trace()') everything works just fine. Pdb almost never goes wrong, however there are times I simply cannot use it, for example when I am debugging a python function invoked from Excel - as there is no console present.
I've noticed that this failure never seems to occur with trivial programs, hence I've tentatively concluded that the fault may be memory related.
So - is anybody aware of what might be causing this unreliability. Are there any tweaks I can make to the debugger or environment that might make the debugger work more reliably?
FYI, running Python 2.4.4 on Windows XP 32bit with the latest Eclipse & Pydev. Psyco (JIT Compiler) is not available. | How can I make the Eclipse Python debugger more reliable? | 0 | 0 | 0 | 1,295 |
3,044,359 | 2010-06-15T10:36:00.000 | 0 | 0 | 1 | 1 | python,windows,setuptools | 3,542,501 | 4 | false | 0 | 0 | If you want scripted automation of installs on Windows, look into AutoIt. | 1 | 11 | 0 | Is there no sane way to peform a scripted install of binary python packages for windows? Unfortunately it seems like several essential windows python packages like pywin32 and py2exe are only available as EXE's not MSI's (and as far as I know only the latter are scriptable). Easy_install/pip also seems no use since they apparently only find source packages and then try to compile locally which is obviously unsatisfactory.
Am I missing something? | unattended install of binary python packages (modules) for windows | 0 | 0 | 0 | 4,548 |
3,044,596 | 2010-06-15T11:15:00.000 | 0 | 0 | 1 | 0 | python,thread-safety,dbus | 3,045,144 | 1 | true | 0 | 0 | If you do not modify the list outside of the callback context, then you do not necessarily need synchronization - you will just need to be aware that the list object's state is volatile.
If the list must be modified both in the callback handler as well as, say, the main execution context (or other threads, etc.), then yes you will need synchronization.
The Python synchronized Queue works naturally for message pumps - allowing you to perform actions sequentially in the order that the events come in one of your own contexts. This benefits code simplicity and readability as well since major state changes are easier to track. Callbacks generally shouldn't be too complicated anyway as the outside context in which the callbacks are called shouldn't (and probably doesn't) have to deal with exceptions raised from your code. There are also potential timing considerations as well - the callback will block the async emitter's context - so keeping the handler short and sweet is also good. | 1 | 0 | 0 | I write a python class which makes asynchronous method calls using D-Bus. When my reply_handler is called, it stores data in list. This list can be used by another class methods at the same time. Is it safe or I can use only synchronized data structures like Queue class? | On thread safety in python using D-Bus asynchronous method calls | 1.2 | 0 | 0 | 628 |
3,045,745 | 2010-06-15T13:49:00.000 | 15 | 0 | 1 | 0 | python,qt | 3,045,754 | 3 | false | 0 | 1 | Qt (ideally) provides source compatibility, not binary compatibility. You still have to compile the application separately for each platform, and use the appropriate dynamic Qt libraries (which also need to be compiled separately, and have some platform-specific code).
For your final question, the user would need Python, the Qt libraries, and the binding library (e.g. pyqt), but there are various ways to bundle these. | 1 | 13 | 0 | When you write an application using Qt, can it just be run right away in different operating systems? And (correct me if I'm wrong) you don't need to have Qt already installed in all of the different platforms where you want to execute your application?
How exactly does this work? Does Qt compile to the desired platform, or does it bundle some "dlls" (libs), or how does it do it? Is it different from programming a Java application, that runs cross-platform.
If you use Python to write a Qt application with Python bindings, does your end user need to have Python installed? | How does Qt work (exactly)? | 1 | 0 | 0 | 3,747 |
3,046,036 | 2010-06-15T14:19:00.000 | 0 | 0 | 0 | 0 | python,django,sites | 8,602,597 | 2 | false | 1 | 0 | The django site framework will do that, but it can't server the site according to the domain name. You'll have to do that using you server such as Apache, Nginx, etc. | 1 | 1 | 0 | I need to create an application for the company where I can create sites dynamically. For example, I need an admin interface (Django's admin is enough) where I can setup a new site and add some settings to it.
Each site must hold a domain (domains can be manually added to apache conf, but if Django can handle it too would be awesome). Each site must be independent of the others, I mean, I shouldn't be able to see the data content of other sites but I can share same applications/models.
I've seen the Django's Sites framework, but I'm not sure if it's possible to implement that way.
Should I use Sites framework or create a new app that can handle sites better?
What do you think? | Django: how to create sites dynamically? | 0 | 0 | 0 | 737 |
3,046,183 | 2010-06-15T14:37:00.000 | 4 | 0 | 1 | 1 | python,macos,terminal | 3,046,210 | 3 | false | 0 | 0 | When you run python in a shell or command prompt it will execute the first executable file which is found in your PATH environment variable.
To find out what file is being executed use which python or where python. | 1 | 1 | 0 | When I enter in python in Terminal it loads up Python 2.6.2. However there are folders by the name of Python 2.6 in different places on my drive. I'm not sure if that's because Python 2.6 has been installed in different places or because Python just likes to have lots of folers in different places.
If there are multiple installations, I could really do with being able to set which one should be used. | I suspect I have multiple version of Python 2.6 installed on Mac OS X 10.6.3; how do I set which one Terminal should launch? | 0.26052 | 0 | 0 | 1,464 |
3,047,012 | 2010-06-15T16:19:00.000 | 5 | 1 | 1 | 0 | python | 3,047,546 | 11 | false | 0 | 0 | In some special cases you can trade program size for blistering speed. Create a large array and store the pre-calculated result for every square root operation (using the input value as the index). It's pretty limited but you won't get anything faster.
(That's how quake did it) | 1 | 17 | 0 | I want to find the square root of a number without using the math module,as i need to call the function some 20k times and dont want to slow down the execution by linking to the math module each time the function is called
Is there any faster and easier way for finding square root? | How to perform square root without using math module? | 0.090659 | 0 | 0 | 60,866 |
3,047,412 | 2010-06-15T17:13:00.000 | 1 | 0 | 1 | 0 | python,sql,database,in-memory-database | 65,153,849 | 6 | false | 0 | 0 | In-memory databases usually do not support memory paging option (for the whole database or certain tables), i,e, total size of the database should be smaller than the available physical memory or maximum shared memory size.
Depending on your application, data-access pattern, size of database and available system memory for database, you have a few choices:
a. Pickled Python Data in File System
It stores structured Python data structure (such as list of dictionaries/lists/tuples/sets, dictionary of lists/pandas dataframes/numpy series, etc.) in pickled format so that they could be used immediately and convienently upon unpickled. AFAIK, Python does not use file system as backing store for Python objects in memory implicitly but host operating system may swap out Python processes for higher priority processes. This is suitable for static data, having smaller memory size compared to available system memory. These pickled data could be copied to other computers, read by multiple dependent or independent processes in the same computer. The actual database file or memory size has higher overhead than size of the data. It is the fastest way to access the data as the data is in the same memory of the Python process, and without a query parsing step.
b. In-memory Database
It stores dynamic or static data in the memory. Possible in-memory libraries that with Python API binding are Redis, sqlite3, Berkeley Database, rqlite, etc. Different in-memory databases offer different features
Database may be locked in the physical memory so that it is not swapped to memory backing store by the host operating system. However the actual implementation for the same libray may vary across different operating systems.
The database may be served by a database server process.
The in-memory may be accessed by multiple dependent or independent processes.
Support full, partial or no ACID model.
In-memory database could be persistent to physical files so that it is available when the host operating is restarted.
Support snapshots or/and different database copies for backup or database management.
Support distributed database using master-slave, cluster models.
Support from simple key-value lookup to advanced query, filter, group functions (such as SQL, NoSQL)
c. Memory-map Database/Data Structure
It stores static or dynamic data which could be larger than physical memory of the host operating system. Python developers could use API such as mmap.mmap() numpy.memmap() to map certain files into process memory space. The files could be arranged into index and data so that data could be lookup/accessed via index lookup. This is actually the mechanism used by various database libraries. Python developers could implement custom techniques to access/update data efficiency. | 1 | 32 | 0 | I'm doing some queries in Python on a large database to get some stats out of the database. I want these stats to be in-memory so other programs can use them without going to a database.
I was thinking of how to structure them, and after trying to set up some complicated nested dictionaries, I realized that a good representation would be an SQL table. I don't want to store the data back into the persistent database, though. Are there any in-memory implementations of an SQL database that supports querying the data with SQL syntax? | in-memory database in Python | 0.033321 | 1 | 0 | 44,308 |
3,047,582 | 2010-06-15T17:41:00.000 | 0 | 0 | 0 | 0 | python,pygtk | 3,048,270 | 2 | false | 0 | 1 | Text views won't expand if you pack them into a gtk.ScrolledWindow. This is not what you directly asked, but I believe should solve your problem in a better way. | 1 | 1 | 0 | How do I force a GTK window object to stay the same size, even when a table inside of it tries to expand?
I've tried using gtk.SHRINK when attaching children to the table, but the TextViews within the table still keep expanding to way beyond an acceptable width and expanding the window along with it. | How to force GTK window to stay at a certain width, even when widgets try to expand? | 0 | 0 | 0 | 6,353 |
3,047,799 | 2010-06-15T18:08:00.000 | 0 | 0 | 1 | 0 | python | 3,047,835 | 6 | false | 0 | 0 | Working with a single file is almost certainly going to be faster: you have to read the same amount of data in both cases, but when working with multiple files, you have that much more housekeeping operations slowing you down.
Additionally, you can read data from a single file at the maximum speed the disk can handle, using the disk buffer to the maximum etc., whereas with multiple files, the disk head does a lot more dancing jumping from file to file. | 6 | 2 | 0 | is opening a large file once reading it completely once to list faster (or) opening smaller files whose total sum of size is equal to large file and loading smaller file into list manupalating one by one faster?
which is faster?? is the difference is time large enough to impact my program??
total time difference of lesser then of 30 sec is negligible for me | Which is faster? | 0 | 0 | 0 | 359 |
3,047,799 | 2010-06-15T18:08:00.000 | 2 | 0 | 1 | 0 | python | 3,047,818 | 6 | false | 0 | 0 | Obviously one open and close is going to be faster than n opens and closes if you are reading the same amount of data. Plus, when reading a single file the I/O classes you use can take advantage of things like buffering, etc, which makes it even faster. | 6 | 2 | 0 | is opening a large file once reading it completely once to list faster (or) opening smaller files whose total sum of size is equal to large file and loading smaller file into list manupalating one by one faster?
which is faster?? is the difference is time large enough to impact my program??
total time difference of lesser then of 30 sec is negligible for me | Which is faster? | 0.066568 | 0 | 0 | 359 |
3,047,799 | 2010-06-15T18:08:00.000 | 6 | 0 | 1 | 0 | python | 3,047,842 | 6 | true | 0 | 0 | It depends if your data fit in your available memory. If you need to resort to paging, or virtual memory, then opening a single giant file might become slower than opening more smaller files. This will be even more true if the computation you need to make creates intermediate variables that won't fit in the physical RAM either.
So, as long as the file is not that big, one opening will be faster, but if this is not true, then many opening may be faster.
At last, note that if you can do many opening, you might be able to do them in parallel and process various parts in different processes, which might make things faster again. | 6 | 2 | 0 | is opening a large file once reading it completely once to list faster (or) opening smaller files whose total sum of size is equal to large file and loading smaller file into list manupalating one by one faster?
which is faster?? is the difference is time large enough to impact my program??
total time difference of lesser then of 30 sec is negligible for me | Which is faster? | 1.2 | 0 | 0 | 359 |
3,047,799 | 2010-06-15T18:08:00.000 | 0 | 0 | 1 | 0 | python | 3,047,859 | 6 | false | 0 | 0 | 30sec time difference? Define large. Everything that fits into an average's computer RAM would probably not take much more time than 30sec in total. | 6 | 2 | 0 | is opening a large file once reading it completely once to list faster (or) opening smaller files whose total sum of size is equal to large file and loading smaller file into list manupalating one by one faster?
which is faster?? is the difference is time large enough to impact my program??
total time difference of lesser then of 30 sec is negligible for me | Which is faster? | 0 | 0 | 0 | 359 |
3,047,799 | 2010-06-15T18:08:00.000 | 0 | 0 | 1 | 0 | python | 3,049,925 | 6 | false | 0 | 0 | Why do you think you need to read the file(s) into a list?
If you can open several small files and process each independently, then surely that means:
(a) that you don't need to read into a list, you can process any file (including 1 large file) a line at a time (avoiding running-out-of-real-memory problems)
or
(b) what you need to do is more complicated than you have told us. | 6 | 2 | 0 | is opening a large file once reading it completely once to list faster (or) opening smaller files whose total sum of size is equal to large file and loading smaller file into list manupalating one by one faster?
which is faster?? is the difference is time large enough to impact my program??
total time difference of lesser then of 30 sec is negligible for me | Which is faster? | 0 | 0 | 0 | 359 |
3,047,799 | 2010-06-15T18:08:00.000 | 1 | 0 | 1 | 0 | python | 3,047,840 | 6 | false | 0 | 0 | If you are reading the file sequentially from start until end, one open/close is faster than multiple open/close operations.
However keep in mind that if you need to do a lot of seeking in your 1 big file, then maybe storing separate files won't be slower in that case.
Also keep in mind that no matter which approach you are using, you shouldn't read the entire file in at once. Do it in chunks. | 6 | 2 | 0 | is opening a large file once reading it completely once to list faster (or) opening smaller files whose total sum of size is equal to large file and loading smaller file into list manupalating one by one faster?
which is faster?? is the difference is time large enough to impact my program??
total time difference of lesser then of 30 sec is negligible for me | Which is faster? | 0.033321 | 0 | 0 | 359 |
3,048,268 | 2010-06-15T19:14:00.000 | 1 | 0 | 1 | 0 | python,ruby,regex,perl,nlp | 3,048,460 | 3 | false | 1 | 0 | Ok, this answer is probably not going to be helpful -- I will say that up front. But, in my opinion, merely thinking about the problem in this way is enough to get you hired at most places I've worked. My suggestion? Contact the hiring manager at any of the postings in which you have interest, tell them this is what you are doing. Tell them generically what you have coded so far, and ask for assistance in learning the patterns they use when writing their adverts.
If I were on the receiving end of this letter, I think I would invite the person in for an interview. | 2 | 7 | 0 | Many job sites have broken searches that don't let you narrow down jobs by experience level. Even when they do, it's usually wrong. This requires you to wade through hundreds of postings that you can't apply for before finding a relevant one, quite tedious. Since I'd rather focus on writing cover letters etc., I want to write a program to look through a large number of postings, and save the URLs of just those jobs that don't require years of experience.
I don't require help writing the scraper to get the html bodies of possibly relevant job posts. The issue is accurately detecting the level of experience required for the job. This should not be too difficult as job posts are usually very explicit about this ("must have 5 years experience in..."), but there may be some issues with overly simple solutions.
In my case, I'm looking for entry-level positions. Often they don't say "entry-level", but inclusion of the words probably means the job should be saved.
Next, I can safely exclude a job the says it requires "5 years" of experience in whatever, so a regex like /\d\syears/ seems reasonable to exclude jobs. But then, I realized some jobs say they'll take 0-2 years of experience, matches the exclusion regex but is clearly a job I want to take a look at. Hmmm, I can handle that with another regex. But some say "less than 2 years" or "fewer than 2 years". Can handle that too, but it makes me wonder what other patterns I'm not thinking of, and possibly excluding many jobs. That's what brings me here, to find a better way to do this than regexes, if there is one.
I'd like to minimize the false negative rate and save all the jobs that seem like they might not require many years of experience. Does excluding anything that matches /[3-9]\syears|1\d\syears/ seem reasonable? Or is there a better way? Training a bayesian filter maybe?
Edit: There's a similar, but harder problem, which would probably be more useful to solve. There are lots of jobs that just require an "engineering degree", as you just have to understand a few technical things. But searching for "engineering" gives you thousands of jobs, mostly irrelevant.
How do I narrow this down to just those jobs that require any engineering degree, rather than particular degrees, without looking at each myself? | Online job-searching is tedious. Help me automate it | 0.066568 | 0 | 0 | 567 |
3,048,268 | 2010-06-15T19:14:00.000 | 1 | 0 | 1 | 0 | python,ruby,regex,perl,nlp | 3,050,912 | 3 | false | 1 | 0 | I developed a good parse and email routine for a couple of job websites when I was looking for work for myself and a couple of friends. I agree with the other posts, this is a great way to look at the problem. Just to drop a little info, I did it mostly in ruby, and used tor proxies and some other methods to make sure that I wouldn't be iced out of the job site. This sort of project is unlike usual scraping as you really can't afford to get kicked off a job board. In any case, I just have one piece of advice: forget about sorting and fine tuning this too intensely. Let the HR department do that for you and get your resume and credentials out everywhere. It's a statistical game, and you want to broadcast yourself and throw that net as widely as possible. | 2 | 7 | 0 | Many job sites have broken searches that don't let you narrow down jobs by experience level. Even when they do, it's usually wrong. This requires you to wade through hundreds of postings that you can't apply for before finding a relevant one, quite tedious. Since I'd rather focus on writing cover letters etc., I want to write a program to look through a large number of postings, and save the URLs of just those jobs that don't require years of experience.
I don't require help writing the scraper to get the html bodies of possibly relevant job posts. The issue is accurately detecting the level of experience required for the job. This should not be too difficult as job posts are usually very explicit about this ("must have 5 years experience in..."), but there may be some issues with overly simple solutions.
In my case, I'm looking for entry-level positions. Often they don't say "entry-level", but inclusion of the words probably means the job should be saved.
Next, I can safely exclude a job the says it requires "5 years" of experience in whatever, so a regex like /\d\syears/ seems reasonable to exclude jobs. But then, I realized some jobs say they'll take 0-2 years of experience, matches the exclusion regex but is clearly a job I want to take a look at. Hmmm, I can handle that with another regex. But some say "less than 2 years" or "fewer than 2 years". Can handle that too, but it makes me wonder what other patterns I'm not thinking of, and possibly excluding many jobs. That's what brings me here, to find a better way to do this than regexes, if there is one.
I'd like to minimize the false negative rate and save all the jobs that seem like they might not require many years of experience. Does excluding anything that matches /[3-9]\syears|1\d\syears/ seem reasonable? Or is there a better way? Training a bayesian filter maybe?
Edit: There's a similar, but harder problem, which would probably be more useful to solve. There are lots of jobs that just require an "engineering degree", as you just have to understand a few technical things. But searching for "engineering" gives you thousands of jobs, mostly irrelevant.
How do I narrow this down to just those jobs that require any engineering degree, rather than particular degrees, without looking at each myself? | Online job-searching is tedious. Help me automate it | 0.066568 | 0 | 0 | 567 |
3,048,865 | 2010-06-15T20:43:00.000 | 0 | 0 | 1 | 0 | javascript,python,floating-point | 3,048,904 | 3 | false | 0 | 0 | I would like to understand the reason for this difference in behavior.
They're different languages.
They use different underlying packages.
They have different implementations.
When you say "Python" -- which implementation are you talking about? C, Jython, IronPython? Did you compare each of those?
The Javascript folks seem to handle repeating binary fractions differently from the way the Python folks handle repeating binary fractions.
Sometimes Javascript quietly suppresses the error bits at the end. Sometimes it doesn't.
That's the reason.
You have the source code for both. If you want to know more, you can. Knowing the source code doesn't change much, however. | 2 | 5 | 0 | I have read most of the posts on here regarding floating point, and I understand the basic underlying issue that using IEEE 754 (and just by the nature of storing numbers in binary) certain fractions cannot be represented. I am trying to figure out the following: If both Python and JavaScript use the IEEE 754 standard, why is it that executing the following in Python
.1 + .1
Results in
0.20000000000000001 (which is to be expected)
Where as in Javascript (in at least Chrome and Firefox) the answer is .2
However performing
.1 + .2
In both languages results in
0.30000000000000004
In addition, executing
var a = 0.3; in JavaScript and printing a results in
0.3
Where as doing a = 0.3 in Python results in 0.29999999999999999
I would like to understand the reason for this difference in behavior.
In addition, many of the posts on OS link to a JavaScript port of Java's BigDecimal, but the link is dead. Does anyone have a copy? | Another floating point question | 0 | 0 | 0 | 342 |
3,048,865 | 2010-06-15T20:43:00.000 | 3 | 0 | 1 | 0 | javascript,python,floating-point | 3,048,911 | 3 | false | 0 | 0 | and printing.
They might both have the same IEEE 754 underlying representation, but that doesn't mean they're forced to print the same way. It looks like Javascript is rounding the output when the difference is small enough.
With floating point numbers, the important part is how the binary data is structured, not what it shows on the screen. | 2 | 5 | 0 | I have read most of the posts on here regarding floating point, and I understand the basic underlying issue that using IEEE 754 (and just by the nature of storing numbers in binary) certain fractions cannot be represented. I am trying to figure out the following: If both Python and JavaScript use the IEEE 754 standard, why is it that executing the following in Python
.1 + .1
Results in
0.20000000000000001 (which is to be expected)
Where as in Javascript (in at least Chrome and Firefox) the answer is .2
However performing
.1 + .2
In both languages results in
0.30000000000000004
In addition, executing
var a = 0.3; in JavaScript and printing a results in
0.3
Where as doing a = 0.3 in Python results in 0.29999999999999999
I would like to understand the reason for this difference in behavior.
In addition, many of the posts on OS link to a JavaScript port of Java's BigDecimal, but the link is dead. Does anyone have a copy? | Another floating point question | 0.197375 | 0 | 0 | 342 |
3,049,188 | 2010-06-15T21:27:00.000 | 2 | 1 | 0 | 0 | python,xml,lxml | 3,049,245 | 4 | false | 0 | 0 | The only sane way to generate so large an XML file is line by line, which means printing while running a state machine, and lots of testing. | 2 | 11 | 0 | Does anyone know of a memory efficient way to generate very large xml files (e.g. 100-500 MiB) in Python?
I've been utilizing lxml, but memory usage is through the roof. | Generating very large XML files in Python? | 0.099668 | 0 | 1 | 4,751 |
3,049,188 | 2010-06-15T21:27:00.000 | 2 | 1 | 0 | 0 | python,xml,lxml | 3,050,007 | 4 | false | 0 | 0 | Obviously, you've got to avoid having to build the entire tree ( whether DOM or etree or whatever ) in memory. But the best way depends on the source of your data and how complicated and interlinked the structure of your output is.
If it's big because it's got thousands of instances of fairly independent items, then you can generate the outer wrapper, and then build trees for each item and then serialize each fragment to the output.
If the fragments aren't so independent, then you'll need to do some extra bookkeeping -- like maybe manage a database of generated ids & idrefs.
I would break it into 2 or 3 parts: a sax event producer, an output serializer
eating sax events, and optionally, if it seems easier to work with some independent pieces as objects or trees, something to build those objects and then turn them into sax events for the serializer.
Maybe you could just manage it all as direct text output, instead of dealing with sax events: that depends on how complicated it is.
This may also be a good place to use python generators as a way of streaming the output without having to build large structures in memory. | 2 | 11 | 0 | Does anyone know of a memory efficient way to generate very large xml files (e.g. 100-500 MiB) in Python?
I've been utilizing lxml, but memory usage is through the roof. | Generating very large XML files in Python? | 0.099668 | 0 | 1 | 4,751 |
3,049,431 | 2010-06-15T22:10:00.000 | 3 | 0 | 0 | 0 | python,plone,zope | 3,054,308 | 2 | true | 1 | 0 | BFG doesn't have very much to do with Zope, except:
it uses some Zope libraries internally.
it uses a variant of ZPT as its built-in templating language.
it uses some concepts, such as traversal, that will be familiar to Zope people.
If you know Zope 3 very well, and you like it, you'll like Grok. If you want a framework maybe a bit more like Pylons, but slightly cleaner, and which uses some Zope technologies and concepts, you'll like BFG. | 1 | 1 | 0 | I am about to take the head long plunge into Zope land and am wondering which framework would fit my needs better. I have some experience toying around with django and the primary reason I am switching to a zope-based framework is ZPT and also needing to occasionally do things with Plone. Both seem to be well run projects I am mainly wondering which would have the better learning overlap with Plone? Thanks in advance! | Repoze.bfg or Grok | 1.2 | 0 | 0 | 338 |
3,049,569 | 2010-06-15T22:35:00.000 | 4 | 0 | 1 | 0 | python,function,import,utilities | 3,049,575 | 2 | true | 0 | 0 | If you don't want to make it a member of the Table class you could put it into a utilities module. | 1 | 13 | 0 | I need to create a function to rotate a given matrix (list of lists) clockwise, and I need to use it in my Table class. Where should I put this utility function (called rotateMatrixClockwise) so I can call it easily from within a function in my Table class? | Where do I put utility functions in my Python project? | 1.2 | 0 | 0 | 12,843 |
3,049,625 | 2010-06-15T22:45:00.000 | 1 | 0 | 0 | 0 | python,database,django,postgresql,django-orm | 3,049,796 | 1 | true | 1 | 0 | This could be caused by other things. For example, configuring Apache/mod_wsgi in a way that theoretically it could accept more concurrent requests than what the database itself may be able to accept at the same time. Have you reviewed your Apache/mod_wsgi configuration and compared limit on maximum clients to that of PostgreSQL to make sure something like that hasn't been done. Obviously this presumes though that you have managed to reach that limit in Apache some how and also depends on how any database connection pooling is set up. | 1 | 3 | 0 | I'm running a Django project on Postgresql 8.1.21 (using Django 1.1.1, Python2.5, psycopg2, Apache2 with mod_wsgi 3.2). We've recently encountered this lovely error:
OperationalError: FATAL: connection limit exceeded for non-superusers
I'm not the first person to run up against this. There's a lot of discussion about this error, specifically with psycopg, but much of it centers on older versions of Django and/or offer solutions involving edits to code in Django itself. I've yet to find a succinct explanation of how to solve the problem of the Django ORM (or psycopg, whichever is really responsible, in this case) leaving open Postgre connections.
Will simply adding connection.close() at the end of every view solve this problem? Better yet, has anyone conclusively solved this problem and kicked this error's ass?
Edit: we later upped Postgresql's limit to 500 connections; this prevented the error from cropping up, but replaced it with excessive memory usage. | Django ORM and PostgreSQL connection limits | 1.2 | 1 | 0 | 2,568 |
3,050,450 | 2010-06-16T02:59:00.000 | 0 | 1 | 0 | 0 | java,php,python,artificial-intelligence | 3,050,643 | 9 | false | 1 | 0 | Never use PHP for AI. Java or C/C++ is the best, but Python for fast development. | 7 | 6 | 0 | I have to do one project for my thesis involving Artificial intelligence, collaborative filtering and machine learning methods.
I only know PHP/mysq/JS, and there is not much AI stuff examples in PHP.
There are some books on AI on internet but they use Java , Python.
Now I have to apply AI techniques on web application.
Which language should i choose java or python.
I searhed on internet that I can call java classes inside my php so that can help as as I am very good at php
I have also seen that python can also be used with php as well
So which way should I go and roughly how much it will take me to learn java
I have done java basics but that was 6 years ago | Which language should I use for Artificial intelligence on web projects | 0 | 0 | 0 | 10,608 |
3,050,450 | 2010-06-16T02:59:00.000 | 6 | 1 | 0 | 0 | java,php,python,artificial-intelligence | 3,050,476 | 9 | false | 1 | 0 | Does it really matter which language your books use? I mean, you're not gonna copy-paste those examples. And you'll learn to recognize basic constructs (functions, loops, etc) pretty fast. It's not like learning to read Chinese.
Talking about learning time, there's probably no definite answer to this question. I think the best is to look at examples of code both in java and python and see which seems 'nicer', easier and more familiar to you.
Good luck! | 7 | 6 | 0 | I have to do one project for my thesis involving Artificial intelligence, collaborative filtering and machine learning methods.
I only know PHP/mysq/JS, and there is not much AI stuff examples in PHP.
There are some books on AI on internet but they use Java , Python.
Now I have to apply AI techniques on web application.
Which language should i choose java or python.
I searhed on internet that I can call java classes inside my php so that can help as as I am very good at php
I have also seen that python can also be used with php as well
So which way should I go and roughly how much it will take me to learn java
I have done java basics but that was 6 years ago | Which language should I use for Artificial intelligence on web projects | 1 | 0 | 0 | 10,608 |
3,050,450 | 2010-06-16T02:59:00.000 | 3 | 1 | 0 | 0 | java,php,python,artificial-intelligence | 3,051,952 | 9 | false | 1 | 0 | Which language should i choose java or python.
Here are a few things to consider:
java is more widely used (presumably more mature code "out there" to look at - but I haven't tested that out)
python is more prolific (you write faster in python than in java), and from learning the language to writing the code that you want takes less in python than in java
python is multi-paradigm, java is (almost) strictly OOP
java is compiled (whereas python is scripted); this means that java finds your errors at compilation; python at execution - this can make a big difference, depending on your development style/practices
java is more strictly defined and much more verbose than python. Where in java you have to formalize your contracts, in python you use duck-typing.
In the end, the best you could do is set up a small project, write it in both languages and see what you end up preferring. You may also find some restrictions that you can't get around for one of the languages.
In the end it's up to you :)
Edit: that was not an exhaustive list and I tried to be as impartial as I could (but that ends here: I'd go with python :D) | 7 | 6 | 0 | I have to do one project for my thesis involving Artificial intelligence, collaborative filtering and machine learning methods.
I only know PHP/mysq/JS, and there is not much AI stuff examples in PHP.
There are some books on AI on internet but they use Java , Python.
Now I have to apply AI techniques on web application.
Which language should i choose java or python.
I searhed on internet that I can call java classes inside my php so that can help as as I am very good at php
I have also seen that python can also be used with php as well
So which way should I go and roughly how much it will take me to learn java
I have done java basics but that was 6 years ago | Which language should I use for Artificial intelligence on web projects | 0.066568 | 0 | 0 | 10,608 |
3,050,450 | 2010-06-16T02:59:00.000 | 2 | 1 | 0 | 0 | java,php,python,artificial-intelligence | 3,050,709 | 9 | false | 1 | 0 | You can use any language you like, as long as the server it's hosted on supports it. You can use HTML/JS as the user interface, and request results from the server with AJAX requests.
What answers those requests would be your AI code, and that can be anything you want. PHP makes it really simple to answer AJAX requests. Since you are already familiar with it I would recommend that, although if your AI is very sophisticated you may want to go with something a little more efficient, like C/C++. | 7 | 6 | 0 | I have to do one project for my thesis involving Artificial intelligence, collaborative filtering and machine learning methods.
I only know PHP/mysq/JS, and there is not much AI stuff examples in PHP.
There are some books on AI on internet but they use Java , Python.
Now I have to apply AI techniques on web application.
Which language should i choose java or python.
I searhed on internet that I can call java classes inside my php so that can help as as I am very good at php
I have also seen that python can also be used with php as well
So which way should I go and roughly how much it will take me to learn java
I have done java basics but that was 6 years ago | Which language should I use for Artificial intelligence on web projects | 0.044415 | 0 | 0 | 10,608 |
3,050,450 | 2010-06-16T02:59:00.000 | 0 | 1 | 0 | 0 | java,php,python,artificial-intelligence | 3,264,444 | 9 | false | 1 | 0 | I believe Python is nice for this sort of tasks because of it's flexibility. Using the numpy/scipy libraries together with a nice plotting lib (chaco or matplotlib for instance) makes the workflow of working with the data and algorithms easy and you can lab around with the code in the live interpreter in an almost matlab-like manner. Change a line of code here, cleanse the data there and watch the whole thing live in a graph window without having to bother with recompilation etc.
Once you settled on the algorithms it is fairly easy to profile the code and move hotspots into C/C++ or Fortran for instance if you are worried about performance.
(you could even write the stuff in Jython and drop down into java for the performance-heavy bits of the code if you really like to be on the JVM platform) | 7 | 6 | 0 | I have to do one project for my thesis involving Artificial intelligence, collaborative filtering and machine learning methods.
I only know PHP/mysq/JS, and there is not much AI stuff examples in PHP.
There are some books on AI on internet but they use Java , Python.
Now I have to apply AI techniques on web application.
Which language should i choose java or python.
I searhed on internet that I can call java classes inside my php so that can help as as I am very good at php
I have also seen that python can also be used with php as well
So which way should I go and roughly how much it will take me to learn java
I have done java basics but that was 6 years ago | Which language should I use for Artificial intelligence on web projects | 0 | 0 | 0 | 10,608 |
3,050,450 | 2010-06-16T02:59:00.000 | 0 | 1 | 0 | 0 | java,php,python,artificial-intelligence | 47,068,977 | 9 | false | 1 | 0 | AI is not a language or a specific problem like summation or finding an average of some numbers. It's the intelligence which is going to be developed artificially. And to make a system intelligent especially a computer you can use any language that computer can understand and you are comfortable with (C, Java, Python, C++). A very simple AI example could be tic-tac-toe. This game could be made by using any language you would like to. The important thing is the algorithm that needs to be developed. AI is a vast area and it comprises of many things like Image processing, NLP, Machine learning, Psychology and more. And most importantly one has to be very strong in Mathematics, which is the most important and integral part of softcomputing. So again AI is not a language rather intelligent algorithm based on pure mathematics. | 7 | 6 | 0 | I have to do one project for my thesis involving Artificial intelligence, collaborative filtering and machine learning methods.
I only know PHP/mysq/JS, and there is not much AI stuff examples in PHP.
There are some books on AI on internet but they use Java , Python.
Now I have to apply AI techniques on web application.
Which language should i choose java or python.
I searhed on internet that I can call java classes inside my php so that can help as as I am very good at php
I have also seen that python can also be used with php as well
So which way should I go and roughly how much it will take me to learn java
I have done java basics but that was 6 years ago | Which language should I use for Artificial intelligence on web projects | 0 | 0 | 0 | 10,608 |
3,050,450 | 2010-06-16T02:59:00.000 | 0 | 1 | 0 | 0 | java,php,python,artificial-intelligence | 3,051,880 | 9 | false | 1 | 0 | Pretty much any language can be used to code pretty much anything - given the effort and will. But Python has more functional programming constructs which may be more useful when you are coding AI. | 7 | 6 | 0 | I have to do one project for my thesis involving Artificial intelligence, collaborative filtering and machine learning methods.
I only know PHP/mysq/JS, and there is not much AI stuff examples in PHP.
There are some books on AI on internet but they use Java , Python.
Now I have to apply AI techniques on web application.
Which language should i choose java or python.
I searhed on internet that I can call java classes inside my php so that can help as as I am very good at php
I have also seen that python can also be used with php as well
So which way should I go and roughly how much it will take me to learn java
I have done java basics but that was 6 years ago | Which language should I use for Artificial intelligence on web projects | 0 | 0 | 0 | 10,608 |
3,050,477 | 2010-06-16T03:07:00.000 | 0 | 0 | 0 | 0 | javascript,python | 3,051,343 | 1 | true | 1 | 0 | It can work like this:
on air ticket booking system you have a html form pointing on certain airline booking website (by action parameter). If user submits data then data lands on airline booking website and this website proceed the request.
Usuallly people want to get back to the first site. This can be done by sending return url with request data. Of course there must be an API on the airline booking site to handle such url.
This is common mechanism when you do online payments, all kind of reservations, etc.
Not sure about your idea to use ajax calls. Simple html form is enough here. Note that also making ajax calls between different domains can be recognized as attempt to access the restricted url. | 1 | 0 | 0 | just wonder how those air ticket booking website redirect the user to the airline booking website and then fill up(i suppose doing POST) the required information so that the users will land on the booking page with origin/destination/date selected?
Is the technique used is to open up new browser window and do a ajax POST from there?
Thanks. | redirection follow by post | 1.2 | 0 | 1 | 81 |
3,050,512 | 2010-06-16T03:18:00.000 | 10 | 0 | 1 | 1 | python,ubuntu,installation,gnu,configure | 3,050,521 | 4 | true | 0 | 0 | When you install from source, by default, the installation goes in /usr/local -- the executable in particular becomes /usr/local/bin/pythonX.Y with a symlink to it that's named /usr/local/python. Ubuntu's own installation is in /usr/ (e.g., /usr/bin/python), so the new installation won't overwrite it. Take care that the PATH environment variable doesn't have /usr/local/bin before /usr/bin, or else simple mentions of python would execute the new one, not the old one. | 1 | 8 | 0 | Background:
I am using Ubuntu
The newer python version is not in the apt-get repository (or synaptic)
I plan on keeping the old version as the default python when you call "python" from the command line
I plan on calling the new python using pythonX.X (X.X is the new version).
Given the background, how do you install a newer version of python and keep the older python version?
I have downloaded from python.org the "install from source" *.tgz package. The readme is pretty simple and says "execute three commands: ./configure; make; make test; sudo make install;"
If I do the above commands, will the installation overwrite the old version of python I have (I definitely need the old version)? | On Ubuntu, how do you install a newer version of python and keep the older python version? | 1.2 | 0 | 0 | 11,229 |
3,050,528 | 2010-06-16T03:22:00.000 | 1 | 0 | 1 | 0 | python,dtmf | 3,050,536 | 2 | false | 1 | 0 | Do an FFT on the data. You should get spikes at the frequencies of the two tones. | 1 | 2 | 0 | If I have a recorded audio file (MP3), is there any way to get the figure out the DTMF tones that were recorded in pure Python?
(If pure python is not available, then Java is okay too. The point being that it should be able to run in Google Appengine) | Parse (extract) DTMF in Python | 0.099668 | 0 | 0 | 6,174 |
3,053,442 | 2010-06-16T13:03:00.000 | 0 | 0 | 0 | 0 | python,django | 3,053,690 | 1 | false | 1 | 0 | You'll need to be a bit more specific. There's nothing magical about an app in Django - it's just a collection of models and views. If you need access to some of the models from one app in another app, just import them and use them as normal. | 1 | 0 | 0 | I want to have two custom made app dealing with two different tasks.
i have a page(template) where the data from the both app come together.
how to deploy url for that, in the common urls.py so that the two app work together. how to integrate the views from both app to return data to same template simultaneously. is that possible?
I found these situations in django books, but they have one custom made app and other one is built-in app. the apps are integrated in special way.
can u help to solve my problem with 2 custom app. | multiple custom app in django | 0 | 0 | 0 | 72 |
3,053,480 | 2010-06-16T13:09:00.000 | 3 | 1 | 1 | 0 | python,watermark | 3,053,551 | 1 | false | 0 | 0 | If by watermark you mean some "signature" image content added to an image in order to mark it, then no. Such a watermark is merged with the original image and thus an integral part of it. If you mean meta-data info then yes, this can be read: but you don't specify whether you mean programmatically, or what language or stack you're using or would like to use. | 1 | 1 | 0 | Is there any way to read metadata - watermarks from image files with Python? | How to read watermarks with Python? | 0.53705 | 0 | 0 | 546 |
3,053,875 | 2010-06-16T13:56:00.000 | 0 | 0 | 1 | 0 | python,file,append,prepend | 3,053,949 | 3 | false | 0 | 0 | You could quite easily create an new file, output the data you wish to prepend to that file and then copy the content of the existing file and append it to the new one, then rename.
This would prevent having to read the whole file if that is the primary issue. | 2 | 3 | 0 | Question: How do you write data to an already existing file at the beginning of the file with out writing over what's already there and with out reading the entire file into memory? (e.g. prepend)
Info:
I'm working on a project right now where the program frequently dumps data into a file. this file will very quickly balloon up to 3-4gb. I'm running this simulation on a computer with only 768mb of ram. pulling all that data to the ram over and over will be a great pain and a huge waste of time. The simulation already takes long enough to run as it is.
The file is structured such that the number of dumps it makes is listed at the beginning with just a simple value, like 6. each time the program makes a new dump I want that to be incremented, so now it's 7. the problem lies with the 10th, 100th, 1000th, and so dump. the program will enter the 10 just fine, but remove the first letter of the next line:
"9\n580,2995,2083,028\n..."
"10\n80,2995,2083,028\n..."
obviously, the difference between 580 and 80 in this case is significant. I can't lose these values. so i need a way to add a little space in there so that I can add in this new data without losing my data or having to pull the entire file up and then rewrite it.
Basically what I'm looking for is a kind of prepend function. something to add data to the beginning of a file instead of the end.
Programmed in Python
~n | adding space in an output file with out having to read the entire thing first | 0 | 0 | 0 | 265 |
3,053,875 | 2010-06-16T13:56:00.000 | 1 | 0 | 1 | 0 | python,file,append,prepend | 3,053,958 | 3 | true | 0 | 0 | It's not addressing your original question, but here are some possible workarounds:
Use SQLite (it's bundled with your Python)
Use a fancier database, either RDBMS or NoSQL
Just track the number of dumps in a different text file
The first couple of options are a little more work up front, but provide more flexibility. The last option is the easiest solution to your current problem. | 2 | 3 | 0 | Question: How do you write data to an already existing file at the beginning of the file with out writing over what's already there and with out reading the entire file into memory? (e.g. prepend)
Info:
I'm working on a project right now where the program frequently dumps data into a file. this file will very quickly balloon up to 3-4gb. I'm running this simulation on a computer with only 768mb of ram. pulling all that data to the ram over and over will be a great pain and a huge waste of time. The simulation already takes long enough to run as it is.
The file is structured such that the number of dumps it makes is listed at the beginning with just a simple value, like 6. each time the program makes a new dump I want that to be incremented, so now it's 7. the problem lies with the 10th, 100th, 1000th, and so dump. the program will enter the 10 just fine, but remove the first letter of the next line:
"9\n580,2995,2083,028\n..."
"10\n80,2995,2083,028\n..."
obviously, the difference between 580 and 80 in this case is significant. I can't lose these values. so i need a way to add a little space in there so that I can add in this new data without losing my data or having to pull the entire file up and then rewrite it.
Basically what I'm looking for is a kind of prepend function. something to add data to the beginning of a file instead of the end.
Programmed in Python
~n | adding space in an output file with out having to read the entire thing first | 1.2 | 0 | 0 | 265 |
3,053,923 | 2010-06-16T14:01:00.000 | 1 | 0 | 0 | 0 | python,django,cookies,django-authentication | 3,054,422 | 1 | true | 1 | 0 | I think you should be able to access this via request.session.session_key | 1 | 0 | 0 | In case of views that contain login or logout,
this sessionid is different from the one submitted in request's Coockie header.
I need to retrieve it before returning response for some purpose.
How can I do this ? | Django : In a view how do I obtain the sessionid which will be part of the Set-Cookie header of following response? | 1.2 | 0 | 0 | 501 |
3,054,086 | 2010-06-16T14:18:00.000 | 0 | 0 | 0 | 0 | python,telnet,telnetlib | 3,054,195 | 2 | false | 0 | 0 | If you log in from A to B to C, do you need the console input from A to go to C ?
If not, it is fairly straightforward, as you can execute commands on the second server to connect to the third.
I do something like that using SSH, where I have paramiko and scripts installed on both A and B. A logs in to B and executes a command to start a python script on B which then connects to C and does whatever. | 2 | 0 | 0 | I am able to establish the initial telnet session. But from this session I need to create a second. Basically I can not telnet directly to the device I need to access. Interactively this is not an issue but I am attempting to setup an automated test using python.
Does anyone know who to accomplish this? | Using Python: How can I telnet into a server and then from that connection telnet into a second server? | 0 | 0 | 1 | 797 |
3,054,086 | 2010-06-16T14:18:00.000 | 1 | 0 | 0 | 0 | python,telnet,telnetlib | 3,054,153 | 2 | false | 0 | 0 | After establishing the first connection, just write the same telnet command you use manually to that connection. | 2 | 0 | 0 | I am able to establish the initial telnet session. But from this session I need to create a second. Basically I can not telnet directly to the device I need to access. Interactively this is not an issue but I am attempting to setup an automated test using python.
Does anyone know who to accomplish this? | Using Python: How can I telnet into a server and then from that connection telnet into a second server? | 0.099668 | 0 | 1 | 797 |
3,056,324 | 2010-06-16T19:00:00.000 | 1 | 0 | 1 | 1 | python,django,networking,mac-address | 3,056,396 | 2 | true | 0 | 0 | The easiest thing to do would be to run a tool that can achieve this and parse its output (e.g. nmap). Depending on your needs, you could run it periodically and keep a file with the mac addresses.
Looking at the leases file could work, assuming that all your machines are in there. If you want to actively look for machines, do a nmap scan. | 2 | 0 | 0 | is there a good way to gather the mac addresses of machines on a local network using Python. If it helps I'm trying to execute this python script from the DHCP server for the network. I'm new to Python but would it be a bad idea to look at the DHCP leases file for this info? I'd like to use this inside a Django app eventually. Thanks. | Gathering mac addresses with Python | 1.2 | 0 | 0 | 1,429 |
3,056,324 | 2010-06-16T19:00:00.000 | 1 | 0 | 1 | 1 | python,django,networking,mac-address | 3,056,384 | 2 | false | 0 | 0 | Really a unix question (one will assume)
You can either look at the arp addresses registered "/sbin/arp -a" or a DHCP lease table. If you go the arp route you will on find addresses that your system has recently received/sent packets to, the DHCP lease table will give you the ability to see everything. Though if it's static configured it won't show up. | 2 | 0 | 0 | is there a good way to gather the mac addresses of machines on a local network using Python. If it helps I'm trying to execute this python script from the DHCP server for the network. I'm new to Python but would it be a bad idea to look at the DHCP leases file for this info? I'd like to use this inside a Django app eventually. Thanks. | Gathering mac addresses with Python | 0.099668 | 0 | 0 | 1,429 |
3,057,318 | 2010-06-16T21:26:00.000 | 1 | 0 | 0 | 0 | python,django,django-urls,django-templates | 16,610,048 | 5 | false | 1 | 0 | if you are using Django 1.5 and up, django-reversetags is not required anymore for just passing view names as variables into templates, to be used within the url tag.
I was confused with the availability of django-reversetags, just thought of updating the matter correctly here. | 1 | 18 | 0 | What I'd like to do (for a recent changes 'widget' - not a django widget in this case) is pass a urlname into my template as a variable, then use it like so: {% url sitechangeobject.urlname %} Where urlname is a string containing a valid name for a url.
Is this possible? The template keeps breaking saying it can't find sitechangeobject.urlname as a name (which is quite right, it doesn't exist). Is there any way to make it look inside that variable?
There are other ways to solve this problem if not, just thought I'd check though.
Thanks! | Passing variable urlname to url tag in django template | 0.039979 | 0 | 0 | 13,093 |
3,057,382 | 2010-06-16T21:38:00.000 | 2 | 0 | 0 | 0 | java,python,eclipse,jython,pydev | 3,119,610 | 1 | false | 1 | 0 | eclipse stores project data in files like
.project
.pydevprojct
.classpath
with checkin / checkout via svn it is possible to lost some of these files
check your dot-files | 1 | 2 | 0 | I have two projects in Eclipse with Java and Python code, using Jython. Also I'm using PyDev. One project can import and use the xml module just fine, and the other gives the error ImportError: No module named xml. As far as I can tell, all the project properties are set identically. The working project was created from scratch and the other comes from code checked out of an svn repository and put into a new project.
What could be the difference?
edit- Same for os, btw. It's just missing some path somewhere... | Jython project in Eclipse can't find the xml module, but works in an identical project | 0.379949 | 0 | 1 | 190 |
3,057,507 | 2010-06-16T22:03:00.000 | 4 | 0 | 0 | 1 | python,django | 3,057,550 | 3 | false | 1 | 0 | There are a number of ways to achieve this. Assuming the correct server resources I would write a python script that calls function xyz "outside" of your django directory (although importing the necessary stuff) that only runs if /var/run/django-stuff/my-daemon.run exists. Get cron to run this every two minutes.
Then, for your django functions, your start function creates the above mentioned file if it doesn't already exist and the stop function destroys it.
As I say, there are other ways to achieve this. You could have a python script on loop waiting for approx 2 minutes... etc. In either case, you're up against the fact that two python scripts run on two different invocations of cpython (no idea if this is the case with mod_wsgi) cannot communicate with each other and as such IPC between python scripts is not simple, so you need to use some sort of formal IPC (like semaphores, files etc) rather than just common variables (which won't work). | 2 | 1 | 0 | I am working on a django web application.
A function 'xyx' (it updates a variable) needs to be called every 2 minutes.
I want one http request should start the daemon and keep calling xyz (every 2 minutes) until I send another http request to stop it.
Appreciate your ideas.
Thanks
Vishal Rana | A daemon to call a function every 2 minutes with start and stop capablities | 0.26052 | 0 | 0 | 549 |
3,057,507 | 2010-06-16T22:03:00.000 | 2 | 0 | 0 | 1 | python,django | 3,057,553 | 3 | false | 1 | 0 | Probably a little hacked but you could try this:
Set up a crontab entry that runs a script every two minutes. This script will check for some sort of flag (file existence, contents of a file, etc.) on the disk to decide whether to run a given python module. The problem with this is it could take up to 1:59 to run the function the first time after it is started.
I think if you started a daemon in the view function it would keep the httpd worker process alive as well as the connection unless you figure out how to send a connection close without terminating the django view function. This could be very bad if you want to be able to do this in parallel for different users. Also to kill the function this way, you would have to somehow know which python and/or httpd process you want to kill later so you don't kill all of them.
The real way to do it would be to code an actual daemon in w/e language and just make a system call to "/etc/init.d/daemon_name start" and "... stop" in the django views. For this, you need to make sure your web server user has permission to execute the daemon. | 2 | 1 | 0 | I am working on a django web application.
A function 'xyx' (it updates a variable) needs to be called every 2 minutes.
I want one http request should start the daemon and keep calling xyz (every 2 minutes) until I send another http request to stop it.
Appreciate your ideas.
Thanks
Vishal Rana | A daemon to call a function every 2 minutes with start and stop capablities | 0.132549 | 0 | 0 | 549 |
3,057,643 | 2010-06-16T22:30:00.000 | 4 | 0 | 0 | 0 | python,django,credit-card,payment | 4,027,265 | 4 | false | 1 | 0 | You can avoid PCI audits if the credit card details never touch your server... for example by using payment forms hosted on the servers of your chosen payment gateway provider.
I have used SagePay here in the UK (and built Django connectors for their service from scratch - sorry not on github yet...) and they offer payment forms you can display in an iframe on your site so they look part of your own checkout page, specifically to avoid the PCI issues. | 1 | 32 | 0 | I need to process credit card payments on an app that provides a service outside the U.S. Given that Paypal it's not an option, I was wondering if there other services I could try. What would you recommend? | What's the best option to process credit card payments in Django? | 0.197375 | 0 | 0 | 31,908 |
3,057,805 | 2010-06-16T23:04:00.000 | 0 | 0 | 1 | 0 | python,shell,command-line-interface | 3,057,864 | 3 | false | 0 | 0 | You just need to stick something like this on the first line:
#/usr/local/bin/python
Just make yours be wherever your python binary is located.
As for args look at getopt or optparser
And remember to chmod your file to make it executable. | 1 | 3 | 0 | If possible I would like to use the following structure for a command however I can't seem to figure out how to achieve this in Python:
./somescript.py arg <optional argument> -- "some long argument"
Would it be possible to achieve this in a feasible manner without too much dirty code? Or should I just reconsider the syntax (which is primarily preference).
Thanks! | Python CLI tool - general parsing question | 0 | 0 | 0 | 236 |
3,058,723 | 2010-06-17T03:41:00.000 | 6 | 0 | 0 | 0 | python,bash,facebook | 3,381,527 | 8 | false | 0 | 0 | There IS a way to do it, I've found it, but it's a lot of work and will require you to spoof a browser 100% (and you'll likely be breaking their terms of service)
Sorry I can't provide all the details, but the gist of it:
assuming you have a username/password for a facebook account, go curl for the oauth/authenticate... page. Extract any cookies returned in the "Set-Cookie" header and then follow any "Location" headers (compiling cookies along the way).
scrape the login form, preserving all fields, and submit it (setting the referer and content-type headers, and inserting your email/pass) same cookie collection from (1) required
same as (2) but now you're going to need to POST the approval form acquired after (2) was submitted, set the Referer header with thr URL where the form was acquired.
follow the redirects until it sends you back to your site, and get the "code" parameter out of that URL
Exchange the code for an access_token at the oauth endpoint
The main gotchas are cookie management and redirects. Basically, you MUST mimic a browser 100%. I think it's hackery but there is a way, it's just really hard! | 1 | 41 | 0 | I am trying to put together a bash or python script to play with the facebook graph API. Using the API looks simple, but I'm having trouble setting up curl in my bash script to call authorize and access_token. Does anyone have a working example? | Programmatically getting an access token for using the Facebook Graph API | 1 | 0 | 1 | 72,749 |
3,061,459 | 2010-06-17T12:05:00.000 | 1 | 0 | 1 | 0 | python,code-access-security | 3,063,139 | 2 | false | 0 | 0 | In which I attempt to answer the implied question, "And if so, how?"
I think this is really a Linux administration question. You'd have to figure out how to suspend a user's account on the system you're using and then log the current user out. It's likely going to involve the Python script running as a user with privileges greater than the user you're locking out. You don't really want to encrypt, do you? Just prevent access. Once you know how to accomplish all those things (suspend account / deny login, log out user, run script as privileged user, etc.,) it's easy to perform those tasks from a Python script. | 2 | 0 | 0 | Has anyone seen Jurrassic Park where Dennis Nedry has protected the system with an animation that says 'You didn't say the magic word' where after the system goes down.
Is it possible to do something similar ikn Python ?
To describe it less humoristic:
A response screen which waits for a condition fulfilled by the user.
And encrypts and locks the system after a certain time.
Is that possible on a linux system by the use of Python ? | Python: Dennis Nedry - Security | 0.099668 | 0 | 0 | 467 |
3,061,459 | 2010-06-17T12:05:00.000 | 7 | 0 | 1 | 0 | python,code-access-security | 3,061,468 | 2 | false | 0 | 0 | Yes, it is possible. | 2 | 0 | 0 | Has anyone seen Jurrassic Park where Dennis Nedry has protected the system with an animation that says 'You didn't say the magic word' where after the system goes down.
Is it possible to do something similar ikn Python ?
To describe it less humoristic:
A response screen which waits for a condition fulfilled by the user.
And encrypts and locks the system after a certain time.
Is that possible on a linux system by the use of Python ? | Python: Dennis Nedry - Security | 1 | 0 | 0 | 467 |
3,062,701 | 2010-06-17T14:44:00.000 | 1 | 1 | 1 | 0 | c#,java,python,dynamic-languages | 3,062,743 | 9 | false | 0 | 0 | Interfaces are used in statically typed languages to describe that two otherwise independent objects "implement the same behaviour". In dynamically typed languages one implicitly assumes that when two objects have a method with the same name/params it does the same thing, so interfaces are of no use. | 4 | 18 | 0 | Is it just because of dynamic typing we don't require a concept of interfaces(like in Java and C#) in python? | Why don't we require interfaces in dynamic languages? | 0.022219 | 0 | 0 | 3,173 |
3,062,701 | 2010-06-17T14:44:00.000 | 1 | 1 | 1 | 0 | c#,java,python,dynamic-languages | 3,062,895 | 9 | false | 0 | 0 | Interface constructs are used in statically typed languages to teach the type system which objects are substitutable for each other in a particular method-calling context. If two objects implement the same method but aren't related through inheritance from a common base class or implementation of a common interface, the type system will raise an error at compile time if you substitute one for the other.
Dynamic languages use "duck typing", which means the method is simply looked up at runtime and if it exists with the right signature, it's used; otherwise a runtime error results. If two objects both "quack like a duck" by implementing the same method, they are substitutable. Thus, there's no explicit need for the language to relate them via base class or interface.
That being said, interfaces as a concept are still very important in the dynamic world, but they're often just defined in documentation and not enforced by the language. Occasionally, I see programmers actually make a base class that sketches out the interface for this purpose as well; this helps formalize the documentation, and is of particular use if part of the interface can be implemented in terms of the rest of the interface. | 4 | 18 | 0 | Is it just because of dynamic typing we don't require a concept of interfaces(like in Java and C#) in python? | Why don't we require interfaces in dynamic languages? | 0.022219 | 0 | 0 | 3,173 |
3,062,701 | 2010-06-17T14:44:00.000 | 1 | 1 | 1 | 0 | c#,java,python,dynamic-languages | 3,063,282 | 9 | false | 0 | 0 | One key thing about at least some dynamic languages that makes explicit interfaces more than a little awkward is that dynamic languages can often respond to messages (err, “method calls”) that they don't know about beforehand, even doing things like creating methods on the fly. The only real way to know whether an object will respond to a message correctly is by sending it the message. That's OK, because dynamic languages consider it better to be able to support that sort of thing rather than static type checking; an object is considered to be usable in a particular protocol because it is “known” to be able to participate in that protocol (e.g., by virtue of being given by another message). | 4 | 18 | 0 | Is it just because of dynamic typing we don't require a concept of interfaces(like in Java and C#) in python? | Why don't we require interfaces in dynamic languages? | 0.022219 | 0 | 0 | 3,173 |
3,062,701 | 2010-06-17T14:44:00.000 | 2 | 1 | 1 | 0 | c#,java,python,dynamic-languages | 3,063,169 | 9 | false | 0 | 0 | It's worth noting that, contrary to what many people will say as a first response, interfaces can be used to do more than document "what methods a class supports". Grzenio touches on this with his wording on "implement the same behaviour". As a specific example of this, look at the Java interface Serializable. It doesn't implement any methods; rather it's used as a "marker" to indicate that the class can be serialized safely.
When considered this way, it could be reasonable to have a dynamic language that uses interfaces. That being said, something akin to annotations might be a more reasonable approach. | 4 | 18 | 0 | Is it just because of dynamic typing we don't require a concept of interfaces(like in Java and C#) in python? | Why don't we require interfaces in dynamic languages? | 0.044415 | 0 | 0 | 3,173 |
3,062,741 | 2010-06-17T14:48:00.000 | 67 | 0 | 1 | 0 | python,random,shuffle | 3,062,966 | 3 | true | 0 | 0 | TL;DR: It "breaks" on lists with over 2080 elements, but don't worry too much :)
Complete answer:
First of all, notice that "shuffling" a list can be understood (conceptually) as generating all possible permutations of the elements of the lists, and picking one of these permutations at random.
Then, you must remember that all self-contained computerised random number generators are actually "pseudo" random. That is, they are not actually random, but rely on a series of factors to try and generate a number that is hard to be guessed in advanced, or purposefully reproduced. Among these factors is usually the previous generated number. So, in practice, if you use a random generator continuously a certain number of times, you'll eventually start getting the same sequence all over again (this is the "period" that the documentation refers to).
Finally, the docstring on Lib/random.py (the random module) says that "The period [of the random number generator] is 2**19937-1."
So, given all that, if your list is such that there are 2**19937 or more permutations, some of these will never be obtained by shuffling the list. You'd (again, conceptually) generate all permutations of the list, then generate a random number x, and pick the xth permutation. Next time, you generate another random number y, and pick the yth permutation. And so on. But, since there are more permutations than you'll get random numbers (because, at most after 2**19937-1 generated numbers, you'll start getting the same ones again), you'll start picking the same permutations again.
So, you see, it's not exactly a matter of how long your list is (though that does enter into the equation). Also, 2**19937-1 is quite a long number. But, still, depending on your shuffling needs, you should bear all that in mind. On a simplistic case (and with a quick calculation), for a list without repeated elements, 2081 elements would yield 2081! permutations, which is more than 2**19937. | 1 | 34 | 0 | I have a list which I shuffle with the Python built in shuffle function (random.shuffle)
However, the Python reference states:
Note that for even rather small len(x), the total number of permutations of x is larger than the period of most random number generators; this implies that most permutations of a long sequence can never be generated.
Now, I wonder what this "rather small len(x)" means. 100, 1000, 10000,... | Maximal Length of List to Shuffle with Python random.shuffle? | 1.2 | 0 | 0 | 6,281 |
3,063,078 | 2010-06-17T15:25:00.000 | 0 | 0 | 1 | 0 | python | 3,063,106 | 2 | false | 0 | 0 | The standard struct module can be used to do this easily. Just be careful of your platform endianess but, other than that, it should be a pretty straight-forward application of pack() and unpack(). | 1 | 6 | 0 | How can I combine 2 ints to a single 32bit IEEE floating point ? (each of the 2 ints represent 16 bit)
And in the opposite direction: How can I transform a python float into 2 16 bit ints?
(I need this because of modbus protocol - where 2x16 bit registers are treated as single 32 floating point number) | Python: convert 2 ints to 32 float | 0 | 0 | 0 | 3,715 |
3,064,169 | 2010-06-17T17:46:00.000 | 3 | 0 | 1 | 0 | python,data-structures | 3,064,188 | 4 | false | 0 | 0 | Could you use a dictionary with A as the key, and the item in the dictionary as a 2-item tuple or list? If you're working with any of that data in a consistent way, you could also consider storing a class that has 2 properties in the dictionary. | 1 | 2 | 0 | I've got a set of data that has three attributes, say A, B, and C, where A is kind of the index (i.e., A is used to look up the other two attributes.) What would be the best data structure for such data?
I used two dictionaries, with A as the index of each. However, there's key errors when the query to the data doesn't match any instance of A. | Python what's the data structure for triple data | 0.148885 | 0 | 0 | 2,766 |
3,064,392 | 2010-06-17T18:18:00.000 | 0 | 0 | 1 | 0 | python,file-io,replace | 3,066,885 | 5 | false | 0 | 0 | sed s/oldword/newword/g originalfile.txt > fixedfile.txt
:-) | 1 | 2 | 0 | I want to write a python code that open a text file and Replace with a word that i want send to it .
May you give me an example ?
Thanks . | What Is The Replace Function In Python | 0 | 0 | 0 | 977 |
3,064,405 | 2010-06-17T18:19:00.000 | 3 | 1 | 0 | 1 | python,egg | 3,064,433 | 1 | true | 0 | 0 | The best way to fix it is by creating a directory where it can write it's egg cache. You can specify the directory with the PYTHON_EGG_CACHE variable.
[edit]
And yes, you can convert your apps so they won't need an egg-cache. If you install the python packages with easy_install you can use easy_install -Z so it won't zip the eggs and it won't need to extract them. You should be able to unzip the current eggs to make sure you won't need them.
But personally I would just create the egg cache directory. | 1 | 1 | 0 | Is there an easy way to disable Python egg caching? We have the situation where a system account needs to run a python program which imports a module.
Since this is a non-login robot account, it does not have a home directory, and dies trying to create the directory /.python-eggs.
What's the best way to fix this? Can I convert my eggs in site-files to something which will not be cached in .python-eggs? | Python: disabling $HOME/.python-eggs? | 1.2 | 0 | 0 | 719 |
3,064,830 | 2010-06-17T19:13:00.000 | 0 | 0 | 0 | 0 | python,sql,ms-access,crm | 3,073,339 | 4 | false | 0 | 0 | I'm not even clear on what you're trying to do. I assume your problem is that Jet/ACE can't handle a UNION with that many SELECT statements.
If you have 64 identically-structured tables and you want them in a single CSV, I'd create a temp table in Access, append each table in turn, then export from the temp table to CSV. This is a simple solution and shouldn't be slow, either. The only possible issue might be if there are dupes, but if there are, you can export from a SELECT DISTINCT saved QueryDef.
Tangentially, I'm surprised Maximizer still exists. I had a client who used to use it, and the db structure was terribly unnormalized, just like all the other sales software like ACT. | 2 | 2 | 0 | THE TASK:
I am in the process of migrating a DB from MS Access to Maximizer. In order to do this I must take 64 tables in MS ACCESS and merge them into one. The output must be in the form of a TAB or CSV file. Which will then be imported into Maximizer.
THE PROBLEM:
Access is unable to perform a query that is so complex it seems, as it crashes any time I run the query.
ALTERNATIVES:
I have thought about a few alternatives, and would like to do the least time-consuming one, out of these, while also taking advantage of any opportunities to learn something new.
Export each table into CSVs and import into SQLight and then make a query with it to do the same as what ACCESS fails to do (merge 64 tables).
Export each table into CSVs and write a script to access each one and merge the CSVs into a single CSV.
Somehow connect to the MS ACCESS DB (API), and write a script to pull data from each table and merge them into a CSV file.
QUESTION:
What do you recommend?
CLARIFICATIONS:
I am merging tables, not concatenating. Each table has a different structure and different data. It is a normalized CRM database. Companies->contacts->details = ~ 60 tables of details.
As the Access db will be scuttled after the db is migrated, I want to spend as little time in Access as possible. | Query crashes MS Access | 0 | 1 | 0 | 4,410 |
3,064,830 | 2010-06-17T19:13:00.000 | 1 | 0 | 0 | 0 | python,sql,ms-access,crm | 3,064,852 | 4 | false | 0 | 0 | I would recommend #2 if the merge is fairly simple and straightforward, and doesn't need the power of an RDBMS. I'd go with #1 if the merge is more complex and you will need to write some actual queries to get the data merged properly. | 2 | 2 | 0 | THE TASK:
I am in the process of migrating a DB from MS Access to Maximizer. In order to do this I must take 64 tables in MS ACCESS and merge them into one. The output must be in the form of a TAB or CSV file. Which will then be imported into Maximizer.
THE PROBLEM:
Access is unable to perform a query that is so complex it seems, as it crashes any time I run the query.
ALTERNATIVES:
I have thought about a few alternatives, and would like to do the least time-consuming one, out of these, while also taking advantage of any opportunities to learn something new.
Export each table into CSVs and import into SQLight and then make a query with it to do the same as what ACCESS fails to do (merge 64 tables).
Export each table into CSVs and write a script to access each one and merge the CSVs into a single CSV.
Somehow connect to the MS ACCESS DB (API), and write a script to pull data from each table and merge them into a CSV file.
QUESTION:
What do you recommend?
CLARIFICATIONS:
I am merging tables, not concatenating. Each table has a different structure and different data. It is a normalized CRM database. Companies->contacts->details = ~ 60 tables of details.
As the Access db will be scuttled after the db is migrated, I want to spend as little time in Access as possible. | Query crashes MS Access | 0.049958 | 1 | 0 | 4,410 |
3,066,255 | 2010-06-17T23:07:00.000 | 0 | 0 | 0 | 0 | python,mysql,django | 3,320,441 | 5 | false | 1 | 0 | I concur with the 'no foreign keys' advice (with the disclaimer: I also work for Percona).
The reason why it is is recommended is for concurrency / reducing locking internally.
It can be a difficult "optimization" to sell, but if you consider that the database has transactions (and is more or less ACID compliant) then it should only be application-logic errors that cause foreign-key violations. Not to say they don't exist, but if you enable foreign keys in development hopefully you should find at least a few bugs.
In terms of whether or not you need to write custom SQL:
The explanation I usually give is that "optimization rarely decreases complexity". I think it is okay to stick with an ORM by default, but if in a profiler it looks like one particular piece of functionality is taking a lot more time than you suspect it would when written by hand, then you need to be prepared to fix it (assuming the code is called often enough).
The real secret here is that you need good instrumentation / profiling in order to be frugal with your complexity adding optimization(s). | 3 | 2 | 0 | I've just started learning Python Django and have a lot of experience building high traffic websites using PHP and MySQL. What worries me so far is Python's overly optimistic approach that you will never need to write custom SQL and that it automatically creates all these Foreign Key relationships in your database. The one thing I've learned in the last few years of building Chess.com is that its impossible to NOT write custom SQL when you're dealing with something like MySQL that frequently needs to be told what indexes it should use (or avoid), and that Foreign Keys are a death sentence. Percona's strongest recommendation was for us to remove all FKs for optimal performance.
Is there a way in Django to do this in the models file? create relationships without creating actual DB FKs? Or is there a way to start at the database level, design/create my database, and then have Django reverse engineer the models file? | Does Python Django support custom SQL and denormalized databases with no Foreign Key relationships? | 0 | 1 | 0 | 640 |
3,066,255 | 2010-06-17T23:07:00.000 | 0 | 0 | 0 | 0 | python,mysql,django | 3,066,274 | 5 | false | 1 | 0 | django-admin inspectdb allows you to reverse engineer a models file from existing tables. That is only a very partial response to your question ;) | 3 | 2 | 0 | I've just started learning Python Django and have a lot of experience building high traffic websites using PHP and MySQL. What worries me so far is Python's overly optimistic approach that you will never need to write custom SQL and that it automatically creates all these Foreign Key relationships in your database. The one thing I've learned in the last few years of building Chess.com is that its impossible to NOT write custom SQL when you're dealing with something like MySQL that frequently needs to be told what indexes it should use (or avoid), and that Foreign Keys are a death sentence. Percona's strongest recommendation was for us to remove all FKs for optimal performance.
Is there a way in Django to do this in the models file? create relationships without creating actual DB FKs? Or is there a way to start at the database level, design/create my database, and then have Django reverse engineer the models file? | Does Python Django support custom SQL and denormalized databases with no Foreign Key relationships? | 0 | 1 | 0 | 640 |
3,066,255 | 2010-06-17T23:07:00.000 | 0 | 0 | 0 | 0 | python,mysql,django | 3,066,360 | 5 | false | 1 | 0 | You can just create the model.py and avoid having SQL Alchemy automatically create the tables leaving it up to you to define the actual tables as you please. So although there are foreign key relationships in the model.py this does not mean that they must exist in the actual tables. This is a very good thing considering how ludicrously foreign key constraints are implemented in MySQL - MyISAM just ignores them and InnoDB creates a non-optional index on every single one regardless of whether it makes sense. | 3 | 2 | 0 | I've just started learning Python Django and have a lot of experience building high traffic websites using PHP and MySQL. What worries me so far is Python's overly optimistic approach that you will never need to write custom SQL and that it automatically creates all these Foreign Key relationships in your database. The one thing I've learned in the last few years of building Chess.com is that its impossible to NOT write custom SQL when you're dealing with something like MySQL that frequently needs to be told what indexes it should use (or avoid), and that Foreign Keys are a death sentence. Percona's strongest recommendation was for us to remove all FKs for optimal performance.
Is there a way in Django to do this in the models file? create relationships without creating actual DB FKs? Or is there a way to start at the database level, design/create my database, and then have Django reverse engineer the models file? | Does Python Django support custom SQL and denormalized databases with no Foreign Key relationships? | 0 | 1 | 0 | 640 |
3,066,438 | 2010-06-18T00:05:00.000 | 1 | 0 | 1 | 1 | python,login,restart,boot | 3,066,480 | 3 | true | 0 | 0 | I can't think of any way to do strictly what you want off the top of my head other than the registry, at least not without even more drastic measures. But doing this registry modification isn't a big deal; just change the autologon username/password and reboot the computer. To have the computer reboot when the user logs off, give them a "logoff" option that actually reboots rather than logging off; I've seen other places do that.
(edit)FYI: for registry edits, Windows has a REG command that will be useful if you decide to go with that route.(/edit)
Also, what kind of process are you trying to run? If it's not a GUI app that needs your interaction, you don't have to go through any great pains; just run the app remotely. At my work, we use psexec to do it very simply, and I've also created C++ programs that run code remotely. It's not that difficult, the way I do it is to have C++ call the WinAPI function to remotely register a service on the remote PC and start it, the service then does whatever I want (itself, or as a staging point to launch other things), then unregisters itself. I have only used Python for simple webpage stuff, so I'm not sure what kind of support it has for accessing the DLLs required, but if it can do that, you can still use Python here.
Or even better yet, if you don't need to do this remotely but just want it done every night, you can just use the Windows scheduler to run whatever application you want run during the night. You can even do this programmatically as there are a couple Windows commands for that: one is the "at" command, and I don't recall right now what the other is but just a little Googling should find it for you. | 2 | 1 | 0 | I know how to reboot machines remotely, so that's the easy part. However, the complexity of the issue is trying to setup the following. I'd like to control machines on a network for after-hours use such that when users logoff and go home, or shutdown their computers, whatever, python or some combination of python + windows could restart their machines (for cleanliness) and automatically login, running a process for the night, then in the morning, stop said process and restart the machine so the user could easily login like normal.
I've looked around, haven't had too terribly much luck, though it looks like one could do it with a changing of the registry. That sounds like a rough idea though, modifying the registry on a per-day basis. Is there an easier way? | Reboot windows machines at a certain time of day and automatically login with Python | 1.2 | 0 | 0 | 1,489 |
3,066,438 | 2010-06-18T00:05:00.000 | 0 | 0 | 1 | 1 | python,login,restart,boot | 3,076,111 | 3 | false | 0 | 0 | Thanks for the responses. To be more clear on what I'm doing, I have a program that automatically starts on bootup, so getting logged in would be preferred. I'm coding a manager for a render-farm for work which will take all the machines that our guys use during the day and turn them into render servers at night (or whenever they log off for a period of time, for example).
I'm not sure if I necessarily require a GUI app, but the computer would need to boot and login to launch a server application that does the rendering, and I'm not certain if that can be done without logging in. What i'm needing to run is Autodesk's Backburner Server.exe
Maybe that can be run without needing to be logged in specifically, but I'm unfamiliar with doing things of that nature. | 2 | 1 | 0 | I know how to reboot machines remotely, so that's the easy part. However, the complexity of the issue is trying to setup the following. I'd like to control machines on a network for after-hours use such that when users logoff and go home, or shutdown their computers, whatever, python or some combination of python + windows could restart their machines (for cleanliness) and automatically login, running a process for the night, then in the morning, stop said process and restart the machine so the user could easily login like normal.
I've looked around, haven't had too terribly much luck, though it looks like one could do it with a changing of the registry. That sounds like a rough idea though, modifying the registry on a per-day basis. Is there an easier way? | Reboot windows machines at a certain time of day and automatically login with Python | 0 | 0 | 0 | 1,489 |
3,067,409 | 2010-06-18T05:35:00.000 | 6 | 0 | 1 | 0 | python | 3,067,481 | 6 | false | 0 | 0 | Quite apart from the octal caper:
Zip codes, social security "numbers", credit card "numbers", phone "numbers", etc are NOT numbers in the sense that you can do meaningful arithmetic on them, so don't keep them as integers, keep them as strings. | 4 | 6 | 0 | zipcode = 02132
print zipcode
result = 1114 | Not getting exact result in python with the values leading zero. Please tell me what is going on there | 1 | 0 | 0 | 1,103 |
3,067,409 | 2010-06-18T05:35:00.000 | 9 | 0 | 1 | 0 | python | 3,067,424 | 6 | false | 0 | 0 | In Python 2.x, number with a leading zero is interpreted as octal (base-eight). Python 3.x requires a leading "0o" to indicate an octal number. You probably want to treat a zipcode as a string to keep the leading zeroes intact. | 4 | 6 | 0 | zipcode = 02132
print zipcode
result = 1114 | Not getting exact result in python with the values leading zero. Please tell me what is going on there | 1 | 0 | 0 | 1,103 |
3,067,409 | 2010-06-18T05:35:00.000 | 2 | 0 | 1 | 0 | python | 3,067,418 | 6 | false | 0 | 0 | What is your question? I guess, why is that. The answer is octal numbers. If a number starts with a zero, Python thinks you mean an octal number. (Base 8) | 4 | 6 | 0 | zipcode = 02132
print zipcode
result = 1114 | Not getting exact result in python with the values leading zero. Please tell me what is going on there | 0.066568 | 0 | 0 | 1,103 |
3,067,409 | 2010-06-18T05:35:00.000 | 5 | 0 | 1 | 0 | python | 3,067,413 | 6 | false | 0 | 0 | The leading 0 makes it assume 02132 is octal. | 4 | 6 | 0 | zipcode = 02132
print zipcode
result = 1114 | Not getting exact result in python with the values leading zero. Please tell me what is going on there | 0.16514 | 0 | 0 | 1,103 |
3,067,452 | 2010-06-18T05:48:00.000 | 0 | 0 | 0 | 1 | python,django,google-app-engine | 13,855,137 | 3 | false | 1 | 0 | Appengine comes with built in Django, if you look under your (google_appengine/lib/django_1_3) lib dir you will see a few versions. You can define what version you want to be used in your app.yaml
It isn't a full release of Django and if you do want to have full admin functionality of Django you might have to use something like nonrel but personally I would say its not necessary and you stand to gain more by getting to understand the underlying nosql structure of appengine, in particular the NDB model is very useful | 1 | 1 | 0 | I am impressed with django.Am am currenty a java developer.I want to make some cool websites for myself but i want to host it in some third pary environmet.
Now the question is can i host the django application on appengine?If yes , how??
Are there any site built using django which are already hosted on appengine? | django on appengine | 0 | 0 | 0 | 253 |
3,067,453 | 2010-06-18T05:48:00.000 | 1 | 0 | 0 | 0 | python,django,datefield | 3,067,477 | 3 | false | 1 | 0 | A DateField is a whole date. If you only care about the month and day then use __month and __day when querying. | 1 | 10 | 0 | Is it possible to have a DateField without the year? Or will I have to use a CharField? I am using the admin to edit the models. | Django DateField without year | 0.066568 | 0 | 0 | 4,685 |
3,068,827 | 2010-06-18T10:27:00.000 | 1 | 0 | 0 | 0 | python,django | 3,068,886 | 2 | false | 1 | 0 | This template responsibility to display this image in your case, I believe.
If you form need to be able to send image related information (path, url..), you'll need to create a dedicated widget. | 2 | 4 | 0 | I need to display an image in a Django form. My Django form is quite simple - a single text input field. When I initialise my Django form in a view, I would like to pass the image path as a parameter, and the form when rendered in the template displays the image. Is is possible with Django forms or would i have to display the image separately?
Thanks. | Display image in Django Form | 0.099668 | 0 | 0 | 1,365 |
3,068,827 | 2010-06-18T10:27:00.000 | 1 | 0 | 0 | 0 | python,django | 3,068,909 | 2 | true | 1 | 0 | If the image is related to the form itself, not to any field in particular, then you can make a custom form class and override one of as_table(), as_ul(), as_p() methods. Or you can just use a custom template instead of leaving the form to render itself.
If it is field related then a custom widget is appropriate, as Pierre suggested. | 2 | 4 | 0 | I need to display an image in a Django form. My Django form is quite simple - a single text input field. When I initialise my Django form in a view, I would like to pass the image path as a parameter, and the form when rendered in the template displays the image. Is is possible with Django forms or would i have to display the image separately?
Thanks. | Display image in Django Form | 1.2 | 0 | 0 | 1,365 |
3,068,843 | 2010-06-18T10:30:00.000 | 3 | 0 | 0 | 0 | python,django,django-admin | 3,069,023 | 12 | false | 1 | 0 | One workaround would be to have an additional "save" permission on your model and check in the modeladmin's save_model method if the user has this permissions, if he has not, that would mean he can do everything in this modeladmin, except saving edited data! | 3 | 27 | 0 | is it possible to give users the permission to view, but not to change or delete.
currently in the only permissions I see are "add", "change" and "delete"... but there is no "read/view" in there.
I really need this as some users will only be able to consult the admin panel, in order to see what has been added in. | Permission to view, but not to change! - Django | 0.049958 | 0 | 0 | 25,793 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.