Q_Id
int64
337
49.3M
CreationDate
stringlengths
23
23
Users Score
int64
-42
1.15k
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
Tags
stringlengths
6
105
A_Id
int64
518
72.5M
AnswerCount
int64
1
64
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
6
11.6k
Available Count
int64
1
31
Q_Score
int64
0
6.79k
Data Science and Machine Learning
int64
0
1
Question
stringlengths
15
29k
Title
stringlengths
11
150
Score
float64
-1
1.2
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
8
6.81M
8,668,152
2011-12-29T12:57:00.000
76
0
1
0
python,string,methods,python-3.x
8,668,177
4
true
0
0
'.'.join() or ".".join().. So any string instance has the method join()
2
78
0
I've been using string.join() method in python 2 but it seems like it has been removed in python 3. What is the equivalent method in python 3? string.join() method let me combine multiple strings together with a string in between every other string. For example, string.join(("a", "b", "c"), ".") would result "a.b.c".
Python 3 string.join() equivalent?
1.2
0
0
127,495
8,668,152
2011-12-29T12:57:00.000
15
0
1
0
python,string,methods,python-3.x
8,668,179
4
false
0
0
There are method join for string objects: ".".join(("a","b","c"))
2
78
0
I've been using string.join() method in python 2 but it seems like it has been removed in python 3. What is the equivalent method in python 3? string.join() method let me combine multiple strings together with a string in between every other string. For example, string.join(("a", "b", "c"), ".") would result "a.b.c".
Python 3 string.join() equivalent?
1
0
0
127,495
8,674,077
2011-12-29T22:08:00.000
0
1
0
0
python,html,web
8,674,108
1
false
1
0
I don't know anything about Python, but in PHP, in some fopen modes, if a file is trying to be made with the same name as an existing file, it will cancel the operation.
1
0
0
I have a problem with links on my website. Please forgive me if this is asked somewhere else, but I have no idea how to search for this. A little background on the current situation: I've created a python program that randomly generates planets for a sci-fi game. Each created planet is placed in a text file to be viewe...
Website Links to Downloadable Files Don't Seem to Update
0
0
1
45
8,674,426
2011-12-29T22:52:00.000
2
0
0
0
python,dictionary,insert,mysql-python
8,674,504
2
true
0
0
MySQLDB does not come with anything which allows a direct operation like that. This is a common problem with a variety of answers, including a custom function for this purpose. In my experience, it is best to buckle down and just write the paramaterized SQL most of the time. If you have the same thing going on a lot,...
2
2
0
I have a row of data in dict format. Is there an easy way to insert it into a mysql table. I know that I can write a custom function to convert dict into a custom sql query, but I am looking for a more direct alternative.
MySQLdb inserting a dict into a table
1.2
1
0
1,650
8,674,426
2011-12-29T22:52:00.000
5
0
0
0
python,dictionary,insert,mysql-python
8,674,547
2
false
0
0
Well... According to the documentation for paramstyle: Set to 'format' = ANSI C printf format codes, e.g. '...WHERE name=%s'. If a mapping object is used for conn.execute(), then the interface actually uses 'pyformat' = Python extended format codes, e.g. '...WHERE name=%(name)s'. However, the API does not presen...
2
2
0
I have a row of data in dict format. Is there an easy way to insert it into a mysql table. I know that I can write a custom function to convert dict into a custom sql query, but I am looking for a more direct alternative.
MySQLdb inserting a dict into a table
0.462117
1
0
1,650
8,675,062
2011-12-30T00:46:00.000
0
1
1
0
c++,python,performance
8,675,094
4
false
0
0
The best metric should be something that wieghs up for you.... Makes development, debugging and testing easier (lowers dev cost) Lowers the cost of maintenance meets the performance requirement (provides solution)
4
11
0
I'm developing a C++ application that is extended/ scriptable with Python. Of course C++ is much faster than Python, in general, but does that necessarily mean that you should prefer to execute C++ code over Python code as often as possible? I'm asking this because I'm not sure, is there any performance cost of switchi...
Price of switching control between C++ and Python
0
0
0
991
8,675,062
2011-12-30T00:46:00.000
1
1
1
0
c++,python,performance
8,675,109
4
true
0
0
The cost is present but negligible. That's because you probably do a fair bit of work converting python's high level datatypes to C++-compatible representations. Of course this is similar to the cost of calling one C++ function from another, there's some overhead. The rules for when it's a good idea to switch from pyth...
4
11
0
I'm developing a C++ application that is extended/ scriptable with Python. Of course C++ is much faster than Python, in general, but does that necessarily mean that you should prefer to execute C++ code over Python code as often as possible? I'm asking this because I'm not sure, is there any performance cost of switchi...
Price of switching control between C++ and Python
1.2
0
0
991
8,675,062
2011-12-30T00:46:00.000
2
1
1
0
c++,python,performance
8,675,394
4
false
0
0
Keep it simple and tune performance as needed. The primary reason for embedding an interpreter in a C++ app is to allow run-time configuration/data to specify some processing - i.e. you can modify the script without recompiling the C++ program - that's your guide for when to call into the interpreter. Once in some in...
4
11
0
I'm developing a C++ application that is extended/ scriptable with Python. Of course C++ is much faster than Python, in general, but does that necessarily mean that you should prefer to execute C++ code over Python code as often as possible? I'm asking this because I'm not sure, is there any performance cost of switchi...
Price of switching control between C++ and Python
0.099668
0
0
991
8,675,062
2011-12-30T00:46:00.000
8
1
1
0
c++,python,performance
8,675,112
4
false
0
0
I don't know there is a concrete rule for this, but a general rule that many follow is to: Prototype in python. This is quicker to write, and may be easier to read/reason about. Once you have a prototype, you can now identify the slow portions that should be written in c++ (through profiling). Depending on the domain...
4
11
0
I'm developing a C++ application that is extended/ scriptable with Python. Of course C++ is much faster than Python, in general, but does that necessarily mean that you should prefer to execute C++ code over Python code as often as possible? I'm asking this because I'm not sure, is there any performance cost of switchi...
Price of switching control between C++ and Python
1
0
0
991
8,675,138
2011-12-30T00:59:00.000
1
0
0
0
python,unix,telnetlib
8,675,162
1
false
0
0
Instead of using more(1) or less(1) to view a file, use cat(1). It will not perform any pagination tasks and will write all the content of the file to the terminal, raw.
1
0
0
As you know, sometimes, you have to click space to get the next page under telnet connections, unix. For instance, you 'more' a text file. You can't get all the content at one time. Using 'space' can get to the next page. Here is the problem, what should I do when using telnetlib, python? I have to get all the informat...
telnetlib | read all message when I have to click space if do it mannually
0.197375
0
1
272
8,676,682
2011-12-30T06:05:00.000
31
0
1
0
python,integer,bit
8,676,794
2
false
0
0
Python 2 has two integer types: int, which is a signed integer whose size equals your machine's word size (but is always at least 32 bits), and long, which is unlimited in size. Python 3 has only one integer type, which is called int but is equivalent to a Python 2 long.
1
10
0
So I am thinking of writing a bitboard in python or lisp. But I don't know how to ensure I would get a 64 bit integer in python. I have been reading documentation and found that mpz library returns a unsigned 32 bit integer. Is this true? If not what should I do?
getting 64 bit integer in python
1
0
0
58,013
8,678,349
2011-12-30T10:09:00.000
0
0
0
0
c#,python,redis
8,724,716
1
false
0
0
I had similar issues with an older version of Redis that was fixed by the latest version. As an alternative you could try adding a separate thread that sends a "PING" command once in a while to keep the connection up.
1
0
0
I have one client subscribe to one channel. After a certain period of time about 10 minutes idle, the client can not receive any message, but the publish command still returns 1. I've tried redis-py and servicestack.redis clients. The only difference is seems the idle period can be little longer when use servicestac...
subscription to redis channel does not keep alive
0
0
1
1,314
8,678,428
2011-12-30T10:19:00.000
13
0
1
0
math,coding-style,python,python-2.7
8,678,521
2
true
0
0
If you use Python 2.7, ALWAYS use from __future__ import division. It removes a hell of a lot confusion and bugs. With this you should never have to worry if a division is a float or not, / will always be a float and // will always be an int. You should convert your input with float(). You will do it only once, and it...
2
4
0
I need to perform simple mathematical calculations in Python 2.7 with sums, subtractions, divisions, multiplications, sums over lists of numbers etc. I want to write elegant, bullet-proof, and efficient code but I must admit I got confused by several things, for example: if I have 1/(N-1)*x in my equation should I jus...
Best practices for coding simple mathematical calculations in Python
1.2
0
0
1,524
8,678,428
2011-12-30T10:19:00.000
2
0
1
0
math,coding-style,python,python-2.7
9,622,700
2
false
0
0
If you want great performance for numerical code in Python, you should consider PyPy. Numpy and scipy are convenient for dealing with arrays, and they give good performance if you use linear algebra algorithms that they provide. But if your numerical operations are in pure Python code, PyPy can give significant improve...
2
4
0
I need to perform simple mathematical calculations in Python 2.7 with sums, subtractions, divisions, multiplications, sums over lists of numbers etc. I want to write elegant, bullet-proof, and efficient code but I must admit I got confused by several things, for example: if I have 1/(N-1)*x in my equation should I jus...
Best practices for coding simple mathematical calculations in Python
0.197375
0
0
1,524
8,680,080
2011-12-30T13:45:00.000
11
0
1
0
python,string,immutability
8,680,104
6
false
0
0
Immutable objects are automatically threadsafe. You will find that using Python strings is trivially easy in comparison to the extreme pain associated with strings in C.
4
69
0
What are the design reasons of making Python strings immutable? How does it make programming easier? I'm used to mutable strings, like the ones in C. How am I supposed to program without mutable strings? Are there any best practices?
Why are Python strings immutable? Best practices for using them
1
0
0
31,789
8,680,080
2011-12-30T13:45:00.000
8
0
1
0
python,string,immutability
8,680,155
6
false
0
0
Immutable strings can be keys in dictionaries and similar data structures, without the need to copy the strings. It is easier to make a mutable wrapper around an immutable string than the other way around.
4
69
0
What are the design reasons of making Python strings immutable? How does it make programming easier? I'm used to mutable strings, like the ones in C. How am I supposed to program without mutable strings? Are there any best practices?
Why are Python strings immutable? Best practices for using them
1
0
0
31,789
8,680,080
2011-12-30T13:45:00.000
3
0
1
0
python,string,immutability
8,680,100
6
false
0
0
Immutable strings makes programming much easier, which is why C# and Java use them too. Had strings been mutable, you would not be able to trust any externally-provided string, since a malicious caller could change it underneath you. It would also make multi-threading much more difficult.
4
69
0
What are the design reasons of making Python strings immutable? How does it make programming easier? I'm used to mutable strings, like the ones in C. How am I supposed to program without mutable strings? Are there any best practices?
Why are Python strings immutable? Best practices for using them
0.099668
0
0
31,789
8,680,080
2011-12-30T13:45:00.000
4
0
1
0
python,string,immutability
8,680,102
6
false
0
0
Most languages have immutable strings. This includes Java, Python, and C#. Usually when concatenating strings, the language allocates an entirely new string and copies the content of the two strings into the new string. Immutability does tend to make programming easier. Especially when dealing with a multi-threaded ...
4
69
0
What are the design reasons of making Python strings immutable? How does it make programming easier? I'm used to mutable strings, like the ones in C. How am I supposed to program without mutable strings? Are there any best practices?
Why are Python strings immutable? Best practices for using them
0.132549
0
0
31,789
8,680,673
2011-12-30T14:52:00.000
0
0
0
0
python,database,django
42,578,440
2
false
1
0
I have used following info and work for me 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'dab_name', 'USER': 'username', 'PASSWORD': 'password', 'HOST': 'localhost', 'PORT': '5432', 'OPTIONS': { 'options': '-c search_path=to...
1
7
0
Assuming I have a schema with the name "my_schema", how can I create tables with "django syncdb" for that particular schema? Or is there any other alternatives for quickly creating tables from my django models? I think, by default django creates tables for the "public" schema.
How to specify schema name while running "syncdb" in django?
0
1
0
4,285
8,683,501
2011-12-30T20:00:00.000
1
1
0
0
python,jython,robocode
18,469,631
1
false
1
0
As long as your java-class extends robocode.Robot everything is recognized as robot. It doesn't matter where you put the class.
1
3
0
The question is, how do you make a robot for Robocode using Python? There seem to be two options: Robocode + Jython Robocode for .NET + Iron Python There's some info for the first, but it doesn't look very robust, and none for the latter. Step by step, anyone?
Robocode + Python
0.197375
0
0
1,489
8,684,091
2011-12-30T21:04:00.000
2
0
0
1
python,file-io,python-3.x,posix,file-descriptor
8,684,222
3
false
0
0
You can't. POSIX file descriptors are tracked in the operating system kernel, outside the world of Python; you can't simulate them in Python code.
1
5
0
I'd like to write a class that can behave as a bona fide file descriptor. Its .fileno() method should return a file descriptor that provides all the services a POSIX system expects. This is my first foray into POSIX system programming, so I could be misunderstanding things quite badly. The underlying motivation is the ...
How can I implement a POSIX file descriptor in Python 3?
0.132549
0
0
1,279
8,685,695
2011-12-31T01:39:00.000
2
1
0
1
python,apache,daemon,infinite-loop
8,685,801
3
false
0
0
I assume you are running Unix/Linux but you don't really say. I have no direct advice on your issue. So I don't expect to be the "right" answer to this question. But there is something to explore here. First, if your daemons are crashing, you should fix that. Only programs with bugs should crash. Perhaps you should lau...
1
38
0
I've recently started experimenting with using Python for web development. So far I've had some success using Apache with mod_wsgi and the Django web framework for Python 2.7. However I have run into some issues with having processes constantly running, updating information and such. I have written a script I call "dae...
How do I run long term (infinite) Python processes?
0.132549
0
0
36,296
8,686,159
2011-12-31T03:54:00.000
6
0
1
0
python,vim
8,686,185
4
false
0
0
I simply hit v for visual mode then ( or ). This will take you to the next blank line. That should correspond to your code blocks if you are formatting nicely.
2
20
0
I can use vi{ and va{ to select C++ code blocks. It helps me a lot when I need to yank/delete them. But Python uses indentation to indicate code blocks. I cannot find any better way. Any ideas?
How to select Python code block using Vim?
1
0
0
5,786
8,686,159
2011-12-31T03:54:00.000
1
0
1
0
python,vim
8,686,196
4
false
0
0
You can show lines (:set nu) and then go to the line where the code block begins (:lineNumber) and yank them.
2
20
0
I can use vi{ and va{ to select C++ code blocks. It helps me a lot when I need to yank/delete them. But Python uses indentation to indicate code blocks. I cannot find any better way. Any ideas?
How to select Python code block using Vim?
0.049958
0
0
5,786
8,686,745
2011-12-31T06:28:00.000
3
0
0
1
python,tornado
9,072,583
2
true
1
0
Starting Tornado 2.2 now you can override RequestHandler.on_finish for post-request processing.
1
1
0
Tornado web framework seems to expose a method RequestHandler.prepare() which is called before the actual handler method. I was wondering if there's a similar method which is called after the handler ?
tornado.web : Is there a method which is called after the actual handler method?
1.2
0
0
922
8,688,050
2011-12-31T12:21:00.000
2
0
1
0
python,eclipse,pydev
8,688,355
2
true
0
0
Go to run -> run configurations In the menu on the right you should have Python Run option. Create new run configuration by double clicking. On the right you can select the project you want to run and it's main module. The other tabs can be used to configure arguments, python interpreter used to run the project, etc..
1
1
0
I have created a new project in Eclipse, PyDev. If I were in VS2010, I would mark a project as startup project, and whenever I click F5, it runs. I want to mark one .py file to be my so called Main, and that each time I click run (F11), it will be the one to run, and not the current that is being edited. Is it poss...
Is there such a thing as startup file in PyDev under Eclipse?
1.2
0
0
232
8,688,762
2011-12-31T14:51:00.000
5
0
0
0
python,django,sha1
8,688,811
1
true
1
0
You are asking the impossible. The passwords are salted and hashed. The way they're validated is by performing the same process on the re-supplied password. There's no way to 'decrypt' it.
1
0
0
I have a SECRET_KEY, how do i decompile a user password using python? I assume that the encryption method is sha1. thanks.
how to decompile user password in django
1.2
0
0
263
8,689,258
2011-12-31T16:39:00.000
1
0
1
0
python
8,689,307
3
false
0
0
Declare a module-level variable named __all__. This is a tuple of strings and will be the only symbols imported by from module import * and the only names that appear in help(module).
2
1
0
I am writing a sizable side project in python and I have got a module which implements all database access with only functions declared within the module.I was wondering if there is anyway to declare functions in the module as public so that python knows that these are the only functions that should be used from outsid...
Publicly accessible functions from python module
0.066568
0
0
121
8,689,258
2011-12-31T16:39:00.000
1
0
1
0
python
8,689,272
3
false
0
0
No. The convention is to prefix private names with a single underscore, e.g. _foo.
2
1
0
I am writing a sizable side project in python and I have got a module which implements all database access with only functions declared within the module.I was wondering if there is anyway to declare functions in the module as public so that python knows that these are the only functions that should be used from outsid...
Publicly accessible functions from python module
0.066568
0
0
121
8,689,964
2011-12-31T18:57:00.000
72
0
1
0
python,function,methods,double-underscore
8,690,287
6
false
0
0
The other respondents are correct in describing the double leading and trailing underscores as a naming convention for "special" or "magic" methods. While you can call these methods directly ([10, 20].__len__() for example), the presence of the underscores is a hint that these methods are intended to be invoked indirec...
1
514
0
This "underscoring" seems to occur a lot, and I was wondering if this was a requirement in the Python language, or merely a matter of convention? Also, could someone name and explain which functions tend to have the underscores, and why (__init__, for instance)?
Why do some functions have underscores "__" before and after the function name?
1
0
0
321,667
8,690,722
2011-12-31T21:46:00.000
0
0
0
0
python,spss
8,863,642
2
false
0
0
If you really want the table as an image rather than any of the other formats, it is a little more complicated. OUTPUT EXPORT and OMS only support images for graphics, not tables. You can use CopySpecial to put a table on the clipboard as a emf, jpg, png. This would require a script. Use the SetSelected api to select...
2
0
0
Is there a way to use SPSS syntax or r/python to export custom tables to jpg or some other file format? I often like to use ctables in PPT decks but find it extremely cumbersome to run syntax and 1x1 right-click-copy the custom tables output to PPT slides. In short, I am looking for SPSS-centric ways to "reproduce" ...
Programmatically export SPSS Custom Tables to image file
0
0
0
1,359
8,690,722
2011-12-31T21:46:00.000
1
0
0
0
python,spss
8,693,600
2
false
0
0
There are several ways to do this. You can use the OUTPUT EXPORT command. You can use OMS to captures selected tables, charts, etc. You can use a custom Python or Basic script. The output formats include Ppt, Word, Excel, PDF, HTML, XML, plain text, and tabbed text, among others. A variety of image formats are avail...
2
0
0
Is there a way to use SPSS syntax or r/python to export custom tables to jpg or some other file format? I often like to use ctables in PPT decks but find it extremely cumbersome to run syntax and 1x1 right-click-copy the custom tables output to PPT slides. In short, I am looking for SPSS-centric ways to "reproduce" ...
Programmatically export SPSS Custom Tables to image file
0.099668
0
0
1,359
8,693,622
2012-01-01T14:45:00.000
-1
0
1
1
python,default,file-association
8,694,464
5
false
0
0
Find any file of type foo right-click -> Get Info or Click on the file icon,then click Get info or click on the file and hit Command+I In the Open With pane that shows up, select the path to the python binary Once selected, You can click the change All button It'll ask for confirmation, just say continue
1
12
0
How can I make a Python script to be a specific file type's (e.g., *.foo) default application? As in, when I double click the file in the Finder / Explorer I want the file to open in the Python script. Is this possible to do in Win and/or OS X? The application is a PySide app if that matters.
Open specific file type with Python script?
-0.039979
0
0
5,722
8,696,469
2012-01-02T00:09:00.000
2
1
0
0
python,django
8,696,496
2
false
1
0
That assumes your database is only accessible from one specific host, and even then, why would you want to give a potential attacker another piece of information? Suppose you deploy this to a shared host and I have an account on there, I could connect to your database just by logging into my account on that box. Also,...
1
1
0
For a git repository that is shared with others, is it a vulnerability to expose your database password in the settings.py file? (My initial thought was no, since you still need the ssh password.)
Exposing passwords in django
0.197375
0
0
104
8,697,664
2012-01-02T05:25:00.000
1
0
0
0
python,django
8,697,977
1
false
1
0
Sending raw password is a bad idea, it's not secure. If user forgets his password, reset password form should be used instead of finding raw password in mail inbox. To answer your question I could suggest using form for getting raw password. If you'll have own form, you'll get access to all user-entered text, including...
1
0
0
How can I mail a decrypted 'current password' to a django user just created. eg I create a customer by inheriting the User model. Hence the user name and password get saved. Once the customer details are entered and saved. While overriding the save function for the customer form I trigger the send_mail function to send...
How can I mail decrypted 'current password' of a django user created
0.197375
0
0
1,188
8,698,140
2012-01-02T06:44:00.000
2
0
0
0
python,django,python-3.x
8,698,193
3
false
1
0
Django (due to the immense amount of code running on it), will not, atleast in the near future, drop support for 2.x. It just doesn't make any sense. Any Python 3 is having trouble getting adoption right now; PyPy is picking up much, much faster. And, there's py2to3 which converts some parts to python 2 code to python...
1
6
0
I am in the process of learning Python and had a question about the future. I know it's not the most pressing thing to think about currently, but I'm curious. Currently, Django only supports up to Python 2.7. However, in the near future, it will be supporting Python 3. In terms of writing code in Python 2.7 and using ...
How to maintain when Django switches to Python 3?
0.132549
0
0
270
8,699,665
2012-01-02T10:19:00.000
0
0
0
0
python,image-processing,edge-detection
8,724,586
1
false
0
0
You can use a method named dynamic programming. A very good intro on this can be found on chapter 6 of Sonka's digital image processing book
1
1
1
I have written a canny edge detection algorithm for a project. I want to know is there any method to link the broken segments of an edge, since i am getting a single edge as a conglomeration of a few segments. I am getting around 100 segments, which i am sure can be decreased with some intelligence. Please help.
Linking segments of edges
0
0
0
433
8,700,765
2012-01-02T12:22:00.000
1
0
1
0
python,django
8,700,910
3
false
0
0
For Python 2.6 or later you could probably use the ast module. Read in the code (as a string, use ast.parse() to create an abstract syntax tree of that code, and then walk over the code looking for the ast.Print objects and then translate those back into filename, line number tuples.
1
2
0
I am working on a opensource project where i implementing searching of "print" statements and such other statements that are unnecessary in a live production enviroment and can create a error. But i dont want to trouble the user if there is a print statement commmented out or "print" word in a docstring or a comment....
Find statements in a python file that have a chance to get executed
0.066568
0
0
80
8,702,080
2012-01-02T14:39:00.000
1
1
0
0
python,gevent
8,712,328
1
true
1
0
If I've understood you right, you just need to link the second person with someone connected before. Think it's simple. The greenlet working with a person who comes first ('the first greenlet') just register somewhere it's inbound and outbound queues. The greenlet working with the second person gets this queues, unreg...
1
1
0
I have searched tutorials and documentation for gevent, but seems that there isn't lots of it. I have coded Python for several years, also I can code PHP + JavaScript + jQuery. So, how would I create Omeglish chat, where one random person connects and then waits for another one to connect? I have understood that Omegle...
How would I create "Omegle"-like random chat with gevent?
1.2
0
0
2,300
8,706,661
2012-01-03T00:16:00.000
3
0
1
0
memory-management,python,cpu-usage,assign
8,707,250
3
false
0
0
The preferred style is the one which is most readable for that particular function. Once you have readable, correct code -- you are probably done. If performance is an issue at that point, profile to see where the bottlenecks are, and work on those spots. It is easier to optimize correct code than to correct optimiz...
1
2
0
Considering the following as two versions of a very simple function in Python, the question is which one is preferred over another and why? Is there any extra memory usage and or CPU usage for case 1 compared to case 2 in which additional assignment has been used? case 1: def f(x): y = x*x return y case 2: ...
Python: extra assignments in functions
0.197375
0
0
183
8,706,850
2012-01-03T00:53:00.000
1
0
0
0
python,google-cloud-datastore
8,709,167
3
false
1
0
"always(?)" indeed. Sweden = 46 looks like you mean the telephone not-necessarily-a-country code which is VARIABLE LENGTH ... for example CHINA = 86, HONG KONG (not a country) = 852, CANADA = USA = 1. Is your ID allowed to be variable length or not? If it is allowed to be variable, you would need do str(countrycode) + ...
1
0
0
Update: The requirement is "fixed length 9 digits" so 460 000 000 138 should be 460 000 138 I want to generate IDs on a special form such as 460 000 000 138 where 46 is the country code and the rest is the ID and this number always(?) has the same number of digits ie four pairs of threes. My input is this ID that can b...
Generating IDs how to make IDs same length using zeroes?
0.066568
0
0
171
8,707,238
2012-01-03T02:16:00.000
0
1
0
1
python,ruby,compilation,distribution
8,716,554
2
false
0
0
Use whatever language you know well, I know python and use that to develop windows desktop applications and end user can't distinguish it with say a C# or C++ app
1
3
0
I'm a fan of Ruby but I don't oppose Python. ( I have 2+ years of Ruby experience and maybe 2 months of Python ). Anyway, I need to create a service for both the Mac and Windows (and Linux, actually) that takes certain files from different directories and sends them to S3. I could use .NET on Windows but I don't want...
Should I use Python or Ruby for creating a cross-platform, compiled application?
0
0
0
1,058
8,707,663
2012-01-03T03:42:00.000
0
1
1
1
python,executable
8,709,784
5
false
0
0
Use shutil.copyfile(src, dst) or shutil.copy(src, dst). It may not work in case of files in the C:\Program Files\ as they are protected by administrator rights by default.
2
0
0
How can i copy a .exe file through python? I tried to read the file and then write the contents to another but everytime i try to open the file it say ioerror is directory. Any input is appreciated. EDIT: ok i've read through the comments and i'll edit my code and see what happens. If i still get an error i'll post my ...
how to copy an executable file with python?
0
0
0
2,980
8,707,663
2012-01-03T03:42:00.000
1
1
1
1
python,executable
8,707,865
5
false
0
0
Windows Vista and 7 will restrict your access to files installed into the Programs directories. Unless you run with UAC privileges you will never be able to open them. I hope I'm interpreting your error properly. In the future it is best to copy and paste the actual error message into your question.
2
0
0
How can i copy a .exe file through python? I tried to read the file and then write the contents to another but everytime i try to open the file it say ioerror is directory. Any input is appreciated. EDIT: ok i've read through the comments and i'll edit my code and see what happens. If i still get an error i'll post my ...
how to copy an executable file with python?
0.039979
0
0
2,980
8,711,147
2012-01-03T10:52:00.000
3
0
0
1
python,csv
8,711,375
2
true
0
0
The csv module wraps the _csv module, which is written in C. You could grab the source for it and modify it to not require the file-like object, but poking around in the module, I don't see any clear way to do it without recompiling.
1
0
1
I'm creating a script to convert a whole lot of data into CSV format. It runs on Google AppEngine using the mapreduce API, which is only relevant in that it means each row of data is formatted and output separately, in a callback function. I want to take advantage of the logic that already exists in the csv module to c...
Formatting a single row as CSV
1.2
0
0
464
8,714,233
2012-01-03T15:04:00.000
0
0
0
1
python,eclipse,pydev,net-snmp
8,731,472
1
true
0
0
PyDev does one thing differently, which is setting: sys.setdefaultencoding(encoding) with the encoding of the java console (so that if you print unicode to the console it won't fail saying that the unicode doesn't decode as ascii). To see if this is your problem, you can go to eclipse\plugins\org.python.pydev\PySrc\pyd...
1
0
0
I am doing an snmpget using Net-SNMP. Specifically I am sending a command via os.popen("etc"). The value returned is a Hex-string separated by spaces, something like this : "A0 f0 D0". The returned value comes sometimes in the form :"Hex-String: A0 f0 D0.." but sometimes comes in the form "String:\xA0\xf0\xD0" where...
Net-SNMP returns HexString and then just String (Eclipse and Pydev)
1.2
0
0
737
8,714,358
2012-01-03T15:14:00.000
2
0
1
0
python,caching,memory-management
8,714,493
2
false
0
0
Weakrefs aren't what you want -- weakrefs are a way to reference an item that allows the garbage collector to collect (i.e. destroy) the referent if only weakrefs to it exist. In other words, if you create and store only weakrefs to some object, it is likely to be garbage collected quickly, and you won't have benefitte...
1
1
0
I have a directory of images in order. Typically my code will be using data from a sequential subset of images (e.g. images 5-10), and the naive options for accessing these are: Create a wrapper object with a method that loads the image when needed and reads my data (e.g. a pixel value). This has little memory overhea...
Smart caching of expensive objects in Python
0.197375
0
0
3,537
8,715,370
2012-01-03T16:33:00.000
0
0
1
0
python,django
8,717,036
3
false
1
0
Do you think you have to share your source code if you host your application on a 'shared hosting' provider? That's not the case. Your source code should still be private to you but the administrators of your hosting provider can get it too. Other normal Joe Users of the service shouldn't have access to your source cod...
2
0
0
I am starting on developing a django application on a shared webhosting server(alwaysdata.com). I would like to understand what are the packaing options available to package a django application (preferably in compiled form) I would like to setup the source code repository on my system and build using the python packag...
What packaging option are available for python/django
0
0
0
182
8,715,370
2012-01-03T16:33:00.000
1
0
1
0
python,django
8,733,563
3
false
1
0
How is this API key used? Is it a google maps api? Is it provided in scripts that go to the browser? If so, it's already out in the open, anyone using your site will see it, so you're trying to provide a $100 lock for a $0.01 piece of information. If it's a google maps api, it's not secured by keeping it hidden, but ...
2
0
0
I am starting on developing a django application on a shared webhosting server(alwaysdata.com). I would like to understand what are the packaing options available to package a django application (preferably in compiled form) I would like to setup the source code repository on my system and build using the python packag...
What packaging option are available for python/django
0.066568
0
0
182
8,715,435
2012-01-03T16:37:00.000
1
0
1
0
python,variables,environment-variables,go,share
8,715,483
2
true
0
0
use standard streams. use a simple printf type command to print the string to stdout. then read it with a raw_input() in python. run the two programs like so: ./output | ./read.py
2
0
0
i need to know how share variable between two program, basically the go program have to write a variable ,like a string, and the python program have to read this variable. Please help me, thank you in advance.
how to share variable between python and go language?
1.2
0
0
247
8,715,435
2012-01-03T16:37:00.000
1
0
1
0
python,variables,environment-variables,go,share
8,752,696
2
false
0
0
In Windows, most common way to do communication between two processes is "Named Pipe" (could also be tcp/ip, web service, etc...). A ugly but lighter way is to write the value to a file, and read it from python.
2
0
0
i need to know how share variable between two program, basically the go program have to write a variable ,like a string, and the python program have to read this variable. Please help me, thank you in advance.
how to share variable between python and go language?
0.099668
0
0
247
8,717,179
2012-01-03T18:52:00.000
2
0
1
0
python,parallel-processing
8,717,213
2
false
0
0
I would keep it simple. Have a single program open the file and read it line by line. You can choose how many files to split it into, open that many output files, and every line write to the next file. This will split the file into n equal parts. You can then run a Python program against each of the files in parallel.
1
18
1
I'm trying to a parallelize an application using multiprocessing which takes in a very large csv file (64MB to 500MB), does some work line by line, and then outputs a small, fixed size file. Currently I do a list(file_obj), which unfortunately is loaded entirely into memory (I think) and I then I break that list up in...
Chunking data from a large file for multiprocessing?
0.197375
0
0
14,016
8,718,081
2012-01-03T20:19:00.000
1
0
1
0
python,multithreading,http,pycurl,python-multithreading
8,718,262
1
false
1
0
I would suggest to have one controling thread which spawns http streaming threads, and such a streaming thread implements the proper handling for a connection loss or timeout (e.g. either terminating itself or telling to controling thread that a new streaming thread should be spawned for a reconnect). Depending on your...
1
0
0
I am implementing an app consuming a few http streams at the same time. All threads (a pycurl object each) are spawned in the same loop. The trick is how to build a proper architecture for handling reconnects. Is it a good practice to create a separate controller thread that somehow checks which connections are not ali...
Controlling http streams with python threads
0.197375
0
0
114
8,718,870
2012-01-03T21:28:00.000
1
1
0
0
python,nginx,php
8,718,932
1
true
1
0
How about supervisor with uwsgi?
1
2
0
I'm starting a web project in Python and I'm looking for a process manager that offers reloading in the same manner as PHP-FPM. I've built stuff with Python before and Paste seems similar to what I want, but not quite. The need for the ability to reload the process rather than restart is to allow long-running tasks to ...
Is there a Python equivalent to PHP-FPM?
1.2
0
0
1,732
8,719,976
2012-01-03T23:11:00.000
1
0
0
0
python,ruby-on-rails,windows,django,windows-7
8,722,898
1
true
1
0
I am using Django on Windows Vista and it works very well. I am using sqlite, mysql and postgres. mysql install is a bit tricky: I recommend to download the right binaries from the web. I am using popular django apps and python modules without any problem. However, I've made a quick test with GeoDjango and noticed tha...
1
1
0
I work in an environment that is totally .NET. However, over the past few months I've been learning Ruby and Rails on the side and enjoying it very much. I have been using Windows 7 to develop - along with Aptana - and so far things have gone better than I expected. I have run into a few issues with gems on windows -...
Django and Rails - what should I expect in a Windows environment?
1.2
0
0
306
8,720,589
2012-01-04T00:23:00.000
7
0
0
0
python,perl,bash,csv,openoffice-calc
8,720,660
10
false
0
0
Maybe you just need to udpate to a more recent version. I'm using LibreOffice 3.4.4 and I see Format -> Change Case -> Sentence case which I'd say does exactly what you need.
2
8
0
I have many cells which I'd like to convert such that the first letter in every cell is capitalized. E.g. cook, chef, fireman becomes Cook, Chef, Fireman. I have the spreadsheet in OpenOffice.org, but it seems to only have options for "all uppercase" or "all lowercase". I can edit it in OpenOffice.org or export to a C...
Change case of first letter in every cell in spreadsheet
1
0
0
5,126
8,720,589
2012-01-04T00:23:00.000
2
0
0
0
python,perl,bash,csv,openoffice-calc
8,721,517
10
false
0
0
If you are using, or if you upgrade to, OOo 3.3 there are options for this built in. Mark all the cells you want to affect, then choose Format -> Change Case -> Sentence case and voila! See if that does the trick for you?
2
8
0
I have many cells which I'd like to convert such that the first letter in every cell is capitalized. E.g. cook, chef, fireman becomes Cook, Chef, Fireman. I have the spreadsheet in OpenOffice.org, but it seems to only have options for "all uppercase" or "all lowercase". I can edit it in OpenOffice.org or export to a C...
Change case of first letter in every cell in spreadsheet
0.039979
0
0
5,126
8,721,870
2012-01-04T04:03:00.000
3
0
0
0
python,file,sockets
8,722,433
4
false
0
0
ZeroMQ helps to replace sockets. You can send an entire file in one command. A ZMQ 'party' can be written in any major language and for a given ZMQ-powered software, it doesnt matter what the other end it written in. From their site: It gives you sockets that carry whole messages across various transports like in-p...
1
7
0
I don't know if this has been answered before(i looked online but couldn't find one), but how can i send a file (.exe if possible) over a network to another computer that is connected to the network? I tried sockets but i could only send strings and i've tried to learn ftplib but i don't understand it at all or if ftp ...
How to transfer a file between two connected computers in python?
0.148885
0
1
24,645
8,721,918
2012-01-04T04:11:00.000
0
0
1
1
python,cross-platform,packaging,python-c-extension
10,105,281
3
false
0
0
All of my Python extension modules are C++, not C so I use boost Python. I also use virtual machines when I need to support different operating systems. Boost's bjam build driver allows you to build with different versions of Python (2.6, 2.7) different versions of g++ and various other things. If I had an extension mo...
2
8
0
I have noticed that several mature Python libraries have precompiled versions for most architectures (Win32/Win-amd64/MacOS) and versions of Python. What is the standard way to cross-compile your extensions for different environments? Wine? Virtual machines? Crowd sourcing?
How do you compile Python C/C++ extensions for different OS/versions of Python?
0
0
0
2,222
8,721,918
2012-01-04T04:11:00.000
0
0
1
1
python,cross-platform,packaging,python-c-extension
8,785,299
3
false
0
0
SWIG provides a path for multiplatform code generation.
2
8
0
I have noticed that several mature Python libraries have precompiled versions for most architectures (Win32/Win-amd64/MacOS) and versions of Python. What is the standard way to cross-compile your extensions for different environments? Wine? Virtual machines? Crowd sourcing?
How do you compile Python C/C++ extensions for different OS/versions of Python?
0
0
0
2,222
8,722,427
2012-01-04T05:29:00.000
2
0
0
1
python,image,google-app-engine,blob
8,722,451
2
false
1
0
"Blob" stands for "Binary Large OBject". It's bytes. Just instantiate a db.Blob, passing the bytes.
1
1
0
I am working on an AppEngine application, to store images, they have to be stored in a BlobProperty. Is there a Mac/Linux way to convert images to their Blob representation or is there any tool (especially online) that can do this?
What does an image look like as a Blob?
0.197375
0
0
2,977
8,723,808
2012-01-04T08:11:00.000
1
0
0
0
python,string,url,unicode,seo
8,724,105
6
false
0
0
If you have Django around, you can use its defaultfilter slugify (or adapt it for your needs).
1
1
0
I would like to convert a accented string to a seo-url ... For instance: "Le bébé (de 4 ans) a également un étrange "rire"" to : "le-bebe-de-4-ans-a-egalement-un-etrange-rire" Any solution, please ? Thanks !
How to convert string to seo-url?
0.033321
0
1
1,338
8,724,172
2012-01-04T08:51:00.000
0
0
1
0
javascript,python,json
8,726,867
1
false
0
0
comparing the two JSONs is very simple (in all languages) - you just compare the strings. showing the diffs is a little more complicated - i guess that one need to deserialize the JSONs and compare the objects.
1
1
0
Is there any library/script to compare two JSONs objects and show the diff between them? Thanks EDIT: I want to do that using python OR jquery/javascript
How to get the diff between two JSONs?
0
0
0
300
8,724,557
2012-01-04T09:26:00.000
0
1
0
1
python,bash
8,724,602
2
false
0
0
I would suggest you to look at the subprocess module in python. You can start another process using it, manipulate its streams and get the return code.
1
6
0
I'm relatively new to both Python and bash. However, I am finding Python much more intuitive and easier than bash. I have a few bash scripts I have managed to cobble together, but I would like to replace them with Python scripts - for ease of maintenance etc. The bash scripts essentially run python scripts, check the r...
How to run a python script from another python script and get the returned status code?
0
0
0
2,400
8,726,881
2012-01-04T12:29:00.000
0
0
0
0
python,pcap,scapy
34,000,828
4
false
0
0
For correct checksum, I also needed to add del p[UDP].chksum
1
25
0
I am trying to send a previously recorded traffic (captured in pcap format) with scapy. Currently I am stuck at striping original Ether layer. The traffic was captured on another host and I basically need to change both IP and Ether layer src and dst. I managed to replace IP layer and recalculate checksums, but Ether l...
Sending packets from pcap with changed src/dst in scapy
0
0
1
43,692
8,730,927
2012-01-04T17:11:00.000
2
0
1
0
python,bytearray,long-integer,diffie-hellman,rc4-cipher
33,226,324
10
false
0
0
Python 2.7 does not implement the int.to- very slow_bytes() method. I tried 3 methods: hex unpack/pack : very slow byte shifting 8 bits at a time: significantly faster. using a "C" module and packing into the lower (7 ia64 or 3 i32) bytes. This was about twice as fast as 2/ . It is the fastest option, but still too sl...
1
55
0
I'm trying to implement RC4 and DH key exchange in python. Problem is that I have no idea about how to convert the python long/int from the key exchange to the byte array I need for the RC4 implementation. Is there a simple way to convert a long to the required length byte array? Update: forgot to mention that the numb...
Convert python long/int to fixed size byte array
0.039979
0
0
124,134
8,731,179
2012-01-04T17:26:00.000
-1
0
1
1
python,bash,redhat
8,732,259
6
false
0
0
This is a job for cron. Cron man, man cron!
1
2
0
I'm in a red hat environment. I need to move a file from server A to server B when a file is available in a folder F. THere's no constraint on the method used. Is it possible to trigger this event in python or any other scripts? It could be run as a daemon but I'm not sure how to do that. Any advices?
How to start a script based on an event?
-0.033321
0
0
176
8,733,163
2012-01-04T19:58:00.000
1
0
0
0
python,image
8,735,741
1
true
1
0
I know it sounds dumb but, speaking of experience, check that the device on which the script is saving the files is not full (or have permission problems or whatever). Modify your script to print out the URL instead of downloading the file. See if the URL is well printed and if there's no strange character that may be ...
1
0
0
I'm downloading around 200 images from url's using urlretrieve. They all download correctly except for one. I have opened the url in my browser and the image loads correctly. urlretrieve downloads something for that image but it doesn't open. It gives me an error "The file xxx.jpg could not be opened." and it shows...
Python urlretrieve image
1.2
0
1
664
8,733,403
2012-01-04T20:16:00.000
2
0
0
1
python,google-app-engine
8,735,561
1
true
1
0
No, there's no way around this. This limitation exists due to how indexes are constructed. You'll simply have to do either the sorting or the filtering in memory, just as other databases would.
1
0
0
Hey guys I know this is an old issue but I am wondering if there any news about it: I have a simple query where I want to do: filter('created >=', somedatetime).order('-counter') I tried: filter('created >=', somedatetime).order('-created').order('-counter') but because created is a datetime the results are pretty bad....
AppEngine Datastore query with inequality and sort (different attribute). Workaround?
1.2
0
0
177
8,735,487
2012-01-04T23:16:00.000
1
1
0
0
python,ssh,heroku,paramiko,cedar
8,735,515
2
false
1
0
Can you please post the STDERR of ssh -v -L .....? May be you need to disable the tty allocation and run ssh in batch mode.
1
1
0
Is it possible to open a non-blocking ssh tunnel from a python app on the heroku cedar stack? I've tried to do this via paramiko and also asyncproc with no success. On my development box, the tunnel looks like this: ssh -L local_port:remote_server:remote_port another_remote_server
open an ssh tunnel from heroku python app on the cedar stack?
0.099668
0
1
476
8,735,668
2012-01-04T23:37:00.000
1
0
0
0
python,tkinter
12,025,488
2
false
0
1
You could use the PanedWindow widget, or a combination of a few of them, inside your canvas. They are designed to do that. Getting the PanedWindow to stretch like the "sticky" command inside the canvas is an unknown though. That is what I was looking for when stumbled across this post.
1
1
0
I have a number of text widgets floating on a scrollable canvas widget. I want to allow users to resize them by dragging their edges and/or corners, possibly moving them if they drag the upper left edges or corner. I'm open to making them into frames with text widgets inside them, since I'm likely to do that anyway. I ...
Make widgets/frames inside tkinter canvas resizable
0.099668
0
0
3,942
8,736,396
2012-01-05T01:13:00.000
0
0
1
0
python
8,741,894
4
false
0
0
Like the commentators have said, find someone to talk to in your university. The answer to your question will be specific to what software is installed on the grid. If you have access to a grid, it's highly likely you also have access to a person whose job it is to answer your questions (and they will be pleased to h...
1
2
1
I have a two dimensional table (Matrix) I need to process each line in this matrix independently from the others. The process of each line is time consuming. I'd like to use parallel computing resources in our university (Canadian Grid something) Can I have some advise on how to start ? I never used parallel computing ...
Parallel computing
0
0
0
1,155
8,739,227
2012-01-05T07:49:00.000
2
0
1
0
python,numpy,scipy,sympy
21,651,546
9
false
0
0
You can use openopt package and its NLP method. It has many dynamic programming algorithms to solve nonlinear algebraic equations consisting: goldenSection, scipy_fminbound, scipy_bfgs, scipy_cg, scipy_ncg, amsg2p, scipy_lbfgsb, scipy_tnc, bobyqa, ralg, ipopt, scipy_slsqp, scipy_cobyla, lincher, algencan, which you c...
1
82
1
What's the (best) way to solve a pair of non linear equations using Python. (Numpy, Scipy or Sympy) eg: x+y^2 = 4 e^x+ xy = 3 A code snippet which solves the above pair will be great
How to solve a pair of nonlinear equations using Python?
0.044415
0
0
135,871
8,744,604
2012-01-05T15:00:00.000
1
0
0
0
python,xml,sax,saxparser
8,744,989
4
false
1
0
I don't believe it's possible with the xml.sax. BeautifulSoup has SoupStrainer which does exactly that. If you're open to using the library, it's quite easy to work with.
1
3
0
I have pretty big XML documents, so I don't want to use DOM, but while parsing a document with SAX parser I want to stop at some point (let's say when I reached element with a certain name) and get everything inside that element as a string. "Everything" inside is not necessary a text node, it may contain tags, but I d...
Can I somehow tell to SAX parser to stop at some element and get its child nodes as a string?
0.049958
0
1
1,889
8,747,299
2012-01-05T17:56:00.000
1
1
1
0
python,module,imaging
11,829,919
4
false
0
1
try to install pillow. you can install it with the command: pip install pillow you have install the python-imaging?? sudo apt-get install python-imaging. install first the python-imaging and next install the pillow
1
0
0
I'm trying to use a file that uses PIL and when I try to run it I get the following error: ImportError: The _imaging C module is not installed I know theres a bunch of threads online about this but most of them see pretty specific. I'm 100% sure there is no problem with the code I'm running. Python version 2.7.2 64bit ...
Python: PIL _imaging C module
0.049958
0
0
6,417
8,749,108
2012-01-05T20:13:00.000
8
1
1
0
python,import,symlink
41,005,775
2
false
0
0
This kind of behavior can happen if your symbolic links are not set up right. For example, if you created them using relative file paths. In this case the symlinks would be created without error but would not point anywhere meaningful. If this could be the cause of the error, use the full path to create the links and c...
1
17
0
I have a folder A which contains some Python files and __init__.py. If I copy the whole folder A into some other folder B and create there a file with "import A", it works. But now I remove the folder and move in a symbolic link to the original folder. Now it doesn't work, saying "No module named foo". Does anyone know...
Python: import symbolic link of a folder
1
0
0
22,941
8,750,530
2012-01-05T22:07:00.000
1
1
1
1
python,eclipse,pydev
21,244,922
3
false
0
0
Go to: Window > Preferences > PyDev > Interpreter - (Python, Iron python, or Jython) > Libraries You can add a new folder, using the New folder Button, You can add a new egg, using the New Egg button, or remove. If you are experimenting with new versions of libraries, I suggest to remove the old versions, restart eclip...
3
1
0
I'm trying to add a python egg to my eclipse pydev path via Eclipse Settings -> PyDev -> Interpreter - Python -> New Egg/Zip(s), and in the dialog where I browse to the egg file, and click the "open" button on the dialog, it simply keeps the dialog open and browses into the egg. This is on OS X with Helios SR 2.
How to add Python Egg to Eclipse Pydev paths? New Egg button not behaving as expected
0.066568
0
0
2,346
8,750,530
2012-01-05T22:07:00.000
2
1
1
1
python,eclipse,pydev
21,922,683
3
false
0
0
On my Mac I have some .egg's that are files, and some .egg's that are folders, for example my SQLObject is a folder but my oauth is a file. I am not exactly sure why, it could be because of how I downloaded and installed them. The ones that are folders can't be chosen by the "Add zip/jar/egg" chooser, but the simple s...
3
1
0
I'm trying to add a python egg to my eclipse pydev path via Eclipse Settings -> PyDev -> Interpreter - Python -> New Egg/Zip(s), and in the dialog where I browse to the egg file, and click the "open" button on the dialog, it simply keeps the dialog open and browses into the egg. This is on OS X with Helios SR 2.
How to add Python Egg to Eclipse Pydev paths? New Egg button not behaving as expected
0.132549
0
0
2,346
8,750,530
2012-01-05T22:07:00.000
1
1
1
1
python,eclipse,pydev
8,750,576
3
true
0
0
Perhaps this only on OS X, but simple solution was to just add the egg as a folder via New Folder. I'm guessing the New Egg/Zip button is for OS's that don't treat Zips/Eggs as folders.
3
1
0
I'm trying to add a python egg to my eclipse pydev path via Eclipse Settings -> PyDev -> Interpreter - Python -> New Egg/Zip(s), and in the dialog where I browse to the egg file, and click the "open" button on the dialog, it simply keeps the dialog open and browses into the egg. This is on OS X with Helios SR 2.
How to add Python Egg to Eclipse Pydev paths? New Egg button not behaving as expected
1.2
0
0
2,346
8,751,208
2012-01-05T23:05:00.000
1
0
0
0
python,django,authentication,single-sign-on
8,754,198
1
false
1
0
Use a session backend that uses a common store (a database, or redis), which is accessible to both; or openid as suggested by alf.
1
2
0
I have two sites that are very closely linked and both are built with django. They have the same set of users. How would I tell on one site if the user is authenticated on the other?
I have two django sites. How can I tell if a user is already authenticated on one of them?
0.197375
0
0
120
8,751,293
2012-01-05T23:13:00.000
0
0
0
0
python,cassandra,cql
43,361,173
3
false
0
0
Latest versions of Cassandra support aggregations within single partition only.
1
2
1
For example in CQL, SELECT * from abc_dimension ORDER BY key ASC; seems to be not working. Any help?
does cassandra cql support aggregation functions, like group by and order by
0
1
0
3,328
8,752,168
2012-01-06T01:06:00.000
2
0
0
1
python,google-app-engine,model,reference
8,752,433
1
true
1
0
To do this you'd have to write your own custom Property subclass. You should be able to do so by examining the code behind ComputedProperty and ReferenceProperty; in effect you'd be combining the two.
1
0
0
I have a model with an attribute that is a reference to another model. The model it references depends on some logic. Is there a way to have a computed property that gives me the same ReferenceProperty niceties (reverse references, dereferencing)? So far I the computed property stores a db.Key, but this is not optimal....
Is it possible to return a reference property in an App Engine computed property?
1.2
0
0
86
8,753,559
2012-01-06T04:56:00.000
0
0
0
0
python,mysql,database-design
8,754,480
1
false
0
0
I'm using mongodb right now for the first time and I find it to be really awesome in the way it lets you represent a document pretty much like an object oriented class structure. You can easily have a document per user that stores any number of embedded documents. Your players can be in a nested dictionary or a list, a...
1
0
0
We are sketching out how a system would work. The problem is that have a set of items with a computed value for each item. Say for example you like players in the nba and there are a certain set of players that you have shown preferences about. Examples might be: number of games played rebounding scoring assists min...
Caching computed results for each user - would having a table dedicated to each user make sense?
0
1
0
49
8,754,520
2012-01-06T07:06:00.000
0
1
0
0
python,installation
8,754,536
3
false
0
0
Download the source tarballs of the relevant modules and install them locally.
1
7
0
I'm installing python on custom location on a internal server. Unfortunately, I can't make full internet connection here. Most of sites are block by firewall. (essentially pypi repository!) Please don't ask the reason. And I don't have root account, so I have to install python from source. I did install python from sou...
How to install python from source without internet connection?
0
0
0
18,613
8,757,313
2012-01-06T11:43:00.000
1
0
1
0
python,package,temporary-files,temporary-directory
8,757,622
3
false
0
0
Also consider giving the possibility to the user to specify how your library should handle temp files or where to store them
1
2
0
I'm writing a Python library which needs to cache remote data on the local machine. I would like to prevent the library from polluting the OS and placing temp files where they don't belong. To use OS default temp folders seems a bit long winded as I would like to use one OS-Independent way of doing this. Would storing ...
Python - Where should a library store temporary files?
0.066568
0
0
1,916
8,758,131
2012-01-06T12:56:00.000
1
0
0
0
python,jsp,png,screen-scraping,mechanize
8,758,625
1
true
1
0
If you use urllib correctly (for example, making sure your User-Agent resembles a browser etc), the "gibberish" you get back is the actual file, so you just need to write it out to disk (open the file with "wb" for writing in binary mode) and re-read it with some image-manipulation library if you need to play with it. ...
1
0
0
I am trying to grab a PNG image which is being dynamically generated with JSP in a web service. I have tried visiting the web page it is contained in and grabbing the image src attribute; but the link leads to a .jsp file. Reading the response with urllib2 just shows a lot of gibberish. I also need to do this while log...
Grabbing a .jsp generated PNG in Python
1.2
0
1
214
8,758,666
2012-01-06T13:39:00.000
5
0
0
0
python,plone
8,760,668
2
true
1
0
As the initial developer of Dexterity, I'm quite biased, but: Dexterity is cleaner and more 'modern' Dexterity is more consistent with the rest of modern Zope and Plone Dexterity has less boilerplate and Dexterity types generally use less code Dexterity lets you evolve from through-the-web schemata to filesystem devel...
1
2
0
I've been out of the Plone world for a few years (since about Plone 2.5) and I'm trying to get my bearings as to where to invest my time creating new content types, specifically, with new custom fields (including custom view & edit widgets). Can someone help me understand the decision points between Archetypes versus D...
Archetypes vs. Dexterity for new content types and new field types
1.2
0
0
641
8,761,860
2012-01-06T17:27:00.000
0
0
1
0
python,algorithm,data-structures,hash
8,764,642
6
false
0
0
If you are dealing with a book, then you know the vocabulary and the approximate word frequencies. Even if you are not given this information up front, you can get a good estimate by scanning a random sample. For the exact answer, I would use a perfect hash function of the k most common words. A perfect hash function r...
4
5
0
An interview question: Find the most frequently used word in a book. My idea: Use a hash table, traverse and mark the hash table. If the book's size is known, if any word is found to be used > 50%, then skip any new words in the following traversal and only count old words. What if the book size is unknown? It is O...
Design an algorithm, find the most frequently used word in a book
0
0
0
2,901
8,761,860
2012-01-06T17:27:00.000
1
0
1
0
python,algorithm,data-structures,hash
8,762,361
6
false
0
0
Your solution is correct, fast, and probably the best/easiest from a practical standpoint. The other poster's solutions have worse time complexities than your solution. For a hash, as you are using, the time complexity is indeed O(n). Each insertion is O(1) and there are n words, so the insertion phase costs O(n). Ite...
4
5
0
An interview question: Find the most frequently used word in a book. My idea: Use a hash table, traverse and mark the hash table. If the book's size is known, if any word is found to be used > 50%, then skip any new words in the following traversal and only count old words. What if the book size is unknown? It is O...
Design an algorithm, find the most frequently used word in a book
0.033321
0
0
2,901
8,761,860
2012-01-06T17:27:00.000
2
0
1
0
python,algorithm,data-structures,hash
8,762,248
6
false
0
0
To determine complexity I think you need to consider two variables, n = total number of words, m = number of unique words. I imagine the best case complexity will come out close to O(n log(m)) for speed, and O(m) for storage, assuming each time you iterate over each of n words, and build and search based on a hash tab...
4
5
0
An interview question: Find the most frequently used word in a book. My idea: Use a hash table, traverse and mark the hash table. If the book's size is known, if any word is found to be used > 50%, then skip any new words in the following traversal and only count old words. What if the book size is unknown? It is O...
Design an algorithm, find the most frequently used word in a book
0.066568
0
0
2,901
8,761,860
2012-01-06T17:27:00.000
1
0
1
0
python,algorithm,data-structures,hash
8,761,965
6
false
0
0
There is a generalization of your optimization- if the book size is known and any word you have seen has a count > the remaining number of words + the next-highest count, your current highest-counted word is the answer.
4
5
0
An interview question: Find the most frequently used word in a book. My idea: Use a hash table, traverse and mark the hash table. If the book's size is known, if any word is found to be used > 50%, then skip any new words in the following traversal and only count old words. What if the book size is unknown? It is O...
Design an algorithm, find the most frequently used word in a book
0.033321
0
0
2,901
8,762,234
2012-01-06T17:57:00.000
2
0
1
0
c#,c++,python,compiler-construction,recursion
8,762,310
7
false
0
0
How is the compiler or interpreter suppose to know what the function is doing? The scope of the compiler and interpreter is to compile or interpret the syntactical code-- not interpret the semantics of your code. Even if a compiler did check for this, where do you draw the line? What if you had a recursive function tha...
6
10
0
Many months back, I had to fix up some code that caused some problems. The code looked basically like this: int badFun() { return badFun(); } This obviously caused a stack overflow even in the high level language I was working with (4Test in SilkTest). There's no way this code could be seen as beneficial. The first si...
Why doesn't this obvious infinite recursion give a compiler warning?
0.057081
0
0
4,064
8,762,234
2012-01-06T17:57:00.000
38
0
1
0
c#,c++,python,compiler-construction,recursion
8,762,743
7
true
0
0
Here's the deal: compiler warnings are features. Features require effort, and effort is a finite quantity. (It might be measured in dollars or it might be measured in the number of hours someone is willing to give to an open source project, but I assure you, it is finite.) Therefore we have to budget that effort. Ever...
6
10
0
Many months back, I had to fix up some code that caused some problems. The code looked basically like this: int badFun() { return badFun(); } This obviously caused a stack overflow even in the high level language I was working with (4Test in SilkTest). There's no way this code could be seen as beneficial. The first si...
Why doesn't this obvious infinite recursion give a compiler warning?
1.2
0
0
4,064
8,762,234
2012-01-06T17:57:00.000
1
0
1
0
c#,c++,python,compiler-construction,recursion
8,762,271
7
false
0
0
Because compiler will not check for these kind of stuff. If you install a code analyzer like Resharper in Visual Studio it bring a warning of infinite recursive call or sth like that in case you enabled the code analysis option.
6
10
0
Many months back, I had to fix up some code that caused some problems. The code looked basically like this: int badFun() { return badFun(); } This obviously caused a stack overflow even in the high level language I was working with (4Test in SilkTest). There's no way this code could be seen as beneficial. The first si...
Why doesn't this obvious infinite recursion give a compiler warning?
0.028564
0
0
4,064
8,762,234
2012-01-06T17:57:00.000
0
0
1
0
c#,c++,python,compiler-construction,recursion
8,762,375
7
false
0
0
As you have mentioned Compiler just checks syntatical errors. the recursive function isperfectly valid w/o any error. During Runtime, when stack is overflown it throws an error because of stack overflow *not because of code*. Recursive function is perfetly valid, but again in implementation we need to put condition ...
6
10
0
Many months back, I had to fix up some code that caused some problems. The code looked basically like this: int badFun() { return badFun(); } This obviously caused a stack overflow even in the high level language I was working with (4Test in SilkTest). There's no way this code could be seen as beneficial. The first si...
Why doesn't this obvious infinite recursion give a compiler warning?
0
0
0
4,064
8,762,234
2012-01-06T17:57:00.000
3
0
1
0
c#,c++,python,compiler-construction,recursion
8,762,329
7
false
0
0
No compiler of any programming language has any sort of idea about the semantics of the code it compiles. This is valid code, though stupid, so it will be compiled.
6
10
0
Many months back, I had to fix up some code that caused some problems. The code looked basically like this: int badFun() { return badFun(); } This obviously caused a stack overflow even in the high level language I was working with (4Test in SilkTest). There's no way this code could be seen as beneficial. The first si...
Why doesn't this obvious infinite recursion give a compiler warning?
0.085505
0
0
4,064
8,762,234
2012-01-06T17:57:00.000
1
0
1
0
c#,c++,python,compiler-construction,recursion
8,762,299
7
false
0
0
I doubt the compiler can detect a run-time phenomena (stack overflow) at compile time. There is many valid cases to call a function inside itself, recursion. But how can the compiler know the good from the bad cases of recursion? Unless it has some added AI to it, I don't think a compiler could detect the differenc...
6
10
0
Many months back, I had to fix up some code that caused some problems. The code looked basically like this: int badFun() { return badFun(); } This obviously caused a stack overflow even in the high level language I was working with (4Test in SilkTest). There's no way this code could be seen as beneficial. The first si...
Why doesn't this obvious infinite recursion give a compiler warning?
0.028564
0
0
4,064
8,762,797
2012-01-06T18:44:00.000
1
0
0
1
python,google-app-engine,ssl
8,762,875
2
false
0
0
"Use" SLL for what? Joachim has answered regarding serving your pages over SSL. If you want an SSL client, then urlfetch allows https URLS. It gives you no control other than the "validate_certificate" boolean parameter, and I don't immediately see any documentation of what CAs/certificates it trusts. Of course it does...
1
1
0
I want to use SSL on Google App Engine. Is there a 3rd-party Python module I must use or can I just use the Google SDK?
How to use SSL in Python?
0.099668
0
0
1,280
8,763,101
2012-01-06T19:10:00.000
0
0
1
0
python,date,time,gmt
8,763,229
3
false
0
0
Since both dates are in UTC, you don't need any timezone handling. UTC does not have daylight savings time, and the datetime library can convert UTC times without any external library. If you were unclear, and the datestring includes a timezone information in a format that doesn't specify offset, then you do have to us...
3
1
0
I want to convert a datestring to date in UTC . In addition need to compare this date with current time in UTC and get the difference in milliseconds in python. I looked at python timedelta tzinfo time date datetime But all of them seem to be confusing , what the best way to solve my problem w...
datetime , time python
0
0
0
520
8,763,101
2012-01-06T19:10:00.000
0
0
1
0
python,date,time,gmt
8,768,659
3
false
0
0
There is a quite powerful python extension called dateutil. In particular, dateutil.parser is really useful for, well, parsing various date/time formats with timezone information available or not.
3
1
0
I want to convert a datestring to date in UTC . In addition need to compare this date with current time in UTC and get the difference in milliseconds in python. I looked at python timedelta tzinfo time date datetime But all of them seem to be confusing , what the best way to solve my problem w...
datetime , time python
0
0
0
520