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)

1
vote
1answer
143 views

From which point does it become dangerous to keep going as the sole developer on a project? [duplicate]

I'm currently working as the sole developer in the brand-new "software department" of a company that, for the moment, gets all its revenues from consulting. The idea is that the management wants to ...
-2
votes
0answers
42 views

Django vs Rails for SaaS Startup [on hold]

Several friends and I have a SaaS idea we want to flush out and build a prototype. We have already decided on AngularJS for the front-end, so we need to find a framework that plays well with ...
0
votes
2answers
75 views

How early does a hashable type need to become immutable?

Suppose I have a class that looks vaguely like this: class Foo(object): _value = None # XXX: see below def __init__(self, value): self._value = value @property def ...
-4
votes
1answer
51 views

Explanation of the code to read a file (File IO)

In the code: in_file = open("test.txt", "r") text = in_file.read() in_file.close() What is the role of the text in the 2nd line ?
2
votes
3answers
56 views

How do I deal with imported modules in GPL?

I wish to release a non-commercial python application under GPL3 in both source and (PyInstaller) executable form. I'm struggling to find a consistent answer to the problem of imported modules. Can I ...
-3
votes
0answers
45 views

Realtime updates from facebook using Django

I am working on capturing realtime updates from facebook using Django. I found a similar question asked regarding this on stackoverflow ...
0
votes
0answers
5 views

Python large list error [migrated]

I did the following program to generate a list of consecutive numbers. However, the computations seem to fail for more than 70.000 elements in the list. I tried using Pycharm IDE and also the python ...
-3
votes
0answers
27 views

Where can I download a (Windows) app made with pyQt? [closed]

I am curious about things like the sizes and startup times for programs made with pyQt when packaged for, installed on, and run in machines without python or Qt. I don't know what programs have been ...
0
votes
0answers
11 views

Networkx: draw edges certain attributes [migrated]

Using Networkx, I am considering a graph that is in reality the union of several subgraphs. I am trying to figure out the best way to deal with this. Currently, I have been using the following ...
-3
votes
1answer
74 views

For a beginner, should the adoption of a language determine which version to learn? [closed]

I've been using C# and Java at my workplace for about 5 years and I'm thinking about learning a new language, say Python. Many of my coworkers have told me that Python is a great language, but I ...
3
votes
1answer
52 views

How should I represent composeable, associative computations to be repeatedly applied to units of data?

Spoiler My question is the following: Are there any design patterns for representing chainable functions that are for the problem described below? High-Level Decription of the Process I'm ...
-2
votes
0answers
31 views

A library to be able to reproduce mp3 files in Raspberry Pi [closed]

I've been having a hard time looking for a simple library to reproduce audio files (mp3 precisely) , i've tried pyglet for python, but didn't succeed, but look, the only thing i want/need is a library ...
0
votes
2answers
80 views

Is it ok to access private members while doing same class comparison?

I am writing a class which basically is a wrapper around a dictionary with some extra functionality. This dictionary is stored as protected member _store. Now I am writing a __eq__ method to compare ...
1
vote
0answers
19 views

Keeping Track of Calculation Dependencies [migrated]

Suppose I have a set of calculations: x = x() y = y(x()) z = z(y(), x()) I would like to create a Python class to implement these calculations, being mindful of the dependencies and caching results ...
0
votes
1answer
48 views

Why do objects created with no assignment not generate a syntax error in Python?

While working on a Python project, I realized that during my editing I had left a string floating around in the middle of my code and it didn't generate an error. For example, these few lines execute ...
0
votes
1answer
80 views

Easiest algorithm implementation of a game tree? [closed]

