Available Count
int64
1
31
AnswerCount
int64
1
35
GUI and Desktop Applications
int64
0
1
Users Score
int64
-17
588
Q_Score
int64
0
6.79k
Python Basics and Environment
int64
0
1
Score
float64
-1
1.2
Networking and APIs
int64
0
1
Question
stringlengths
15
7.24k
Database and SQL
int64
0
1
Tags
stringlengths
6
76
CreationDate
stringlengths
23
23
System Administration and DevOps
int64
0
1
Q_Id
int64
469
38.2M
Answer
stringlengths
15
7k
Data Science and Machine Learning
int64
0
1
ViewCount
int64
13
1.88M
is_accepted
bool
2 classes
Web Development
int64
0
1
Other
int64
1
1
Title
stringlengths
15
142
A_Id
int64
518
72.2M
1
7
0
1
8
0
0.028564
0
Imagine a web application that allows a logged in user to run a shell command on the web server at the press of a button. This is relatively simple in most languages via some standard library os tools. But if that command is long running you don't want your UI to hang. Again this is relatively easy to deal with using some sort of background process or putting the command to be executed onto a message queue (and maybe saving the output and status somewhere for later consumption). Just return quickly saving we'll run that and get back to you. What I'd like to do is show the output of said web ui triggered shell command as it happens. So vertically scrolling text like when running in a terminal. I have a vague idea of how I might approach this, streaming the output to a websocket perhaps and simply printing the output to screen. What I'd like to ask is: Are their any plugins, libraries or applications that already do this. Something I can either use or read the source of. Ideally an open source python/django or ruby/rails tool, but other stacks would be interesting too.
0
python,ruby-on-rails,ruby,django,shell
2010-09-03T15:59:00.000
1
3,637,503
I'm not sure if it's what you want, but there are some web based ssh clients out there. If you care about security and really just want dynamic feedback, you could look into comet or just have a frame with its own http session that doesn't end until it's done printing.
0
4,016
false
1
1
What is the best way of running shell commands from a web based interface?
3,637,544
1
3
0
0
4
0
0
0
I'm a newbie to web technology, and still on a learning curve. Heard that, fastcgi would keep the compiled(interpreted) php code in memory, so why would one has to use op-code caching (apc or eaccelerators) for PHP? But I never heard of any such accelerators for Python. I'd expect as python and php are both interpreted language, it makes me think that, there has to be a room for python accelerators ? pls correct me if I'm wrong. Many thanks
0
php,python,fastcgi
2010-09-05T13:28:00.000
0
3,646,205
Python is compiled to bytecode when executed (the .pyc files), and the bytecode is kept around, not discarded. The compiled python is used instead of the source if it is present. Therefore, there is no need for additional opcode caching in python as it is already built in.
0
583
false
0
1
Why would one use accelerators with fastcgi for PHP?
3,646,236
2
2
0
2
4
0
0.197375
0
If so, What is the advantage ? (sure it will avoid restarting webserver). But isn't it a perfomance bottleneck? For production, is it possible to make web2py run directly from bytecode skipping interpreting stage (Caching) (except for the first request) ?
0
python,performance,caching,bytecode,web2py
2010-09-06T06:59:00.000
1
3,649,607
I don't know web2py particularly, but it runs via WSGI like most other Python frameworks. This means that code is only interpreted when the process starts, and is otherwise kept in memory. Processes are dynamically started and killed by the web server itself, but usually last for multiple requests. In any case, the Python interpreter usually creates a byte-code file, .pyc, when code is first read. This works in a webserver environment just as it does anywhere else. Finally, however, it is generally considered that code parsing is not particularly a bottleneck - the conversion to bytecode is pretty quick. In a web application, your bottleneck is almost certainly elsewhere (probably in the connection to the database).
0
814
false
1
1
Is code interpreted at every call in Web2Py?
3,649,957
2
2
0
6
4
0
1
0
If so, What is the advantage ? (sure it will avoid restarting webserver). But isn't it a perfomance bottleneck? For production, is it possible to make web2py run directly from bytecode skipping interpreting stage (Caching) (except for the first request) ?
0
python,performance,caching,bytecode,web2py
2010-09-06T06:59:00.000
1
3,649,607
In web2py, by default, all code in models, views and controllers (not web2py code, not code in modules imported by your models, views, controllers) is interpreted at every request. This allows to use a third party web server (for example apache) and still be able to see changes in your code reflected immediately without restart. PHP works in the same way. The performance penalty is negligible because the time to parse your code is less than the time to execute your code. Anyway, in the admin interface there is a "compile" button that will bytecode compile your code and collapse the view hierarchy (extended and included views) into a single file per action and remove the performance penalty. It also allows you to distribute your code bytecode compiled without giving away the source. The license allows it.
0
814
false
1
1
Is code interpreted at every call in Web2Py?
3,653,081
1
3
0
25
67
0
1
0
I have a function defined by a combination of basic math functions (abs, cosh, sinh, exp, ...). I was wondering if it makes a difference (in speed) to use, for example, numpy.abs() instead of abs()?
0
python,performance,numpy
2010-09-06T09:04:00.000
0
3,650,194
You should use numpy function to deal with numpy's types and use regular python function to deal with regular python types. Worst performance usually occurs when mixing python builtins with numpy, because of types conversion. Those type conversion have been optimized lately, but it's still often better to not use them. Of course, your mileage may vary, so use profiling tools to figure out. Also consider the use of programs like cython or making a C module if you want to optimize further your program. Or consider not to use python when performances matters. but, when your data has been put into a numpy array, then numpy can be really fast at computing bunch of data.
1
39,385
false
0
1
Are NumPy's math functions faster than Python's?
3,650,761
2
2
0
1
3
0
0.099668
0
I'm currently building a web application and I would like my users to have their own URLs to identify them. I could either do this using subdomains or using folders and am wondering what are the advantages and disadvantages of either one. I really like the folder solution because my URL mapping would be fairly easy. I have read about auto-generating subdomains and one solution was to create virtual hosts and then restart my nginx. It's a solution but I would prefer not to have to restart my web server everytime a new account is created. If there are any other ways on how to do automated subdomain creation, that would be great as well! Thanks!
0
python,django,nginx,subdomain
2010-09-06T17:26:00.000
1
3,653,239
I think directories are the way to go. I believe it would be easier to adapt Django to the directories way much easier than to subdomains. And as one user commented you can avoid restarting your server each time. I prefer to keep subdomains reserved for system use. Users should get their own directories instead. This is not a rule, just my preference.
0
286
false
0
1
Subdomains vs folders/directories
3,653,270
2
2
0
0
3
0
0
0
I'm currently building a web application and I would like my users to have their own URLs to identify them. I could either do this using subdomains or using folders and am wondering what are the advantages and disadvantages of either one. I really like the folder solution because my URL mapping would be fairly easy. I have read about auto-generating subdomains and one solution was to create virtual hosts and then restart my nginx. It's a solution but I would prefer not to have to restart my web server everytime a new account is created. If there are any other ways on how to do automated subdomain creation, that would be great as well! Thanks!
0
python,django,nginx,subdomain
2010-09-06T17:26:00.000
1
3,653,239
Use something like mod_wsgi instead of cgi scripts, they allow you to use arbitrary URL configs (example: Django, web.py, Zope ...)
0
286
false
0
1
Subdomains vs folders/directories
3,653,257
1
3
0
0
1
0
0
0
I want to write a python script which reads the '.bash_history' file and prints the statistics. Also, I would like to print the command which was used the most. I was able to read the bash history through the terminal but I'm not able to do it through python programming. Can someone please help me with how to start with it?
0
python
2010-09-07T07:16:00.000
1
3,656,500
Just some basic ideas, with important python functions for that: read the file; open go through all lines and sum up the number of occurences of a line; for, dict in case you only want to check parts of a command (for example treat cd XY and cd .. the same), normalize the lines by removing the command arguments after the space; split sort the sums and print out the command with the highest sum.
0
696
false
0
1
reading .bash_history file through python script
3,656,550
1
3
0
1
2
0
0.066568
0
I have a python code base and want to know whether pyxml is really used in the code any where. The python version i have is 2.6. pyxml's last binary distribution ended with 2.4 python version. Any clues or ideas to judge the code whether it is free of pyxml 0.8.4 on python 2.6 ? Thanks in Advance.
0
python
2010-09-07T08:51:00.000
0
3,657,165
grep your codebase for from xml import or import xml.
0
364
false
0
1
Best way to know that my Python Code base is using PyXML or not?
3,657,249
2
2
0
2
0
1
0.197375
0
If you had to judge someones level of Python understand in just 3 questions, what would you ask?
0
python
2010-09-07T16:17:00.000
0
3,660,503
This is pretty much the same as for any language. What projects have you done with Python? What is your favorite Python reference? Have you worked with other people on code written in Python? That's how I would judge. If I wanted to test, it would depend on whether I were looking for someone to write in 2.x or 3.x. Since I'm familiar with the 2.x stuff... How would you create a list containing the result of [insert operation] on another list? How would you do the above if you cared about memory usage? What tool do you use to debug your Python code? CW'd because the question should be.
0
1,711
false
0
1
Top 3 questions to test someones Python level, what would they be?
3,660,592
2
2
0
1
0
1
0.099668
0
If you had to judge someones level of Python understand in just 3 questions, what would you ask?
0
python
2010-09-07T16:17:00.000
0
3,660,503
Explain generators. Write unit tests for <important-piece-of-code>. Who is Alex Martelli?
0
1,711
false
0
1
Top 3 questions to test someones Python level, what would they be?
3,660,564
4
7
0
1
3
0
0.028564
1
I have substantial PHP experience, although I realize that PHP probably isn't the best language for a large-scale web crawler because a process can't run indefinitely. What languages do people suggest?
0
php,c++,python,web-crawler
2010-09-08T01:27:00.000
0
3,664,016
You could consider using a combination of python and PyGtkMozEmbed or PyWebKitGtk plus javascript to create your spider. The spidering could be done in javascript after the page and all other scripts have loaded. You'd have one of the few web spiders that supports javascript, and might pick up some hidden stuff the others don't see :)
0
6,849
false
0
1
What languages are good for writing a web crawler?
3,664,065
4
7
0
-3
3
0
-0.085505
1
I have substantial PHP experience, although I realize that PHP probably isn't the best language for a large-scale web crawler because a process can't run indefinitely. What languages do people suggest?
0
php,c++,python,web-crawler
2010-09-08T01:27:00.000
0
3,664,016
C# and C++ are probably the best two languages for this, it's just a matter of which you know better and which is faster (C# is probably easier). I wouldn't recommend Python, Javascript, or PHP. They will usually be slower in text processing compared to a C-family language. If you're looking to crawl any significant chunk of the web, you'll need all the speed you can get. I've used C# and the HtmlAgilityPack to do so before, it works relatively well and is pretty easy to pick up. The ability to use a lot of the same commands to work with HTML as you would XML makes it nice (I had experience working with XML in C#). You might want to test the speed of available C# HTML parsing libraries vs C++ parsing libraries. I know in my app, I was running through 60-70 fairly messy pages a second and pulling a good bit of data out of each (but that was a site with a pretty constant layout). Edit: I notice you mentioned accessing a database. Both C++ and C# have libraries to work with most common database systems, from SQLite (which would be great for a quick crawler on a few sites) to midrange engines like MySQL and MSSQL up to the bigger DB engines (I've never used Oracle or DB2 from either language, but it's possible).
0
6,849
false
0
1
What languages are good for writing a web crawler?
3,664,086
4
7
0
6
3
0
1
1
I have substantial PHP experience, although I realize that PHP probably isn't the best language for a large-scale web crawler because a process can't run indefinitely. What languages do people suggest?
0
php,c++,python,web-crawler
2010-09-08T01:27:00.000
0
3,664,016
Any language you can easily use with a good network library and support for parsing the formats you want to crawl. Those are really the only qualifications.
0
6,849
false
0
1
What languages are good for writing a web crawler?
3,664,054
4
7
0
0
3
0
1.2
1
I have substantial PHP experience, although I realize that PHP probably isn't the best language for a large-scale web crawler because a process can't run indefinitely. What languages do people suggest?
0
php,c++,python,web-crawler
2010-09-08T01:27:00.000
0
3,664,016
C++ - if you know what you're doing. You will not need a web server and a web application, because a web crawler is just a client, after all.
0
6,849
true
0
1
What languages are good for writing a web crawler?
3,664,049
1
1
0
2
1
0
1.2
1
I m trying to use smtp class from Python 2.6.4 to send smtp email from a WinXP VMware machine. After the send method is called, I always got this error: socket.error: [Errno 10061] No connection could be made because the target machine actively refused it. Few stuff I noticed: The same code works in the physical WinXP machine with user in/not in the domain, connected to the same smtp server. If I use the smtp server which is setup in the same VM machine, then it works. Any help is appreciate!
0
python,email,smtp,vmware
2010-09-08T03:23:00.000
0
3,664,438
The phrase "...because the target machine actively refused it" usually means there's a firewall that drops any unauthorized connections. Is there a firewall service on the SMTP server that's blocking the WinXP VM's IP address? Or, more likely: Is the SMTP server not configured to accept relays from the WinXP VM's IP address?
0
828
true
0
1
Python smtp connection is always failed in a VMware Windows machine
3,668,622
2
4
0
17
23
1
1
0
Matz, who invented Ruby, said that he designed the language to be more object-oriented than Python. How is Ruby more object-oriented than Python?
0
python,ruby,oop
2010-09-08T07:55:00.000
0
3,665,656
One example that's commonly given is len, which in Python is a built-in function. You may implement a special __len__ method in your objects which will be called by len, but len is still a function. In Ruby, objects just have the .length property/method so it appears more object oriented when you say obj.length rather than len(obj) although deep under the hood pretty much the same thing happens. That said, over the years Python have moved towards more object-orientation. Currently all objects (and implicitly user-defined objects) inherit from the object class. Meta-classes have also been added, and many of the built-in and core library classes have been organized into hierarchies with the help of ABCs (Abstract Base Classes). In my heavy usage of Python I have never found it lacking in the OO department. It can do everything I want it to do with objects. True, Ruby feels somewhat more purely OO, but at least in my experience this hasn't been a really practical concern.
0
5,970
false
0
1
How is Ruby more object-oriented than Python?
3,665,937
2
4
0
-2
23
1
-0.099668
0
Matz, who invented Ruby, said that he designed the language to be more object-oriented than Python. How is Ruby more object-oriented than Python?
0
python,ruby,oop
2010-09-08T07:55:00.000
0
3,665,656
It's simple, nearly everything in Ruby (including numbers) is an object; there are no scalar values.
0
5,970
false
0
1
How is Ruby more object-oriented than Python?
3,666,873
1
2
0
5
4
0
1.2
1
I am developing an email client in Python. Is it possible to check if an email contains an attachement just from the e-mail header without downloading the whole E-Mail?
0
python,email,imap,imaplib
2010-09-09T12:05:00.000
0
3,676,344
"attachment" is quite a broad term. Is an image for HTML message an attachment? In general, you can try analyzing content-type header. If it's multipart/mixed, most likely the message contains an attachment.
0
2,147
true
0
1
Is it possible to check if an email contains an attachement just from the e-mail header?
3,676,393
1
2
0
2
0
0
0.197375
0
I have textmate, but honestly the only thing I can do with it is simply edit a file. The handy little file browser is aslo useful. (how can I show/hide that file browser anyhow!) But I have no other knowledge/tricks up my sleeve, care to help me out?
0
python,pylons,textmate
2010-09-09T15:49:00.000
0
3,678,221
If you look under the Bundles menu in TextMate there is a Python-specific sub-menu that exposes a bunch of helpful things like syntax checking, script debugging, insertion of oft used code blocks, manual look ups and so on. Most of them are bound to keyboard shortcuts (or can be bound if they are not). Also, under the Bundles are sort of general-to-code or general-to-text-editing tasks in sub-menus. You can set up templates for new file creation that let you start new files with all the little bits and pieces you like to see in new files (copyright notice, author, SCC tags, etc.) See the File -> New From Template -> Edit Templates... menu option to do that. It ships with 4 Python templates already. Finally, that browser is called the Project Drawer. View -> Show Project Drawer to get it to show up. It'll only be available when the window you're viewing is a project window, not a single document window.
0
274
false
1
1
How can textmate make my python (pylons) development easier?
3,679,180
1
6
0
3
30
1
0.099668
0
I have a compiled Python library and API docs that I would like to use from Ruby. Is it possible to load a Python library, instantiate a class defined in it and call methods on that object from Ruby?
0
python,ruby
2010-09-09T18:33:00.000
0
3,679,501
Even you can make this work, you might want to consider if this is the best architectural choice. You could run into all sorts of versioning hell trying to maintain such a beast. If you really can't find an equivalent Ruby library (or it's a big investment in Python you want to leverage,) consider using a queue (like RabbitMQ) to implement a message passing design. Then you can keep your Python bits Python and your Ruby bits Ruby and not try to maintain a Frankenstein build environment.
0
27,863
false
0
1
Calling Python from Ruby
3,711,490
2
3
0
5
2
0
1.2
0
I was wondering is learning Python and Django a hard/time consuming process for someone who's already rather familiar with OO programming (C++/Java) and some web dev (Java EE)? I'm starting to look for a technology to implement a part of my master's thesis and since it will be a web app I'm considering Java EE (since I'm already familiar with it), Python/Django (since my professor suggested it and I'd really like to learn Python), Ruby on Rails (also my profs suggestion but somehow I don't feel like learning it) and PHP (the last suggestion but I despise PHP). Oh he also said he heard something about Scala, but from what I know Scala/Lift isn't all that mainstream yet and it might be problematic to work with it? My greatest concern is time since for the next 4-5months I'll be attending my normal courses, go to work and work on my thesis (then I'll have 4-5months for only work+my thesis) and I'm not sure will I find the time to learn a new language. The whole thing will be a web app for the teachers/students to both check and make their schedules at the uni (there will be some constraint programming etc etc and we want to implement an algorithm which would, based on data from previous years and some user input, create a schedule for the upcoming year). Personally I love java but my teacher said it's a performance hog and I'd like to know is python's performance better/worse?
0
java,python,django
2010-09-10T11:08:00.000
0
3,684,105
I'd ask your professor for some data to support "performance hog". Sounds like shallow thinking and FUD to me. Benchmarks can be found to support either position, so I don't pay much attention. The real reason to learn a language is so it can affect the way you think about programming. I think Python will be beneficial. Shame on your professor for not bringing that up. S/he's worried about performance? Ask when they last wrote code where performance mattered. I'm learning Python right now as a long-time Java guy. I think learning anything takes some time. I'm working my way through "Core Python Programming" by Wesley Chun. I'm enjoying it very much so far. I like the language. The ideas map pretty nicely onto what I already know about Java and OO, but there are differences (e.g., dynamic typing, functional programming, etc.) that are worth understanding. The most important thing is writing code. I'm working through the exercises carefully and getting it under my fingers and into my brain. I'm using PyCharm from JetBrains as my IDE. It's brilliant to have such a good tool at my fingertips. I started about a month ago. I'm about 1/3rd of the way through the exercises (reading is further ahead; about halfway). My goal is to finish it before the end of the year and feel comfortable enough to pick up Django. I hope you like it as much as I do. Good luck.
0
1,938
true
1
1
How hard is it to learn Python/Django for a Java EE dev?
3,684,170
2
3
0
0
2
0
0
0
I was wondering is learning Python and Django a hard/time consuming process for someone who's already rather familiar with OO programming (C++/Java) and some web dev (Java EE)? I'm starting to look for a technology to implement a part of my master's thesis and since it will be a web app I'm considering Java EE (since I'm already familiar with it), Python/Django (since my professor suggested it and I'd really like to learn Python), Ruby on Rails (also my profs suggestion but somehow I don't feel like learning it) and PHP (the last suggestion but I despise PHP). Oh he also said he heard something about Scala, but from what I know Scala/Lift isn't all that mainstream yet and it might be problematic to work with it? My greatest concern is time since for the next 4-5months I'll be attending my normal courses, go to work and work on my thesis (then I'll have 4-5months for only work+my thesis) and I'm not sure will I find the time to learn a new language. The whole thing will be a web app for the teachers/students to both check and make their schedules at the uni (there will be some constraint programming etc etc and we want to implement an algorithm which would, based on data from previous years and some user input, create a schedule for the upcoming year). Personally I love java but my teacher said it's a performance hog and I'd like to know is python's performance better/worse?
0
java,python,django
2010-09-10T11:08:00.000
0
3,684,105
If for your thesis and you have decided up front that you like it and want to use it, you have in my opinion the best situation conceivable. Go for it. Learn all you can. Do the best you can. This will happen again and again in your professional life, and you might as well have tried it in a situation where you have an experienced mentor handy (but do as the mentor says!)
0
1,938
false
1
1
How hard is it to learn Python/Django for a Java EE dev?
3,684,145
1
2
0
2
6
1
1.2
0
I am trying, so far unsuccessfully, at installing the rpy2 for python on my Mac OSX. I have tried Macports and DarwinPorts but have had no luck with import rpy2 within the python shell environment. I don't know much about programming in Mac and I am a wiz at installing modules on a Windoze based system, but for the life of me cannot do a simple port on my Mac at home. What I am after, if someone would be so kind, are "dumbed down" instructions for a successful install of rpy2 for Mac OSX Snow Leopard. Hopefully someone here has done this successfully and can outline the process they took? At least that is what I am hoping. Many thanks in advance!
0
python,macos,osx-snow-leopard,rpy2
2010-09-10T20:04:00.000
1
3,687,939
easy_install and rpy2 work fine together (just did it) but you need to have easy_install in sync with your specific python version. This comes down to controlling your $PATH and $PYTHONPATH environment variables so that the first Python directory that appears is the version you want and also has the easy_install version you want. Do not try to solve this by taking out the factory installed version of Python. You set your path variables in your home directory. If you are using the default bash shell, check .bash_profile for $ echo $PYTHONPATH /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ which will tell you where and in what order installed packages are searched for and $ echo $PATH /opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin: Rather than giving a recipe for how to set these if needed, I encourage you to consult the usual sources because a little knowledge is dangerous and rendering the shell inoperative by reasonable, but wrong, guesses is a real danger.
0
7,010
true
0
1
How to Install rpy2 on Mac OS X
3,792,577
7
8
0
6
10
1
1
0
I have a class named SSLXMLRPCServer. Should it be that or SslXmlRpcServer?
0
python,standards
2010-09-10T22:15:00.000
0
3,688,759
It should be SSLXMLRPCServer, to match the standard library classes like SimpleXMLRPCServer, CGIXMLRPCRequestHandler, etc. Adopting a naming convention that differs from equivalents in the standard library is only going to confuse people.
0
2,562
false
0
1
If my python class name has an acronym, should I keep it upper case, or only the first letter?
3,688,987
7
8
0
10
10
1
1
0
I have a class named SSLXMLRPCServer. Should it be that or SslXmlRpcServer?
0
python,standards
2010-09-10T22:15:00.000
0
3,688,759
This is a matter of personal preference, but I find the second format much easier to read. The fact that your first format has a typo in it (PRC instead or RPC) suggests that I am not the only one.
0
2,562
false
0
1
If my python class name has an acronym, should I keep it upper case, or only the first letter?
3,688,784
7
8
0
1
10
1
0.024995
0
I have a class named SSLXMLRPCServer. Should it be that or SslXmlRpcServer?
0
python,standards
2010-09-10T22:15:00.000
0
3,688,759
As stated already, PEP-8 says to use upper-case for acronym. Now, python zen also says "readability counts" (and for me the zen has priority over the PEP :-). My opinion in such unclear situation is to take into account the standard in the programming context, not just the language. For example, some xml-http-query class should be written XMLHttpQuery in a servlet context (w.r.t XMLHttpRequest). I don't know your context, but it seems XMLRPCServer exists and you want to attach ssl to it. So you could choose something like: SSL_XMLRPCServer It would emphasized the XMLRPCServer -without changing it-. Also, you'd stay close to PEP-8 and follow the zen :-) My 2 cents Note: if XMLRPCServer is not strongly related to your class and is really a standard in the domain, then you need to choose another name, as to not be confusing.
0
2,562
false
0
1
If my python class name has an acronym, should I keep it upper case, or only the first letter?
25,161,275
7
8
0
0
10
1
0
0
I have a class named SSLXMLRPCServer. Should it be that or SslXmlRpcServer?
0
python,standards
2010-09-10T22:15:00.000
0
3,688,759
How about SSL_XML_RPC_Server for acronymity and readability? It's what I often do when I want to avoid camel-case for some reason.
0
2,562
false
0
1
If my python class name has an acronym, should I keep it upper case, or only the first letter?
3,689,087
7
8
0
1
10
1
0.024995
0
I have a class named SSLXMLRPCServer. Should it be that or SslXmlRpcServer?
0
python,standards
2010-09-10T22:15:00.000
0
3,688,759
I normally uppercase acronyms. Twisted and a few other libraries do this as well.
0
2,562
false
0
1
If my python class name has an acronym, should I keep it upper case, or only the first letter?
3,688,773
7
8
0
0
10
1
0
0
I have a class named SSLXMLRPCServer. Should it be that or SslXmlRpcServer?
0
python,standards
2010-09-10T22:15:00.000
0
3,688,759
I had this problemlots of time . I uppercase Acronym but I doesn't like it because when you chain them (as in your example) it doesn't feel right. However I think the best things to do is to make a choice and stick to hit, so at least don't you know when you need to reference something how it's written without having to check (which is one of the benefit of coding standard)
0
2,562
false
0
1
If my python class name has an acronym, should I keep it upper case, or only the first letter?
3,688,821
7
8
0
3
10
1
0.07486
0
I have a class named SSLXMLRPCServer. Should it be that or SslXmlRpcServer?
0
python,standards
2010-09-10T22:15:00.000
0
3,688,759
The problem with uppercase acronyms in CamelCase names is that the word following the acronym looks like a part of it, since it begins with a capital letter. Also, when you have several in a row as in your example, it is not clear where each begins. For this reason, I would probably use your second choice.
0
2,562
false
0
1
If my python class name has an acronym, should I keep it upper case, or only the first letter?
3,688,836
1
1
0
1
2
0
0.197375
0
I've developed a website in Pylons (Python web framework) and have it running, on my production server, under Apache + mod_wsgi. I've been hearing a lot of good things about nginx recently and wanted to give it a try. Currently, it's running as a forwarding proxy to create a front end to Paste. It seems to be running pretty damn fast... Though, I could probably contribute that to me being the only one accessing it. What I want to know is, how will Paste hold up under a heavy load? Am I better off going with nginx + mod_wsgi ?
0
python,nginx,pylons,production-environment,paste
2010-09-11T04:11:00.000
0
3,689,766
Your app will be the bottleneck in performance not Apache or Paste. Nginx is used in lots of production servers so that bit will be fine. I don't know about mod_wsgi but uWSGI is used in production environments and plays well with both nginx and Paste applications. I currently run a server using Apache + Paste using Apache to serve static content and Paste to handle Pylons. When I stress tested the setup (using default settings on Apache) I got a lot of variation in the time it took to handle requests (varying from 0.5 to 10 secs). As a test I setup Nginx + uWSGI. Nginx is known to be very good for handling static content and I saw a 10x improvement in the number of files it could serve. The average response time for the Pylons app didn't change (it's DB bound) but the variability dropped to almost zero. Neither setup dropped a connection or failed to respond so based on this I'll be moving to Nginx + uWSGI for our next app, especially as it has a lot more static content.
0
693
false
1
1
Will nginx+paste hold up in a production environment?
3,711,301
1
5
0
2
7
1
0.07983
0
I have a program I'm writing in python, and I have the need to store some passwords. These passwords will be the passwords to ftp servers, so it's important that they're not just plainly visible to everybody. This also means that I can't store a non-reversible hash of the password like you would on a webserver, because I'm not checking if somebody inputs the right password, I'm just relaying the password to somebody else. So what's the best way to store passwords? I'm using python, and the program will be linux-only.
0
python,passwords,storage
2010-09-11T15:42:00.000
0
3,691,587
Depending on the distribution you can probably store it in the keychain if one is available. Otherwise take a look at some of the encryption algorithms available (PGP/GPG, DES, AES etc) and their Python ports/modules but this is hard stuff which you have to get right.
0
6,251
false
0
1
Storing passwords with python
3,691,597
3
3
0
0
2
0
0
0
I'm working on a python script that monitors a directory and uploads files that have been created or modified using scp. That's fine, except I want this to be done recursively, and I'm having a problem if a user creates a directory in the watch directory, and then modifies a file inside that new directory. I can detect the directory creation and file nested file creation/modification just fine. But if I try to upload that file to the remote server, it won't work since the directory on the remote site won't exist. Is there a simple way to do this WITHOUT recursively copying the created directory? I want to avoid this because I don't want to delete the remote folder if it exists. Also, please don't suggest rsync. It has to only use ssh and scp.
0
python,scp
2010-09-12T03:54:00.000
1
3,693,666
It's not exactly scp, but sftp can take the -b parameter with a batch file. You can send a mkdir and a put.
0
5,882
false
0
1
Using scp to transfer a single file into a remote folder that doesn't exist
3,693,682
3
3
0
2
2
0
1.2
0
I'm working on a python script that monitors a directory and uploads files that have been created or modified using scp. That's fine, except I want this to be done recursively, and I'm having a problem if a user creates a directory in the watch directory, and then modifies a file inside that new directory. I can detect the directory creation and file nested file creation/modification just fine. But if I try to upload that file to the remote server, it won't work since the directory on the remote site won't exist. Is there a simple way to do this WITHOUT recursively copying the created directory? I want to avoid this because I don't want to delete the remote folder if it exists. Also, please don't suggest rsync. It has to only use ssh and scp.
0
python,scp
2010-09-12T03:54:00.000
1
3,693,666
Since you have ssh, can't you just create the directory first? For example, given a file with absolute path /some/path/file.txt, issue a mkdir -p /home/path before uploading file.txt. UPDATE: If you're looking to lower the number of transactions, a better method might be to make a tar file locally, transfer that, and untar it.
0
5,882
true
0
1
Using scp to transfer a single file into a remote folder that doesn't exist
3,693,690
3
3
0
1
2
0
0.066568
0
I'm working on a python script that monitors a directory and uploads files that have been created or modified using scp. That's fine, except I want this to be done recursively, and I'm having a problem if a user creates a directory in the watch directory, and then modifies a file inside that new directory. I can detect the directory creation and file nested file creation/modification just fine. But if I try to upload that file to the remote server, it won't work since the directory on the remote site won't exist. Is there a simple way to do this WITHOUT recursively copying the created directory? I want to avoid this because I don't want to delete the remote folder if it exists. Also, please don't suggest rsync. It has to only use ssh and scp.
0
python,scp
2010-09-12T03:54:00.000
1
3,693,666
While I imagine your specific application will have its own quirks (as does mine), this may put you on the right path. Below is a short snippet from a script I use to put files onto a remote EC2 instance using Fabric built on paramiko. Also note I where I put the sudo commands as Fabric has its own "sudo" class. This is one of those quirks I was referring to. Hope this helps someone. from fabric.api import env, run, put, settings, cd from fabric.contrib.files import exists ''' sudo apt-get install fabric Initially setup for interaction with an AWS EC2 instance At the terminal prompt run: fab ec2 makeRemoteDirectory changePermissions putScript ''' TARGETPATH = '/your/path/here' def ec2(): env.hosts = ['your EC2 Instance or remote address'] env.user = 'user_name' env.key_filename = '/path/to/your/private_key.pem' def makeRemoteDirectory(): if not exists('%s'%TARGETPATH): run('sudo mkdir %s'%TARGETPATH) def changePermissions(): run('sudo chown -R %(user)s:%(user)s %(path)s'%{'user': env.user, 'path': TARGETPATH}) def putScript(): fileName = '/path/to/local/file' dirName = TARGETPATH put(fileName, dirName)
0
5,882
false
0
1
Using scp to transfer a single file into a remote folder that doesn't exist
4,294,064
1
3
0
1
0
0
0.066568
0
I have a webapp, created using CakePhp. I need to interface with a Python script. What is the best way to go about doing that? (I could use pipe etc., but I want to check what the best practices are) Thanks.
0
php,python,cakephp
2010-09-13T17:09:00.000
0
3,702,724
First of all, check what kinds of syndication CakePHP offers. It may expose part of its API through xmlrpc, json, RSS, and so on. If that's not an option, connect directly to the same database the CakePHP application uses. Or alternatively, implement some php code within your CakePHP framework that expors relevant data as JSON and interface with it.
0
1,320
false
0
1
Php/Cakephp interface with Python script
3,702,748
2
4
0
0
0
0
0
0
I use TextMate to debug python script, as I like the feature of using 'Command-R' for running python from TextMate, and I learned that emacs provide similar feature. I need to know if the python is run from command line or from TextMate/emacs. How can I do that? ADDED I use TextMate for python coding/debugging, and it's pretty useful. But, sometimes I need to run the test using command line. I normally turn on debugging/logging mode with TextMate, and off with command line mode. This is the reason I asked the question. Also, I plan to use emacs for python debugging, so I wanted to ask the case for emacs. I got an answer in the case with emacs, and I happen to solve this issue with TextMate. Set variables in Preferences -> Advanced -> Shell Variables, and I found that TM_ORGANIZATION_NAME is already there to be used. So, I'll just use this variable. Use this variable, if os.environ['TM_ORGANIZATION_NAME']: return True I guess the shell variable from TextMate disappear when I'm done using it.
0
python,emacs,textmate,environment
2010-09-13T17:32:00.000
0
3,702,889
Use Command-R to run the script directly Use Shift-Command-R to run the script from terminal.
0
521
false
0
1
How to know if I run python from Textmate/emacs?
3,703,093
2
4
0
1
0
0
0.049958
0
I use TextMate to debug python script, as I like the feature of using 'Command-R' for running python from TextMate, and I learned that emacs provide similar feature. I need to know if the python is run from command line or from TextMate/emacs. How can I do that? ADDED I use TextMate for python coding/debugging, and it's pretty useful. But, sometimes I need to run the test using command line. I normally turn on debugging/logging mode with TextMate, and off with command line mode. This is the reason I asked the question. Also, I plan to use emacs for python debugging, so I wanted to ask the case for emacs. I got an answer in the case with emacs, and I happen to solve this issue with TextMate. Set variables in Preferences -> Advanced -> Shell Variables, and I found that TM_ORGANIZATION_NAME is already there to be used. So, I'll just use this variable. Use this variable, if os.environ['TM_ORGANIZATION_NAME']: return True I guess the shell variable from TextMate disappear when I'm done using it.
0
python,emacs,textmate,environment
2010-09-13T17:32:00.000
0
3,702,889
sys.argv will tell you how Python was invoked. I don't know about TextMate, but when I tell Emacs to eval buffer, its value is ['-c']. That means it's executing a specified command, according to the man page. If Python's run directly from the command line with no parameters, sys.argv will be []. If you run a python script, it will have the script name and whatever arguments you pass it. You might want to set up your python-mode in Emacs and whatever the equivalent in TextMate is to put something special like -t in the command line. That's pretty hackish though. Maybe there's a better way.
0
521
false
0
1
How to know if I run python from Textmate/emacs?
3,702,945
1
3
0
5
2
0
1.2
0
I've been writing python scripts that run locally. I would now like to offer a service online using one of these python scripts and through the webhosting I have I can run python in the cgi-bin. The python script takes input from an html form filled in by the user, has the credentials and connects with a local database, calculates stuff using python libraries and sends out the results as HTML to be displayed. What I would like to know is what security precautions I should take. Here are my worries: What are the right file permissions for scripts called via web? 755? I am taking user input. How do I guarantee it is sanitized? I have user/pass for the database in the script. How do I prevent the script from being downloaded and the code seen? Can I install the other libraries next to the file? Do I have to worry about security of/in these as well? Do I set their permissions to 700? 744? Any other vulnerability I am unaware of?
0
python,security,cgi-bin
2010-09-13T19:17:00.000
0
3,703,621
check out owasp.org - you're now writing a web application, and you need to worry about everything web apps need to worry about. The list is too long and complicated to place here, but owasp is a good starting point.
0
2,862
true
0
1
Security precautions for running python in cgi-bin
3,703,723
2
3
0
2
6
1
0.132549
0
What are the top gotchas for someone moving from a static lang (java/c#) to dynamic language like python? It seems cool how things can be done, but renaming a method, or adding/removing parameters seems so risky! Is the only solution to write tests for each method?
0
java,python,dynamic-languages
2010-09-13T19:29:00.000
0
3,703,704
Some things that struck me when first trying out Python (coming from a mainly Java background): Write Pythonic code. Use idioms recommended for Python, rather than doing it the old Java/C way. This is more than just a cosmetic or dogmatic issue. Pythonic code is actually hugely faster in practice than C-like code practically all the time. As a matter of fact, IMHO a lot of the "Python is slow" notion floating around is due to the fact that inexperienced coders tried to code Java/C in Python and ended up taking a big performance hit and got the idea that Python is horribly slow. Use list comprehensions and map/filter/reduce whenever possible. Get comfortable with the idea that functions are truly objects. Pass them around as callbacks, make functions return functions, learn about closures etc. There are a lot of cool and almost magical stuff you can do in Python like renaming methods as you mention. These things are great to show off Python's features, but really not necessary if you don't need them. Indeed, as S. Lott pointed out, its better to avoid things that seem risky.
0
248
false
0
1
top gotchas for someone moving from a static lang (java/c#) to dynamic language like python
3,703,964
2
3
0
3
6
1
0.197375
0
What are the top gotchas for someone moving from a static lang (java/c#) to dynamic language like python? It seems cool how things can be done, but renaming a method, or adding/removing parameters seems so risky! Is the only solution to write tests for each method?
0
java,python,dynamic-languages
2010-09-13T19:29:00.000
0
3,703,704
"Is the only solution to write tests for each method?" Are you saying you didn't write tests for each method in Java? If you wrote tests for each method in Java, then -- well -- nothing changes, does it? renaming a method, seems so risky! Correct. Don't do it. adding/removing parameters seems so risky! What? Are you talking about optional parameters? If so, then having multiple overloaded names in Java seems risky and confusing. Having optional parameters seems simpler. If you search on SO for the most common Python questions, you'll find that some things are chronic questions. How to update the PYTHONPATH. Why some random floating-point calculation isn't the same as a mathematical abstraction might indicate. Using Python 3 and typing code from a Python 2 tutorial. Why Python doesn't have super-complex protected, private and public declarations. Why Python doesn't have an enum type. The #1 chronic problem seems to be using mutable objects as default values for a function. Simply avoid this.
0
248
false
0
1
top gotchas for someone moving from a static lang (java/c#) to dynamic language like python
3,703,732
1
3
1
2
8
1
0.132549
0
How is Python able to call C++ objects when the interpreter is C and has been built w/ a C compiler?
0
c++,python,boost-python
2010-09-14T19:16:00.000
0
3,712,125
C++ can interoperate with C by extern "C" declarations.
0
1,508
false
0
1
How does Boost.Python work?
3,712,249
1
5
0
0
1
0
0
0
I already search for it on Google but I didn't have luck.
0
python,module,attributes,return
2010-09-14T21:03:00.000
0
3,712,885
dir is what you need :)
0
282
false
0
1
Does Python have a method that returns all the attributes in a module?
3,713,156
1
7
0
2
3
1
0.057081
0
As a hobby project, I had like to implement a Morse code encoder and decoder in C++ and Python (both). I was wondering the right data structure I should use for that. Not only is this question related to this specific project, but in general, when one has to make predefined text replacements, what is the best and the fastest way of doing it? I would avoid re-inventing any data structure if possible (and I think it is). Please note that this is purely a learning exercise and I have always wondered what would be the best way of doing this. I can store the code and the corresponding character in a dictionary perhaps, then iterate over the text and make replacements. Is this the best way of doing this or can I do better?
0
c++,python,text
2010-09-15T13:54:00.000
0
3,718,304
On the Python side the string class' translate function is the way to go. On the C++ side I would go with a std::map to hold the character mapping. Then I would probably use std::for_each to do the look up and swap.
0
265
false
0
1
Predefined text replacements in C++ and Python
3,718,792
1
16
0
5
358
0
0.062419
0
I would like to see what is the best way to determine the current script directory in Python. I discovered that, due to the many ways of calling Python code, it is hard to find a good solution. Here are some problems: __file__ is not defined if the script is executed with exec, execfile __module__ is defined only in modules Use cases: ./myfile.py python myfile.py ./somedir/myfile.py python somedir/myfile.py execfile('myfile.py') (from another script, that can be located in another directory and that can have another current directory. I know that there is no perfect solution, but I'm looking for the best approach that solves most of the cases. The most used approach is os.path.dirname(os.path.abspath(__file__)) but this really doesn't work if you execute the script from another one with exec(). Warning Any solution that uses current directory will fail, this can be different based on the way the script is called or it can be changed inside the running script.
0
python
2010-09-15T14:34:00.000
1
3,718,657
Just use os.path.dirname(os.path.abspath(__file__)) and examine very carefully whether there is a real need for the case where exec is used. It could be a sign of troubled design if you are not able to use your script as a module. Keep in mind Zen of Python #8, and if you believe there is a good argument for a use-case where it must work for exec, then please let us know some more details about the background of the problem.
0
156,322
false
0
1
How do you properly determine the current script directory?
6,236,300
2
4
0
2
1
0
1.2
0
although there are many posts on the internet as well as some posts on stack overflow, I still want to ask about this nasty python "import" problem. OK. so, the open source code organization is usually like this: project/src/model.py; project/test/testmodel.py if I put the famous __init__.py in project directory and also in src/ and test/ subdirectories, and then put "from project.src import model" for the testmodel.py. it does not work! keep telling me that the Module named "project.src" is not found! how can I solve the problem without changing the code structure?
0
python
2010-09-15T20:11:00.000
0
3,721,415
Make sure you have the parent directory of project/ on your pythonpath, rather than the project directory. If you add the project path itself, imports like import project.src will look for project/project/src.
0
7,796
true
0
1
python import problem
3,721,515
2
4
0
0
1
0
0
0
although there are many posts on the internet as well as some posts on stack overflow, I still want to ask about this nasty python "import" problem. OK. so, the open source code organization is usually like this: project/src/model.py; project/test/testmodel.py if I put the famous __init__.py in project directory and also in src/ and test/ subdirectories, and then put "from project.src import model" for the testmodel.py. it does not work! keep telling me that the Module named "project.src" is not found! how can I solve the problem without changing the code structure?
0
python
2010-09-15T20:11:00.000
0
3,721,415
The directory where project is located is probably not in your python path.
0
7,796
false
0
1
python import problem
3,721,437
5
6
0
1
3
1
0.033321
0
Hi I'm currently learning Python since the syntax feels so succinct and the idioms match well with my mental model. However I'm also interested in learning about OS internals and reverse engineering software, which ultimately means knowing C in a rather thorough capacity. When originally picking a language I did lots of reading and comparisons, and it seems that a number thrown out a lot is that to write short idiomatic statements in Python would require the equivalent of a few hundred lines of C (I'd guess code for memory management, writing the code for dictionaries,lists etc) that we take for granted as built into the Python language. 1) With an average C programmer, is that 100-200 lines of code per Python idiom anywhere near accurate? Because C doesn't come built-in with Python-like constructs such as dictionaries/lists(with all their nice methods etc): 2) Do C programmers tend to build these constructs from scratch and then re-use them between projects to greatly reduce the actual amount of hand coding for their projects? I assume re-using libraries like boost:: stuff also again, reduces some of the boilerplate hand coding also... 3) But does using popular libraries and re-using common code one has written before in C for basic constructs/etc, how much does that revise the lines of code written in C compared to the code in Python of a enthusiast sized code base? I know specific numbers aren't possible, but is it possible with libraries, code reuse etc, to have a development time in C close to that of Python without being a Linus Torvalds style coding machine? Thanks!
0
python,c,comparison
2010-09-15T21:33:00.000
0
3,722,003
As I did serious c programming I read a book that claimed libraries are worth to write. (Especially in C which considered a low level language) Libraries are build for reuse. If you use libraries you write one line like detectFace( faceDesriptor ) or renderPDF( document) is doesn't matter whether an idiom in another language is more concise or not. Lines of code isn't a proper metric if it is about what would more efficient.
0
7,636
false
0
1
Python vs C : Line of Code Comparison vs Dev Time
3,722,153
5
6
0
1
3
1
0.033321
0
Hi I'm currently learning Python since the syntax feels so succinct and the idioms match well with my mental model. However I'm also interested in learning about OS internals and reverse engineering software, which ultimately means knowing C in a rather thorough capacity. When originally picking a language I did lots of reading and comparisons, and it seems that a number thrown out a lot is that to write short idiomatic statements in Python would require the equivalent of a few hundred lines of C (I'd guess code for memory management, writing the code for dictionaries,lists etc) that we take for granted as built into the Python language. 1) With an average C programmer, is that 100-200 lines of code per Python idiom anywhere near accurate? Because C doesn't come built-in with Python-like constructs such as dictionaries/lists(with all their nice methods etc): 2) Do C programmers tend to build these constructs from scratch and then re-use them between projects to greatly reduce the actual amount of hand coding for their projects? I assume re-using libraries like boost:: stuff also again, reduces some of the boilerplate hand coding also... 3) But does using popular libraries and re-using common code one has written before in C for basic constructs/etc, how much does that revise the lines of code written in C compared to the code in Python of a enthusiast sized code base? I know specific numbers aren't possible, but is it possible with libraries, code reuse etc, to have a development time in C close to that of Python without being a Linus Torvalds style coding machine? Thanks!
0
python,c,comparison
2010-09-15T21:33:00.000
0
3,722,003
I think Python is more productive for small projects (up to a few thousand lines of code). On the other hand, C is better suited for large projects (even though IMHO there are better languages for that, such as Ada): static type-checking allows to find many errors at compile time that are much more difficult to detect at run-time, especially in a large program. In a larger C project, the lack of lists and other powerful data structures that are found in Python can be compensated by implementing or using custom libraries. I agree with user stacker that by using well-designed libraries your C code can be pretty concise.
0
7,636
false
0
1
Python vs C : Line of Code Comparison vs Dev Time
7,054,149
5
6
0
6
3
1
1.2
0
Hi I'm currently learning Python since the syntax feels so succinct and the idioms match well with my mental model. However I'm also interested in learning about OS internals and reverse engineering software, which ultimately means knowing C in a rather thorough capacity. When originally picking a language I did lots of reading and comparisons, and it seems that a number thrown out a lot is that to write short idiomatic statements in Python would require the equivalent of a few hundred lines of C (I'd guess code for memory management, writing the code for dictionaries,lists etc) that we take for granted as built into the Python language. 1) With an average C programmer, is that 100-200 lines of code per Python idiom anywhere near accurate? Because C doesn't come built-in with Python-like constructs such as dictionaries/lists(with all their nice methods etc): 2) Do C programmers tend to build these constructs from scratch and then re-use them between projects to greatly reduce the actual amount of hand coding for their projects? I assume re-using libraries like boost:: stuff also again, reduces some of the boilerplate hand coding also... 3) But does using popular libraries and re-using common code one has written before in C for basic constructs/etc, how much does that revise the lines of code written in C compared to the code in Python of a enthusiast sized code base? I know specific numbers aren't possible, but is it possible with libraries, code reuse etc, to have a development time in C close to that of Python without being a Linus Torvalds style coding machine? Thanks!
0
python,c,comparison
2010-09-15T21:33:00.000
0
3,722,003
Boost is C++, not C (emphatically not C -- virtually all of it makes heavy use of templates and such that aren't part of C). Yes, C programmers tend to build up personal libraries of code for all sorts of "stuff" -- data structures, algorithms, user interfaces, and so on. There are also a fair number of other libraries for everything from basic string manipulation to database connectivity, user interfaces, basic algorithms and data structures, etc. Comparing productivity between the two can be difficult though -- even if something can be done in one line of code either way, there's a greater chance that the C programmer will end up doing extra work to find and learn to use that particular library. OTOH, if he has used it before, the two might be directly competitive of (in a few cases) C might be more productive. I'd guess Python ends up more productive more often, but trying to guess how much so is difficult (and lines of code usually won't be a good indication either).
0
7,636
true
0
1
Python vs C : Line of Code Comparison vs Dev Time
3,722,185
5
6
0
10
3
1
1
0
Hi I'm currently learning Python since the syntax feels so succinct and the idioms match well with my mental model. However I'm also interested in learning about OS internals and reverse engineering software, which ultimately means knowing C in a rather thorough capacity. When originally picking a language I did lots of reading and comparisons, and it seems that a number thrown out a lot is that to write short idiomatic statements in Python would require the equivalent of a few hundred lines of C (I'd guess code for memory management, writing the code for dictionaries,lists etc) that we take for granted as built into the Python language. 1) With an average C programmer, is that 100-200 lines of code per Python idiom anywhere near accurate? Because C doesn't come built-in with Python-like constructs such as dictionaries/lists(with all their nice methods etc): 2) Do C programmers tend to build these constructs from scratch and then re-use them between projects to greatly reduce the actual amount of hand coding for their projects? I assume re-using libraries like boost:: stuff also again, reduces some of the boilerplate hand coding also... 3) But does using popular libraries and re-using common code one has written before in C for basic constructs/etc, how much does that revise the lines of code written in C compared to the code in Python of a enthusiast sized code base? I know specific numbers aren't possible, but is it possible with libraries, code reuse etc, to have a development time in C close to that of Python without being a Linus Torvalds style coding machine? Thanks!
0
python,c,comparison
2010-09-15T21:33:00.000
0
3,722,003
but is it possible with libraries, code reuse etc, to have a development time in C close to that of Python No. You've missed the most important point. Python's interactive. It's not edit-compile-link-execute-break-debug. It's edit-debug.
0
7,636
false
0
1
Python vs C : Line of Code Comparison vs Dev Time
3,722,732
5
6
0
0
3
1
0
0
Hi I'm currently learning Python since the syntax feels so succinct and the idioms match well with my mental model. However I'm also interested in learning about OS internals and reverse engineering software, which ultimately means knowing C in a rather thorough capacity. When originally picking a language I did lots of reading and comparisons, and it seems that a number thrown out a lot is that to write short idiomatic statements in Python would require the equivalent of a few hundred lines of C (I'd guess code for memory management, writing the code for dictionaries,lists etc) that we take for granted as built into the Python language. 1) With an average C programmer, is that 100-200 lines of code per Python idiom anywhere near accurate? Because C doesn't come built-in with Python-like constructs such as dictionaries/lists(with all their nice methods etc): 2) Do C programmers tend to build these constructs from scratch and then re-use them between projects to greatly reduce the actual amount of hand coding for their projects? I assume re-using libraries like boost:: stuff also again, reduces some of the boilerplate hand coding also... 3) But does using popular libraries and re-using common code one has written before in C for basic constructs/etc, how much does that revise the lines of code written in C compared to the code in Python of a enthusiast sized code base? I know specific numbers aren't possible, but is it possible with libraries, code reuse etc, to have a development time in C close to that of Python without being a Linus Torvalds style coding machine? Thanks!
0
python,c,comparison
2010-09-15T21:33:00.000
0
3,722,003
Depends greatly on the task and the size of the project. For many small interesting tasks, I would not be surprised by 100:1 smaller Python code simply because the standard libraries are extremely good. If you find, buy, or build C/C++ libraries that do what you want, I imagine the ratio would be much more like 3:1 on big projects. However, finding, buying, and building C/C++ libraries does take time and effort, so I believe in the vast majority of cases, Python is going to be much faster to develop in.
0
7,636
false
0
1
Python vs C : Line of Code Comparison vs Dev Time
3,790,500
5
7
0
1
3
0
0.028564
0
I am writing a python/pygtk application that is adding some custom scripts (bash) in a certain folder in $HOME (eg. ~/.custom_scripts). I want to make that folder available in $PATH. So every time the python app is adding the script, that script could be instantly available when the user is opening a terminal (eg. gnome-terminal). Where do you suggest to "inject" that $PATH dependecy ? .bashrc, /etc/profile.d, etc. ? What advantages / disadvantages I might encounter ? For example if i add a script to export the new path in /etc/profile.d, the path is not being updated until I re-login. Thanks
0
python,scripting,path,bash
2010-09-16T19:17:00.000
1
3,729,965
You shouldn't. It's the user choice whether he wants that in the PATH, in what cases and how to achieve that. What you can do is inform the user about the directory where your scripts reside and suggest putting it to the PATH. Or maybe you're asking from the user's perspective?
0
3,792
false
0
1
How to update $PATH
3,730,090
5
7
0
2
3
0
0.057081
0
I am writing a python/pygtk application that is adding some custom scripts (bash) in a certain folder in $HOME (eg. ~/.custom_scripts). I want to make that folder available in $PATH. So every time the python app is adding the script, that script could be instantly available when the user is opening a terminal (eg. gnome-terminal). Where do you suggest to "inject" that $PATH dependecy ? .bashrc, /etc/profile.d, etc. ? What advantages / disadvantages I might encounter ? For example if i add a script to export the new path in /etc/profile.d, the path is not being updated until I re-login. Thanks
0
python,scripting,path,bash
2010-09-16T19:17:00.000
1
3,729,965
.profile would be a reasonable place if it's a per-user install; /etc/profile.d for system-wide installs. (You'll need root to do that, of course.) Your installer won't be able to change the path of the current shell (unless it's being run via source, which would be...odd.)
0
3,792
false
0
1
How to update $PATH
3,730,011
5
7
0
2
3
0
0.057081
0
I am writing a python/pygtk application that is adding some custom scripts (bash) in a certain folder in $HOME (eg. ~/.custom_scripts). I want to make that folder available in $PATH. So every time the python app is adding the script, that script could be instantly available when the user is opening a terminal (eg. gnome-terminal). Where do you suggest to "inject" that $PATH dependecy ? .bashrc, /etc/profile.d, etc. ? What advantages / disadvantages I might encounter ? For example if i add a script to export the new path in /etc/profile.d, the path is not being updated until I re-login. Thanks
0
python,scripting,path,bash
2010-09-16T19:17:00.000
1
3,729,965
For scripts that go in the $HOME directory you'd typically use $HOME/bin folder instead which is (usually) on the path.
0
3,792
false
0
1
How to update $PATH
3,730,014
5
7
0
1
3
0
1.2
0
I am writing a python/pygtk application that is adding some custom scripts (bash) in a certain folder in $HOME (eg. ~/.custom_scripts). I want to make that folder available in $PATH. So every time the python app is adding the script, that script could be instantly available when the user is opening a terminal (eg. gnome-terminal). Where do you suggest to "inject" that $PATH dependecy ? .bashrc, /etc/profile.d, etc. ? What advantages / disadvantages I might encounter ? For example if i add a script to export the new path in /etc/profile.d, the path is not being updated until I re-login. Thanks
0
python,scripting,path,bash
2010-09-16T19:17:00.000
1
3,729,965
~/.bashrc is read every time gnome-terminal is opened, (assuming the user has SHELL set to /bin/bash). Be sure to check os.environ['PATH'] to see if the directory has already been added, so that the script doesn't add it more than once.
0
3,792
true
0
1
How to update $PATH
3,730,027
5
7
0
1
3
0
0.028564
0
I am writing a python/pygtk application that is adding some custom scripts (bash) in a certain folder in $HOME (eg. ~/.custom_scripts). I want to make that folder available in $PATH. So every time the python app is adding the script, that script could be instantly available when the user is opening a terminal (eg. gnome-terminal). Where do you suggest to "inject" that $PATH dependecy ? .bashrc, /etc/profile.d, etc. ? What advantages / disadvantages I might encounter ? For example if i add a script to export the new path in /etc/profile.d, the path is not being updated until I re-login. Thanks
0
python,scripting,path,bash
2010-09-16T19:17:00.000
1
3,729,965
/etc/profile.d would add it to every user's path ~/.bashrc would just be your own you can always do "$ source ~/.bashrc" to re-read the config files.
0
3,792
false
0
1
How to update $PATH
3,730,001
1
2
0
5
2
0
1.2
0
Is there some ready-made addon that alerts admins about memcached instance being inaccessible from a Django application? I don't mean here monitoring memcached daemon itself, but something that checks if my Django app benefits from caching. My basic idea is to check if cache.get that follow cache.set actually returns something, and if not - then send email to admins, but only one per hour, to not flood the inbox. But maybe there is something more advanced out there ?
0
python,django,memcached,python-memcached
2010-09-17T12:11:00.000
0
3,735,183
You should monitor your infrastructure. You can use a huge variety of tools for this, look on server fault for more discussions on monitoring. You should probably monitor your cache hit rate and trend it in your monitoring system; if it falls below a figure (say 90%) then you can alert that the cache has stopped working or something. Memcached itself will have some way of monitoring hit rate, but that will be overall rather than for a specific part of your application. You probably want to monitor the hit rate for a specific cache instance in your code so you can be sure it's continuing to be effective.
0
481
true
1
1
Django - alert when memcached is down
3,735,232
1
2
0
4
3
0
1.2
1
Is it possible that CherryPy, in its default configuration, is caching the responses to one or more of my request handlers? And, if so, how do I turn that off?
0
python,http,cherrypy
2010-09-17T15:15:00.000
0
3,736,606
CherryPy has a caching Tool, but it's never on by default. Most HTTP responses are cacheable by default, though, so look for an intermediate cache between your client and server. Look at the browser first. If you're not sure whether or not your content is being cached, compare the Date response header to the current time.
0
2,007
true
0
1
How to determine if CherryPy is caching responses?
3,737,124
1
1
0
1
4
1
0.197375
0
I am building a system that has dependencies such as Apache, Postgresql, and mod_wsgi. As part of my deployment process, I would like to write a sanity-checking script that tries to determine whether the server environment conforms to various assumptions, the most basic of which is whether the dependencies are installed. Checks I have considered: Check the service is responding, e.g. make an HTTP request, connect to a database, etc. Check somehow that a service is running, e.g. maybe grepping ps ax? (This seems unreliable) Check that the package is installed, e.g. through querying dpkg. These obviously go in order of decreasing specificity, the hope being that if one test fails, I might find out why by running a more specific test. But where do I stop? How many levels of specificity should I check? Are there any best practices for doing this sort of thing? Thanks!
0
python,deployment,packages
2010-09-19T14:29:00.000
0
3,746,090
I would run the program and do proper try..except at place of first use of feature in informative message to user for what is missing (not installed db, installed but not running etc)
0
533
false
0
1
Best practices for programmatically sanity checking environment using Python?
3,746,128
2
4
0
4
8
1
0.197375
0
I am amazed by how Expect (TCL) can automate a lot of things I normally could not do. I thought I could dig deeper into Expect by reading a book, but before I do that I want to ask if there are other solutions/languages that could do what Expect does? Eg. I have read that people compare Expect with Awk and also Perl. Could Awk and Perl do the same thing? How about other languages like Python and Ruby? Is Expect the de-facto automation tool or are there other solutions/languages that are more superior?
0
python,perl,awk,tcl,expect
2010-09-19T15:11:00.000
1
3,746,221
ajsie asks, "Which other automation tools are you talking about?" I'll answer a different question: "which other contexts do I have in mind"? The answer: any interactive environment OTHER than a stdio one. Expect is NOT for automation of GUI points-and-clicks, for example. Expect is also not available for Win* non-console applications, even if they look as though they are character-oriented (such exist). An exciting counter-realization: Expect is for automation of wacky equipment that permits control by a term-like connection. If your diesel engine (or, more typically, telecomm iron) says it can be monitored by hooking up a telnet-like process (even through an old-style serial line, say), you're in a domain where Expect has a chance to work its magic.
0
1,532
false
0
1
Other solutions/languages that are superior to the TCL-based Expect?
3,747,275
2
4
0
9
8
1
1.2
0
I am amazed by how Expect (TCL) can automate a lot of things I normally could not do. I thought I could dig deeper into Expect by reading a book, but before I do that I want to ask if there are other solutions/languages that could do what Expect does? Eg. I have read that people compare Expect with Awk and also Perl. Could Awk and Perl do the same thing? How about other languages like Python and Ruby? Is Expect the de-facto automation tool or are there other solutions/languages that are more superior?
0
python,perl,awk,tcl,expect
2010-09-19T15:11:00.000
1
3,746,221
There's more to it. Bluntly, the original Expect--the Tcl Expect--is the best one. It better supports "interact" and various pty eccentricities than any of its successors. It has no superior, for what it does. HOWEVER, at the same time, most Expect users exploit such a small fraction of Expect's capabilities that this technical superiority is a matter of indifference to them. In nearly all cases, I advise someone coming from Perl to use Expect.pm, someone familiar with Python to rely on Pexpect, and so on. Naive comparisons of Perl with "... Awk and also Perl" are ill-founded. In the abstract, all the common scripting languages--Lua, awk, sh, Tcl, Ruby, Perl, Python, ...--are about the same. Expect slightly but very effectively extends this common core in the direction of pty-awareness (there's a little more to the story that we can neglect for the moment). Roughly speaking, if your automation involves entering an invisible password, you want Expect. Awk and Perl do NOT build in this capability. There are other automation tools for other contexts.
0
1,532
true
0
1
Other solutions/languages that are superior to the TCL-based Expect?
3,747,203
2
2
0
7
1
1
1
0
I have been wanting to get into Python for a while now and have accumulated quite a few links to tutorials, books, getting started guides and the like. I have done a little programming in PERL and PHP, but mostly just basic stuff. I'd like to be able to set expectations for myself, so based on the following requirements how long do you think it will take to get this app up and running? Online Collection DB Users can create accounts that are authenticated through token sent via e-mail Once logged in, users can add items to pre-created collections (like "DVD" or "Software") Each collection has it's own template with attributes (ie: DVD has Name, Year, Studio, Rating, Comments, etc) Users can list all items in collections (all DVDs, all Software), sort by various attributes Also: Yes I know there are lots of online tools like this, but I want to build it on my own with Python
0
python
2010-09-20T04:31:00.000
0
3,748,720
Assuming you're already familiar with another programming language: Time to learn python basics: 1 week. Total time to figure out email module: 2 days. Total time to figure out httplib module: 1 days. Total time to figure out creating database: 3 days. Total time to learn about SQL: 2 weeks. Total time to figure out that you probably don't need SQL: 1 week. Total time writing the rest of the logic in python: 1 week. Probably...
0
221
false
0
1
Complete newbie excited about Python. How hard would this app be to build?
3,748,735
2
2
0
0
1
1
0
0
I have been wanting to get into Python for a while now and have accumulated quite a few links to tutorials, books, getting started guides and the like. I have done a little programming in PERL and PHP, but mostly just basic stuff. I'd like to be able to set expectations for myself, so based on the following requirements how long do you think it will take to get this app up and running? Online Collection DB Users can create accounts that are authenticated through token sent via e-mail Once logged in, users can add items to pre-created collections (like "DVD" or "Software") Each collection has it's own template with attributes (ie: DVD has Name, Year, Studio, Rating, Comments, etc) Users can list all items in collections (all DVDs, all Software), sort by various attributes Also: Yes I know there are lots of online tools like this, but I want to build it on my own with Python
0
python
2010-09-20T04:31:00.000
0
3,748,720
Assuming that you don't write everything from the ground up and reuse basic components, this shouldn't be too hard. Probably the most difficult aspect will be authentication, because that requires domain specific knowledge and is hard to get right in any language. I would suggest starting with the basic functionality, even maybe learn how to get it up and running on App Engine, and then once you have the basic functionality, then you can deal with the business of authentication and users.
0
221
false
0
1
Complete newbie excited about Python. How hard would this app be to build?
3,748,731
1
2
0
0
0
0
0
0
I have a python script which generates some reports based on a DB. I am testing the script using java Db Units which call the python script. My question is how can I verify the code coverage for the python script while I am running the DB Units?
0
python,code-coverage
2010-09-20T08:26:00.000
0
3,749,729
I don't know how you can check for inter-language unit test coverage. You will have to tweak the framework yourself to achieve something like this. That said, IMHO this is a wrong approach to take for various reasons. Inter-language disqualifies the tests from being described as "unit". These are functional tests. and thereby shouldn't care about code coverage (See @Ned's comment below). If you must (unit) test the Python code then I suggest that you do it using Python. This will also solve your problem of checking for test coverage. If you do want to function test then it would be good idea to keep Python code coverage checks away from Java. This would reduce the coupling between the Java and Python code. Tests are code after all and it is usually a good idea to reduce coupling between parts.
0
172
false
0
1
While running some java DB Unit tests which call a python script how can I test the code coverage for the python script?
3,749,902
2
6
0
1
1
0
0.033321
0
I'm writing an application and I'd like it to somehow schedule an email to be sent at a later date (likely an hour after it is run). The programming language will be Python or Java. Any open-source tools available for that purpose? EDIT: I forgot to mention it's to be run after a test run, so the application will already be down and I believe the Quartz solution wouldn't work. Would this be possible? Ideally, I'd like to hear that SMTP protocol has some hidden stuff that allows this, and would just require adding some flag to the message and email providers would interpret as to having to send them later.
0
java,python,email,scheduling
2010-09-20T17:47:00.000
0
3,753,982
I don't think standard SMTP protocol has such a feature, so if you want to be platform-independent, you will have to search for another solution. How about writing your message to a queue (local database, for example) with a timestamp and then have some program watching it periodically and send pending emails out? Is the delay an exact timedelta or is it "1-2 hours later"? If it is the latter, than you can have an hourly job (cronjob starting every hour or a background job sleeping for an hour), which would then send out the emails.
0
4,238
false
0
1
Scheduling a time in the future to send an email in Java or Python
3,754,181
2
6
0
2
1
0
0.066568
0
I'm writing an application and I'd like it to somehow schedule an email to be sent at a later date (likely an hour after it is run). The programming language will be Python or Java. Any open-source tools available for that purpose? EDIT: I forgot to mention it's to be run after a test run, so the application will already be down and I believe the Quartz solution wouldn't work. Would this be possible? Ideally, I'd like to hear that SMTP protocol has some hidden stuff that allows this, and would just require adding some flag to the message and email providers would interpret as to having to send them later.
0
java,python,email,scheduling
2010-09-20T17:47:00.000
0
3,753,982
You can build the actual email to send, using JavaMail (with attachments and all), save it to disk, and then delegate a "mail [email protected] < textfilefromjavamail" to the Linux batch system. There is an "at" command which will most likely do exactly what you want.
0
4,238
false
0
1
Scheduling a time in the future to send an email in Java or Python
3,754,446
1
3
0
1
1
0
0.066568
0
I'm curious how to copy the permission from directory to another. Any idea? Thanks
0
python,permissions
2010-09-20T19:33:00.000
1
3,754,848
Try cp -a from_dir to_dir. It will maintain the permissions from the first directory.
0
1,862
false
0
1
How to copy directory permissions
3,754,917
1
4
0
3
6
0
0.148885
0
Is there any production ready open source twitter clones written in Ruby or Python ? I am more interested in feature rich implementations, not just bare bones twitter like messages (e.g.: APIs, FBconnect, Notifications, etc) Thanks !
0
python,ruby,twitter
2010-09-21T08:16:00.000
0
3,758,440
I know of twissandra which is an open source clone. Of course I doubt it meets your need of feature rich implementations.
0
2,578
false
1
1
Open source Twitter clone (in Ruby/Python)
3,758,455
2
5
0
2
4
0
0.07983
0
I'm writing an application where quite a bit of the computational time will be devoted to performing basic linear algebra operations (add, multiply, multiply by vector, multiply by scalar, etc.) on sparse matrices and vectors. Up to this point, we've built a prototype using C++ and the Boost matrix library. I'm considering switching to Python, to ease of coding the application itself, since it seems the Boost library (the easy C++ linear algebra library) isn't particularly fast anyway. This is a research/proof of concept application, so some reduction of run time speed is acceptable (as I assume C++ will almost always outperform Python) so long as coding time is also significantly decreased. Basically, I'm looking for general advice from people who have used these libraries before. But specifically: 1) I've found scipy.sparse and and pySparse. Are these (or other libraries) recommended? 2) What libraries beyond Boost are recommended for C++? I've seen a variety of libraries with C interfaces, but again I'm looking to do something with low complexity, if I can get relatively good performance. 3) Ultimately, will Python be somewhat comparable to C++ in terms of run time speed for the linear algebra operations? I will need to do many, many linear algebra operations and if the slowdown is significant then I probably shouldn't even try to make this switch. Thank you in advance for any help and previous experience you can relate.
0
c++,python,linear-algebra
2010-09-21T15:45:00.000
0
3,761,994
I don't have directly applicable experience, but the scipy/numpy operations are almost all implemented in C. As long as most of what you need to do is expressed in terms of scipy/numpy functions, then your code shouldn't be much slower than equivalent C/C++.
1
3,064
false
0
1
Python vs. C++ for an application that does sparse linear algebra
3,762,217
2
5
0
1
4
0
0.039979
0
I'm writing an application where quite a bit of the computational time will be devoted to performing basic linear algebra operations (add, multiply, multiply by vector, multiply by scalar, etc.) on sparse matrices and vectors. Up to this point, we've built a prototype using C++ and the Boost matrix library. I'm considering switching to Python, to ease of coding the application itself, since it seems the Boost library (the easy C++ linear algebra library) isn't particularly fast anyway. This is a research/proof of concept application, so some reduction of run time speed is acceptable (as I assume C++ will almost always outperform Python) so long as coding time is also significantly decreased. Basically, I'm looking for general advice from people who have used these libraries before. But specifically: 1) I've found scipy.sparse and and pySparse. Are these (or other libraries) recommended? 2) What libraries beyond Boost are recommended for C++? I've seen a variety of libraries with C interfaces, but again I'm looking to do something with low complexity, if I can get relatively good performance. 3) Ultimately, will Python be somewhat comparable to C++ in terms of run time speed for the linear algebra operations? I will need to do many, many linear algebra operations and if the slowdown is significant then I probably shouldn't even try to make this switch. Thank you in advance for any help and previous experience you can relate.
0
c++,python,linear-algebra
2010-09-21T15:45:00.000
0
3,761,994
Speed nowdays its no longer an issue for python since ctypes and cython emerged. Whats brilliant about cython is that your write python code and it generates c code without requiring from you to know a single line of c and then compiles to a library or you could even create a stanalone. Ctypes also is similar though abit slower. From the tests I have conducted cython code is as fast as c code and that make sense since cython code is translated to c code. Ctypes is abit slower. So in the end its a question of profiling , see what is slow in python and move it to cython, or you could wrap your existing c libraries for python with cython. Its quite easy to achieve c speeds this way. So I will recommend not to waste the effort you invested creating these c libraries , wrap them with cython and do the rest with python. Or you could do all of it with cython if you wish as cython is python bar some limitations. And even allows you to mix c code as well. So you could do part of it in c and part of it python/cython. Depending what makes you feel more comfortable. Numpy ans SciPy could be used as well for saving more time and providing ready to use solutions to your problems / needs.You should certainly check them out. Numpy has even has weaver a tool that let you inline c code inside your python code, just like you can inline assembly code inside your c code. But i think you would prefer to use cython . Remember because cython is both c and python at the same time it allows you to use directly c and python libraries.
1
3,064
false
0
1
Python vs. C++ for an application that does sparse linear algebra
3,762,759
2
5
1
1
0
0
0.039979
0
I am interested in programming for Mobile Devices. Now I have a phone which runs Symbian S60 3rd, which is one of my motivations for programming for mobile devices. Now, my question is, which one is better to go for? Python or C++? I have a good background in C++ (ANSI), Java and C#. Thanks.
0
c++,python,symbian
2010-09-21T19:31:00.000
0
3,763,766
Python is more easy to use, but you have to know that a mobile is normally a very strict environment, so is possible that C++ be a better alternative.
0
1,838
false
0
1
Python or C++? Programming for mobile devices
3,763,786
2
5
1
2
0
0
1.2
0
I am interested in programming for Mobile Devices. Now I have a phone which runs Symbian S60 3rd, which is one of my motivations for programming for mobile devices. Now, my question is, which one is better to go for? Python or C++? I have a good background in C++ (ANSI), Java and C#. Thanks.
0
c++,python,symbian
2010-09-21T19:31:00.000
0
3,763,766
There's a large learning curve associated with Symbian C++, if you want to do a quick prototype probably do it in Python. It depends on what you want your application to do. I believe the Symbian Python implementation was done in some Symbian developers spare time so it may not give you access to everything on the phone. Symbian C++ will give you access to almost everything. Also, Java and MIDP may be useful to you too.
0
1,838
true
0
1
Python or C++? Programming for mobile devices
3,763,991
1
4
0
-6
5
0
-1
1
I am trying to use python's imaplib to create an email and send it to a mailbox with specific name, e.g. INBOX. Anyone has some great suggestion :).
0
python,imaplib
2010-09-22T13:28:00.000
0
3,769,701
No idea how they do it but doesn't Microsoft Outlook let you move an email from a local folder to a remote IMAP folder?
0
18,674
false
0
1
How to create an email and send it to specific mailbox with imaplib
3,787,209
1
3
0
1
8
0
0.066568
0
I'm sure you've seen the "the connection was reset" message displayed when trying to browse web pages. (The text is from Firefox, other browsers differ.) I need to generate that message/error/condition on demand, to test workarounds. So, how do I generate that condition programmatically? (How to generate a TCP RST from PHP -- or one of the other web-app languages?) Caveats and Conditions: It cannot be a general IP block. The test client must still be able to see the test server when not triggering the condition. Ideally, it would be done at the web-application level (Python, PHP, Coldfusion, Javascript, etc.). Access to routers is problematic. Access to Apache config is a pain. Ideally, it would be triggered by fetching a specific web-page. Bonus if it works on a standard, commercial web host. Update: Sending RST is not enough to cause this condition. See my partial answer, below. I've a solution that works on a local machine, Now need to get it working on a remote host.
0
php,python,sockets,web-applications,tcp
2010-09-22T20:56:00.000
0
3,773,566
I believe you need to close the low-level socket fairly abruptly. You won't be able to do it from Javascript. For the other languages you'll generally need to get a handle on the underlying socket object and close() it manually. I also doubt you can do this through Apache since it is Apache and not your application holding the socket. At best your efforts are likely to generate a HTTP 500 error which is not what you're after.
0
3,959
false
1
1
How do I generate a connection reset programatically?
3,773,702
2
4
0
5
16
1
0.244919
0
For a project I'm currently working on, I'm looking to embed a scripting engine into my C++ code to allow for some extensibility down the line. The application will require a fair amount of text processing and the use of regular expressions within these scripts. I know Lua is generally the industry darling when it comes to embedded scripting, but I also know it doesn't support regular expressions (at least out of the box). This is causing me to lean toward python for my language to embed, as it seems to have the best support behind Lua and still offers powerful regex capabilities. Is this the right choice? Should I be looking at another language? Is there a reason I should give Lua a second look?
0
c++,python,scripting,lua,embedded-language
2010-09-22T22:30:00.000
0
3,774,108
Having incorporated Lua in one of my C projects myself, I'll suggest Lua, as this is easier. But that depends on what your scripting language needs to be capable of. Lua rose to the de-facto scripting language of games. If you need advanced scripting capabilities, you might use Python, but if it's just for easy scripting support, take Lua. From what I've seen, Lua is easier to learn for newbees, that aren't used to scripting. I'd argue, that Lua is lighter, if you need to have external packages, you can add them, but the point is, the atomic part of Lua, is much smaller than that of Python.
0
9,483
false
0
1
Python vs Lua for embedded scripting/text processing engine
3,774,415
2
4
0
4
16
1
0.197375
0
For a project I'm currently working on, I'm looking to embed a scripting engine into my C++ code to allow for some extensibility down the line. The application will require a fair amount of text processing and the use of regular expressions within these scripts. I know Lua is generally the industry darling when it comes to embedded scripting, but I also know it doesn't support regular expressions (at least out of the box). This is causing me to lean toward python for my language to embed, as it seems to have the best support behind Lua and still offers powerful regex capabilities. Is this the right choice? Should I be looking at another language? Is there a reason I should give Lua a second look?
0
c++,python,scripting,lua,embedded-language
2010-09-22T22:30:00.000
0
3,774,108
dont forget the grand-daddy of them all - tcl there is a c++ wrapper for tcl which makes it incredibly easy to embed i am using it in a current project in previous (c#) project I used lua over python. In older c# projects I had used python; I chose lua because the syntax is more normal for average scripter (used to vbscript or javascript). However I will change back to (iron)python for next c# project; lua is just too obscure For c++ I will always use tcl from now on EDIT: My new favorite is jint (.net javascriptt interpreter) v easy to use, nice interface. And nobody can complain about the language given that js is the cool language at the moment
0
9,483
false
0
1
Python vs Lua for embedded scripting/text processing engine
3,774,148
1
4
0
2
2
0
0.099668
0
When I try to use cron to execute my python script in a future time, I found there is a command at, AFAIK, the cron is for periodically execute, but what my scenario is only execute for once in specified time. and my question is how to add python script to at command, also it there some python package for control the at command My dev os is ubuntu 10.04 lucid,and my product server is ubuntu-server 10.04 lucid version. in fact, I want through python script add python script tasks to at command, which file's change can effect at command add or remove new jobs
0
python,cron,package,execute,at-job
2010-09-23T01:21:00.000
1
3,774,772
type man at, it will explain how to use it. Usage will slighty differ from system to system, so there's no use to tell you here exactly.
0
2,030
false
0
1
How to use at command to set python script execute at specified time
3,774,794
1
1
0
0
0
0
0
0
I'm trying to use a module that requires sys._getframe(), which, as I understand it, is not enabled by default. I've seen a lot of material that suggests that there is a way to enable _getframe(), but I've yet to find anything that tells me how to do so. What is the proper method for enabling this function in IronPython 2.6.1? Does one even exist? Thanks in advance.
0
ironpython
2010-09-23T16:14:00.000
0
3,780,379
Resolved. Turns out that you need to rebuild IronPython from source, with the command line options –X:Frames or –X:FullFrames.
0
905
false
0
1
How can I enable sys._getframe in IronPython 2.6.1?
3,780,791
1
3
0
7
9
0
1.2
0
I have no idea what could be the problem here: I have some modules from Biopython which I can import easily when using the interactive prompt or executing python scripts via the command-line. The problem is, when I try and import the same biopython modules in a web-executable cgi script, I get a "Import Error" : No module named Bio Any ideas here?
0
python,cgi,bioinformatics,biopython
2010-09-24T02:42:00.000
0
3,783,887
Here are a couple of possibilities: Apache (on Unix) generally runs as a different user, and with a different environment, to python from the command line. Try making a small script that just prints out sys.version and sys.prefix, and compare the result through apache and via the command line, to make sure that you're running from the same installation of python in both environments. Is Biopython installed under your home directory, or only readable just for your normal user? Again, because apache generally runs as a different user, perhaps you don't have access to that location, so can't import it. Can you try doing import site before trying to import Biopython? Perhaps something is preventing site packages from being imported when you run through apache.
0
9,473
true
0
1
Why can't python find some modules when I'm running CGI scripts from the web?
3,784,056
1
3
0
-1
14
1
-0.066568
0
I've written a class whose .__hash__() implementation takes a long time to execute. I've been thinking to cache its hash, and store it in a variable like ._hash so the .__hash__() method would simply return ._hash. (Which will be computed either at the end of the .__init__() or the first time .__hash__() is called.) My reasoning was: "This object is immutable -> Its hash will never change -> I can cache the hash." But now that got me thinking: You can say the same thing about any hashable object. (With the exception of objects whose hash is their id.) So is there ever a reason not to cache an object's hash, except for small objects whose hash computation is very fast?
0
python,caching,hash
2010-09-24T13:13:00.000
0
3,787,405
The usual reason is that most objects in Python are mutable, so if the hash depends on the properties, it changes as soon as you change a property. If your class really is an immutable and (all the properties which go into the hash are immutable, too!), then you can cache the hash.
0
2,299
false
0
1
Is there any reason *not* to cache an object's hash?
3,787,439
1
2
0
1
0
1
0.099668
0
I was wondering if there was a way that you could get init code to run upon importing a .NET assembly using clr.AddReference(), in the same way that importing a python file executes the init.py code that resides in the same directory. Thanks in advance!
0
ironpython
2010-09-24T17:58:00.000
0
3,789,716
It is not possible. The only way is to change the clr.AddReference method. As IronPython is open source it should be easy.
0
416
false
0
1
IronPython: how can I run init code when I import a module using clr.AddReference()?
3,803,617
2
5
0
2
8
0
0.07983
0
Which one among the two languages is good for statistical analysis? What are the pros and cons, other than accessibility, for each?
0
python,matlab,statistics,analysis
2010-09-25T04:12:00.000
0
3,792,465
SciPy, NumPy and Matplotlib.
1
1,096
false
0
1
Among MATLAB and Python, which one is good for statistical analysis?
3,792,494
2
5
0
3
8
0
0.119427
0
Which one among the two languages is good for statistical analysis? What are the pros and cons, other than accessibility, for each?
0
python,matlab,statistics,analysis
2010-09-25T04:12:00.000
0
3,792,465
I would pick Python because it can be a powerful as Matlab but is free. Also, you can distribute your applications for free and no licensing chains. Matlab is awesome and expensive (it had a great statistical package) and it will glow smoother than Python in the beginning, but not so in the long run. Now, if you really want the best solution then check out R, the statistical package which is de facto in the community. They even have a Python port for it. R is also free software.
1
1,096
false
0
1
Among MATLAB and Python, which one is good for statistical analysis?
3,792,582
1
2
0
4
1
0
1.2
0
Python 2.6 My script needs to monitor some 1G files on the ftp, when ever it's changed/modified, the script will download it to another place. Those file name will remain unchanged, people will delete the original file on ftp first, then upload a newer version. My script will checking the file metadata like file size and date modified to see if any difference. The question is when the script checking metadata, the new file may be still being uploading. How to handle this situation? Is there any file attribute indicates uploading status (like the file is locked)? Thanks.
0
python,ftp,metadata
2010-09-25T21:20:00.000
0
3,795,605
There is no such attribute. You may be unable to GET such file, but it depends on the server software. Also, file access flags may be set one way while the file is being uploaded and then changed when upload is complete; or incomplete file may have modified name (e.g. original_filename.ext.part) -- it all depends on the server-side software used for upload. If you control the server, make your own metadata, e.g. create an empty flag file alongside the newly uploaded file when upload is finished. In the general case, I'm afraid, the best you can do is monitor file size and consider the file completely uploaded if its size is not changing for a while. Make this interval sufficiently large (on the order of minutes).
0
2,665
true
0
1
Python to check if file status is being uploading
3,795,678
1
2
1
0
1
1
0
0
IronPython.net documentation says the MSIL in the assembly isn't CLS-compliant, but is there a workaround?
0
c#,ironpython,.net-assembly,cil,cls-compliant
2010-09-25T23:07:00.000
0
3,795,914
I'm typing this on my phone so please forgive any silly mistakes. To use the compiled assembly, make sure you compile with clr.CompileModules, NOT pyc.py. Then in your C# call the LoadAssembly method on your Python ScriptEngine object. The module can then be imported by calling the ImportModule method on your ScriptEngine. From there if you can take advantage of the dynamic keyword, do so. Otherwise you'll be stuck with some magic string heavy calls to GetVariable. Also note that you'll have to provide the standard library to your compiled Python Assembly in one form or another.
0
305
false
0
1
Is there a way to use IronPython objects and functions (compiled into an assembly) from C# code?
3,835,553
2
2
0
1
7
0
1.2
0
I was reading "Growing Object-Oriented Software, Guided by Tests" lately. Authors of this book sugested to always start developing a feature with an end-to-end acceptance test (before starting TDD cycle) to not loose a track of progress and to make sure that you're still on the same page while unit-testing. Ok, so I've start writing a veeeery simple application in python+django just to try this approach out. I want User to be able to ask a question via contact-form, the question should be then stored in a db, and a signal after completion should be send to notify mailer which will send follow-up message. Question is - how you'd approach this first end-to-end test in this case? Do you have contain all possibilities in this first test, or maybe I'm misunderstanding this whole technique. Any examples would be most welcome.
0
python,django,unit-testing,tdd,bdd
2010-09-26T16:09:00.000
0
3,798,629
You don't have to contain all possibilities in acceptance tests at all - you will still write unit tests. So I would say that a single tests "user can fill in the form, save it and load it back" is enough to start with. Then you can add more tests if you think that a particular aspect of your system is important enough that it needs an acceptance tests. Don't worry about handling all possibilities here, you will still write tons of unit tests where you will test everything! The easiest way to start is to grow your acceptance test in parallel with the code: so start with testing that the user can input data, implement it until it stops failing, then add to the test the condition that the user has to load this data back etc. It will take a while to implement the initial infrastructure for the acceptance test, before you even start writing production code, but you can't escape from it anyway, and there are various benefits to have tests upfront.
0
479
true
1
1
"Zero Iteration" - end to end acceptance test in simple contact-form feature
3,799,733
2
2
0
0
7
0
0
0
I was reading "Growing Object-Oriented Software, Guided by Tests" lately. Authors of this book sugested to always start developing a feature with an end-to-end acceptance test (before starting TDD cycle) to not loose a track of progress and to make sure that you're still on the same page while unit-testing. Ok, so I've start writing a veeeery simple application in python+django just to try this approach out. I want User to be able to ask a question via contact-form, the question should be then stored in a db, and a signal after completion should be send to notify mailer which will send follow-up message. Question is - how you'd approach this first end-to-end test in this case? Do you have contain all possibilities in this first test, or maybe I'm misunderstanding this whole technique. Any examples would be most welcome.
0
python,django,unit-testing,tdd,bdd
2010-09-26T16:09:00.000
0
3,798,629
This use-case leads to several test-cases (every tests a dedicated possible path of execution). When writing tests focus on one possible outcome, after a while test-suite grows. The first tests then also give you safety net as regression tests to not break anything which you already implemented successfully. My first tests would be: Happy path 1st part frontend-form + controller layer: User passes correct data, controller take the form and log to console/stdout Happy path 2nd part: Instead of logging to stdout, things get stored to database Happy path 3rd part: Follow-up mail gets sent and received by User Validation error handling (user fills form out incorrectly, e.g. misses mandatory fields, wrong email-pattern) ... Fill out the rest ;) Depends on the more detailed requirements... Remember to implement above as simple as possible. When all tests are in place, refactor ruthlessly to make "internal quality" nice.
0
479
false
1
1
"Zero Iteration" - end to end acceptance test in simple contact-form feature
3,799,623
1
1
0
0
3
0
0
0
There are two good open source python e-commerce solutions exist: Satchmo and LFS. But I can't find any theme for them. Does at least one open source theme for them exist? There are thousands themes for Magento, osCommerce, OpenCart, but zero themes for Satchmo. Thanks.
0
python,e-commerce
2010-09-27T09:33:00.000
0
3,802,544
well, if that is the case, I think the only reason I can think up of is that this Satchmo is not that popular so that nobody is willing to port or design a theme for it. I would suggest randomly grab a theme, port it here accordingly
0
299
false
1
1
Themes for python e-commerce solutions
11,260,331
1
1
0
0
0
0
0
1
I changed my domain from abc.com to xyz.com. After that my facebook authentication is not working. It is throwing a key error KeyError: 'access_token'I am using python as my language.
0
python,facebook
2010-09-27T17:08:00.000
0
3,806,082
You probably need to update the domain in the facebook settings/api key which allow you access.
0
186
false
1
1
My facebook authentication is not working?
3,806,101
1
3
0
1
0
0
0.066568
1
Is there any python function that validates E-mail addresses, aware of IDN domains ? For instance, [email protected] should be as correct as user@zääz.de or user@納豆.ac.jp Thanks.
0
python
2010-09-27T17:43:00.000
0
3,806,393
It is very difficult to validate an e-mail address because the syntax is so flexible. The best strategy is to send a test e-mail to the entered address.
0
548
false
0
1
Function to validate an E-mail (IDN aware)
3,806,787
1
17
0
16
39
0
1
0
Does python offer a way to easily get the current week of the month (1:4) ?
0
python,time,week-number
2010-09-27T17:57:00.000
0
3,806,473
If your first week starts on the first day of the month you can use integer division: import datetime day_of_month = datetime.datetime.now().day week_number = (day_of_month - 1) // 7 + 1
0
60,362
false
0
1
Week number of the month?
3,806,516
1
4
0
0
5
0
0
0
I'm currently working on a project where I'm trying to control an embedded device through an Internet facing website. The idea is is that a user can go to a website and tell this device to preform some kind of action. An action on the website would be translated into a series of CLI commands and then sent to the device. Communication could potentially go both ways in the future, but right now I'm focusing on server-to-device. The web server is a LAMP stack using Python (Django) and the device I'm trying to communicate with is a Beagle Board running eLinux. There would be only one device existing at any time communicating to the server. I have all the functional parts written on the server and device side, but I'm having a bit of trouble figuring out how to write the communication layer. One of my big issues is that the device will be mobile and will be moving locations every few days. So, I can't guarantee a static IP address for the device. My networking programming knowledge is pretty minimal so I don't have that great an idea on where to start. Does anyone have any ideas/resources on how I can start developing this kind of communication? Thanks!
0
python,apache,embedded,beagleboard
2010-09-27T23:17:00.000
0
3,808,581
the device will be mobile and will be moving locations every few days. So, I can't guarantee a static IP address for the device. Your device can be a client of the web site. Your web site has two interfaces. HTML interface to people. A non-HTML interface to the device. As a client of a web site, the device will need an HTTP client-side library to send a request to the web site. This request will include the device's IP address, plus all the usual malarky buried in an HTTP request. (There are a bunch of standard headers that are sent in a request) Once the device has made it's initial request, then your web site can save the device's current status and communicate with it through another protocol if you want to do that. (I'm guessing that "I have all the functional parts written on the server and device side" means you have some other protocol for controlling the device, and this protocol isn't based on HTTP.) It might be simplest in the long run to have the device poll the web site for commands or updates or things. That way the device is a pure web client using only HTTP, and your web site is a pure web server, using only HTTP. Then you don't need your more specialized second protocol. Using only HTTP means you can use SSL to assure a secure communication. If your device uses HTTP to get commands and updates, you'll need to work out a usable representation for data that can easily be encoded into HTTP requests and responses. Choices include XML, JSON and YAML. You can always invent your own data format; however, you'll probably be happier debugging a standardized format like JSON. Building these two interfaces in Django is pretty trivial. You'll simply have some URL's which are for people and some which are for your device. You'll have view functions for people that return HTML pages, and view functions for your device that return JSON or XML messages.
0
1,776
false
1
1
Creating a website to communicate with an embedded device
3,811,703
6
8
0
2
2
1
0.049958
0
I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have? Which is more stable? Which is more scaleable? Which is more secure? Which is easier to learn? EDIT: Keeping the original question intact, I'd like to add one more pair of questions. Which is quicker to code with? Which is quicker to learn? (Based on personal experience only please - to avoid holywars.) EDIT2: Sorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.
0
php,python,ruby,programming-languages
2010-09-28T05:39:00.000
0
3,809,981
I personally would prefer Ruby, as it goes wonderfully with the Rails framework and is a blast to learn and to work with. I have only used Python a few times. While I know it is powerful, I have never really fallen in love with it the way I have with Ruby (and specifically the Rails framework)
0
3,516
false
0
1
Ruby or Python instead of PHP?
3,809,997
6
8
0
1
2
1
0.024995
0
I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have? Which is more stable? Which is more scaleable? Which is more secure? Which is easier to learn? EDIT: Keeping the original question intact, I'd like to add one more pair of questions. Which is quicker to code with? Which is quicker to learn? (Based on personal experience only please - to avoid holywars.) EDIT2: Sorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.
0
php,python,ruby,programming-languages
2010-09-28T05:39:00.000
0
3,809,981
To get a quick feel for each and see which one "tastes" better I would suggest taking each one for a spin on a selection of problems on ProjectEeuler. PE is more about algorithms and math but some of thee simpler problems are a great way to get going with syntax and some core library features such as file IO etc.
0
3,516
false
0
1
Ruby or Python instead of PHP?
3,810,088
6
8
0
3
2
1
0.07486
0
I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have? Which is more stable? Which is more scaleable? Which is more secure? Which is easier to learn? EDIT: Keeping the original question intact, I'd like to add one more pair of questions. Which is quicker to code with? Which is quicker to learn? (Based on personal experience only please - to avoid holywars.) EDIT2: Sorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.
0
php,python,ruby,programming-languages
2010-09-28T05:39:00.000
0
3,809,981
These two languages are so similar that any strong preference will be mostly subjective. They are both the correct answer.
0
3,516
false
0
1
Ruby or Python instead of PHP?
3,810,286
6
8
0
1
2
1
0.024995
0
I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have? Which is more stable? Which is more scaleable? Which is more secure? Which is easier to learn? EDIT: Keeping the original question intact, I'd like to add one more pair of questions. Which is quicker to code with? Which is quicker to learn? (Based on personal experience only please - to avoid holywars.) EDIT2: Sorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.
0
php,python,ruby,programming-languages
2010-09-28T05:39:00.000
0
3,809,981
i think you should prefer ruby, while python is assumed easier to learn! python is so friendly great language but you rarely find servers with python support most are expensive one's, ruby on rails is great framework many frameworks for other languages are drives from , great cake php is a sort of such a thing. ruby on rails can be found on many servers. how ever if you have specified applications with special clients you can go to python and it's funny frameworks. by the way, i had a lecture on ruby i had a article claim that ruby is a bit more efficient and more quick.
0
3,516
false
0
1
Ruby or Python instead of PHP?
3,869,927
6
8
0
0
2
1
0
0
I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have? Which is more stable? Which is more scaleable? Which is more secure? Which is easier to learn? EDIT: Keeping the original question intact, I'd like to add one more pair of questions. Which is quicker to code with? Which is quicker to learn? (Based on personal experience only please - to avoid holywars.) EDIT2: Sorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.
0
php,python,ruby,programming-languages
2010-09-28T05:39:00.000
0
3,809,981
pyfunc pretty much said it, but I'd like to offer two more thoughts: 1) Ruby will probably end up being a tiny bit more familiar as it a) can often optionally use a more C-like syntax, b) is not structured quite as foreignly as Python coming from PHP 2) They can both scale well, but Python will probably give you the most bang for your buck (CPU wise - and if you use Ruby, you're probably pretty well off using Ruby Enterprise and mod_rails, aka phusion passenger). That's all - even considering those points, the difference may well be negligible, as the power of the language is all about how you use it, regardless of its inherent pros and cons.
0
3,516
false
0
1
Ruby or Python instead of PHP?
3,869,982
6
8
0
1
2
1
0.024995
0
I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have? Which is more stable? Which is more scaleable? Which is more secure? Which is easier to learn? EDIT: Keeping the original question intact, I'd like to add one more pair of questions. Which is quicker to code with? Which is quicker to learn? (Based on personal experience only please - to avoid holywars.) EDIT2: Sorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.
0
php,python,ruby,programming-languages
2010-09-28T05:39:00.000
0
3,809,981
No significant difference on the first four criteria. No significant difference on coding speed either - you're going to be slow in both at the start, then you'll get faster. Ruby may be slightly better at managing libraries (Ruby Gems) but Python probably has slightly broader library coverage. No big deal either way. Coming from PHP, I'd guess that Python might be slightly quicker to learn. That might be a reason for choosing Ruby - you might learn a little more. There are a lot of "mights" and "slightlys" there. That's because the two languages are much more similar to each other than either is to PHP. Neither is particularly hard to learn - I'd suggest spending a little time with both and then going deeper with the one you prefer.
0
3,516
false
0
1
Ruby or Python instead of PHP?
3,811,039