Python is a dynamic, high-level language. Its design focuses on clear syntax, an intuitive approach to object-oriented programming, and making the right way to do things obvious. Python supports modules, exceptions, had an extensive standard module library. Python can also be embedded in other ...

learn more… | top users | synonyms (1)

48
votes
8answers
10k views

Defensive Programming vs Exception Handling?

I'm working through the book "Head First Python" (it's my language to learn this year) and I got to a section where they argue about two code techniques: Defensive coding vs Exception handling. Here ...
50
votes
7answers
61k views

How do I learn Python from zero to web development? [closed]

I am looking into learning Python for web development. Assuming I already have some basic web development experience with Java (JSP/Servlets), I'm already familiar with web design (HTML, CSS, JS), ...
39
votes
7answers
4k views

Are small amounts of functional programming understandable by non-FP people?

Case: I'm working at a company, writing an application in Python that is handling a lot of data in arrays. I'm the only developer of this program at the moment, but it will probably be ...
78
votes
9answers
40k views

Why is Python used for high-performance/scientific computing (but Ruby isn't)?

There's a quote from a PyCon 2011 talk that goes: At least in our shop (Argonne National Laboratory) we have three accepted languages for scientific computing. In this order they are C/C++, ...
-1
votes
1answer
325 views

How do I create every permutation [closed]

I have a list of letters, this is just an example list: ['a','b','c','d','e'] How do I compute every combination of the list? The letters cannot repeat, for example. a,b,c,d,e a,c,b,d,e a,c,d,b,e ...
140
votes
9answers
34k views

Why do people hesitate to use Python 3?

Python 3 was released in December 2008. A lot of time has passed since then but still today many developers hesitate to use Python 3. Even popular frameworks like Django are not compatible with Python ...
56
votes
7answers
41k views

Why use try … finally without a catch clause?

The classical way to program is with try ... catch. When is it appropriate to use try without catch? In Python the following appears legal and can make sense: try: #do work finally: #do ...
14
votes
6answers
3k views

Best practices in comment writing and documentation

Commenting nowadays is easier than ever. In Java, there are some nice techniques for linking comments to classes, and Java IDEs are good at making comment shells for you. Languages like Clojure even ...
6
votes
6answers
4k views

Why should we use low level languages if a high level one like python can do almost everything? [closed]

I know python is not suitable for things like microcontrolers, make drivers etc, but besides that, you can do everything using python, companys get stuck with speed optimizations for real hard time ...
18
votes
9answers
7k views

Is it essential to learn algorithms to be a real programmer? [closed]

I'm a PHP programmer, and until now I have not needed to learn algorithms... Now I'm start learning Python (a real programming language), because I need to use matplotlib. Does it make sense to start ...
10
votes
6answers
628 views

As a beginning programmer, should I favor building my own libraries over using 3rd-party libraries?

As a beginning Python programmer, is it a good idea to build and understand my own libraries before jumping to advanced 3rd-party libraries that contains the functionality I need? Some projects (e.g. ...
16
votes
1answer
591 views

What are the problems python 3 new features solve? [on hold]

Python 3 new features say: we’re mostly fixing well-known annoyances and warts, and removing a lot of old cruft It mentions what is different (the fix) but not why (the problems). I have have ...
18
votes
7answers
5k views

Learning to program in C (coming from Python) [closed]

If this is the wrong place to ask this question, please let me know. I'm a Python programmer by occupation. I would love to learn C. Indeed, I have tried many times, but I always get discouraged. In ...
35
votes
5answers
3k views

Java dev learning Python: what concepts do I need to wrap my head around?

Background: I've run through a few tutorials and written some small projects. All is going well enough using Google and StackOverflow. Several times in the last few days I've found myself wondering ...
35
votes
4answers
2k views

Python Forgiveness vs. Permission and Duck Typing

In Python, I often hear that it is better to "beg forgiveness" (exception catching) instead of "ask permission" (type/condition checking). In regards to enforcing duck typing in Python, is this try: ...
22
votes
4answers
27k views

Is Python Interpreted or Compiled?

This is just a wondering I had while reading about interpreted and compiled languages. Ruby is no doubt an interpreted language, since source code is compiled by an interpreter at the point of ...
21
votes
8answers
18k views

Ruby or Python? [closed]

This question is extremely subjective and open-ended. It might even sound like something I should just research for myself and make my own decision. But I'd like to put it out there and get some ...
22
votes
7answers
18k views

Should we use python 2.6 or 2.7 or 3.x? [closed]

The version of python which I am using is 2.6, and there is a 2.7 and 3.x. Usually I use python for some trivial program/snippet. I realize there are some major difference between 2.x and 3.x. I would ...
21
votes
3answers
4k views

Why aren't there explicit access modifiers in Python:

If 'explicit is better than implicit', why aren't there explicit access modifiers in Python: Public, Protected, Private, etc.? I know that the idea is that the programmer should know what to do ...
16
votes
8answers
1k views

What are good unit tests to cover the use case of rolling a die?

I'm trying to get to grips with unit testing. Say we have a die which can has a default number of sides equal to 6 (but can be 4, 5 sided etc.): import random class Die(): def __init__(self, ...
13
votes
4answers
4k views

Best practices for execution of untrusted code

I have a project where I need to allow users to run arbitrary, untrusted python code (a bit like this) against my server. I'm fairly new to python and I'd like to avoid making any mistakes that ...
15
votes
7answers
6k views

Python productivity VS Java Productivity

Over on SO I came across a question regarding which platform, Java or Python is best for developing on Google AppEngine. Many people were boasting of the increased productivity gained from using ...
15
votes
4answers
6k views

Why doesn't Python allow multi-line lambdas?

Can someone explain the concrete reasons why BDFL choose to make Python lambdas single line? This is good: lambda x: x**x This results in an error: lambda x: x**x I understand that making ...
7
votes
9answers
1k views

How does one become proficient in a language and its idioms? [closed]

I'm a recent graduate and there are a few (three generally) languages I switch between based on the requirement. What I've found is I always have to look up syntax whenever I code. I know I'm not ...
3
votes
2answers
878 views

Why do ruby and python seem to have more community contribution than PHP? [closed]

In a recent blog post by Roy Osherove, it is pointed out that his switch from primarily .Net development to ruby development has seen a huge difference in community involvement and really enjoys it. ...
1
vote
4answers
580 views

Multiple attribution in Python, JS, …?

I accidentally discovered this a=b=c=d=e=f=2 in python(2.7)(and JavaScript a few minutes later) interpreter . Is this a feature or just the way the interpreter works, if is a feature how it is ...
18
votes
5answers
2k views

What does Tim Peters mean by “complex is better than complicated”? [closed]

In Tim Peters's poem "The Zen of Python" (PEP 20), there is a line that goes: Complex is better than complicated. I like the theme of the poem, but this particular line has always vexed me. What ...
6
votes
6answers
3k views

How does rapid prototyping fit into an agile methodology?

I work for a large company, which dictates the use of agile processes. For example, for our projects, we use cloud-based services that are specifically targeted at managing agile development. The ...
6
votes
3answers
568 views

What are the challenges related to typing in writing a compiler for a dynamically typed language?

In this talk, Guido van Rossum is talking (27:30) about attempts to write a compiler for Python code, commenting on it saying: turns out it's not so easy to write a compiler that maintains all the ...
6
votes
2answers
699 views

Why does the word “Pythonic” exist? [closed]

Honestly, I hate the word "Pythonic" -- it's used as a simple synonym of "good" in many circles, and I think that's pretentious. Those who use it are silently saying that good code cannot be written ...
4
votes
3answers
1k views

Python lower_case_with_underscores style convention: underscores not popular?

PEP8 recommends using lowercase, with words separated by underscores as necessary to improve readability for variable and function names. I've seen this interpreted as ...
7
votes
2answers
168 views

When profiling a function for time use, what information is desirable?

I'm writing a program similar to Python's timeit module. The idea is to time a function by executing it anywhere from 10 to 100,000 times depending on how long it takes and then report results. I've ...
6
votes
2answers
218 views

Version control for code that contains student exercises

I have a fairly substantial Python project that I have developed as an educational endeavor. The version of the code that shall be given to students has exercises throughout, in the form of code that ...
5
votes
2answers
409 views

Writing functional tests for a legacy project

I am trying to add a couple of tests to a legacy C project. The project basically consists of a command line tool that prints something to stdout every time an event happens. Now, since writing unit ...
1
vote
3answers
242 views

How do I test my code in Python other than by doing it by hand?

I am used to user testing in Java, and I also manually test each section of code I write, but now, I want to automate it. There is no GUI for this project, so user testing is not required and I can ...
-1
votes
1answer
186 views

Unevenly distributed random number generation [duplicate]

Let's say I have to generate random number from 1 to 100, however, the probability of each number is not 1/100, but a predefined probability. How to generate that number? I use Ruby/Python.
71
votes
8answers
10k views

Are there any design patterns that are unnecessary in dynamic languages like Python?

I've started reading the design pattern book by the GoF. Some patterns seem very similar with only minor conceptual differences. Do you think out of the many patterns some are unnecessary in a ...
106
votes
15answers
16k views

Is it always a best practice to write a function for anything that needs to repeat twice?

For myself, I can't wait to write a function when I need to do something more than twice. But when it comes to the things that only appear twice, it's a bit more tricky. For code that needs more than ...
69
votes
6answers
7k views

Why was Python's popularity so sudden? [closed]

Python first appeared in 1991, but it was somewhat unknown until 2004, if the TIOBE rankings quantify anything meaningful. What happened? What caused the interest in this 13 year old language to go ...
36
votes
16answers
26k views

Why such popularity with Python? [closed]

Other than being annoyed at whitespace as syntax, I'm not a hater, I just don't get the fascination with Python. I appreciate the poetry of Perl, and have programmed beautiful web services in bash ...
39
votes
8answers
8k views

How can I learn to effectively write Pythonic code?

Doing a google search for "pythonic" reveals a wide range of interpretations. The wikipedia page says: A common neologism in the Python community is pythonic, which can have a wide range of ...
28
votes
8answers
4k views

Is the algorithm more important than the programming language?

During the current (2013) Google Code Jam contest, there was a problem that took C++ and Java people 200+ lines of code as compared to Python people that solved the same problem only using 40 lines of ...
33
votes
6answers
24k views

'import module' vs. 'from module import function'

I have always been using this method: from sys import argv and use argv with just argv. But there is a convention of using this: import sys and using the argv by sys.argv The second method ...
9
votes
5answers
8k views

Moving to Python (SciPy and NumPy) for Scientific Computing [duplicate]

Just read a presentation about using Python for Scientific Computing. I am currently using MATLAB (student license FTW, which will expire when I graduate soon). So I was wondering how matured SciPy ...
20
votes
11answers
4k views

If we can do functional programming with Python, do we need a specific functional programming language? [closed]

Using generators and lambda, we can do functional programming with Python. You can also achieve the same thing with Ruby. So the question is: why do we need specific functional programming languages ...
17
votes
8answers
5k views

I feel stuck in the center of Python, How to get past beginner

I really apologize if this doesn't follow the S.O rules but I need a little help, I personally still classify myself as a beginner in python, Yet I've wrote a very small and VERY SURE impractical ...
9
votes
4answers
11k views

Java or Python for internet application? [closed]

In choosing a technology for internet applications where the number of users may scale over time, which one should we consider: Java or Python? What are the considerations in choosing one and not the ...
5
votes
4answers
1k views

Learning Python is good? [duplicate]

Possible Duplicate: Is Python worth learning? Is it a useful tool? Recently I have seen some videos from MIT on computer programming topics. I found it's really worth watching. Especially ...
8
votes
2answers
10k views

Open source projects, how to choose?

I would like to join an open source project since I think I am good enough at programming to progress onto reading others code and to modify it. But the problem is, how would I choose an open source ...
16
votes
5answers
10k views

How difficult is Python and Django to pick up for a Java/.NET web developer? [closed]

I just started a new job a couple months ago at a small company where I am currently leading all development efforts present and future. I personally have years of experience in software design and ...