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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3 | 5 | 1 | 0 | 12 | 0 | 0 | 0 |
I'm confronted with the task of making a C++ app scriptable by users. The app has been in development for several years with no one wasting a thought on this before. It contains all sorts of niceties like multithreading, template wizardry and multiple inheritance. As the scripting language, Python is preferred, but Lua might be accepted if it is significantly easier to implement.
Question 1
From what I have learned so far, there are broadly speaking two ways to integrate Python/Lua with C++ : "extending" and "embedding".
In this case, it looks like I need both. The scripting language need access to objects, methods and data from the app but needs to be called by the app once the user has written the script - without restarting anything.
How is this usually done in the real world?
Question 2
There seems to be a bewildering array of of manual solutions and binding generators out there, all of them less than perfect.
swig, pyste, Py++, ctypes, Boost.Python sip, PyCXX, pybindgen, robin, (Cython/Pyrex, Weave)
CppLua, Diluculum, Luabind, Luabridge, LuaCpp, Luna/LunaWrapper, MLuaBind, MultiScript, OOLua, SLB, Sweet Lua, lux
(this list from the lua wiki)
CPB, tolua, tolua++, toLuaxx, luna and again swig
Most commments on these found on the web are a little out of date. For example, swig is said to be difficult in non-trivial cases and to generate incomprehensible code. OTOH, it has recently gone to v2.0.
Some of the above use pygccxml to let gcc analyze the C++ code and then genarate the binding. I find this idea appealing, as gcc probably understands the code better than i do :-). Does this work well?
Testing them all might easily cost me half of the time allocated for the whole project.
So, which ones do you recommend?
| 0 |
c++,python,binding,lua,scriptable
|
2010-07-21T12:18:00.000
| 0 | 3,299,067 |
Try Boost::Python, it has somewhat of a learning curve associated with it but it is the best tool for the job in my view, we have a huge real time system and developed the scripting library for the QA in Boost::Python.
| 0 | 1,926 | false | 0 | 1 |
How do I make a nasty C++ program scriptable with Python and/or Lua?
| 3,299,415 |
3 | 5 | 1 | 12 | 12 | 0 | 1 | 0 |
I'm confronted with the task of making a C++ app scriptable by users. The app has been in development for several years with no one wasting a thought on this before. It contains all sorts of niceties like multithreading, template wizardry and multiple inheritance. As the scripting language, Python is preferred, but Lua might be accepted if it is significantly easier to implement.
Question 1
From what I have learned so far, there are broadly speaking two ways to integrate Python/Lua with C++ : "extending" and "embedding".
In this case, it looks like I need both. The scripting language need access to objects, methods and data from the app but needs to be called by the app once the user has written the script - without restarting anything.
How is this usually done in the real world?
Question 2
There seems to be a bewildering array of of manual solutions and binding generators out there, all of them less than perfect.
swig, pyste, Py++, ctypes, Boost.Python sip, PyCXX, pybindgen, robin, (Cython/Pyrex, Weave)
CppLua, Diluculum, Luabind, Luabridge, LuaCpp, Luna/LunaWrapper, MLuaBind, MultiScript, OOLua, SLB, Sweet Lua, lux
(this list from the lua wiki)
CPB, tolua, tolua++, toLuaxx, luna and again swig
Most commments on these found on the web are a little out of date. For example, swig is said to be difficult in non-trivial cases and to generate incomprehensible code. OTOH, it has recently gone to v2.0.
Some of the above use pygccxml to let gcc analyze the C++ code and then genarate the binding. I find this idea appealing, as gcc probably understands the code better than i do :-). Does this work well?
Testing them all might easily cost me half of the time allocated for the whole project.
So, which ones do you recommend?
| 0 |
c++,python,binding,lua,scriptable
|
2010-07-21T12:18:00.000
| 0 | 3,299,067 |
I wouldn't recommend swig as it's hard to get it to generate satisfactory binding in complex situations: been there, done that. I had to write a horrible script that "parsed" the original C++ code to generate some acceptable C++ code that swig could chew and generate acceptable bindings. So, in general: avoid ANY solution that relies on parsing the original C++ program.
Between Lua and Python: I have found Lua MUCH, MUCH better documented and more cleanly implemented. Python has a GIL (global lock), whereas with Lua, you can have an interpreter instance in each thread, for example.
So, if you can choose, I'd recommend Lua. It is smaller language, easier to comprehend, easier to embed (much cleaner and smaller API, with excellent documentation). I have used luabind for a small project of mine and found it easy to use.
| 0 | 1,926 | false | 0 | 1 |
How do I make a nasty C++ program scriptable with Python and/or Lua?
| 3,299,174 |
3 | 3 | 0 | 1 | 2 | 0 | 0.066568 | 0 |
I've installed pydev to my eclipse 3.5.2. Everything was working smoothly, create projects, execute, test, autocomplete.
But then I realized that importing modules from /usr/lib/pymodules/python2.6, such as django, causes error "Unresolved import: xxxx". Of course, PYTHONPATH SYSTEM includes the directories I want. What's more, inside package explorer i can c the modules under "System Libs".
I just can't import them :S. Is this a bug? Or I just missing something.
Thanks.
| 0 |
python,eclipse,pydev
|
2010-07-21T15:21:00.000
| 0 | 3,300,903 |
It seems like some sort of cache issue in PyDev... in which case you could try to remove the interpreter, add it again and restart Eclipse.
| 0 | 9,880 | false | 1 | 1 |
Pydev, eclipse and pythonpath problem
| 8,374,480 |
3 | 3 | 0 | 1 | 2 | 0 | 1.2 | 0 |
I've installed pydev to my eclipse 3.5.2. Everything was working smoothly, create projects, execute, test, autocomplete.
But then I realized that importing modules from /usr/lib/pymodules/python2.6, such as django, causes error "Unresolved import: xxxx". Of course, PYTHONPATH SYSTEM includes the directories I want. What's more, inside package explorer i can c the modules under "System Libs".
I just can't import them :S. Is this a bug? Or I just missing something.
Thanks.
| 0 |
python,eclipse,pydev
|
2010-07-21T15:21:00.000
| 0 | 3,300,903 |
If you're using virtualenv you should setup an interpreter using the python build inside.
ie., default python interpreter for th project will be /usr/bin/python
but change it to something like "{project name} python" and point it to your virtual env path. In my case it's ~/.virtualenvs/acme/bin/python
| 0 | 9,880 | true | 1 | 1 |
Pydev, eclipse and pythonpath problem
| 3,459,938 |
3 | 3 | 0 | 2 | 2 | 0 | 0.132549 | 0 |
I've installed pydev to my eclipse 3.5.2. Everything was working smoothly, create projects, execute, test, autocomplete.
But then I realized that importing modules from /usr/lib/pymodules/python2.6, such as django, causes error "Unresolved import: xxxx". Of course, PYTHONPATH SYSTEM includes the directories I want. What's more, inside package explorer i can c the modules under "System Libs".
I just can't import them :S. Is this a bug? Or I just missing something.
Thanks.
| 0 |
python,eclipse,pydev
|
2010-07-21T15:21:00.000
| 0 | 3,300,903 |
In eclipse you can add django folder in you python path.
Window->Preferences-> PyDev-> Interpreters->Python Interpreter -> Lirararies -> New Folder
And browse till the parent folder of modules you are searching.
| 0 | 9,880 | false | 1 | 1 |
Pydev, eclipse and pythonpath problem
| 32,353,403 |
2 | 9 | 0 | 13 | 90 | 0 | 1 | 0 |
I needed to have a directly executable python script, so i started the file with #!/usr/bin/env python. However, I also need unbuffered output, so i tried #!/usr/bin/env python -u, but that fails with python -u: no such file or directory.
I found out that #/usr/bin/python -u works, but I need it to get the python in PATH to support virtual env environments.
What are my options?
| 0 |
python,arguments,shebang
|
2010-07-22T07:07:00.000
| 1 | 3,306,518 |
Passing arguments to the shebang line is not standard and in as you have experimented do not work in combination with env in Linux. The solution with bash is to use the builtin command "set" to set the required options. I think you can do the same to set unbuffered output of stdin with a python command.
my2c
| 0 | 27,298 | false | 0 | 1 |
Cannot pass an argument to python with "#!/usr/bin/env python"
| 3,306,575 |
2 | 9 | 0 | 17 | 90 | 0 | 1 | 0 |
I needed to have a directly executable python script, so i started the file with #!/usr/bin/env python. However, I also need unbuffered output, so i tried #!/usr/bin/env python -u, but that fails with python -u: no such file or directory.
I found out that #/usr/bin/python -u works, but I need it to get the python in PATH to support virtual env environments.
What are my options?
| 0 |
python,arguments,shebang
|
2010-07-22T07:07:00.000
| 1 | 3,306,518 |
When you use shebang on Linux, the entire rest of the line after the interpreter name is interpreted as a single argument. The python -u gets passed to env as if you'd typed: /usr/bin/env 'python -u'. The /usr/bin/env searches for a binary called python -u, which there isn't one.
| 0 | 27,298 | false | 0 | 1 |
Cannot pass an argument to python with "#!/usr/bin/env python"
| 8,921,497 |
6 | 8 | 0 | 3 | 21 | 1 | 0.07486 | 0 |
I'm planning on moving to Python and I have a couple of additional questions along with the title:
did you have more fun with python?
are you as productive as when you're using PHP?
what made you change to python?
Would you do a project again in PHP? If so, why?
Your answers would really be useful for us PHP devs wanting something more I guess :)
Thanks in advance!
| 0 |
php,python
|
2010-07-23T14:46:00.000
| 0 | 3,319,261 |
I run a self-developed private social site for 100+ users. Python was absolutely fantastic for making and running this.
did you have more fun with python?
Most definitely.
are you as productive as when you're using PHP?
Mostly yes. Python coding style, at least for me is so much quicker and easier. But python does sometimes lack in included libraries and documentation over PHP. (But PHP seems second to none in that reguard). Also requires a tad more to get running under apache.
what made you change to python?
Easier to manage code, and quicker development (A good IDE helps there, I use WingIDE for python), as well as improving my python skills for when I switch to non-web based projects.
Would you do a project again in PHP? If so, why?
Perhaps if I were working on a large scale professional project. PHP is so ubiquitous on the web A company would have a much easier time finding a replacement PHP programmer.
| 0 | 9,531 | false | 0 | 1 |
PHP devs that moved to Python, is the experience better?
| 3,323,632 |
6 | 8 | 0 | 4 | 21 | 1 | 0.099668 | 0 |
I'm planning on moving to Python and I have a couple of additional questions along with the title:
did you have more fun with python?
are you as productive as when you're using PHP?
what made you change to python?
Would you do a project again in PHP? If so, why?
Your answers would really be useful for us PHP devs wanting something more I guess :)
Thanks in advance!
| 0 |
php,python
|
2010-07-23T14:46:00.000
| 0 | 3,319,261 |
I'll try my best to answer your questions as best I can:
Did you have more fun with python?
I really enjoy how minimalist python is, having modules with non-redundant naming conventions is really nice. I found this to be especially convenient when reading/debugging other peoples code.
I also love all of the python tricks to do some very elegant things in a single line of code such as list comprehensions and the itertools library.
I tend to develop my applications using mod_wsgi and it took some time to wrap my head around writing thread-safe web applications, but it was really worth it.
I also find unicode to be much less frustrating with python especially with python 3k.
are you as productive as when you're using PHP?
For simple websites python can be less fun to setup and use. One nice feature of PHP that I miss with python is mixing PHP and HTML in the same file. Python has a lot of nice template languages that make this easy as well, but they have to be installed.
what made you change to python?
I became frustrated with a lot of the little nuances of PHP such as strange integer and string conversions and so forth. I also started to feel that PHP was getting very bloated with a lot of methods with inconsistent naming schemes. I was referring to the PHP documentation quite frequently despite having a large portion of the php library memorized.
Would you do a project again in PHP? If so, why?
I would develop a PHP project again, it has a lot of nice features and a great community. Plus I have a lot of experience with PHP. I'd prefer to use python, but if the client wants PHP I'm not going to force something they don't want.
| 0 | 9,531 | false | 0 | 1 |
PHP devs that moved to Python, is the experience better?
| 3,319,941 |
6 | 8 | 0 | 1 | 21 | 1 | 0.024995 | 0 |
I'm planning on moving to Python and I have a couple of additional questions along with the title:
did you have more fun with python?
are you as productive as when you're using PHP?
what made you change to python?
Would you do a project again in PHP? If so, why?
Your answers would really be useful for us PHP devs wanting something more I guess :)
Thanks in advance!
| 0 |
php,python
|
2010-07-23T14:46:00.000
| 0 | 3,319,261 |
I've never really worked with PHP (nothing major) and come from the .NET world. The project I am currently on requires a lot of Python work and I must say I love it. Very easy and "cool" language, ie. FUN!
.NET will always be my wife but Python is my mistress ;)
| 0 | 9,531 | false | 0 | 1 |
PHP devs that moved to Python, is the experience better?
| 3,319,485 |
6 | 8 | 0 | 1 | 21 | 1 | 0.024995 | 0 |
I'm planning on moving to Python and I have a couple of additional questions along with the title:
did you have more fun with python?
are you as productive as when you're using PHP?
what made you change to python?
Would you do a project again in PHP? If so, why?
Your answers would really be useful for us PHP devs wanting something more I guess :)
Thanks in advance!
| 0 |
php,python
|
2010-07-23T14:46:00.000
| 0 | 3,319,261 |
yes
yes
curiosity, search for better languages, etc. (actually, I learned them somewhat in parallel many years ago)
yes, if a project requires it explicitly
disclaimer: I never really moved from php.
| 0 | 9,531 | false | 0 | 1 |
PHP devs that moved to Python, is the experience better?
| 3,319,291 |
6 | 8 | 0 | 3 | 21 | 1 | 0.07486 | 0 |
I'm planning on moving to Python and I have a couple of additional questions along with the title:
did you have more fun with python?
are you as productive as when you're using PHP?
what made you change to python?
Would you do a project again in PHP? If so, why?
Your answers would really be useful for us PHP devs wanting something more I guess :)
Thanks in advance!
| 0 |
php,python
|
2010-07-23T14:46:00.000
| 0 | 3,319,261 |
Well, I started with PHP, and have delved into Python recently. I wouldn't say that I've "moved to", but I do use both (still PHP more, but a fair bit of Python as well).
I wouldn't say that I have more "fun" with Python. There are a lot of really cool and easy things that I really wish I could take to PHP. So I guess it could be considered "fun". But I still enjoy PHP, so...
I'm more productive with PHP. I know PHP inside and out. I know most of the little nuances involved in writing effective PHP code. I don't know Python that well (I've maybe written 5k lines of Python)... I know enough to do what I need to, but not nearly as in-depth as PHP.
I wanted to try something new. I never liked Python, but then one day I decided to learn the basics, and that changed my views on it. Now I really like some parts (and can see how it influences what PHP I write)...
I am still doing PHP projects. It's my best language. And IMHO it's better than Python at some web tasks (like high traffic sites). PHP has a built in multi-threaded FastCGI listener. Python you need to find one (there are a bunch out there). But in my benchmarks, Python was never able to get anywhere near as as fast as PHP with FastCGI (The best Py performed it was 25% slower than PHP. The worst was several hundered times, depending on the FCGI library). But that's based on my experience (which admittedly isn't much). I know PHP, so I feel more comfortable committing a large site to it than I would PY...
| 0 | 9,531 | false | 0 | 1 |
PHP devs that moved to Python, is the experience better?
| 3,319,318 |
6 | 8 | 0 | 1 | 21 | 1 | 0.024995 | 0 |
I'm planning on moving to Python and I have a couple of additional questions along with the title:
did you have more fun with python?
are you as productive as when you're using PHP?
what made you change to python?
Would you do a project again in PHP? If so, why?
Your answers would really be useful for us PHP devs wanting something more I guess :)
Thanks in advance!
| 0 |
php,python
|
2010-07-23T14:46:00.000
| 0 | 3,319,261 |
did you have more fun with python?
Yes. Lot more.
are you as productive as when you're using PHP?
No. I think more.
what made you change to python?
Django.
Would you do a project again in PHP? If so, why?
Only if it is required.
| 0 | 9,531 | false | 0 | 1 |
PHP devs that moved to Python, is the experience better?
| 3,325,047 |
1 | 1 | 1 | 0 | 0 | 0 | 1.2 | 0 |
I am compiling on Ubuntu 10.04 LTS. The Perforce Python API uses their C++ API for some of it. So, I point the setup.py at the C++'s API directory using the --apidir= they say to use. When it starts to compile the C++, I get a whole load of errors (temporary error list link is now gone). No one else has had these errors as far as I can tell. So, my question is, is it my idiocy, or Perforce's?
P.S. The reason I don't have the flag in the command is because I setup the setup.cfg file to point at the API.
| 0 |
c++,python,perforce
|
2010-07-24T09:08:00.000
| 0 | 3,324,490 |
Woops! Forgot I still needed to install python-dev...
| 0 | 290 | true | 0 | 1 |
Perforce P4Python API Bug
| 3,324,560 |
2 | 5 | 0 | 1 | 0 | 0 | 0.039979 | 0 |
I have couple of ideas in my brain which I would like to bring out before it's too late. Basically I want to develop a web application which I could sell it to clients. So which technology shall I use to accomplish this? I have been a C and C++ software developer but it's been a very long time since I have developed one. So the things I would like to know is:
Scalability and Performance?
Easy way to develop web application in a faster manner?
Any Framework?
Application server?
and which programming language?
| 0 |
c#,java,python
|
2010-07-24T10:16:00.000
| 0 | 3,324,683 |
I kinda think this is almost more like a religious problem, than a real technical issue. For almost every programming language you can find a big website that's using it.
.NET -> Microsoft
Ruby -> Twitter (yes, they have a few issues, but still)
PHP -> Facebook
Java -> Lots of finance companies
Don't know about Phyton, but I'm sure there is.
More important is a good scalable architecture. That is where Twitter kinda screwed it up it seems.
Personally I use ASP.NET. Works fine, is somewhat easy and has a nice IDE. And the market is not so fragmented. Before I used Java with Websphere. Was running on a Sergenti Sun Box, so could definitely handle a lot.
I would more see into what you can get yourself into the quickest. If you know C++ C# or Java are easy to learn.
| 0 | 3,428 | false | 1 | 1 |
Which technology should I use to develop a high performance web application
| 3,324,710 |
2 | 5 | 0 | 6 | 0 | 0 | 1 | 0 |
I have couple of ideas in my brain which I would like to bring out before it's too late. Basically I want to develop a web application which I could sell it to clients. So which technology shall I use to accomplish this? I have been a C and C++ software developer but it's been a very long time since I have developed one. So the things I would like to know is:
Scalability and Performance?
Easy way to develop web application in a faster manner?
Any Framework?
Application server?
and which programming language?
| 0 |
c#,java,python
|
2010-07-24T10:16:00.000
| 0 | 3,324,683 |
Usually the programming language doesn't really matter. All have their own strengths and weaknesses. All come up with their own best-practices and frameworks.
It's really up to you what's your preference. If you are coming from Microsoft C/C++ I'd use .NET, if you are from Linux world I'd use Java.
Back in the 90s Java was well known as a slow framework, however there was much of myth and the framework architecture is dramatically changed since that. Today, there is no generally slow or fast framework.
You can find thousands of sites in the web that tell you that the one or the other is faster. However, at the end of the day it depends on how you implemented your solution and how you utilized the best features of the framework.
Greets
Flo
| 0 | 3,428 | false | 1 | 1 |
Which technology should I use to develop a high performance web application
| 3,324,720 |
1 | 1 | 1 | 1 | 0 | 0 | 0.197375 | 0 |
Is there any difference in speed of copying files from one location to another betwen python or delphi or c++ ?
I guess that all 3 laguages uses same or similar win api calls and that there is not much performance difference.
| 0 |
python,windows,performance,comparison
|
2010-07-24T11:17:00.000
| 0 | 3,324,870 |
Pythons shutil module does not use the Windows API, but instead uses an open/read/write loop. This may or may not be slower than using CopyFile(Ex). Please measure it, everything else is just guessing.
| 0 | 78 | false | 0 | 1 |
python file copying
| 3,324,905 |
1 | 3 | 0 | 2 | 10 | 1 | 0.132549 | 0 |
I currently work with Python for a while and I came to the point where I questioned myself whether I should use "Properties" in Python as often as in C#.
In C# I've mostly created properties for the majority of my classes.
It seems that properties are not that popular in python, am I wrong?
How to use properties in Python?
regards,
| 0 |
c#,python,properties
|
2010-07-24T11:33:00.000
| 0 | 3,324,920 |
If you make an attribute public in C# then later need to change it into a property you also need to recompile all code that uses the original class. This is bad, so make any public attributes into properties from day one 'just in case'.
If you have an attribute that is used from other code then later need to change it into a property then you just change it and nothing else needs to happen. So use ordinary attributes until such time as you find you need something more complicated.
| 0 | 3,192 | false | 0 | 1 |
Use of properties in python like in example C#
| 3,325,757 |
5 | 7 | 0 | 2 | 63 | 1 | 0.057081 | 0 |
I want to know why Python is not fully object-oriented. For example, it does not support private, public, protected access level modifiers.
What are the advantages and disadvantages of this? By these expressions, Python is suitable for what applications (Desktop, Scientific, Web or other)?
| 0 |
python,oop
|
2010-07-24T13:47:00.000
| 0 | 3,325,343 |
What exactly is full object oriented? Alan Kay said "Actually I made up the term "object-oriented", and I can tell you I did not have C++ in mind.". Admittedly, he probably did not have python in mind either, but it is worth noting that Smalltalk also protects classes by convention, no mandate.
| 0 | 80,955 | false | 0 | 1 |
Why is Python not fully object-oriented?
| 3,325,399 |
5 | 7 | 0 | 2 | 63 | 1 | 0.057081 | 0 |
I want to know why Python is not fully object-oriented. For example, it does not support private, public, protected access level modifiers.
What are the advantages and disadvantages of this? By these expressions, Python is suitable for what applications (Desktop, Scientific, Web or other)?
| 0 |
python,oop
|
2010-07-24T13:47:00.000
| 0 | 3,325,343 |
I believe Python is more of a very practical, pragmatic language.
Concepts which offer value to the developer are put in, without too much consideration about theological concepts like "proper OO design" and stuff. It's a language for people who have real work to do.
I think Python is suitable for all kinds of environments, though Desktop is a bit difficult due to the lack of a single framework. For all applications it's handy to use a framework,
like NumPy for computational stuff, Twisted or Django for web stuff, and WxWidgets or other for Desktop stuff.
| 0 | 80,955 | false | 0 | 1 |
Why is Python not fully object-oriented?
| 3,325,363 |
5 | 7 | 0 | 4 | 63 | 1 | 0.113791 | 0 |
I want to know why Python is not fully object-oriented. For example, it does not support private, public, protected access level modifiers.
What are the advantages and disadvantages of this? By these expressions, Python is suitable for what applications (Desktop, Scientific, Web or other)?
| 0 |
python,oop
|
2010-07-24T13:47:00.000
| 0 | 3,325,343 |
I think Python is designed to be a hybrid. You can write in object oriented or functional styles.
The hallmarks of object-orientation are abstraction, encapsulation, inheritance, and polymorphism. Which of these are missing from Python?
Object-orientation is a continuum. We might say that Smalltalk is the purest of the pure, and all others occupy different places on the scale.
No one can say what the value of being 100% pure is. It's possible to write very good object-oriented code in languages that aren't Smalltalk, Python included.
Python is useful in all those areas: scientific (NumPy), web (Django), and desktop.
| 0 | 80,955 | false | 0 | 1 |
Why is Python not fully object-oriented?
| 3,325,355 |
5 | 7 | 0 | -5 | 63 | 1 | -1 | 0 |
I want to know why Python is not fully object-oriented. For example, it does not support private, public, protected access level modifiers.
What are the advantages and disadvantages of this? By these expressions, Python is suitable for what applications (Desktop, Scientific, Web or other)?
| 0 |
python,oop
|
2010-07-24T13:47:00.000
| 0 | 3,325,343 |
A language is said to Full Objective Oriented if it has no primitive data types. Each data type we need to construct.
| 0 | 80,955 | false | 0 | 1 |
Why is Python not fully object-oriented?
| 4,521,644 |
5 | 7 | 0 | 100 | 63 | 1 | 1.2 | 0 |
I want to know why Python is not fully object-oriented. For example, it does not support private, public, protected access level modifiers.
What are the advantages and disadvantages of this? By these expressions, Python is suitable for what applications (Desktop, Scientific, Web or other)?
| 0 |
python,oop
|
2010-07-24T13:47:00.000
| 0 | 3,325,343 |
Python doesn't support strong encapsulation, which is only one of many features associated with the term "object-oriented".
The answer is simply philosophy. Guido doesn't like hiding things, and many in the Python community agree with him.
| 0 | 80,955 | true | 0 | 1 |
Why is Python not fully object-oriented?
| 3,325,353 |
2 | 6 | 0 | 4 | 3 | 0 | 0.132549 | 0 |
I was wondering if i could possible write an app, that could be a list of all my friends and just simply posting a message to their walls on the friends i select. Not a message, a wall post. So it appears that i went to their wall and wrote a message, they have no idea that an app is pushing the message to them.
also could it be written in python :) its what i know. php is so icky, but doable if it is the only option.
Please and thank you.
| 0 |
php,python,facebook
|
2010-07-24T22:55:00.000
| 0 | 3,327,244 |
Check out the Facebook API. It will more than likely show that the wall post came from your application. As far as the language you implement in, I think you could use Python.
| 0 | 1,795 | false | 1 | 1 |
Facebook wall writing application
| 3,327,259 |
2 | 6 | 0 | 3 | 3 | 0 | 0.099668 | 0 |
I was wondering if i could possible write an app, that could be a list of all my friends and just simply posting a message to their walls on the friends i select. Not a message, a wall post. So it appears that i went to their wall and wrote a message, they have no idea that an app is pushing the message to them.
also could it be written in python :) its what i know. php is so icky, but doable if it is the only option.
Please and thank you.
| 0 |
php,python,facebook
|
2010-07-24T22:55:00.000
| 0 | 3,327,244 |
There are a couple of Facebook APIs that could tie in to. I'm at work and any website that makes mention of facebook is blocked so I can't provide links, but Google 'Facebook API'.
| 0 | 1,795 | false | 1 | 1 |
Facebook wall writing application
| 3,327,248 |
4 | 5 | 0 | 1 | 4 | 0 | 0.039979 | 1 |
I'm learning Python and would like to start a small project. It seems that making IRC bots is a popular project amongst beginners so I thought I would implement one. Obviously, there are core functionalities like being able to connect to a server and join a channel but what are some good functionalities that are usually included in the bots? Thanks for your ideas.
| 0 |
python,irc
|
2010-07-25T06:40:00.000
| 0 | 3,328,315 |
Again, this is an utterly personal suggestion, but I would really like to see eggdrop rewritten in Python.
Such a project could use Twisted to provide the base IRC interaction, but would then need to support add-on scripts.
This would be great for allowing easy IRC bot functionality to be built upon using python, instead of TCL, scripts.
| 0 | 3,546 | false | 0 | 1 |
IRC bot functionalities
| 3,329,252 |
4 | 5 | 0 | 0 | 4 | 0 | 0 | 1 |
I'm learning Python and would like to start a small project. It seems that making IRC bots is a popular project amongst beginners so I thought I would implement one. Obviously, there are core functionalities like being able to connect to a server and join a channel but what are some good functionalities that are usually included in the bots? Thanks for your ideas.
| 0 |
python,irc
|
2010-07-25T06:40:00.000
| 0 | 3,328,315 |
That is very subjective and totally depends upon where the bot will be used. I'm sure others will have nice suggestions. But whatever you do, please do not query users arbitrarily. And do not spam the main chat periodically.
| 0 | 3,546 | false | 0 | 1 |
IRC bot functionalities
| 3,328,343 |
4 | 5 | 0 | 1 | 4 | 0 | 0.039979 | 1 |
I'm learning Python and would like to start a small project. It seems that making IRC bots is a popular project amongst beginners so I thought I would implement one. Obviously, there are core functionalities like being able to connect to a server and join a channel but what are some good functionalities that are usually included in the bots? Thanks for your ideas.
| 0 |
python,irc
|
2010-07-25T06:40:00.000
| 0 | 3,328,315 |
I'm also in the process of writing a bot in node.js. Here are some of my goals/functions:
map '@' command so the bot detects the last URI in message history and uses the w3 html validation service
setup a trivia game by invoking !ask, asks a question with 3 hints, have the ability to load custom questions based on category
get the weather with weather [zip/name]
hook up jseval command to evaluate javascript, same for python and perl and haskell
seen command that reports the last time the bot has "seen" a person online
translate command to translate X language string to Y language string
map dict to a dictionary service
map wik to wiki service
| 0 | 3,546 | false | 0 | 1 |
IRC bot functionalities
| 3,328,322 |
4 | 5 | 0 | 0 | 4 | 0 | 0 | 1 |
I'm learning Python and would like to start a small project. It seems that making IRC bots is a popular project amongst beginners so I thought I would implement one. Obviously, there are core functionalities like being able to connect to a server and join a channel but what are some good functionalities that are usually included in the bots? Thanks for your ideas.
| 0 |
python,irc
|
2010-07-25T06:40:00.000
| 0 | 3,328,315 |
Make a google search to get a library that implements IRC protocol for you. That way you only need to add the features, those are already something enough to bother you.
Common functions:
Conduct a search from a wiki or google
Notify people on project/issue updates
Leave a message
Toy for spamming the channel
Pick a topic
Categorize messages
Search from channel logs
| 0 | 3,546 | false | 0 | 1 |
IRC bot functionalities
| 3,328,376 |
1 | 4 | 0 | 10 | 3 | 1 | 1.2 | 0 |
What does '\r' mean? What does it do? I have never seen it before and its giving me headaches. It doesnt seem to have any purpose, since 'a\ra' prints as 'aa', but its not the same as the string 'aa'. Im using python 2.6
| 0 |
python,syntax
|
2010-07-25T15:35:00.000
| 0 | 3,329,775 |
It's an old control character from typewriters.
It means "carriage return". In this time, when you pressed "enter", you were going to the next line, then the carriage went back to the beginning of the line (hence the carriage return).
Then with computers, different OSes made different choices to represent new lines.
On windows, you have "\r\n" (carriage return + new line).
On unices, you have "\n" only (no need to do a carriage return, it was sort of implied by the new line).
On old mac OS, you had "\r" only.
Nowadays, it's not used except for newlines (or I don't know other usages).
| 0 | 11,032 | true | 0 | 1 |
What does this stand for?
| 3,329,797 |
1 | 2 | 0 | 6 | 3 | 0 | 1.2 | 0 |
I believe eggdrop is the most active/popular bot and it's written in tcl ( and according to wiki the core is C but I haven't confirmed that ).
I'm wondering if there would be any performance benefit of recoding it's functionality in node.js or Python, in addition to making it more accessible since Python and JS are arguably more popular languages and not many are familiar with tcl.
So, how would they stack up vs tcl in general, performance-wise?
| 0 |
python,tcl,irc,node.js,eggdrop
|
2010-07-25T21:13:00.000
| 1 | 3,331,027 |
As you suspected, eggdrop is not written in tcl, it is written in C, however it does use tcl as its scripting/extension language.
I would expect that in the case of an eggdrop, the performance difference between using tcl as a scripting language, and using Python, Lua, JS, or virtually anything else would be negligible, as eggdrops generally aren't performing high load tasks.
In the event it really was an issue, your question would need more specifics. Performance for what task under what conditions? Memory use? CPU efficiency? Latency? And the answer would probably be "measure and find out". Given the typical use of an eggdrop, it doesn't take particularly efficient code to respond to the occasional IRC trigger command once every few minutes or hours.
As a more general case, I'm sure you could find benchmark comparisons of specific algorithms or tasks performed by various scripting languages on particular operating systems or environments, at which point it wouldn't really have anything to do with IRC or eggdrop.
| 0 | 964 | true | 0 | 1 |
How would an irc bot written in tcl stack up against a python/node.js clone?
| 3,331,115 |
1 | 2 | 0 | 0 | 5 | 0 | 0 | 0 |
I'm looking into Pylons and was wondering, should I use Paste as the webserver or can I use Apache?
Are there advantages to using Paste?
Would you recommend against using Apache?
How should I host the sites?
| 0 |
python,web-services,pylons
|
2010-07-26T07:57:00.000
| 1 | 3,333,113 |
I'm using Nginx (with fastcgi) or Apache for hosting Pylons sites, mostly because lack of some "production" features in Paste, but for development Paste is very usefull and handy.
| 0 | 511 | false | 0 | 1 |
Should I use Pylon's Paste to host my Pylons website? Or can I use Apache?
| 3,358,288 |
2 | 6 | 0 | 4 | 2 | 0 | 0.132549 | 0 |
I am leasing a dedicated web server.
I have a Python web-application.
Which configuration option (CGI, FCGI, mod_python, Passenger, etc) would result in Python being served the fastest on my web server and how do I set it up that way?
UPDATE:
Note, I'm not using a Python framework such as Django or Pylons.
| 0 |
python,webserver,mod-wsgi
|
2010-07-26T16:21:00.000
| 0 | 3,336,787 |
Don't get carried away with trying to work out what is the fastest web server. All you will do in doing that is waste your time. This is because the web server is nearly never the bottleneck if you set them up properly. The real bottleneck is your web application, database access etc.
As such, choose whatever web hosting system you think meets your general requirements and which you find easy to setup and manage. Using something you understand and which doesn't require lots of time devoted to it, means you can then focus your valuable time on making your application perform better, thus reducing the real bottleneck.
| 0 | 5,769 | false | 1 | 1 |
Python/Web: What's the best way to run Python on a web server?
| 3,339,594 |
2 | 6 | 0 | -1 | 2 | 0 | -0.033321 | 0 |
I am leasing a dedicated web server.
I have a Python web-application.
Which configuration option (CGI, FCGI, mod_python, Passenger, etc) would result in Python being served the fastest on my web server and how do I set it up that way?
UPDATE:
Note, I'm not using a Python framework such as Django or Pylons.
| 0 |
python,webserver,mod-wsgi
|
2010-07-26T16:21:00.000
| 0 | 3,336,787 |
You don't usually just serve Python, you serve a specific web server or framework based on Python. eg. Zope, TurboGears, Django, Pylons, etc. Although they tend to be able to operate on different web server back-ends (and some provide an internal web server themselves), the best solution will depend on which one you use.
| 0 | 5,769 | false | 1 | 1 |
Python/Web: What's the best way to run Python on a web server?
| 3,336,816 |
1 | 2 | 0 | 1 | 9 | 1 | 0.099668 | 0 |
I have an esoteric question involving Python metaclasses. I am creating a Python package for web-server-side code that will make it easy to access arbitrary Python classes via client-side proxies. My proxy-generating code needs a catalog of all of the Python classes that I want to include in my API. To create this catalog, I am using the __metaclass__ special attribute to put a hook into the class-creation process. Specifically, all of the classes in the "published" API will subclass a particular base class, PythonDirectPublic, which itself has a __metaclass__ that has been set up to record information about the class creation.
So far so good. Where it gets complicated is that I want my PythonDirectPublic itself to inherit from a third-party class (enthought.traits.api.HasTraits). This third-party class also uses a __metaclass__.
So what's the right way of managing two metaclasses? Should my metaclass be a subclass of Enthought's metaclass? Or should I just invoke Enthought's metaclass inside my metaclass's __new__ method to get the type object that I will return? Or is there some other mystical incantation to use in this particular circumstance?
| 0 |
python,metaclass,traits
|
2010-07-27T17:34:00.000
| 0 | 3,346,262 |
Specifically, all of the classes in the "published" API will subclass a particular base class, PythonDirectPublic
Rather than adding another metaclass, you could recursively use the result of PythonDirectPublic.subclasses().
| 0 | 715 | false | 0 | 1 |
Python: Metaclasses all the way down
| 4,833,132 |
1 | 12 | 0 | 10 | 77 | 1 | 1 | 0 |
I have a text file which contains a time stamp on each line. My goal is to find the time range. All the times are in order so the first line will be the earliest time and the last line will be the latest time. I only need the very first and very last line. What would be the most efficient way to get these lines in python?
Note: These files are relatively large in length, about 1-2 million lines each and I have to do this for several hundred files.
| 0 |
python,file,seek
|
2010-07-27T17:58:00.000
| 0 | 3,346,430 |
Can you use unix commands? I think using head -1 and tail -n 1 are probably the most efficient methods. Alternatively, you could use a simple fid.readline() to get the first line and fid.readlines()[-1], but that may take too much memory.
| 0 | 139,998 | false | 0 | 1 |
What is the most efficient way to get first and last line of a text file?
| 3,346,499 |
1 | 3 | 0 | 2 | 3 | 1 | 0.132549 | 0 |
I'm having problems with my PythonPath on windows XP, and I'm wondering if I'm doing something wrong.
Say that I have a project (created with Pydev) that has an src directory. Under src I have a single package, named common, and in it a single class module, named service.py with a class name Service
Say now that I have another project (also created with Pydev) with an src directory and a common package. In the common package, I have a single script, client.py, that imports service.
So in other words, two separate disk locations, but same package.
I've noticed that even if I set my PYTHONPATH to include both src directories, the import fails unless the files are both in the same directory. I get the dreaded no module found.
Am I misunderstanding how python resolves module names? I'm used to Java and its classpath hell.
| 0 |
python,pythonpath
|
2010-07-27T18:05:00.000
| 0 | 3,346,482 |
If you really must have a split package like this, read up on the module level attribute __path__.
In short, make one of the 'src' directories the main one, and give it an __init__.py that appends the path of other 'src' to the __path__ list. Python will now look in both places when looking up submodules of 'src'.
I really don't recommend this for the long term though. It is kind of brittle and breaks if you move things around.
| 0 | 1,088 | false | 0 | 1 |
PYTHONPATH hell with overlapping package structures
| 3,346,786 |
1 | 6 | 0 | 0 | 5 | 1 | 1.2 | 0 |
I am looking for a command-line tool that removes all comments from an input
file and returns the stripped output. It'd be nice it supports popular
programming languages like c, c++, python, php, javascript, html, css, etc. It
has to be syntax-aware as opposed to regexp-based, since the latter will catch
the pattern in source code strings as well. Is there any such tool?
I am fully aware that comments are useful information and often leaving them
as they are is a good idea. It's just that my focus is on different use cases.
| 0 |
php,python,c
|
2010-07-28T00:56:00.000
| 0 | 3,349,156 |
No such tool exists yet.
| 0 | 3,169 | true | 0 | 1 |
General utility to remove/strip all comments from source code in various languages?
| 3,599,951 |
1 | 2 | 0 | 2 | 4 | 1 | 0.197375 | 0 |
Does any one know how we can do this?
I have python code in eclipse and whenever it calls c++ functions, i want the break point to go to the visual studio c++ project.
| 0 |
c++,python,visual-studio,eclipse
|
2010-07-28T08:28:00.000
| 0 | 3,351,110 |
If the C++ app runs as a separate process then its pretty easy. You can run the process yourself or attach visual studio to existing running process and put break points.
If C++ code is an embedded DLL/LIB then you can use python as debug/launch process. As soon as python will load the DLL/LIB into your python code visual studio will activate your break points.
Alternatively you can also add windows debugger launcher calls to your code. As soon as your code gets executed, you will see a dialog box asking if you want to attach a debugger.
| 0 | 1,619 | false | 0 | 1 |
Debug C++ code in visual studio from python code running in eclipse
| 3,776,671 |
3 | 3 | 0 | 1 | 0 | 1 | 0.066568 | 0 |
Is it possible to create read only files in python which can not be changed later and in which users can not change its attribute from read-only to normal file?
Please suggest.
Thanks in advance.
| 0 |
python,file
|
2010-07-28T09:22:00.000
| 0 | 3,351,484 |
This is just impossible.
Any user with administrative rights can remove readonly restrictions of any kind.
Another option might be "Write a python program to kill all users over the worls so that they would not be able to change file attributes or security settings" :-)
| 0 | 3,100 | false | 0 | 1 |
Creating read only text files with python
| 3,351,513 |
3 | 3 | 0 | 3 | 0 | 1 | 1.2 | 0 |
Is it possible to create read only files in python which can not be changed later and in which users can not change its attribute from read-only to normal file?
Please suggest.
Thanks in advance.
| 0 |
python,file
|
2010-07-28T09:22:00.000
| 0 | 3,351,484 |
This is not python specific.
If the files are made by a different user that the one viewing it the script can make it read-only. As the file is owned by the python user, the viewing user cannot just change the attributes.
So it's very much an OS question, and not a Python question.
Oh, and there is no way to prevent an administrator changing the file, or for the file to be readable but not copyable.
| 0 | 3,100 | true | 0 | 1 |
Creating read only text files with python
| 3,351,517 |
3 | 3 | 0 | 0 | 0 | 1 | 0 | 0 |
Is it possible to create read only files in python which can not be changed later and in which users can not change its attribute from read-only to normal file?
Please suggest.
Thanks in advance.
| 0 |
python,file
|
2010-07-28T09:22:00.000
| 0 | 3,351,484 |
Take a look at os.chmod() function and execute it with appropriate parameters (filename, stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH) for your just created file.
On linux other users then you will not be able to change file or change attributes to writable.
Some root user or someone logged into you account will be able to change it though.
| 0 | 3,100 | false | 0 | 1 |
Creating read only text files with python
| 3,352,472 |
2 | 6 | 0 | 2 | 4 | 0 | 0.066568 | 0 |
I have a C# application that needs to be run several thousand times. Currently it precomputes a large table of constant values at the start of the run for reference. As these values will be the same from run to run I would like to compute them independently in a simple python script and then just have the C# app import the file at the start of each run.
The table consists of a sorted 2D array (500-3000+ rows/columns) of simple (int x, double y) tuples. I am looking for recommendations concerning the best/simplest way to store and then import this data. For example, I could store the data in a text file like this "(x1,y1)|(x2,y2)|(x3,y3)|...|(xn,yn)" This seems like a very ugly solution to a problem that seems to lend itself to a specific data structure or library I am currently unaware of. Any suggestions would be welcome.
| 0 |
c#,python,file
|
2010-07-28T17:52:00.000
| 0 | 3,355,832 |
You may consider running IronPython - then you can pass values back and forth across C#/Python
| 1 | 1,046 | false | 0 | 1 |
Suggestions for passing large table between Python and C#
| 3,355,927 |
2 | 6 | 0 | 1 | 4 | 0 | 0.033321 | 0 |
I have a C# application that needs to be run several thousand times. Currently it precomputes a large table of constant values at the start of the run for reference. As these values will be the same from run to run I would like to compute them independently in a simple python script and then just have the C# app import the file at the start of each run.
The table consists of a sorted 2D array (500-3000+ rows/columns) of simple (int x, double y) tuples. I am looking for recommendations concerning the best/simplest way to store and then import this data. For example, I could store the data in a text file like this "(x1,y1)|(x2,y2)|(x3,y3)|...|(xn,yn)" This seems like a very ugly solution to a problem that seems to lend itself to a specific data structure or library I am currently unaware of. Any suggestions would be welcome.
| 0 |
c#,python,file
|
2010-07-28T17:52:00.000
| 0 | 3,355,832 |
CSV is fine suggestion, but may be clumsy with values being int and double. Generally tab or semicomma are best separators.
| 1 | 1,046 | false | 0 | 1 |
Suggestions for passing large table between Python and C#
| 3,356,036 |
1 | 2 | 0 | 0 | 2 | 0 | 0 | 0 |
I am trying to load a CCITT T.3 compressed tiff into python, and get the pixel matrix from it. It should just be a logical matrix.
I have tried using pylibtiff and PIL, but when I load it with them, the matrix it returns is empty. I have read in a lot of places that these two tools support loading CCITT but not accessing the pixels.
I am open to converting the image, as long as I can get the logical matrix from it and do it in python code. The crazy thing is is that if I open one of my images in paint, save it without altering it, then try to load it with pylibtiff, it works. Paint re-compresses it to the LZW compression.
So I guess my real question is: Is there a way to either natively load CCITT images to matricies or convert the images to LZW using python??
Thanks,
tylerthemiler
| 0 |
python,compression,tiff,imaging,image-formats
|
2010-07-28T18:06:00.000
| 0 | 3,355,962 |
How about running tiffcp with subprocess to convert to LZW (-c lzw switch), then process normally with pylibtiff? There are Windows builds of tiffcp lying around on the web. Not exactly Python-native solution, but still...
| 1 | 1,297 | false | 0 | 1 |
What is the best way to load a CCITT T.3 compressed tiff using python?
| 3,357,139 |
2 | 2 | 0 | 4 | 1 | 0 | 0.379949 | 0 |
What are the Pro's and Con's of using win32api for I/O and other things instead of simply Python, if both have a specific function for it
I mean, using PyWin32 vs Win32Api
| 0 |
python,winapi,io
|
2010-07-28T22:42:00.000
| 1 | 3,358,126 |
The most obvious thing seems to be losing cross-platform compatibilty. Python runs on a number of different platforms, none of which has a win32 API except MS Windows.
| 0 | 390 | false | 0 | 1 |
win32api vs Python
| 3,358,136 |
2 | 2 | 0 | 5 | 1 | 0 | 1.2 | 0 |
What are the Pro's and Con's of using win32api for I/O and other things instead of simply Python, if both have a specific function for it
I mean, using PyWin32 vs Win32Api
| 0 |
python,winapi,io
|
2010-07-28T22:42:00.000
| 1 | 3,358,126 |
con
(lack of) portability
harder/more error prone
pro
performance (potentially, it must be measured, as will depend on more than just the api calls)
| 0 | 390 | true | 0 | 1 |
win32api vs Python
| 3,358,143 |
1 | 2 | 0 | 3 | 2 | 0 | 0.291313 | 0 |
I am using the Bottle framework. I have set the @error decorator so I am able to display my customized error page, and i can also send email if any 500 error occurs, but I need the complete traceback to be sent in the email. Does anyone know how to have the framework include that in the e-mail?
| 0 |
python,error-handling,bottle
|
2010-07-29T13:47:00.000
| 0 | 3,363,167 |
in the error500 function written after the @error decorator to serve my customized error page, wrote error.exception and error.traceback, these two give the exception and complete traceback of the error message.
| 0 | 894 | false | 1 | 1 |
E-mail traceback on errors in Bottle framework
| 3,393,377 |
1 | 3 | 0 | 1 | 0 | 0 | 0.066568 | 0 |
I'm a LAMP developer trying out Python for the first time.. I'm okay with picking up the syntax, but I can't figure out how to run it on the server! I've tried the following
uploading filename.py to a regular web/public directory. chmod 777, 711, 733, 773... (variations of execute)
putting the filename.py in cgi-bin, chmod same as above..
Typing up example.com/filename.py simply loads a textfile - nothing appears to have been compiled/parsed/etc!
(I believe python is installed, as
whereis python on my server shows /usr/bin/python among several other directories)
Many words for a simple question - how do you run a python file on a CentOS server?
| 0 |
python,centos
|
2010-07-30T06:17:00.000
| 1 | 3,369,080 |
you can use cgi, but that will not have great performance as it starts a new process for each request.
More efficient alternatives are to use fastcgi or wsgi
A third option is to run a mini Python webserver and proxy the requests from apache using rewrite rules
| 0 | 5,711 | false | 0 | 1 |
Running a .py file on LAMP (CentOS) server - from a PHP developer's perspective
| 3,369,157 |
1 | 7 | 0 | 3 | 545 | 1 | 0.085505 | 0 |
I completed my first proper project in Python and now my task is to write tests for it.
Since this is the first time I did a project, this is the first time I would be writing tests for it.
The question is, how do I start? I have absolutely no idea. Can anyone point me to some documentation/ tutorial/ link/ book that I can use to start with writing tests (and I guess unit testing in particular)
Any advice will be welcomed on this topic.
| 0 |
python,unit-testing,testing
|
2010-07-30T12:10:00.000
| 0 | 3,371,255 |
nosetests is a brilliant solution for unit testing in Python. It supports both unittest based testcases and doctests, and gets you started with it with just a simple configuration file.
| 0 | 258,822 | false | 0 | 1 |
Writing unit tests in Python: How do I start?
| 3,371,690 |
3 | 7 | 0 | 2 | 17 | 1 | 0.057081 | 0 |
I'm a big fan of PHP and it's obviously a very weakly-typed language. I realize some of the benefits include the general independence of changing variable types on the fly and such.
What I'm wondering about are the drawbacks. What can you get out of a strongly-typed language like C that you otherwise can't get from a weakly-typed one like PHP? Also with type setting (like double($variable)), one could argue that even a weakly-typed language can act just like a strongly-typed one.
So. Weak-type. What are some benefits I didn't include? More importantly, what are the drawbacks?
| 0 |
php,python,c,types
|
2010-07-31T00:24:00.000
| 0 | 3,376,252 |
Many a book has been written about this sort of thing. There's an inherent tradeoff; with a weakly-typed language a lot of annoyances simply cease to be. For instance, in Python you never have to worry about dividing a float by an int; adding an int to a list; typing functions' arguments (did you know, OCaml has special +. operators for adding floats because (+) sends ints to ints!); forgetting that a variable can be null... those sorts of problems simply vanish.
In their place come a whole host of new runtime bugs: Python's [0]*5 gives, wait for it, [0,0,0,0,0]! OCaml, for all the annoyance of strong typing, catches many many bugs with its compiler; and this is precisely why it's good. It's a tradeoff.
| 0 | 11,418 | false | 0 | 1 |
What are the benefits (and drawbacks) of a weakly typed language?
| 3,376,298 |
3 | 7 | 0 | 0 | 17 | 1 | 0 | 0 |
I'm a big fan of PHP and it's obviously a very weakly-typed language. I realize some of the benefits include the general independence of changing variable types on the fly and such.
What I'm wondering about are the drawbacks. What can you get out of a strongly-typed language like C that you otherwise can't get from a weakly-typed one like PHP? Also with type setting (like double($variable)), one could argue that even a weakly-typed language can act just like a strongly-typed one.
So. Weak-type. What are some benefits I didn't include? More importantly, what are the drawbacks?
| 0 |
php,python,c,types
|
2010-07-31T00:24:00.000
| 0 | 3,376,252 |
You have to understand that PHP was created for the context of web applications. Everything in the context of the web is a string. Therefore it is very rare where strong typing would be beneficial.
| 0 | 11,418 | false | 0 | 1 |
What are the benefits (and drawbacks) of a weakly typed language?
| 18,869,364 |
3 | 7 | 0 | 5 | 17 | 1 | 0.141893 | 0 |
I'm a big fan of PHP and it's obviously a very weakly-typed language. I realize some of the benefits include the general independence of changing variable types on the fly and such.
What I'm wondering about are the drawbacks. What can you get out of a strongly-typed language like C that you otherwise can't get from a weakly-typed one like PHP? Also with type setting (like double($variable)), one could argue that even a weakly-typed language can act just like a strongly-typed one.
So. Weak-type. What are some benefits I didn't include? More importantly, what are the drawbacks?
| 0 |
php,python,c,types
|
2010-07-31T00:24:00.000
| 0 | 3,376,252 |
I have been using both strong typed (like Java) and weak typed (like JavaScript) languages for some time now. What I have found is that the convenience of the weak typed languages are great for small applications. Unfortunately, as the application grows in size, it becomes impossible to manage. There becomes too much to keep track of in your head and you have to start depending on your IDE and the compiler more and more or your coding grinds to a halt. That is when strong typed languages start to become more useful - with the application grows very large.
Two examples that constantly drive me nuts in the weak typed JavaScript are using external libraries that are not thoroughly documented and refactoring.
External libraries: When dealing with a strongly typed language, the code from the library itself provides self documentation. When I create a variable of type Person, the IDE can inspect the code and tell there is a getFirstName(), getLastName() and getFullName(). In weak typed languages, this is not the case as a variable could be anything, have any kind of variable or function and have function arguments that could also be anything (they are not explicitly defined). As a result, a developer has to lean heavily on documentation, web searches, discussion forums and their memory of past usages. I find it can take hours of looking things up in JavaScript for external libraries while with Java I just hit the "." key and it pops up all my options with documentation attached. When you encounter libraries that are not 100% fully documented, it can be really frustrating with weak typed languages. I recently found myself asking "What is argument 'plot' in function 'draw'?" when using jqplot, a fairly well but not completely documented JavaScript library. I had to spend an hour or two digging through source code before finally giving up and finding an alternative solution.
Refactoring: With strongly typed languages, I find myself able to refactor quickly by just changing the file I need to change and then going to fix the compiler errors. Some tools will even refactor for you with a simple click of a button. With weak typed languages, you have to do a search and then replace with care and then test, test, TEST and then test some more. You are seldom entirely sure you have found and fixed everything you broke, especially in large applications.
For simple needs and small applications, these two concerns are minimal to non-existent. But if you are working with an application with 100's of thousands or millions of lines of code, weak typed languages will drive you nuts.
I think many developers get upset about this and turn it into an emotional discussion is because we sometimes get it in our heads that there is one right and one wrong approach. But each approach has its merits - its own advantages and disadvantages. Once you recognize that you set the emotion aside and choose the best for you for what you need right now.
| 0 | 11,418 | false | 0 | 1 |
What are the benefits (and drawbacks) of a weakly typed language?
| 28,466,502 |
4 | 7 | 0 | 3 | 0 | 1 | 0.085505 | 0 |
After working for on JAVA for a long time now i feel like also learn some other language just for a change. This time i want to spend some time learning and reading one of the dynamic languages.
Which is the most appropriate one that covers most of the features offered by dynamic languages and the syntax which probably is fun and also one that is closer to the syntax used by most of the dynamic languages.
BR,
Keshav
| 0 |
python,ruby,dynamic-languages
|
2010-07-31T17:43:00.000
| 0 | 3,379,174 |
Learn [one of] these:
Ruby
Python
Clojure (a modern Lisp)
JavaScript (yes, this is a great dynamic language!)
Don't transition via a semi-dynamic, semi-Java language. Just jump in and try a dynamic language. In order to really understand what else is going on, you have to get out of the Java world by jumping in, not by sticking your toes into the water.
Yes, I know Clojure is on the JVM and that Ruby and Python have implementations on the JVM as well. But the runtime implementation of a language does not define the language. Learn the language, and you can pick a favorite runtime.
| 0 | 367 | false | 0 | 1 |
Which is the most preferred language to start with dynamic languages
| 3,379,213 |
4 | 7 | 0 | 0 | 0 | 1 | 0 | 0 |
After working for on JAVA for a long time now i feel like also learn some other language just for a change. This time i want to spend some time learning and reading one of the dynamic languages.
Which is the most appropriate one that covers most of the features offered by dynamic languages and the syntax which probably is fun and also one that is closer to the syntax used by most of the dynamic languages.
BR,
Keshav
| 0 |
python,ruby,dynamic-languages
|
2010-07-31T17:43:00.000
| 0 | 3,379,174 |
Try Jython, if you like Java, this way you can both ;-)
| 0 | 367 | false | 0 | 1 |
Which is the most preferred language to start with dynamic languages
| 3,379,189 |
4 | 7 | 0 | 2 | 0 | 1 | 0.057081 | 0 |
After working for on JAVA for a long time now i feel like also learn some other language just for a change. This time i want to spend some time learning and reading one of the dynamic languages.
Which is the most appropriate one that covers most of the features offered by dynamic languages and the syntax which probably is fun and also one that is closer to the syntax used by most of the dynamic languages.
BR,
Keshav
| 0 |
python,ruby,dynamic-languages
|
2010-07-31T17:43:00.000
| 0 | 3,379,174 |
Ahah, nice troll :) (with ruby and python tags).
In my humble opinion, after trying many languages, my favorite is Ruby with Ruby on Rails.
| 0 | 367 | false | 0 | 1 |
Which is the most preferred language to start with dynamic languages
| 3,379,188 |
4 | 7 | 0 | 7 | 0 | 1 | 1 | 0 |
After working for on JAVA for a long time now i feel like also learn some other language just for a change. This time i want to spend some time learning and reading one of the dynamic languages.
Which is the most appropriate one that covers most of the features offered by dynamic languages and the syntax which probably is fun and also one that is closer to the syntax used by most of the dynamic languages.
BR,
Keshav
| 0 |
python,ruby,dynamic-languages
|
2010-07-31T17:43:00.000
| 0 | 3,379,174 |
Python is always fun.Go for it.
| 0 | 367 | false | 0 | 1 |
Which is the most preferred language to start with dynamic languages
| 3,379,183 |
1 | 1 | 0 | 2 | 1 | 0 | 1.2 | 1 |
i developed an aplication built on twitter api , but i get erorrs like a mesage that i've parsed and deleted to be parsed again at the next execution , could that be because i left the twitter connection opened or is just a fault of the twitter API. I also tried to delete all direct messages because it seemed too full for me but instead the Api has just reset the count of my messages , the messages haven't been deleted:((
| 0 |
python,twitter
|
2010-08-02T07:59:00.000
| 0 | 3,385,990 |
Twitter's API is over HTTP, which is a stateless protocol. you don't really need to close the connection, since connections made and closed for each request
| 0 | 105 | true | 0 | 1 |
twitter connection needs to be closed?
| 3,388,478 |
1 | 3 | 1 | 4 | 2 | 0 | 1.2 | 0 |
HI all
I am trying to use SWIG to export C++ code to Python.
The C sample I read on the web site does work but I have problem with C++ code.
Here are the lines I call
swig -c++ -python SWIG_TEST.i
g++ -c -fPIC SWIG_TEST.cpp SWIG_TEST_wrap.cxx -I/usr/include/python2.4/
gcc --shared SWIG_TEST.o SWIG_TEST_wrap.o -o _SWIG_TEST.so -lstdc++
When I am finished I receive the following error message
ImportError: ./_SWIG_TEST.so: undefined symbol: Py_InitModule4
Do you know what it is?
| 0 |
c++,python,swig
|
2010-08-02T12:20:00.000
| 0 | 3,387,663 |
It looks like you aren't linking to the Python runtime library. Something like adding -lpython24 to your gcc line. (I don't have a Linux system handy at the moment).
| 0 | 886 | true | 0 | 1 |
using SWIG with C++
| 3,393,617 |
1 | 3 | 0 | 0 | 6 | 0 | 0 | 1 |
Do you know how I could get one of the IPv6 adress of one of my interface in python2.6. I tried something with the socket module which lead me nowhere.
Thanks.
| 0 |
python,linux,ipv6
|
2010-08-02T14:53:00.000
| 0 | 3,388,911 |
You could just simply run 'ifconfig' with a subprocess.* call and parse the output.
| 0 | 3,133 | false | 0 | 1 |
How to get the IPv6 address of an interface under linux
| 3,388,966 |
1 | 1 | 0 | 1 | 1 | 0 | 1.2 | 0 |
I wanted to make a website that would let users record a small video message through their broswer and save it to my website.
As I have never used flash, i wanted to know what softwares would be required and what programming languages would I need? I mean, what should I go about learning to implement such a site. I would prefer open-source solutions wherever possible.
Can something like this be implemented using python and html5?
| 0 |
python,flash,video-capture,html5-video
|
2010-08-02T19:49:00.000
| 0 | 3,391,222 |
There are many video solutions. Here are two:
Take a look at Flash Media Server (FMS). You will need to some server-side code to place the video into a folder as it streams up.
Also, if you're looking into free open-source take a look at Red5.
| 0 | 549 | true | 1 | 1 |
Flash video record on website tutorial
| 3,393,137 |
1 | 1 | 0 | 1 | 0 | 1 | 1.2 | 0 |
I have this line:
NSWorkspace.sharedWorkspace().setIcon_forFile_options_(unicode(icon),unicode(target),0)
Why does it give that error and how do I fix it?
Thank you.
| 0 |
python,objective-c,unicode,pyobjc
|
2010-08-02T20:58:00.000
| 0 | 3,391,692 |
I misread the documentation. I need to do this:
NSWorkspace.sharedWorkspace().setIcon_forFile_options_(NSImage.alloc().initWithContentsOfFile_(icon),target,0)
Unfortunately the error is what confused me.
| 0 | 318 | true | 0 | 1 |
PyObjC giving strange error - [OC_PythonUnicode representations]: unrecognized selector sent to instance 0x258ae2a0
| 3,391,733 |
1 | 2 | 0 | 1 | 0 | 0 | 1.2 | 0 |
I have a c# application that defines a membership provider used in a Asp.Net MVC application.
And i have an apache httpd server that does authentication with mod_wsgi.
The objective is to share the membership provider between the two, so that the authentication information be the same.
How can i achieve this behaviour ?
| 0 |
c#,python,apache,mod-wsgi
|
2010-08-03T09:58:00.000
| 0 | 3,395,409 |
Trivially.
Apache serves static content.
Certain URI's will be routed to mod_wsgi to Python.
Python will then execute (via subprocess) a C# program, providing command-line arguments, and reading the standard output response from the C# program.
Python does whatever else is required to serve the web pages.
This presumes your C# application runs at the command line, reads command-line parameters and writes its result to standard output. This is an easy thing to build. It may not be the way it works today, but any program that runs from the command line is trivial to integrate.
Your C# application, BTW, can also be rewritten into Python. It isn't magic. It's just code. Read the code, understand the code, and translate the code. You'll be a lot happier replacing the C# with something simpler.
| 0 | 145 | true | 0 | 1 |
using c# inside an apache python script
| 3,395,446 |
5 | 6 | 0 | 1 | 1 | 1 | 0.033321 | 0 |
Is it just me or is having to run multiple instances of a web server to scale a hack?
Am I wrong in this?
Clarification
I am referring to how I read people run multiple instances of a web service on a single server. I am not talking about a cluster of servers.
| 0 |
python,ruby-on-rails
|
2010-08-03T18:06:00.000
| 0 | 3,399,367 |
Even if Ruby/Python interpreters were perfect, and could utilize all avail CPU with single process, you would still reach maximal capability of single server sooner or later and have to scale across several machines, going back to running several instances of your app.
| 0 | 584 | false | 1 | 1 |
having to run multiple instances of a web service for ruby/python seems like a hack to me
| 3,399,696 |
5 | 6 | 0 | 1 | 1 | 1 | 0.033321 | 0 |
Is it just me or is having to run multiple instances of a web server to scale a hack?
Am I wrong in this?
Clarification
I am referring to how I read people run multiple instances of a web service on a single server. I am not talking about a cluster of servers.
| 0 |
python,ruby-on-rails
|
2010-08-03T18:06:00.000
| 0 | 3,399,367 |
With no details, it is very difficult to see what you are getting at. That being said, it is quite possible that you are simply not using the right approach for your problem.
Sometimes multiple separate instances are better. Sometimes, your Python services are actually better deployed behind a single Apache instance (using mod_wsgi) which may elect to use more than a single process. I don't know about Ruby to opinionate there.
In short, if you want to make your service scalable then the way to do so depends heavily on additional details. Is it scaling up or scaling out? What is the operating system and available or possibly installable server software? Is the service itself easily parallelized and how much is it database dependent? How is the database deployed?
| 0 | 584 | false | 1 | 1 |
having to run multiple instances of a web service for ruby/python seems like a hack to me
| 3,399,437 |
5 | 6 | 0 | 0 | 1 | 1 | 0 | 0 |
Is it just me or is having to run multiple instances of a web server to scale a hack?
Am I wrong in this?
Clarification
I am referring to how I read people run multiple instances of a web service on a single server. I am not talking about a cluster of servers.
| 0 |
python,ruby-on-rails
|
2010-08-03T18:06:00.000
| 0 | 3,399,367 |
Your assumption that Tomcat's and IIS's single process per server is superior is flawed. The choice of a multi-threaded server and a multi-process server depends on a lot of variables.
One main thing is the underlying operating system. Unix systems have always had great support for multi-processing because of the copy-on-write nature of the fork system call. This makes multi-processes a really attractive option because web-serving is usually very shared-nothing and you don't have to worry about locking. Windows on the other hand had much heavier processes and lighter threads so programs like IIS would gravitate to a multi-threading model.
As for the question to wether it's a hack to run multiple servers really depends on your perspective. If you look at Apache, it comes with a variety of pluggable engines to choose from. The MPM-prefork one is the default because it allows the programmer to easily use non-thread-safe C/Perl/database libraries without having to throw locks and semaphores all over the place. To some that might be a hack to work around poorly implemented libraries. To me it's a brilliant way of leaving it to the OS to handle the problems and letting me get back to work.
Also a multi-process model comes with a few features that would be very difficult to implement in a multi-threaded server. Because they are just processes, zero-downtime rolling-updates are trivial. You can do it with a bash script.
It also has it's short-comings. In a single-server model setting up a singleton that holds some global state is trivial, while on a multi-process model you have to serialize that state to a database or Redis server. (Of course if your single-process server outgrows a single server you'll have to do that anyway.)
Is it a hack? Yes and no. Both original implementations (MRI, and CPython) have Global Interpreter Locks that will prevent a multi-core server from operating at it's 100% potential. On the other hand multi-process has it's advantages (especially on the Unix-side of the fence).
There's also nothing inherent in the languages themselves that makes them require a GIL, so you can run your application with Jython, JRuby, IronPython or IronRuby if you really want to share state inside a single process.
| 0 | 584 | false | 1 | 1 |
having to run multiple instances of a web service for ruby/python seems like a hack to me
| 3,402,337 |
5 | 6 | 0 | 4 | 1 | 1 | 1.2 | 0 |
Is it just me or is having to run multiple instances of a web server to scale a hack?
Am I wrong in this?
Clarification
I am referring to how I read people run multiple instances of a web service on a single server. I am not talking about a cluster of servers.
| 0 |
python,ruby-on-rails
|
2010-08-03T18:06:00.000
| 0 | 3,399,367 |
Not really, people were running multiple frontends across a cluster of servers before multicore cpus became widespread
So there has been all the infrastructure for supporting sessions properly across multiple frontends for quite some time before it became really advantageous to run a bunch of threads on one machine.
Infact using asynchronous style frontends gives better performance on the same hardware than a multithreaded approach, so I would say that not running multiple instances in favour of a multithreaded monster is a hack
| 0 | 584 | true | 1 | 1 |
having to run multiple instances of a web service for ruby/python seems like a hack to me
| 3,399,409 |
5 | 6 | 0 | 4 | 1 | 1 | 0.132549 | 0 |
Is it just me or is having to run multiple instances of a web server to scale a hack?
Am I wrong in this?
Clarification
I am referring to how I read people run multiple instances of a web service on a single server. I am not talking about a cluster of servers.
| 0 |
python,ruby-on-rails
|
2010-08-03T18:06:00.000
| 0 | 3,399,367 |
Since we are now moving towards more cores, rather than faster processors - in order to scale more and more, you will need to be running more instances.
So yes, I reckon you are wrong.
This does not by any means condone brain-dead programming with the excuse that you can just scale it horizontally, that just seems retarded.
| 0 | 584 | false | 1 | 1 |
having to run multiple instances of a web service for ruby/python seems like a hack to me
| 3,399,416 |
4 | 6 | 0 | 0 | 3 | 1 | 0 | 0 |
I'm a mechanical engineering student, and I'm building a physical simulation using PyODE.
instead of running everything from one file, I wanted to organize stuff in modules so I had:
main.py
callback.py
helper.py
I ran into problems when I realized that helper.py needed to reference variables from main, but main was the one importing helper!
so my solution was to create a 4th file, which houses variables and imports only external modules (such as time and random).
so I now have:
main.py
callback.py
helper.py
parameters.py
and all scripts have: import parameters and use: parameters.foo or parameters.bar.
Is this an acceptable practice or is this a sure fire way to make python programmers puke? :)
Please let me know if this makes sense, or if there is a more sensible way of doing it!
Thanks,
-Leav
| 0 |
python
|
2010-08-03T21:23:00.000
| 0 | 3,400,847 |
Seems like what you want is to organize various dependencies between components. You will be better off expressing these dependencies in an object-oriented manner. Rather than doing it by importing modules and global states, encode these states in objects and pass those around.
Read up on objects and classes and how to write them in Python; I'd probably start there.
| 0 | 260 | false | 0 | 1 |
A python module for global parameters - is this good practice?
| 3,401,173 |
4 | 6 | 0 | 1 | 3 | 1 | 1.2 | 0 |
I'm a mechanical engineering student, and I'm building a physical simulation using PyODE.
instead of running everything from one file, I wanted to organize stuff in modules so I had:
main.py
callback.py
helper.py
I ran into problems when I realized that helper.py needed to reference variables from main, but main was the one importing helper!
so my solution was to create a 4th file, which houses variables and imports only external modules (such as time and random).
so I now have:
main.py
callback.py
helper.py
parameters.py
and all scripts have: import parameters and use: parameters.foo or parameters.bar.
Is this an acceptable practice or is this a sure fire way to make python programmers puke? :)
Please let me know if this makes sense, or if there is a more sensible way of doing it!
Thanks,
-Leav
| 0 |
python
|
2010-08-03T21:23:00.000
| 0 | 3,400,847 |
I try to design my code so that it looks much like a pyramid. That, I have found, leads to cleaner code.
| 0 | 260 | true | 0 | 1 |
A python module for global parameters - is this good practice?
| 3,401,021 |
4 | 6 | 0 | 3 | 3 | 1 | 0.099668 | 0 |
I'm a mechanical engineering student, and I'm building a physical simulation using PyODE.
instead of running everything from one file, I wanted to organize stuff in modules so I had:
main.py
callback.py
helper.py
I ran into problems when I realized that helper.py needed to reference variables from main, but main was the one importing helper!
so my solution was to create a 4th file, which houses variables and imports only external modules (such as time and random).
so I now have:
main.py
callback.py
helper.py
parameters.py
and all scripts have: import parameters and use: parameters.foo or parameters.bar.
Is this an acceptable practice or is this a sure fire way to make python programmers puke? :)
Please let me know if this makes sense, or if there is a more sensible way of doing it!
Thanks,
-Leav
| 0 |
python
|
2010-08-03T21:23:00.000
| 0 | 3,400,847 |
Separate 'global' files for constants, configurations, and includes needed everywhere are fine. But when they contain actual mutable variables then they're not such a good idea. Consider having the files communicate with function return values and arguments instead. This promotes encapsulation and will keep your code from becoming a tangled mess.
Clear communication between files makes them easier to understand and makes what's going on more obvious. When you're using variables and nobody knows where they came from, things can get pretty annoying. :)
| 0 | 260 | false | 0 | 1 |
A python module for global parameters - is this good practice?
| 3,400,902 |
4 | 6 | 0 | 2 | 3 | 1 | 0.066568 | 0 |
I'm a mechanical engineering student, and I'm building a physical simulation using PyODE.
instead of running everything from one file, I wanted to organize stuff in modules so I had:
main.py
callback.py
helper.py
I ran into problems when I realized that helper.py needed to reference variables from main, but main was the one importing helper!
so my solution was to create a 4th file, which houses variables and imports only external modules (such as time and random).
so I now have:
main.py
callback.py
helper.py
parameters.py
and all scripts have: import parameters and use: parameters.foo or parameters.bar.
Is this an acceptable practice or is this a sure fire way to make python programmers puke? :)
Please let me know if this makes sense, or if there is a more sensible way of doing it!
Thanks,
-Leav
| 0 |
python
|
2010-08-03T21:23:00.000
| 0 | 3,400,847 |
Uhm, i think it does not make sence if this happens: "realized that helper.py needed to reference variables from main", your helper functions should be independent from your "main code", otherwise i think its ugly and more like a design failure.
| 0 | 260 | false | 0 | 1 |
A python module for global parameters - is this good practice?
| 3,400,871 |
1 | 3 | 0 | 1 | 2 | 1 | 0.066568 | 0 |
Python has a subversion bindings called 'pysvn' that can be used to manipulate subversion repository. Does something similar exists for IronPython?
My test platform in Windows 7 64-bit with Visual Studio 2010.
| 0 |
.net,visual-studio-2010,ironpython,pysvn
|
2010-08-04T18:31:00.000
| 0 | 3,408,610 |
I believe you can import pysvn in IronPython, but you have to add python site-packages directory to IRONPYTHONPATH.
| 0 | 248 | false | 0 | 1 |
is it possible to access subversion from ironpython?
| 3,408,897 |
3 | 3 | 0 | 2 | 0 | 0 | 0.132549 | 0 |
Does anyone know how to get an intellisense like functionality (better than default) in eclipse for python development? I am using Eclipse 3.5 with aptana and pydev and the interpreter is python 2.5.2
| 0 |
python,eclipse,intellisense,pydev
|
2010-08-04T19:41:00.000
| 1 | 3,409,226 |
I'm using eclipse 3.6 and pydev with python 2.6 and it's the best one I've tested up to now. I didn't try 3.5 so not sure if it's the same as yours but I think it autocompletes well compared to others I tried but I didn't try any of the paid ones.
| 0 | 3,548 | false | 0 | 1 |
How do you get Intellisense for Python in Eclipse/Aptana/Pydev?
| 3,409,335 |
3 | 3 | 0 | 3 | 0 | 0 | 0.197375 | 0 |
Does anyone know how to get an intellisense like functionality (better than default) in eclipse for python development? I am using Eclipse 3.5 with aptana and pydev and the interpreter is python 2.5.2
| 0 |
python,eclipse,intellisense,pydev
|
2010-08-04T19:41:00.000
| 1 | 3,409,226 |
You are probably never going to get something as good as intellisense for python. Due to the dynamic nature of python, it is often impossible to be able to know the type of some variables.
And if you don't know their types, you can't do auto-complete on things like class members.
Personally, I think the auto-complete in PyDev is pretty good, given the nature of python. It isn't as good as for Java and probably won't be, but it sure beats not having anything.
Having said that, I haven't tried if PyDev is able to use the parameter types you can specify in python 3.x. Otherwise, that might be an improvement that could make life a little easier.
Update: Got curious and did a quick test, Looks like optional type information in python 3 is not used by PyDev.
| 0 | 3,548 | false | 0 | 1 |
How do you get Intellisense for Python in Eclipse/Aptana/Pydev?
| 3,409,439 |
3 | 3 | 0 | 0 | 0 | 0 | 0 | 0 |
Does anyone know how to get an intellisense like functionality (better than default) in eclipse for python development? I am using Eclipse 3.5 with aptana and pydev and the interpreter is python 2.5.2
| 0 |
python,eclipse,intellisense,pydev
|
2010-08-04T19:41:00.000
| 1 | 3,409,226 |
In Aptana I added the reference to the .egg file to the system PYTHONPATH in Preferences menu. I am not sure if this works for every library out there.
Preferences --> PyDev --> Interpreter Python --> Libraries tab on the right.
| 0 | 3,548 | false | 0 | 1 |
How do you get Intellisense for Python in Eclipse/Aptana/Pydev?
| 9,141,159 |
1 | 3 | 0 | 3 | 2 | 1 | 0.197375 | 0 |
Why is this such a bad idea? (According to many people)
| 0 |
python,shell
|
2010-08-04T22:17:00.000
| 0 | 3,410,296 |
I don't think it's a bad idea. Lots of people use IPython which is a shell written in Python :)
In fact you may want to base your effort around IPython. scipy does this, for example
| 0 | 797 | false | 0 | 1 |
Writing a Shell in Python?
| 3,410,409 |
1 | 2 | 0 | 6 | 30 | 1 | 1 | 0 |
Besides the obvious (one is a type, the other a class)? What should be preferred? Any notable difference in use cases, perhaps?
| 0 |
python,string
|
2010-08-04T22:18:00.000
| 0 | 3,410,309 |
In terms of python 2.7 and 3:
io.BytesIO is an in-memory file-like object that doesn't do any alteration to newlines, and is similar to open(filename, "wb"). It deal with bytes() strings, which in py2.7 is an alias for str.
io.StringIO is an in-memory file-like object that does do alterations to newlines, and is similar to open(filename, "w"). It deal with unicode() strings, which in py3.x is an alias for str.
py2.7's old StringIO.StringIO is an in-memory file-like object that does not do alterations to newlines, and is similar to open(filename, "w"). It deals with both unicode() and bytes() in the same way that most obsolete python 2 string methods do: by allowing you to mix them without error, but only as long as you're lucky.
Thus py2.7's old StringIO.StringIO class is actually more similar to io.BytesIO than io.StringIO, as it is operating in terms of bytes()/str() and doesn't do newline conversions.
What should be preferred?
Don't use StringIO.StringIO, instead use io.BytesIO or io.StringIO, depending on the use-case. This is forward compatible with python 3 and commits to bytes or unicode, rather than "both, maybe".
| 0 | 19,774 | false | 0 | 1 |
What is the difference between StringIO and io.StringIO in Python2.7?
| 49,795,277 |
6 | 8 | 0 | 2 | 0 | 0 | 0.049958 | 0 |
I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a variety of complicated reasons, this fall is the only time I can learn both languages. Please advise.
GillingsT
Update:
A little more detail about myself: as I said I did a PhD in Molecular Genetic. I now wish to be able to obtain programming skills so that I can apply it to do bioinformatics- like sequence manipulation and pathway analysis. I was told that Python is great for that but our course does not cover basics for beginners. I approached a Comp Sci Prof. who suggested that I learn C++ first before learning Python. So I got into this dilemma (added to other logistics).
| 0 |
c++,python
|
2010-08-05T15:29:00.000
| 0 | 3,416,342 |
If you are new to programming, I would say start with the C++ class. If you get the hang of it and enjoy programming, you can always learn Python later. There are a wealth of good books and Internet resources on pretty much any programming language out there that you should be able to teach yourself any language in your spare time. I would recommend learning that first language in a formal classroom, however, to help make it easier to learn the general concepts behind programming.
Edit: To clarify the point I was trying to make, my recommendation is to take whichever course is geared more towards beginning programmers. The important things to learn first are the basic fundamentals of programming. These apply towards almost any language. Thanks to the wealth of resources available online or in your bookstore/library, you can teach yourself practically any programming language that you want to learn. First, however, you must grasp the basics, and intro C/C++ classes typically (in my experiences, at least) do a good job of teaching programming fundamentals as well as the language itself.
Since you are a beginning programmer, I would not recommend trying to learn two languages at once (especially if you are trying to learn fundamentals at the same time). That's a lot of very similar (yet very different) information to keep track of in your head, almost like trying to learn two brand new spoken languages at the same time. You may be able to handle it perfectly fine but at least for most programmers that I know, it is much easier to get a good grasp on one language first and then start learning the second.
| 0 | 4,081 | false | 0 | 1 |
C++ and python simultaneously. Is it doable
| 3,416,435 |
6 | 8 | 0 | 0 | 0 | 0 | 0 | 0 |
I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a variety of complicated reasons, this fall is the only time I can learn both languages. Please advise.
GillingsT
Update:
A little more detail about myself: as I said I did a PhD in Molecular Genetic. I now wish to be able to obtain programming skills so that I can apply it to do bioinformatics- like sequence manipulation and pathway analysis. I was told that Python is great for that but our course does not cover basics for beginners. I approached a Comp Sci Prof. who suggested that I learn C++ first before learning Python. So I got into this dilemma (added to other logistics).
| 0 |
c++,python
|
2010-08-05T15:29:00.000
| 0 | 3,416,342 |
You've got to find out what people in your field are programming with so you can leverage existing libraries/APIs/projects. It won't do you any good re-inventing the wheel in C++ or Python if there's some wicked-cool FORTRAN library out there that is standard in your field. (And, if that is the case, God help you, I'm sorry.) Anyway, the CS prof you talked to might not have any idea what computational molecular geneticists use.
| 0 | 4,081 | false | 0 | 1 |
C++ and python simultaneously. Is it doable
| 3,648,941 |
6 | 8 | 0 | 0 | 0 | 0 | 0 | 0 |
I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a variety of complicated reasons, this fall is the only time I can learn both languages. Please advise.
GillingsT
Update:
A little more detail about myself: as I said I did a PhD in Molecular Genetic. I now wish to be able to obtain programming skills so that I can apply it to do bioinformatics- like sequence manipulation and pathway analysis. I was told that Python is great for that but our course does not cover basics for beginners. I approached a Comp Sci Prof. who suggested that I learn C++ first before learning Python. So I got into this dilemma (added to other logistics).
| 0 |
c++,python
|
2010-08-05T15:29:00.000
| 0 | 3,416,342 |
I come from a computational maths background, and have written sizeable (commercial and accademic) programs in both C++ and python. They are very different languages and I would probably learn one first (or only one).
Which one would depend on what you want to be able to do with the language.
If you want to build something useful with your language that is not (overly) compute or data heavy, go with python, you'll get something useful quicker.
If you need to do something useful that is either compute heavy or data heavy, then you'll probably need to go with C++. But it will take you longer to get to something to do what you need --- It will take a while to learn C++, then additional time to code data-heavy or compute-heavy code effectively.
Now some will say that python can handle data/compute heavy jobs well enough.. but in molecular biology "heavy" can mean very heavy.
Having said this, my suggestion is go with python if you can.
| 0 | 4,081 | false | 0 | 1 |
C++ and python simultaneously. Is it doable
| 3,648,912 |
6 | 8 | 0 | 7 | 0 | 0 | 1 | 0 |
I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a variety of complicated reasons, this fall is the only time I can learn both languages. Please advise.
GillingsT
Update:
A little more detail about myself: as I said I did a PhD in Molecular Genetic. I now wish to be able to obtain programming skills so that I can apply it to do bioinformatics- like sequence manipulation and pathway analysis. I was told that Python is great for that but our course does not cover basics for beginners. I approached a Comp Sci Prof. who suggested that I learn C++ first before learning Python. So I got into this dilemma (added to other logistics).
| 0 |
c++,python
|
2010-08-05T15:29:00.000
| 0 | 3,416,342 |
You'll get holes in the head.
Python's data structures and memory management are radically different from C++.
Whichever language you "get" first, you'll love. The other you'll hate. Indeed, you'll be confused at the weird things one language lacks that the other has. One language will be reasonable, logical, unsurprising. The other will be a mess of ad-hoc decisions and quirks.
If you learn one all the way through -- by itself -- you'll probably be happier.
I find that most folks can more easily add a language to a base of expertise.
[Not all, however. Some folks are so mired in the first language they ever learned that they challenge every feature of a new language as being nonsensical. I had a guy in a Java class who only wanted to complain about the numerous ways that Java wasn't Fortran. All the type-specific stuff in Java gave him fits. A lot of discussions had to be curtailed with "That's the way it is. If you don't like it, take it up with Gosling. My job isn't to justify Java; my job is to get you to be able to work with java. Can we move on, now?"]
| 0 | 4,081 | false | 0 | 1 |
C++ and python simultaneously. Is it doable
| 3,416,441 |
6 | 8 | 0 | 1 | 0 | 0 | 0.024995 | 0 |
I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a variety of complicated reasons, this fall is the only time I can learn both languages. Please advise.
GillingsT
Update:
A little more detail about myself: as I said I did a PhD in Molecular Genetic. I now wish to be able to obtain programming skills so that I can apply it to do bioinformatics- like sequence manipulation and pathway analysis. I was told that Python is great for that but our course does not cover basics for beginners. I approached a Comp Sci Prof. who suggested that I learn C++ first before learning Python. So I got into this dilemma (added to other logistics).
| 0 |
c++,python
|
2010-08-05T15:29:00.000
| 0 | 3,416,342 |
I think that given the circumstances (fulltime employee, etc) studying one language will be hard enough. Pick one, then study another. You'll learn basics from either language.
As for "which language to pick"... I specialize in C++, and know a bit of python. C++ is much more difficult, more flexible, and more suitable for making "traditional" executables.
I'd recommend to start with C++. You'll learn more concepts (some of them doesn't exist in python), and learning python after C++ won't be a problem.
| 0 | 4,081 | false | 0 | 1 |
C++ and python simultaneously. Is it doable
| 3,416,466 |
6 | 8 | 0 | 0 | 0 | 0 | 0 | 0 |
I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a variety of complicated reasons, this fall is the only time I can learn both languages. Please advise.
GillingsT
Update:
A little more detail about myself: as I said I did a PhD in Molecular Genetic. I now wish to be able to obtain programming skills so that I can apply it to do bioinformatics- like sequence manipulation and pathway analysis. I was told that Python is great for that but our course does not cover basics for beginners. I approached a Comp Sci Prof. who suggested that I learn C++ first before learning Python. So I got into this dilemma (added to other logistics).
| 0 |
c++,python
|
2010-08-05T15:29:00.000
| 0 | 3,416,342 |
I think you pretty much answered this question yourself:
I was told that Python is great for that but our course does not cover basics for beginners.
In other words, the Python course is not an introductory course -- it assumes you already know how the basics of programming. That's probably why the professor suggested you take the C++ course first.
| 0 | 4,081 | false | 0 | 1 |
C++ and python simultaneously. Is it doable
| 3,648,838 |
2 | 3 | 0 | 0 | 2 | 0 | 0 | 0 |
I have the following problem: I have a local .zip file and a .zip file located on a server. I need to check if the .zip file on the server is different from the local one; if they are not I need to pull the new one from the server. My question is how do I compare them without downloading the file from the server and comparing them locally?
I could create an MD5 hash for the zip file on the server when creating the .zip file and then compare it with the MD5 of my local .zip file, but is there a simpler way?
| 0 |
python,comparison,md5
|
2010-08-06T11:58:00.000
| 0 | 3,423,510 |
You can log in using ssh and make a md5 hash for the file remotely and a md5 hash for the current local file. If the md5s are matching the files are identicaly, else they are different.
| 0 | 4,055 | false | 0 | 1 |
Comparing local file with remote file
| 3,423,577 |
2 | 3 | 0 | 0 | 2 | 0 | 0 | 0 |
I have the following problem: I have a local .zip file and a .zip file located on a server. I need to check if the .zip file on the server is different from the local one; if they are not I need to pull the new one from the server. My question is how do I compare them without downloading the file from the server and comparing them locally?
I could create an MD5 hash for the zip file on the server when creating the .zip file and then compare it with the MD5 of my local .zip file, but is there a simpler way?
| 0 |
python,comparison,md5
|
2010-08-06T11:58:00.000
| 0 | 3,423,510 |
I would like to know how you intend to compare them locally, if it were the case. You can apply the same logic to compare them remotely.
| 0 | 4,055 | false | 0 | 1 |
Comparing local file with remote file
| 3,423,559 |
1 | 2 | 0 | 18 | 13 | 1 | 1.2 | 0 |
I am trying to teach myself Python, and I have realized that the only way I really learn stuff is by reading the actual programs. Tutorials/manuals just cause me to feel deeply confused.
It's just my learning style, and I'm like that with everything I've studied (including natural languages -- I've managed to teach myself three of them by just getting into the actual 'flow of it').
Classical music once had the concept of a 'gamut' -- playing the entire range of an instrument in an artful manner. I'm guessing that there may be a few well-written scripts out there that really show off every feature of the language. It doesn't matter what they do, I just want to start studying Python by reading programs themselves.
I remember coming across a similar method years ago when I studied some LISP. It was a book, published by Springer Verlag, consisting solely of AI programs, to be read for their didactic merit.
| 0 |
python
|
2010-08-06T22:29:00.000
| 0 | 3,428,245 |
I would recommend studying the Standard Python Library (all the parts of it that are coded in Python, that is) -- it's not uniformly excellent in elegance, but it sets a pretty high standard. Plus, the study has the extra benefit of making you very familiar with the library itself (an absolutely crucial part of mastering Python), in addition to showing you a lot good to excellent Python style code;-).
Edit: I have to point out (or my wife and co-author Anna has threatened to not cook the yummy steak I see waiting;-) that the Python Cookbook, 2nd printed edition, also has a lot of code examples, in the best style Anna and I could make them, and with substantial discussion of style variations and alternatives. However, it's stuck back in time to the days of Python 2.4 (sorry, no time to do a third edition for now...), and that's a real block for some people (though I think that having learned good Python 2.4 style, moving to good 2.7 or 3.1 style is really an "incremental" matter, that's definitely a subjective opinion). "Declaring my interest": Anna and I still get some royalties if you buy the book, and, more importantly, the Python Software Foundation (near and dear to both our hearts -- our Prius's vanity license plate reads "P♥THON"...!-) gets more -- so obviously we're biased in the book's favor;-). If you don't want to spend money, you can read some parts of the book online and for free on Google Books (O'Reilly gets to pick and choose which parts are thus freely readable, so please don't complain to me [[or Anna]] about those choices...!-).
I wish I could recommend the online edition of the Cookbook, which does have recipes that are very recent as well as the classic old ones among which we picked and chose most of the printed edition's ones -- but, unfortunately, there are lots of style issues with too many of the online recipes to recommend them collectively as "good style examples" (and that goes for the good recipes too: most of the recipes we picked for the book, we also heavily edited to improve style (and readability, and performance, but those often go hand-in-hand with Python).
| 0 | 2,872 | true | 0 | 1 |
Elegant Python?
| 3,428,288 |
1 | 2 | 0 | 3 | 4 | 0 | 1.2 | 0 |
I use Eclipse for programming in PHP (PDT), Python and sometimes Android. Each of this programming languages requires to run many things after Eclipse start.
Of course I do not use all of them at one moment, I have different workspace for each of those. Is there any way, or recommendation, how to make Eclipse to run only neccessary tools when opening defined workspace?
e.g.:
I choose /workspace/www/, so then only PDT tools will run
I choose /workspace/android/, so then only Android tools and buttons in toolbars will appears
Do I have to manually remove all unneccessary things from each of the workspace? Or it is either possible to remove all?
| 0 |
python,android,eclipse,workspace,eclipse-pdt
|
2010-08-07T09:23:00.000
| 0 | 3,429,887 |
The plug-ins are stored in the Eclipse installation, not in the workspace folder. So one solution would be to different Eclipse installations for every task, in this case only the required plug-ins would load (and the others not available), on the other hand, you have to maintain at least three parallel Eclipse installations.
Another solution is to disable plug-in activation on startup: in Preferences/General/Startup and Shutdown you can disable single plug-ins not loading. The problem with this approach is, that this only helps to not load plug-ins, but its menu and toolbar contributions will be loaded.
| 0 | 741 | true | 1 | 1 |
How to organize Eclipse - Workspace VS Programming languages
| 3,430,003 |
3 | 4 | 0 | 1 | 4 | 1 | 1.2 | 0 |
Suppose you have a MD5 hash encoded in base64. Then each
character needs only 6 bits to store each character in the
resultant 22-byte string (excluding the ending '=='). Thus, each
base64 md5 hash can shrink down to 6*22 = 132 bits, which
requires 25% less memory space compared to the original 8*22=176
bits string.
Is there any Python module or function that lets you store base64
data in the way described above?
| 0 |
python,algorithm,data-structures,md5,base64
|
2010-08-07T10:08:00.000
| 0 | 3,430,016 |
David gave an answer that works on all base64 strings.
Just use base64.decodestring in base64 module. That is,
import base64
binary = base64.decodestring(base64_string)
is a more memory efficient representation of the original base64 string. If you
are truncating trailing '==' in your base64 md5, use it like
base64.decodestring(md5+'==')
| 0 | 1,820 | true | 0 | 1 |
Most memory-efficient way of holding base64 data in Python?
| 3,452,248 |
3 | 4 | 0 | 4 | 4 | 1 | 0.197375 | 0 |
Suppose you have a MD5 hash encoded in base64. Then each
character needs only 6 bits to store each character in the
resultant 22-byte string (excluding the ending '=='). Thus, each
base64 md5 hash can shrink down to 6*22 = 132 bits, which
requires 25% less memory space compared to the original 8*22=176
bits string.
Is there any Python module or function that lets you store base64
data in the way described above?
| 0 |
python,algorithm,data-structures,md5,base64
|
2010-08-07T10:08:00.000
| 0 | 3,430,016 |
"store base64 data"
Don't.
Do. Not. Store. Base64. Data.
Base64 is built by encoding something to make it bigger.
Store the original something. Never store the base64 encoding of something.
| 0 | 1,820 | false | 0 | 1 |
Most memory-efficient way of holding base64 data in Python?
| 3,430,256 |
3 | 4 | 0 | 8 | 4 | 1 | 1 | 0 |
Suppose you have a MD5 hash encoded in base64. Then each
character needs only 6 bits to store each character in the
resultant 22-byte string (excluding the ending '=='). Thus, each
base64 md5 hash can shrink down to 6*22 = 132 bits, which
requires 25% less memory space compared to the original 8*22=176
bits string.
Is there any Python module or function that lets you store base64
data in the way described above?
| 0 |
python,algorithm,data-structures,md5,base64
|
2010-08-07T10:08:00.000
| 0 | 3,430,016 |
The most efficient way to store base64 encoded data is to decode it and store it as binary. base64 is a transport encoding - there's no sense in storing data in it, especially in memory, unless you have a compelling reason otherwise.
Also, nitpick: The output of a hash function is not a hex string - that's just a common representation. The output of a hash function is some number of bytes of binary data. If you're using the md5, sha, or hashlib modules, for example, you don't need to encode it as anything in the first place - just call .digest() instead of .hexdigest() on the hash object.
| 0 | 1,820 | false | 0 | 1 |
Most memory-efficient way of holding base64 data in Python?
| 3,430,100 |
2 | 3 | 0 | 9 | 9 | 0 | 1 | 0 |
I created a module in Python which provides about a dozen functionalities. While it will be mostly used from within Python, there is a good fraction of legacy users which will be calling it from Perl.
What is the best way to make a plug in to this module? My thoughts are:
Provide the functionalities as command line utilities and make system calls
Create some sort of server and handle RPC calls (say, via JSON RPC)
Any advise?
| 0 |
python,perl,interop
|
2010-08-09T15:50:00.000
| 1 | 3,441,766 |
In the short run the easiest solution is to use Inline::Python. Closely followed by calling a command-line script.
In the long run, using a server to provide RPC functionality or simply calling a command-line script will give you the most future proof solution.
Why?
Becuase that way you aren't tied to Perl or Python as the language used to build the systems that consume the services provided by your library. Either method creates a clear, language independent interface that you can use with whatever development environment you adopt.
Depending on your needs any of the presented options may be the "best choice". Depending on how your needs evolve over time, a different choice may be revealed as "best".
My approach to this would be to ask a couple of questions:
How often do you change development tools. You've switched to Python from Perl. Did you start with Tcl and go to Perl? Are you going to switch to the exciting new language X in 1, 5 or 10 years? If you change tools 'often' (whatever that means) emphasize cross tool compatibility.
How fast is fast enough? Is the start up time for command line solutions ok? Does Inline::Python slow things down too much (you are still initializing a Python interpreter, it's just embedded in your Perl interpreter)?
Based on the answers to these questions, I would do the simplest thing that is likely to work.
My guess is that means in order:
Inline::Python
Command line scripts
Build an RPC server
| 0 | 9,275 | false | 0 | 1 |
Calling a Python module from Perl
| 3,446,205 |
2 | 3 | 0 | 3 | 9 | 0 | 0.197375 | 0 |
I created a module in Python which provides about a dozen functionalities. While it will be mostly used from within Python, there is a good fraction of legacy users which will be calling it from Perl.
What is the best way to make a plug in to this module? My thoughts are:
Provide the functionalities as command line utilities and make system calls
Create some sort of server and handle RPC calls (say, via JSON RPC)
Any advise?
| 0 |
python,perl,interop
|
2010-08-09T15:50:00.000
| 1 | 3,441,766 |
Provide the functionalities as command line utilities and make system calls
Works really nicely. This is the way programs like Python (and Perl) are meant to use used.
| 0 | 9,275 | false | 0 | 1 |
Calling a Python module from Perl
| 3,441,920 |
3 | 5 | 0 | 0 | 7 | 1 | 0 | 0 |
Can I call a test method from within the test class in python? For example:
class Test(unittest.TestCase):
def setUp(self):
#do stuff
def test1(self):
self.test2()
def test2(self):
#do stuff
update: I forgot the other half of my question. Will setup or teardown be called only after the method that the tester calls? Or will it get called between test1 entering and after calling test2 from test1?
| 0 |
python,unit-testing
|
2010-08-09T22:59:00.000
| 0 | 3,444,827 |
Yes to both:
setUp will be called between each test
test2 will be called twice.
If you would like to call a function inside a test, then omit the test prefix.
| 0 | 3,578 | false | 0 | 1 |
python unittest methods
| 3,444,963 |
3 | 5 | 0 | 1 | 7 | 1 | 0.039979 | 0 |
Can I call a test method from within the test class in python? For example:
class Test(unittest.TestCase):
def setUp(self):
#do stuff
def test1(self):
self.test2()
def test2(self):
#do stuff
update: I forgot the other half of my question. Will setup or teardown be called only after the method that the tester calls? Or will it get called between test1 entering and after calling test2 from test1?
| 0 |
python,unit-testing
|
2010-08-09T22:59:00.000
| 0 | 3,444,827 |
All methods whose name begins with the string 'test' are considered unit tests (i.e. they get run when you call unittest.main()). So you can call methods from within the Test class, but you should name it something that does not start with the string 'test' unless you want it to be also run as a unit test.
| 0 | 3,578 | false | 0 | 1 |
python unittest methods
| 3,444,872 |
3 | 5 | 0 | 0 | 7 | 1 | 0 | 0 |
Can I call a test method from within the test class in python? For example:
class Test(unittest.TestCase):
def setUp(self):
#do stuff
def test1(self):
self.test2()
def test2(self):
#do stuff
update: I forgot the other half of my question. Will setup or teardown be called only after the method that the tester calls? Or will it get called between test1 entering and after calling test2 from test1?
| 0 |
python,unit-testing
|
2010-08-09T22:59:00.000
| 0 | 3,444,827 |
sure, why not -- however that means test2 will be called twice -- once by test1 and then again as its own test, since all functions named test will be called.
| 0 | 3,578 | false | 0 | 1 |
python unittest methods
| 3,444,874 |
1 | 1 | 0 | 1 | 0 | 0 | 1.2 | 0 |
I'm considering moving from PHP to Python (for personal projects), and I really don't like seeing /cgi-bin/ in my URL.
I got the Python to execute outside of cgi-bin, but I just wanted to make sure there were no possible security issues that could pop up, and that there were no major impacts on the speed.
So are there any major issues I need to be aware of?
Thanks in advance for any help.
| 0 |
python,cgi,cgi-bin
|
2010-08-10T18:55:00.000
| 0 | 3,452,388 |
Being as how it's nominally just a URL, there aren't any impacts on speed per-se. However, it is standard practice, just like it's standard practice to make the entry page to a website index.html, but it's not required by any stretch (as evidenced by default.aspx, home.php, etc)
I would change it as a security through obscurity reference myself, were I inclined to change those things on my system.
While you won't incur any Apache security issues, there may be issues with server-side code or hard-coded modules that don't query for path, and assume code is running from cgi-bin ... just something to consider.
| 0 | 313 | true | 0 | 1 |
Running CGI outside of cgi-bin. Good idea?
| 3,452,427 |
1 | 3 | 0 | 6 | 1 | 1 | 1 | 0 |
I'm learning Python (and it's my first programming language so don't be too intense with your reasons) and I wanted to know how it stacks up to other scripting languages, like Perl and Ruby. What is Python better in comparison to other scripting languages, and what is it worse for?
| 0 |
python,ruby,perl,comparison
|
2010-08-10T19:35:00.000
| 0 | 3,452,729 |
I'm learning Python (and it's my first programming language so don't be too intense with your reasons) and I wanted to know how it stacks up to other scripting languages, like Perl and Ruby. What is Python better in comparison to other scripting languages, and what is it worse for?
IMO.
I have tried Python 2.x for some time and went back to the Perl and C++.
What is good about Python. Python features better portability and has modern GUI libraries. Standard library in some places is also very very nice (I esp. liked random). Execution speed of arithmetic expressions beats that of Perl.
What is bad about Python. Poor documentation. No warnings, no typing whatsoever combined with weak typing/language's dynamic nature is a hell. Learning easy - using hard, mainly due to immature optimizer driving the need to think about performance edge cases quite early in the development cycle. (That some times reminded me of the Pascal.) OO is a mess at the moment: distinct features and differences between old-style and new-style classes are not spelled out very well; libraries do not mention what type of classes they do define.
Poor documentation probably should be highlighted. There are piles of standard functions but their purpose in life isn't really specified nor decent examples are given. And better half of those standard functions in Perl land would have been sitting somewhere in the perldoc perlguts. Anyhow, looking up stuff is much faster with Google.
Lack of warnings and lack of typing (and that compared to the weak Perl's use warnings/use strict and sub prototypes) is what in the end drove me back. Partially it is because that I write code faster than I can read it thus I like to rely on the compiler/interpreter to tell me where I might have wrote something I haven't really meant.
Also excuse me, but I would throw that at Python again: using indentation to denote code structure is kind'a kinky. I do not mind it per se and for short functions it is very nice. But after one week I have found that I do read Python code slower (compared to C++ or Perl) in greater part because I have to always extra check whether the statement really closed or it still goes on. If code doesn't fit one screen, it becomes a chore to always press PgDown/PgUp just to check. Never before I were that appreciative of the {}s.
All considered, Python is at the moment a mess. Worthy contender I do keep an eye on, but not mature enough for my daily needs. If I were making decision about learning Python now, I would have instead waited for Python 3.x to mature. Many things one would learn now with Python 2.x might be useless in Python 3.x. And Python 3.x is at the moment isn't very useful since many libraries were not yet ported to it.
P.S. Most bogus part I have encountered is the function pointers. I have discovered them sooner than I needed them by writing start_time = time.time and time_elapsed = time.time() - start_time. Half hour later when script finished instead of results I was presented with nice interpreter exception telling me that I cannot subtract function object. And the half hour was due to the standard for loop, as tutorials have taught me. Optimizations I have looked up later (range vs. xrange, manual loop unrolling) made the script run in less than one minute.
| 0 | 1,331 | false | 0 | 1 |
How does Python stack up to other scripting languages?
| 3,454,618 |
1 | 4 | 0 | 0 | 4 | 0 | 0 | 0 |
is this possible to view contents and Functions of a DLL file...
few times ago i was playing with OlyDBG then i found there is option for viewing contents of dll...
so suggest me any good tool or soft for this...
and suppose i have a DLL named "Python27.dll"...
now i need to view the content of this DLL so what do i do...
thanx...
| 0 |
c#,python,c,dll,import
|
2010-08-11T01:17:00.000
| 1 | 3,454,647 |
I've done some work with ctypes, and loading dlls in windows, but I don't think DLL have any sort of introspection. This really isn't a big deal, because all of the function calls in DLLs are static. If your trying to use a undocumented DLL, you would not only need to know the names of the functions, but also the parameters of the functions. You would have to reverse engineer the DLL, no small task.
So, in my opinion, I would say no.
| 0 | 3,117 | false | 0 | 1 |
Viewing Contents Of a DLL File
| 3,454,709 |
2 | 3 | 0 | 0 | 3 | 1 | 0 | 0 |
I have a web service that is required to handle significant concurrent utilization and volume and I need to test it. Since the service is fairly specialized, it does not lend itself well to a typical testing framework. The test would need to simulate multiple clients concurrently posting to a URL, parsing the resulting Http response, checking that a database has been appropriately updated and making sure certain emails have been correctly sent/received.
The current opinion at my company is that I should write this framework using Python. I have never used Python with multiple threads before and as I was doing my research I came across the Global Interpreter Lock which seems to be the basis of most of Python's concurrency handling. It seems to me that the GIL would prevent Python from being able to achieve true concurrency even on a multi-processor machine. Is this true? Does this scenario change if I use a compiler to compile Python to native code? Am I just barking up the wrong tree entirely and is Python the wrong tool for this job?
| 0 |
python
|
2010-08-11T12:36:00.000
| 0 | 3,458,249 |
Assuming general network conditions, as long you have sufficient system resources Python's regular threading module will allow you to simulate concurrent workload at an higher rate than any a real workload.
| 0 | 1,336 | false | 0 | 1 |
Concurrency Testing For A Web Service Using Python
| 3,458,457 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.