Available Count
int64 1
31
| AnswerCount
int64 1
35
| GUI and Desktop Applications
int64 0
1
| Users Score
int64 -17
588
| Q_Score
int64 0
6.79k
| Python Basics and Environment
int64 0
1
| Score
float64 -1
1.2
| Networking and APIs
int64 0
1
| Question
stringlengths 15
7.24k
| Database and SQL
int64 0
1
| Tags
stringlengths 6
76
| CreationDate
stringlengths 23
23
| System Administration and DevOps
int64 0
1
| Q_Id
int64 469
38.2M
| Answer
stringlengths 15
7k
| Data Science and Machine Learning
int64 0
1
| ViewCount
int64 13
1.88M
| is_accepted
bool 2
classes | Web Development
int64 0
1
| Other
int64 1
1
| Title
stringlengths 15
142
| A_Id
int64 518
72.2M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 2 | 0 | 0 | 2 | 0 | 0 | 0 | What's are some ways of testing complex data types such as video, images, music, etc. I'm using TDD and wonder are there alternatives to "gold file" testing for rendering algorithms. I understand that there's ways to test other parts of the program that don't render and using those results you can infer. However, I'm particularly interested in rendering algorithms specifically image/video testing.
The question came up while I was using OpenCV/Python to do some basic facial recognition and want to verify its correctness.
Even if there's nothing definitive any suggestion will help. | 0 | python,image,testing,opencv | 2009-11-19T08:05:00.000 | 0 | 1,761,663 | What's wrong with the "gold file" technique? It's part of your test fixture. Every test has a data fixture that's the equivalent to the "gold file" in a media-intensive application.
When doing ordinary TDD of ordinary business applications, one often has a golden database fixture that must be used.
Even when testing simple functions and core classes of an application, the setUp method creates a kind of "gold file" fixture for that class or function.
What's wrong with that technique? Please update your question with the specific problems you're having. | 0 | 229 | false | 0 | 1 | Testing complex datatypes? | 1,762,591 |
1 | 1 | 0 | 2 | 5 | 0 | 1.2 | 0 | I'm working with pysvn, and I'm trying to find a decent way to handle repositories that are only accessible via svn+ssh. Obviously SSH keys make this all incredibly easy, but I can't guarantee the end user will be using an SSH key. This also has to be able to run without user interaction, because it's going to be doing some svn log parsing.
The big issue is that, with svn+ssh an interactive prompt is popped up for authentication. Obviously I'd like to be able to have pysvn automatically login with a set of given credentials, but set_default_username and set_default_password aren't doing me any good in that respect. If I can't have that, I'd at least like to able to just fail out, and log a message to tell the user to setup an SSH key. However, set_interactive seems to have no bearing on this either, and I'm still prompted for a password with client.log('svn+ssh://path').
Any thoughts on how to tackle this issue? Is it even really possible to handle this without SSH keys, since it's SSH that's throwing the prompts? | 0 | python,svn,ssh,pysvn | 2009-11-20T17:41:00.000 | 0 | 1,772,133 | Check out ssh configuration option PasswordAuthentication.
I'm not sure how pysvn interacts with ssh, but if you set this to no in your ~/.ssh/config (or maybe global config?) then it shouldn't prompt for a password. | 0 | 1,664 | true | 0 | 1 | pysvn with svn+ssh | 1,773,231 |
10 | 13 | 0 | 0 | 20 | 1 | 0 | 0 | For someone who’s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others.
Personally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.)
What are the good things about Python that developers love? Stuff that’ll excite me more than C#. | 0 | c#,python,programming-languages | 2009-11-20T20:30:00.000 | 0 | 1,773,063 | Don't get me wrong, I am and will always be a devoted fan of C#.
But sometimes there are things I can't do in C#. lthough C# keeps reducing those gaps, Python is still the language I go to to fill them.
It's dynamic, flexible, powerful, and clean. Lovely language. Whenever I need to script or build dynamic or functional (as in functional programming) software, I go Python. | 0 | 3,108 | false | 0 | 1 | What Python features will excite the interest of a C# developer? | 1,773,322 |
10 | 13 | 0 | 1 | 20 | 1 | 0.015383 | 0 | For someone who’s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others.
Personally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.)
What are the good things about Python that developers love? Stuff that’ll excite me more than C#. | 0 | c#,python,programming-languages | 2009-11-20T20:30:00.000 | 0 | 1,773,063 | Like any programming language, it is just a tool in the box or a brush by which you may paint your creation. Any creative endeavour requires that the artist loves the tools he uses; otherwise, the outcome suffers. Some people like Python for the same reason others love Perl. Incidentally, I have found that most Python lovers loathe Perl's flexible and expressive syntax. As a Perl lover, I don't hate Python, but consider it to be overly structured and restrictive.
If you ask me, all of these throngs of people who seem to love Python were silently suffering under the tool choices before Python came into being. Some suffered under Perl, others under something else. In other words, I believe that when Python came along, it found a large group of silent sufferers longing for a tool like Python.
I can't program in Python because I can't "think" in Python. I can "think" in Perl, therefore, it is the tool I prefer. The silently suffering mass of, now, Python users seem to have found some long lost salvation. Now if they could only keep their evangelism to themselves :). | 0 | 3,108 | false | 0 | 1 | What Python features will excite the interest of a C# developer? | 1,773,317 |
10 | 13 | 0 | 11 | 20 | 1 | 1 | 0 | For someone who’s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others.
Personally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.)
What are the good things about Python that developers love? Stuff that’ll excite me more than C#. | 0 | c#,python,programming-languages | 2009-11-20T20:30:00.000 | 0 | 1,773,063 | I'm a very heavy user of both C# and Python; I've built very complicated applications in both languages, and I've also embedded Python scripting in my major C# application. I'm not using either to do much in the way of web work right now, but other than that I feel like I'm pretty qualified to answer the question.
The things about Python that excite me, in particular:
The deep integration of generators into the language. This was the first thing that made me realize that I needed to take a long, serious look at Python. My appreciation for this has deepened considerably since I've become conversant with the itertools module, which looks like a nifty set of tools but is in fact a new way of life.
The coupling of dynamic typing and the fact that everything's an object makes pretty sophisticated techniques extremely simple to implement. It's so easy to replace logic with tables in Python (e.g. o = class_map[k]() instead of if k='foo': o = Foo()) that it becomes a basic technique. It's so normal in Python to write methods that take methods as parameters that you don't raise an eyebrow when you see d = defaultdict(list).
zip, and the methods that are designed with it in mind. It takes a while before you can intuitively grasp what dict(zip(k, v)) and d.update(zip(k, v)) are doing, but it's a paradigm-shifting moment when you get there. An entire universe of uninteresting and potentially error-laden code eliminated, just by using one function. Then you start designing functions and classes with the expectation that they'll be used in conjunction with zip, and suddenly your code gets simpler and easier. (Protip: Or itertools.izip. Or itertools.izip_longest.)
Speaking of dictionaries, the way that they're deeply integrated into the language. Understanding what a line of code like self.__dict__.update(**kwargs) does is another one of those paradigm-shifting moments.
List comprehensions and generator expressions, of course.
Inexpensive exceptions.
An interactive intepreter.
Function decorators.
IronPython, which is so much simpler to use than we have any right to expect.
And that's without even getting into the remarkable array of functionality in the standard modules, or the ridiculous bounty of third-party tools like BeautifulSoup or SQL Alchemy or Pylons.
One of the most direct benefits that I've gotten from getting deeply into Python is that it has greatly improved my C# code. I could generally understand code that had a variable of type Dictionary<string, Action<Foo>> in it, but it didn't seem natural to write it. (I use static dictionaries to replace hard-coded logic far more frequently today than I did a year ago.) I have no difficulty understanding what LINQ is doing now, or how IEnumerable<T> and return yield work.
So what don't I like about Python?
Dynamic typing really limits what you can do with static code analysis. Not only isn't there a tool like Resharper for Python, in a language where it's possible to write getattr(x, y)() there really can't be.
It has a bunch of inelegant conventions. How I would love to be able to go back in time and try to talk GVR out of the idea that lambda expressions should be introduced with the word lambda - it's pretty damning that something as fundamental as lambda expressions should be more concise in C# than they are in Python. The leading and trailing double-underscore convention is horrible, and the fact that people mutely acquiesce to it is testimony to Dostoevsky's observation that man is the animal who can get used to anything. And don't get me started on the fact that a module with the name of StringIO was allowed to get out the door.
Some of the features that make Python work on multiple platforms also make it kind of baffling. It's easy to use import, but it's really not easy to understand what the hell it's actually doing. (Where is it looking? What does __init__.py do? Etc.)
The amazingly rich library of standard modules is so amazingly rich that it's hard to know what's in it. It's often easier to write a function than it is to find out whether or not there's something in the standard library that does the same thing - I'm looking at you, itertools.chain. | 0 | 3,108 | false | 0 | 1 | What Python features will excite the interest of a C# developer? | 1,773,987 |
10 | 13 | 0 | 10 | 20 | 1 | 1 | 0 | For someone who’s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others.
Personally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.)
What are the good things about Python that developers love? Stuff that’ll excite me more than C#. | 0 | c#,python,programming-languages | 2009-11-20T20:30:00.000 | 0 | 1,773,063 | Your question is kind of like a plumber asking why carpenters are always going on and on about hammers. After all the plumber doesn't have a hammer and has never missed it. Python (even IronPython) and C# target different types of developers and different types of programs. I am very comfortable in Python and enjoy the freedom to focus on the business rules without being distracted by the syntax requirements of the language. On the other hand I have written some fairly substantial code in C# and would be very concerned about the lack of type safety had I taken on the same task in Python. This is not to say that Python is a "toy" language. You can (and people have) write a complete medium or large application in Python. You have the freedom of dynamic typing, but you also have the responsibility to keep it all straight (frameworks help here). Similarly you can write a small application in C#, but you will bring along some overhead you do not likely need.
So if the problem is a nail use a hammer, if the problem is a screw use a screw driver. In other words spend some time to learn Python, get to know it's streangths (text processing, quick coding cycles, simple clean code, etc) and then when you are looking at tackling a new problem ask whether you would be better off in Python or C#. One thing is certain. So long as C# is the only programming language you know, it is the only one you will ever use.
Pat O | 0 | 3,108 | false | 0 | 1 | What Python features will excite the interest of a C# developer? | 1,773,278 |
10 | 13 | 0 | 2 | 20 | 1 | 0.03076 | 0 | For someone who’s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others.
Personally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.)
What are the good things about Python that developers love? Stuff that’ll excite me more than C#. | 0 | c#,python,programming-languages | 2009-11-20T20:30:00.000 | 0 | 1,773,063 | I'm an asymmetrical user of both languages, in a sense that I use C# mostly professionally and Python for all my "fun" projects (not that work is never fun, but... you know...)
This difference of context may skew my perspective, including my opinion that they are two distinct types (pun intended) of languages for, generally, distinct purposes.
This said, it may not be a coincidence that Python is, at this point in time, [one of?] the languages of choice for all kinds of cutting edge, somewhat scholarly, technology/science oriented projects. (And BTW, this "scholarly" keyword here doesNOT imply, that Python is a university toy, plenty of "serious" applications in plenty of domains/industry are proof to the contrary). This may be due to several factors:
(I don't develop most points, readily well expressed in other responses)
the openness and quasi universal availability of Python (unlike C# !)
the lightweight / ease of use / low learning curve
the extensive, high quality, "standard" library and the extensiver (and occasionally bum quality, but on the whole available, open-sourced, etc.) additional library.
the wide array of open source projects in Python language
the relative ease to bind with C/C++ for reusing legacy code, but also for placing performance-critical portions of a project
the generally higher level of abstraction of may constructs of the language
the multi-paradigms (imperative, object oriented and functional)
the availability of practitioners in so many domain of science and technology
and, yes, the
"herd mentality effect" mentioned in a remark, possibly in a [self?] deriding way. The fact that a language attracts a broad, "closely knit" community, makes it attractive too, beyond the superficial ("look cool" and such) traits of herd mentality. Put in broader context, sometimes the best technology/language to use is not measured on the its intrinsic merits but on the overall "picture", including the user community. | 0 | 3,108 | false | 0 | 1 | What Python features will excite the interest of a C# developer? | 1,773,315 |
10 | 13 | 0 | 18 | 20 | 1 | 1 | 0 | For someone who’s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others.
Personally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.)
What are the good things about Python that developers love? Stuff that’ll excite me more than C#. | 0 | c#,python,programming-languages | 2009-11-20T20:30:00.000 | 0 | 1,773,063 | For me its the flexibility and elegance, but there are a handful of things I wish could be pulled in from other languages though (better threading, more robust expressions).
In typical I can write a little bit of code in python and do a lot more than the same amount of lines in many other languages. Also, in python code form is of utmost importance and the syntax lends its self to highly readable, clean looking code. That of course helps out with maintenance.
I love having a command line interpreter that I can quickly prototype an algorithm in rather than having to start up a new project, code, compile, test, repeat. Not to mention the fact I can use it to help me automate my server maintenance as well (I double as a SA for my company).
The last thing that comes to mind immediately is the vast amounts of libraries. There are a lot of things already solved out there, the built-in library has a lot to offer, and the third party ones are many times very good (not always though). | 0 | 3,108 | false | 0 | 1 | What Python features will excite the interest of a C# developer? | 1,773,087 |
10 | 13 | 0 | 15 | 20 | 1 | 1 | 0 | For someone who’s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others.
Personally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.)
What are the good things about Python that developers love? Stuff that’ll excite me more than C#. | 0 | c#,python,programming-languages | 2009-11-20T20:30:00.000 | 0 | 1,773,063 | Being able to type in some code and get the result back immediately.
(Disclaimer: I use both C# and Python regularly, and I think both have their good and bad points.) | 0 | 3,108 | false | 0 | 1 | What Python features will excite the interest of a C# developer? | 1,773,082 |
10 | 13 | 0 | 11 | 20 | 1 | 1.2 | 0 | For someone who’s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others.
Personally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.)
What are the good things about Python that developers love? Stuff that’ll excite me more than C#. | 0 | c#,python,programming-languages | 2009-11-20T20:30:00.000 | 0 | 1,773,063 | I'm primarily .NET developer and using Python for me personal projects.
What are the good things about python that developers love?
I can say for myself - Python is like a breath of fresh air.
1) It's simple to learn, took about a week for me in the evenings. I'm saying about Python + Django. Python syntax is quite simple.
2) It's simple to use. No troubles installing Python + Django on Windows at all.
3) It can be run on Windows and UNIX.
4) I need it for web, so I get cheaper hosting than ASP.NET.
5) All the advantages of Python language over C#. Like tuples - so useful!
The only thing I don't like is that my favorite IDE Visual Studio doesn't support it (I know about IronPython, don't you worry). | 0 | 3,108 | true | 0 | 1 | What Python features will excite the interest of a C# developer? | 1,773,224 |
10 | 13 | 0 | 1 | 20 | 1 | 0.015383 | 0 | For someone who’s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others.
Personally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.)
What are the good things about Python that developers love? Stuff that’ll excite me more than C#. | 0 | c#,python,programming-languages | 2009-11-20T20:30:00.000 | 0 | 1,773,063 | I like all stuff with [] and {}. Selectors like this [-1:1]. Possibility to write less code, but more something meaningfull, that gives to write Models and other declarative things very DRY. | 0 | 3,108 | false | 0 | 1 | What Python features will excite the interest of a C# developer? | 1,773,215 |
10 | 13 | 0 | 0 | 20 | 1 | 0 | 0 | For someone who’s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others.
Personally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.)
What are the good things about Python that developers love? Stuff that’ll excite me more than C#. | 0 | c#,python,programming-languages | 2009-11-20T20:30:00.000 | 0 | 1,773,063 | The main thing I like about Python is its very concise, readable syntax. Though using indentation as a block delimiter can seem strange at first, once you begin to code a lot in the language I find it begins to make sense. Though the core language is quite simple, its more advanced features, e.g. list comprehension, decorators and generators, are rather useful too.
In addition, the Python standard library is just fantastic; its documentation is very well written, and it contains a lot of very useful packages. I also find that there are plenty of good bindings for C libraries, such as PyGTK, Webkit and Qt, to name but a few.
One caveat is that Python, like most dynamic languages, is quite slow in comparison with compiled, statically-typed languages. However, you can easily extend it with C, allowing you to write code requiring better performance in C and the rest in Python.
It's a great language overall, and (for me at least) makes coding more productive and enjoyable. | 0 | 3,108 | false | 0 | 1 | What Python features will excite the interest of a C# developer? | 1,773,312 |
1 | 1 | 1 | 3 | 0 | 1 | 0.53705 | 0 | I have an existing Python 2.4 and it is working properly with tkinter as I tested it using
python
import _tkinter
import Tkinter
Tkinter._test()
Now, I have installed python 2.5.2 but when I try the same tests (with the newer version), it returns (but the same tests are working for the previous version)
ImportError: No module named _tkinter
I know that tcl8.5 and tk8.5 are installed on my machine as the following commands return there locations
whereis tcl
tcl: /usr/lib/tcl8.4 /usr/local/lib/tcl8.5 /usr/local/lib/tcl8.4 /usr/share/tcl8.4
whereis tk
tk: /usr/lib/tk8.4 /usr/local/lib/tk8.5 /usr/share/tk8.4
Any ideas how do I make my newer python version work with tkinter? | 0 | python,tcl,tkinter,tk | 2009-11-20T21:02:00.000 | 0 | 1,773,222 | The files you found are for linking directly to tcl/tk. Python depends on another library as well: _tkinter.so. It should be in /usr/lib/python2.5/lib-dynload/_tkinter.so.
How did you install python2.5? If you are using Debian or Ubuntu you need to install the python-tk package to get Tkinter support.
If the _tkinter.so file is there, your environment could be causing problems.
If
python -E -c "import
Tkinter;Tkinter._test()"
suceeds, but
python -c "import
Tkinter;Tkinter._test()"
fails, then the problem is with how your environment is set up. Check the value of PYTHONPATH is set correctly. | 0 | 1,073 | false | 0 | 1 | Linking Tcl/Tk to Python 2.5 | 1,773,435 |
1 | 3 | 0 | 1 | 5 | 0 | 0.066568 | 0 | How can I import contacts of given email id/pwd from
gmail
yahoo
hotmail
etc
using python/django application. Please suggest? | 0 | python,django | 2009-11-21T08:12:00.000 | 0 | 1,774,915 | Amir Hussain,
Yahoo mail using captcha, so it will not works for any scripts or service unless they have managed service with the help of a third party for captcha decoder. So u have to contact a service provider who provide managed service.
As far as I know, Improsys is the first Address Grabber marketer and they have managed service. They have this tool available for Classic ASP, ASP.Net, .Net, Ruby on Rails, PHP, Cold Fusion, JAVA, JSP and Perl. Microsoft Outlook and Outlook Express.
Actually I am using their service. Their service is satisfactory but the cost is too high. | 0 | 2,955 | false | 1 | 1 | how to import contacts from various services like gmail or yahoo using python/django | 11,819,696 |
1 | 4 | 0 | 4 | 28 | 1 | 0.197375 | 0 | TextMate seems to use the built-in Python version I assume (sys.path doesn't work). How do you configure it to use 3.1 instead? I've already installed the 3.1 package and I can use IDLE for interactive sessions, but I need to use TextMate now.
Thanks | 0 | python,macos,python-3.x,textmate | 2009-11-21T16:34:00.000 | 0 | 1,775,954 | the shebang is the best solution, to see where python 3 is installed type in terminal:
which python3
you will get something like this:
/usr/local/bin/python3
if nothing shows up first install python3
and at the top of your script insert:
#!/usr/local/bin/python3 | 0 | 17,177 | false | 0 | 1 | Using Python 3.1 with TextMate | 7,792,338 |
1 | 3 | 0 | 19 | 14 | 1 | 1 | 0 | Can you delete emails with imaplib? If so how? | 0 | python,email,imap | 2009-11-22T00:13:00.000 | 0 | 1,777,264 | Deleting an email over IMAP is performed in two phases:
mark one or more items for deletion: imap.store(msg_no, '+FLAGS', '\\Deleted')
expunge the mailbox: imap.expunge()
(imap is your IMAP4 object) | 0 | 23,123 | false | 0 | 1 | Using python imaplib to "delete" an email from Gmail? | 1,777,290 |
3 | 4 | 0 | 2 | 5 | 1 | 1.2 | 0 | One of my Python scripts runs in interactive mode but fails when run from the command line. The difference is that when run from the command line, it imports modules from a bad .egg file, and when run interactively it uses my fixed (unzipped) version in the current directory.
My question is two-fold: a) why does Python load modules differently when run from these locations, and b) what are my options to work around it? | 0 | python,interactive,egg,non-interactive | 2009-11-22T02:51:00.000 | 0 | 1,777,671 | I don't understand what do you mean by running script in interactive mode, so I can't say exactly. But the first place to look for modules (sys.path[0]) in interactive mode is current directory (even calling os.chdir() will affect imports), while for script it's directory where the script is located (derived from sys.argv[0]). Note that they are effectively the same when script is run from directory where it's located, but could be different in other cases. Hope this helps. | 0 | 2,052 | true | 0 | 1 | Python importing modules differently when run interactively/non-interactively | 1,777,968 |
3 | 4 | 0 | 2 | 5 | 1 | 0.099668 | 0 | One of my Python scripts runs in interactive mode but fails when run from the command line. The difference is that when run from the command line, it imports modules from a bad .egg file, and when run interactively it uses my fixed (unzipped) version in the current directory.
My question is two-fold: a) why does Python load modules differently when run from these locations, and b) what are my options to work around it? | 0 | python,interactive,egg,non-interactive | 2009-11-22T02:51:00.000 | 0 | 1,777,671 | On UNIX systems and Mac OS-X:
Do you have a ~/.python-eggs directory?
OS independent:
Are you sure that you use the same Python instance in both cases?
Can you print sys.path in each cases and see which package directory comes first on your module search path? | 0 | 2,052 | false | 0 | 1 | Python importing modules differently when run interactively/non-interactively | 1,777,700 |
3 | 4 | 0 | 1 | 5 | 1 | 0.049958 | 0 | One of my Python scripts runs in interactive mode but fails when run from the command line. The difference is that when run from the command line, it imports modules from a bad .egg file, and when run interactively it uses my fixed (unzipped) version in the current directory.
My question is two-fold: a) why does Python load modules differently when run from these locations, and b) what are my options to work around it? | 0 | python,interactive,egg,non-interactive | 2009-11-22T02:51:00.000 | 0 | 1,777,671 | a) why does Python load modules differently when run from these locations
b) what are my options to work around it?
Check your environment variable PYTHONPATH. When python imports module, it searches those directories. One way to get around your problem is to add your local folder "the (unzipped) version in the current directory" to the beginning of PYTHONPATH so that python will find it first. | 0 | 2,052 | false | 0 | 1 | Python importing modules differently when run interactively/non-interactively | 1,778,097 |
1 | 5 | 0 | 0 | 0 | 1 | 0 | 0 | Just curious. If you had the time and inclination to create a programming language, what characteristics would it have?
One language I would like to see would borrow as much from the syntax of Python as possible but compile to machine code that runs as fast as C or C++. | 0 | python,c++ | 2009-11-22T09:39:00.000 | 0 | 1,778,278 | It should be fast and lightweight (not like the .NET Framework), but you should still be able to create fully functional and flexible GUI apps. | 0 | 340 | false | 0 | 1 | If you had the time and inclination to create a programming language, what characteristics would it have? | 1,778,322 |
1 | 2 | 0 | 47 | 43 | 1 | 1.2 | 0 | What are the main differences between Python metaclasses and class decorators? Is there something I can do with one but not with the other? | 0 | python,decorator,metaclass | 2009-11-22T17:39:00.000 | 0 | 1,779,372 | Decorators are much, much simpler and more limited -- and therefore should be preferred whenever the desired effect can be achieved with either a metaclass or a class decorator.
Anything you can do with a class decorator, you can of course do with a custom metaclass (just apply the functionality of the "decorator function", i.e., the one that takes a class object and modifies it, in the course of the metaclass's __new__ or __init__ that make the class object!-).
There are many things you can do in a custom metaclass but not in a decorator (unless the decorator internally generates and applies a custom metaclass, of course -- but that's cheating;-)... and even then, in Python 3, there are things you can only do with a custom metaclass, not after the fact... but that's a pretty advanced sub-niche of your question, so let me give simpler examples).
For example, suppose you want to make a class object X such that print X (or in Python 3 print(X) of course;-) displays peekaboo!. You cannot possibly do that without a custom metaclass, because the metaclass's override of __str__ is the crucial actor here, i.e., you need a def __str__(cls): return "peekaboo!" in the custom metaclass of class X.
The same applies to all magic methods, i.e., to all kinds of operations as applied to the class object itself (as opposed to, ones applied to its instances, which use magic methods as defined in the class -- operations on the class object itself use magic methods as defined in the metaclass). | 0 | 8,667 | true | 0 | 1 | Python metaclasses vs class decorators | 1,779,404 |
1 | 6 | 0 | 2 | 2 | 0 | 0.066568 | 0 | First, a disclaimer. I'm not a CS grad nor a math major, so simplicity is important.
I have a four-character string (e.g. "isoy") that I need to pass as a single 32-bit integer field. Of course at the other end, I need to decode it back to a string. The string will only contain A-Z, and case is not important, if that helps.
The funny part is that I'm starting with PowerShell on the sending end and Linux at the receiving end. I can use Perl or Python there, with a preference for Python. I don't actually need answers in each language, I'm most interested in a PowerShell (C# also good) example for going both ways. | 0 | c#,python,algorithm,powershell | 2009-11-23T03:09:00.000 | 0 | 1,780,922 | Please take a look at the struct standard library module in Python's Manual. It has two functions for this: struct.pack and struct.unpack. You can use the 'L' (unsigned long) format character for this. | 0 | 3,087 | false | 0 | 1 | How do I encode a 4-byte string as a single 32-bit integer? | 1,780,938 |
1 | 3 | 0 | 2 | 1 | 0 | 0.132549 | 0 | I'm just starting out with Python and have practiced so far in the IDLE interface. Now I'd like to configure Python with MAMP so I can start creating really basic webapps — using Python inside HTML, or well, vice-versa. (I'm assuming HTML is allowed in Python, just like PHP? If not, are there any modules/template engines for that?)
What modules do I need to install to run .py from my localhost? Googling a bit, it seems there're various methods — mod_python, FastCGI etc.. which one should I use and how to install it with MAMP Pro 1.8.2?
Many thanks | 0 | python,html,web-applications,fastcgi,template-engine | 2009-11-23T06:28:00.000 | 0 | 1,781,431 | You asked whether HTML is allowed within Python, which indicates that you still think too much in PHP terms about it. Contrary to PHP, Python was not designed to create dynamic web-pages. Instead, it was designed as a stand-alone, general-purpose programming language. Therefore you will not be able to put HTML into Python. There are some templating libraries which allow you to go the other way around, somewhat, but that's a completely different issue.
With things like Django or TurboGears or all the other web-frameworks, you essentially set up a small, stand-alone web-server (which comes bundled with the framework so you don't have to do anything), tell the server which function should handle what URL and then write those functions. In the simplest case, each URL you specify has its own function.
That 'handler function' (or 'view function' in Django terminology) receives a request object in which interesting info about the just-received request is contained. It then does whatever processing is required (a DB query for example). Finally, it produces some output, which is returned to the client. A typical way to get the output is to have some data passed to a template where it is rendered together with some HTML.
So, the HTML is separated in a template (in the typical case) and is not in the Python code.
About Python 3: I think you will find that the vast majority of all Python development going on in the world is still with Python 2.*. As others have pointed out here, Python 3 is just coming out, most of the good stuff is not available for it yet, and you shouldn't be bothered about that.
My advise: Grab yourself Python 2.6 and Django 1.1 and dive in. It's fun. | 0 | 756 | false | 1 | 1 | Python for web scripting | 1,784,843 |
8 | 11 | 0 | 41 | 12 | 1 | 1.2 | 0 | I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn.
So I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead?
What can C++ do and Python can't ? | 0 | c++,python | 2009-11-24T19:26:00.000 | 0 | 1,792,360 | Some Python limits :
- Python is slow. It can be improved in many ways (see other answers) but the bare bone cPython is 100 times slower that C/C++.
This problem is getter more and more mitigated. With Numpy, Pypy and asyncio, most performance problems are not covered, and only very specific use cases are a bottleneck in Python anymore.
- Python is opened to anything. It's really hard to protect / obfuscate / limit Python code.
- Python is not hype. Unlike Ruby, there is no "cool wave" around Python, and it's still much harder to find a experienced Python coder, than, let's say, a Java or a PHP pro.
- After using Python, a lot of languages seems to be a pain to use. You'd think it's good, but believe me, not always. When you have to go Javascript after a Python project, your eyes are in tears for at least 3 days. Really hard to get started.
- It's harder to find web hosting than for popular solutions, such as PHP.
- As a dynamic language, you don't have the very handy refactoring tools you could get with Java and Eclipse or C# and VS.
- For the same reason, you can't rely on type checking as a safety net. This is why pythonistas tend to follow best practice and write unit tests more often than others.
- It seems I just can't find an IDE with a decent code completion. PyDev, Gedit, Komodo, SPE, etc. just don't do it as good as it could be.
With Python 3 types hints and tools like PyCharm or Sublime Text+Anaconda, the situation has changed a lot.
- The best docs are still in English only. Some people don't deal well with it.
- You have to get use to the syntax. Not only you get spaces and line breaks instead of bracets, but you can forget about long lambdas, --i, and ternary operation.
Now, to me, these are not reasons to not learn a tool that will make you produce more while having more fun. But maybe it's just me :-)
Honestly, given that :
C++ much harder to learn;
You can do pretty much any thing you want with Python;
You will get quicker result with Python in your projects.
Unless you have professional issues involving C++, you'd better learn Python first, it's more motivating. You still can learn C++ later, it's a useful language for system programming, embedded devices and such.
Don't try to learn both at the same times, multitasking rarely ends well. | 0 | 10,696 | true | 0 | 1 | What are the limits of Python? | 1,793,767 |
8 | 11 | 0 | 32 | 12 | 1 | 1 | 0 | I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn.
So I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead?
What can C++ do and Python can't ? | 0 | c++,python | 2009-11-24T19:26:00.000 | 0 | 1,792,360 | Here's why it's worth learning Python:
A comparatively small number of problems are constrained by the speed of the algorithm. A comparatively large number of problems are bounded by the speed of the developer. | 0 | 10,696 | false | 0 | 1 | What are the limits of Python? | 1,794,560 |
8 | 11 | 0 | 0 | 12 | 1 | 0 | 0 | I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn.
So I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead?
What can C++ do and Python can't ? | 0 | c++,python | 2009-11-24T19:26:00.000 | 0 | 1,792,360 | One significant difference not so far mentioned is the difference between a language like C++ that builds to native code, and a language like Python which by default puts a VM between you and the hardware. For doing low-level work, like coding against the OS kernel, the native language will be the preferred option.
In practise, though, when you're working in that context it usually means dropping all the way down C (in its role as portable assembler) rather than being able to use C++ (and its runtime libraries), for much if not all of the code. | 0 | 10,696 | false | 0 | 1 | What are the limits of Python? | 1,795,473 |
8 | 11 | 0 | 0 | 12 | 1 | 0 | 0 | I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn.
So I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead?
What can C++ do and Python can't ? | 0 | c++,python | 2009-11-24T19:26:00.000 | 0 | 1,792,360 | One thing that people often use C for, and never (to my knowledge) Python, is low-level code such as operating-system kernels and embedded software.
C has a lot of of constructs that make it very easy to, for example, convert an arbitrary machine address into a pointer and dereference it, or tell the compiler that an address used for memory-mapped I/O might change even though this program doesn’t change it, or to specify the exact layout of an object in memory. It’s designed to run as fast as possible, with as little wasted memory, rather than be safe.
That’s what the comments about “letting you shoot yourself in the foot” are mostly referring to. | 0 | 10,696 | false | 0 | 1 | What are the limits of Python? | 53,662,323 |
8 | 11 | 0 | 0 | 12 | 1 | 0 | 0 | I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn.
So I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead?
What can C++ do and Python can't ? | 0 | c++,python | 2009-11-24T19:26:00.000 | 0 | 1,792,360 | As others have suggested: learn Python to study algorithms and higher level concepts and use it for prototyping and for places where you can. Learn C/C++ and/or Java for the job market and for cases where you must use it.
Python's vastly easier syntax and high level libraries allow you to focus on interfaces and abstractions while still having a functional prototype. | 0 | 10,696 | false | 0 | 1 | What are the limits of Python? | 1,795,061 |
8 | 11 | 0 | 1 | 12 | 1 | 0.01818 | 0 | I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn.
So I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead?
What can C++ do and Python can't ? | 0 | c++,python | 2009-11-24T19:26:00.000 | 0 | 1,792,360 | From what I've been told, 1% of learning C++ is learning C. 1% is learning the extra basic features. 98% is learning to use the features in a safe, maintainable way, and coping with the dark hairy corners of the language.
Learning python will teach you to write code that is safe, and maintainable. I think that if you learn python then go back to C++, then you will be able to write good C++ code. Of course, that won't mean you will understand bad C++, or C++ code that was written in a non-pythonic way.
Limits to python?
It's interpreted, so you have to ship the source and the interpreter; and processes will take much longer to start up.
It's not C++, so it won't play with existing C++ code.
It's a bit slower (even if you wrap the hot loops in C).*
It encourages you to be "pythonic", and some problems are easier if you are not "pythonic".
*Python might be faster:
Automatic GC. C++ is only faster if it doesn't leak too much.
Dictionaries. Lots of code runs in O(N plus a bit), rather than O(N^2) if you use a dictionary. Sure, you can use a hash table in C++, but not everbody does.
Memory management - the python interpreter caches some of the basic data structures' memory, then reallocates them, rather than hitting the system for new memory. This reduces system calls, which is a very good thing.
Profiling new algorithms is waaaay easier on python. In lots of problems, a better algorithm is more important than a linear speedup (which is what C++ gives you).
If you are making a program that "only runs once" (scientific analysis, data migration, etc), then the compile-build-test cycle should be faster in python. That's what really counts ;) | 0 | 10,696 | false | 0 | 1 | What are the limits of Python? | 1,794,856 |
8 | 11 | 0 | 0 | 12 | 1 | 0 | 0 | I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn.
So I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead?
What can C++ do and Python can't ? | 0 | c++,python | 2009-11-24T19:26:00.000 | 0 | 1,792,360 | Learn a statically typed language and a scripting language.
You can do whatever you want in either language. A well-written C++ code base is easier to maintain/debug than a Python code base written with the same level of competency.
If your goal is to do web stuff or scripting, Python is for you. Anything more advanced will require C++.
That being said, go for Python. | 0 | 10,696 | false | 0 | 1 | What are the limits of Python? | 1,793,871 |
8 | 11 | 0 | 3 | 12 | 1 | 0.054491 | 0 | I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn.
So I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead?
What can C++ do and Python can't ? | 0 | c++,python | 2009-11-24T19:26:00.000 | 0 | 1,792,360 | if you are trying to find out whether you are still going to be employed some
time later using C++ or Python, don't concern yourself with a single language's longevity.
Learn to program. Don't learn to program in <insert a language here>.
Here is an analogy: If your car is running fine (gets you where you're
going, has good mileage, cheap to maintain, relatively safe), there is
no logical reason to trade it in for another one. None. Whatsoever.
Drive it to the ground before you even consider what make or model to
get next. But if you are already looking around thinking what car to
get, just go get it, stop asking everybody you know whether you should
do it. If you need to ask, you need to change it. It's as simple as
that. | 0 | 10,696 | false | 0 | 1 | What are the limits of Python? | 1,792,387 |
2 | 5 | 0 | 2 | 5 | 1 | 0.07983 | 0 | Inside my python scrip, I get some string back from a function which I didn't write. The encoding of it varies. I need to convert it to ascii format. Is there some fool-proof way of doing this? I don't mind replacing the non-ascii chars with blanks or something else... | 0 | python,utf-8,ascii,decode | 2009-11-24T20:08:00.000 | 0 | 1,792,602 | What's meant by "foolproof" is that the function does not fail with even the most obscure, impossible input -- meaning, you could feed the function random binary data and IT WOULD NEVER FAIL, NO MATTER WHAT. That's what "foolproof" means.
The function should then proceed do its best to convert to the destination encoding. If it has to throw away all the trash it does not understand, then that is perfectly fine and is in fact the most desirable result. Why try to salvage all the junk? Just discard the junk. Tell the user he's not merely a moron for using Microsoft anything, but a non-standard moron for using non-standard Microsoft anything...or for attempting to send in binary data!
I have just precisely this same need (though my need is in PHP), and I also have users who are at least as moronic as I am, sometimes moreso; however, they are definitely nicer and no doubt more patient.
The best, bottom-line thing I've found so far is (in PHP 5.3):
$fixed_string = iconv( 'ISO-8859-1', 'UTF-8//IGNORE//TRANSLATE', $in_string );
This attempts to translate whatever it can and simply throws away all the junk, resulting in a legal UTF-8 string output. I've also not been able to break it or cause it to fail or reject any incoming text or data, even by feeding it gobs of binary junk data.
Finding the iconv() and getting it to work is easy; what's so maddening and wasteful is reading through all the total garbage and bend-over-backwards idiocy that so many programmers seem to espouse when dealing with this encoding fiasco. What's become of the enviable (and respectable) "Flail and Burn The Idiots" mentality of old school programming? Let's get back to basics. Use iconv() and throw away their garbage, and don't be bashful when telling them you threw away their garbage -- in short, don't fail to flail the morons who feed you garbage. And you can tell them I told you so. | 0 | 11,358 | false | 0 | 1 | What is the fool proof way to convert some string (utf-8 or else) to a simple ASCII string in python | 5,642,048 |
2 | 5 | 0 | 9 | 5 | 1 | 1.2 | 0 | Inside my python scrip, I get some string back from a function which I didn't write. The encoding of it varies. I need to convert it to ascii format. Is there some fool-proof way of doing this? I don't mind replacing the non-ascii chars with blanks or something else... | 0 | python,utf-8,ascii,decode | 2009-11-24T20:08:00.000 | 0 | 1,792,602 | If you want an ASCII string that unambiguously represents what you have got, without losing any information, the answer is simple:
Don't muck about with encode/decode, use the repr() function (Python 2.X) or the ascii() function (Python 3.x). | 0 | 11,358 | true | 0 | 1 | What is the fool proof way to convert some string (utf-8 or else) to a simple ASCII string in python | 1,793,902 |
1 | 4 | 0 | 14 | 23 | 0 | 1 | 0 | Would it be possible to translate the Ruby on Rails code base to Python?
I think many people like Python more than Ruby, but find Ruby on Rails features better (as a whole) than the ones in Python web frameworks.
So that, would it be possible? Or does Ruby on Rails utilize language-specific features that would be difficult to translate to Python? | 0 | python,ruby-on-rails,metaprogramming,code-translation | 2009-11-25T01:56:00.000 | 0 | 1,794,179 | I think one of the things that people like about RoR is the domain-specific language (DSL) style of programming. This is something that Ruby is much better at than Python. | 0 | 23,732 | false | 1 | 1 | Python on Rails? | 1,794,205 |
2 | 3 | 0 | 4 | 5 | 0 | 1.2 | 0 | Is smtplib pure python or implemented in C? | 0 | python,c,smtplib | 2009-11-26T02:40:00.000 | 0 | 1,801,271 | smtplib itself is implemented in python but socket is based on C, so its means both. | 0 | 355 | true | 0 | 1 | Is smtplib pure python or implemented in C? | 1,801,277 |
2 | 3 | 0 | 2 | 5 | 0 | 0.132549 | 0 | Is smtplib pure python or implemented in C? | 0 | python,c,smtplib | 2009-11-26T02:40:00.000 | 0 | 1,801,271 | Basically pure Python (as the underlying implementation if you go down far enough is C). You can find the source under the Lib\ directory in your Python root. | 0 | 355 | false | 0 | 1 | Is smtplib pure python or implemented in C? | 1,801,281 |
3 | 5 | 0 | 39 | 47 | 1 | 1.2 | 0 | I come from a background where I normally create one file per class. I organize common classes under directories as well. This practice is intuitive to me and it has been proven to be effective in C++, PHP, JavaSript, etc.
I am having trouble bringing this metaphor into Python: files are not just files anymore, but they are formal modules. It doesn't seem right to just have one class in a module --- most classes are useless by themselves. If I have a automobile.py and an Automobile class, it seems silly to always reference it as automobile.Automobile as well.
But, at the same time, it doesn't seem right to throw a ton of code into one file and call it a day. Obviously, a very complex application should have more than 5 files.
What is the correct---or pythonic---way? (Or if there is no correct way, what is your preferred way and why?) How much code should I be throwing in a Python module? | 0 | python,module,package,project-organization | 2009-11-26T06:28:00.000 | 0 | 1,801,878 | Think in terms of a "logical unit of packaging" -- which may be a single class, but more often will be a set of classes that closely cooperate. Classes (or module-level functions -- don't "do Java in Python" by always using static methods when module-level functions are also available as a choice!-) can be grouped based on this criterion. Basically, if most users of A also need B and vice versa, A and B should probably be in the same module; but if many users will only need one of them and not the other, then they should probably be in distinct modules (perhaps in the same package, i.e., directory with an __init__.py file in it).
The standard Python library, while far from perfect, tends to reflect (mostly) reasonably good practices -- so you can mostly learn from it by example. E.g., the threading module of course defines a Thread class... but it also holds the synchronization-primitive classes such as locks, events, conditions, and semaphores, and an exception-class that can be raised by threading operations (and a few more things). It's at the upper bound of reasonable size (800 lines including whitespace and docstrings), and some crucial thread-related functionality such as Queue has been placed in a separate module, nevertheless it's a good example of what maximum amount of functionality it still makes sense to pack into a single module. | 0 | 22,658 | true | 0 | 1 | The Pythonic way of organizing modules and packages | 1,801,992 |
3 | 5 | 0 | 7 | 47 | 1 | 1 | 0 | I come from a background where I normally create one file per class. I organize common classes under directories as well. This practice is intuitive to me and it has been proven to be effective in C++, PHP, JavaSript, etc.
I am having trouble bringing this metaphor into Python: files are not just files anymore, but they are formal modules. It doesn't seem right to just have one class in a module --- most classes are useless by themselves. If I have a automobile.py and an Automobile class, it seems silly to always reference it as automobile.Automobile as well.
But, at the same time, it doesn't seem right to throw a ton of code into one file and call it a day. Obviously, a very complex application should have more than 5 files.
What is the correct---or pythonic---way? (Or if there is no correct way, what is your preferred way and why?) How much code should I be throwing in a Python module? | 0 | python,module,package,project-organization | 2009-11-26T06:28:00.000 | 0 | 1,801,878 | If you are coming from a c++ point of view, you could view python modules akin to a .so or .dll. Yeah they look like source files, because python is scripted, but they are actually loadable libraries of specific functionality.
Another metaphor that may help is you might look python modules as namespaces. | 0 | 22,658 | false | 0 | 1 | The Pythonic way of organizing modules and packages | 1,802,001 |
3 | 5 | 0 | 4 | 47 | 1 | 0.158649 | 0 | I come from a background where I normally create one file per class. I organize common classes under directories as well. This practice is intuitive to me and it has been proven to be effective in C++, PHP, JavaSript, etc.
I am having trouble bringing this metaphor into Python: files are not just files anymore, but they are formal modules. It doesn't seem right to just have one class in a module --- most classes are useless by themselves. If I have a automobile.py and an Automobile class, it seems silly to always reference it as automobile.Automobile as well.
But, at the same time, it doesn't seem right to throw a ton of code into one file and call it a day. Obviously, a very complex application should have more than 5 files.
What is the correct---or pythonic---way? (Or if there is no correct way, what is your preferred way and why?) How much code should I be throwing in a Python module? | 0 | python,module,package,project-organization | 2009-11-26T06:28:00.000 | 0 | 1,801,878 | In a mid-sized project, I found myself with several sets of closely related classes. Several of those sets are now grouped into files; for example, the low-level network classes are all in a single network module. However, a few of the largest classes have been split out into their own file.
Perhaps the best way to start down that path from a one-class-per-file history is to take the classes that you would normally place in the same directory, and instead keep them in the same file. If that file starts looking too large, split it. | 0 | 22,658 | false | 0 | 1 | The Pythonic way of organizing modules and packages | 1,801,981 |
1 | 2 | 0 | 4 | 21 | 0 | 0.379949 | 0 | I'm trying to understand what paste script and paster are. The website is far from clear.
I used paster to generate pre-made layouts for projects, but I don't get the big picture.
As far as I understand, and from the wikipedia entry, it says it's a framework for web frameworks, but that seems reductive. paster create seems to be able to create pre-made layouts for setuptools/distutils enabled packages.
What is the problem (or set of problems) it's trying to solve? | 0 | python,paste,paster | 2009-11-26T08:26:00.000 | 0 | 1,802,282 | PasteScript (and its companion PasteDeploy) are tools for running Python code using 'entry points'. Basically, a python library can specify in metadata that it knows how to create a certain kind of Python project, or perform certain operations on those projects. paster is a commandline tool that looks up the appropriate code for the operation you requested. It's a very general kind of problem; if you're familiar with Ruby at all, the equivalent might be 'rake'.
In particular, PasteDeploy is a configuration format to serve Python webapps using paster. Both PasteScript and PasteDeploy are important for the Pylons web framework. | 0 | 6,425 | false | 0 | 1 | What is paste script? | 1,802,443 |
7 | 12 | 0 | 1 | 18 | 1 | 0.016665 | 0 | What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So certainly I am missing something. | 0 | python,ruby,compiler-construction | 2009-11-26T18:47:00.000 | 0 | 1,805,148 | By design.
The authors wanted something where they can write scripts into.
Python gets compiled the first time it is executed though | 0 | 2,514 | false | 0 | 1 | Why is (python|ruby) interpreted? | 1,805,155 |
7 | 12 | 0 | 2 | 18 | 1 | 0.033321 | 0 | What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So certainly I am missing something. | 0 | python,ruby,compiler-construction | 2009-11-26T18:47:00.000 | 0 | 1,805,148 | In a compiled language, the loop you get into when making software is
Make a change
Compile changes
Test changes
goto 1
Interpreted languages tend to be faster to make stuff in because you get to cut out step two of that process (and when you're dealing with a large system where compile times can be upwards of two minutes, step two can add a significant amount of time).
This isn't necessarily the reason python|ruby designers thought of, but keep in mind that "How efficiently does the machine run this?" is only half the software development problem.
It also seems like it would be easier to compile code in a language that's interpreted naturally than it would be to add an interpreter to a language that's compiled by default. | 0 | 2,514 | false | 0 | 1 | Why is (python|ruby) interpreted? | 1,805,169 |
7 | 12 | 0 | 1 | 18 | 1 | 0.016665 | 0 | What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So certainly I am missing something. | 0 | python,ruby,compiler-construction | 2009-11-26T18:47:00.000 | 0 | 1,805,148 | Raw compute performance is probably not a goal of most interpreted languages. Interpreted languages are typically more concerned about programmer productivity than raw speed. In most cases these languages are plenty fast enough for the tasks the languages were designed to tackle.
Given that, and that just about the only advantages of a compiler are type checking (difficult to do in a dynamic language) and speed, there's not much incentive to write compilers for most interpreted languages. | 0 | 2,514 | false | 0 | 1 | Why is (python|ruby) interpreted? | 1,928,816 |
7 | 12 | 0 | 2 | 18 | 1 | 0.033321 | 0 | What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So certainly I am missing something. | 0 | python,ruby,compiler-construction | 2009-11-26T18:47:00.000 | 0 | 1,805,148 | Well, isn't one of the strengths of these languages that they are so easily scriptable? They wouldn't be if they were compiled. And on the other hand, dynamic languages are easier to intereprete than to compile. | 0 | 2,514 | false | 0 | 1 | Why is (python|ruby) interpreted? | 1,805,157 |
7 | 12 | 0 | 32 | 18 | 1 | 1 | 0 | What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So certainly I am missing something. | 0 | python,ruby,compiler-construction | 2009-11-26T18:47:00.000 | 0 | 1,805,148 | Several reasons:
faster development loop, write-test vs write-compile-link-test
easier to arrange for dynamic behavior (reflection, metaprogramming)
makes the whole system portable (just recompile the underlying C code and you are good to go on a new platform)
Think of what would happen if the system was not interpreted. Say you used translation-to-C as the mechanism. The compiled code would periodically have to check if it had been superseded by metaprogramming. A similar situation arises with eval()-type functions. In those cases, it would have to run the compiler again, an outrageously slow process, or it would have to also have the interpreter around at run-time anyway.
The only alternative here is a JIT compiler. These systems are highly complex and sophisticated and have even bigger run-time footprints than all the other alternatives. They start up very slowly, making them impractical for scripting. Ever seen a Java script? I haven't.
So, you have two choices:
all the disadvantages of both a compiler and an interpreter
just the disadvantages of an interpreter
It's not surprising that generally the primary implementation just goes with the second choice. It's quite possible that some day we may see secondary implementations like compilers appearing. Ruby 1.9 and Python have bytecode VM's; those are ½-way there. A compiler might target just non-dynamic code, or it might have various levels of language support declarable as options. But since such a thing can't be the primary implementation, it represents a lot of work for a very marginal benefit. Ruby already has 200,000 lines of C in it...
I suppose I should add that one can always add a compiled C (or, with some effort, any other language) extension. So, say you have a slow numerical operation. If you add, say Array#newOp with a C implementation then you get the speedup, the program stays in Ruby (or whatever) and your environment gets a new instance method. Everybody wins! So this reduces the need for a problematic secondary implementation. | 0 | 2,514 | false | 0 | 1 | Why is (python|ruby) interpreted? | 1,805,172 |
7 | 12 | 0 | 8 | 18 | 1 | 1 | 0 | What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So certainly I am missing something. | 0 | python,ruby,compiler-construction | 2009-11-26T18:47:00.000 | 0 | 1,805,148 | Merely replacing an interpreter with a compiler won't give you as big a performance boost as you might think for a language like Python. When most time is actually spend doing symbolic lookups of object members in dictionaries, it doesn't really matter if the call to the function performing such lookup is interpreted, or is native machine code - the difference, while not quite negligible, will be dwarfed by lookup overhead.
To really improve performance, you need optimizing compilers. And optimization techniques here are very different from what you have with C++, or even Java JIT - an optimizing compiler for a dynamically typed / duck typed language such as Python needs to do some very creative type inference (including probabilistic - i.e. "90% chance of it being T" and then generating efficient machine code for that case with a check/branch before it) and escape analysis. This is hard. | 0 | 2,514 | false | 0 | 1 | Why is (python|ruby) interpreted? | 1,805,899 |
7 | 12 | 0 | 6 | 18 | 1 | 1 | 0 | What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So certainly I am missing something. | 0 | python,ruby,compiler-construction | 2009-11-26T18:47:00.000 | 0 | 1,805,148 | I think the biggest reason for the languages being interpreted is portability. As a programmer you can write code that will run in an interpreter not a specific OS. So your programs behave more uniformly across platforms (more so than compiled languages). Another advantage I can think of is it's easier to have a dynamic type system in an interpreted language. I think the creators of the language were thinking having a language where programmers can be more productive due to automatic memory management, dynamic type system and meta programming wins over any performance loss due to the language being interpreted. If you are concerned about performance you can always compile the language to native machine code employing a technique like JIT compilation. | 0 | 2,514 | false | 0 | 1 | Why is (python|ruby) interpreted? | 1,805,158 |
4 | 6 | 0 | 13 | 23 | 1 | 1.2 | 0 | Been using mod_python for a while, I read more and more articles about how good WSGI is, without really understanding why.
So why should I switch to it? What are the benefits? Is it hard, and is the learning curve worth it? | 0 | python,wsgi | 2009-11-28T18:54:00.000 | 0 | 1,813,394 | mod_wsgi vs. mod_python:
mod_wsgi is a little faster (internally there's more C, less Python)
mod_wsgi processes can be isolated from Apache, which improves security/stability with lower memory use[1]
mod_python gives you access to some of Apache's internals
WSGI in general:
lots of reusable middleware (authentication/authorisation, session stuff, caching, filtering)
ease of deployment on non-Apache webservers either via native WSGI support or flup
[1] - compared to a preforking Apache, which maintains a separate Python interpreter in each process | 0 | 10,494 | true | 0 | 1 | Why should I use WSGI? | 1,813,471 |
4 | 6 | 0 | 1 | 23 | 1 | 0.033321 | 0 | Been using mod_python for a while, I read more and more articles about how good WSGI is, without really understanding why.
So why should I switch to it? What are the benefits? Is it hard, and is the learning curve worth it? | 0 | python,wsgi | 2009-11-28T18:54:00.000 | 0 | 1,813,394 | You shouldn't have to relearn much, since the difference from a developer perspective is just a small wrapper and some server configuration.
From a deployment perspective, the difference is that your python code lives in a separate process from the web browser, which means
a) The python process can be running as another user than the web server. This can be valuable for security, if used right.
b) The web server processes does not need to contain the python runtime. This can be a major boost for performance if the server runs a lot of "other" requests (static files, etc) and some heavy python requests. | 0 | 10,494 | false | 0 | 1 | Why should I use WSGI? | 1,813,431 |
4 | 6 | 0 | 2 | 23 | 1 | 0.066568 | 0 | Been using mod_python for a while, I read more and more articles about how good WSGI is, without really understanding why.
So why should I switch to it? What are the benefits? Is it hard, and is the learning curve worth it? | 0 | python,wsgi | 2009-11-28T18:54:00.000 | 0 | 1,813,394 | Most Python frameworks implement wsgi. There is mod_wsgi for apache and a SCGI/FastCGI/AJP module + Flup for the others. That way you can have all the advantages of a separate Python process, without being tied to one webserver. | 0 | 10,494 | false | 0 | 1 | Why should I use WSGI? | 1,813,462 |
4 | 6 | 0 | 15 | 23 | 1 | 1 | 0 | Been using mod_python for a while, I read more and more articles about how good WSGI is, without really understanding why.
So why should I switch to it? What are the benefits? Is it hard, and is the learning curve worth it? | 0 | python,wsgi | 2009-11-28T18:54:00.000 | 0 | 1,813,394 | For developing sophisticated web applications in Python, you would probably use a more comprehensive web development framework like DJango, Zope, Turbogears etc. As an application developer, you don't have to worry about WSGI much. All you have to be aware about is that these frameworks support WSGI. The WSGI allows separation of web server and web application code and a system administrator can change the web server as long as the web application is WSGI compliant. If you are developing in one of these frameworks, you would anyway be satisfying this condition.
If you are a web framework developer (that is developing DJango or Zope itself), then you have to understand WSGI in more depth. | 0 | 10,494 | false | 0 | 1 | Why should I use WSGI? | 1,813,470 |
11 | 13 | 0 | 2 | 4 | 1 | 0.03076 | 0 | I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.
EDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.
EDIT 1: faster - less time && less work to code the solution
Thank you all for your help ! | 0 | c++,python,algorithm,graph | 2009-12-01T01:08:00.000 | 0 | 1,823,431 | I also vote for python. When do algorithm, we tend to work on the algorithm itself rather than language, low level details. Basically, we works on abstraction level. And using python, we're less likely to be side-tracked.
But if you're very familiar and comfortable with C++ and can use it freely to express your idea, just use it. | 0 | 1,482 | false | 0 | 1 | which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)? | 1,823,545 |
11 | 13 | 0 | 1 | 4 | 1 | 0.015383 | 0 | I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.
EDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.
EDIT 1: faster - less time && less work to code the solution
Thank you all for your help ! | 0 | c++,python,algorithm,graph | 2009-12-01T01:08:00.000 | 0 | 1,823,431 | If using C++ means that STL is fair game, I'd say that it deserves serious consideration. STL is a fantastic library, combining structures, iterators, and algorithms. I love the Python recommendations, but if I could use STL I'd reconsider C++. | 0 | 1,482 | false | 0 | 1 | which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)? | 1,823,577 |
11 | 13 | 0 | 2 | 4 | 1 | 0.03076 | 0 | I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.
EDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.
EDIT 1: faster - less time && less work to code the solution
Thank you all for your help ! | 0 | c++,python,algorithm,graph | 2009-12-01T01:08:00.000 | 0 | 1,823,431 | With C++, you'd sometimes be concentrating more on the language issues than the problem itself, so Python. I'd even be recommending you do it in a higher-level language like Matlab (although the language itself can be a bit ugly). | 0 | 1,482 | false | 0 | 1 | which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)? | 1,823,589 |
11 | 13 | 0 | 0 | 4 | 1 | 0 | 0 | I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.
EDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.
EDIT 1: faster - less time && less work to code the solution
Thank you all for your help ! | 0 | c++,python,algorithm,graph | 2009-12-01T01:08:00.000 | 0 | 1,823,431 | Remember that Python is compiled to bytecode and then interpreted in a VM. So, in performance isn't better (faster) than C++. | 0 | 1,482 | false | 0 | 1 | which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)? | 1,823,580 |
11 | 13 | 0 | 3 | 4 | 1 | 0.046121 | 0 | I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.
EDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.
EDIT 1: faster - less time && less work to code the solution
Thank you all for your help ! | 0 | c++,python,algorithm,graph | 2009-12-01T01:08:00.000 | 0 | 1,823,431 | Algorithms are fine in Python (allthough you can only fly one OS scheduled python thread due to the global lock); however, when it comes to data structures + algorithms you need fixed complexity guarantees, and this case you mix Python with C.
I suppose what I have said applies more to long running computations. You can emulate data structures on-top of the python hashmap primitive. | 0 | 1,482 | false | 0 | 1 | which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)? | 1,823,479 |
11 | 13 | 0 | 4 | 4 | 1 | 0.061461 | 0 | I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.
EDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.
EDIT 1: faster - less time && less work to code the solution
Thank you all for your help ! | 0 | c++,python,algorithm,graph | 2009-12-01T01:08:00.000 | 0 | 1,823,431 | I would go for python. And if you really need the performance, then you can always write C/C++ extensions and use them in python. | 0 | 1,482 | false | 0 | 1 | which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)? | 1,823,473 |
11 | 13 | 0 | 8 | 4 | 1 | 1 | 0 | I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.
EDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.
EDIT 1: faster - less time && less work to code the solution
Thank you all for your help ! | 0 | c++,python,algorithm,graph | 2009-12-01T01:08:00.000 | 0 | 1,823,431 | A bit subjective, but I'd vote for python because it has good libraries and abstracts a lot of the low level 'detail' that you'd have to consider when using c++... | 0 | 1,482 | false | 0 | 1 | which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)? | 1,823,434 |
11 | 13 | 0 | 6 | 4 | 1 | 1 | 0 | I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.
EDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.
EDIT 1: faster - less time && less work to code the solution
Thank you all for your help ! | 0 | c++,python,algorithm,graph | 2009-12-01T01:08:00.000 | 0 | 1,823,431 | I did all my algorithms work in college in C++ because I knew it.
If I'd had to learn a language at the same time, I would have picked Python most likely. | 0 | 1,482 | false | 0 | 1 | which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)? | 1,823,440 |
11 | 13 | 0 | 6 | 4 | 1 | 1 | 0 | I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.
EDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.
EDIT 1: faster - less time && less work to code the solution
Thank you all for your help ! | 0 | c++,python,algorithm,graph | 2009-12-01T01:08:00.000 | 0 | 1,823,431 | I am under the impression that it really depends from what you mean by faster.
Faster to develop: go python.
Faster to run: go C++.
However python can use a lot of external C libraries, so the difference in processing time might not be that relevant, depending on the type of implementation. | 0 | 1,482 | false | 0 | 1 | which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)? | 1,823,447 |
11 | 13 | 0 | 5 | 4 | 1 | 0.076772 | 0 | I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.
EDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.
EDIT 1: faster - less time && less work to code the solution
Thank you all for your help ! | 0 | c++,python,algorithm,graph | 2009-12-01T01:08:00.000 | 0 | 1,823,431 | At my university the 500 students in the "Algorithms and Datastructures" class get to choose the language they want.
Python is by far the most popular choice there, and personally I'm happy I also chose that, even though I already knew C++. | 0 | 1,482 | false | 0 | 1 | which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)? | 1,823,457 |
11 | 13 | 0 | 23 | 4 | 1 | 1.2 | 0 | I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.
EDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.
EDIT 1: faster - less time && less work to code the solution
Thank you all for your help ! | 0 | c++,python,algorithm,graph | 2009-12-01T01:08:00.000 | 0 | 1,823,431 | I think you're looking for Python, because you can:
Focus on the algorithms themselves and not have to worry about other detail like memory management.
Do more with less code
The syntax is almost like working with pseudo code.
There is great built in language support for lists, tuples, list comprehensions, etc...
But more specifically...
If by better you mean speed of development, then chose Python.
If by better you mean sheer execution speed, then chose C++. | 0 | 1,482 | true | 0 | 1 | which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)? | 1,823,475 |
1 | 3 | 0 | 0 | 5 | 0 | 0 | 0 | I have been using python's native bignums for an algorithm and decided to try and speed it up by converting it to C++. When I used long longs, the C++ was about 100x faster than the python, but when I used GMP bindings in C++, it was only 10x faster than the python (for the same cases that fit in long longs).
Is there a better bignum implementation for doing a large number of small additions? For example, we have a big number N we'll be adding a lot of little +1, +21, +1, etc. and every once and a while adds another big number M? | 0 | c++,python,bignum,gmp,arbitrary-precision | 2009-12-02T07:33:00.000 | 0 | 1,831,212 | Did you do profiling ? Of Python and C++ whole applications. So that you know that you really need that additional speed.
Try Python 3k it now have any-length integers implemented! | 0 | 1,568 | false | 0 | 1 | Bignum implementation that has efficient addition of small integers | 1,831,277 |
1 | 5 | 0 | 1 | 2 | 0 | 0.039979 | 0 | I have been working with Ruby on Rails for over a year now and have been offered some development work with Python. I would like know if development with Python is as enjoyable as Ruby in terms of the clarity and ease of use. And how well is Python suited for Web development. I've heard of Pylons being a direct port of the Rails framework but does it provide the same level of comfort and features. Are there any popular websites built using Python and a framework that offers the same level of flexibilty as Rails.
Because Rails doesn't seem like work. | 0 | python,ruby-on-rails,pylons | 2009-12-02T18:22:00.000 | 0 | 1,834,829 | Clarity and ease of use are some of Pythons biggest selling points. In saying that, the different Python web frameworks cover almost the entire spectrum from small and simple all the way up to large and complex with everything in between.
You should find that most Python web frameworks have less 'magic' than Rails - ie they are a bit more explicit which is arguably better from the clarity point of view.
In my opinion, even if you enjoy Rails and don't ever plan on leaving, you should still try out other languages and frameworks occasionally to give you a broader perspective.
Personally I like Turbogears2, but I think Django would make a good starting point for a Rails developer that wanted to try out something else. | 0 | 1,541 | false | 1 | 1 | Python after Ruby on Rails | 1,864,605 |
6 | 8 | 0 | 46 | 32 | 1 | 1 | 0 | What are the advantages of Python, PowerShell, and other scripting environments? We would like to standardize our scripting and are currently using bat and cmd files as the standard. I think Python would be a better option than these, but am also researching PowerShell and other scripting tools.
The scripts would be used to trigger processes such as wget etc to call web services, or other applications/tools that need to run in a specific order with specific parameters.
We primarily work with the Windows stack, but there is a good chance we will need to support Unix in the future. | 0 | python,powershell,scripting | 2009-12-02T18:26:00.000 | 1 | 1,834,850 | Python works as a great, all-purpose tool if you're looking to replace CMD and BAT scripts on your Windows boxes, and can also be written to run scripts on your (L)inux boxes, too. It's a great, flexible language and can handle many tasks you throw at it.
That being said, PowerShell is an amazingly versatile tool for administering all manner of Windows boxes; it has all the power of .NET, with many more interfaces into MS products such as Exchange and Active Directory, which are a timesaver. Depending on your situation, you may get more use of of PS than other scripting languages just because of the interfaces available to MS products, and I know MS seems to have made a commitment to providing those APIs in a lot of products. PowerShell comes installed on all current versions of Windows (Windows 7+, Windows Server 2008+), and is fairly easily installed on older versions.
To address your edit that your scripts will be used to launch other processes, I think in that case either of the tools fit the bill. I would recommend PS if you plan on adding any admin-ish tasks to the scripts rather than just service calls, but if you stick to what you described, Python is good. | 0 | 44,901 | false | 0 | 1 | Python, PowerShell, or Other? | 1,835,086 |
6 | 8 | 0 | 3 | 32 | 1 | 0.07486 | 0 | What are the advantages of Python, PowerShell, and other scripting environments? We would like to standardize our scripting and are currently using bat and cmd files as the standard. I think Python would be a better option than these, but am also researching PowerShell and other scripting tools.
The scripts would be used to trigger processes such as wget etc to call web services, or other applications/tools that need to run in a specific order with specific parameters.
We primarily work with the Windows stack, but there is a good chance we will need to support Unix in the future. | 0 | python,powershell,scripting | 2009-12-02T18:26:00.000 | 1 | 1,834,850 | If all you do is spawning a lot of system specific programs with no or little programming logic behind then OS specific shell might be a better choice than a full general purpose programming language. | 0 | 44,901 | false | 0 | 1 | Python, PowerShell, or Other? | 1,836,471 |
6 | 8 | 0 | 2 | 32 | 1 | 0.049958 | 0 | What are the advantages of Python, PowerShell, and other scripting environments? We would like to standardize our scripting and are currently using bat and cmd files as the standard. I think Python would be a better option than these, but am also researching PowerShell and other scripting tools.
The scripts would be used to trigger processes such as wget etc to call web services, or other applications/tools that need to run in a specific order with specific parameters.
We primarily work with the Windows stack, but there is a good chance we will need to support Unix in the future. | 0 | python,powershell,scripting | 2009-12-02T18:26:00.000 | 1 | 1,834,850 | I find it sad no one yet mentioend good ol' Perl. | 0 | 44,901 | false | 0 | 1 | Python, PowerShell, or Other? | 1,835,112 |
6 | 8 | 0 | 2 | 32 | 1 | 0.049958 | 0 | What are the advantages of Python, PowerShell, and other scripting environments? We would like to standardize our scripting and are currently using bat and cmd files as the standard. I think Python would be a better option than these, but am also researching PowerShell and other scripting tools.
The scripts would be used to trigger processes such as wget etc to call web services, or other applications/tools that need to run in a specific order with specific parameters.
We primarily work with the Windows stack, but there is a good chance we will need to support Unix in the future. | 0 | python,powershell,scripting | 2009-12-02T18:26:00.000 | 1 | 1,834,850 | The questions is kind of vague, but Python is much more portable than PowerShell; however, Python isn't that prevalent on Windows. But on the other hand, I don't believe PowerShell scripts will work on a Windows machine that doesn't have PowerShell. Meaning they may not work in the old fashioned cmd shell. I think you'll find more documentation and libraries for Python as well.
PowerShell is more like Bash than it is a programming language like Python.
Maybe you could explain what you want to do with your scripts and you'll probably get better answers. | 0 | 44,901 | false | 0 | 1 | Python, PowerShell, or Other? | 1,834,895 |
6 | 8 | 0 | 20 | 32 | 1 | 1 | 0 | What are the advantages of Python, PowerShell, and other scripting environments? We would like to standardize our scripting and are currently using bat and cmd files as the standard. I think Python would be a better option than these, but am also researching PowerShell and other scripting tools.
The scripts would be used to trigger processes such as wget etc to call web services, or other applications/tools that need to run in a specific order with specific parameters.
We primarily work with the Windows stack, but there is a good chance we will need to support Unix in the future. | 0 | python,powershell,scripting | 2009-12-02T18:26:00.000 | 1 | 1,834,850 | We would like to standardize our scripting and are currently using bat and cmd files as the standard.
It sounds like Windows is your predominate environment.
If so, PowerShell would be much better than Python.
PowerShell is included with Windows
Server 2008. No need to
deploy/install Python runtime on
every new server that rolls in.
The entire Microsoft server related software (Exchange, Systems Center, etc) is transitioning to PowerShell cmdlets for functionality and extensions
3rd party vendors (e.g. SCOM plugins) will also use PowerShell scripts/cmdlets to expose functionality
I have more experience with Python than PowerShell but the writing is on the wall as far as the Microsoft ecosystem is concerned: go with PowerShell. Otherwise, you'll just be going against the grain and constantly interop-ing between Python and everyone else's cmdlets.
Just because you can code import win32com.client in Python does not put it on equal footing with PowerShell in the Windows environment. | 0 | 44,901 | false | 0 | 1 | Python, PowerShell, or Other? | 1,836,342 |
6 | 8 | 0 | 2 | 32 | 1 | 0.049958 | 0 | What are the advantages of Python, PowerShell, and other scripting environments? We would like to standardize our scripting and are currently using bat and cmd files as the standard. I think Python would be a better option than these, but am also researching PowerShell and other scripting tools.
The scripts would be used to trigger processes such as wget etc to call web services, or other applications/tools that need to run in a specific order with specific parameters.
We primarily work with the Windows stack, but there is a good chance we will need to support Unix in the future. | 0 | python,powershell,scripting | 2009-12-02T18:26:00.000 | 1 | 1,834,850 | One advantage to Python is the availability of third-party libraries and an extensive built-in standard library. You can do a lot of powerful operations quickly and easily with Python on a variety of operating systems and environments. That's one reason we use Python here at the office not only as a scripting language but for all of our database backend applications as well.
We also use it for XML and HTML scraping, using ElementTree and BeautifulSoup, which are very powerful and flexible Python-specific libraries for this sort of work. | 0 | 44,901 | false | 0 | 1 | Python, PowerShell, or Other? | 1,834,979 |
1 | 3 | 1 | -1 | 1 | 0 | -0.066568 | 0 | I need to render wikitext (pulled from the database of a mediawiki of it's relevant) and display in some other format (ultimately to be rendered as a PDF, but basically any other format will do).
I can definately hack together something that does the job but ultimately I'll be writing it as I go along, and I can see that the overhead of implementing new tags as people in my team use them will eat up a lot of my time.
Is there a project to do this?
I saw TiddlyWiki which is written in python, which I will look into borrowing their library, but in the meantime I figured there may be a project that's a bit more niche that someone knows?
Cheers | 0 | python,mediawiki,wikitext | 2009-12-03T00:29:00.000 | 0 | 1,836,884 | pywikipedia i have found to be best | 0 | 2,209 | false | 0 | 1 | Render wikitext with Python | 2,321,542 |
3 | 6 | 0 | 18 | 2 | 1 | 1 | 0 | I wish to take a file encoded in UTF-8 that doesn't use more than 128 different characters, then move it to a 7-bit encoding to save the 1/8 of space. For example, if I have a 16 MB text file that only uses the first 128(ascii) characters, I would like to shave off the extra bit to reduce the file to 14MB.
How would I go about doing this?
There doesn't seem to be an existing free or proprietary program to do so, so I was thinking I might try and make a simple(if inefficient) one.
The basic idea I have is to make a function from the current hex/decimal/binary values used for each character to the 128 values I would have in the seven bit encoding, then scan through the file and write each modified value to a new file.
So if the file looked like(I'll use a decimal example because I try not to have to think in hex)
127 254 025 212 015 015 132...
It would become
001 002 003 004 005 005 006
If 127 mapped to 001, 254 mapped to 005, etc.
I'm not entirely sure on a couple things, though.
Would this be enough to actually shorten the filesize? I have a bad feeling this would simply leave an extra 0 on the binary string--11011001 might get mapped to 01000001 rather than 1000001, and I won't actually save space.
If this would happen, how do I get rid of the zero?
How do I open the file to read/write in binary/decimal/hex rather than just text?
I've mostly worked with Python, but I can muddle through C if I must.
Thank you. | 0 | python,c,utf-8,compression | 2009-12-03T04:43:00.000 | 0 | 1,837,686 | Just use gzip compression, and save 60-70% with 0% effort! | 0 | 2,837 | false | 0 | 1 | Compressing UTF-8(or other 8-bit encoding) to 7 or fewer bits | 1,837,697 |
3 | 6 | 0 | 0 | 2 | 1 | 0 | 0 | I wish to take a file encoded in UTF-8 that doesn't use more than 128 different characters, then move it to a 7-bit encoding to save the 1/8 of space. For example, if I have a 16 MB text file that only uses the first 128(ascii) characters, I would like to shave off the extra bit to reduce the file to 14MB.
How would I go about doing this?
There doesn't seem to be an existing free or proprietary program to do so, so I was thinking I might try and make a simple(if inefficient) one.
The basic idea I have is to make a function from the current hex/decimal/binary values used for each character to the 128 values I would have in the seven bit encoding, then scan through the file and write each modified value to a new file.
So if the file looked like(I'll use a decimal example because I try not to have to think in hex)
127 254 025 212 015 015 132...
It would become
001 002 003 004 005 005 006
If 127 mapped to 001, 254 mapped to 005, etc.
I'm not entirely sure on a couple things, though.
Would this be enough to actually shorten the filesize? I have a bad feeling this would simply leave an extra 0 on the binary string--11011001 might get mapped to 01000001 rather than 1000001, and I won't actually save space.
If this would happen, how do I get rid of the zero?
How do I open the file to read/write in binary/decimal/hex rather than just text?
I've mostly worked with Python, but I can muddle through C if I must.
Thank you. | 0 | python,c,utf-8,compression | 2009-12-03T04:43:00.000 | 0 | 1,837,686 | "this would simply leave an extra 0 on the binary string--11011001 might get mapped to 01000001 rather than 1000001, and I won't actually save space."
Correct. Your plan will do nothing. | 0 | 2,837 | false | 0 | 1 | Compressing UTF-8(or other 8-bit encoding) to 7 or fewer bits | 1,839,384 |
3 | 6 | 0 | -2 | 2 | 1 | -0.066568 | 0 | I wish to take a file encoded in UTF-8 that doesn't use more than 128 different characters, then move it to a 7-bit encoding to save the 1/8 of space. For example, if I have a 16 MB text file that only uses the first 128(ascii) characters, I would like to shave off the extra bit to reduce the file to 14MB.
How would I go about doing this?
There doesn't seem to be an existing free or proprietary program to do so, so I was thinking I might try and make a simple(if inefficient) one.
The basic idea I have is to make a function from the current hex/decimal/binary values used for each character to the 128 values I would have in the seven bit encoding, then scan through the file and write each modified value to a new file.
So if the file looked like(I'll use a decimal example because I try not to have to think in hex)
127 254 025 212 015 015 132...
It would become
001 002 003 004 005 005 006
If 127 mapped to 001, 254 mapped to 005, etc.
I'm not entirely sure on a couple things, though.
Would this be enough to actually shorten the filesize? I have a bad feeling this would simply leave an extra 0 on the binary string--11011001 might get mapped to 01000001 rather than 1000001, and I won't actually save space.
If this would happen, how do I get rid of the zero?
How do I open the file to read/write in binary/decimal/hex rather than just text?
I've mostly worked with Python, but I can muddle through C if I must.
Thank you. | 0 | python,c,utf-8,compression | 2009-12-03T04:43:00.000 | 0 | 1,837,686 | What you need is UTF-7.
Edit: UTF-7 has the advantage of bloating "only" special characters, so if special characters are rare in the input, you get far less bytes than by just converting UTF-8 to 7 bit. That's what UTF-7 is for. | 0 | 2,837 | false | 0 | 1 | Compressing UTF-8(or other 8-bit encoding) to 7 or fewer bits | 1,838,614 |
1 | 1 | 0 | 1 | 0 | 0 | 1.2 | 0 | I'm writing a web app using python with web.py, and I want to implement my own logging system. I'd like to log detailed information about each request that come to python (static files are handled by web servers).
Currently I'm thinking about writing the logs to a pipe. On the other side, there should be cronolog.
My main concern is that will the performance be good? How is the time/resource consumed in piping the logs compared to the normal processing of a request (less than 5 database queries, and page generation from templates)?
Or are there other better approaches? I don't want to write the log file in python because tens of processes will be started by fastcgi. | 0 | python,logging,pipe | 2009-12-03T11:28:00.000 | 1 | 1,839,348 | Pipes are one of the fastest I/O mechanisms available. It's just a shared buffer. Nothing more. If the receiving end of your pipe is totally overwhelmed, you may have an issue. But you have no evidence of that right now.
If you have 10's of processes started by FastCGI, each can have their own independent log file. That's the ideal situation: use Python logging -- make each process have a unique log file.
In the rare event that you need to examine all log files, cat them together for analysis. | 0 | 514 | true | 1 | 1 | python web app logging through pipe? (performance concerned) | 1,839,366 |
1 | 13 | 0 | 1 | 3 | 1 | 0.015383 | 0 | Problem Specification:
Given a directory, I want to iterate through the directory and its non-hidden sub-directories,
and add a whirlpool hash into the non-hidden
file's names.
If the script is re-run it would would replace an old hash with a new one.
<filename>.<extension> ==> <filename>.<a-whirlpool-hash>.<extension>
<filename>.<old-hash>.<extension> ==> <filename>.<new-hash>.<extension>
Question:
a) How would you do this?
b) Out of the all methods available to you, what makes your method most suitable?
Verdict:
Thanks all, I have chosen SeigeX's answer for it's speed and portability.
It is emprically quicker than the other bash variants,
and it worked without alteration on my Mac OS X machine. | 0 | python,perl,bash,hash,batch-processing | 2009-12-03T18:00:00.000 | 1 | 1,841,737 | Hm, interesting problem.
Try the following (the mktest function is just for testing -- TDD for bash! :)
Edit:
Added support for whirlpool hashes.
code cleanup
better quoting of filenames
changed array-syntax for test part-- should now work with most korn-like shells. Note that pdksh does not support :-based parameter expansion (or rather
it means something else)
Note also that when in md5-mode it fails for filenames with whirlpool-like hashes, and
possibly vice-versa.
#!/usr/bin/env bash
#Tested with:
# GNU bash, version 4.0.28(1)-release (x86_64-pc-linux-gnu)
# ksh (AT&T Research) 93s+ 2008-01-31
# mksh @(#)MIRBSD KSH R39 2009/08/01 Debian 39.1-4
# Does not work with pdksh, dash
DEFAULT_SUM="md5"
#Takes a parameter, as root path
# as well as an optional parameter, the hash function to use (md5 or wp for whirlpool).
main()
{
case $2 in
"wp")
export SUM="wp"
;;
"md5")
export SUM="md5"
;;
*)
export SUM=$DEFAULT_SUM
;;
esac
# For all visible files in all visible subfolders, move the file
# to a name including the correct hash:
find $1 -type f -not -regex '.*/\..*' -exec $0 hashmove '{}' \;
}
# Given a file named in $1 with full path, calculate it's hash.
# Output the filname, with the hash inserted before the extention
# (if any) -- or: replace an existing hash with the new one,
# if a hash already exist.
hashname_md5()
{
pathname="$1"
full_hash=`md5sum "$pathname"`
hash=${full_hash:0:32}
filename=`basename "$pathname"`
prefix=${filename%%.*}
suffix=${filename#$prefix}
#If the suffix starts with something that looks like an md5sum,
#remove it:
suffix=`echo $suffix|sed -r 's/\.[a-z0-9]{32}//'`
echo "$prefix.$hash$suffix"
}
# Same as hashname_md5 -- but uses whirlpool hash.
hashname_wp()
{
pathname="$1"
hash=`whirlpool "$pathname"`
filename=`basename "$pathname"`
prefix=${filename%%.*}
suffix=${filename#$prefix}
#If the suffix starts with something that looks like an md5sum,
#remove it:
suffix=`echo $suffix|sed -r 's/\.[a-z0-9]{128}//'`
echo "$prefix.$hash$suffix"
}
#Given a filepath $1, move/rename it to a name including the filehash.
# Try to replace an existing hash, an not move a file if no update is
# needed.
hashmove()
{
pathname="$1"
filename=`basename "$pathname"`
path="${pathname%%/$filename}"
case $SUM in
"wp")
hashname=`hashname_wp "$pathname"`
;;
"md5")
hashname=`hashname_md5 "$pathname"`
;;
*)
echo "Unknown hash requested"
exit 1
;;
esac
if [[ "$filename" != "$hashname" ]]
then
echo "renaming: $pathname => $path/$hashname"
mv "$pathname" "$path/$hashname"
else
echo "$pathname up to date"
fi
}
# Create som testdata under /tmp
mktest()
{
root_dir=$(tempfile)
rm "$root_dir"
mkdir "$root_dir"
i=0
test_files[$((i++))]='test'
test_files[$((i++))]='testfile, no extention or spaces'
test_files[$((i++))]='.hidden'
test_files[$((i++))]='a hidden file'
test_files[$((i++))]='test space'
test_files[$((i++))]='testfile, no extention, spaces in name'
test_files[$((i++))]='test.txt'
test_files[$((i++))]='testfile, extention, no spaces in name'
test_files[$((i++))]='test.ab8e460eac3599549cfaa23a848635aa.txt'
test_files[$((i++))]='testfile, With (wrong) md5sum, no spaces in name'
test_files[$((i++))]='test spaced.ab8e460eac3599549cfaa23a848635aa.txt'
test_files[$((i++))]='testfile, With (wrong) md5sum, spaces in name'
test_files[$((i++))]='test.8072ec03e95a26bb07d6e163c93593283fee032db7265a29e2430004eefda22ce096be3fa189e8988c6ad77a3154af76f582d7e84e3f319b798d369352a63c3d.txt'
test_files[$((i++))]='testfile, With (wrong) whirlpoolhash, no spaces in name'
test_files[$((i++))]='test spaced.8072ec03e95a26bb07d6e163c93593283fee032db7265a29e2430004eefda22ce096be3fa189e8988c6ad77a3154af76f582d7e84e3f319b798d369352a63c3d.txt']
test_files[$((i++))]='testfile, With (wrong) whirlpoolhash, spaces in name'
test_files[$((i++))]='test space.txt'
test_files[$((i++))]='testfile, extention, spaces in name'
test_files[$((i++))]='test multi-space .txt'
test_files[$((i++))]='testfile, extention, multiple consequtive spaces in name'
test_files[$((i++))]='test space.h'
test_files[$((i++))]='testfile, short extention, spaces in name'
test_files[$((i++))]='test space.reallylong'
test_files[$((i++))]='testfile, long extention, spaces in name'
test_files[$((i++))]='test space.reallyreallyreallylong.tst'
test_files[$((i++))]='testfile, long extention, double extention,
might look like hash, spaces in name'
test_files[$((i++))]='utf8test1 - æeiaæå.txt'
test_files[$((i++))]='testfile, extention, utf8 characters, spaces in name'
test_files[$((i++))]='utf8test1 - 漢字.txt'
test_files[$((i++))]='testfile, extention, Japanese utf8 characters, spaces in name'
for s in . sub1 sub2 sub1/sub3 .hidden_dir
do
#note -p not needed as we create dirs top-down
#fails for "." -- but the hack allows us to use a single loop
#for creating testdata in all dirs
mkdir $root_dir/$s
dir=$root_dir/$s
i=0
while [[ $i -lt ${#test_files[*]} ]]
do
filename=${test_files[$((i++))]}
echo ${test_files[$((i++))]} > "$dir/$filename"
done
done
echo "$root_dir"
}
# Run test, given a hash-type as first argument
runtest()
{
sum=$1
root_dir=$(mktest)
echo "created dir: $root_dir"
echo "Running first test with hashtype $sum:"
echo
main $root_dir $sum
echo
echo "Running second test:"
echo
main $root_dir $sum
echo "Updating all files:"
find $root_dir -type f | while read f
do
echo "more content" >> "$f"
done
echo
echo "Running final test:"
echo
main $root_dir $sum
#cleanup:
rm -r $root_dir
}
# Test md5 and whirlpool hashes on generated data.
runtests()
{
runtest md5
runtest wp
}
#For in order to be able to call the script recursively, without splitting off
# functions to separate files:
case "$1" in
'test')
runtests
;;
'hashname')
hashname "$2"
;;
'hashmove')
hashmove "$2"
;;
'run')
main "$2" "$3"
;;
*)
echo "Use with: $0 test - or if you just want to try it on a folder:"
echo " $0 run path (implies md5)"
echo " $0 run md5 path"
echo " $0 run wp path"
;;
esac | 0 | 4,430 | false | 0 | 1 | Hashing Multiple Files | 1,847,365 |
5 | 8 | 0 | 1 | 3 | 1 | 0.024995 | 0 | I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.
Edit: just to add this as an important note, I do mean strictly for linux, not multi-platform.
Edit 2: I'm hoping for objective answers, like a specific project, not a general field of projects, etc. | 0 | php,python,linux,theory | 2009-12-03T19:13:00.000 | 0 | 1,842,208 | If you're doing any multi threading development, pick Python over PHP. | 0 | 640 | false | 0 | 1 | From a coder's perspective, what kind of project should I choose python over php for where both could do the job? | 1,847,687 |
5 | 8 | 0 | 1 | 3 | 1 | 0.024995 | 0 | I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.
Edit: just to add this as an important note, I do mean strictly for linux, not multi-platform.
Edit 2: I'm hoping for objective answers, like a specific project, not a general field of projects, etc. | 0 | php,python,linux,theory | 2009-12-03T19:13:00.000 | 0 | 1,842,208 | My company was contracted to build a web application last year, and the client specified that it should be done in Flex. Now, this application should have been a web application, but we had a unique opportunity to try something new.
We had absolutely no idea what we were doing at the time, but it was a great learning experience. My advice would be to try something new when you get the chance, make mistakes, and continue to learn.
Might be harder if you want to learn Python casually... Try getting someone to pay you for using it. | 0 | 640 | false | 0 | 1 | From a coder's perspective, what kind of project should I choose python over php for where both could do the job? | 1,845,431 |
5 | 8 | 0 | 3 | 3 | 1 | 0.07486 | 0 | I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.
Edit: just to add this as an important note, I do mean strictly for linux, not multi-platform.
Edit 2: I'm hoping for objective answers, like a specific project, not a general field of projects, etc. | 0 | php,python,linux,theory | 2009-12-03T19:13:00.000 | 0 | 1,842,208 | A project you want to maintain over any length of time.
I've had to maintain PHP code and there is something about the fact that you can mix HTML and code that makes PHP stuff a nightmare.
Python has a much higher level of abstraction and makes more maintainable code much easier to write and much more importantly for maintenance - read.
All IMHO of course as this is a rather subjective question. | 0 | 640 | false | 0 | 1 | From a coder's perspective, what kind of project should I choose python over php for where both could do the job? | 1,842,248 |
5 | 8 | 0 | 1 | 3 | 1 | 0.024995 | 0 | I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.
Edit: just to add this as an important note, I do mean strictly for linux, not multi-platform.
Edit 2: I'm hoping for objective answers, like a specific project, not a general field of projects, etc. | 0 | php,python,linux,theory | 2009-12-03T19:13:00.000 | 0 | 1,842,208 | Anything that requires background processing or any significant amount of code that doesn't just show a user a page. Python is really good as a scripting language, and writing a command line Python script is commonplace; writing a PHP script to do command line work is rare. | 0 | 640 | false | 0 | 1 | From a coder's perspective, what kind of project should I choose python over php for where both could do the job? | 1,842,267 |
5 | 8 | 0 | 5 | 3 | 1 | 0.124353 | 0 | I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.
Edit: just to add this as an important note, I do mean strictly for linux, not multi-platform.
Edit 2: I'm hoping for objective answers, like a specific project, not a general field of projects, etc. | 0 | php,python,linux,theory | 2009-12-03T19:13:00.000 | 0 | 1,842,208 | PHP for websites. Python for pretty much anything else, such as commandline tools, long-running scripts, daemons, etcetera. If you're writing a PHP script and you're reaching for functions in the posix extenstion, shared memory or other low-level stuff then that's generally a sign that Python would be better suited. It's not that PHP can't do it, but Python just does it better and less buggy.
Especially when you're venturing into background daemons for your website you'll want to look at Python. PHP has some garbage collection problems in long running processes such as daemons. Also, some functionality is much easier and clearer in Python (e.g. redirecting STDIN, STDOUT and STDERR. PHP misses posix_dup2()). Also, Python has threads :-)
The only time when I now use PHP background daemons for my websites is when they can re-use significant amounts of code (such as with MVC frameworks like CakePHP).
One more advantage of Python is that there are many, many libraries for it, because it's rather easy to create a Python wrapper for a C library. So, Python has libraries that PHP doesn't have (OpenGL, multimedia, etcetera). So if you're into those areas Python becomes the obvious choice. | 0 | 640 | false | 0 | 1 | From a coder's perspective, what kind of project should I choose python over php for where both could do the job? | 1,843,790 |
2 | 4 | 0 | 1 | 9 | 1 | 0.049958 | 0 | Ruby uses require, Python uses import. They're substantially different models, and while I'm more used to the require model, I can see a few places where I think I like import more. I'm curious what things people find particularly easy — or more interestingly, harder than they should be — with each of these models.
In particular, if you were writing a new programming language, how would you design a code-loading mechanism? Which "pros" and "cons" would weigh most heavily on your design choice? | 0 | python,ruby,programming-languages,language-features,language-design | 2009-12-04T20:12:00.000 | 0 | 1,849,376 | Python's import provides a very explicit kind of namespace: the namespace is the path, you don't have to look into files to know what namespace they do their definitions in, and your file is not cluttered with namespace definitions. This makes the namespace scheme of an application simple and fast to understand (just look at the source tree), and avoids simple mistakes like mistyping a namespace declaration.
A nice side effect is every file has its own private namespace, so you don't have to worry about conflicts when naming things.
Sometimes namespaces can get annoying too, having things like some.module.far.far.away.TheClass() everywhere can quickly make your code very long and boring to type. In these cases you can import ... from ... and inject bits of another namespace in the current one. If the injection causes a conflict with the module you are importing in, you can simply rename the thing you imported: from some.other.module import Bar as BarFromOtherModule.
Python is still vulnerable to problems like circular imports, but it's the application design more than the language that has to be blamed in these cases.
So python took C++ namespace and #include and largely extended on it. On the other hand I don't see in which way ruby's module and require add anything new to these, and you have the exact same horrible problems like global namespace cluttering. | 0 | 6,271 | false | 0 | 1 | What are the advantages and disadvantages of the require vs. import methods of loading code? | 1,871,126 |
2 | 4 | 0 | 4 | 9 | 1 | 0.197375 | 0 | Ruby uses require, Python uses import. They're substantially different models, and while I'm more used to the require model, I can see a few places where I think I like import more. I'm curious what things people find particularly easy — or more interestingly, harder than they should be — with each of these models.
In particular, if you were writing a new programming language, how would you design a code-loading mechanism? Which "pros" and "cons" would weigh most heavily on your design choice? | 0 | python,ruby,programming-languages,language-features,language-design | 2009-12-04T20:12:00.000 | 0 | 1,849,376 | A nice property of require is that it is actually a method defined in Kernel. Thus you can override it and implement your own packaging system for Ruby, which is what e.g. Rubygems does!
PS: I am not selling monkey patching here, but the fact that Ruby's package system can be rewritten by the user (even to work like python's system). When you write a new programming language, you cannot get everything right. Thus if your import mechanism is fully extensible (into totally all directions) from within the language, you do your future users the best service. A language that is not fully extensible from within itself is an evolutionary dead-end. I'd say this is one of the things Matz got right with Ruby. | 0 | 6,271 | false | 0 | 1 | What are the advantages and disadvantages of the require vs. import methods of loading code? | 1,870,801 |
1 | 2 | 0 | 1 | 2 | 0 | 0.099668 | 0 | Is there a blog/forum/listserv that is equivalent to RubyQuiz.com for the Python language? | 0 | python | 2009-12-05T06:52:00.000 | 0 | 1,851,396 | At the risk of stating the obvious, why not just do the rubyquiz examples in python. Those exercises as well as others aren't tied to a language - you're just as well off just doing projecteuler problems in python rather than searching for python-specific puzzles. A puzzle is a puzzle a language is just a tool to solve it. | 0 | 463 | false | 1 | 1 | Ruby Quiz for Python | 1,852,706 |
2 | 2 | 1 | 2 | 4 | 1 | 1.2 | 0 | I know that IronPython is a dynamically typed language so what I am asking sounds pretty stupid, but is it possible to do something with an IronPython script to make sure the changing of the CLR libraries it references will not result in a runtime error when the script is executed?
The reason I ask is that I have written a library referenced by IronPython scripts in C#, and I want a way to know if I've broken any of the interfaces used by the IronPhon scripts when I change the C# library. This is easy to do with another C# project by just compiling the code and seeing compile errors, but this doesn't seem to work when compiling the IronPython scripts.
Any ideas? | 0 | ironpython,dynamic-language-runtime | 2009-12-05T17:51:00.000 | 0 | 1,852,897 | No, there is no way to statically verify at compile time that the interface changes have not broken your IronPython code. This is the nature of dynamic languages. Such errors are instead presented at runtime | 0 | 244 | true | 0 | 1 | IronPython compile-time checks against CLR libraries? | 1,852,956 |
2 | 2 | 1 | 1 | 4 | 1 | 0.099668 | 0 | I know that IronPython is a dynamically typed language so what I am asking sounds pretty stupid, but is it possible to do something with an IronPython script to make sure the changing of the CLR libraries it references will not result in a runtime error when the script is executed?
The reason I ask is that I have written a library referenced by IronPython scripts in C#, and I want a way to know if I've broken any of the interfaces used by the IronPhon scripts when I change the C# library. This is easy to do with another C# project by just compiling the code and seeing compile errors, but this doesn't seem to work when compiling the IronPython scripts.
Any ideas? | 0 | ironpython,dynamic-language-runtime | 2009-12-05T17:51:00.000 | 0 | 1,852,897 | A good set of fast running unit tests would be a good alternative to compile time checking. | 0 | 244 | false | 0 | 1 | IronPython compile-time checks against CLR libraries? | 1,866,436 |
1 | 4 | 0 | 0 | 2 | 0 | 0 | 0 | I've been researching this on and off for a number of months now, but I am incapable of finding clear direction.
My goal is to have a page which has a form on it and a graph on it. The form can be filled out and then sent to the CGI Python script (yeah, I'll move to WSGI or fast_cgi later, I'm starting simple!) I'd like the form to be able to send multiple times, so the user can update the graph, but I don't want the page to reload every time it doe that. I have a form and a graph now, but they're on separate pages and work as a conventional script.
I'd like to avoid ALL frameworks except JQuery (as I love it, don't like dealing with the quirks of different browsers, etc).
A nudge in the right direction(s) is all I'm asking for here, or be as specific as you care to.
(I've found similar guides to doing this in PHP, I believe, but for some reason, they didn't serve my purpose.)
EDIT: The graph is generated using Flot (a JQuery plugin) using points generated from the form input and processed in the Python script. The Python script prints the Javascript which produces the graph in the end. It could all be done in Javascript, but I want the heavier stuff to be handled server-side, hence the Python.
Thanks! | 0 | javascript,python,ajax | 2009-12-06T15:59:00.000 | 0 | 1,855,748 | Update img.src attribute in onsubmit() handler.
img.src url points to your Python script that should generate an image in response.
onsubmit() for your form could be registered and written using JQuery. | 0 | 1,212 | false | 1 | 1 | Dynamically Refreshed Pages produced by Python | 1,855,787 |
4 | 7 | 0 | 4 | 4 | 0 | 0.113791 | 0 | I thought it would be a good idea to compile a list of things to watch out for when making a Python app portable. There are a lot of subtle 'gotchas' in portability that are only discovered through experience and thorough testing; there needs to be some sort of list addressing the more common ones.
Please post one gotcha (with its fix) per comment. | 0 | python,portability | 2009-12-10T18:41:00.000 | 0 | 1,883,118 | If you deal with binary file formats in Python, note that the struct and array modules uses machine dependent size and endianness. struct can be used portably by always using < or > in the format string. array can't. It will probably be portable for arrays of bytes, but the documentation makes no such guarantee. | 0 | 2,875 | false | 0 | 1 | Big List Of Portability in Python | 1,883,501 |
4 | 7 | 0 | 2 | 4 | 0 | 0.057081 | 0 | I thought it would be a good idea to compile a list of things to watch out for when making a Python app portable. There are a lot of subtle 'gotchas' in portability that are only discovered through experience and thorough testing; there needs to be some sort of list addressing the more common ones.
Please post one gotcha (with its fix) per comment. | 0 | python,portability | 2009-12-10T18:41:00.000 | 0 | 1,883,118 | Getting away from the syntax side of things, I think the biggest thing to watch out for is that typically when people think of python, they might not think of all the libraries it is composed of.
Many python packages depend on C libraries which may or may not be cross platform compatible. In addition, Python runs under Java through Jython, and .Net through IronPython. Unless libraries are written in pure python, they will not, in many cases, work on anything other than the C based version of python. | 0 | 2,875 | false | 0 | 1 | Big List Of Portability in Python | 1,883,350 |
4 | 7 | 0 | 1 | 4 | 0 | 0.028564 | 0 | I thought it would be a good idea to compile a list of things to watch out for when making a Python app portable. There are a lot of subtle 'gotchas' in portability that are only discovered through experience and thorough testing; there needs to be some sort of list addressing the more common ones.
Please post one gotcha (with its fix) per comment. | 0 | python,portability | 2009-12-10T18:41:00.000 | 0 | 1,883,118 | I'll start off:
Windows uses backslashes for path separators --> '\'
Unix uses forward slashes for path separators --> '/'
The os module comes with os.sep, which contains the path separator for the current platform that the script is being run on. Use os.sep instead of forward or back slashes. os.path.join will join two or more path components this way. | 0 | 2,875 | false | 0 | 1 | Big List Of Portability in Python | 1,883,137 |
4 | 7 | 0 | 2 | 4 | 0 | 0.057081 | 0 | I thought it would be a good idea to compile a list of things to watch out for when making a Python app portable. There are a lot of subtle 'gotchas' in portability that are only discovered through experience and thorough testing; there needs to be some sort of list addressing the more common ones.
Please post one gotcha (with its fix) per comment. | 0 | python,portability | 2009-12-10T18:41:00.000 | 0 | 1,883,118 | Some modules are not cross-platform. Two that come to mind are both curses (Linux) and msvcrt (Windows). The fix to this simple problem is simply not to use them but find an alternative instead. | 0 | 2,875 | false | 0 | 1 | Big List Of Portability in Python | 1,883,817 |
5 | 9 | 1 | 8 | 20 | 0 | 1 | 0 | I have been programming in Python for a while now, and I'd like to learn a more "hireable" language like Java or the C/C++/C# family. I'm acquainted with (though not necessarily good at) all of them. I'm leaning towards Java because it runs just about everywhere, and I'd like to start developing for the Android.
Coming from a dynamic language, what is the best way for me to learn Java? Or should I learn a C based language instead? | 0 | java,python | 2009-12-10T19:41:00.000 | 0 | 1,883,455 | Java and C# will be less of a step away from Python than would C or C++ because Java, C#, and Python all have automatic memory management. A good Java book is Thinking in Java by Bruce Eckel. It starts at an introductory level, but also has a lot of depth.
The big difference with the language coming from Python is the fact that all variables are typed. The other hard thing with Java has to do with the bewildering array of Java APIs out there. The fact that you are interested in Android is an advantage here. After becoming comfortable with the core language, I suggest you start learning the Android API and focus on becoming an Android expert. I think Android will be a growing market for a while.
Good luck! | 0 | 18,209 | false | 0 | 1 | Learn Java from Python background | 1,883,690 |
5 | 9 | 1 | 0 | 20 | 0 | 0 | 0 | I have been programming in Python for a while now, and I'd like to learn a more "hireable" language like Java or the C/C++/C# family. I'm acquainted with (though not necessarily good at) all of them. I'm leaning towards Java because it runs just about everywhere, and I'd like to start developing for the Android.
Coming from a dynamic language, what is the best way for me to learn Java? Or should I learn a C based language instead? | 0 | java,python | 2009-12-10T19:41:00.000 | 0 | 1,883,455 | I don't think you should use a special way to learn Java because you know Python. Just start with HelloWorld.java and move on step by step. Your basic skills in programming will help you. | 0 | 18,209 | false | 0 | 1 | Learn Java from Python background | 1,883,538 |
5 | 9 | 1 | 0 | 20 | 0 | 0 | 0 | I have been programming in Python for a while now, and I'd like to learn a more "hireable" language like Java or the C/C++/C# family. I'm acquainted with (though not necessarily good at) all of them. I'm leaning towards Java because it runs just about everywhere, and I'd like to start developing for the Android.
Coming from a dynamic language, what is the best way for me to learn Java? Or should I learn a C based language instead? | 0 | java,python | 2009-12-10T19:41:00.000 | 0 | 1,883,455 | I suppose one could ease his/her way into .NET and Java by starting with IronPython and Jython respectively. This will not teach you the new language syntax but open up respective libraries so you can explore what is "out there", learn development tools, build process etc. Syntax is by far the easiest to switch but the know-how and best practices in each language are not. | 0 | 18,209 | false | 0 | 1 | Learn Java from Python background | 1,884,743 |
5 | 9 | 1 | 0 | 20 | 0 | 0 | 0 | I have been programming in Python for a while now, and I'd like to learn a more "hireable" language like Java or the C/C++/C# family. I'm acquainted with (though not necessarily good at) all of them. I'm leaning towards Java because it runs just about everywhere, and I'd like to start developing for the Android.
Coming from a dynamic language, what is the best way for me to learn Java? Or should I learn a C based language instead? | 0 | java,python | 2009-12-10T19:41:00.000 | 0 | 1,883,455 | 1) It depends what you would do with an "hireable" language. For instance, if you were interested in programming web applications and distributed/client/server app, Java would be a good choice.
C# is maybe a bit less client / server oriented, and maybe more valuable for small non IT companies and for most retail software companies.
C and C++ are still great languages, but are more "system", embeded and "critical apps" oriented. And they are not suitable to be runned on differents mobile phones.
2) The best way to learn java, according to me, is firstable to learn the basics, then look for more specialized stuff like J2ME and Android software framework. | 0 | 18,209 | false | 0 | 1 | Learn Java from Python background | 1,883,705 |
5 | 9 | 1 | 9 | 20 | 0 | 1 | 0 | I have been programming in Python for a while now, and I'd like to learn a more "hireable" language like Java or the C/C++/C# family. I'm acquainted with (though not necessarily good at) all of them. I'm leaning towards Java because it runs just about everywhere, and I'd like to start developing for the Android.
Coming from a dynamic language, what is the best way for me to learn Java? Or should I learn a C based language instead? | 0 | java,python | 2009-12-10T19:41:00.000 | 0 | 1,883,455 | I would take a project you've implemented in Python and try converting it to Java. Since you already know basic programming fundamentals, it'll probably be easier if you take things you know how to do and figure out how you'd do the same sort of operations in Java (or whatever new language you want to learn).
In the end, the only way to learn to write code, is to write more code. | 0 | 18,209 | false | 0 | 1 | Learn Java from Python background | 1,883,585 |
4 | 4 | 0 | 0 | 1 | 1 | 0 | 0 | I'm learning about Pylons and I've read a few tutorials, but none of them have addressed collaboration practices. Starting on a practice project. I'd like to keep my code in a revision-control system (Git, specifically) as if it were an open-source project with multiple developers, in order to practice that aspect of Pylons development as well.
I'm wondering what I should do with the development.ini file that was generated by Paster as part of my new application. On one hand, it contains lots of settings that other develpers wouldn't want to have to recreate by hand, so it seems like it ought to be stored in my Git repository so that other developers can access it. On the other hand, some of the settings, such as the database connection URL, are specific to one person's development environment and wouldn't make sense to share with others.
What do real-world Pylons applications do with this file? | 0 | python,pylons | 2009-12-11T06:29:00.000 | 0 | 1,886,192 | You should check in development.ini. Most developers are smart enough to realize that if they want to run your application they need to make some tweaks. The development.ini will serve as a template. A file that has the database configured incorrectly is still useful since I can see that the system is trying to connect to the database and failing.
Later on you will be making files such as development.ini, staging.ini, and production.ini. This will help when you move environments. | 0 | 358 | false | 0 | 1 | Should Pylons' development.ini be checked in? | 1,894,559 |
4 | 4 | 0 | 2 | 1 | 1 | 0.099668 | 0 | I'm learning about Pylons and I've read a few tutorials, but none of them have addressed collaboration practices. Starting on a practice project. I'd like to keep my code in a revision-control system (Git, specifically) as if it were an open-source project with multiple developers, in order to practice that aspect of Pylons development as well.
I'm wondering what I should do with the development.ini file that was generated by Paster as part of my new application. On one hand, it contains lots of settings that other develpers wouldn't want to have to recreate by hand, so it seems like it ought to be stored in my Git repository so that other developers can access it. On the other hand, some of the settings, such as the database connection URL, are specific to one person's development environment and wouldn't make sense to share with others.
What do real-world Pylons applications do with this file? | 0 | python,pylons | 2009-12-11T06:29:00.000 | 0 | 1,886,192 | On a team development, we make an effort to ensure everyone has a common development environment, or we make adjustments to things (like database URLs) to allow people on different environments (we do Mac, Windows, and Linux) to share all files.
And our Pylons development.ini files are committed to subversion, just like everything else. | 0 | 358 | false | 0 | 1 | Should Pylons' development.ini be checked in? | 1,891,883 |
4 | 4 | 0 | 2 | 1 | 1 | 1.2 | 0 | I'm learning about Pylons and I've read a few tutorials, but none of them have addressed collaboration practices. Starting on a practice project. I'd like to keep my code in a revision-control system (Git, specifically) as if it were an open-source project with multiple developers, in order to practice that aspect of Pylons development as well.
I'm wondering what I should do with the development.ini file that was generated by Paster as part of my new application. On one hand, it contains lots of settings that other develpers wouldn't want to have to recreate by hand, so it seems like it ought to be stored in my Git repository so that other developers can access it. On the other hand, some of the settings, such as the database connection URL, are specific to one person's development environment and wouldn't make sense to share with others.
What do real-world Pylons applications do with this file? | 0 | python,pylons | 2009-12-11T06:29:00.000 | 0 | 1,886,192 | You could check it in as sample.ini for example so that everyone can copy to their own development.ini and modify as needed | 0 | 358 | true | 0 | 1 | Should Pylons' development.ini be checked in? | 1,886,486 |
4 | 4 | 0 | 0 | 1 | 1 | 0 | 0 | I'm learning about Pylons and I've read a few tutorials, but none of them have addressed collaboration practices. Starting on a practice project. I'd like to keep my code in a revision-control system (Git, specifically) as if it were an open-source project with multiple developers, in order to practice that aspect of Pylons development as well.
I'm wondering what I should do with the development.ini file that was generated by Paster as part of my new application. On one hand, it contains lots of settings that other develpers wouldn't want to have to recreate by hand, so it seems like it ought to be stored in my Git repository so that other developers can access it. On the other hand, some of the settings, such as the database connection URL, are specific to one person's development environment and wouldn't make sense to share with others.
What do real-world Pylons applications do with this file? | 0 | python,pylons | 2009-12-11T06:29:00.000 | 0 | 1,886,192 | The most important aspect of collaboration is communicating with your teammates. See if you can come to a quick consensus on how to handle the situation.
My suggestion though, would be to pass around your completed ini file for the other devs to modify for their own purposes. If there are a lot of hand tuned settings that they won't want (or need) to change, then they shouldn't have to do the work. At the end of the day though, they'll need to write the settings somehow. | 0 | 358 | false | 0 | 1 | Should Pylons' development.ini be checked in? | 1,886,225 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.