Available Count
int64 1
31
| AnswerCount
int64 1
35
| GUI and Desktop Applications
int64 0
1
| Users Score
int64 -17
588
| Q_Score
int64 0
6.79k
| Python Basics and Environment
int64 0
1
| Score
float64 -1
1.2
| Networking and APIs
int64 0
1
| Question
stringlengths 15
7.24k
| Database and SQL
int64 0
1
| Tags
stringlengths 6
76
| CreationDate
stringlengths 23
23
| System Administration and DevOps
int64 0
1
| Q_Id
int64 469
38.2M
| Answer
stringlengths 15
7k
| Data Science and Machine Learning
int64 0
1
| ViewCount
int64 13
1.88M
| is_accepted
bool 2
classes | Web Development
int64 0
1
| Other
int64 1
1
| Title
stringlengths 15
142
| A_Id
int64 518
72.2M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 3 | 0 | 2 | 7 | 1 | 0.132549 | 0 | I have a Python module with nothing but regular global functions. I need to call it from another business-domain scripting environment that can only call out to C DLLs. Is there anyway to build my Python modules so that to other code it can be called like a standard C function that's exported from a DLL? This is for a Windows environment. I'm aware of IronPython, but as far as I know it can only build .NET Assemblies, which are not callable as C DLL functions. | 0 | python | 2009-03-14T13:11:00.000 | 0 | 645,892 | Py2exe can generate COM dlls from python code, by compiling and embedding python code + interpreter. It does not, AFAIK, support regular DLLs yet. For that, see dirkgently's answer about embedding python yourself. | 0 | 310 | false | 0 | 1 | Is there a way to build a C-like DLL from a Python module? | 645,935 |
1 | 1 | 0 | 2 | 1 | 0 | 1.2 | 0 | I am new to Satchmo -- picked it up because I needed payment processing for site subscriptions and physical product.
My site will have two classes of users: paid subscribers and free users. Both can order a
physical product. Paid subscribers get an automatic discount on all orders.
I don't see a configuration for this in the admin. (Discount looks like it would apply to all users. If I'm missing something here, let me know.)
So what's the best place to automatically override the price depending on the user class? The displayed price should show up, say, 10% less for subscribers everywhere in the site, not just at the checkout.
Thanks. | 0 | python,django,satchmo | 2009-03-15T03:46:00.000 | 0 | 647,257 | Checkout the tiered pricing module | 0 | 312 | true | 1 | 1 | Provide discount to preferred customer with Satchmo? | 1,198,670 |
1 | 4 | 0 | 1 | 28 | 1 | 0.049958 | 0 | One of Python's strongest points is the ease of writing C and C++ extensions to speed up processor intensive parts of the code. Can these extensions avoid the Global Interpreter Lock or are they also restricted by the GIL? If not, then this "ease of extension" is even more of a killer feature than I previously realized. I suspect the answer is not a simple yes-or-no but I am not sure, so I am asking the question here on StackOverflow. | 0 | c++,python,c,multithreading | 2009-03-16T16:00:00.000 | 0 | 651,048 | Check out Cython, it has similar syntax to Python but with a few constructs like "cdef", fast numpy access functions, and a "with nogil" statement (which does what it says). | 0 | 7,350 | false | 0 | 1 | Concurrency: Are Python extensions written in C/C++ affected by the Global Interpreter Lock? | 733,143 |
3 | 3 | 0 | 6 | 1 | 0 | 1.2 | 1 | I need advice and how to got about setting up a simple service for my users. I would like to add a new feature where users can send and receive emails from their gmail account. I have seen this done several times and I know its possible.
There use to be a project for "Libgmailer" at sourceforge but I think it was abandoned. Is anyone aware of anything similar?
I have found that Gmail has a Python API but my site is making use of PHP.
I really need ideas on how to best go about this!
Thanks all for any input | 0 | php,python,email,gmail | 2009-03-17T21:51:00.000 | 0 | 656,180 | any library/source that works with imap or pop will work. | 0 | 498 | true | 0 | 1 | Implementation: How to retrieve and send emails for different Gmail accounts? | 656,198 |
3 | 3 | 0 | 0 | 1 | 0 | 0 | 1 | I need advice and how to got about setting up a simple service for my users. I would like to add a new feature where users can send and receive emails from their gmail account. I have seen this done several times and I know its possible.
There use to be a project for "Libgmailer" at sourceforge but I think it was abandoned. Is anyone aware of anything similar?
I have found that Gmail has a Python API but my site is making use of PHP.
I really need ideas on how to best go about this!
Thanks all for any input | 0 | php,python,email,gmail | 2009-03-17T21:51:00.000 | 0 | 656,180 | Just a thought, Gmail supports POP/IMAP access. Could you do it using those protocols? It would mean asking your users to go into their gmail and enable it though. | 0 | 498 | false | 0 | 1 | Implementation: How to retrieve and send emails for different Gmail accounts? | 656,205 |
3 | 3 | 0 | 0 | 1 | 0 | 0 | 1 | I need advice and how to got about setting up a simple service for my users. I would like to add a new feature where users can send and receive emails from their gmail account. I have seen this done several times and I know its possible.
There use to be a project for "Libgmailer" at sourceforge but I think it was abandoned. Is anyone aware of anything similar?
I have found that Gmail has a Python API but my site is making use of PHP.
I really need ideas on how to best go about this!
Thanks all for any input | 0 | php,python,email,gmail | 2009-03-17T21:51:00.000 | 0 | 656,180 | Well if Google didn't come up with anything personally I'd see if I could reverse engineer the Python API by implementing it and watching it with a packet sniffer. My guess is it's just accessing some web service which should be pretty easy to mimic regardless of the language you're using. | 0 | 498 | false | 0 | 1 | Implementation: How to retrieve and send emails for different Gmail accounts? | 656,194 |
2 | 4 | 0 | 3 | 10 | 0 | 0.148885 | 0 | I've been playing with PyWinAuto today and having fun automating all sorts GUI tests. I was wondering if it is still state of the art or if there might be something else (also free) which does windows rich client automation better. | 0 | python,pywinauto | 2009-03-18T02:34:00.000 | 0 | 656,779 | I am going the same way, bit by bit and I have to say that python + pywinauto is good stuff! | 0 | 6,625 | false | 0 | 1 | PyWinAuto still useful? | 6,291,256 |
2 | 4 | 0 | 8 | 10 | 0 | 1 | 0 | I've been playing with PyWinAuto today and having fun automating all sorts GUI tests. I was wondering if it is still state of the art or if there might be something else (also free) which does windows rich client automation better. | 0 | python,pywinauto | 2009-03-18T02:34:00.000 | 0 | 656,779 | I used to do test automation on our projects with AutoIt but switched over to pywinauto 3 months ago and have been very happy with that decision. There are some rough edges, but I've been able to fill them in with my own supplementary test functions. In addition I find that coding tests and support code in Python is much easier and more manageable compared to AutoIt. With Python I have way more powerful options for logging, debugging, documentation, process management and test configuration. For me it was absolutely the right way to go. | 0 | 6,625 | false | 0 | 1 | PyWinAuto still useful? | 1,653,008 |
2 | 4 | 0 | -2 | 2 | 1 | -0.099668 | 0 | Is there a way of knowing which modules are available to import from inside a package? | 0 | python,import | 2009-03-18T11:30:00.000 | 0 | 657,868 | import fred
print dir(fred) | 0 | 284 | false | 0 | 1 | How do I find the modules that are available for import from within a package? | 657,927 |
2 | 4 | 0 | -1 | 2 | 1 | -0.049958 | 0 | Is there a way of knowing which modules are available to import from inside a package? | 0 | python,import | 2009-03-18T11:30:00.000 | 0 | 657,868 | You have the source.
Look at the files inside the package directory. Those modules are available for you to import. | 0 | 284 | false | 0 | 1 | How do I find the modules that are available for import from within a package? | 658,158 |
1 | 6 | 0 | 1 | 25 | 0 | 0.033321 | 0 | I am stuck with a fairly complex Python module that does not return useful error codes (it actually fails disturbingly silently). However, the underlying C library it calls sets errno.
Normally errno comes in over OSError attributes, but since I don't have an exception, I can't get at it.
Using ctypes, libc.errno doesn't work because errno is a macro in GNU libc. Python 2.6 has some affordances but Debian still uses Python 2.5. Inserting a C module into my pure Python program just to read errno disgusts me.
Is there some way to access errno? A Linux-only solution is fine, since the library being wrapped is Linux-only. I also don't have to worry about threads, as I'm only running one thread during the time in which this can fail. | 0 | python,linux,python-2.5,errno | 2009-03-19T04:00:00.000 | 1 | 661,017 | ctypes actually gives a standard way to access python's c implementation, which is using errno. I haven't tested this on anything other than my (linux) system, but this should be very portable:
ctypes.c_int.in_dll(ctypes.pythonapi,"errno")
which returns a c_int containing the current value. | 0 | 10,955 | false | 0 | 1 | Access to errno from Python? | 6,170,629 |
3 | 24 | 0 | 66 | 206 | 0 | 1.2 | 0 | Is there a simple way of testing if the generator has no items, like peek, hasNext, isEmpty, something along those lines? | 0 | python,generator | 2009-03-19T09:51:00.000 | 0 | 661,603 | The simple answer to your question: no, there is no simple way. There are a whole lot of work-arounds.
There really shouldn't be a simple way, because of what generators are: a way to output a sequence of values without holding the sequence in memory. So there's no backward traversal.
You could write a has_next function or maybe even slap it on to a generator as a method with a fancy decorator if you wanted to. | 0 | 101,926 | true | 0 | 1 | How do I know if a generator is empty from the start? | 662,925 |
3 | 24 | 0 | 0 | 206 | 0 | 0 | 0 | Is there a simple way of testing if the generator has no items, like peek, hasNext, isEmpty, something along those lines? | 0 | python,generator | 2009-03-19T09:51:00.000 | 0 | 661,603 | There's a very simple solution: if next(generator,-1) == -1 then the generator is empty! | 0 | 101,926 | false | 0 | 1 | How do I know if a generator is empty from the start? | 64,162,865 |
3 | 24 | 0 | 0 | 206 | 0 | 0 | 0 | Is there a simple way of testing if the generator has no items, like peek, hasNext, isEmpty, something along those lines? | 0 | python,generator | 2009-03-19T09:51:00.000 | 0 | 661,603 | bool(generator) will return the correct result | 0 | 101,926 | false | 0 | 1 | How do I know if a generator is empty from the start? | 70,471,281 |
1 | 10 | 0 | 3 | 173 | 0 | 0.059928 | 1 | I could use some pseudo-code, or better, Python. I am trying to implement a rate-limiting queue for a Python IRC bot, and it partially works, but if someone triggers less messages than the limit (e.g., rate limit is 5 messages per 8 seconds, and the person triggers only 4), and the next trigger is over the 8 seconds (e.g., 16 seconds later), the bot sends the message, but the queue becomes full and the bot waits 8 seconds, even though it's not needed since the 8 second period has lapsed. | 0 | python,algorithm,message-queue | 2009-03-20T19:02:00.000 | 0 | 667,508 | One solution is to attach a timestamp to each queue item and to discard the item after 8 seconds have passed. You can perform this check each time the queue is added to.
This only works if you limit the queue size to 5 and discard any additions whilst the queue is full. | 0 | 108,156 | false | 0 | 1 | What's a good rate limiting algorithm? | 667,528 |
2 | 2 | 0 | 3 | 7 | 1 | 0.291313 | 0 | I'm a somewhat advanced C++/Java Developer who recently became interested in Python and I enjoy its dynamic typing and efficient coding style very much. I currently use it on my small programming needs like solving programming riddles and scripting, but I'm curious if anyone out there has successfully used Python in an enterprise-quality project? (Preferably using modern programming concepts such as OOP and some type of Design Pattern)
If so, would you please explain why you chose Python (specifically) and give us some of the lessons you learned from this project? (Feel free to compare the use of Python in the project vs Java or etc) | 0 | java,python,design-patterns,programming-languages,dynamic-typing | 2009-03-23T09:59:00.000 | 0 | 672,781 | I've been using Python as distributed computing framework in one of the worlds largest banks.
It was chosen because:
It had to be extremely fast for developing and deploying new functionalities;
It had to be easily integrable with C and C++;
Some parts of the code were to be written by people whose area of expertise was mathematical modeling, not software development. | 0 | 1,839 | false | 0 | 1 | Python Programming - Rules/Advice for developing enterprise-level software in Python? | 672,806 |
2 | 2 | 0 | 17 | 7 | 1 | 1.2 | 0 | I'm a somewhat advanced C++/Java Developer who recently became interested in Python and I enjoy its dynamic typing and efficient coding style very much. I currently use it on my small programming needs like solving programming riddles and scripting, but I'm curious if anyone out there has successfully used Python in an enterprise-quality project? (Preferably using modern programming concepts such as OOP and some type of Design Pattern)
If so, would you please explain why you chose Python (specifically) and give us some of the lessons you learned from this project? (Feel free to compare the use of Python in the project vs Java or etc) | 0 | java,python,design-patterns,programming-languages,dynamic-typing | 2009-03-23T09:59:00.000 | 0 | 672,781 | I'm using Python for developing a complex insurance underwriting application.
Our application software essentially repackages our actuarial model in a form that companies can subscribe to it. This business is based on our actuaries and their deep thinking. We're not packaging a clever algorithm that's relatively fixed. We're renting our actuarial brains to customers via a web service.
The actuaries must be free to make changes as they gain deeper insight into the various factors that lead to claims.
Static languages (Java, C++, C#) lead to early lock-in to a data model.
Python allows us to have a very flexible data model. They're free to add, change or delete factors or information sources without a lot of development cost and complexity. Duck typing allows us to introduce new pieces without a lot rework.
Our software is a service (not a package) so we have an endless integration problem.
Static languages need complex mapping components. Often some kind of configurable, XML-driven mapping from customer messages to our ever-changing internal structures.
Python allows us to have the mappings as a simple Python class definition that we simply tweak, test and put into production. There are no limitations on this module -- it's first-class Python code.
We have to do extensive, long-running proof-of-concept. These involve numerous "what-if" scenarios with different data feeds and customized features.
Static languages require a lot of careful planning and thinking to create yet another demo, yet another mapping from yet another customer-supplied file to the current version of our actuarial models.
Python requires much less planning. Duck typing (and Django) let us knock out a demo without very much pain. The data mappings are simple python class definitions; our actuarial models are in a fairly constant state of flux.
Our business model is subject to a certain amount of negotiation. We have rather complex contracts with information providers; these don't change as often as the actuarial model, but changes here require customization.
Static languages bind in assumptions about the contracts, and require fairly complex designs (or workarounds) to handle the brain-farts of the business folks negotiating the deals.
In Python, we use an extensive test suite and do a lot of refactoring as the various contract terms and conditions trickle down to us.
Every week we get a question like "Can we handle a provision like X?" Our standard answer is "Absolutely." Followed by an hour of refactoring to be sure we could handle it if the deal was struck in that form.
We're mostly a RESTful web service. Django does a lot of this out of the box. We had to write some extensions because our security model is a bit more strict than the one provided by Django.
Static languages don't have to ship source. Don't like the security model? Pay the vendor $$$.
Dynamic languages must ship as source. In our case, we spend time reading the source of Django carefully to make sure that our security model fits cleanly with the rest of Django. We don't need HIPAA compliance, but we're building it in anyway.
We use web services from information providers. urllib2 does this for us nicely. We can prototype an interface rapidly.
With a static language, you have API's, you write, you run, and you hope it worked. The development cycle is Edit, Compile, Build, Run, Crash, Look at Logs; and this is just to spike the interface and be sure we have the protocol, credentials and configuration right.
We exercise the interface in interactive Python. Since we're executing it interactively, we can examine the responses immediately. The development cycle is reduced to Run, Edit. We can spike a web services API in an afternoon. | 0 | 1,839 | true | 0 | 1 | Python Programming - Rules/Advice for developing enterprise-level software in Python? | 672,975 |
2 | 4 | 0 | 1 | 1 | 1 | 0.049958 | 0 | I want to enable a user on a website to upload an image, and write some text over it. Also, they should be able to crop/scale/move the image and text. For that stuff, I can do it in jQuery.
After they've made the image the way they want it, is there a way i can take a screenshot of that image (using PiL) and save it on the server?
What is the best/proper way to do this? | 0 | jquery,python,css,xhtml,python-imaging-library | 2009-03-23T15:00:00.000 | 0 | 673,725 | I assume you got Python on the server side.
The best way imo is to somehow 'get' all the editing parameters from the client, then re-render it using PIL.
Update: How I will do it
On the server side, you need an url to handle posts.
On the client side, (after each edit, )send a post to that url, with the editing parameters.
I think there is not an easy solution to this.
Maybe if you don't use PIL to render the final image, but only remember the parameters, each view from clients can render itself? | 0 | 1,584 | false | 1 | 1 | Using PiL to take a screenshot of HTML/CSS | 673,958 |
2 | 4 | 0 | 0 | 1 | 1 | 0 | 0 | I want to enable a user on a website to upload an image, and write some text over it. Also, they should be able to crop/scale/move the image and text. For that stuff, I can do it in jQuery.
After they've made the image the way they want it, is there a way i can take a screenshot of that image (using PiL) and save it on the server?
What is the best/proper way to do this? | 0 | jquery,python,css,xhtml,python-imaging-library | 2009-03-23T15:00:00.000 | 0 | 673,725 | Well, even if others are trying to discourage you from doing this, it would probably not be that hard.
On the client-side, you, you define a div that is floated/resizable over the image, with transparency, that can be scaled for the crop.
Move, I assume it applies only to the text, so you dynamically create draggable spans on the client side, still easy.
Scale, I have no Idea of a simple UI to do it.
When you want to update your Image, you serialize your data (position of your cropping div and position of your text spans / scaling, relative to the position to the image.) Then, using json or anything similar you'd like, you transfer the data to the server.
Then, on the server, using python/PIL, you reproduce the transformations that you have serialized. | 0 | 1,584 | false | 1 | 1 | Using PiL to take a screenshot of HTML/CSS | 674,283 |
2 | 2 | 0 | 5 | 4 | 1 | 1.2 | 0 | I'm trying to use gstreamer 0.10 from Python to simultaneously display a v4l2 video source and record it to xvid-in-avi. Over a long period of time the computer would be fast enough to do this but if another program uses the disk it drops frames. That's bad enough, but on playback there are bursts of movement in the video where frames were dropped instead of displaying the frames we were able to encode at a lower framerate.
The pipeline is v4l2src ! capsfilter ! tee ! queue ! xvidenc ! avimux ! filesink and the tee also sinks to a queue ! xvimagesink sync=false. I've tried adding videorate in front of xvidenc but that seems to make things worse.
I've considered spooling the uncompressed video to disk in this pipeline and encoding it in a background thread. What else could I do to solve this problem? Is xvidenc or avimux doing the wrong thing with dropped frames? Could I dramatically increase the size of the queue preceding my encoder? | 0 | python,linux,gstreamer | 2009-03-24T14:28:00.000 | 0 | 677,641 | tee will block if either output blocks, so it's probably your bottleneck. I suggest to write the stream that takes longer to encode to disk and encode from there. | 0 | 3,103 | true | 0 | 1 | How can I record live video with gstreamer without dropping frames? | 677,681 |
2 | 2 | 0 | 2 | 4 | 1 | 0.197375 | 0 | I'm trying to use gstreamer 0.10 from Python to simultaneously display a v4l2 video source and record it to xvid-in-avi. Over a long period of time the computer would be fast enough to do this but if another program uses the disk it drops frames. That's bad enough, but on playback there are bursts of movement in the video where frames were dropped instead of displaying the frames we were able to encode at a lower framerate.
The pipeline is v4l2src ! capsfilter ! tee ! queue ! xvidenc ! avimux ! filesink and the tee also sinks to a queue ! xvimagesink sync=false. I've tried adding videorate in front of xvidenc but that seems to make things worse.
I've considered spooling the uncompressed video to disk in this pipeline and encoding it in a background thread. What else could I do to solve this problem? Is xvidenc or avimux doing the wrong thing with dropped frames? Could I dramatically increase the size of the queue preceding my encoder? | 0 | python,linux,gstreamer | 2009-03-24T14:28:00.000 | 0 | 677,641 | and you need to write xvimagesink, not xvimagesync | 0 | 3,103 | false | 0 | 1 | How can I record live video with gstreamer without dropping frames? | 2,237,878 |
2 | 4 | 0 | 1 | 3 | 1 | 0.049958 | 0 | Are there any alternatives to Python for .NET or IronPython for accessing .NET CLR? Both of these seem to have downsides in that Python for .NET is not under active development (as far as I can tell) and you lose some features available in CPython if you use IronPython. So are there any alternatives? | 0 | .net,python,clr,ironpython | 2009-03-25T14:33:00.000 | 0 | 681,853 | As far as I know you are not going to get anything more actively developed than IronPython .
IronPython is currently one of the .NET 5 being developed by the language team (C#, VB.NET, F#, IronPython and IronRuby) so I doubt that there's another open source .NET Python project that's gone anywhere near as far. | 0 | 3,386 | false | 0 | 1 | Any alternatives to IronPython, Python for .NET for accessing CLR from python? | 681,875 |
2 | 4 | 0 | 4 | 3 | 1 | 0.197375 | 0 | Are there any alternatives to Python for .NET or IronPython for accessing .NET CLR? Both of these seem to have downsides in that Python for .NET is not under active development (as far as I can tell) and you lose some features available in CPython if you use IronPython. So are there any alternatives? | 0 | .net,python,clr,ironpython | 2009-03-25T14:33:00.000 | 0 | 681,853 | Apart from Python for .NET (which works pretty well for me), the only other solution I'm aware of is exposing the .NET libraries via COM interop, so you can use them via the pywin32 extensions.
(I don't know much about .NET com interop yet, so hopefully someone else can provide further explanation on that.) | 0 | 3,386 | false | 0 | 1 | Any alternatives to IronPython, Python for .NET for accessing CLR from python? | 682,313 |
2 | 10 | 0 | 2 | 74 | 1 | 0.039979 | 0 | I've mainly been doing C# development for the past few years but recently started to do a bit of Python (not Iron Python). But I'm not sure if I've made the mental leap to Python...I kind of feel I'm trying to do things as I would in C#.
Any advice on how I can fully take advantage of Python?
Or any tips\tricks, things to learn more about, things to watch out for? | 0 | c#,python | 2009-03-25T20:18:00.000 | 0 | 683,273 | I'm pretty much in your shoes too, still using C# for most of my work, but using Python more and more for other projects.
@e-satis probably knows Python inside-out and all his advice is top-notch. From my point of view what made the biggest difference to me was the following:
Get back into functional. not necessarily spaghetti code, but learning that not everything has to be in an object, nor should it be.
The interpreter. It's like the immediate window except 10^10 better. Because of how Python works you don't need all the baggage and crap C# makes you put in before you can run things; you can just whack in a few lines and see how things work.
I've normally got an IDLE instance up where I just throw around snippets as I'm working out how the various bits in the language works while I'm editing my files... e.g. busy working out how to do a map call on a list, but I'm not 100% on the lambda I should use... whack in a few lines into IDLE, see how it works and what it does.
And finally, loving into the verbosity of Python, and I don't mean that in the long winded meaning of verbosity, but as e-satis pointed out, using verbs like "in", "is", "for", etc.
If you did a lot of reflection work in C# you'll feel like crying when you see how simple the same stuff is in Python.
Good luck with it. | 0 | 12,232 | false | 0 | 1 | Advice for C# programmer writing Python | 687,099 |
2 | 10 | 0 | 16 | 74 | 1 | 1 | 0 | I've mainly been doing C# development for the past few years but recently started to do a bit of Python (not Iron Python). But I'm not sure if I've made the mental leap to Python...I kind of feel I'm trying to do things as I would in C#.
Any advice on how I can fully take advantage of Python?
Or any tips\tricks, things to learn more about, things to watch out for? | 0 | c#,python | 2009-03-25T20:18:00.000 | 0 | 683,273 | Refrain from using classes. Use dictionaries, sets, list and tuples.
Setters and getters are forbidden.
Don't have exception handlers unless you really need to - let it crash in style.
Pylint can be your friend for more pythonish coding style.
When you're ready - check out list comprehensions, generators and lambda functions. | 0 | 12,232 | false | 0 | 1 | Advice for C# programmer writing Python | 683,362 |
2 | 3 | 0 | 0 | 5 | 1 | 0 | 0 | I'm programming a game in Python, where all IO activities are done by an IO object (in the hope that it will be easy to swap that object out for another which implements a different user interface). Nearly all the other objects in the game need to access the IO system at some point (e.g. printing a message, updating the position of the player, showing a special effect caused by an in-game action), so my question is this:
Does it make sense for a reference to the IO object to be available globally?
The alternative is passing a reference to the IO object into the __init__() of every object that needs to use it. I understand that this is good from a testing point of view, but is this worth the resulting "function signature pollution"?
Thanks. | 0 | python,io,global-variables | 2009-03-26T21:52:00.000 | 0 | 687,703 | Nope.
Variables are too specific to be passed around in the global namespace. Hide them inside static functions/classes instead that can do magic things to them at run time (or call other ones entirely).
Consider what happens if the IO can periodically change state or if it needs to block for a while (like many sockets do).
Consider what happens if the same block of code is included multiple times. Does the variable instance get duplicated as well?
Consider what happens if you want to have a version 2 of the same variable. What if you want to change its interface? Do you have to modify all the code that references it?
Does it really make sense to infect all the code that uses the variable with knowledge of all the ways it can go bad? | 0 | 250 | false | 0 | 1 | Python game programming: is my IO object a legitimate candidate for being a global variable? | 687,855 |
2 | 3 | 0 | 1 | 5 | 1 | 0.066568 | 0 | I'm programming a game in Python, where all IO activities are done by an IO object (in the hope that it will be easy to swap that object out for another which implements a different user interface). Nearly all the other objects in the game need to access the IO system at some point (e.g. printing a message, updating the position of the player, showing a special effect caused by an in-game action), so my question is this:
Does it make sense for a reference to the IO object to be available globally?
The alternative is passing a reference to the IO object into the __init__() of every object that needs to use it. I understand that this is good from a testing point of view, but is this worth the resulting "function signature pollution"?
Thanks. | 0 | python,io,global-variables | 2009-03-26T21:52:00.000 | 0 | 687,703 | Yes, I think so.
Another possibility would be to create a module loggerModule that has functions like print() and write(), but this would only marginally be better. | 0 | 250 | false | 0 | 1 | Python game programming: is my IO object a legitimate candidate for being a global variable? | 687,782 |
2 | 4 | 0 | 17 | 7 | 1 | 1.2 | 0 | How to make sure that code is still working after refactoring ( i.e, after variable name change)?
In static language, if a class is renamed but other referring class is not, then I will get a compilation error.
But in dynamic language there is no such safety net, and your code can break during refactoring if you are not careful enough. You can use unit test, but when you are using mocks it's pretty hard to know the name changes and as a consequence, it may not help.
How to solve this problem? | 0 | php,python,dynamic-languages | 2009-03-27T06:36:00.000 | 0 | 688,740 | Before you start refactoring you should create tests that will be able to test what you're going to change - if you say unit tests will not be enought, or they will be hard to create, then by all means create higher level tests possibly even excersising the whole of your product.
If you have code coverage tools for your language use them to measure the quality of the tests that you've created - after it's reached a reasonably high value and if the tests are kept up to date and extended you'll be able to do anything with your code very efficiently and be rather sure things are not going in the wrong direction. | 0 | 403 | true | 0 | 1 | How to Make sure the code is still working after refactoring ( Dynamic language) | 688,756 |
2 | 4 | 0 | 0 | 7 | 1 | 0 | 0 | How to make sure that code is still working after refactoring ( i.e, after variable name change)?
In static language, if a class is renamed but other referring class is not, then I will get a compilation error.
But in dynamic language there is no such safety net, and your code can break during refactoring if you are not careful enough. You can use unit test, but when you are using mocks it's pretty hard to know the name changes and as a consequence, it may not help.
How to solve this problem? | 0 | php,python,dynamic-languages | 2009-03-27T06:36:00.000 | 0 | 688,740 | 1) For Python use PyUnit for PHP phpunit.
2) TDD approach is good but also making tests after writing code is acceptable.
3) Also use refactoring tools that are available for Your IDE they do only safe refactorings.
In Python You have rope (this is library but have plugins for most IDEs).
4) Good books are:
'Test-Driven Development by example' Best
'Expert Python Programing' Tarek Ziade (explain both TDD and refactoring)
google tdd and database to find a good book about TDD approach for developing databases.
Add info for mocks you are using. AFAIK mocks are needed only when database or network is involved. But normally unit test should cover small pice of code (one class only) sometimes two classes so no mockup needed !! | 0 | 403 | false | 0 | 1 | How to Make sure the code is still working after refactoring ( Dynamic language) | 1,813,232 |
1 | 2 | 0 | 1 | 3 | 1 | 0.099668 | 0 | I'm on Fedora Core 6 (64 bit)
after "yum install libjpeg-devel" I have downloaded and built PIL. It gives the message:
--- JPEG support ok
Looks like JPEG built okay, but when running selftest.py:
IOError: decoder jpeg not available
Why would it appear to have built correctly, but fail the selftest? | 0 | python,jpeg,python-imaging-library,fedora,libjpeg | 2009-03-27T12:19:00.000 | 0 | 689,560 | Turns out this gets solved by completely removing the installed versions of PIL and starting the build again from scratch. | 0 | 2,349 | false | 0 | 1 | Building Python PIL for JPEG looks okay, but fails the selftest | 689,629 |
4 | 4 | 0 | 3 | 0 | 0 | 0.148885 | 1 | I have been asked to quote a project where they want to see sent email using POP. I am pretty sure this is not possible, but I thought if it was.
So is it possible given a users POP email server details to access their sent mail?
If so any examples in Python or fetchmail? | 0 | python,email,pop3,fetchmail | 2009-03-27T16:45:00.000 | 0 | 690,527 | Pop doesn't support sent email. Pop is an inbox only, Sent mail will be stored in IMAP, Exchange or other proprietary system. | 0 | 3,820 | false | 0 | 1 | Is it possible to Access a Users Sent Email over POP? | 690,536 |
4 | 4 | 0 | 1 | 0 | 0 | 0.049958 | 1 | I have been asked to quote a project where they want to see sent email using POP. I am pretty sure this is not possible, but I thought if it was.
So is it possible given a users POP email server details to access their sent mail?
If so any examples in Python or fetchmail? | 0 | python,email,pop3,fetchmail | 2009-03-27T16:45:00.000 | 0 | 690,527 | The smtp (mail sending) server could forward a copy of all sent mail back to the sender, they could then access this over pop. | 0 | 3,820 | false | 0 | 1 | Is it possible to Access a Users Sent Email over POP? | 690,541 |
4 | 4 | 0 | 5 | 0 | 0 | 1.2 | 1 | I have been asked to quote a project where they want to see sent email using POP. I am pretty sure this is not possible, but I thought if it was.
So is it possible given a users POP email server details to access their sent mail?
If so any examples in Python or fetchmail? | 0 | python,email,pop3,fetchmail | 2009-03-27T16:45:00.000 | 0 | 690,527 | POP3 only handles receiving email; sent mail is sent via SMTP in these situations, and may be sent via a different ISP to the receiver (say, when you host your own email server, but use your current ISP to send). As such, this isn't directly possible.
IMAP could do it, as this offers server side email folders as well as having the server handle the interface to both send and receive SMTP traffic | 0 | 3,820 | true | 0 | 1 | Is it possible to Access a Users Sent Email over POP? | 690,542 |
4 | 4 | 0 | 1 | 0 | 0 | 0.049958 | 1 | I have been asked to quote a project where they want to see sent email using POP. I am pretty sure this is not possible, but I thought if it was.
So is it possible given a users POP email server details to access their sent mail?
If so any examples in Python or fetchmail? | 0 | python,email,pop3,fetchmail | 2009-03-27T16:45:00.000 | 0 | 690,527 | Emails are not sent using POP, but collected from a server using POP. They are sent using SMTP, and they don't hang around on the server once they're gone.
You might want to look into IMAP? | 0 | 3,820 | false | 0 | 1 | Is it possible to Access a Users Sent Email over POP? | 690,540 |
3 | 3 | 0 | 4 | 8 | 0 | 0.26052 | 0 | I'm going to build a turn-key solution for a vertical market, and would like to offer both options: software as a service, and give them the opportunity to host the application on their own. In other words, I'm aiming to have similar deployment options as Joel's FogBugz.
I'm a Python programmer, and I could fly over the project with Django. There are several reasons I prefer PHP though:
1) Django installation, and configuration assumes you have access to a shell (my target is not the programmer type). Although I could offer installation service, but not on their servers.
2) Django runs only on some specific hosts that must take special care to enable it. Installing mod_python/mod_wsgi, and most likely the minority of my potential clients would have root access, or even a cpanel.
3) Using PHP would mean I could run it on their existing server. I would have no need to move them to a Django-enabled server, and no downtime for their emails, while the DNS updates.
On the other hand, I have very little experience with PHP. Smarty as a templating language looks nice, and works similarly to Django templates. It doesn't offer template inheritance though, except in a very hackish way in which I wish not to use as it could break the application if the designer messes them up. What do you think? Thanks in advance! | 0 | php,python,django,codeigniter | 2009-03-27T18:05:00.000 | 0 | 690,856 | Deployment is clearly a problem for all non-PHP based web apps, but I think things are getting better with the DreamHost/Engineyard type ISP's who provide Ruby/Python etc. out of the box. It also looks like there's going to be a lot of discussion at PyCon this week about ways to fix deployment problems. The growth in popularity of Django, Turbogears, and Pylons is driving demand for better deployment solutions.
That said, if your target market are people hosting on the very low end $12 a year type ISP's then I don't think you have much choice other than PHP.
Finally, one thing I disagree with you is running PHP and Django on the same server. I'm running a few PHP apps on my server with Apache and dozens of Django sites with mod_wsgi in daemon mode. Running it that way means the Python interpreter doesn't use up ram in the Apache workers and vice versa, the PHP interpreter isn't contaminating my mod_wsgi daemons :) | 0 | 6,522 | false | 1 | 1 | Django or CodeIgniter for Turn-Key Web Application | 691,231 |
3 | 3 | 0 | 3 | 8 | 0 | 0.197375 | 0 | I'm going to build a turn-key solution for a vertical market, and would like to offer both options: software as a service, and give them the opportunity to host the application on their own. In other words, I'm aiming to have similar deployment options as Joel's FogBugz.
I'm a Python programmer, and I could fly over the project with Django. There are several reasons I prefer PHP though:
1) Django installation, and configuration assumes you have access to a shell (my target is not the programmer type). Although I could offer installation service, but not on their servers.
2) Django runs only on some specific hosts that must take special care to enable it. Installing mod_python/mod_wsgi, and most likely the minority of my potential clients would have root access, or even a cpanel.
3) Using PHP would mean I could run it on their existing server. I would have no need to move them to a Django-enabled server, and no downtime for their emails, while the DNS updates.
On the other hand, I have very little experience with PHP. Smarty as a templating language looks nice, and works similarly to Django templates. It doesn't offer template inheritance though, except in a very hackish way in which I wish not to use as it could break the application if the designer messes them up. What do you think? Thanks in advance! | 0 | php,python,django,codeigniter | 2009-03-27T18:05:00.000 | 0 | 690,856 | If you want your application to be mainstream then your almost forced to go with PHP. Going from Django to PHP is alot easier than going from PHP to Django. You know the standards, you just need to learn the PHP syntax and functions.
I would definitely use a PHP framework. Symfony and akelos are very similar to Rails (close to Django). On the other than theres Code Igniter which does what it should - organise your code. | 0 | 6,522 | false | 1 | 1 | Django or CodeIgniter for Turn-Key Web Application | 691,549 |
3 | 3 | 0 | 2 | 8 | 0 | 0.132549 | 0 | I'm going to build a turn-key solution for a vertical market, and would like to offer both options: software as a service, and give them the opportunity to host the application on their own. In other words, I'm aiming to have similar deployment options as Joel's FogBugz.
I'm a Python programmer, and I could fly over the project with Django. There are several reasons I prefer PHP though:
1) Django installation, and configuration assumes you have access to a shell (my target is not the programmer type). Although I could offer installation service, but not on their servers.
2) Django runs only on some specific hosts that must take special care to enable it. Installing mod_python/mod_wsgi, and most likely the minority of my potential clients would have root access, or even a cpanel.
3) Using PHP would mean I could run it on their existing server. I would have no need to move them to a Django-enabled server, and no downtime for their emails, while the DNS updates.
On the other hand, I have very little experience with PHP. Smarty as a templating language looks nice, and works similarly to Django templates. It doesn't offer template inheritance though, except in a very hackish way in which I wish not to use as it could break the application if the designer messes them up. What do you think? Thanks in advance! | 0 | php,python,django,codeigniter | 2009-03-27T18:05:00.000 | 0 | 690,856 | Based on your own conclusions, I would go with CodeIgniter. It seems like there would be a ton of work helping your customers install your web app, and I assume you don't want that.
Build a simple-to-install web app so that you can concentrate your efforts on making it better and selling it, instead of working extra as a sysadmin or writing extensive installation tutorials.
(With that said, FogBugz wasn't easy to install on our Linux server, even though it is written in PHP. It took me and my colleague (both programmers!) more than a full work day to install. So I think there will always be problems with installation of self-hosted web apps.) | 0 | 6,522 | false | 1 | 1 | Django or CodeIgniter for Turn-Key Web Application | 692,907 |
2 | 5 | 0 | 0 | 5 | 1 | 0 | 0 | Lets say I have projects x and y in brother directories: projects/x and projects/y.
There are some utility funcs common to both projects in myutils.py and some db stuff in mydbstuff.py, etc.
Those are minor common goodies, so I don't want to create a single package for them.
Questions arise about the whereabouts of such files, possible changes to PYTHONPATH, proper way to import, etc.
What is the 'pythonic way' to use such files? | 0 | python | 2009-03-30T11:12:00.000 | 0 | 696,792 | I agree with 'create a package'.
If you cannot do that, how about using symbolic links/junctions (ln -s on Linux, linkd on Windows)? | 0 | 426 | false | 0 | 1 | What is the pythonic way to share common files in multiple projects? | 697,052 |
2 | 5 | 0 | 9 | 5 | 1 | 1.2 | 0 | Lets say I have projects x and y in brother directories: projects/x and projects/y.
There are some utility funcs common to both projects in myutils.py and some db stuff in mydbstuff.py, etc.
Those are minor common goodies, so I don't want to create a single package for them.
Questions arise about the whereabouts of such files, possible changes to PYTHONPATH, proper way to import, etc.
What is the 'pythonic way' to use such files? | 0 | python | 2009-03-30T11:12:00.000 | 0 | 696,792 | The pythonic way is to create a single extra package for them.
Why don't you want to create a package? You can distribute this package with both projects, and the effect would be the same.
You'll never do it right for all instalation scenarios and platforms if you do it by mangling with PYTHONPATH and custom imports.
Just create another package and be done in no time. | 0 | 426 | true | 0 | 1 | What is the pythonic way to share common files in multiple projects? | 696,825 |
1 | 3 | 0 | 5 | 121 | 0 | 0.321513 | 0 | Given a class C in Python, how can I determine which file the class was defined in? I need something that can work from either the class C, or from an instance off C.
The reason I am doing this, is because I am generally a fan off putting files that belong together in the same folder. I want to create a class that uses a Django template to render itself as HTML. The base implementation should infer the filename for the template based on the filename that the class is defined in.
Say I put a class LocationArtifact in the file "base/artifacts.py", then I want the default behaviour to be that the template name is "base/LocationArtifact.html". | 0 | python,class,introspection | 2009-03-30T13:58:00.000 | 0 | 697,320 | This is the wrong approach for Django and really forcing things.
The typical Django app pattern is:
/project
/appname
models.py
views.py
/templates
index.html
etc. | 0 | 56,627 | false | 1 | 1 | How do I get the filepath for a class in Python? | 697,405 |
1 | 1 | 0 | 1 | 3 | 0 | 0.197375 | 0 | Has anyone ever tried that? | 0 | java,python,reporting,birt | 2009-03-30T15:05:00.000 | 0 | 697,594 | What kind of integration are you talking about?
If you want to call some BIRT API the I gues it could be done from Jython as Jython can call any Java API.
If you don't need to call the BIRT API then you can just get the birt reports with http requests from the BIRT report server (a tomcat application). | 0 | 4,155 | false | 0 | 1 | How to integrate BIRT with Python | 716,222 |
1 | 2 | 1 | 0 | 9 | 0 | 0 | 0 | I hit this issue about two years ago when I first implemented our SWIG bindings. As soon as we exposed a large amount of code we got to the point where SWIG would output C++ files so large the compiler could not handle them. The only way I could get around the issue was to split up the interfaces into multiple modules and to compile them separately.
This has several downsides:
• Each module must know about dependencies in other modules. I have a script to generate the interface files which handles this side of things, but it adds extra complexity.
• Each additional module increases the time that the dynamic linker requires to load in the code. I have added an init.py file that imports all the submodules, so that the fact that the code is split up is transparent to the user, but what is always visible is the long load times.
I'm currently reviewing our build scripts / build process and I wanted to see if I could find a solution to this issue that was better than what I have now. Ideally, I'd have one shared library containing all the wrapper code.
Does anyone know how I can acheive this with SWIG? I've seen some custom code written in Ruby for a specific project, where the output is post-processed to make this possible, but when I looked at the feasibility for Python wrappers it does not look so easy. | 0 | c++,python,swig | 2009-03-30T15:40:00.000 | 0 | 697,749 | If split properly, the modules don't necessarily need to have the same dependencies as the others - just what's necessary to do compilation. If you break things up appropriately, you can have libraries without cyclic dependencies. The issue with using multiple libraries is that by default, SWIG declares its runtime code statically, and as a result, as problems passing objects from one module to another. You need to enable a shared version of the SWIG runtime code.
From the documentation (SWIG web page documentation link is broken):
The runtime functions are private to
each SWIG-generated module. That is,
the runtime functions are declared
with "static" linkage and are visible
only to the wrapper functions defined
in that module. The only problem with
this approach is that when more than
one SWIG module is used in the same
application, those modules often need
to share type information. This is
especially true for C++ programs where
SWIG must collect and share
information about inheritance
relationships that cross module
boundaries.
Check out that section in your downloaded documentation (section 16.2 The SWIG runtime code), and it'll give you details on how to enable this so that objects can be properly handled when passed from one module to the other.
FWIW, I've not worked with Python SWIG, but have done Tcl SWIG. | 0 | 2,117 | false | 0 | 1 | Is it possible to split a SWIG module for compilation, but rejoin it when linking? | 698,089 |
3 | 9 | 0 | 10 | 9 | 0 | 1.2 | 0 | I know it's kinda subjective but, if you were to put yourself in my shoes which would you invest the time in learning?
I want to write a web app which deals securely with relatively modest amounts of peoples private data, a few thousand records of a few Kb each but stuff that needs to be kept safe, addresses, phone numbers etc. I've done several web projects in PHP/MYSQL and have decided, handy though it is I really don't like PHP and don't want to do another large project in it...
As such I figure I'd best learn something new and so I am considering 2 options (although I'll happily entertain others if you have suggestions). I'm having terrible trouble deciding though. They both look quite involved so rather than just jump in and potentially waste days getting up to speed enough on both of them to make an informed choice I thought I'd come here and canvas some opinion.
So the two options I'm considering are...
One of the PYTHON Web frameworks - TurboGears seems well regarded?
Advantage: Of all the languages I ever tried Python is by far and away my favorite. There's loads of frameworks to choose from and I have done quite a lot of non web python coding over the last few years.
Disadvantage: There's loads to choose from so it's hard to pick! Need to run single server process? or mod_python? which I don't like the sound of. What I do like is the notion of process separation and compartmentalization, i.e. if one users account is compromised it gives an attacker no leverage against the rest of the system. I'm not clear to what extent a python solution would handle that.
Writing it as a SEASIDE app Which I guess runs on a squeak app server?
Adv: From what I've heard it would permit good compartmentalization of users as each would have their own little private VM independent of all the systems other users which sounds wonderful from a security, scaling and redundancy standpoint.
Dis: I've not done any Smalltalk since Uni 15 years back and I never dug too deep into it then. I don't see much entry level help for seaside or that many projects using it. I suspect setting a server up to run it is hard for the same reason i.e. not because it's inherently hard but just cause there will be less help online and a presumption you are already rather au fait with Sqeak/Smalltalk.
So, what do people think? Would I be able to efficiently get the kind of strong separation and compartmentalization I'm after with a Python framework? Is Seaside as good as I think in terms of insulating users from each other? Might I be better off, security wise, sticking to the languages I'm most familiar with so I don't make any n00b mistakes or will Seaside be worth worth scaling the learning curve and prove more secure, comprehensible and maintainable in the long run? At the end of the day it's not a life or death decision and I can always bail if I start with one and then hate it so pls nobody get all holy language war and start flaming anyone! ;-)
Cheers for any replies this gets,
Roger :) | 0 | python,frameworks,seaside | 2009-03-30T16:11:00.000 | 0 | 697,866 | Disclaimer: I really don't like PHP, Python is nice, but doesn't come close to Smalltalk in my book. But I am a biased Smalltalker. Some answers about Seaside/Squeak:
Q: Which I guess runs on a squeak app server?
Seaside runs in several different Smalltalks (VW, Gemstone, Squeak etc). The term "app server" is not really used in Smalltalk country. :)
Q: From what I've heard it would permit good compartmentalization of users as each would have their own little private VM independent of all the systems other users which sounds wonderful from a security, scaling and redundancy standpoint.
Yes, each user has its own WASession and all UI components the user sees are instances living on the server side in that session. So sharing of state between sessions is something you must do explicitly, typically through a db.
Q: I've not done any Smalltalk since Uni 15 years back and I never dug too deep into it then. I don't see much entry level help for seaside or that many projects using it.
Smalltalk is easy to get going with and there is a whole free online book on Seaside.
Q: I suspect setting a server up to run it is hard for the same reason i.e. not because it's inherently hard but just cause there will be less help online and a presumption you are already rather au fait with Sqeak/Smalltalk.
No, not hard. :) In fact, quite trivial. Tons of help - Seaside ml, IRC on freenode, etc.
Q: Is Seaside as good as I think in terms of insulating users from each other?
I would say so.
Q: Might I be better off, security wise, sticking to the languages I'm most familiar with so I don't make any n00b mistakes or will Seaside be worth worth scaling the learning curve and prove more secure, comprehensible and maintainable in the long run?
The killer argument in favor of Seaside IMHO is the true component model. It really, really makes it wonderful for complex UIs and maintenance. If you are afraid of learning "something different" (but then you wouldn't even consider it in the first place I guess) then I would warn you. But if you are not afraid then you will probably love it.
Also - Squeak (or VW) is a truly awesome development environment - debugging live Seaside sessions, changing code in the debugger and resuming etc etc. It rocks. | 0 | 2,399 | true | 1 | 1 | Dilemma: Should I learn Seaside or a Python framework? | 698,677 |
3 | 9 | 0 | 6 | 9 | 0 | 1 | 0 | I know it's kinda subjective but, if you were to put yourself in my shoes which would you invest the time in learning?
I want to write a web app which deals securely with relatively modest amounts of peoples private data, a few thousand records of a few Kb each but stuff that needs to be kept safe, addresses, phone numbers etc. I've done several web projects in PHP/MYSQL and have decided, handy though it is I really don't like PHP and don't want to do another large project in it...
As such I figure I'd best learn something new and so I am considering 2 options (although I'll happily entertain others if you have suggestions). I'm having terrible trouble deciding though. They both look quite involved so rather than just jump in and potentially waste days getting up to speed enough on both of them to make an informed choice I thought I'd come here and canvas some opinion.
So the two options I'm considering are...
One of the PYTHON Web frameworks - TurboGears seems well regarded?
Advantage: Of all the languages I ever tried Python is by far and away my favorite. There's loads of frameworks to choose from and I have done quite a lot of non web python coding over the last few years.
Disadvantage: There's loads to choose from so it's hard to pick! Need to run single server process? or mod_python? which I don't like the sound of. What I do like is the notion of process separation and compartmentalization, i.e. if one users account is compromised it gives an attacker no leverage against the rest of the system. I'm not clear to what extent a python solution would handle that.
Writing it as a SEASIDE app Which I guess runs on a squeak app server?
Adv: From what I've heard it would permit good compartmentalization of users as each would have their own little private VM independent of all the systems other users which sounds wonderful from a security, scaling and redundancy standpoint.
Dis: I've not done any Smalltalk since Uni 15 years back and I never dug too deep into it then. I don't see much entry level help for seaside or that many projects using it. I suspect setting a server up to run it is hard for the same reason i.e. not because it's inherently hard but just cause there will be less help online and a presumption you are already rather au fait with Sqeak/Smalltalk.
So, what do people think? Would I be able to efficiently get the kind of strong separation and compartmentalization I'm after with a Python framework? Is Seaside as good as I think in terms of insulating users from each other? Might I be better off, security wise, sticking to the languages I'm most familiar with so I don't make any n00b mistakes or will Seaside be worth worth scaling the learning curve and prove more secure, comprehensible and maintainable in the long run? At the end of the day it's not a life or death decision and I can always bail if I start with one and then hate it so pls nobody get all holy language war and start flaming anyone! ;-)
Cheers for any replies this gets,
Roger :) | 0 | python,frameworks,seaside | 2009-03-30T16:11:00.000 | 0 | 697,866 | I've been getting into seaside myself but in many ways it is very hard to get started, which has nothing to do with the smalltalk which can be picked up extremely quickly. The challenge is that you are really protected from writing html directly.
I find in most frameworks when you get stuck on how to do something there is always a work around of solving it by using the template. You may later discover that this solution causes problems with clarity down the road and there is in fact a better solutions built into the framework but you were able to move on from that problem until you learned the right way to do it.
Seaside doesn't have templates so you don't get that crutch. No problems have permanently stumped me but some have taken me longer to solve than I would have liked. The flip side of this is you end up learning the seaside methodology much quicker because you can't cheat.
If you decide to go the seaside route don't be afraid to post to the seaside mailing list at squeakfoundation.org. I found it intimidating at first because you don't see a lot of beginner questions there due to the low traffic but people are willing to help beginners there.
Also there are a handful of seaside developers who monitor stackoverflow regularly. Good luck. | 0 | 2,399 | false | 1 | 1 | Dilemma: Should I learn Seaside or a Python framework? | 698,940 |
3 | 9 | 0 | 1 | 9 | 0 | 0.022219 | 0 | I know it's kinda subjective but, if you were to put yourself in my shoes which would you invest the time in learning?
I want to write a web app which deals securely with relatively modest amounts of peoples private data, a few thousand records of a few Kb each but stuff that needs to be kept safe, addresses, phone numbers etc. I've done several web projects in PHP/MYSQL and have decided, handy though it is I really don't like PHP and don't want to do another large project in it...
As such I figure I'd best learn something new and so I am considering 2 options (although I'll happily entertain others if you have suggestions). I'm having terrible trouble deciding though. They both look quite involved so rather than just jump in and potentially waste days getting up to speed enough on both of them to make an informed choice I thought I'd come here and canvas some opinion.
So the two options I'm considering are...
One of the PYTHON Web frameworks - TurboGears seems well regarded?
Advantage: Of all the languages I ever tried Python is by far and away my favorite. There's loads of frameworks to choose from and I have done quite a lot of non web python coding over the last few years.
Disadvantage: There's loads to choose from so it's hard to pick! Need to run single server process? or mod_python? which I don't like the sound of. What I do like is the notion of process separation and compartmentalization, i.e. if one users account is compromised it gives an attacker no leverage against the rest of the system. I'm not clear to what extent a python solution would handle that.
Writing it as a SEASIDE app Which I guess runs on a squeak app server?
Adv: From what I've heard it would permit good compartmentalization of users as each would have their own little private VM independent of all the systems other users which sounds wonderful from a security, scaling and redundancy standpoint.
Dis: I've not done any Smalltalk since Uni 15 years back and I never dug too deep into it then. I don't see much entry level help for seaside or that many projects using it. I suspect setting a server up to run it is hard for the same reason i.e. not because it's inherently hard but just cause there will be less help online and a presumption you are already rather au fait with Sqeak/Smalltalk.
So, what do people think? Would I be able to efficiently get the kind of strong separation and compartmentalization I'm after with a Python framework? Is Seaside as good as I think in terms of insulating users from each other? Might I be better off, security wise, sticking to the languages I'm most familiar with so I don't make any n00b mistakes or will Seaside be worth worth scaling the learning curve and prove more secure, comprehensible and maintainable in the long run? At the end of the day it's not a life or death decision and I can always bail if I start with one and then hate it so pls nobody get all holy language war and start flaming anyone! ;-)
Cheers for any replies this gets,
Roger :) | 0 | python,frameworks,seaside | 2009-03-30T16:11:00.000 | 0 | 697,866 | I think you've pretty much summed up the pros and cons. Seaside isn't that hard to set up (I've installed it twice for various projects) but using it will definitely affect how you work--in addition to re-learning the language you'll probably have to adjust lots of assumptions about your work flow.
It also depends on two other factors
If other people will eventually be maintaining it, you'll have better luck finding python programmers
If you are doing a highly stateful site, Seaside is going to beat the pants off any other framework I've seen. | 0 | 2,399 | false | 1 | 1 | Dilemma: Should I learn Seaside or a Python framework? | 697,934 |
1 | 9 | 0 | 12 | 45 | 0 | 1 | 0 | I have a binary named A that generates output when called. If I call it from a Bash shell, most of the output is suppressed by A > /dev/null. All of the output is suppressed by A &> /dev/null
I have a python script named B that needs to call A. I want to be able to generate output from B, while suppressing all the output from A.
From within B, I've tried os.system('A'), os.system('A > /dev/null'), and os.system('A &> /dev/null'), os.execvp('...'), etc. but none of those suppress all the output from A.
I could run B &> /dev/null, but that suppresses all of B's output too and I don't want that.
Anyone have suggestions? | 0 | python,redirect | 2009-03-30T22:39:00.000 | 1 | 699,325 | If your search engine lead you to this old question (like me), be aware that using PIPE may lead to deadlocks.
Indeed, because pipes are buffered, you can write a certain number of bytes in a pipe, even if no one read it. However the size of buffer is finite. And consequently if your program A has an output larger than the buffer, A will be blocked on writing, while the calling program B awaits the termination of A. But not, in this particular case... see comments below.
Still, I recommend using Devin Jeanpierre and DNS' solution. | 0 | 42,935 | false | 0 | 1 | Suppress output in Python calls to executables | 2,728,111 |
1 | 4 | 0 | 0 | 6 | 0 | 0 | 0 | I have binary files no larger than 20Mb in size that have a header section and then a data section containing sequences of uchars. I have Numpy, SciPy, etc. and each library has different ways of loading in the data. Any suggestions for the most efficient methods I should use? | 0 | python,input,binaryfiles | 2009-03-31T22:03:00.000 | 0 | 703,262 | I found that array.fromfile is the fastest methods for homogeneous data. | 1 | 450 | false | 0 | 1 | Most efficient way of loading formatted binary files in Python | 703,588 |
1 | 7 | 0 | 1 | 45 | 1 | 0.028564 | 0 | I'm using the json module in Python 2.6 to load and decode JSON files. However I'm currently getting slower than expected performance. I'm using a test case which is 6MB in size and json.loads() is taking 20 seconds.
I thought the json module had some native code to speed up the decoding?
How do I check if this is being used?
As a comparison, I downloaded and installed the python-cjson module, and cjson.decode() is taking 1 second for the same test case.
I'd rather use the JSON module provided with Python 2.6 so that users of my code aren't required to install additional modules.
(I'm developing on Mac OS X, but I getting a similar result on Windows XP.) | 0 | python,json,python-2.6 | 2009-04-01T15:39:00.000 | 0 | 706,101 | Even though _json is available, I've noticed json decoding is very slow on CPython 2.6.6. I haven't compared with other implementations, but I've switched to string manipulation when inside performance-critical loops. | 0 | 37,359 | false | 0 | 1 | Python 2.6 JSON decoding performance | 5,541,345 |
6 | 21 | 0 | 43 | 535 | 1 | 1 | 0 | I've tried to find a comprehensive guide on whether it is best to use import module or from module import. I've just started with Python and I'm trying to start off with best practices in mind.
Basically, I was hoping if anyone could share their experiences, what preferences other developers have and what's the best way to avoid any gotchas down the road? | 0 | python,python-import | 2009-04-02T16:40:00.000 | 0 | 710,551 | Both ways are supported for a reason: there are times when one is more appropriate than the other.
import module: nice when you are using many bits from the module. drawback is that you'll need to qualify each reference with the module name.
from module import ...: nice that imported items are usable directly without module name prefix. The drawback is that you must list each thing you use, and that it's not clear in code where something came from.
Which to use depends on which makes the code clear and readable, and has more than a little to do with personal preference. I lean toward import module generally because in the code it's very clear where an object or function came from. I use from module import ... when I'm using some object/function a lot in the code. | 0 | 216,208 | false | 0 | 1 | Use 'import module' or 'from module import'? | 710,598 |
6 | 21 | 0 | 4 | 535 | 1 | 0.038077 | 0 | I've tried to find a comprehensive guide on whether it is best to use import module or from module import. I've just started with Python and I'm trying to start off with best practices in mind.
Basically, I was hoping if anyone could share their experiences, what preferences other developers have and what's the best way to avoid any gotchas down the road? | 0 | python,python-import | 2009-04-02T16:40:00.000 | 0 | 710,551 | To add to what people have said about from x import *: besides making it more difficult to tell where names came from, this throws off code checkers like Pylint. They will report those names as undefined variables. | 0 | 216,208 | false | 0 | 1 | Use 'import module' or 'from module import'? | 710,831 |
6 | 21 | 0 | 0 | 535 | 1 | 0 | 0 | I've tried to find a comprehensive guide on whether it is best to use import module or from module import. I've just started with Python and I'm trying to start off with best practices in mind.
Basically, I was hoping if anyone could share their experiences, what preferences other developers have and what's the best way to avoid any gotchas down the road? | 0 | python,python-import | 2009-04-02T16:40:00.000 | 0 | 710,551 | Import Module - You don't need additional efforts to fetch another thing from module. It has disadvantages such as redundant typing
Module Import From - Less typing &More control over which items of a module can be accessed.To use a new item from the module you have to update your import statement. | 0 | 216,208 | false | 0 | 1 | Use 'import module' or 'from module import'? | 34,892,472 |
6 | 21 | 0 | 1 | 535 | 1 | 0.009524 | 0 | I've tried to find a comprehensive guide on whether it is best to use import module or from module import. I've just started with Python and I'm trying to start off with best practices in mind.
Basically, I was hoping if anyone could share their experiences, what preferences other developers have and what's the best way to avoid any gotchas down the road? | 0 | python,python-import | 2009-04-02T16:40:00.000 | 0 | 710,551 | since many people answered here but i am just trying my best :)
import module is best when you don't know which item you have to import from module. In this way it may be difficult to debug when problem raises because
you don't know which item have problem.
form module import <foo> is best when you know which item you require to import and also helpful in more controlling using importing specific item according to your need. Using this way debugging may be easy because you know which item you imported. | 0 | 216,208 | false | 0 | 1 | Use 'import module' or 'from module import'? | 62,796,069 |
6 | 21 | 0 | 3 | 535 | 1 | 0.028564 | 0 | I've tried to find a comprehensive guide on whether it is best to use import module or from module import. I've just started with Python and I'm trying to start off with best practices in mind.
Basically, I was hoping if anyone could share their experiences, what preferences other developers have and what's the best way to avoid any gotchas down the road? | 0 | python,python-import | 2009-04-02T16:40:00.000 | 0 | 710,551 | My own answer to this depends mostly on first, how many different modules I'll be using. If i'm only going to use one or two, I'll often use from ... import since it makes for fewer keystrokes in the rest of the file, but if I'm going to make use of many different modules, I prefer just import because that means that each module reference is self-documenting. I can see where each symbol comes from without having to hunt around.
Usuaully I prefer the self documenting style of plain import and only change to from.. import when the number of times I have to type the module name grows above 10 to 20, even if there's only one module being imported. | 0 | 216,208 | false | 0 | 1 | Use 'import module' or 'from module import'? | 710,861 |
6 | 21 | 0 | 575 | 535 | 1 | 1.2 | 0 | I've tried to find a comprehensive guide on whether it is best to use import module or from module import. I've just started with Python and I'm trying to start off with best practices in mind.
Basically, I was hoping if anyone could share their experiences, what preferences other developers have and what's the best way to avoid any gotchas down the road? | 0 | python,python-import | 2009-04-02T16:40:00.000 | 0 | 710,551 | The difference between import module and from module import foo is mainly subjective. Pick the one you like best and be consistent in your use of it. Here are some points to help you decide.
import module
Pros:
Less maintenance of your import statements. Don't need to add any additional imports to start using another item from the module
Cons:
Typing module.foo in your code can be tedious and redundant (tedium can be minimized by using import module as mo then typing mo.foo)
from module import foo
Pros:
Less typing to use foo
More control over which items of a module can be accessed
Cons:
To use a new item from the module you have to update your import statement
You lose context about foo. For example, it's less clear what ceil() does compared to math.ceil()
Either method is acceptable, but don't use from module import *.
For any reasonable large set of code, if you import * you will likely be cementing it into the module, unable to be removed. This is because it is difficult to determine what items used in the code are coming from 'module', making it easy to get to the point where you think you don't use the import any more but it's extremely difficult to be sure. | 0 | 216,208 | true | 0 | 1 | Use 'import module' or 'from module import'? | 710,603 |
2 | 7 | 0 | 8 | 136 | 1 | 1.2 | 0 | Many third-party Python modules have an attribute which holds the version information for the module (usually something like module.VERSION or module.__version__), however some do not.
Particular examples of such modules are libxslt and libxml2.
I need to check that the correct version of these modules are being used at runtime. Is there a way to do this?
A potential solution wold be to read in the source at runtime, hash it, and then compare it to the hash of the known version, but that's nasty.
Is there a better solutions? | 0 | python,module,version | 2009-04-02T16:53:00.000 | 0 | 710,609 | I'd stay away from hashing. The version of libxslt being used might contain some type of patch that doesn't effect your use of it.
As an alternative, I'd like to suggest that you don't check at run time (don't know if that's a hard requirement or not). For the python stuff I write that has external dependencies (3rd party libraries), I write a script that users can run to check their python install to see if the appropriate versions of modules are installed.
For the modules that don't have a defined 'version' attribute, you can inspect the interfaces it contains (classes and methods) and see if they match the interface they expect. Then in the actual code that you're working on, assume that the 3rd party modules have the interface you expect. | 0 | 83,866 | true | 0 | 1 | Checking a Python module version at runtime | 710,653 |
2 | 7 | 0 | 6 | 136 | 1 | 1 | 0 | Many third-party Python modules have an attribute which holds the version information for the module (usually something like module.VERSION or module.__version__), however some do not.
Particular examples of such modules are libxslt and libxml2.
I need to check that the correct version of these modules are being used at runtime. Is there a way to do this?
A potential solution wold be to read in the source at runtime, hash it, and then compare it to the hash of the known version, but that's nasty.
Is there a better solutions? | 0 | python,module,version | 2009-04-02T16:53:00.000 | 0 | 710,609 | Some ideas:
Try checking for functions that exist or don't exist in your needed versions.
If there are no function differences, inspect function arguments and signatures.
If you can't figure it out from function signatures, set up some stub calls at import time and check their behavior. | 0 | 83,866 | false | 0 | 1 | Checking a Python module version at runtime | 710,642 |
1 | 3 | 0 | 3 | 42 | 0 | 0.197375 | 0 | I use nosetests to run my unittests and it works well. I want to get a list of all the tests nostests finds without actually running them. Is there a way to do that? | 0 | python,unit-testing,nose,nosetests | 2009-04-02T23:27:00.000 | 0 | 712,020 | There will be soon: a new --collect switch that produces this behavior was demo'd at PyCon last week. It should be on the trunk "soon" and will be in the 0.11 release.
The http://groups.google.com/group/nose-users list is a great resource for nose questions. | 0 | 9,288 | false | 0 | 1 | List all Tests Found by Nosetest | 716,408 |
1 | 1 | 0 | 0 | 0 | 0 | 1.2 | 0 | There is cgi.escape but that appears to be implemented in pure python. It seems like most frameworks like Django also just run some regular expressions. This is something we do a lot, so it would be good to have it be as fast as possible.
Maybe C implementations wouldn't be much faster than a series of regexes for this? | 0 | python,escaping,python-module | 2009-04-03T00:14:00.000 | 0 | 712,113 | See lxml, which is based on libxml2. While it's primarily a XML library, HTML support is available. | 0 | 961 | true | 1 | 1 | Is there a good python module that does HTML encoding/escaping in C? | 712,154 |
2 | 7 | 0 | 0 | 1 | 0 | 0 | 1 | I have a web application and I would like to enable real time SMS notifications to the users of the applications.
Note: I currently cannot use the Twitter API because I live in West Africa, and Twitter doesn't send SMS to my country.
Also email2sms is not an option because the mobile operators don't allow that in my country. | 0 | python,sms,notifications | 2009-04-04T11:47:00.000 | 0 | 716,946 | I don't have any knowledge in this area. But I think you'll have to talk to the mobile operators, and see if they have any API for sending SMS messages.
You'll probably have to pay them, or have some scheme for customers to pay them. Alternatively there might be some 3rd party that implements this functionality. | 0 | 2,976 | false | 1 | 1 | How do I enable SMS notifications in my web apps? | 716,953 |
2 | 7 | 0 | 2 | 1 | 0 | 0.057081 | 1 | I have a web application and I would like to enable real time SMS notifications to the users of the applications.
Note: I currently cannot use the Twitter API because I live in West Africa, and Twitter doesn't send SMS to my country.
Also email2sms is not an option because the mobile operators don't allow that in my country. | 0 | python,sms,notifications | 2009-04-04T11:47:00.000 | 0 | 716,946 | The easiest way to accomplish this is by using a third party API. Some I know that work well are:
restSms.me
Twilio.com
Clicatell.com
I have used all of them and they easiest/cheapest one to implement was restSms.me
Hope that helps. | 0 | 2,976 | false | 1 | 1 | How do I enable SMS notifications in my web apps? | 5,414,483 |
1 | 3 | 0 | 8 | 5 | 1 | 1.2 | 0 | The authentication system for an application we're using right now uses a two-way hash that's basically little more than a glorified caesar cypher. Without going into too much detail about what's going on with it, I'd like to replace it with a more secure encryption algorithm (and it needs to be done server-side). Unfortunately, it needs to be two-way and the algorithms in hashlib are all one-way.
What are some good encryption libraries that will include algorithms for this kind of thing? | 0 | python,encryption | 2009-04-06T13:27:00.000 | 0 | 721,436 | If it's two-way, it's not really a "hash". It's encryption (and from the sounds of things this is really more of a 'salt' or 'cypher', not real encryption.) A hash is one-way by definition. So rather than something like MD5 or SHA1 you need to look for something more like PGP.
Secondly, can you explain the reasoning behind the 2-way requirement? That's not generally considered good practice for authentication systems any more. | 0 | 3,449 | true | 0 | 1 | What's a good two-way encryption library implemented in Python? | 721,444 |
1 | 4 | 0 | 9 | 9 | 0 | 1 | 0 | I'm not sure if this is even possible since this might be handled in hardware, but I need to send some Ethernet frames with errors in them. I'd like to be able to create runts, jabber, misalignment, and bad FCS errors. I'm working in Python. | 0 | python,networking,automated-tests,ethernet | 2009-04-06T23:30:00.000 | 0 | 723,635 | It can be handled in hardware, but isn't always -- and even if it is, you can turn that off; see the ethtool offload parameters.
With regard to getting full control over the frames you create -- look into PF_PACKET (for one approach) or the tap driver (for another).
Here's an article on using PF_PACKET to send hand-crafted frames from Python. | 0 | 12,680 | false | 0 | 1 | How do you send an Ethernet frame with a corrupt FCS? | 724,009 |
1 | 3 | 0 | 3 | 0 | 1 | 0.197375 | 0 | Is there any way to generate words based on characters and checking if a domain exists with this word (ping)?
What I want to do is to generate words based on some characters, example "abcdefgh", and then ping generatedword.com to check if it exists. | 0 | python,ping | 2009-04-09T20:03:00.000 | 0 | 735,743 | Just because a site fails a ping doesn't mean the domain is available. The domain could be reserved but not pointing anywhere, or the machine may not respond to pings, or it may just be down. | 0 | 382 | false | 0 | 1 | Looping through chars, generating words and checking if domain exists | 735,801 |
1 | 2 | 0 | 2 | 1 | 0 | 0.197375 | 0 | I need to measure the performance of a hard disk using python. What is the best/fastest/shortest/easiest approach to do it? It doesn't have to be overly accurate, just a ballpark value.
My actual goal is to write a small utility which will adjust the postgres settings to the best configuration for the given hardware.
My naive approach would be to write some files and measure the time how long it would take. I would try it for several block sizes, and then I would try to access some random positions within a large file. Any other ideas? | 0 | python,performance,postgresql | 2009-04-16T20:00:00.000 | 0 | 757,816 | I would think your best bet would be using an external tool, Bonnie++ for example, and parse the program output. Even if you're not that concerned with precision there's no reason to reinvent the wheel. Why rewrite what's already there? | 0 | 179 | false | 0 | 1 | Whats the easiest and fastest way to measure HD performance using Python? | 758,057 |
1 | 2 | 0 | 6 | 6 | 0 | 1 | 0 | I have a python process (Pylons webapp) that is constantly using 10-30% of CPU. I'll improve/tune logging to get some insight of what's going on, but until then, are there any tools/techniques that allow to see what python process is doing, how many and how busy threads it has etc?
Update:
configured access log which shows that there are no requests going on, webapp is just idling
no point to plug in paste.profile in middleware chain since there are no requests, activity must be happening either in webapp's worker threads or paster web server
running paster like this: "python -m cProfile -o outfile /usr/bin/paster serve dev.ini" and inspecting results shows that most time is spent in "posix.waitpid". Paster runs webapp in subprocess, subprocess activity is not picked up by profiler
looking into ;hacking PasteScript "serve" command so that subprocesses would get profiled
Another update:
After much tinkering, sticking profiler in various places and getting familiar with PasteScript insides, I discovered that the constant CPU load goes away if application is started without "--reload" parameter (this flag tells paster to restart itself if code changes, handy in development), which is fine in production environment. | 0 | python,multithreading,debugging,monitoring,pylons | 2009-04-17T11:17:00.000 | 1 | 760,039 | As you noted, in --reload mode, Paste sweeps the filesystem every second to see if any of the files loaded have changed. If they have, then Paste reloads the process. You can also manually tell Paste to monitor non-Python code modules for changes if desired.
You can change the reload interval with the --reload-interval option, this will reduce the CPU usage when using --reload as it will sweep less often. | 0 | 3,282 | false | 0 | 1 | Investigating python process to see what's eating CPU | 784,432 |
2 | 2 | 0 | 0 | 1 | 0 | 1.2 | 0 | I'm trying to find a way to mark a USB flash device in a way that I can programmaticly test for without mounting it or changing the label.
Are there any properties I can modify about a device that will not cause it to behave/look differently to the user?
Running Ubuntu Jaunty. | 0 | python,hardware,mount,dbus,hal | 2009-04-17T12:58:00.000 | 0 | 760,310 | Changing the VID/PID might make your device non-usable without custom drivers. HAL isn't supposed to auto-mount your flash drives for you.
That being said, you could always sneak something into the boot sector and/or the beginning part of the drive. There are a lot of spare bytes in there that can be used for custom purposes - both nefarious and otherwise. | 0 | 104 | true | 0 | 1 | How to mark a device in a way that can be retrived by HAL but does not require mounting or changing the label | 760,814 |
2 | 2 | 0 | 1 | 1 | 0 | 0.099668 | 0 | I'm trying to find a way to mark a USB flash device in a way that I can programmaticly test for without mounting it or changing the label.
Are there any properties I can modify about a device that will not cause it to behave/look differently to the user?
Running Ubuntu Jaunty. | 0 | python,hardware,mount,dbus,hal | 2009-04-17T12:58:00.000 | 0 | 760,310 | You cannot modify this property, but the tuple (vendor_id, product_id, serial_number) is unique to each device, so you can use this as mark that is already there.
You can enumerate the devices on the USB bus using lsusb or usblib. | 0 | 104 | false | 0 | 1 | How to mark a device in a way that can be retrived by HAL but does not require mounting or changing the label | 760,744 |
2 | 7 | 0 | 3 | 3 | 1 | 0.085505 | 0 | Is it possible to import modules based on location?
(eg. do all modules i import have to be in /usr/lib64/python2.5/ or a similar dir?)
I'd like to import a module that's local to the current script. | 0 | python,import | 2009-04-17T20:37:00.000 | 0 | 762,111 | python will import from the current directory by default.
sys.path is the variable that controls where python searches for imports. | 0 | 462 | false | 0 | 1 | Importing In Python | 762,122 |
2 | 7 | 0 | 0 | 3 | 1 | 0 | 0 | Is it possible to import modules based on location?
(eg. do all modules i import have to be in /usr/lib64/python2.5/ or a similar dir?)
I'd like to import a module that's local to the current script. | 0 | python,import | 2009-04-17T20:37:00.000 | 0 | 762,111 | It searches in ./lib by default. | 0 | 462 | false | 0 | 1 | Importing In Python | 762,142 |
1 | 3 | 0 | 1 | 4 | 0 | 0.066568 | 0 | The host I'm considering for hosting a Django site has mod_python installed, but does not have Django. Django's INSTALL file indicates that I can simply copy the django directory to Python's site-packages directory to install Django, so I suspect that it might be possible to configure Python / mod_python to look for it elsewhere (namely my user space) by modifying sys.path, but I don't know how to change it from .htaccess or mod_python.
How do I modify sys.path from .htaccess to allow mod_python to see Django?
P.S. I can only access the site via FTP (i.e. no shell access). I realize that it sounds like I should just switch hosts, but there are compelling reasons for me to make this work so I'm at least going to try. | 0 | python,django,apache,.htaccess,mod-python | 2009-04-18T22:02:00.000 | 0 | 764,312 | You're using mod_python wrong. It was never intended to serve python web applications. You should be using WSGI for this... or at least FastCGI. | 0 | 1,417 | false | 1 | 1 | How do I modify sys.path from .htaccess to allow mod_python to see Django? | 764,769 |
2 | 3 | 0 | 5 | 3 | 0 | 1.2 | 0 | I need to send email in delbian linux. How to send? I run my server on 256 MB linux box and I heard postfix and sendmail is overkill.
Recently I came across the ssmtp, that seems to be an executable, needs to be executed as a process and called through python using os modules.
alternatively, python already provides smtplib which is working fine with me.
What is the advantage of using ssmtp over python's smtplib? | 0 | python,smtplib,ssmtp | 2009-04-19T03:24:00.000 | 0 | 764,778 | In a Python program, there is no advantage.
The only purpose of ssmtp is to wrap the SMTP protocol in the sendmail API. That is, it provides a program /usr/sbin/sendmail that accepts the same options, arguments, and inputs as the full-blown sendmail (though most of the options do nothing); but behind the scenes, instead of processing the email itself, it sends the message to an SMTP server. This is for systems that need to have a sendmail program present, perhaps because they don't understand SMTP - for example, I think older versions of PHP had this requirement, and even in recent versions it might still be easier to configure PHP to use the so-called sendmail interface (i.e. the program sendmail) than to use SMTP directly. (I haven't used PHP in a little while, I'm not sure about the current status)
However, in Python the situation is reversed: you have a builtin library that makes it easy to use SMTP directly, whereas using sendmail requires you to invoke the subprocess module which is somewhat clunky and also very dependent on things that are not part of Python. So basically there is no reason not to use smtplib. | 0 | 4,757 | true | 0 | 1 | how to send mail in python ssmtp vs smtplib | 765,044 |
2 | 3 | 0 | 2 | 3 | 0 | 0.132549 | 0 | I need to send email in delbian linux. How to send? I run my server on 256 MB linux box and I heard postfix and sendmail is overkill.
Recently I came across the ssmtp, that seems to be an executable, needs to be executed as a process and called through python using os modules.
alternatively, python already provides smtplib which is working fine with me.
What is the advantage of using ssmtp over python's smtplib? | 0 | python,smtplib,ssmtp | 2009-04-19T03:24:00.000 | 0 | 764,778 | Additionally, postfix is very easy to install in "satellite" mode, where all it does is queue and deliver email for you. Way easier than implementing your own email queue. Most decent package management systems will let you configure it this way. | 0 | 4,757 | false | 0 | 1 | how to send mail in python ssmtp vs smtplib | 766,413 |
1 | 4 | 0 | 0 | 10 | 1 | 0 | 0 | Can you elaborate on the current state of "blocks" (in the Ruby sense) in Python?
What are the language constructs that exist in Python? How do they compare to other languages (like Ruby, Smalltalk, [insert more])? Or does Python lack such constructs?
I have so far understood the lambda thing; it is only one-line, but maybe it comes close. What about "decorators" and yield in this context?
I am also using old Python versions in some projects. Which constructs were introduced in which Python version (2.5, 2.6, etc.) or are planned in future versions?
Can you link interesting articles on the subject that explain this stuff for Python and also comparing to other languages and could be interesting for someone who wants to extend basic Python knowledge? | 0 | python,ruby,lambda | 2009-04-20T09:14:00.000 | 0 | 767,519 | The def is equivalent of an assignment statement which only binds the function object to the object reference variable.
The object reference variable can then be used to call the function object to execute. | 0 | 4,121 | false | 0 | 1 | Blocks of code in Python | 768,265 |
2 | 4 | 0 | 3 | 7 | 0 | 0.148885 | 0 | I need to create ZIP archives on demand, using either Python zipfile module or unix command line utilities.
Resources to be zipped are often > 1GB and not necessarily compression-friendly.
How do I efficiently estimate its creation time / size? | 0 | python,zip,time-estimation | 2009-04-20T10:23:00.000 | 1 | 767,684 | I suggest you measure the average time it takes to produce a zip of a certain size. Then you calculate the estimate from that measure. However I think the estimate will be very rough in any case if you don't know how well the data compresses. If the data you want to compress had a very similar "profile" each time you could probably make better predictions. | 0 | 3,583 | false | 0 | 1 | Estimating zip size/creation time | 767,701 |
2 | 4 | 0 | 16 | 7 | 0 | 1.2 | 0 | I need to create ZIP archives on demand, using either Python zipfile module or unix command line utilities.
Resources to be zipped are often > 1GB and not necessarily compression-friendly.
How do I efficiently estimate its creation time / size? | 0 | python,zip,time-estimation | 2009-04-20T10:23:00.000 | 1 | 767,684 | Extract a bunch of small parts from the big file. Maybe 64 chunks of 64k each. Randomly selected.
Concatenate the data, compress it, measure the time and the compression ratio. Since you've randomly selected parts of the file chances are that you have compressed a representative subset of the data.
Now all you have to do is to estimate the time for the whole file based on the time of your test-data. | 0 | 3,583 | true | 0 | 1 | Estimating zip size/creation time | 767,704 |
1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | I would like to use the entry point functionality in setuptools.
There are a number of occasions where I would like to tightly control the list of eggs that are run, and thence the extensions that contribute to a set of entry points:
egg integration testing, where I want to run multiple test suites on different combinations of eggs.
scanning a single directory of eggs/plugins so as to run two different instances of the same program, but with different eggs.
development time, where I am developing one or more egg, and would like to run the program as part of the normal edit-run cycle.
I have looked through the setuptools documentation, and while it doesn't say that this is not possible, I must have missed something saying how to do it.
What is the best way to approach deploying plugins differently to the default system-wide discovery? | 0 | python,setuptools,distutils,egg | 2009-04-20T19:27:00.000 | 0 | 769,766 | We're solving something similar, ability to use setup.py develop if You're mere user without access to global site-packages. So far, we solved it with virtualenv.
I'd say it will help for your case too: have minimal system-wide install (or explicitly exclude it), create virtual environment with eggs you want and test there.
(Or, for integration tests, create clean environment, install egg and test all dependencies are installed).
For 2, I'm not sure, but it should work too, with multiple virtualenvs. For 3, setup.py develop is the way to go. | 0 | 294 | false | 0 | 1 | How do I load entry-points for a defined set of eggs with Python setuptools? | 1,000,651 |
1 | 2 | 0 | 1 | 3 | 0 | 0.099668 | 0 | I've set up a few web servers in my day, but I'm not sure how they work internally. I'm setting up a new environment for myself and I'm interested in configuring my lighttpd server to support both PHP and Python. Is this possible? | 0 | php,python,lighttpd,configure | 2009-04-21T06:49:00.000 | 0 | 771,341 | You can also enable Lighty to use .pl, .py and .php as 'cgi' by enabling mod_cgi and setting it up. The default configs are on the Lighty website. However, this will have the benefits and problems of running an independent cgi process. If you are only experiencing light traffic, performance shouldn't be an issue. | 0 | 3,056 | false | 0 | 1 | Python + PHP + Lighttpd? | 771,528 |
1 | 1 | 0 | 3 | 3 | 1 | 1.2 | 0 | Since python2.6, it's now easier to extract data from a password protected zip. But how to create a password protected zipfile in pure python ? | 0 | python,zip | 2009-04-21T14:20:00.000 | 0 | 772,814 | I've looked for this in the past and been unsuccessful. (I'd love to see a solution get posted!)
One option is a commercial package from chilkatsoft that will do this, but at $150. Makes sense if you are doing a commercial app, but tough to swallow otherwise.
I wound up calling out to the system for my solution, a while ago. Unfortunately, this locks it to a platform. | 0 | 1,457 | true | 0 | 1 | How to create a password protected zipfile with python? | 772,842 |
1 | 3 | 0 | 3 | 1 | 0 | 1.2 | 1 | Hi I have a small comment shoutbox type cgi process running on a server and currently when someone leaves a comment I simply format that comment into html i.e
<p class="title">$title</p>
<p class="comment">$comment</p>
and store in a flat file.
Would it be faster and acceptably low in LOC to reimplement the storage in xml or json, in a simple spec of my own or stick with the simple html route?.
I don't want to use relational database for this. | 0 | python,xml,json | 2009-04-22T12:56:00.000 | 0 | 777,090 | If a flat file is fast enough, then go with that, since it's very simple and accessible. Storing as XML and JSON but still using a flat file probably is very comparable in performance.
You might want to consider (ignore this if you just left it out of your question) sanitizing/filtering the text, so that users can't break your HTML by e.g. entering "</p>" in the comment text. | 0 | 331 | true | 0 | 1 | fastest way to store comment data python | 777,119 |
1 | 7 | 0 | 2 | 14 | 1 | 0.057081 | 0 | The struct.pack() function allows converting integers of up to 64 bit to byte strings. What's the most efficient way to pack an even larger integer? I'd rather not add a dependency on non-standard modules like PyCrypto (which provides num_to_bytes()). | 0 | python,byte | 2009-04-22T14:36:00.000 | 0 | 777,525 | I take it you mean you only want to use as many bytes as you need to represent the number? e.g. if the number is:
255 or less you'd use only 1 byte
65535 or less 2 bytes
16777215 or less 3 bytes
etc etc
On the Psion PDA they'd usually have some of packing scheme in which you read the first byte, detect if it has the highest bit set and then read another byte if it has. That way you'd just keep reading bytes until you read the "full" number. That system works quite well if most of the numbers you are dealing with are fairly small, as you'll normally only use one or two bytes per number.
The alternative is to have one (or more) bytes representing the number of total bytes used, but at that point it's basically a string in Python anyway. i.e. it's a string of base-256 digits. | 0 | 4,223 | false | 0 | 1 | Efficient arbitrary-sized integer packing in Python | 777,746 |
1 | 5 | 0 | 0 | 0 | 0 | 0 | 1 | Other than basic python syntax, what other key areas should I learn to get a website live?
Is there a web.config in the python world?
Which libraries handle things like authentication? or is that all done manually via session cookies and database tables?
Are there any web specific libraries?
Edit: sorry!
I am well versed in asp.net, I want to branch out and learn Python, hence this question (sorry, terrible start to this question I know). | 0 | python | 2009-04-22T15:46:00.000 | 0 | 777,924 | Oh, golly.
Look, this is gonna be real hard to answer because, read as you wrote it, you're missing a lot of steps. Like, you need a web server, a design, some HTML, and so on.
Are you building from the ground up? Asking about Python makes me suspect you may be using something like Zope. | 0 | 177 | false | 0 | 1 | Other than basic python syntax, what other key areas should I learn to get a website live? | 777,952 |
1 | 1 | 0 | 2 | 0 | 1 | 1.2 | 0 | Is there an easy-to-use python module that'd do english or finnish text validation?
It'd be ok if I could just check the words exist in user-defined dictionary and possibly checking that the grammar is somewhat okay.
I am planning to implement a fancy validation for a directory contents I did while ago back. This involves some simple stuff like checking that the config scripts won't crash and does it all well. It's all quite easy otherwise.
For the validator I should just be able to input whole files or strings of unicode text. | 0 | python | 2009-04-23T19:27:00.000 | 0 | 783,189 | I'm not sure what you're trying to do, but if you're looking for something that can say 'this is valid English' or 'this is valid Finnish', then you're looking at a class of problems that is quite likely unsolvable.
If not, then use a dictionary and/or letter frequencies and Bayesian analysis to determine whether or not given text is English-like or Finnish-like. If you're trying to auto-detect a language, this is likely the best route, although you'll run into problems with mixed-language text. | 0 | 152 | true | 0 | 1 | English and/or Finnish text validation | 783,207 |
9 | 11 | 0 | 5 | 2 | 0 | 0.090659 | 0 | G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.
I've broken this down into 2 parts:
1) show Python and Ruby's advantages over PHP;
2) show Ruby's advantages over Python.
The first is easy. I'll explain things like:
Everything's an object.
Python and Ruby are easier to read and write.
For the second, I'm thinking of:
Ruby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now
RSpec is miles ahead of Python's TDD and BDD frameworks.
GitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.
Do you have any suggestions? I'm all ears! | 0 | python,ruby | 2009-04-24T05:02:00.000 | 0 | 784,584 | Devil's advocate maybe...
Everything's an object.
This is a feature of Ruby, but it is not self-explanatory as to why this is a benefit. You would need to pre-prepare an argument for why that is a benefit. When convincing somebody of something's superiority, always think in terms of showing the benefits, not the features.
Python and Ruby are easier to read and write.
This is a very big claim to make, and I would not be comfortable making such a claim without a substantial amount of credible objective third party evidence supporting this. If not, and I suspect such a claim really couldn't be backed up, I would play it safe and avoid making such a claim. Making a claim this substantial, but only backing it up with personal opinion or anecdotal evidence would not be a good idea.
Ruby has many conveniences, which
makes it easier to read and write. Eg:
Optional brackets, and being able to
open built-ins, allows for things like
2.days.from_now
Again, you will need to think benefits, not features. It may be true that it has optional brackets, but you cannot just mention a feature, you have to explain its benefit - why that feature is a better idea than any other approach. Personally I am not sure that 'optional' syntax is ever a good idea, and would need a fair bit of evidence to convince me that it was.
GitHub and RubyForge are fantastic resources for finding,
releasing, and collaborating on
software.
That's good. There are also similar resources for languages other than Ruby - again, you will need to not only mention the existence of these but explain how they are better than the alternatives.
Good luck. | 0 | 1,888 | false | 1 | 1 | Convincing others of Ruby over Python and PHP | 784,667 |
9 | 11 | 0 | 0 | 2 | 0 | 0 | 0 | G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.
I've broken this down into 2 parts:
1) show Python and Ruby's advantages over PHP;
2) show Ruby's advantages over Python.
The first is easy. I'll explain things like:
Everything's an object.
Python and Ruby are easier to read and write.
For the second, I'm thinking of:
Ruby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now
RSpec is miles ahead of Python's TDD and BDD frameworks.
GitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.
Do you have any suggestions? I'm all ears! | 0 | python,ruby | 2009-04-24T05:02:00.000 | 0 | 784,584 | All 3 languages have their place. As with any programming task you must pick the language best suited for the task. Python has list comprehensions, php is much better when embedding and generating html. Ruby is a great language too. One of the things I have found myself using in ruby a few times is the 'a'...'zzzzz' to generate all possible strings of size 1 - 5. They all have their advantages and are all better than the others at particular tasks. | 0 | 1,888 | false | 1 | 1 | Convincing others of Ruby over Python and PHP | 784,633 |
9 | 11 | 0 | 0 | 2 | 0 | 0 | 0 | G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.
I've broken this down into 2 parts:
1) show Python and Ruby's advantages over PHP;
2) show Ruby's advantages over Python.
The first is easy. I'll explain things like:
Everything's an object.
Python and Ruby are easier to read and write.
For the second, I'm thinking of:
Ruby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now
RSpec is miles ahead of Python's TDD and BDD frameworks.
GitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.
Do you have any suggestions? I'm all ears! | 0 | python,ruby | 2009-04-24T05:02:00.000 | 0 | 784,584 | If you are inclined towards a language or a software then you will tend to see only the goodies compared to others. If you want to do real comparison then comapre pros and cons and see if Ruby is clear winner in terms of what you want to achieve with that language in your company. If you do this and your company see benefits of Ruby then surely they will use. | 0 | 1,888 | false | 1 | 1 | Convincing others of Ruby over Python and PHP | 784,656 |
9 | 11 | 0 | 0 | 2 | 0 | 0 | 0 | G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.
I've broken this down into 2 parts:
1) show Python and Ruby's advantages over PHP;
2) show Ruby's advantages over Python.
The first is easy. I'll explain things like:
Everything's an object.
Python and Ruby are easier to read and write.
For the second, I'm thinking of:
Ruby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now
RSpec is miles ahead of Python's TDD and BDD frameworks.
GitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.
Do you have any suggestions? I'm all ears! | 0 | python,ruby | 2009-04-24T05:02:00.000 | 0 | 784,584 | This kind of post gives Ruby programmers a bad name. Ruby is Beethoven, Python is Bach. If you prefer one style to the other, fine, but don't try to argue the superiority of one over the other. | 0 | 1,888 | false | 1 | 1 | Convincing others of Ruby over Python and PHP | 1,227,135 |
9 | 11 | 0 | 1 | 2 | 0 | 0.01818 | 0 | G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.
I've broken this down into 2 parts:
1) show Python and Ruby's advantages over PHP;
2) show Ruby's advantages over Python.
The first is easy. I'll explain things like:
Everything's an object.
Python and Ruby are easier to read and write.
For the second, I'm thinking of:
Ruby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now
RSpec is miles ahead of Python's TDD and BDD frameworks.
GitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.
Do you have any suggestions? I'm all ears! | 0 | python,ruby | 2009-04-24T05:02:00.000 | 0 | 784,584 | Actually no one ever conviced me (at least directly), to use one programming language or another.
I used to have a certain need for clearness (if you might call it that way) and some other criteria, a language and its ecosystem should meet. And you definitively will end up using some stdlib, and third-party resources, so you might want to look into them as well (and use them as arguments).
I am a fan of both, ruby and python (and these languages conviced me both by their design, their constant progress and their communities). The general notion of a scripting language makes them equally appealing. I found gem to be one of the slowest software I ever used. And personally, I think pythons stdlib is better organized than rubys. But I like Ruby Mixins, they are elegant and safe a lot of time.
In short: You could point your colleagues interest to some current hot spots, where coding is just hard, then show some alternatives in ruby. Rake is a great tool as well, demonstrate it ... Just be rationally passionate about it .. The rest will come .. | 0 | 1,888 | false | 1 | 1 | Convincing others of Ruby over Python and PHP | 785,273 |
9 | 11 | 0 | 2 | 2 | 0 | 0.036348 | 0 | G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.
I've broken this down into 2 parts:
1) show Python and Ruby's advantages over PHP;
2) show Ruby's advantages over Python.
The first is easy. I'll explain things like:
Everything's an object.
Python and Ruby are easier to read and write.
For the second, I'm thinking of:
Ruby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now
RSpec is miles ahead of Python's TDD and BDD frameworks.
GitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.
Do you have any suggestions? I'm all ears! | 0 | python,ruby | 2009-04-24T05:02:00.000 | 0 | 784,584 | You're going to have a tough sell over python. GitHub is written in Ruby, not for ruby per se, by the way.
For python one has BitBucket (even though I do prefer git), as well as pypi.
Correct me if I'm wrong, but it sounds like you haven't looked at python code all that much. (I've written buckets of both python and Ruby by the way) I find it much more readable, especially when you're working on code that's not your own.
Anyways, not really answering your question, and don't really want to contribute more to the flame war. | 0 | 1,888 | false | 1 | 1 | Convincing others of Ruby over Python and PHP | 785,262 |
9 | 11 | 0 | 5 | 2 | 0 | 0.090659 | 0 | G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.
I've broken this down into 2 parts:
1) show Python and Ruby's advantages over PHP;
2) show Ruby's advantages over Python.
The first is easy. I'll explain things like:
Everything's an object.
Python and Ruby are easier to read and write.
For the second, I'm thinking of:
Ruby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now
RSpec is miles ahead of Python's TDD and BDD frameworks.
GitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.
Do you have any suggestions? I'm all ears! | 0 | python,ruby | 2009-04-24T05:02:00.000 | 0 | 784,584 | If you really want to show Ruby is better (assuming it is for your application!), why not try writing a small app from scratch in front of them? It doesn't have to be big, but something relavent to what you'll eventually be using it for is a good idea.
Write the app in all three languages including any configuration for the server (I'm assuming you're writing a web app here using DJango / Rails / PHP right?) and show how much faster you are, how much cleaner the code is etc. ...assuming it is ;-)
You can finish up by asking them what they'd like to add to it and then try adding that feature if it's a small change. Nothing like a bit of audience participation - people like applauding themselves. If you get them involved they're more likely to accept the winner.
For the record, I've tried all three and would agree that both Ruby and Python seem to result in cleaner code. I'd go for Python over Ruby though - there was something clunky about the syntax of Ruby when I tried it that I just didn't experience with Python. | 0 | 1,888 | false | 1 | 1 | Convincing others of Ruby over Python and PHP | 785,060 |
9 | 11 | 0 | 29 | 2 | 0 | 1 | 0 | G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.
I've broken this down into 2 parts:
1) show Python and Ruby's advantages over PHP;
2) show Ruby's advantages over Python.
The first is easy. I'll explain things like:
Everything's an object.
Python and Ruby are easier to read and write.
For the second, I'm thinking of:
Ruby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now
RSpec is miles ahead of Python's TDD and BDD frameworks.
GitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.
Do you have any suggestions? I'm all ears! | 0 | python,ruby | 2009-04-24T05:02:00.000 | 0 | 784,584 | If your goal is to show why language X is better than language Y, you're stuck in subjective-land where there are no right answers.
No, Ruby is not better than PHP or Python. It might be more suited for a given purpose, and for that you can give specific examples. PHP is a poor choice for writing an SMTP server; Ruby and Python will serve you better (in fact, in Python it can be done in just a few lines, can't speak for Ruby though). On the other hand, PHP is better suited than Ruby for writing a one-off, short backend for an email submission form. The code is short, easy to maintain, quick to write, etc.
PHP has an absolutely huge developer base, making programmers easy to find, which comes in handy if you ever want to out-source any aspect of the development chain. On the other hand, it's also terrifically easy to write horrible code in PHP, and there is more than enough of that going around.
Python has a much larger user base than Ruby, and indeed is the primary language that RedHat uses for developing system tools. So if you're on a RedHat derived server (and statistically, chances are pretty good that you are if you're using Linux) then Python is guaranteed to be already in-place and working properly, etc.
In short, weigh the benefits, make a decision, but don't assume that people will agree with you; after all it's just an opinion.
Edit
It just occurred to me that I failed to state the whole point: you shouldn't be trying to convince other people that they should use Ruby over Python/PHP. Instead you should be trying to determine whether you should use Ruby over Python/PHP.
You can't go fact-finding like this having already determined what the answer will be -- that's not helpful. Instead you should be gathering information on the benefits and drawbacks of each language and weighing that against the requirements of your company. Once you come to a conclusion, you'll already have a preponderance of evidence showing it was the correct one. | 0 | 1,888 | false | 1 | 1 | Convincing others of Ruby over Python and PHP | 784,626 |
9 | 11 | 0 | 12 | 2 | 0 | 1 | 0 | G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.
I've broken this down into 2 parts:
1) show Python and Ruby's advantages over PHP;
2) show Ruby's advantages over Python.
The first is easy. I'll explain things like:
Everything's an object.
Python and Ruby are easier to read and write.
For the second, I'm thinking of:
Ruby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now
RSpec is miles ahead of Python's TDD and BDD frameworks.
GitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.
Do you have any suggestions? I'm all ears! | 0 | python,ruby | 2009-04-24T05:02:00.000 | 0 | 784,584 | Hmm, as an active programmer in all three languages I simply can't agree with the sentiment that either is better than the other. Sure, Python and Ruby are more object-oriented, but that's not a requirement to be better, it's only a convenience. You can't beat the community of PHP and the legacy (for good and for bad) of code, nor ignore the direction PHP is taking for the future, the mass of support, the distributed servers ready for it, and so on.
If you want to focus on syntax, then all three have their strong and weak points. If you want to talk about back-end technology, then as all three are moving active open-source projects, there really is no winner.
Except, you, the programmer, who can mix and choose what best suits you. Remember that even if you think Ruby is the best thing since NAND gates it doesn't mean others follow. And remember also that we're all different; some people actually like Java and .Net, just like others love LISP. We're all different, and I doubt any of the Ruby/Python/PHP contenders are any better than the other. Sorry. | 0 | 1,888 | false | 1 | 1 | Convincing others of Ruby over Python and PHP | 784,621 |
2 | 3 | 0 | 2 | 2 | 0 | 0.132549 | 0 | Is there a way to generically retrieve process stats using Perl or Python? We could keep it Linux specific.
There are a few problems: I won't know the PID ahead of time, but I can run the process in question from the script itself. For example, I'd have no problem doing:
./myscript.pl some/process/I/want/to/get/stats/for
Basically, I'd like to, at the very least, get the memory consumption of the process, but the more information I can get the better (like run time of the process, average CPU usage of the process, etc.)
Thanks. | 0 | python,linux,perl,process | 2009-04-24T13:18:00.000 | 1 | 785,810 | If you are fork()ing the child, you will know it's PID.
From within the parent you can then parse the files in /proc/<PID/ to check the memory and CPU usage, albeit only for as long as the child process is running. | 0 | 4,760 | false | 0 | 1 | Is there a way to retrieve process stats using Perl or Python? | 785,836 |
2 | 3 | 0 | 1 | 2 | 0 | 0.066568 | 0 | Is there a way to generically retrieve process stats using Perl or Python? We could keep it Linux specific.
There are a few problems: I won't know the PID ahead of time, but I can run the process in question from the script itself. For example, I'd have no problem doing:
./myscript.pl some/process/I/want/to/get/stats/for
Basically, I'd like to, at the very least, get the memory consumption of the process, but the more information I can get the better (like run time of the process, average CPU usage of the process, etc.)
Thanks. | 0 | python,linux,perl,process | 2009-04-24T13:18:00.000 | 1 | 785,810 | A common misconception is that reading /proc is like reading /home. /proc is designed to give you the same information with one open() that 20 similar syscalls filling some structure could provide. Reading it does not pollute buffers, send innocent programs to paging hell or otherwise contribute to the death of kittens.
Accessing /proc/foo is just telling the kernel "give me information on foo that I can process in a language agnostic way"
If you need more details on what is in /proc/{pid}/ , update your question and I'll post them. | 0 | 4,760 | false | 0 | 1 | Is there a way to retrieve process stats using Perl or Python? | 785,855 |
2 | 4 | 0 | 3 | 3 | 0 | 0.148885 | 0 | I am working for a company that provides customer support to its clients. I am trying to design a system that would send emails automatically to clients when some event occurs. The system would consist of a backend part and a web interface part. The backend will handle the communication with a web interface (which will be only for internal use to change the email templates) and most important it will check some database tables and based on those results will send emails ... lots of them.
Now, I am wondering how can this be designed so it can be made scalable and provide the necessary performance as it will probably have to handle a few thousands emails per hours (this should be the peek). I am mostly interested about how would this kind of architecture should be thought in order to be easily scaled in the future if needed.
Python will be used on the backend with Postgres and probably whatever comes first between a Python web framework and GWT on the frontend (which seems the simplest task). | 0 | python,linux,email | 2009-04-24T14:45:00.000 | 0 | 786,138 | A few thousand emails per hour isn't really that much, as long as your outgoing mail server is willing to accept them in a timely manner.
I would send them using a local mta, like postfix, or exim (which would then send them through your outgoing relay if required). That service is then responsible for the mail queues, retries, bounces, etc. If your looking for more "mailing list" features, try adding mailman into the mix. It's written in python, and you've probably seen it, as it runs tons of internet mailing lists. | 0 | 3,573 | false | 1 | 1 | How to design an email system? | 787,170 |
2 | 4 | 0 | 0 | 3 | 0 | 0 | 0 | I am working for a company that provides customer support to its clients. I am trying to design a system that would send emails automatically to clients when some event occurs. The system would consist of a backend part and a web interface part. The backend will handle the communication with a web interface (which will be only for internal use to change the email templates) and most important it will check some database tables and based on those results will send emails ... lots of them.
Now, I am wondering how can this be designed so it can be made scalable and provide the necessary performance as it will probably have to handle a few thousands emails per hours (this should be the peek). I am mostly interested about how would this kind of architecture should be thought in order to be easily scaled in the future if needed.
Python will be used on the backend with Postgres and probably whatever comes first between a Python web framework and GWT on the frontend (which seems the simplest task). | 0 | python,linux,email | 2009-04-24T14:45:00.000 | 0 | 786,138 | You might want to try Twisted Mail for implementing your own backend in pure Python. | 0 | 3,573 | false | 1 | 1 | How to design an email system? | 787,214 |
1 | 20 | 0 | 0 | 121 | 0 | 0 | 0 | I have a python daemon running as a part of my web app/ How can I quickly check (using python) if my daemon is running and, if not, launch it?
I want to do it that way to fix any crashes of the daemon, and so the script does not have to be run manually, it will automatically run as soon as it is called and then stay running.
How can i check (using python) if my script is running? | 0 | python,process,daemon | 2009-04-25T06:59:00.000 | 1 | 788,411 | I was looking for an answer on this and in my case, came to mind a very easy and very good solution, in my opinion (since it's not possible to exist a false positive on this, I guess - how can the timestamp on the TXT be updated if the program doesn't do it):
--> just keep writing on a TXT the current timestamp in some time interval, depending on your needs (here each half hour was perfect).
If the timestamp on the TXT is outdated relatively to the current one when you check, then there was a problem on the program and it should be restarted or what you prefer to do. | 0 | 189,116 | false | 0 | 1 | Check to see if python script is running | 66,500,807 |
1 | 2 | 0 | 2 | 3 | 1 | 0.197375 | 0 | I am using Python as a plug-in scripting language for an existing C++ application. I am able to embed the python interpreter as stated in the Python documentation. Everything works successfully with the initialization and de-initialization of the interpreter. I am, however, having trouble loading modules because I have not been able to zip up the standard library in to a zip file (normally PythonXX.zip, corresponding to the version number of the python dll).
What is the simplest way to zip up all of the standard library after optimized bytecode compiling? I'm looking for a simple script or command to do so for me, as I really don't want to do this by hand.
Any ideas?
Thanks! | 0 | c++,python,distribution,embedded-language | 2009-04-25T19:48:00.000 | 0 | 789,598 | It shouldn't be too difficult to write a script for that. Check out the zipfile.PyZipFile class and it's writepy method. | 0 | 845 | false | 0 | 1 | What is the easiest way to build Python26.zip for embedded distribution? | 789,669 |
1 | 4 | 0 | 0 | 2 | 0 | 0 | 0 | I'd like to provide a functionality for users of my website to get assigned an email address upon registration (such as [email protected]) but I don't really think it is feasible to actually support all these emails account normally through a webmail program. I am also not sure if my webhost would be cool with it. What I'd really want is to be able to have a seamless integration of this email into the bigger system that the website is, as it is mostly going to be for intra-site messaging but we want to allow users to put actual email addresses. So what I would like to do instead is have a catch-all account under mydomain and have this email look at incoming mail, see who it was meant to be sent to, and add a message for the user in the system.
So, the questions are:
1) Is this the right approach? How expensive would it be to get a host that would allow me to just assign emails to at will to my domain? I am currently using WebFaction's shared hosting.
2) If it is an okay approach, what is the best way to route this catch all account to my python script? I have read about .forward but I am not very good at UNIX stuff. Once I figure that out, how would I get the script to be in the "Django environment" so I can use Django's model functionality to add the new messages to the user?
3) Is there anything Django can do to make this any easier?
4) Are there any tools in Python to help me parse the email address? How do they work? | 0 | python,django,email | 2009-04-25T20:35:00.000 | 0 | 789,685 | but I don't really think it is
feasible to actually support all these
emails account normally through a
webmail program
I think that your base assumption here is incorrect. You see, most 'webmail' programs are just frontends (or clients) to the backend mail system (postfix etc). You will need to see how your webhost is set up. There is no reason why you can not create these accounts programmatically and then let them use a normal webmail interface like SquirrelMail or RoundCube. For instance, my webhost (bluehost) allows me 2500 email accounts - I am not sure how many yours allows - but I can upgrade to unlimited for a few extra dollars a month. I think that using the builtin email handling facility is a more robust way to go. | 0 | 2,191 | false | 1 | 1 | What is the best way to redirect email to a Python script? | 789,699 |
2 | 4 | 0 | 0 | 4 | 1 | 0 | 0 | (I'm sure this is a FAQ, but also hard to google)
Why does Python use abs(x) instead of x.abs?
As far as I see everything abs() does besides calling x.__abs__ could just as well be implemented in object.abs()
Is it historical, because there hasn't always been a root class? | 0 | python,oop | 2009-04-25T21:02:00.000 | 0 | 789,718 | Python is a language that supports object oriented coding, but it deliberately isn't a pure OO language. As you correctly mention, Python classes, even user defined ones, haven't always derived from a single base class.
Functions are the basic unit of functionality in Python, so it makes sense for the core operations (random sample: str, dir, print, hash) to look like functions. | 0 | 635 | false | 0 | 1 | Why builtin functions instead of root class methods? | 789,746 |
2 | 4 | 0 | 1 | 4 | 1 | 0.049958 | 0 | (I'm sure this is a FAQ, but also hard to google)
Why does Python use abs(x) instead of x.abs?
As far as I see everything abs() does besides calling x.__abs__ could just as well be implemented in object.abs()
Is it historical, because there hasn't always been a root class? | 0 | python,oop | 2009-04-25T21:02:00.000 | 0 | 789,718 | I think you are looking a typical example where a language designer decides that readability and terseness trump purist constructs. | 0 | 635 | false | 0 | 1 | Why builtin functions instead of root class methods? | 789,724 |
Subsets and Splits