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
5answers
152 views

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

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 ...
1
vote
1answer
207 views

Merge two different API calls into One

I have two different apps in my django project. One is "comment" and an other one is "files". A comment might save some file attached to it. The current way of creating a comment with attachments is ...
5
votes
0answers
95 views

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

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
21 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
1answer
259 views

Watching file changes/additions/removal, but with an eye on partial transfer

I would like to monitor the filesystem in python, so that my application gets warned of the new file addition, file removal, or file change. Once the file is detected, the application starts ...
1
vote
0answers
28 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 ...
-5
votes
0answers
79 views

Is it worth investing time will it be easy to get a job [on hold]

so basicly im intrested in coding im only 16 at the moment and im really intrested in doing those things ,first of i think i will start with python and actually make a project that i wanted for a long ...
-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 ...
1
vote
2answers
120 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
1answer
91 views

Seeking Guidance on Thread Safe Scripting

I am trying to write a script that will take multiple paths to files on various servers, search them all simultaneously, and return a single list of results to a user. Initially, I was just using ...
11
votes
4answers
5k 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 ...
1
vote
2answers
27 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 ...
8
votes
4answers
2k views

Google App Engine, what are the advantages and limitations?

First, does anyone know a specific advantage of Google App Engine for Python Apps? Is there some advantage over Heruko or Appfog? And about the database API? Now, what about the limitations? Are ...
16
votes
3answers
7k views

What is the name of ** in python?

When programming Python I sometimes do a ** to make a conversion. I understand what it does but what data structures am I manipulating? A dict and what is the other? An array? Is there a name for the ...
0
votes
1answer
47 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 ...
-3
votes
0answers
13 views

while creating Virtual Environment Project in Python I'm not able to run server in Python Please help me out to figure the error [closed]

After Creating the virtualenv in python and craeted a project called myproject and in that django has been installed and then tryed to run the manage.py to start sever it is not running it is ...
24
votes
4answers
15k 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 ...
0
votes
0answers
28 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: ...
-3
votes
0answers
29 views

Python MySQLdb vs mysql-connector-python [closed]

Could anyone who is experienced with both MySQLdb and mysql-connector-python talks about the pros and cons of using each of them to connect to MySQL/MariaDB through Python? I believe it would be ...
0
votes
0answers
29 views

Minimizing Downtime With Upgrades For 3rd Party Products [migrated]

I am currently maintaining a Review Board server (https://www.reviewboard.org/) and one of the big pain points is scheduling upgrades. Currently the process is: Take the server down and send all ...
-3
votes
0answers
71 views

Python algorithms for poker hands? [closed]

I am in the middle of writing a Texas Hold'Em poker program in Python and need some algorithms. I'm sure I can write these but I'd like to see if someone already has something similar to this. NOTE I ...
0
votes
0answers
55 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 ...
0
votes
0answers
20 views

How to stop connecting to a server after n unsuccessful attempts? [migrated]

Here is the problem. I am trying to connect to a server. If the connection goes through, then print an apt message. If the connection does not go through, try for a total of n times. And quit after ...
-4
votes
0answers
50 views

how couldnI write a python program to calculate fourier series [closed]

while I am researching wave function, I found out there is a way to calculate the result by Fourier Series. But I have little experience with python. can anyone show me how to write the python program ...
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) ...
6
votes
6answers
3k views

What is the simplest human readable configuration file format? [closed]

Current configuration file is as follows: mainwindow.title = 'test' mainwindow.position.x = 100 mainwindow.position.y = 200 mainwindow.button.label = 'apply' mainwindow.button.size.x = 100 ...
0
votes
1answer
82 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
votes
4answers
3k views

Using Django without a database [closed]

Is Django a good solution for creating applications that won't use any database and communicate only through an internal API?
40
votes
13answers
5k views

Is C# development effectively inseparable from the IDE you use?

I'm a Python programmer learning C# who is trying to stop worrying and just love C# for what it is, rather than constantly comparing it back to Python. I'm caught up on one point: the lack of ...
0
votes
0answers
5 views

Pylab: Why does script run from Canopy command prompt but not Window's Powershell? [migrated]

When I try and run the Python script below in the Canopy 64-bit command prompt it works but when I try it on the standard Window's Powershell it gives me an ImportError (see image). I ran the files ...
1
vote
1answer
43 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", ...
0
votes
1answer
106 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
1answer
97 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. ...
1
vote
2answers
68 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 ...
4
votes
3answers
210 views

Python - defining exit method before importing

This breaks nothing (in my experience), but lots of things "don't break anything" and are still wrong. #! /usr/bin/env python """Short description of this module.""" def ...
0
votes
0answers
13 views

Python: algorithm for describing chess positions [migrated]

I have an interesting problem with my chess application. The application reads PGN files, and at any time while viewing a game from the file, the function below, when called, iterates over the ...
-2
votes
0answers
53 views

Selling the idea of using Python vs Java for offline batch jobs [duplicate]

I need to make a case to my team why we should expand our technology spectrum onto Python. We currently use Java with JBoss and JSF/PrimeFaces for our mission critical, user-interactive web ...
1
vote
0answers
74 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: ...
3
votes
1answer
345 views

Using naming conventions to make `import *` safer in Python

Consider the following code: a.py import os def print_rand(): print os.urandom() And another module: b.py from a import * In this code, I end up with an os variable getting imported from ...
0
votes
1answer
105 views

Running Python script in background on Mac

I have a Python script that counts the number of file in a folder, and if the number of files exceeds 10 then it creates a popup window to ask the user to clean up the folder (I use tkMessageBox). ...
0
votes
3answers
127 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 ...
0
votes
1answer
68 views

Is there a canonical way to cache instance methods in python?

I have some computationally intensive functions in my python script that I would like to cache. I went looking for solutions on stack overflow and found lots of links: ...
16
votes
3answers
926 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 ...
4
votes
2answers
132 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 ...
17
votes
3answers
2k views

How to solve the problem of nested comments

It appears in not just one language that comments can't be nested. Do you have a good solution for this problem? One workaround in C/C++ and Java is to only use the single-line comment but it becomes ...
44
votes
7answers
29k views

Why use try … finally without a catch clause?

The classical way to program is with try / catch but when is it appropriate to use try without catch? In Python the following appears legal and can make sense: try: #do work finally: #do ...
0
votes
1answer
104 views

Should an object query its owner?

I have a World class World: def __init__(self): self.size = 10 self.n_busStops = 10 self.busStopMatrix = SpatialGraph(self.size, self.n_busStops, 1.0) self.buses ...
0
votes
2answers
82 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
2answers
703 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 ...
8
votes
2answers
307 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 ...