I want to create an algorithm to play out all possibilities in this game and print the most optimal moves. (This is a variant of mancala. You don't need to play the game to understand my code (the ...
-1
votes
1answer
54 views

Python recipe question: Use of **kwds instead of specific named argument in itertools recipe [closed]

The function definition below comes from the itertools recipes page (https://docs.python.org/2/library/itertools.html#recipes). def random_product(*args, **kwds): "Random selection from ...
-1
votes
0answers
15 views

Is it possible to use Python to detect the address of a (parallel) port? [migrated]

I have an EEG experiment programmed in Python (PsychoPy, to be exact), and we send event markers to the EEG recording computer through one of these adapters. This requires giving Python the address of ...
2
votes
1answer
108 views

Python Open Source Development

I am looking to contribute to some Python projects on Github, and I am looking for a bit of clarification on the mechanics of doing this effectively. As I understand it, the typical workflow is as ...
0
votes
0answers
5 views

Opencv two camera source [migrated]

I am working with opencv and have two video source. I am using the following code. The code works sometimes and sometimes it does not work. Is there a problem with my code. How can I make the ...
0
votes
1answer
43 views

How can I determine which version of Python introduced a particular module to the std lib? [closed]

Is there a single timeline-style resource available showing the history of the modules available in different versions of Python? I'd like to, for instance, easily determine which version of Python ...
0
votes
0answers
4 views

Trouble installing mechanize in virtualenv [migrated]

If use pip to install mechanize on my computer, I can import it perfectly fine. However, if I set up a virtualenv (following the instructions here), run ` pip install mechanize and then try ...
4
votes
2answers
95 views

Changing method signature while keeping backwards compatibility

I've inherited an API to maintain. Users can pass a callback function to the class which gets called on some event. The callback function is currently passed in a single argument. I need to change ...
0
votes
3answers
314 views

What can C++ do that Python cannot? [closed]

I was reading this post: http://www.quora.com/What-are-the-advantages-of-Python-over-C++ And I am wondering the converse of this question: what can C++ do that Python cannot? For example, in the ...
-1
votes
1answer
73 views

Intership Interview Tips? [closed]

I am currently a freshman in college studying CS. I recently submitted my resume to a small subset of HP in my hometown and got a response back saying they will contact me for a phone interview. I ...
-1
votes
0answers
11 views

In IPython console (Spyder), can I access a variable from main() after running my program? [migrated]

I am running my code using an IPython Console. I have a main() function that is executed as follows: if __name__ == "__main__": main() Then main() calls a bunch of other functions and I don't ...
0
votes
1answer
113 views

Should I use a class as a wrapper?

Lets say I have a class representing a chemical compound class Compound(networkx.Graph): def __init__(self): super(Compound, self).__init__() And lets say that I want to add some ...
3
votes
4answers
146 views

What argument passing mechanism does python use, and where is this officially documented?

As far as I am aware, python is generally referred to as 'call-by-sharing', but does it implement this with call-by-value (like Java) or call-by-reference? or something else? I would appreciate if ...
2
votes
6answers
524 views

Why is python treated as a interpreted language when it has a compiling stage? [closed]

Why is that python is treated as only an interpreted language when there is in fact a compiling stage where the code we write gets converted into byte code(.pyc), which is later interpreted by the ...
6
votes
0answers
113 views

Which languages have the best support for stackful coroutines? [closed]

Various languages support (some flavor of) coroutines. One way to discriminate coroutines is whether they are stackful or not (terminology based on Ana Lucia de Moura; Roberto Ierusalimschy (2004). ...
0
votes
1answer
32 views

Django Project Logic Solution

I'm starting to develop my first webapp, and I'm using django. Before anything I'm working on the software logic, how it should work, the links and objects it needs. The problem is: I need the app ...
1
vote
0answers
32 views

auto update strategy for a software distributed as a tar ball written in python 2.7 targeting mac osx

This is what I have planned as an auto update strategy for a software that is as a tar ball. The application is running as a system daemon which means it have root privilege. App runs on startup ...
-2
votes
0answers
15 views

encryption and decryption with python [migrated]

This is my code for encryption and decryption when the key = 'a'. I'm just a little confused on how to make it work when the key contains multiple characters, key = 'abc' for example. If anyone could ...
0
votes
1answer
52 views

how python updates references to variables

For this while loop below. It is clear how the v1,v2,v3 are updated to new data objects based on the equation. But I do not understand how u1,u2,u3 retains the original values of v1,v2,v3.Can someone ...
0
votes
0answers
35 views

how to test a generator with unittest?

I have programmed a small iterator in Python: class anything(): def __init__(self): self.i=1 def __iter__(self): return self def next(self): if self.i>100: ...
0
votes
0answers
61 views

Naming self or this something else, a good idea?

I'm finding that my code becomes more readable when I make a local reference to this/self, and/or call it something that makes sense in the context. "self" or "this" doesn't really indicate what kind ...
1
vote
2answers
122 views

Python: Object initialised inside a Class?

Is possible and, if so, common practice to initialize an object inside a class in Python? self.field = Class()
3
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) ...
0
votes
1answer
85 views

Handling the process of large-scale lists [closed]

What are the efficient ways to process huge lists (+10 millions), and things to consider while manipulating huge lists. First question, when should I use recursion, and when I shouldn't. In both ...
1
vote
2answers
31 views

How to handle configuration of Python modules, especially when used standalone and in frameworks like Django

I am trying to package a Python module for pip, following the guide here. One area I would like feedback on is best practices or convention for making my module configurable. The module is a library ...
1
vote
1answer
46 views

Is this type of data insertion safe and can stop sql injection in Python?

I am learning Database connection from MySQL Connector/Python Developer Guide. This is the code I am using to insert data: conn = mysql.connector.connect(user="user", password="password", ...
1
vote
1answer
101 views

Why is a python package more perfomant as zip?

I have read the following text in the setuptools documentation: For maximum performance, Python packages are best installed as zip files. ...
0
votes
1answer
111 views

How do different technologies connect to form a web stack? [closed]

I am a little confused, is it possible to implement a front end using common languages like html, css and javascript and then do server side processing using a language of your choice, say python or ...
1
vote
0answers
85 views

The Python module-as-singleton hack

I've seen (and once used) this idiom a few times in Python: # At the end of a module: if __name__ == '__main__': main() # or whatever your entry point looks like, this line isn't important else: ...
1
vote
2answers
81 views

Is it safe to catch ImportError when trying to import optional modules?

I usually see this pattern at least once in every Python project I work on. For example, in a Django project, this is often added at the bottom of the base settings file: try: from .local_settings ...
0
votes
3answers
133 views

Socket Connecting to Large number of IPs

I have a text file of ~600 CIDR notation IP blocks which, when expanded, amount to ~17.5M IP addresses. I need to socket connect to each one. If it connects, I add it to a "live" list, if it returns ...
4
votes
2answers
139 views

In Python, is there any difference (apart from a few listed exceptions) between classes and dictionaries?

My logic goes like this: def A(val): return {'a':val} print(A(7)['a']) is the same as class A: def __init__(self, val): self.a = val print(A(7).a) Obviously, there are problems ...
16
votes
3answers
964 views

Should I pass in filenames to be opened, or open files?

Suppose I have a function that does things with a text file - for example reads from it and removes the word 'a'. I could either pass it a filename and handle the opening/closing in the function, or ...
0
votes
2answers
85 views

Print Statements Inside Function Or Before Calling It? [closed]

I have a script which different people may use. I have print statements so people can follow along what the script is doing, and if it breaks where it went wrong, and if a certain step takes a long ...
1
vote
0answers
17 views

How should private dependency links be handled in setup.py

At work we use a private pypi server. This pypi server is specified as a dependency link: ... from setuptools import setup config = ConfigParser.ConfigParser() rc = ...