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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2 | 2 | 0 | 4 | 9 | 0 | 0.379949 | 0 |
my Django tests run really slowly, but it's not the test's fault.
At the moment, the whole process takes 14s, but only 0.1s of that is running tests. The first few seconds are creating tables & indexes, the rest is applying the project's many fixtures.
What's the best way to deal with this? I think there is a way of specifying which fixtures to load in each test, but I need most of them to do most tests...
A solution I think would work is if the tests didn't drop the tables after each run, that way there would be no need to create & populate the database each run-through of the tests. Most tests don't even write to the DB.
What's the best way to optimise the fixture-loading part of Django tests?
Thanks!
(I'm using nose, but otherwise just plain Django and sqlite)
EDIT: I should have mentioned that I'm using an in-memory sqlite database. What I'm looking for - specifically - is an optimisation of the fixture-loading section of the test.
| 0 |
python,django,testing,performance,fixtures
|
2011-02-17T13:16:00.000
| 0 | 5,029,415 |
You may use sqlite in-memory database for tests - it really fast
| 0 | 1,206 | false | 1 | 1 |
What's the best way to optimise the fixture-loading part of Django tests?
| 5,029,483 |
2 | 2 | 0 | 4 | 9 | 0 | 1.2 | 0 |
my Django tests run really slowly, but it's not the test's fault.
At the moment, the whole process takes 14s, but only 0.1s of that is running tests. The first few seconds are creating tables & indexes, the rest is applying the project's many fixtures.
What's the best way to deal with this? I think there is a way of specifying which fixtures to load in each test, but I need most of them to do most tests...
A solution I think would work is if the tests didn't drop the tables after each run, that way there would be no need to create & populate the database each run-through of the tests. Most tests don't even write to the DB.
What's the best way to optimise the fixture-loading part of Django tests?
Thanks!
(I'm using nose, but otherwise just plain Django and sqlite)
EDIT: I should have mentioned that I'm using an in-memory sqlite database. What I'm looking for - specifically - is an optimisation of the fixture-loading section of the test.
| 0 |
python,django,testing,performance,fixtures
|
2011-02-17T13:16:00.000
| 0 | 5,029,415 |
"but I need most of them to do most tests"...
Sorry about this, but to speed things up you're going to have to do some thinking.
"I think there is a way of specifying which fixtures to load in each test"
This is a disturbing thing to read. Have you looked at your tests recently?
Your tests do -- specifically -- list the fixtures. You need to minimize that list.
| 0 | 1,206 | true | 1 | 1 |
What's the best way to optimise the fixture-loading part of Django tests?
| 5,029,700 |
1 | 1 | 0 | 0 | 0 | 0 | 1.2 | 0 |
I want to make units fight in space just to try out some stuff it would need to print whats going on and results. I'm planing on loading each unit from a separate file or similar (units will be modifiable so i think it should be better this way, no need to keep each unit stats for instancing). I'm not sure how i would load the units.
Is the question too broad? A link to something similar would be helpfull i couldn't find anything
| 0 |
python
|
2011-02-17T22:24:00.000
| 0 | 5,035,460 |
There are a bunch of different ways of handling this, depending on exactly what you are trying to save and how you want to use it.
If you want to save basic unit-type stats so they can be easily modified, a plain-text file or csv file would work nicely. (If you have a copy of the game Alpha Centauri, look at the faction definition files - should give you lots of ideas!).
For the ultimate in flexibility, you could save your units as Python source-files and import as needed. But too much "flexibility" can also make debugging nasty. A half-way step would be to definite your own 'unit definition language'
You could use cPickle if you just want to save and reload units, not edit them; this might be useful for savegames.
For graphics or 3d models, a lot of game engines (Panda, pyOgre, etc) have binary-format support built in.
| 0 | 375 | true | 0 | 1 |
How to make RTS units
| 5,035,919 |
1 | 2 | 0 | 0 | 0 | 0 | 0 | 0 |
I want to create an application which needs from time to time do
file transfer (I want to write the server as well as the client).
What is the best way to do this file transfer?
Thanks in advance..
Nimmy...
| 0 |
python,file,rtp
|
2011-02-18T06:18:00.000
| 0 | 5,038,255 |
FTP Tunneled over SSH.
Use twisted and a good linux shell.
| 0 | 662 | false | 0 | 1 |
Real Time File Transfer using python script
| 5,039,698 |
1 | 1 | 1 | 0 | 1 | 1 | 1.2 | 0 |
I'm developing a game and now I want to make script system for it.
Now I have abstract class Object which is inherited by all game objects. I have to write a lot of technical code, add new object type into enum, register parser function for each object (that function parses object's params from file).
I don't want to make such work. So the idea is to get some script system (boost.python for example, because I'm using boost in my project). Each object will be a simple python-script, at c++ side I just load and run all that scripts.
Python isn't hard -typed so I can register functions, build types dynamically without storing enum, etc. The only bad part is writing a lot of binding-code but It makes only once.
Are my ideas right?
| 0 |
c++,python,boost,system
|
2011-02-19T10:57:00.000
| 0 | 5,050,372 |
Can you give us a rough idea of how large the game is going to be?
If you're not careful, you could give yourself a lot of extra work without much benefit, but with some planning it sounds like it might help. The important questions are "What parts of the program do I want to simplify?", "Do I need a scripting language to simplify them? and "Can the scripting language simplify them?".
You mentioned that you don't want to have to manually parse files. Python's pickle module could handle serialization for you, but so could .NET. If you're using Visual Studio, then you may find it easier to write the code in C# than in Python.
You should also look for ways to simplify your code without adding a new language. For example, you might be able to create a simple binary file format and store your data structures without much parsing. There are probably other things you can do, but that would require more detailed knowledge of the program.
| 0 | 203 | true | 0 | 1 |
Script system in application
| 5,055,236 |
1 | 1 | 0 | 1 | 2 | 0 | 0.197375 | 0 |
I have an old project, it written under Python 2.5/2.6, Windows.
We had Python 2.6/Win7/x64 now, and I tried to start it.
I got the old project that running nondebug mode in a server, and
copied into local folder.
When I tried to yesterday start it, I got this error:
15:44:58,038 DEBUG [pylons.configuration] Loaded None template engine
as the default template renderer
I see the google, but they are points to config.init_app, that is does
not exists.
TOday I reinstalled Python, but with Py2.7, pylons and mako.
But when I tried to stat it, I got only this message:
07:36:36,377 DEBUG [pylons.configuration] Initializing configuration,
package: 'x'
And no more information about die... :-(
So what do you meaning, how can I raise this "undead" project to debug
some things?
( it was good experience with Python/Pylons, but I'm sad now that I
not choose PHP previously, because of package changes).
Thanks:
dd
| 0 |
python,project,upgrade,pylons
|
2011-02-21T13:28:00.000
| 1 | 5,066,530 |
might be obvious but did you run "python setup.py develop" on the application package so that the dependencies could be installed?
| 0 | 68 | false | 1 | 1 |
Pylons - how to use an old project in a new environment?
| 5,067,114 |
3 | 4 | 0 | 1 | 2 | 0 | 0.049958 | 0 |
I want to get email notifications to the portal email address whenever a new user joins the portal.
My guess is that I should code a new product to do that.
Does such product already exist (for Plone 4)?
I checked content rules, but AFAICT it could work only if I made the users contentish themselves with something like membrane/remember, but for my requirements that would be overkill.
| 0 |
python,notifications,plone
|
2011-02-21T19:03:00.000
| 0 | 5,070,055 |
You can easily customize the registered.pt template add a simple call to a PythonScript sending out an email through the MailHost api.
Doing a proper customization of plone.app.users.browser.register.py is much more complex.
| 0 | 1,115 | false | 1 | 1 |
Is there an easy way in Plone to get email notifications when new users join the portal?
| 5,070,368 |
3 | 4 | 0 | 1 | 2 | 0 | 0.049958 | 0 |
I want to get email notifications to the portal email address whenever a new user joins the portal.
My guess is that I should code a new product to do that.
Does such product already exist (for Plone 4)?
I checked content rules, but AFAICT it could work only if I made the users contentish themselves with something like membrane/remember, but for my requirements that would be overkill.
| 0 |
python,notifications,plone
|
2011-02-21T19:03:00.000
| 0 | 5,070,055 |
You can also just have login_next traverse to a Controller Python Script (you'll fine other similar ones in the /plone_login area of the core Plone product that end with the extension '.cpy') that you write that sends the email (perhaps notifyMangersUponLogin ) rather than it's default of traversing to login_success.
Then, have your CPT script traverse to login_success to continue the sript/page MVC flow that Plone ships with, if that's what you want.
To leverage Controller Page Templates (.cpt files)/Scripts (.cpy files), it's key to not only copy the custom version of login_next.cpy to your custom product's skin path, but also the login.cpy.metadata file that specifies the success/failure actions of the MVC page/script logic flow.
With Plone 4.0.2, you'll find the Plone login-related scripts/templates under a path such as:
/buildout-cache/eggs/plone-4.0.2-py2.6.egg/Products/CMFPlone/skins/plone_login
relative to your buildout structure.
| 0 | 1,115 | false | 1 | 1 |
Is there an easy way in Plone to get email notifications when new users join the portal?
| 5,146,475 |
3 | 4 | 0 | 0 | 2 | 0 | 0 | 0 |
I want to get email notifications to the portal email address whenever a new user joins the portal.
My guess is that I should code a new product to do that.
Does such product already exist (for Plone 4)?
I checked content rules, but AFAICT it could work only if I made the users contentish themselves with something like membrane/remember, but for my requirements that would be overkill.
| 0 |
python,notifications,plone
|
2011-02-21T19:03:00.000
| 0 | 5,070,055 |
If you want to do it the right way, follow Martijn's directions above. If you want another dirty solution, do the following:
make a copy of register.cpy
insert the following code:
context.MailHost.send('Content-Type: text/plain\n\n' + 'User has registered: ' + str(username),
mfrom='[email protected]',
mto='[email protected]',
subject='User Registration',
)
| 0 | 1,115 | false | 1 | 1 |
Is there an easy way in Plone to get email notifications when new users join the portal?
| 5,318,895 |
1 | 2 | 0 | 0 | 1 | 0 | 1.2 | 1 |
On a host with multiple network interfaces, is it possible to bind the connect method from the Python smtplib to an specific source address?
| 0 |
python,ip-address,connect,smtplib
|
2011-02-22T03:01:00.000
| 0 | 5,073,575 |
No such option - at least not without hacking smtplib.connect() yourself.
| 0 | 984 | true | 0 | 1 |
Python smtplib: bind to specific source IP address in a machine with multiple network interfaces
| 5,073,815 |
1 | 2 | 0 | 0 | 1 | 1 | 0 | 0 |
Seems simple but I just don't know.
I'm interested in serializing a date to a string or integer and sending it from Objective-C to Python, and I want to know if there's a way I should be doing it.
Sending the integer seconds since the Unix epoch seems pretty reasonable (and NSDate supplies that readily) but does Python datetime support that?
Is there an accepted string format for dates and serialization?
| 0 |
python,objective-c,datetime,serialization,date
|
2011-02-22T23:38:00.000
| 0 | 5,085,365 |
Yes, Python supports creating Date objects from Unix epoch time (although I'm not 100% sure it's in seconds, may be in ms)
Most languages should have built-in support for Unix time, and if not it wouldn't be hard to create a function to do so.
| 0 | 125 | false | 0 | 1 |
Are there standard rules and practices for Date serialization between two languages or frameworks?
| 5,085,395 |
1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
We are having a problem with individual apache processes utilizing large amounts of memory, depending on the request, and never releasing it back to the main system. Since these requests can happen at any time, over time the web server is pushed into swap, rendering it unresponsive even to SSH. Worse, after the request has finished, Python fails to release the memory back into the wild, which results in a number 500mb - 1gb Apache processes lying around.
We push very few requests per second, but each request has the potential to be very heavy.
What I would like to do is have a way to kill an individual apache process child after it has finished serving a request if its resident memory exceeds a certain threshold. I have tried several ways of actually doing this inside mod_python, but it appears that any form of system exit results in the response not completing to the client.
Outside of gracefuling all the processes (which we really want to avoid) whenever this happens, is there anyway to tell Apache to arbitrarily kill off a process after it has finished serving a request? All ideas are welcome.
As an additional caveat, due to the legacy nature of the system, we can’t upgrade to a later version of Python, so we can’t utilize the improved memory performance of 2.5. Similarly, we are stuck with our current OS.
Versions:
System: Red Hat Enterprise 4
Apache: 2.0.55
Python: 2.3.5
| 0 |
python,apache,mod-python
|
2011-02-23T19:33:00.000
| 1 | 5,096,057 |
I'd say that even it is possible, it would be a tremendous hack (and instable) - you should set-up a process external to apache in this case, that would supervise running processes and kill an individual apache when it goes beyond memory/time predefined limits.
Such a script can be kept running continuously with a mainloop that is performs it's checks every few seconds, or could even be put in crontab to run every minute.
I see no reason to try to that from inside the serving processes themselves.
| 0 | 318 | false | 1 | 1 |
Killing individual Apache processes in mod_python
| 5,098,486 |
2 | 2 | 0 | 0 | 6 | 1 | 0 | 0 |
EDIT
Okay, rookie here so please bear with me. What I'm trying to ask is the following:
Is it plausible for a Python-syntax fan to use one of these options while other team members "plain vanilla" version? Is it a matter of personal preference, or would it require converting other people to using these technologies as well?
Is it possible to easily convert between, say, Jython and Java or Pyjamas and Javascript?
Also, in general, what advantages/disadvantages have people experienced from using these in the "real world"?
I think that states a little more clearly what I'm looking for. Input from anyone who uses these technologies in the industry would be very helpful.
Thanks in advance for your insights.
| 0 |
python,ironpython,jython,pyjamas
|
2011-02-23T22:44:00.000
| 0 | 5,098,183 |
But how does it scale?
As well as anything else. Scalability is about architecture, not language.
Anyone use these frameworks in industry?
Yes.
| 0 | 3,513 | false | 1 | 1 |
What are the advantages/disadvantages of using Jython/IronPython/Pyjamas?
| 5,099,381 |
2 | 2 | 0 | 5 | 6 | 1 | 1.2 | 0 |
EDIT
Okay, rookie here so please bear with me. What I'm trying to ask is the following:
Is it plausible for a Python-syntax fan to use one of these options while other team members "plain vanilla" version? Is it a matter of personal preference, or would it require converting other people to using these technologies as well?
Is it possible to easily convert between, say, Jython and Java or Pyjamas and Javascript?
Also, in general, what advantages/disadvantages have people experienced from using these in the "real world"?
I think that states a little more clearly what I'm looking for. Input from anyone who uses these technologies in the industry would be very helpful.
Thanks in advance for your insights.
| 0 |
python,ironpython,jython,pyjamas
|
2011-02-23T22:44:00.000
| 0 | 5,098,183 |
You are talking about two different things.
First, Jython and IronPython are Python implementations that you can embed in a Java or C# application to provide scripting capability. This reduces the amount of code that you have to write overall. Or you can look at them as a way to glue together and leverage an existing collection of class libraries. However you look at it, these are good things and lots of people use them.
But Pyjamas is something else entirely. It complicates your web stack and makes it harder to pass projects on to other programmers. The main use case is if you have a shop of Python programmers and they need to provide a rich Internet application client side but cannot afford the time to learn Javascript. Not as broadly useful.
Also, my personal experience is that most Python programmers already know Javascript reasonably well from building web apps. It really is not much of a learning curve to just dive into Javascript. I've written JSCRIPT scripts on Windows as a batch file replacement and bits of Javascript with Jquery in numerous web pages. When I wanted to learn server-side Javascript for node.js, it really only took a couple of weeks to round out my knowledge of Javascript. In my opinion, Pyjamas should be avoided. Sooner, rather than later, Javascript engines will be supporting version 1.8 of the language which greatly narrows the gap between the languages other than the curly braces issue.
| 0 | 3,513 | true | 1 | 1 |
What are the advantages/disadvantages of using Jython/IronPython/Pyjamas?
| 5,209,736 |
1 | 1 | 0 | 8 | 3 | 0 | 1.2 | 0 |
I'm trying out a new Python mode for Emacs 23, but I'm not sure how to tell if I'm using the new mode (source code located at ~/.elisp/python.el) or the bundled python.el mode.
Is there a way to find out where the current (or any active) mode was loaded from? C-h m does not seem to provide that information, and I don't know where else to look.
| 0 |
emacs,path,mode,python-mode
|
2011-02-23T22:58:00.000
| 0 | 5,098,356 |
C-hf python-mode RET will tell you which file it lives in, and you can browse to that file by following the link.
You can also use M-x find-function RET python-mode RET to go there directly.
(I find it handy to have find-function bound to C-hC-f)
In general, you could use the following:
M-: (find-function major-mode) RET
| 0 | 318 | true | 0 | 1 |
Determine path to source code of current mode in Emacs 23
| 5,098,431 |
1 | 2 | 0 | 0 | 0 | 0 | 0 | 0 |
i want to create a webservice (SOAP & REST) in python which cab be called from iphone,
now i have install python 2.7.1 on Ubuntu 10.04.2 LTS using Putty. so now i am searching for a nice and easy framework that helps me in creating webservices and web programming.
I have searched a lot but confused with the combination of framworks.
| 0 |
python,web-services,frameworks
|
2011-02-24T11:48:00.000
| 1 | 5,104,215 |
For REST, I am very satisfied with Flask.
| 0 | 931 | false | 1 | 1 |
webservices in python
| 5,104,394 |
2 | 3 | 0 | -1 | 5 | 0 | -0.066568 | 0 |
I have some Python code abstracting the database and the business logic on it. This code is already covered by unit tests but now I need to test this code against different DBs (MySQL, SQLite, etc...)
What is the default pattern for passing the same set of tests with different configurations? My goal is making sure that that abstraction layer works as expected independently of the underlying database. If that could help, I'm using nosetests for running tests but it seems that it lacks the Suite Test concept
Best regards.
| 0 |
python,database,unit-testing,nosetests
|
2011-02-24T11:53:00.000
| 0 | 5,104,276 |
Nose supports test suites just import and use unittest.TestSuite. In fact nose will happily run any tesys written using the standard lib's unittest module so tesys do not need to be written in the nose style to be discovered by the nose test runner.
However, I suspect you need morw than test suite support to do the kind of testing you are talking about but more detail about your application is necessary to really address that.
| 0 | 414 | false | 0 | 1 |
Running the same tests with different configurations
| 5,105,166 |
2 | 3 | 0 | -1 | 5 | 0 | -0.066568 | 0 |
I have some Python code abstracting the database and the business logic on it. This code is already covered by unit tests but now I need to test this code against different DBs (MySQL, SQLite, etc...)
What is the default pattern for passing the same set of tests with different configurations? My goal is making sure that that abstraction layer works as expected independently of the underlying database. If that could help, I'm using nosetests for running tests but it seems that it lacks the Suite Test concept
Best regards.
| 0 |
python,database,unit-testing,nosetests
|
2011-02-24T11:53:00.000
| 0 | 5,104,276 |
use --attrib plugin, and in the commadn line
1. nosetests -s -a 'sqlite'
2. nosetests -s -a 'mysql'
| 0 | 414 | false | 0 | 1 |
Running the same tests with different configurations
| 6,515,097 |
2 | 2 | 0 | 0 | 0 | 0 | 0 | 0 |
When creating zip archive using python ZipFile, how can i set file mime types?
| 0 |
python,mime,zip
|
2011-02-25T17:31:00.000
| 0 | 5,120,558 |
This question does not make any sense. Files are stored as binary content inside the ZIP archive together with the filesize (and flags afaik). But there is absolutely no mimetype information involved here.
| 0 | 1,396 | false | 0 | 1 |
Set ZipInfo mime type
| 5,120,702 |
2 | 2 | 0 | 3 | 0 | 0 | 1.2 | 0 |
When creating zip archive using python ZipFile, how can i set file mime types?
| 0 |
python,mime,zip
|
2011-02-25T17:31:00.000
| 0 | 5,120,558 |
The ZIP format doesn't carry MIME content-type for the individual files contained in the archive, though the ZIP format itself has a MIME content-type: application\zip.
The only way you've got to determine the appropriate MIME content-type for a file contained in a ZIP archive is by examination of the file name and using its file extension to determine the likely MIME content-type.
| 0 | 1,396 | true | 0 | 1 |
Set ZipInfo mime type
| 5,120,648 |
1 | 1 | 0 | 4 | 1 | 0 | 1.2 | 0 |
I want use send_mass_mail() in django and then want receive list of delivery mail
list with email address and problem for failed or delivered ok status
how i can make this modules ?
| 0 |
python,django,email,smtp,email-confirmation
|
2011-02-26T06:58:00.000
| 0 | 5,125,544 |
List of delivered emails is outside of the scope of Django, which is a web framework and not a replacement for services like Mailchimp.
| 0 | 415 | true | 1 | 1 |
receive delivery list of send mail in django
| 5,126,778 |
1 | 5 | 0 | 0 | 13 | 0 | 0 | 0 |
I would to pick up a new programming language - Java, having been using Python for some time. But it seems most things that can be done with Java can be done with Python. So I would like to know
What kind of things can be done with Java but not Python?
mobile programming (Android).
POSIX Threads Programming.
Conversely, What kind of things can be done with Python but not Java if any?
clarification:
I hope to get an answer from a practical point of view but not a theoretical point of view and it should be about the current status, not future. So theoretically all programming languages can perform any task, practically each is limited in some way.
| 0 |
java,python,programming-languages
|
2011-02-26T10:26:00.000
| 0 | 5,126,346 |
CPython has a lot of libraries with bindings to native libraries--not so Java.
| 0 | 13,215 | false | 1 | 1 |
What kind of things can be done with Java but not Python?
| 5,126,443 |
1 | 1 | 0 | 0 | 2 | 1 | 1.2 | 0 |
Am just curious and wondering why it takes longer for python code to execute when run from inside Stani Python Editor in comparison to when run from IDLE or the terminal or even inside gvim.
| 0 |
python,performance
|
2011-02-26T14:43:00.000
| 0 | 5,127,521 |
SPE has an object explorer, and debugger. Maybe these slow things down a bit.
| 0 | 177 | true | 0 | 1 |
Performance of running code in stani python editor vs IDLE/terminal/gvim
| 5,128,723 |
3 | 7 | 0 | 39 | 68 | 0 | 1 | 0 |
Why do we need RabbitMQ when we have a more powerful network framework in Python called Twisted. I am trying to understand the reason why someone would want to use RabbitMQ.
Could you please provide a scenario or an example using RabbitMQ?
Also, where can I find a tutorial on how to use RabbitMQ?
| 0 |
python,django,twisted,rabbitmq
|
2011-02-27T10:26:00.000
| 0 | 5,132,648 |
Let me tell you a few reasons that makes using MOM (Message Oriented Middleware) probably the best choice.
Decoupling:
It can decouple/separate the core components of the application. There is no need to bring all the benefits of the decoupled architecture here. I just want to point it out that this is one of the main requirement of writing a quality and maintainable software.
Flexibility:
It is actually very easy to connect two totally different applications written on different languages together by using AMQP protocol. These application will talk to each other by the help of a "translator" which is MOM.
Scalability:
By using MOM we can scale the system horizontally. One message producer can transmit to unlimited number of message consumers a task, a command or a message for processing and for scaling this system all we need to do is just create new message consumers. Lets say we are getting 1000 pictures per second and we must resize them. Solving this problem with traditional methods could be a headache. With MOM we can transmit images to the message consumers which can do their job asynchronously and make sure data integrity is intact.
They are other benefits of using MOM as well but these 3 are the most significant in my opinion.
| 0 | 20,812 | false | 0 | 1 |
Why do we need to use rabbitmq
| 19,206,575 |
3 | 7 | 0 | 6 | 68 | 0 | 1 | 0 |
Why do we need RabbitMQ when we have a more powerful network framework in Python called Twisted. I am trying to understand the reason why someone would want to use RabbitMQ.
Could you please provide a scenario or an example using RabbitMQ?
Also, where can I find a tutorial on how to use RabbitMQ?
| 0 |
python,django,twisted,rabbitmq
|
2011-02-27T10:26:00.000
| 0 | 5,132,648 |
RabbitMQ is a bit more than mere messaging... It's a common platform that has ability to inter-connect applications. Using RabbitMQ a Java application can speak to a Linux server and/or a .NET app, to a Ruby & rails + almost anything that finds its place in the corporate web development. And most importantly it implements the "fire and forget" model proposed by AMQP. Its just a perfect replacement for JMS or ESB, especially if you are dealing with cross platform architecture, with a guaranty of reliability. There is even a special feature called RPC (Remote procedure call) that adds to the ease of development in the distributed arch.
Apart from all these, in the world financial services like Stock-exchange or share-market where a lot of reliable and efficient routing is required (suppose you don't know the actual number of people subscribed to your services, but want to ensure that who ever does so, receives your pings whether they are connected in this moment, or will connect later), RabbitMQ rules because it's based on ERLANG & the Open-telecom platform that assures high performance while using minimum resources. For the most convenient introduction to RabbitMQ, see rabbitmq.com/getstarted.html for your native development language.
| 0 | 20,812 | false | 0 | 1 |
Why do we need to use rabbitmq
| 27,416,485 |
3 | 7 | 0 | 14 | 68 | 0 | 1 | 0 |
Why do we need RabbitMQ when we have a more powerful network framework in Python called Twisted. I am trying to understand the reason why someone would want to use RabbitMQ.
Could you please provide a scenario or an example using RabbitMQ?
Also, where can I find a tutorial on how to use RabbitMQ?
| 0 |
python,django,twisted,rabbitmq
|
2011-02-27T10:26:00.000
| 0 | 5,132,648 |
Twisted is not a queue implementation. Apart from that RabbitMQ offers enterprise-level queuing features and implements the AMQP protocol which is often needed in an enterprise world.
| 0 | 20,812 | false | 0 | 1 |
Why do we need to use rabbitmq
| 5,132,740 |
1 | 2 | 0 | 1 | 2 | 0 | 0.099668 | 0 |
I'm wondering if someone could help guide the approach to this fairly common problem:
I'm building a simple site which a user connects their twitter account to sign up. I'd like to create an interface which shows them which of their twitter friends are already using the site.
So I can get a list the user's twitter friends, and a list of the site's users (which all have the twitter screen name as username, but I'm wondering the most efficient method to compare these lists and create a variable with the commonalities.
As an aside, given the Twitter API returns IDs, should I save the twitter user's ID (in addition to their username) when they create an account?
Thanks in advance!
| 0 |
python,django,twitter
|
2011-02-28T00:32:00.000
| 0 | 5,137,126 |
You should store the twitter user's ID because the username can change at any time, but the id will always be the same. You should be comparing the id's, not the usernames in the intersection_set that Ofri recommends.
| 0 | 323 | false | 1 | 1 |
Comparing user's facebook/twitter friends to site's users in Python/Django
| 5,137,217 |
1 | 2 | 0 | 1 | 0 | 0 | 0.099668 | 0 |
I'm a PHP programmer. What module can I use in Python to do the same that cURL does?
Best Regards,
| 0 |
python,curl
|
2011-02-28T14:36:00.000
| 0 | 5,143,325 |
you can do the same stuff with urllib2, pycurl hasn't been updated in a while, so I wouldn't recommend it. Especially on Windows. Always better to use a native module rather than a 3rd party plugin
| 0 | 602 | false | 0 | 1 |
What module to use in Python to do the same as cURL in Php?
| 5,143,397 |
3 | 4 | 0 | 4 | 1 | 1 | 0.197375 | 0 |
A problem I frequently run into when using Python, R, Matlab etc. is installing packages or libraries when I don't have admin privileges on the server I'm using. I was wondering if there is a way to get around this?
I was thinking of "installing" the libraries somewhere in my own account, and adding that directory to my path, rather than somewhere like /usr/bin, /usr/lib etc. Does anyone have any tips / pointers on this? This must be a frequent problem for college / graduate students.
Thanks!
| 0 |
python,r,matlab,installation,administrator
|
2011-02-28T18:13:00.000
| 0 | 5,145,846 |
For R you can do install.packages("foo",lib="~/R/") - create the directory ~/R/ first - and then the packages will install there. Then do library(foo,lib="~/R/") to load it.
You can use the .libPaths function in your R startup files to add this automatically. Most of the Ubuntu boxes I've used are set up something like this by default. If a plain user tries to install a package it goes into their ~/R/ library, if root tries to do it, it goes into a site library for everyone.
Since generally there's no point backing up these installed packages, I tend to put my ~/R/ library on a non-backed up part of my filesystem.
[Note the correct use of 'library' here - in R-speak a library is a place where packages are installed]
| 0 | 1,195 | false | 0 | 1 |
Install Python / Matlab libraries without admin priviledges?
| 5,148,866 |
3 | 4 | 0 | 0 | 1 | 1 | 0 | 0 |
A problem I frequently run into when using Python, R, Matlab etc. is installing packages or libraries when I don't have admin privileges on the server I'm using. I was wondering if there is a way to get around this?
I was thinking of "installing" the libraries somewhere in my own account, and adding that directory to my path, rather than somewhere like /usr/bin, /usr/lib etc. Does anyone have any tips / pointers on this? This must be a frequent problem for college / graduate students.
Thanks!
| 0 |
python,r,matlab,installation,administrator
|
2011-02-28T18:13:00.000
| 0 | 5,145,846 |
In python you can do python setup.py install --user or pip install --user foo. This will install it in a user-specific directory appropriate for your platform.
| 0 | 1,195 | false | 0 | 1 |
Install Python / Matlab libraries without admin priviledges?
| 30,807,406 |
3 | 4 | 0 | 0 | 1 | 1 | 0 | 0 |
A problem I frequently run into when using Python, R, Matlab etc. is installing packages or libraries when I don't have admin privileges on the server I'm using. I was wondering if there is a way to get around this?
I was thinking of "installing" the libraries somewhere in my own account, and adding that directory to my path, rather than somewhere like /usr/bin, /usr/lib etc. Does anyone have any tips / pointers on this? This must be a frequent problem for college / graduate students.
Thanks!
| 0 |
python,r,matlab,installation,administrator
|
2011-02-28T18:13:00.000
| 0 | 5,145,846 |
In Matlab you typically can just download the m files anywhere you like, and then add their location to the path. Not sure but I would suspect that getting a complete toolbox may require admin rights but for anything less you should be fine.
To conveniently add the location to your path automatically when you run matlab you can edit startup.m
| 0 | 1,195 | false | 0 | 1 |
Install Python / Matlab libraries without admin priviledges?
| 14,704,458 |
2 | 5 | 0 | 0 | 2 | 0 | 0 | 0 |
I love Python and Ruby equally and I simply cannot standardize on one. I love Heroku, but it can get a speck pricey and is totally specific to Rails.
Is there a decently inexpensive host, or many, that adequately supports both Ruby and Python frameworks as well as offering common LAMPish support?
Yeah... I wanna know if I can just have it all for cheap (sigh).
I'm mostly interested in this for development and startups... scalability is not a big deal, but very welcome.
| 0 |
python,ruby,django,apache,ruby-on-rails-3
|
2011-03-01T00:12:00.000
| 0 | 5,149,127 |
I use rackspace, it's 10$ /month for the basic setup, they just give you a clean install of whatever OS you want so it will support any packages/configurations you choose to install.
| 0 | 1,466 | false | 1 | 1 |
Good Web hosts that support Ruby and Python?
| 5,149,250 |
2 | 5 | 0 | 0 | 2 | 0 | 0 | 0 |
I love Python and Ruby equally and I simply cannot standardize on one. I love Heroku, but it can get a speck pricey and is totally specific to Rails.
Is there a decently inexpensive host, or many, that adequately supports both Ruby and Python frameworks as well as offering common LAMPish support?
Yeah... I wanna know if I can just have it all for cheap (sigh).
I'm mostly interested in this for development and startups... scalability is not a big deal, but very welcome.
| 0 |
python,ruby,django,apache,ruby-on-rails-3
|
2011-03-01T00:12:00.000
| 0 | 5,149,127 |
I'm in accordance with elithrar. I switched to webfaction and I'm very happy with the change. They've a very good support (I got answers in less than half hour for my problems/questions) and when my question is got by one of the IT guys, the same guy cares about all the subsequent communications until problem, doubts are resolved.
They're cheap too and have very good support to do almost anythong you could need. Just compile what you need and install it in your home by ssh access and ready to go.
I'm not from webfaction, but this is my experience with them.
Hope this could help you.
| 0 | 1,466 | false | 1 | 1 |
Good Web hosts that support Ruby and Python?
| 5,149,489 |
1 | 2 | 0 | 0 | 0 | 0 | 0 | 1 |
Are there libraries for email message parsing (particularly, from Gmail's IMAP server) in Python (except for the standard email library)?
Or if not, maybe there is some C++ library for this purpose (and I'll be able to use it through SWIG)?
| 0 |
python,email
|
2011-03-01T15:17:00.000
| 0 | 5,156,422 |
This question does not make sense. You can access GMail either using IMAP or POP3.
And for parsing retrieved emails you use the 'email' module of Python. Python provides support for all this out-of-the-box "all batteries included".
| 0 | 909 | false | 0 | 1 |
python: libraries for parsing email
| 5,156,532 |
3 | 6 | 0 | 1 | 1 | 0 | 0.033321 | 0 |
I want to embark on learning a totally new language for web back-end development and I've narrowed down my choice between these three:
GWT
Ruby
Python
Do you know or recommend of any sites that walks you through building a simple site using these technologies that could be easily deployed and tested?
By the way, I am running a Windows OS, so please let me know if there is anything I may need to configure on my machine to start learning these tools.
On the front end side of development, I would also like to see some samples that greatly exemplifies being able to use the technologies in its full potentials.
Totally appreciate your suggestions and responses. Thank you.
Angelo
| 0 |
python,ruby,gwt
|
2011-03-01T15:24:00.000
| 0 | 5,156,496 |
GWT is really a frontend development technology. It includes components that make it play nice with the backend, but it is primarily a UI framework.
| 0 | 3,022 | false | 1 | 1 |
GWT or Python or Ruby for Web Development
| 5,156,600 |
3 | 6 | 0 | 0 | 1 | 0 | 0 | 0 |
I want to embark on learning a totally new language for web back-end development and I've narrowed down my choice between these three:
GWT
Ruby
Python
Do you know or recommend of any sites that walks you through building a simple site using these technologies that could be easily deployed and tested?
By the way, I am running a Windows OS, so please let me know if there is anything I may need to configure on my machine to start learning these tools.
On the front end side of development, I would also like to see some samples that greatly exemplifies being able to use the technologies in its full potentials.
Totally appreciate your suggestions and responses. Thank you.
Angelo
| 0 |
python,ruby,gwt
|
2011-03-01T15:24:00.000
| 0 | 5,156,496 |
@Finbarr...but it contains a full fledged Java Servlet Backend.
And this is probably why I'd suggest you to use RoR or Django or something too cook up a simple website.
GWT Applications are usually made of Server components written in Java and Client Side code (mostly JavaScript) that has been generated from Java. Ususally GWT is not what you want for a simple company website.
| 0 | 3,022 | false | 1 | 1 |
GWT or Python or Ruby for Web Development
| 5,156,700 |
3 | 6 | 0 | 0 | 1 | 0 | 0 | 0 |
I want to embark on learning a totally new language for web back-end development and I've narrowed down my choice between these three:
GWT
Ruby
Python
Do you know or recommend of any sites that walks you through building a simple site using these technologies that could be easily deployed and tested?
By the way, I am running a Windows OS, so please let me know if there is anything I may need to configure on my machine to start learning these tools.
On the front end side of development, I would also like to see some samples that greatly exemplifies being able to use the technologies in its full potentials.
Totally appreciate your suggestions and responses. Thank you.
Angelo
| 0 |
python,ruby,gwt
|
2011-03-01T15:24:00.000
| 0 | 5,156,496 |
I would personally go with Python/Django (you can get nice overview of the technology on djangobook.com) but Ruby/Rails is probably equally good.
And about GWT ... hmm we are about to start GWT project at work and I am really scared. Code looks terrible bloated , generated HTML is huge , performance can be a problem and no SEO.
| 0 | 3,022 | false | 1 | 1 |
GWT or Python or Ruby for Web Development
| 5,164,844 |
1 | 1 | 1 | 1 | 3 | 0 | 0.197375 | 0 |
I started using SWIG on a huge C++ library (made of of several inter-dependent static libs) to expose it to python. This library defines many primitive classes that are used throughout as parameters (images of different types for example). There is extensive use of STL, inheritance and templating in the lib as well.
So far I have a minimal portion of the lib usable from Python but would like to progressively add the remaining 90+%.
For my part, working with SWIG is really no fun: Battling with template instantiations, learning all that SWIG syntax and keywords, etc. I recently played a bit with CTypes and found it so enjoyable that I am now considering writing an extern C interface for the whole library instead of using SWIG.
I would rather be coding in C/C++ and/or Python than learning an obscure set of SWIG commands (that counts for SIP also).
There are quite a few questions out there already asking similar advice so I'll add something new and specific:
I would like for the library's internal images classes to be visible from python as PIL images transparently, not as SWIG-Wrapped native classes. Will I have to resort to the plain-old Python External API to accomplish that?
I welcome any and all advice!
| 0 |
c++,python,python-imaging-library
|
2011-03-01T21:03:00.000
| 0 | 5,160,308 |
Have you considered looking into using Boost.Python?
| 0 | 982 | false | 0 | 1 |
Exposing C++ library to Python + PIL
| 5,161,325 |
3 | 5 | 0 | 1 | 24 | 0 | 0.039979 | 0 |
Is there a way of writing Python embedded in HTML like I do with PHP or JSP?
| 0 |
python,html
|
2011-03-02T14:10:00.000
| 0 | 5,168,588 |
Use Cheetah or another templating engine.
| 0 | 41,257 | false | 1 | 1 |
Can Python be embedded in HTML like PHP and JSP?
| 5,168,637 |
3 | 5 | 0 | 7 | 24 | 0 | 1 | 0 |
Is there a way of writing Python embedded in HTML like I do with PHP or JSP?
| 0 |
python,html
|
2011-03-02T14:10:00.000
| 0 | 5,168,588 |
There is... But you're highly suggested to use a templating engine, or some other means of separating the presentation from the business layer.
There are some available that use python as the templating language, but it's nasty because python is sensitive to whitespace, so special syntax hacks have to be added.
| 0 | 41,257 | false | 1 | 1 |
Can Python be embedded in HTML like PHP and JSP?
| 5,168,640 |
3 | 5 | 0 | 2 | 24 | 0 | 0.07983 | 0 |
Is there a way of writing Python embedded in HTML like I do with PHP or JSP?
| 0 |
python,html
|
2011-03-02T14:10:00.000
| 0 | 5,168,588 |
Several templating engines support this in one way or another: Mako, Jinja, and Genshi are all popular choices.
Different engines support different features of Python and may be better suited to your needs. Your best bet is to try them out and see what works.
| 0 | 41,257 | false | 1 | 1 |
Can Python be embedded in HTML like PHP and JSP?
| 5,168,647 |
1 | 1 | 0 | 3 | 2 | 0 | 0.53705 | 0 |
While trying to get a python application to talk to a C++ application using an encrypt link, we could not get them to talk. Trying various combinations of parameters we accidentally found that if we told python to encrypt in OFB mode it would successfully decrypt in the C++ in CFB mode.
Both the python pycrypt library and the C++ Gladman library are highly regarded, so which could be wrong?
Strangely, the first byte seems to decrypt OK when using either OFB or CFB at both ends. Since the standard test vectors only seem to test the first byte (I'm not an expert on this stuff and might not be understanding the test vectors), is it possible that both algorithms would pass the standard test?
| 0 |
c++,python,encryption,aes
|
2011-03-02T16:29:00.000
| 0 | 5,170,442 |
PyCrypto uses 8-bit CFB mode by default. I guess the other end uses block-size CFB mode. The segment size in bits is set by the segment_size keyword argument to AES.new, for block-size CFB mode it should be AES.block_size*8.
For the first block OFB mode is identical to block-size CFB mode.
| 0 | 1,060 | false | 0 | 1 |
AES encryption problem: Python pycrypt OFB = C++ Gladman CFB
| 5,171,081 |
1 | 2 | 0 | 1 | 1 | 0 | 0.099668 | 0 |
First, sorry for my bad English.
I'm writing a python script, which compares the files in two different directories. But for performance, I want to know that: "Are the directories on the same physical disk or not?", so I can read them simultaneously for performance gain.
My current idea is getting "mount" commands output, and getting the /dev/sd* directories path and use them for identify the disks. But sometimes you can mount an already mounted directory on somewhere else(or something like that, i'm not so sure), so things get complicated.
Is there a better way to do that, like a library?
(If there is a cross-platform way, I will be more appreciated, but it seems it's hard to find a cross-platform library like this.)
| 0 |
python,linux
|
2011-03-02T18:05:00.000
| 1 | 5,171,511 |
An easier alternative to using mount might be to invoke df <directory>.
This prints out the filesystem. Also, on my Ubuntu box, passing -P to df makes the output a little bit easier to parse.
| 0 | 515 | false | 0 | 1 |
Learning the directory's physical disk on Linux with Python
| 5,171,542 |
2 | 4 | 0 | 1 | 2 | 0 | 0.049958 | 0 |
what happens to my script in python that does not run through crontab every minute.
My script has execute permissions and then calls two other scripts in python.
This is the content of my crontab (#crontab -l):
*/1 * * * * /usr/bin/rsm/samplesMonitor.py
Thank you guys.
| 0 |
python,cron,execution,crontab
|
2011-03-02T22:00:00.000
| 1 | 5,174,080 |
I believe it should be */1, not *\1.
| 0 | 7,385 | false | 0 | 1 |
python script execution through crontab
| 5,174,130 |
2 | 4 | 0 | 0 | 2 | 0 | 0 | 0 |
what happens to my script in python that does not run through crontab every minute.
My script has execute permissions and then calls two other scripts in python.
This is the content of my crontab (#crontab -l):
*/1 * * * * /usr/bin/rsm/samplesMonitor.py
Thank you guys.
| 0 |
python,cron,execution,crontab
|
2011-03-02T22:00:00.000
| 1 | 5,174,080 |
It should be */1 instead of *\1 (forward slash instead of backslash). Also, make sure the path is correct; there usually are no subdirectories under /usr/bin.
| 0 | 7,385 | false | 0 | 1 |
python script execution through crontab
| 5,174,140 |
1 | 3 | 0 | 0 | 3 | 0 | 0 | 0 |
I have 10,000 binary files, named like this:
file0.bin
file1.bin
............
............
file10000.bin
Each of the above files contains exactly 391 float values (1564 bytes per file).
my goal is to read all of the files into a python array in the fastest way possible. If I open & close each file using a script, it takes a lot of time (about 8min!).
are there any other creative ways to read these files FAST?
I am using Ubuntu Linux and would prefer a solution that can work with Python. Thanks.
| 0 |
python,linux
|
2011-03-03T23:00:00.000
| 1 | 5,187,705 |
Iterate over them and use optimise flag you might also want to parse them using pypy it compiles python via a JIT compiler allowing for a somewhat marked increase in speed.
| 0 | 669 | false | 0 | 1 |
Fast Reading of 10000 Binary Files?
| 5,187,734 |
2 | 2 | 0 | 0 | 1 | 0 | 0 | 0 |
So I have been developing my first website. I have a cgi script that allows users to sign up for e-mail updates. However, I don't trust the security of cgi-bin with the api-key I am using to sign people up to a mailing list. So I put the api-key in another folder in home with chmod 711 on the directory (as opposed to 755 on the cgi-bin directory). I then import the api-key into the python cgi script. With something like:
sys.append.path("/home/otherfolder")
import apikeyfile
Does this actually provide any extra security to my script? Is there something else I should be doing instead?
| 0 |
python,cgi,security
|
2011-03-05T00:09:00.000
| 0 | 5,200,635 |
This is a good idea. chmod 500 is better in this case. The rule of th You have to have the most restrictive privileges as possible. Keep in mind your app might hacked and then you don't want your app to write to its self. (unless it has too...)
| 0 | 227 | false | 0 | 1 |
Basic python cgi security question: Storing sensitive information in another directory
| 5,200,797 |
2 | 2 | 0 | 0 | 1 | 0 | 0 | 0 |
So I have been developing my first website. I have a cgi script that allows users to sign up for e-mail updates. However, I don't trust the security of cgi-bin with the api-key I am using to sign people up to a mailing list. So I put the api-key in another folder in home with chmod 711 on the directory (as opposed to 755 on the cgi-bin directory). I then import the api-key into the python cgi script. With something like:
sys.append.path("/home/otherfolder")
import apikeyfile
Does this actually provide any extra security to my script? Is there something else I should be doing instead?
| 0 |
python,cgi,security
|
2011-03-05T00:09:00.000
| 0 | 5,200,635 |
This isn't a Python question (the fact that you're using Python is totally incidental), but the answer is: yeah, it's a good idea to have your sensitive data in a place where your Web server can't, even if somewhat misconfigured, send it to an attacker. So outside of whatever directory hierarchy your Web documents and scripts are in. It won't stop an attacker if they root your server, but a lot of exploits don't require root, and so putting as many obstacles in the way of a hacker as possible is considered good pracitce. (This is called "defense in depth" by network security wonks.)
| 0 | 227 | false | 0 | 1 |
Basic python cgi security question: Storing sensitive information in another directory
| 5,200,769 |
2 | 7 | 0 | 0 | 1 | 1 | 0 | 0 |
How to check for a string that for every character in it, there exists all the characters which are alphabetically smaller than it before it e.g aab is correct while aacb is not, because the second case, we have 'c' but 'b' is not present before it.
Also aac is not correct as it does not have 'b' before 'c'.
| 0 |
python,algorithm,string
|
2011-03-05T07:22:00.000
| 0 | 5,202,362 |
I believe to understand your question correctly, and here is my attempt at answering it, if I have mis-understood please correct me.
The standard comparisons (<, <=, >, >=, ==, !=) apply to strings. These comparisons use the standard character-by-character comparison rules for ASCII or Unicode. That being said, the greater and less than operators will compare strings using alphabetical order.
| 0 | 155 | false | 0 | 1 |
a string that for every character in it, there exists all the characters which are alphabetically smaller than it before it
| 5,202,394 |
2 | 7 | 0 | 0 | 1 | 1 | 0 | 0 |
How to check for a string that for every character in it, there exists all the characters which are alphabetically smaller than it before it e.g aab is correct while aacb is not, because the second case, we have 'c' but 'b' is not present before it.
Also aac is not correct as it does not have 'b' before 'c'.
| 0 |
python,algorithm,string
|
2011-03-05T07:22:00.000
| 0 | 5,202,362 |
The idea is very simple, for each char in the string, it should not less than its preceding, and it shouldn't larger than its preceding + 1.
| 0 | 155 | false | 0 | 1 |
a string that for every character in it, there exists all the characters which are alphabetically smaller than it before it
| 5,202,661 |
2 | 3 | 0 | 0 | 2 | 0 | 0 | 0 |
I'm writing a script in Python that saves attachments from Gmail, only from unseen emails. To save on bandwidth I want to make sure that every file only gets downloaded once.
-I can't check the folder where I save them, because the file could be removed already, and then it shouldn't download again. (The scripts accesses the Inbox read_only, so it doesn't mark the email as read. As soon as the script runs again it will download the same attachments again, until the email gets marked read via another channel.)
-Right now I save the filename to a sqlite database, but there's 2 problems: I haven't figured out how to check the database for the filename the next time I run the script, and there's also a chance that somewhen down the line an attachment arrives with the same filename, which then wouldn't get downloaded.
What's a safe and scalable way to make sure I don't download the files more than once?
| 0 |
python,imaplib
|
2011-03-05T14:19:00.000
| 0 | 5,204,339 |
You could fetch the headers for the message, and use the message's Date and/or Message-Id header value to construct a "unique id prefix" for all of the attachments in that message. Then create a key of the form [unique_id]_[filename], check if that key exists in your database or filesystem. If not, download all attachments for that message, and save each with the modified unique id key.
| 0 | 292 | false | 0 | 1 |
Way to avoid downloading file twice via IMAP
| 5,204,450 |
2 | 3 | 0 | 0 | 2 | 0 | 1.2 | 0 |
I'm writing a script in Python that saves attachments from Gmail, only from unseen emails. To save on bandwidth I want to make sure that every file only gets downloaded once.
-I can't check the folder where I save them, because the file could be removed already, and then it shouldn't download again. (The scripts accesses the Inbox read_only, so it doesn't mark the email as read. As soon as the script runs again it will download the same attachments again, until the email gets marked read via another channel.)
-Right now I save the filename to a sqlite database, but there's 2 problems: I haven't figured out how to check the database for the filename the next time I run the script, and there's also a chance that somewhen down the line an attachment arrives with the same filename, which then wouldn't get downloaded.
What's a safe and scalable way to make sure I don't download the files more than once?
| 0 |
python,imaplib
|
2011-03-05T14:19:00.000
| 0 | 5,204,339 |
You could not only save the filename to the database but save, for example, the Date:-header of the mail, too. (Or any combination of headers of which you are sure that they define a mail uniquely).
| 0 | 292 | true | 0 | 1 |
Way to avoid downloading file twice via IMAP
| 5,204,367 |
1 | 1 | 0 | 0 | 0 | 0 | 1.2 | 1 |
I have little working knowledge of python. I know that there is something called a Twitter search API, but I'm not really sure what I'm doing. I know what I need to do:
I need point data for a class. I thought I would just pull up a map of the world in a GIS application, select cities that have x population or larger, then export those selections to a new table. That table would have a key and city name.
next i randomly select 100 of those cities. Then I perform a search of a certain term (in this case, Gaddafi) for each of those 100 cities. All I need to know is how many posts there were on a certain day (or over a few days depending on amount of tweets there were).
I just have a feeling there is something that already exsists that does this, and I'm having a hard time finding it. I've dowloaded and installed python-twitter but have no idea how to get this search done. Anyone know where I can find or how I can make this tool? Any suggestions would really help. Thanks!
| 0 |
python,api,twitter
|
2011-03-06T06:00:00.000
| 0 | 5,209,003 |
A tweet itself comes with a geo tag. But it is a new feature and majority tweets do not have it. So it is not possible to search for all tweets containing "Gaddafi" from a city given the city name.
What you could do is the reverse, you search for "Gaddafi" first (regardless of geo location), using search api. Then, for each tweet, find the location of the poster (either thru the RESTful api or use some sort of web scraping).
so basically you can classify the tweets collected according to the location of the poster.
I think only tweepy have access to both twitter search API as well as RESTful API.
| 0 | 268 | true | 0 | 1 |
Performing multiple searches of a term in Twitter
| 5,209,588 |
1 | 3 | 0 | 0 | 6 | 0 | 0 | 0 |
I'd like to ask you about your experiences in developing facebook applications in Python. Which of the popular web frameworks for this language you think best suits this purpose? I know "best" is a very subjective word, so I'm specifically interested in the following:
Most reusable libraries. For example one might want to automatically create accounts for new logged in facebook users, but at the same time provide an alternative username + password logging functionality. I need authentication to fit into this nicely.
Facebook applications tend to differ from CMS-like sites. They are action intensive. For more complicated use-cases, usually some kind of caching for the data fetched from Open Graph API is required in order to be able to perform some queries on local and facebook data at once (for example join some tables based on friendship relation).
I'd definitely prefer popular solutions. They just seem to be much more stable and better thought through. I've previously developed a facebook application in Grails and I as much as I liked the architecture and the general ideas, the amount of bugs and complication that I ran into was just a little bit too much. Also Groovy is still quite an exotic language to develop in, and this time I'm not going to work on my own.
I'm not new to Python, but definitely new to web development in Python. Though after the experience with Grails and all its twists and turns I doubt Python could really scare me.
| 0 |
python,facebook
|
2011-03-06T13:13:00.000
| 0 | 5,210,692 |
If you do not want to start on Django now. Try learning Flask(which is comparatively a lot easier to begin than Django) and then start building app with Flask.
| 0 | 2,182 | false | 1 | 1 |
Python frameworks for developing facebook apps
| 23,464,883 |
1 | 3 | 0 | 0 | 2 | 0 | 0 | 0 |
Is it possible to programmatically detect dependencies given a python project residing in SVN?
| 0 |
python,svn,dependencies,detection
|
2011-03-07T02:27:00.000
| 0 | 5,215,195 |
Absolutely! If you are working from a UNIX or Linux shell, a simple combination of grep and awk would work; basically, all you want to do is search for lines containing the "import" keyword.
However, if you are working from any environment, you could just write a small Python script to do the searching for you (don't forget that strings are treated as immutable sequences, so you can do something like if "import" in line: ....
The one sticky spot, would be associating those imported modules to their package name (the first one that comes to mind is the PIL module, in Ubuntu it's provided by the python-imaging package).
| 0 | 1,336 | false | 0 | 1 |
Python dependencies?
| 5,215,273 |
1 | 2 | 0 | 8 | 4 | 1 | 1.2 | 0 |
I am automatically generating unit tests for some Python code which number in the thousands. The unittest module uses classes to contain the tests however I'm guessing there is an upper limit to the number of methods a class may contain - is this the case?
| 0 |
python,unit-testing,class,methods
|
2011-03-08T01:03:00.000
| 0 | 5,227,198 |
Methods (and in fact all attributes) of a class are stored in a dict. There is no limit to the number of items a dict can contain, save that each key must be unique.
| 0 | 1,932 | true | 0 | 1 |
What is the maximum number of methods on a Python class?
| 5,227,226 |
4 | 12 | 0 | 0 | 8 | 1 | 0 | 0 |
I want to know what exactly is lambda in python? and where and why it is used.
thanks
| 0 |
python,lambda
|
2011-03-08T14:04:00.000
| 0 | 5,233,508 |
lambda is an anonymous function, usually used for something quick that needs computing.
Example (This is used in a LexYacc command parser):
assign_command = lambda dictionary, command: lambda command_function: dictionary.setdefault(command, command_function)
This is a decorator. Put before a command we'd have from the LexYacc parser:
@assign_command(_command_handlers, 'COMMAND')
This essentially builds a python script from the LexYacc language defined.
Or, a bit simpler:
`x = lambda x: return x > 0 and x & (x-1) == 0
| 0 | 3,299 | false | 0 | 1 |
What exactly is "lambda" in Python?
| 5,233,599 |
4 | 12 | 0 | 5 | 8 | 1 | 0.083141 | 0 |
I want to know what exactly is lambda in python? and where and why it is used.
thanks
| 0 |
python,lambda
|
2011-03-08T14:04:00.000
| 0 | 5,233,508 |
Lambdas are not anonymous functions. Lambdas are anonymous expressions.
They're accessed like functions, but they're not the same thing. Functions allow complex tasks: flow control, variable declarations and lists of statements containing expressions. Expressions are merely one part of a function, and that's what lambdas give you. They're severely limited compared to functions.
Python does not support anonymous functions. For examples of languages that do, see Javascript and Lua.
(Note: It's correct to call lambdas anonymous functions in functional languages, where the mathematical definition of "function" is used, but in procedural languages the word has a very different meaning than in mathematics.)
| 0 | 3,299 | false | 0 | 1 |
What exactly is "lambda" in Python?
| 5,233,898 |
4 | 12 | 0 | 0 | 8 | 1 | 0 | 0 |
I want to know what exactly is lambda in python? and where and why it is used.
thanks
| 0 |
python,lambda
|
2011-03-08T14:04:00.000
| 0 | 5,233,508 |
It's an inline anonymous function.
| 0 | 3,299 | false | 0 | 1 |
What exactly is "lambda" in Python?
| 5,233,587 |
4 | 12 | 0 | 0 | 8 | 1 | 0 | 0 |
I want to know what exactly is lambda in python? and where and why it is used.
thanks
| 0 |
python,lambda
|
2011-03-08T14:04:00.000
| 0 | 5,233,508 |
I would like to explain this with a little layman approach in terms of the usage perspective, since all the technical points are already covered.
A lambda function is just like any other function, only thing that makes it different (other than the syntax and the fact that it can't be reused), is that it is used when we want to quickly write a function which takes an argument and just returns a value using only one expression.
For instance:
If all that a function does is take a argument and add 1 to it then using a lambda function is a better approach than a normal function.
But if your function requires more than one line of processing before returning the value, then we need to use a normal function definition and then call it.
| 0 | 3,299 | false | 0 | 1 |
What exactly is "lambda" in Python?
| 71,792,193 |
1 | 8 | 0 | 0 | 14 | 0 | 0 | 1 |
I would like to send email through a proxy.
My current implementation is as follows:
I connect to the smtp server with authentication. After I've successfully logged in, I send an email. It works fine but when I look at the email header I can see my host name. I would like to tunnel it through a proxy instead.
Any help will be highly appreciated.
| 0 |
python,proxy,smtp,smtplib
|
2011-03-08T23:51:00.000
| 0 | 5,239,797 |
This code has earned from me.
1. The file name must not be email.py Rename file name for example emailSend.py
2. It is necessary to allow Google to send messages from unreliable sources.
| 0 | 25,028 | false | 0 | 1 |
Python smtplib proxy support
| 44,179,874 |
1 | 6 | 0 | 0 | 56 | 1 | 0 | 0 |
I have to write a program to calculate a**b % c where b and c are both very large numbers. If I just use a**b % c, it's really slow. Then I found that the built-in function pow() can do this really fast by calling pow(a, b, c).
I'm curious to know how does Python implement this? Or where could I find the source code file that implement this function?
| 0 |
python,algorithm,math
|
2011-03-09T14:01:00.000
| 0 | 5,246,856 |
Python uses C math libraries for general cases and its own logic for some of its concepts (such as infinity).
| 0 | 37,922 | false | 0 | 1 |
How did Python implement the built-in function pow()?
| 5,246,963 |
2 | 6 | 0 | 0 | 24 | 1 | 0 | 0 |
I have a relatively large dictionary. How do I know the size? well when I save it using cPickle the size of the file will grow approx. 400Mb. cPickle is supposed to be much faster than pickle but loading and saving this file just takes a lot of time. I have a Dual Core laptop 2.6 Ghz with 4GB RAM on a Linux machine. Does anyone have any suggestions for a faster saving and loading of dictionaries in python? thanks
| 0 |
python,file,dictionary,pickle
|
2011-03-09T16:35:00.000
| 0 | 5,248,958 |
That is a lot of data...
What kind of contents has your dictionary? If it is only primitive or fixed datatypes, maybe a real database or a custom file-format is the better option?
| 0 | 25,562 | false | 0 | 1 |
Fastest way to save and load a large dictionary in Python
| 5,249,005 |
2 | 6 | 0 | 2 | 24 | 1 | 0.066568 | 0 |
I have a relatively large dictionary. How do I know the size? well when I save it using cPickle the size of the file will grow approx. 400Mb. cPickle is supposed to be much faster than pickle but loading and saving this file just takes a lot of time. I have a Dual Core laptop 2.6 Ghz with 4GB RAM on a Linux machine. Does anyone have any suggestions for a faster saving and loading of dictionaries in python? thanks
| 0 |
python,file,dictionary,pickle
|
2011-03-09T16:35:00.000
| 0 | 5,248,958 |
I have tried this for many projects and concluded that shelve is faster than pickle in saving data. Both perform the same at loading data.
Shelve is in fact a dirty solution.
That is because you have to be very careful with it. If you do not close a shelve file after opening it, or due to any reason some interruption happens in your code when you're in the middle of opening and closing it, the shelve file has high chance of getting corrupted (resulting in frustrating KeyErrors); which is really annoying given that we who are using them are interested in them because of storing our LARGE dict files which clearly also took a long time to be constructed
And that is why shelve is a dirty solution... It's still faster though. So!
| 0 | 25,562 | false | 0 | 1 |
Fastest way to save and load a large dictionary in Python
| 58,051,642 |
3 | 6 | 0 | 2 | 58 | 1 | 0.066568 | 0 |
I created a module named util that provides classes and functions I often use in Python.
Some of them need imported features. What are the pros and the cons of importing needed things inside class/function definition? Is it better than import at the beginning of a module file? Is it a good idea?
| 0 |
python,function,class,import
|
2011-03-10T16:10:00.000
| 0 | 5,262,406 |
I believe that it's best practice (according to some PEP's) that you keep import statements at the beginning of a module. You can add import statements to an __init__.py file, which will import those module to all modules inside the package.
So...it's certainly something you can do the way you're doing it, but it's discouraged and actually unnecessary.
| 0 | 54,351 | false | 0 | 1 |
Import statement inside class/function definition - is it a good idea?
| 5,262,474 |
3 | 6 | 0 | 4 | 58 | 1 | 0.132549 | 0 |
I created a module named util that provides classes and functions I often use in Python.
Some of them need imported features. What are the pros and the cons of importing needed things inside class/function definition? Is it better than import at the beginning of a module file? Is it a good idea?
| 0 |
python,function,class,import
|
2011-03-10T16:10:00.000
| 0 | 5,262,406 |
Like flying sheep's answer, I agree that the others are right, but I put imports in other places like in __init__() routines and function calls when I am DEVELOPING code. After my class or function has been tested and proven to work with the import inside of it, I normally give it its own module with the import following PEP8 guidelines. I do this because sometimes I forget to delete imports after refactoring code or removing old code with bad ideas. By keeping the imports inside the class or function under development, I am specifying its dependencies should I want to copy it elsewhere or promote it to its own module...
| 0 | 54,351 | false | 0 | 1 |
Import statement inside class/function definition - is it a good idea?
| 30,221,106 |
3 | 6 | 0 | 2 | 58 | 1 | 0.066568 | 0 |
I created a module named util that provides classes and functions I often use in Python.
Some of them need imported features. What are the pros and the cons of importing needed things inside class/function definition? Is it better than import at the beginning of a module file? Is it a good idea?
| 0 |
python,function,class,import
|
2011-03-10T16:10:00.000
| 0 | 5,262,406 |
While the other answers are mostly right, there is a reason why python allows this.
It is not smart to import redundant stuff which isn’t needed. So, if you want to e.g. parse XML into an element tree, but don’t want to use the slow builtin XML parser if lxml is available, you would need to check this the moment you need to invoke the parser.
And instead of memorizing the availability of lxml at the beginning, I would prefer to try importing and using lxml, except it’s not there, in which case I’d fallback to the builtin xml module.
| 0 | 54,351 | false | 0 | 1 |
Import statement inside class/function definition - is it a good idea?
| 5,302,566 |
1 | 4 | 0 | 0 | 0 | 0 | 0 | 0 |
should be dumb as everybody seems to installed it without trouble.
I spent hours within a fresh squeeze and tried different configurations (easy_install, aptitude and from source 0.81p.tar.gz) the best I got is a page from the localhost:9989
without any slave started.
Knowing that I made the 2 accounts : buildmaster and buildslave
how to clean and reinstall it to have server and 1 slave for git ?
thanks in advance
Added :
You are right some details are missing:
I use buildbot from virtualBox with a Debian squeeze 6.0 in 32bits
The both accounts : buildmaster and buildslave are running within this same Virtual environment.
I just tried the little example (this seems really interesting) :
easy_install buildbot
buildbot create-master /tmp/experimental_buildmaster
buildbot start /tmp/experimental_buildmaster
as root the jinja2 was missing whereas from buildmaster there were no complain (??)
commented the Git calls that created errors to try to start the simplest demo
buildslave create-slave /tmp/experimental_buildslave 127.0.0.1:9989 slave-name mypasswd
in the log something appear allways : "No address associated with hostname"
it seems I'm closer with this no ?
| 0 |
python,buildbot
|
2011-03-10T16:49:00.000
| 0 | 5,262,977 |
Some additional information about configuring abd running buildslave after it's creation.
After installing buildbot package int.d script /etc/init.d/buildbot is added to enable running buildbot as a service (starting automatically after system restart and so on).
For this script to run successfully you need to edit conf file for this script. File name is specified inside the script, typically it is /etc/default/buildbot. Options in this file are pretty clear. One interesting thing you can tune here - the user from which buildbot will be running (default is buildbot). Small example of when it is useful:
I had to write a buildbot task, one part of which was managing virtual machines running on builslave machine (starting, stopping, managing snapshots). But rights for doing this had only vbox user (I used Virtual Box VMs). So I simply changed the user field in /etc/buildbot/default to accomplish this.
I hope this information will be useful to you.
| 0 | 1,638 | false | 1 | 1 |
buildbot from start
| 5,692,993 |
2 | 7 | 0 | 29 | 44 | 1 | 1 | 0 |
Why does Python compile libraries that are used in a script, but not the script being called itself?
For instance,
If there is main.py and module.py, and Python is run by doing python main.py, there will be a compiled file module.pyc but not one for main. Why?
Edit
Adding bounty. I don't think this has been properly answered.
If the response is potential disk permissions for the directory of main.py, why does Python compile modules? They are just as likely (if not more likely) to appear in a location where the user does not have write access. Python could compile main if it is writable, or alternatively in another directory.
If the reason is that benefits will be minimal, consider the situation when the script will be used a large number of times (such as in a CGI application).
| 0 |
python
|
2011-03-11T01:27:00.000
| 0 | 5,268,017 |
Nobody seems to want to say this, but I'm pretty sure the answer is simply: there's no solid reason for this behavior.
All of the reasons given so far are essentially incorrect:
There's nothing special about the main file. It's loaded as a module, and shows up in sys.modules like any other module. Running a main script is nothing more than importing it with a module name of __main__.
There's no problem with failing to save .pyc files due to read-only directories; Python simply ignores it and moves on.
The benefit of caching a script is the same as that of caching any module: not wasting time recompiling the script every time it's run. The docs acknowledge this explicitly ("Thus, the startup time of a script may be reduced ...").
Another issue to note: if you run python foo.py and foo.pyc exists, it will not be used. You have to explicitly say python foo.pyc. That's a very bad idea: it means Python won't automatically recompile the .pyc file when it's out of sync (due to the .py file changing), so changes to the .py file won't be used until you manually recompile it. It'll also fail outright with a RuntimeError if you upgrade Python and the .pyc file format is no longer compatible, which happens regularly. Normally, this is all handled transparently.
You shouldn't need to move a script to a dummy module and set up a bootstrapping script to trick Python into caching it. That's a hackish workaround.
The only possible (and very unconvincing) reason I can contrive is to avoid your home directory from being cluttered with a bunch of .pyc files. (This isn't a real reason; if that was an actual concern, then .pyc files should be saved as dotfiles.) It's certainly no reason not to even have an option to do this.
Python should definitely be able to cache the main module.
| 0 | 11,900 | false | 0 | 1 |
Why does Python compile modules but not the script being run?
| 5,321,733 |
2 | 7 | 0 | 1 | 44 | 1 | 0.028564 | 0 |
Why does Python compile libraries that are used in a script, but not the script being called itself?
For instance,
If there is main.py and module.py, and Python is run by doing python main.py, there will be a compiled file module.pyc but not one for main. Why?
Edit
Adding bounty. I don't think this has been properly answered.
If the response is potential disk permissions for the directory of main.py, why does Python compile modules? They are just as likely (if not more likely) to appear in a location where the user does not have write access. Python could compile main if it is writable, or alternatively in another directory.
If the reason is that benefits will be minimal, consider the situation when the script will be used a large number of times (such as in a CGI application).
| 0 |
python
|
2011-03-11T01:27:00.000
| 0 | 5,268,017 |
Because the script being run may be somewhere where it is inappropriate to generate .pyc files, such as /usr/bin.
| 0 | 11,900 | false | 0 | 1 |
Why does Python compile modules but not the script being run?
| 5,268,020 |
1 | 1 | 0 | 1 | 1 | 0 | 1.2 | 0 |
I have got a list of files in txt files and I need to check them out in edit mode, and make some changes(there are word documents), and check them back in via WinCVS.
I know I can write tcl scripts or macro, or python scripts in wincvs shell but I have some problems with them.
I have installed TCL 8.5 and selected tcl DLL in Admin>Preferences, tcl is now available, but whenever I type and execute a tcl script, it says
can not find channel named "stdout"
Do you have any idea regarding this error?
Also, I cannot see admin macros, it says Shell is not available. I have installed the latest version of python and select related dll in preferences.
Could anyone give me a hint for checking a list of files via wincvs?
many thanks in advance,
regards
| 0 |
python,tcl,wincvs
|
2011-03-11T11:05:00.000
| 1 | 5,272,116 |
The problem is that Tcl's trying to build the standard file descriptors into available-by-default channels (i.e., stdin, stdout and stderr) but this goes wrong when they're not opened by default. That's the case on Windows when running disconnected (which is what happens inside GUI applications on that platform). When you're running with a full Tcl shell such as wish, this is worked around, but you're embedded so that's not going to work; the code to fix things isn't run because it's part of the shell startup and not the library initialization (after all, replacing a process-global resource like file descriptors is a little unfriendly for any library to do without the app or user asking it to!)
The simplest workaround is to not write to stdout – note that it's the default destination of the puts command, so you have to be careful – and to take care not to write to stderr either, as that's probably under the same restrictions (which means that you've got to be careful how you trap errors, especially while testing your script).
| 0 | 2,712 | true | 0 | 1 |
WinCVS - Python - TCL
| 5,296,594 |
1 | 5 | 0 | 1 | 1 | 0 | 0.039979 | 0 |
I have a python script that output/prints a large array (50MB in size) to the screen. This script is running on machineA. Is it at all possible to 'pipe' this output to machineB, where it will be processed?
I know I can save the output in a file on machineA and then send the file to machineB. I was just wondering if it is possible to do so without having to save the data first to a file (on machineA).
Any solutions (python, bash shell, other ideas) will be appreciated.
| 0 |
python,linux,bash,shell
|
2011-03-11T20:38:00.000
| 1 | 5,278,044 |
You can do it on different levels - here are a few options
use ssh to pipe
myprog | ssh remotemachine myotherprog
use nfs (if going to a file
use netcat (nc)
use something like thrift
It depends on how solid & permanent the solution needs to be
| 0 | 3,563 | false | 0 | 1 |
Piping output from a python script to a remote machine?
| 5,278,104 |
1 | 1 | 0 | 1 | 1 | 0 | 1.2 | 0 |
This might be something obvious that I'm missing.
I would like to have my host encrypt a message to a client using the client's public key, and also have that message signed using the hosts private key.
It seems like an obvious scenario, but perhaps my concept is simply wrong. I think that you should be able to do with with a single message, much like you see using PGP. Can this be done with M2Crypto easily?
I tried first encrypting the message and then signing it but I get the message "RSAError: digest too big for rsa key".
I would rather not send the encrypted message and its signature as two separate pieces of data.
Edit:
For the time being I'm using a custom delimiter, to separate the message from the signature, but I feel like this is bad form, and that the format should have provisions for what I'm attempting.
| 0 |
python,cryptography,rsa,m2crypto
|
2011-03-11T22:36:00.000
| 0 | 5,279,102 |
It sounds like you're looking for a hybrid cryptosystem which takes care of encryption and signature together, using appropriate crypto primitives to allow it to work whatever the size of the data, and encapsulating all the components of the cryptogram in one place. PGP, HTTPS and DHIES are good examples. While it seems to me that you could implement such a system using m2crypto, you probably shouldn't; you're much better off reusing an existing protocol than rolling your own. It's far too easy to make mistakes which are hard to spot and render the security useless.
| 0 | 641 | true | 0 | 1 |
M2Crypto, Encrypt and Sign at once?
| 5,340,010 |
1 | 2 | 0 | 6 | 12 | 1 | 1.2 | 0 |
I cannot find much advantage in them besides kind of documentation purpose. Python will warn me if I forget to implement a method I defined in a ABC but since I do not reference my objects by their interfaces I can forget to declare methods in their interfaces and I won't event notice it.
Is it common practice to use ABC's for interface-like behaviour?
| 0 |
python,interface,abstract-class
|
2011-03-12T17:03:00.000
| 0 | 5,283,995 |
Personally, I find abstract classes to be most useful when writing libraries or other code which interfaces between one developer and another.
One of the advantages of statically-typed languages is that when you use the wrong type, it fails early (often, as early as compile time). ABCs allow Python to gain this same advantage with dynamic typing.
If your library code duck types an object which lacks a vital method, it likely won't fail until that method is needed (which could take significant time or put resources into an inconsistent state, depending on how it's used). With ABCs, however, a missing method either isn't using the correct ABC (and fails an instanceof check) or is "validated" by the ABC.
Additionally, ABCs serve as an excellent way to document interfaces, both conceptually and, via docstrings, literally.
| 0 | 2,095 | true | 0 | 1 |
Is it pythonic to use interfaces / abstract base classes?
| 5,284,403 |
1 | 1 | 0 | 1 | 0 | 0 | 0.197375 | 0 |
I am trying to get the query string in a CGI python script because for some reason the .FieldStorage and .getvalue functions are returning "None". The query is being generated correctly. I checked it in Wireshark and it is correctly produced.
Any ideas on how I can just get the string itself correctly?
I was trying to use os.environ('QUERY_STRING') but that didn't work either.
Josh
| 0 |
python,apache,cgi
|
2011-03-13T03:02:00.000
| 0 | 5,287,113 |
I think I figured it out. I need to use the environ variable passed to the application function by mod_wsgi.
Thanks!
| 0 | 669 | false | 1 | 1 |
Get the GET query in a Python CGI script (Apache, mod_cgi)
| 5,287,233 |
1 | 3 | 0 | 0 | 2 | 0 | 0 | 0 |
I hope you don't mind if I ask for a bit of advice regarding modelling robotic systems. I've recently become rather interested in using inverse kinematics (IK) to control a 5 dof robotic manipulator. I have a solid foundation in IK but what I'm having trouble with is a way to visualize how the manipulator moves with respect to joint angles.
I've looked into using 3D toolkits (such as Blender, Panda3D, vPython) to create a 3d model of the arm, but I'm not sure if I should be looking something with physics support. I'm also not sure how well I can model motion with these packages. Anyone have any suggestions? What I'm NOT looking for is a full blown robotic simulator like Microsoft's Robotic Studio, I'd like to start with the basics and learn how everything works first, ie code the IK in Python, then visualize the motion in 3D. I'm very familiar with Python, so something that interfaces with Python would be preferable.
Thanks!
| 0 |
python,modeling,robotics,robot,inverse-kinematics
|
2011-03-13T05:06:00.000
| 0 | 5,287,575 |
This isn't really a hard problem, is it? Presumably you're working out the math on your own; so if your robotic arm is visualized as, say, a few rectangular solids then all you need is something that will render these at the x,y,z coordinates and with the orientation vector you supply, updating when need be. OpenGL should do just fine for this, you could probably do it in <50 lines.
| 0 | 2,937 | false | 0 | 1 |
Modelling a robotic arm motion in 3D, ideas?
| 5,287,632 |
4 | 8 | 0 | 372 | 315 | 1 | 1.2 | 0 |
Imagine a python script that will take a long time to run, what will happen if I modify it while it's running? Will the result be different?
| 0 |
python
|
2011-03-14T09:47:00.000
| 0 | 5,296,977 |
Nothing, because Python precompiles your script into a PYC file and launches that.
However, if some kind of exception occurs, you may get a slightly misleading explanation, because line X may have different code than before you started the script.
| 0 | 69,356 | true | 0 | 1 |
What will happen if I modify a Python script while it's running?
| 5,296,992 |
4 | 8 | 0 | -5 | 315 | 1 | -1 | 0 |
Imagine a python script that will take a long time to run, what will happen if I modify it while it's running? Will the result be different?
| 0 |
python
|
2011-03-14T09:47:00.000
| 0 | 5,296,977 |
depending. if a python script links to other modified file, then will load newer version ofcourse. but if source doesnt point to any other file it'll just run all script from cache as long as its run. changes will be visible next time...
and if about auto-applying changes when they're made - yes, @pcbacterio was correct. its possible to do thar but script which does it just remembers last action/thing what was doing and checks when the file is modified to rerun it (so its almost invisible)
=]
| 0 | 69,356 | false | 0 | 1 |
What will happen if I modify a Python script while it's running?
| 70,072,657 |
4 | 8 | 0 | -1 | 315 | 1 | -0.024995 | 0 |
Imagine a python script that will take a long time to run, what will happen if I modify it while it's running? Will the result be different?
| 0 |
python
|
2011-03-14T09:47:00.000
| 0 | 5,296,977 |
It happens nothing. Once the script is loaded in memory and running it will keep like this.
An "auto-reloading" feature can be implemented anyway in your code, like Flask and other frameworks does.
| 0 | 69,356 | false | 0 | 1 |
What will happen if I modify a Python script while it's running?
| 70,066,818 |
4 | 8 | 0 | 1 | 315 | 1 | 0.024995 | 0 |
Imagine a python script that will take a long time to run, what will happen if I modify it while it's running? Will the result be different?
| 0 |
python
|
2011-03-14T09:47:00.000
| 0 | 5,296,977 |
No, the result will not reflect the changes once saved. The result will not change when running regular python files. You will have to save your changes and re-run your program.
| 0 | 69,356 | false | 0 | 1 |
What will happen if I modify a Python script while it's running?
| 70,108,346 |
1 | 1 | 0 | 25 | 13 | 1 | 1.2 | 0 |
I have difficulty understanding the difference between zipfile.ZIP_DEFLATED and zipfile.ZIP_STORED compression modes of the zipfile module.
| 0 |
python,python-zipfile
|
2011-03-14T11:51:00.000
| 0 | 5,298,169 |
ZIP_DEFLATED correspond to an archive member (a file inside the archive) which is compressed (or deflated). ZIP_STORED correspond to an archive member which is simply stored, without being compressed, quite the same as an archive member inside a tar file.
| 0 | 10,717 | true | 0 | 1 |
Python zipfile module: difference between zipfile.ZIP_DEFLATED and zipfile.ZIP_STORED
| 5,298,221 |
1 | 2 | 0 | 0 | 2 | 0 | 0 | 0 |
How would I DKIM sign an email I've constructed using email.mime.text.MIMEText and am sending using smtplib?
| 0 |
python,email,smtplib,dkim
|
2011-03-14T13:13:00.000
| 0 | 5,299,025 |
You don't. It's the mail server's job to add this signature.
| 0 | 1,800 | false | 0 | 1 |
Sending a DKIM signed email - Python
| 5,299,099 |
2 | 6 | 0 | 1 | 2 | 1 | 0.033321 | 0 |
I'm using python and virtualenv/pip. I have a module installed via pip called test_utils (it's django-test-utils). Inside one of my django apps, I want to import that module. However I also have another file test_utils.py in the same directory. If I go import test_utils, then it will import this local file.
Is it possible to make python use a non-local / non-relative / global import? I suppose I can just rename my test_utils.py, but I'm curious.
| 0 |
python,django,import,python-module
|
2011-03-14T13:28:00.000
| 0 | 5,299,199 |
I was able to force python to import the global one with
from __future__ import absolute_import
at the beginning of the file (this is the default in python 3.0)
| 0 | 3,449 | false | 1 | 1 |
Python - Importing a global/site-packages module rather than the file of the same name in the local directory
| 46,303,381 |
2 | 6 | 0 | 0 | 2 | 1 | 1.2 | 0 |
I'm using python and virtualenv/pip. I have a module installed via pip called test_utils (it's django-test-utils). Inside one of my django apps, I want to import that module. However I also have another file test_utils.py in the same directory. If I go import test_utils, then it will import this local file.
Is it possible to make python use a non-local / non-relative / global import? I suppose I can just rename my test_utils.py, but I'm curious.
| 0 |
python,django,import,python-module
|
2011-03-14T13:28:00.000
| 0 | 5,299,199 |
Since my test_utils was in a django project, I was able to go from ..test_utils import ... to import the global one.
| 0 | 3,449 | true | 1 | 1 |
Python - Importing a global/site-packages module rather than the file of the same name in the local directory
| 5,351,006 |
1 | 2 | 0 | 6 | 5 | 1 | 1.2 | 0 |
I have created my own simple logger class which uses COM interop to redirect to a company-standard logger. I would like to create logger instance near the beginning of my script and then use this logger to allow all modules in my script to log centrally.
Is there an idiomatic way to share this logger instance between all modules, without specifically adding a logger parameter to the constructor of every class that needs to log?
Should I use a global variable, or a singleton, or is there another recommended way to shar the logger between modules?
| 0 |
python,singleton
|
2011-03-14T15:16:00.000
| 0 | 5,300,563 |
Why don't you use Python standard logging and write a handler to interface with your company-standard logging system? Python logging is specifically designed so you don't need to pass logger instances between layers of your code - Python loggers are essentially singletons already.
Handlers for stdlib logging are pretty easy to write, too - there are many examples of third party handlers.
Disclosure: I'm the maintainer of Python's standard library logging package.
| 0 | 2,563 | true | 0 | 1 |
What is the idiomatic way to share a logger instance between modules in my Python script?
| 5,300,658 |
1 | 2 | 0 | 1 | 1 | 1 | 0.099668 | 0 |
I use optparse module to parse the options that I make, and it automatically generates usage message to print with -h option.
How can I get the usage message as a string in a python script? I'd like to print out it when something's wrong with parsing.
| 0 |
python,optparse
|
2011-03-15T02:26:00.000
| 0 | 5,306,852 |
How about parser.format_help()?
| 0 | 1,826 | false | 0 | 1 |
Usage message string that optparse makes in python?
| 5,306,963 |
4 | 5 | 0 | -1 | 13 | 0 | -0.039979 | 0 |
I have a Python script that is connecting to the database. To that, obviously, I need the password. I need to hide it somewhere.
My problem is that this code is stored in a folder that everybody who has access to the server can look. So, if I write this password encrypted in a file, in the code will appear the key to discover it and people can figured it out.
So, please, if anyone has an idea..
| 0 |
python,passwords
|
2011-03-15T17:48:00.000
| 0 | 5,315,829 |
A more advanced idea is to do the mysql authentication manually. That is, learn the mysql protocol (it's a standard handshake with a challenege and a response) and do the procedure yourself. This way, you never send the password directly.
| 0 | 8,940 | false | 0 | 1 |
What is the best way of hide a password?
| 5,316,042 |
4 | 5 | 0 | 0 | 13 | 0 | 0 | 0 |
I have a Python script that is connecting to the database. To that, obviously, I need the password. I need to hide it somewhere.
My problem is that this code is stored in a folder that everybody who has access to the server can look. So, if I write this password encrypted in a file, in the code will appear the key to discover it and people can figured it out.
So, please, if anyone has an idea..
| 0 |
python,passwords
|
2011-03-15T17:48:00.000
| 0 | 5,315,829 |
Just to reinforce what Brian said, if a program runs automatically (i.e., without the opportunity to prompt the user for a password), any program that runs under the same user authority has the same access to any password. It's not clear what else you could do. Perhaps if the (trusted) operating system on the client machine could certify to the host that it was being accessed by a program run from a particular path, the host could be told "Only open the database to /var/lib/tomcat/bin/tomcat on appserver.example.com". If you accomplish all that, an attacker would have to compromise the tomcat executable to get to the database.
| 0 | 8,940 | false | 0 | 1 |
What is the best way of hide a password?
| 5,316,392 |
4 | 5 | 0 | 10 | 13 | 0 | 1.2 | 0 |
I have a Python script that is connecting to the database. To that, obviously, I need the password. I need to hide it somewhere.
My problem is that this code is stored in a folder that everybody who has access to the server can look. So, if I write this password encrypted in a file, in the code will appear the key to discover it and people can figured it out.
So, please, if anyone has an idea..
| 0 |
python,passwords
|
2011-03-15T17:48:00.000
| 0 | 5,315,829 |
You're using a scripting language and accessing a database directly with a password. No matter what you do, at some level that password is going to be easily accessible. Obscuring it doesn't really buy you much.
You have to rely on the machine's security and permissions, and perhaps the database (restricting access from that particular machine and user).
| 0 | 8,940 | true | 0 | 1 |
What is the best way of hide a password?
| 5,315,927 |
4 | 5 | 0 | 7 | 13 | 0 | 1 | 0 |
I have a Python script that is connecting to the database. To that, obviously, I need the password. I need to hide it somewhere.
My problem is that this code is stored in a folder that everybody who has access to the server can look. So, if I write this password encrypted in a file, in the code will appear the key to discover it and people can figured it out.
So, please, if anyone has an idea..
| 0 |
python,passwords
|
2011-03-15T17:48:00.000
| 0 | 5,315,829 |
Don't store the database connection credentials in the Python file at all. Instead, store them in a secure place, readable only by the user account that the script will run under.
For example, create a user account for running this job, and create a file in that user account's home directory (readable only by that user) called database.ini and put the database connection string and password there. Then use the Python ConfigParser class in the standard library to read the file in.
Then the job can be always run under that user account. You can also run it under your account by putting a database.ini file in your home directory with the correct credentials, but anyone who doesn't have the credentials cannot run it.
| 0 | 8,940 | false | 0 | 1 |
What is the best way of hide a password?
| 5,316,011 |
1 | 3 | 0 | 19 | 12 | 0 | 1 | 0 |
Has anyone here done any benchmarking of Chameleon versus Jinja2, in respect to performance? I'm more used to the Jinja syntax, since I come from Django, but as Pyramid suggests to use Chameleon, I'm thinking if it would be nice to give it a try - despite having an awkward syntax, IMO.
| 0 |
python,performance,jinja2,pyramid,chameleon
|
2011-03-16T06:28:00.000
| 0 | 5,321,789 |
Template engines are rarely the cause of performance problems, even if chameleon is slightly faster than Jinja2 I doubt the effort of learning a new template language etc. is worth it.
Optimization of database queries and caching will probably result in more performance than you could gain by switching the template engine and take little effort.
| 0 | 6,518 | false | 1 | 1 |
Speed comparisons between Chameleon and Jinja2
| 5,324,691 |
1 | 8 | 0 | 1 | 101 | 0 | 0.024995 | 0 |
How do you configure fabric to connect to remote hosts using SSH keyfiles (for example, Amazon EC2 instances)?
| 0 |
python,fabric
|
2011-03-16T15:20:00.000
| 1 | 5,327,465 |
As stated above, Fabric will support .ssh/config file settings after a fashion, but using a pem file for ec2 seems to be problematic. IOW a properly setup .ssh/config file will work from the command line via 'ssh servername' and fail to work with 'fab sometask' when env.host=['servername'].
This was overcome by specifying the env.key_filename='keyfile' in my fabfile.py and duplicating the IdentityFile entry already in my .ssh/config.
This could be either Fabric or paramiko, which in my case was Fabric 1.5.3 and Paramiko 1.9.0.
| 0 | 58,539 | false | 0 | 1 |
Using an SSH keyfile with Fabric
| 14,738,198 |
1 | 3 | 0 | 0 | 1 | 0 | 0 | 0 |
I used MailSlots with Delphi for my softwares when I needed dialogs between them (on MS Windows on the same coputer).
Now I need to do the same things but with Python and on MS Windows but also on Linux.
So : what is the best way to communicate between Python written software running on the same computer ?
For some firewall problemes I would prefer to avoid IP dialogs.
As I tested it, I don't want all the DIsk File share solutions.
So in brief :
2 Python software on the same computer need to dialog.
No IP
No Disk File share.
| 0 |
python,pipe
|
2011-03-17T18:05:00.000
| 1 | 5,343,264 |
How about one of them being a thread started by the another one?
| 0 | 368 | false | 0 | 1 |
What is the best way to communicate between Python softwares running on the same computer?
| 5,343,298 |
1 | 2 | 0 | 2 | 0 | 0 | 0.197375 | 0 |
How can i detect mouse movement in a python script in linux?
I want to then send those events to a handler which will dispatch that where i can process it later.
There is no gui installed if that matters.
| 0 |
python,linux
|
2011-03-18T10:10:00.000
| 0 | 5,350,491 |
You could try reading /dev/input/mice.
| 0 | 3,099 | false | 0 | 1 |
How can i simply detect mouse movement in python?
| 5,350,513 |
2 | 3 | 0 | 4 | 4 | 1 | 1.2 | 0 |
We are moving from latin1 to UTF-8 and have 100k lines of python code.
Plus I'm new in python (ha-ha-ha!).
I already know that str() function fails when receiving Unicode so we should use unicode() instead of it with almost the same effect.
What are the other "dangerous" places of code?
Are there any basic guidelines/algorithms for moving to UTF-8? Can it be written an automatic 'code transformer'?
| 0 |
python,unicode
|
2011-03-18T10:56:00.000
| 0 | 5,350,958 |
str and unicode are classes, not functions. When you call str(u'abcd') you are initialising a new string which takes 'abcd' as a variable. It just so happens that str() can be used to convert a string of any type to an ascii str.
Other areas to look out for are when reading from a file/input, or basically anything you get back as a string from a function that was not written for unicode.
Enjoy :)
| 0 | 1,414 | true | 0 | 1 |
How to move a python 2.6 project to UTF-8?
| 5,351,400 |
2 | 3 | 0 | 2 | 4 | 1 | 0.132549 | 0 |
We are moving from latin1 to UTF-8 and have 100k lines of python code.
Plus I'm new in python (ha-ha-ha!).
I already know that str() function fails when receiving Unicode so we should use unicode() instead of it with almost the same effect.
What are the other "dangerous" places of code?
Are there any basic guidelines/algorithms for moving to UTF-8? Can it be written an automatic 'code transformer'?
| 0 |
python,unicode
|
2011-03-18T10:56:00.000
| 0 | 5,350,958 |
Can it be written an automatic 'code transformer'? =)
No. str and unicode are two different types which have different purposes. You should not attempt to replace every occurrence of a byte string with a Unicode string, neither in Python 2 nor Python 3.
Continue to use byte strings for binary data. In particular anything you're writing to a file or network socket is bytes. And use Unicode strings for user-facing text.
In between there is a grey area of internal ASCII-character strings which could equally be bytes or Unicode. In Python 2 these are typically bytes, in Python 3 typically Unicode. In you are happy to limit your code to Python 2.6+, you can mark your definitely-bytes strings as b'' and bytes, your definitely-characters strings as u'' and unicode, and use '' and str for the “whatever the default type of string is” strings.
| 0 | 1,414 | false | 0 | 1 |
How to move a python 2.6 project to UTF-8?
| 5,357,350 |
1 | 7 | 0 | 39 | 23 | 1 | 1.2 | 0 |
I have a need to add module attributes at run time. For example, when a module is loaded, it reads the file where the data is contained. I would like that data to be available as a module attribute, but the data is only available at run time.
How can I add module attributes at run time?
| 0 |
python
|
2011-03-18T16:04:00.000
| 0 | 5,354,676 |
Thanks @Dharmesh. That was what I needed. There is only one change that needs to be made. The module won't be importing itself so to get the module object I can do:
setattr(sys.modules[__name__], 'attr1', 'attr1')
| 0 | 16,367 | true | 0 | 1 |
How can I add attributes to a module at run time?
| 5,356,035 |
5 | 5 | 0 | 3 | 1 | 0 | 0.119427 | 1 |
I was looking at a book on python network programming and i wanted to know what would be the benefits to learning python network programming comprehensively? This would be in the context of being able to develop some really cool, ground breaking web apps. I am a python newbe so all opinions woul be appreciated.
Kind Regards
4 Years later:
This was 4yrs ago, its crazy how much I've grown as a developer. Regarding how it has helped, I've developed an email application, a chat application using Objective C, python Twisted on the server side, it also helped with developing my apns push notification pipeline.
| 0 |
python,network-programming
|
2011-03-18T19:49:00.000
| 0 | 5,357,103 |
If you want to develop wed apps, than you should rather focus on web frameworks like Django or Pylons.
| 0 | 2,411 | false | 0 | 1 |
benefits of learning python network programming?
| 5,357,120 |
5 | 5 | 0 | 0 | 1 | 0 | 0 | 1 |
I was looking at a book on python network programming and i wanted to know what would be the benefits to learning python network programming comprehensively? This would be in the context of being able to develop some really cool, ground breaking web apps. I am a python newbe so all opinions woul be appreciated.
Kind Regards
4 Years later:
This was 4yrs ago, its crazy how much I've grown as a developer. Regarding how it has helped, I've developed an email application, a chat application using Objective C, python Twisted on the server side, it also helped with developing my apns push notification pipeline.
| 0 |
python,network-programming
|
2011-03-18T19:49:00.000
| 0 | 5,357,103 |
The network is and always will be the sexiest arena for a hacker. An attacker can do almost anything with simple network access, such as scan for hosts, inject packets, sniff data, remotely exploit hosts, and much more. But if you are an attacker who has worked your way into the deepest depths of an enterprise target, you may find yourself in a bit of a conundrum: you have no tools to execute network attacks. No netcat. No Wireshark. No compiler and no means to install one. However, you might be surprised to find that in many cases, you’ll find a Python install.
Hence, the one benefit of python network programming I see is that one has a chance of becoming a penetration tester or an Offensive security guy.
Edit (10-06-2020):
I have no knowledge of what I was thinking when I was writing this answer. It's clearly not helpful.
Regarding the question, making web apps is not equivalent to network programming. In network programming with python, you can start with lower level of the OSI model by using libraries like scapy. Here you can make raw packets and understand the various protocols with it. And then maybe move to application level with libraries like Scrapy which involves web scraping, making http requests, etc. But develping python web apps would use tools like flask, django, jinja, etc and the development of a web app can take the form totally different than that of a regular scripting tool.
| 0 | 2,411 | false | 0 | 1 |
benefits of learning python network programming?
| 31,816,130 |
5 | 5 | 0 | 2 | 1 | 0 | 1.2 | 1 |
I was looking at a book on python network programming and i wanted to know what would be the benefits to learning python network programming comprehensively? This would be in the context of being able to develop some really cool, ground breaking web apps. I am a python newbe so all opinions woul be appreciated.
Kind Regards
4 Years later:
This was 4yrs ago, its crazy how much I've grown as a developer. Regarding how it has helped, I've developed an email application, a chat application using Objective C, python Twisted on the server side, it also helped with developing my apns push notification pipeline.
| 0 |
python,network-programming
|
2011-03-18T19:49:00.000
| 0 | 5,357,103 |
"Network programming" isn't about "cool web apps". It's more about creating servers, and creating clients that talk to servers. It's about sockets, tcp/ip communication, XMLRPC, http protocols and all the technologies that let two computers talk to each other.
If all you're interested in is web apps, learning network programming won't benefit you a whole lot.
| 0 | 2,411 | true | 0 | 1 |
benefits of learning python network programming?
| 5,357,140 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.