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)

117
votes
15answers
18k views

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

Myself, I can't wait to write a function when I need to do something more than twice. But when it comes to things that only appear twice, it's a bit more tricky. For code that needs more than two ...
54
votes
6answers
52k 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 ...
56
votes
1answer
39k views

Module vs. Package?

Whenever I do from 'x' import 'y' I was wondering which one is considered the 'module' and which is the 'package', and why it isn't the other way around?
73
votes
6answers
9k 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 ...
43
votes
8answers
11k 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 ...
41
votes
16answers
38k 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 ...
9
votes
5answers
11k 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 ...
19
votes
11answers
5k 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
9answers
10k views

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

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 ...
8
votes
6answers
7k views

What are some characteristics of Python that makes it unique as its own language? [closed]

What are some characteristics of Python that makes it unique as its own language? I'm looking for any sort of characteristics ranging from good to bad, useful to hindrance, syntax to real-world usage, ...
10
votes
3answers
6k views

Differences between “Java OOP” and “Pythonic OOP”? [closed]

I started with ActionScript 2.0 and then went on with Java. I have learned, or at least used, a bunch of languages since then, including Python (probably my favorite). I'm afraid that my style of ...
3
votes
4answers
9k views

Which language is the most flexible for scraping websites? [closed]

I'm new to programming. I know a little python and a little objective c, and I've been going through tutorials for each. Then it occurred to me, I need to know which language is more flexible (python, ...
9
votes
10answers
56k views

How long would it take to learn Python? [closed]

I have decided to take the time out after work to learn Python. Python appeals to me because at work (Web and eLearning Company), I have to follow out very repetitive tasks like delete all these tags, ...
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 ...
20
votes
3answers
808 views

How do I express subtle relationships in my data?

"A" is related to "B" and "C". How do I show that "B" and "C" might, by this context, be related as well? Example: Here are a few headlines about a recent Broadway play: David Mamet's Glengarry ...
7
votes
2answers
11k views

Open source projects, how to choose? [closed]

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 ...
5
votes
10answers
5k views

Newbie, deciding Python or Erlang [closed]

I'm a Administrator (unix, Linux and some windows apps such as Exchange) by experience and have never worked on any programming language besides C# and scripting on Bash and lately on powershell. I'm ...
2
votes
7answers
1k views

tips, guidelines, points to remember for rendering professional code? [closed]

I'm talking about giving clients professional looking code. The whole nine yards, everything you hardcore professional highly experienced programmers here probably do when coding freelance or for the ...
24
votes
4answers
16k views

Purpose of `return self` from a class method?

I came across something like this in an open-source project. Methods that modify instance attributes return a reference to the instance. Would you trust code that is written like this? class ...
15
votes
2answers
4k views

SQLite with two python processes accessing it: one reading, one writing

I'm developing a small system with two components: one polls data from an internet resource and translates it into sql data to persist it locally; the second one reads that sql data from the local ...
8
votes
5answers
2k views

Algorithm for flattening overlapping ranges

I am looking for a nice way of flattening (splitting) a list of potentially-overlapping numeric ranges. The problem is very similar to that of this question: Fastest way to split overlapping date ...
8
votes
4answers
2k views

When to import names into the global namespace? (using x::y, from x import y etc.)

I've been programming in various languages for about 10 years now. And I still haven't figured out when it is a good idea to import something into the global namespace (using x::y in C++, from x ...
5
votes
5answers
4k views

When should use of database be preferred over parsing data from a text file?

I was making a Python program to measure the growth of codereview.SE. My approach was to get the "Site stats" shown on the front page and store them on my hard drive. I plan to do this once every day. ...
4
votes
4answers
767 views

How to familiarize myself with Python [closed]

I'm a Python beginner. I started programming with Python 1.5 months back. I downloaded the Python docs and read some parts of the tutorial. I have been programming on codechef.com and solving ...
2
votes
1answer
420 views

How to approach web app development?

I have been going through Flask and it seems that now I have a decent understanding to go ahead and build a web application. However I want to know how would I approach the problem. For eg: I decide ...
29
votes
4answers
3k views

Concrete examples of Python's “only one way to do it” maxim [closed]

I am learning Python and am intrigued by the following point in PEP 20 The Zen of Python: There should be one-- and preferably only one --obvious way to do it. Although that way may not be ...
11
votes
4answers
2k views

Python decorators and Lisp macros

When looking Python decorators someone made the statement, that they are as powerful as Lisp macros (particularly Clojure). Looking at the examples given in PEP 318 it looks to me as if they are just ...
9
votes
2answers
389 views

Why don't Python and Ruby make a distinction between declaring and assigning a value to variables?

Two of the most popular dynamically typed scripting languages, Python and Ruby, do not make a distinction in syntax between the declaration of a variable and assignation of a value to it. That is in ...
8
votes
1answer
2k views

Duck typing, data validation and assertive programming in Python

About duck typing: Duck typing is aided by habitually not testing for the type of arguments in method and function bodies, relying on documentation, clear code and testing to ensure correct use. ...
6
votes
1answer
3k views

Is it possible to use python as a shell replacement? [duplicate]

Recently I was looking at python's shutil and subprocess etc... And I started wondering: wouldn't it be ok to use python instead of e.g. bash? What am I missing?
6
votes
15answers
3k views

Python and only Python for almost any programming tasks! [closed]

Am I wrong if I think that Python is all I need to master, in order to solve most of the common programming tasks? EDIT I'm not OK with learning new programming languages if they don't teach me new ...
5
votes
4answers
2k views

How does Python compile some its code in C?

I read that some constructs of Python are more efficient because they are compiled in C. https://wiki.python.org/moin/PythonSpeed/PerformanceTips Some of the examples used were map() and filter(). I ...
1
vote
1answer
405 views

Is circular Dependency Injection a good practice?

I'm trying the Dependency Injection pattern in some new classes, more specifically in a Transaction System and stumbled into a dilemma. I have a Person class with a create_new_transaction method, and ...
0
votes
3answers
334 views

How to convert this recursive problem to iterative? Line Simplification algorithm fails to run due to Maximum Recursion Depth being hit

I am implementing the Douglas, Peucker's Line Simplification algorithm in Python. I started with this implementation. However, it fails to run in Python due to Maximum Recursion Depth being hit. How ...
12
votes
7answers
959 views

Thinking of simultaneously coding the same project in two languages. Good Idea? [closed]

Is this a good way to learn a new language? Or to develop a preference of one language? I was thinking of coding a project in both Python and Java. The only foreseeable problem is trying to transfer ...
11
votes
2answers
1k views

Object oriented vs vector based programming

I am torn between object oriented and vector based design. I love the abilities, structure and safety that objects give to the whole architecture. But at the same time, speed is very important to me, ...
10
votes
3answers
2k views

What are “class methods” and “instance methods”, in Python?

There has been a discussion in chat relating to a question (the question itself being irrelevant to this one), that has revealed I may not know Python whatsoever. In my mind, although terminology ...
7
votes
9answers
5k views

Is there any good reason for someone who knows Python to learn Perl? [closed]

Reading the answers to Python vs. Perl in ten years time here on SE, most people seem to say go with Python. I agree (sorry Perl fans ;-) ). I already know Python, and I think it is a very good ...
5
votes
3answers
8k views

How do I encrypt the source code on the webserver?

I have a web application developed using Python, HTML, CSS & JavaScript. The customer installs it in any of their own Machine and uses it through their LAN. In short the customer sets up the ...
4
votes
3answers
544 views

Why do you need “self.” in Python to refer to instance variables?

I have been programming into a number of languages like Java, Ruby, Haskell and Python. I have to switch between many languages per day due to different projects I work on. Now, the issue is I often ...
4
votes
4answers
386 views

Legitimate cases of having .equals() behaving inconsistently with .compareTo()?

Java documentation says it's "strongly recommended" to have them behaving consistently. But are there legitimate cases of java/c#/python/etc Object.equals() method behaving inconsistently with the ...
2
votes
2answers
241 views

Changing __class__ in a factory?

I'm parsing a set of XML files of different kinds (these kinds are known in advance). These are my requirements: I want an object to represent each XML document (object-xml mapping) I'd rather ...
2
votes
1answer
1k views

Python web frameworks comparisons

I recently asked a question on SO about Python web frameworks: http://stackoverflow.com/questions/4909306/python-web-frameworks-vs-java-web-frameworks-how-is-web-development-in-python-do I want to ...
0
votes
1answer
466 views

What are the external dependencies of a Python executable?

I guess there is a tool called Py2Exe to convert a Python application into an executable file. Since I am also using PyQt4 for GUI apps., what are the external dependencies for such an executable? ...
15
votes
3answers
8k views

Why isn't there a python compiler to native machine code?

As I understand, the cause of the speed difference between compiled languages and python is, that the first compiles code all way to the native machine's code, whereas python compiles to python ...
10
votes
9answers
1k views

Omitting inheritance in programming languages

I am developing my own programming language. It's a general purpose language (think staticlly typed Python for the desktop, i.e. int x = 1; ) not intended for the cloud. Do you think it's okay not ...
5
votes
2answers
2k views

Every function is a closure?

Wikipedia says, that closure - is a function, which has an access to variables, declared outside of the function. There is even an example: function startAt(x) function incrementBy(y) ...
5
votes
2answers
8k views

What should I learn after Python? [closed]

I am 12 years old and have mastered the basics of Python with Learn Python The Hard Way by Zed Shaw (I think) and it has done me well. What should I do next? Do you have any recommended books or good ...
4
votes
1answer
2k views

How should I architect a personal schedule manager that runs 24/7? [closed]

I've developed an ADHD management system for myself that's attempting to change multiple habits at once. I know this is counter to conventional wisdom, but I've tried the conventional for years & ...
4
votes
2answers
2k views

Python threading vs. multiprocessing: Should I learn one before the other?

I'm looking to dive into multithreading or multiprocessing in Python. Question: should I be learning one before the other (for any reason)? If so, which one and why? I've read the pro's and con's in ...