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
315,435
2008-11-24T20:53:00.000
0
0
1
0
python,reversi
319,927
6
false
0
0
You may also wish to consider the application of a "fuzzy logic" loop to analyze positions. Reversi/Othello is notorious for forcing players to consider certain strategic gains against strategic losses for each move, as well as prioritizing one positive move over another. A fuzzy system would give you greater control o...
3
3
0
I am trying to write Reversi game in Python. Can anyone give me some basic ideas and strategy which are simple, good and easy to use? I would appreciate for any help because I've gone to a little far but is stucked between codes and it became more complex too. I think I overdid in some part that should be fairly simple...
Need instructions for Reversi game
0
0
0
3,730
315,435
2008-11-24T20:53:00.000
0
0
1
0
python,reversi
315,515
6
false
0
0
You'll need a 2D array. Beware of [[0] * 8] * 8, instead use [[0 for _ in [0] * 8] for _ in [0] * 8] White should be 1 and black -1 (Or vice versa, of course). This way you can do flips with *=-1 and keep blank blank Double four loops will be able to total scores and determine if the game is done pretty well. map(sum,m...
3
3
0
I am trying to write Reversi game in Python. Can anyone give me some basic ideas and strategy which are simple, good and easy to use? I would appreciate for any help because I've gone to a little far but is stucked between codes and it became more complex too. I think I overdid in some part that should be fairly simple...
Need instructions for Reversi game
0
0
0
3,730
315,716
2008-11-24T22:21:00.000
3
0
0
1
python,tcp,twisted,protocols
315,855
2
false
0
0
I'd imagine the easiest way to do that is to manage a list of clients in the protocol with connectionMade and connectionLost in the client and then use a LoopingCall to ask each client to send data. That feels a little invasive, but I don't think you'd want to do it without the protocol having some control over the tra...
1
24
0
I am looking for a way to periodically send some data over all clients connected to a TCP port. I am looking at twisted python and I am aware of reactor.callLater. But how do I use it to send some data to all connected clients periodically ? The data sending logic is in Protocol class and it is instantiated by the reac...
Running a function periodically in twisted protocol
0.291313
0
0
8,021
316,238
2008-11-25T02:53:00.000
30
0
1
0
python,decimal
316,308
11
false
0
0
You said in your question: Can someone suggest a good way to convert from float to Decimal preserving value as the user has entered But every time the user enters a value, it is entered as a string, not as a float. You are converting it to a float somewhere. Convert it to a Decimal directly instead and no prec...
4
76
0
Python Decimal doesn't support being constructed from float; it expects that you have to convert float to a string first. This is very inconvenient since standard string formatters for float require that you specify number of decimal places rather than significant places. So if you have a number that could have as man...
Python float to Decimal conversion
1
0
0
116,354
316,238
2008-11-25T02:53:00.000
5
0
1
0
python,decimal
342,356
11
false
0
0
Python does support Decimal creation from a float. You just cast it as a string first. But the precision loss doesn't occur with string conversion. The float you are converting doesn't have that kind of precision in the first place. (Otherwise you wouldn't need Decimal) I think the confusion here is that we can create ...
4
76
0
Python Decimal doesn't support being constructed from float; it expects that you have to convert float to a string first. This is very inconvenient since standard string formatters for float require that you specify number of decimal places rather than significant places. So if you have a number that could have as man...
Python float to Decimal conversion
0.090659
0
0
116,354
316,238
2008-11-25T02:53:00.000
2
0
1
0
python,decimal
62,046,166
11
false
0
0
The main answer is slightly misleading. The g format ignores any leading zeroes after the decimal point, so format(0.012345, ".2g") returns 0.012 - three decimal places. If you need a hard limit on the number of decimal places, use the f formatter: format(0.012345, ".2f") == 0.01
4
76
0
Python Decimal doesn't support being constructed from float; it expects that you have to convert float to a string first. This is very inconvenient since standard string formatters for float require that you specify number of decimal places rather than significant places. So if you have a number that could have as man...
Python float to Decimal conversion
0.036348
0
0
116,354
316,238
2008-11-25T02:53:00.000
2
0
1
0
python,decimal
316,313
11
false
0
0
When you say "preserving value as the user has entered", why not just store the user-entered value as a string, and pass that to the Decimal constructor?
4
76
0
Python Decimal doesn't support being constructed from float; it expects that you have to convert float to a string first. This is very inconvenient since standard string formatters for float require that you specify number of decimal places rather than significant places. So if you have a number that could have as man...
Python float to Decimal conversion
0.036348
0
0
116,354
316,484
2008-11-25T06:14:00.000
2
0
0
0
python,mysql,winapi
317,716
4
true
0
0
I think that the header files are shipped with MySQL, just make sure you check the appropriate options when installing (I think that sources and headers are under "developer components" in the installation dialog).
1
9
0
I'm using Django and Python 2.6, and I want to grow my application using a MySQL backend. Problem is that there isn't a win32 package for MySQLdb on Python 2.6. Now I'm no hacker, but I thought I might compile it myself using MSVC++9 Express. But I run into a problem that the compiler quickly can't find config_win.h,...
Problem compiling MySQLdb for Python 2.6 on Win32
1.2
1
0
3,446
316,518
2008-11-25T06:41:00.000
1
1
0
1
python,jython,tiff,ghostscript
317,300
1
false
0
0
It may be that you need to read stderr from the child process.
1
0
0
Ghostscript curls up and dies, throwing an exception to stdout which I cannot catch and log. I am pretty sure it gets sick when I give it asian fonts. Has anybody backed into this problem and solved it?
Ghostscript PDF -> TIFF throws an untrappable exception, when consuming files with asian fonts
0.197375
0
0
416
318,390
2008-11-25T18:23:00.000
1
0
1
0
python,numpy
318,422
4
false
0
0
You're running a separate copy of python provided by cygwin. You can run /cygdrive/c/python25/python (or wherever you installed it) to get your win32 one, or just install another copy of numpy.
3
2
0
I am running a windows machine have installed Python 2.5. I also used the windows installer to install NumPy. This all works great when I run the Python (command line) tool that comes with Python. However, if I run cygwin and then run Python from within, it cannot find the numpy package. What environment variable do ...
Running numpy from cygwin
0.049958
0
0
9,602
318,390
2008-11-25T18:23:00.000
4
0
1
0
python,numpy
318,419
4
true
0
0
Cygwin comes with its own version of Python, so it's likely that you have two Python installs on your system; one that installed under Windows and one which came with Cygwin. To test this, try opening a bash prompt in Cygwin and typing which python to see where the Python executable is located. If it says /cygdrive/c/...
3
2
0
I am running a windows machine have installed Python 2.5. I also used the windows installer to install NumPy. This all works great when I run the Python (command line) tool that comes with Python. However, if I run cygwin and then run Python from within, it cannot find the numpy package. What environment variable do ...
Running numpy from cygwin
1.2
0
0
9,602
318,390
2008-11-25T18:23:00.000
0
0
1
0
python,numpy
798,145
4
false
0
0
numpy built for windows is not compatible with cygwin python. You have to build it by yourself on cygwin.
3
2
0
I am running a windows machine have installed Python 2.5. I also used the windows installer to install NumPy. This all works great when I run the Python (command line) tool that comes with Python. However, if I run cygwin and then run Python from within, it cannot find the numpy package. What environment variable do ...
Running numpy from cygwin
0
0
0
9,602
319,232
2008-11-25T23:14:00.000
1
0
1
0
python,assembly
327,529
2
false
0
0
It's certainly doable, but you'd have a much easier time reading the C API docs and writing a go-between function in C. Come to think of it, C is highly recommended, since it may be hard to tell which of the routines you're calling might be implemented as preprocessor macros.
1
2
0
I'll have couple of python functions I must interface with from the assembly code. The solution doesn't need to be a complete solution because I'm not going to interface with python code for too long. Anyway, I chewed it a bit: What does a python object look like in memory? How can I call a python function? How can I ...
How to call python2.5 function from x86asm/x64asm?
0.099668
0
0
126
319,279
2008-11-25T23:40:00.000
0
0
1
0
python,validation,networking,ip-address
17,214,916
11
false
0
0
I only needed to parse IP v4 addresses. My solution based on Chills strategy follows: def getIP(): valid = False while not valid : octets = raw_input( "Remote Machine IP Address:" ).strip().split(".") try: valid=len( filter( lambda(item):0<=int(item)<256, octets) ) == 4 except: valid = ...
1
175
0
What's the best way to validate that an IP entered by the user is valid? It comes in as a string.
How to validate IP address in Python?
0
0
1
305,361
319,426
2008-11-26T01:06:00.000
2
0
1
0
python,comparison,case-insensitive
319,439
12
false
0
0
How about converting to lowercase first? you can use string.lower().
1
700
0
How can I do case insensitive string comparison in Python? I would like to encapsulate comparison of a regular strings to a repository string using in a very simple and Pythonic way. I also would like to have ability to look up values in a dict hashed by strings using regular python strings.
How do I do a case-insensitive string comparison?
0.033321
0
0
984,158
319,896
2008-11-26T06:20:00.000
0
1
1
0
python,email,jython,attachment
320,285
4
false
0
0
Have you tried the get_payload( [i[, decode]]) method? Unlike walk it is not documented to recursively open attachments.
1
3
0
using jython I have a situation where emails come in with different attachments. Certain file types I process others I ignore and dont write to file. I am caught in a rather nasty situation, because sometimes people send an email as an attachment, and that attached email has legal attachments. What I want to do is ski...
How do I skip processing the attachments of an email which is an attachment of a different email
0
0
0
978
320,232
2008-11-26T10:21:00.000
3
0
1
1
python,subprocess,kill,zombie-process
320,251
15
false
0
0
poll( ) Check if child process has terminated. Returns returncode attribute.
1
77
0
Is there a way to ensure all created subprocess are dead at exit time of a Python program? By subprocess I mean those created with subprocess.Popen(). If not, should I iterate over all of the issuing kills and then kills -9? anything cleaner?
Ensuring subprocesses are dead on exiting Python program
0.039979
0
0
78,382
320,979
2008-11-26T14:58:00.000
1
0
0
0
php,python,plone
321,274
3
false
1
0
Well, use AJAX to call the PHP script (yes, you will need apache) and display the output. Adding a custom JS to plone is trivial and this abstract the technology issue. Just be sure this is not a critical feature. Some users still deactivate JS and the web page should therefor degrade itself nicely.
1
2
0
I need to have the output of a PHP snippet in a Plone site. It was delivered to be a small library that has a display() function, in PHP, that outputs a line of text. But I need to put it in a Plone site. Do you have any recommendations? I was thinking a long the lines of having a display.php that just runs display() a...
How to include output of PHP script in Python driven Plone site?
0.066568
0
0
1,656
321,668
2008-11-26T18:21:00.000
1
0
1
0
python,image-processing
323,097
4
false
0
1
Install Python "for all users", not "just for me".
2
4
0
I'm trying to install the Python Imaging Library 1.1.6 for Python 2.6. After downloading the installation executable (Win XP), I receive the following error message: "Application failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem" Any thoughts on what I...
Application configuration incorrect with Python Imaging Library
0.049958
0
0
784
321,668
2008-11-26T18:21:00.000
0
0
1
0
python,image-processing
368,543
4
false
0
1
I got that same message recently to do with the wxPython library. It was because wxPython had been built using a later version of Visual C++ than I had on my PC. As atzz suggests, one solution is to install the appropriate redistributable package. Try a Google search for 'Microsoft Visual C++ 2008 Redistributable Packa...
2
4
0
I'm trying to install the Python Imaging Library 1.1.6 for Python 2.6. After downloading the installation executable (Win XP), I receive the following error message: "Application failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem" Any thoughts on what I...
Application configuration incorrect with Python Imaging Library
0
0
0
784
321,795
2008-11-26T19:09:00.000
3
1
0
0
python,xml,elementtree
322,088
10
false
0
0
Why are you examining the XML data at all? The way to test object serialization is to create an instance of the object, serialize it, deserialize it into a new object, and compare the two objects. When you make a change that breaks serialization or deserialization, this test will fail. The only thing checking the XML ...
2
41
0
I have an object that can build itself from an XML string, and write itself out to an XML string. I'd like to write a unit test to test round tripping through XML, but I'm having trouble comparing the two XML versions. Whitespace and attribute order seem to be the issues. Any suggestions for how to do this? This is in ...
Comparing XML in a unit test in Python
0.059928
0
1
17,177
321,795
2008-11-26T19:09:00.000
0
1
0
0
python,xml,elementtree
322,600
10
false
0
0
The Java component dbUnit does a lot of XML comparisons, so you might find it useful to look at their approach (especially to find any gotchas that they may have already addressed).
2
41
0
I have an object that can build itself from an XML string, and write itself out to an XML string. I'd like to write a unit test to test round tripping through XML, but I'm having trouble comparing the two XML versions. Whitespace and attribute order seem to be the issues. Any suggestions for how to do this? This is in ...
Comparing XML in a unit test in Python
0
0
1
17,177
323,581
2008-11-27T12:10:00.000
1
0
1
0
python,ide
1,399,786
2
false
0
0
If you mean to the interactive console, use ctrl+alt+enter in the pydev editor (version 1.5). That action does a number of things: opens an interactive console view if it's not opened already sends the selected text to the console makes an execfile of the current editor (if no text is selected)
2
4
0
Question so easy that fitted in the title :) Eclipse (pydev): Is it possible to assign a shortcut to send selection to the python console?
Eclipse (pydev): Is it possible to assign a shortcut to send selection to the python console?
0.099668
0
0
859
323,581
2008-11-27T12:10:00.000
1
0
1
0
python,ide
323,789
2
false
0
0
You can only assign shortcuts to "actions". Actions bound to buttons (for example, the toolbar) and menus. If you have a menu for this, you can bind a key to it. If not, then you will have to open an enhancement request in the pydev project.
2
4
0
Question so easy that fitted in the title :) Eclipse (pydev): Is it possible to assign a shortcut to send selection to the python console?
Eclipse (pydev): Is it possible to assign a shortcut to send selection to the python console?
0.099668
0
0
859
323,866
2008-11-27T14:13:00.000
5
0
1
0
c#,java,.net,python
323,891
9
true
0
0
Create a hash table which stores function pointers (in C# that'd be delegates) for handling each of the parameters, keyed using the parameter text. Then you just go through the command line in a loop and make calls to delegates based on what comes out of hash table lookups.
3
4
0
I have a program that can have a lot of parameters (we have over +30 differents options). Example: myProgram.exe -t alpha 1 -prod 1 2 -sleep 200 This is 3 Commands (from command pattern object at the end) that each contain some parameters. Inside the code we parse all command (start with -) and get a list of string (sp...
How to analyse .exe parameters inside the program?
1.2
0
0
1,655
323,866
2008-11-27T14:13:00.000
1
0
1
0
c#,java,.net,python
323,887
9
false
0
0
I'd be a little uncomfortable using a command line like that. First thing I'd say is "what does the first '1' mean, and why is it different to the second '1'?" Any time I write a command line utility that accepts an argument, I consider how easy it would be for a user to learn all the options. In this case, it looks ...
3
4
0
I have a program that can have a lot of parameters (we have over +30 differents options). Example: myProgram.exe -t alpha 1 -prod 1 2 -sleep 200 This is 3 Commands (from command pattern object at the end) that each contain some parameters. Inside the code we parse all command (start with -) and get a list of string (sp...
How to analyse .exe parameters inside the program?
0.022219
0
0
1,655
323,866
2008-11-27T14:13:00.000
0
0
1
0
c#,java,.net,python
325,157
9
false
0
0
Commonly, you can replace large if/else or switch/case constructs with a Dictionary. Where the if-criteria is the key and the code to execute is the value. For example, you could nave a Dictionary<string, ICommand> (or Dictionary<string, Type>), which you fill before you parse your command line. When you iterate over ...
3
4
0
I have a program that can have a lot of parameters (we have over +30 differents options). Example: myProgram.exe -t alpha 1 -prod 1 2 -sleep 200 This is 3 Commands (from command pattern object at the end) that each contain some parameters. Inside the code we parse all command (start with -) and get a list of string (sp...
How to analyse .exe parameters inside the program?
0
0
0
1,655
323,972
2008-11-27T14:55:00.000
-1
0
1
0
python,multithreading,kill,terminate
24,353,228
30
false
0
0
If you really need the ability to kill a sub-task, use an alternate implementation. multiprocessing and gevent both support indiscriminately killing a "thread". Python's threading does not support cancellation. Do not even try. Your code is very likely to deadlock, corrupt or leak memory, or have other unintended "inte...
4
914
0
Is it possible to terminate a running thread without setting/checking any flags/semaphores/etc.?
Is there any way to kill a Thread?
-0.006667
0
0
1,043,639
323,972
2008-11-27T14:55:00.000
134
0
1
0
python,multithreading,kill,terminate
323,993
30
false
0
0
There is no official API to do that, no. You need to use platform API to kill the thread, e.g. pthread_kill, or TerminateThread. You can access such API e.g. through pythonwin, or through ctypes. Notice that this is inherently unsafe. It will likely lead to uncollectable garbage (from local variables of the stack frame...
4
914
0
Is it possible to terminate a running thread without setting/checking any flags/semaphores/etc.?
Is there any way to kill a Thread?
1
0
0
1,043,639
323,972
2008-11-27T14:55:00.000
33
0
1
0
python,multithreading,kill,terminate
323,981
30
false
0
0
You should never forcibly kill a thread without cooperating with it. Killing a thread removes any guarantees that try/finally blocks set up so you might leave locks locked, files open, etc. The only time you can argue that forcibly killing threads is a good idea is to kill a program fast, but never single threads.
4
914
0
Is it possible to terminate a running thread without setting/checking any flags/semaphores/etc.?
Is there any way to kill a Thread?
1
0
0
1,043,639
323,972
2008-11-27T14:55:00.000
11
0
1
0
python,multithreading,kill,terminate
324,002
30
false
0
0
It is better if you don't kill a thread. A way could be to introduce a "try" block into the thread's cycle and to throw an exception when you want to stop the thread (for example a break/return/... that stops your for/while/...). I've used this on my app and it works...
4
914
0
Is it possible to terminate a running thread without setting/checking any flags/semaphores/etc.?
Is there any way to kill a Thread?
1
0
0
1,043,639
325,165
2008-11-28T06:40:00.000
1
1
1
0
python
325,180
9
false
0
0
what language a block of code is written in What are your alternatives, among what languages? There is no way to determine this universally. But if you narrow your focus there is probably a tool somewhere
2
22
0
Writing a python script and it needs to find out what language a block of code is written in. I could easily write this myself, but I'd like to know if a solution already exists. Pygments is insufficient and unreliable.
Is there a library that will detect the source code language of a block of code?
0.022219
0
0
4,415
325,165
2008-11-28T06:40:00.000
0
1
1
0
python
346,832
9
false
0
0
As other have said Pygments will be your best bet.
2
22
0
Writing a python script and it needs to find out what language a block of code is written in. I could easily write this myself, but I'd like to know if a solution already exists. Pygments is insufficient and unreliable.
Is there a library that will detect the source code language of a block of code?
0
0
0
4,415
327,002
2008-11-29T01:24:00.000
9
1
1
0
python,performance
327,009
15
false
0
0
How many square roots are you really performing? Are you trying to write some 3D graphics engine in Python? If not, then why go with code which is cryptic over code that is easy to read? The time difference is would be less than anybody could notice in just about any application I could forsee. I really don't mean ...
4
236
0
I've been wondering this for some time. As the title say, which is faster, the actual function or simply raising to the half power? UPDATE This is not a matter of premature optimization. This is simply a question of how the underlying code actually works. What is the theory of how Python code works? I sent Guido van Ro...
Which is faster in Python: x**.5 or math.sqrt(x)?
1
0
0
100,568
327,002
2008-11-29T01:24:00.000
4
1
1
0
python,performance
327,063
15
false
0
0
using Claudiu's code, on my machine even with "from math import sqrt" x**.5 is faster but using psyco.full() sqrt(x) becomes much faster, at least by 200%
4
236
0
I've been wondering this for some time. As the title say, which is faster, the actual function or simply raising to the half power? UPDATE This is not a matter of premature optimization. This is simply a question of how the underlying code actually works. What is the theory of how Python code works? I sent Guido van Ro...
Which is faster in Python: x**.5 or math.sqrt(x)?
0.053283
0
0
100,568
327,002
2008-11-29T01:24:00.000
3
1
1
0
python,performance
327,005
15
false
0
0
Most likely math.sqrt(x), because it's optimized for square rooting. Benchmarks will provide you the answer you are looking for.
4
236
0
I've been wondering this for some time. As the title say, which is faster, the actual function or simply raising to the half power? UPDATE This is not a matter of premature optimization. This is simply a question of how the underlying code actually works. What is the theory of how Python code works? I sent Guido van Ro...
Which is faster in Python: x**.5 or math.sqrt(x)?
0.039979
0
0
100,568
327,002
2008-11-29T01:24:00.000
-4
1
1
0
python,performance
29,231,648
15
false
0
0
What would be even faster is if you went into math.py and copied the function "sqrt" into your program. It takes time for your program to find math.py, then open it, find the function you are looking for, and then bring that back to your program. If that function is faster even with the "lookup" steps, then the functio...
4
236
0
I've been wondering this for some time. As the title say, which is faster, the actual function or simply raising to the half power? UPDATE This is not a matter of premature optimization. This is simply a question of how the underlying code actually works. What is the theory of how Python code works? I sent Guido van Ro...
Which is faster in Python: x**.5 or math.sqrt(x)?
-1
0
0
100,568
327,026
2008-11-29T01:46:00.000
5
0
0
0
python,linux,curses,bold
53,016,371
2
false
0
1
I tried this: screen.addstr(text, curses.color_pair(1) | curses.A_BOLD) and it worked! So just add curses. and it should do the trick. Of course at the beginning use: import curses
1
6
0
I use something like this: screen.addstr(text, color_pair(1) | A_BOLD), but it doesn't seem to work.. However, A_REVERSE and all others attribute does work! In fact, I'm trying to print something in white, but the COLOR_WHITE prints it gray.. and after a while of searching, it seems that printing it gray + BOLD makes...
Attribute BOLD doesn't seem to work in my curses
0.462117
0
0
6,287
327,101
2008-11-29T03:11:00.000
11
0
0
0
python,ruby-on-rails,web2py
327,684
3
false
1
0
c'mon guys... your only argument is "Technical differences are rather irrelevant." and "it don't matter what web framework you use"? I disagree. The size of the users base has more to do with marketing and how long a framework has been around. By that argument ASP and PHP are better than Rails. Has anybody here us...
3
13
0
web2py to is a Python framework but shares the "convention over configuration" design that Ruby on Rails has. On the plus side it packages a lot more functionality with its s standard distribution and we claim it is faster and easier to use. Has any Rails user tried it? What is your impression? No rants please. Just t...
@Rails users: have you tried web2py? Pros? Cons?
1
0
0
2,962
327,101
2008-11-29T03:11:00.000
1
0
0
0
python,ruby-on-rails,web2py
1,250,930
3
false
1
0
I found web2py much easier to learn... there are fewer scripts to run and abstractions. On the other hand, web2py's database layer isn't a real ORM... it's almost like writing raw SQL. Simple things end up taking many lines of code, just like SQL.
3
13
0
web2py to is a Python framework but shares the "convention over configuration" design that Ruby on Rails has. On the plus side it packages a lot more functionality with its s standard distribution and we claim it is faster and easier to use. Has any Rails user tried it? What is your impression? No rants please. Just t...
@Rails users: have you tried web2py? Pros? Cons?
0.066568
0
0
2,962
327,101
2008-11-29T03:11:00.000
0
0
0
0
python,ruby-on-rails,web2py
327,519
3
false
1
0
I would say the biggest "con" of using webpy over Rails is that there are not a lot of Rails-specific hosting services around, and the huge community based around it (there are Rails plugins and tools for.. everything). The same cannot be said for web2py. It depends what you want to do with it - if it's something to wr...
3
13
0
web2py to is a Python framework but shares the "convention over configuration" design that Ruby on Rails has. On the plus side it packages a lot more functionality with its s standard distribution and we claim it is faster and easier to use. Has any Rails user tried it? What is your impression? No rants please. Just t...
@Rails users: have you tried web2py? Pros? Cons?
0
0
0
2,962
327,142
2008-11-29T04:01:00.000
0
0
0
0
python,django,admin
327,296
5
false
1
0
The session information is stored in the database, so if you're sharing the database with both running instances, logging off one location will log you off both. If your circumstance requires you to share the database, the easiest workaround is probably to create a second user account with admin privileges.
4
3
0
I have two Django projects and applications running on the same Apache installation. Both projects and both applications have the same name, for example myproject.myapplication. They are each in separately named directories so it looks like .../dir1/myproject/myapplication and .../dir2/myproject/myapplication. Eve...
Multiple Django Admin Sites on one Apache... When I log into one I get logged out of the other
0
0
0
1,679
327,142
2008-11-29T04:01:00.000
1
0
0
0
python,django,admin
1,007,356
5
false
1
0
I ran into a similar issue with a live & staging site hosted on the same Apache server (on CentOS). I added unique SESSION_COOKIE_NAME values to each site's settings (in local_settings.py, create one if you don't have one and import it in your settings.py), set the SESSION_COOKIE_DOMAIN for the live site and set SESSIO...
4
3
0
I have two Django projects and applications running on the same Apache installation. Both projects and both applications have the same name, for example myproject.myapplication. They are each in separately named directories so it looks like .../dir1/myproject/myapplication and .../dir2/myproject/myapplication. Eve...
Multiple Django Admin Sites on one Apache... When I log into one I get logged out of the other
0.039979
0
0
1,679
327,142
2008-11-29T04:01:00.000
0
0
0
0
python,django,admin
327,398
5
false
1
0
Let me guess, is this running on your localhost? and you have each site assigned to a different port? i.e. localhost:8000, localhost:8001 ..? I've had the same problem! (although I wasn't running Apache per se) When you login to the admin site, you get a cookie in your browser that's associated with the domain "localho...
4
3
0
I have two Django projects and applications running on the same Apache installation. Both projects and both applications have the same name, for example myproject.myapplication. They are each in separately named directories so it looks like .../dir1/myproject/myapplication and .../dir2/myproject/myapplication. Eve...
Multiple Django Admin Sites on one Apache... When I log into one I get logged out of the other
0
0
0
1,679
327,142
2008-11-29T04:01:00.000
0
0
0
0
python,django,admin
327,237
5
false
1
0
Well, if they have the same project and application names, then the databases and tables will be the same. Your django_session table which holds the session information is the same for both sites. You have to use different project names that will go in different MySQL (or whatever) databases.
4
3
0
I have two Django projects and applications running on the same Apache installation. Both projects and both applications have the same name, for example myproject.myapplication. They are each in separately named directories so it looks like .../dir1/myproject/myapplication and .../dir2/myproject/myapplication. Eve...
Multiple Django Admin Sites on one Apache... When I log into one I get logged out of the other
0
0
0
1,679
327,597
2008-11-29T15:01:00.000
0
0
1
0
python
327,735
6
false
0
1
To your first question I agree with Ali A. To your second question : import sys sys.exit(1)
1
3
0
I'm giving my first steps on Python. I saw that we don't have switch case statement, so I would you guys implement a text Menu in python? Thanks
Suggestion to implement a text Menu without switch case
0
0
0
5,723
327,985
2008-11-29T20:41:00.000
0
0
1
0
python,file
327,992
4
false
0
0
Don't work with files directly, make a data structure that fits your needs in form of a class and make read from/write to file methods.
1
9
0
The last line of my file is: 29-dez,40, How can I modify that line so that it reads: 29-Dez,40,90,100,50 Note: I don't want to write a new line. I want to take the same line and put new values after 29-Dez,40, I'm new at python. I'm having a lot of trouble manipulating files and for me every example I look at seems...
How do I modify the last line of a file?
0
0
0
11,474
328,041
2008-11-29T21:34:00.000
3
1
0
1
python,ruby,perl,bash,scripting-language
328,062
13
false
0
0
If Low memory and low startup time are truly important you might want to consider doing the work to keep the C code cross platform, however I have found this is rarely necessary. Personally I would use Ruby or Python for this type of job, they both make it very easy to make clear understandable code that others can mai...
9
10
0
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single ...
Scripting language choice for initial performance
0.046121
0
0
8,004
328,041
2008-11-29T21:34:00.000
0
1
0
1
python,ruby,perl,bash,scripting-language
328,075
13
false
0
0
I agree with others in that you should probably try to make this a more portable C app instead of porting it over to something else since any scripting language is going to introduce significant overhead from a startup perspective, have a much larger memory footprint, and will probably be much slower. In my experience,...
9
10
0
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single ...
Scripting language choice for initial performance
0
0
0
8,004
328,041
2008-11-29T21:34:00.000
5
1
0
1
python,ruby,perl,bash,scripting-language
328,054
13
false
0
0
When written properly, C should be platform independant and would only need a recompile for those different platforms. You might have to jump through some #ifdef hoops for the headers (not all systems use the same headers), but most normal (non-win32 API) calls are very portable. For web access (which I presume you nee...
9
10
0
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single ...
Scripting language choice for initial performance
0.076772
0
0
8,004
328,041
2008-11-29T21:34:00.000
4
1
0
1
python,ruby,perl,bash,scripting-language
328,120
13
false
0
0
I concur with Lua: it is super-portable, it has XML libraries, either native or by binding C libraries like Expat, it has a good socket library (LuaSocket) plus, for complex stuff, some cURL bindings, and is well known for being very lightweight (often embedded in low memory devices), very fast (one of the fastest scri...
9
10
0
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single ...
Scripting language choice for initial performance
0.061461
0
0
8,004
328,041
2008-11-29T21:34:00.000
9
1
0
1
python,ruby,perl,bash,scripting-language
328,065
13
true
0
0
Because of your requirement for fast startup time and a calling frequency greater than 1Hz I'd recommend either staying with C and figuring out how to make it portable (not always as easy as a few ifdefs) or exploring the possibility of turning it into a service daemon that is always running. Of course this depends on ...
9
10
0
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single ...
Scripting language choice for initial performance
1.2
0
0
8,004
328,041
2008-11-29T21:34:00.000
23
1
0
1
python,ruby,perl,bash,scripting-language
328,045
13
false
0
0
Lua is a scripting language that meets your criteria. It's certainly the fastest and lowest memory scripting language available.
9
10
0
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single ...
Scripting language choice for initial performance
1
0
0
8,004
328,041
2008-11-29T21:34:00.000
0
1
0
1
python,ruby,perl,bash,scripting-language
328,519
13
false
0
0
Port your app to Ruby. If your app is too slow, profile it and rewrite the those parts in C.
9
10
0
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single ...
Scripting language choice for initial performance
0
0
0
8,004
328,041
2008-11-29T21:34:00.000
6
1
0
1
python,ruby,perl,bash,scripting-language
328,129
13
false
0
0
"called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important." This doesn't sound like a script to me at all. This sounds like a server handling requests that arrive from every minute to several times a second. If it's a server, handling requests,...
9
10
0
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single ...
Scripting language choice for initial performance
1
0
0
8,004
328,041
2008-11-29T21:34:00.000
0
1
0
1
python,ruby,perl,bash,scripting-language
328,132
13
false
0
0
Can you instead have it be a long-running process and answer http or rpc requests? This would satisfy the latency requirements in almost any scenario, but I don't know if that would break your memory footprint constraints.
9
10
0
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single ...
Scripting language choice for initial performance
0
0
0
8,004
328,107
2008-11-29T22:37:00.000
9
0
1
0
python,math,geometry
328,142
21
false
0
0
Here's another approach: Lets assume the two points be A (x1,y1) and B (x2,y2) The equation of the line passing through those points is (x-x1)/(y-y1)=(x2-x1)/(y2-y1) .. (just making equating the slopes) Point C (x3,y3) will lie between A & B if: x3,y3 satisfies the above equation. x3 lies between x1 & x2 and y3 li...
2
111
0
Let's say you have a two dimensional plane with 2 points (called a and b) on it represented by an x integer and a y integer for each point. How can you determine if another point c is on the line segment defined by a and b? I use python most, but examples in any language would be helpful.
How can you determine a point is between two other points on a line segment?
1
0
0
146,297
328,107
2008-11-29T22:37:00.000
0
0
1
0
python,math,geometry
329,347
21
false
0
0
how about just ensuring that the slope is the same and the point is between the others? given points (x1, y1) and (x2, y2) ( with x2 > x1) and candidate point (a,b) if (b-y1) / (a-x1) = (y2-y2) / (x2-x1) And x1 < a < x2 Then (a,b) must be on line between (x1,y1) and (x2, y2)
2
111
0
Let's say you have a two dimensional plane with 2 points (called a and b) on it represented by an x integer and a y integer for each point. How can you determine if another point c is on the line segment defined by a and b? I use python most, but examples in any language would be helpful.
How can you determine a point is between two other points on a line segment?
0
0
0
146,297
328,577
2008-11-30T07:14:00.000
4
1
1
0
c++,python
328,599
8
false
0
1
I learned a lot about Python by reading the source of the standard library that ships with Python. I seem to remember having a few "a-ha!" moments when reading urllib2.py in particular.
3
56
0
I'm a long time C++/Java developer trying to get into Python and am looking for the stereotypical "Python for C++ Developers" article, but coming up blank. I've seen these sort of things for C#, Java, etc, and they're incredibly useful for getting up to speed on language features and noteworthy differences. Anyone ha...
Python for C++ Developers
0.099668
0
0
43,679
328,577
2008-11-30T07:14:00.000
0
1
1
0
c++,python
328,598
8
false
0
1
For the best examples of code of a language, the language's standard library is often a good place to look. Pick a recent piece, though - old parts are probably written for older versions and also sometimes were written before the library became big enough to warrant big standards - like PHP and Erlang's libraries, whi...
3
56
0
I'm a long time C++/Java developer trying to get into Python and am looking for the stereotypical "Python for C++ Developers" article, but coming up blank. I've seen these sort of things for C#, Java, etc, and they're incredibly useful for getting up to speed on language features and noteworthy differences. Anyone ha...
Python for C++ Developers
0
0
0
43,679
328,577
2008-11-30T07:14:00.000
1
1
1
0
c++,python
328,689
8
false
0
1
C# and Java are seen as cleaner replacements for C++ in many application areas so there is often a "migration" from one to the other - which is why there are books available. Python and C++ are very different beasts, and although they are both considered general purpose programming languages they are targetted towards ...
3
56
0
I'm a long time C++/Java developer trying to get into Python and am looking for the stereotypical "Python for C++ Developers" article, but coming up blank. I've seen these sort of things for C#, Java, etc, and they're incredibly useful for getting up to speed on language features and noteworthy differences. Anyone ha...
Python for C++ Developers
0.024995
0
0
43,679
331,377
2008-12-01T16:40:00.000
2
0
1
1
python,linux,deployment
331,703
4
false
0
0
But if you make a deb with the correct dependencies listed the installer will download them for the user. That's the best way, as it's non redundant. Maybe you could make a tar or zip with your deb and all the third-party deb's and an install script that just install all the debs in the correct order. This way, if the...
1
4
0
How to pack python libs I'm using so I can distribute them with my app and have as few dependencies as possible and also not to conflict with different lib/version that is already on my system. L.E.: Sorry i forgot to specify. I will be doing this on linux. And I'm not referring in making my app a installable file like...
How to pack python libs I'm using so I can distribute them with my app and have as few dependencies as possible
0.099668
0
0
505
331,855
2008-12-01T19:10:00.000
1
1
0
0
python,http,http-headers
331,871
2
false
0
0
When you open the URL with urllib2, and you're redirected, you get a status 30x for redirection. Check the info to see the location to which you're redirected. You don't need to read the page to read the info() that's part of the response.
1
5
0
I need to check whether a page is being redirected or not without actually downloading the content. I just need the final URL. What's the best way of doing this is Python? Thanks!
How to determine if a page is being redirected
0.099668
0
1
3,318
331,918
2008-12-01T19:31:00.000
4
0
1
0
python,pdf,imagemagick,jpeg,python-imaging-library
657,704
5
false
1
0
You can't avoid the Ghostscript dependency. Even Imagemagick relies on Ghostscript for its PDF reading functions. The reason for this is the complexity of the PDF format: a PDF doesn't just contain bitmap information, but mostly vector shapes, transparencies etc. Furthermore it is quite complex to figure out which of t...
1
50
0
I'm attempting to use Python to convert a multi-page PDF into a series of JPEGs. I can split the PDF up into individual pages easily enough with available tools, but I haven't been able to find anything that can covert PDFs to images. PIL does not work, as it can't read PDFs. The two options I've found are using either...
Converting a PDF to a series of images with Python
0.158649
0
0
44,444
332,255
2008-12-01T21:17:00.000
6
0
1
0
python
332,575
4
false
0
0
Subclassing object yields a new-style class. Two well known advantages of new-style classes are: Metaclasses (like class factories, but works transparently) Properties (getters & setters...)
1
72
0
I know class foo(object) is an old school way of defining a class. But I would like to understand in more detail the difference between these two.
Difference between class foo and class foo(object) in Python
1
0
0
33,698
333,995
2008-12-02T13:58:00.000
28
0
1
0
python,debugging
334,090
10
false
0
0
Python debuggers (as well as profilers and coverage tools) use the sys.settrace function (in the sys module) to register a callback that gets called when interesting events happen. If you're using Python 2.6, you can call sys.gettrace() to get the current trace callback function. If it's not None then you can assume yo...
1
35
0
Is there a simple way to detect, within Python code, that this code is being executed through the Python debugger? I have a small Python application that uses Java code (thanks to JPype). When I'm debugging the Python part, I'd like the embedded JVM to be passed debug options too.
How to detect that Python code is being executed through the debugger?
1
0
0
9,637
334,765
2008-12-02T17:30:00.000
1
0
0
0
python,symbian,s60,pys60
337,308
2
true
0
1
Linux is not officially supported for Series60 development yet. You will save yourself a lot of headache using Windows, weirdly enough. As far as Python is oncerned, I think the developed application is packaged into a .sis file but still requires the PyS60 interpreter to run once installed.
1
9
0
I am currently looking at developing a mobile apps for the S60 platform and is specifically looking at PyS60. It seems to suggest that the it can be compiled into native .sis files without the need for an embedded python interpreter. Reading through the documentations I could not find any statements where this is expli...
Does PyS60 produce sis files that are native?
1.2
0
0
1,161
335,078
2008-12-02T19:09:00.000
5
0
1
0
python
335,106
4
false
0
0
There is no other way to compute the size than recursively invoking stat. This is independent of Python; the operating system just provides no other way. The algorithm doesn't have to be recursive; you can use os.walk. There might be two exceptions to make it more efficient: If all the files you want to measure fill a...
2
6
0
If there will be a small number of files it should be easy with a recursive function to pass through all the files and add the size but what if there are lots of files, and by lots i really mean lots of files.
What's the best way to get the size of a folder and all the files inside from python?
0.244919
0
0
3,802
335,078
2008-12-02T19:09:00.000
0
0
1
0
python
9,439,237
4
false
0
0
If you are on a posix system that provides du, you should be able to use pexpect.run or subprocess to execute du <path to folder> to get the size of the folder and subfiles. Keep in mind it will output a string with each file listed and each folder totaled. (Look at the du manpage to see what you can do to limit that...
2
6
0
If there will be a small number of files it should be easy with a recursive function to pass through all the files and add the size but what if there are lots of files, and by lots i really mean lots of files.
What's the best way to get the size of a folder and all the files inside from python?
0
0
0
3,802
336,753
2008-12-03T10:29:00.000
1
0
0
0
python,django,forms
337,753
2
true
1
0
There's a lot that you can do, but you'd need to be more specific about what you mean by "integrate a formwizard into the admin app" and "trigger several forms within the admin app." The admin app at its core is basically just a wrapper around a bunch of stock ModelForms, so if you just build a formwizard using ModelFo...
1
3
0
I have a series of forms that I need a user to complete in sequence, which is perfect for the formwizard app. However, I've some need of the admin application also and would like to set the whole thing up to trigger several forms within the admin app. Is it possible/easy to integrate a 'formwizard' into the admin appl...
Django FormWizard and Admin application
1.2
0
0
1,539
336,963
2008-12-03T12:36:00.000
0
0
1
0
python,optparse
3,882,232
5
false
0
0
metavar is a variable used for print in the screen after option. Usually used for suggestion input after option are FILE or INT or STRING to user. Without metavar, optparse will print dest value after option you've been added.
1
26
0
I am not sure what optparse's metavar parameter is used for. I see it is used all around, but I can't see its use. Can someone make it clear to me? Thanks.
Python optparse metavar
0
0
0
12,451
337,870
2008-12-03T16:54:00.000
7
0
1
1
python,multithreading,subprocess
337,990
3
true
0
0
sys.stdin and sys.stdout handles are invalid because pythonw does not provide console support as it runs as a deamon, so default arguments of subprocess.call() are failing. Deamon programs close stdin/stdout/stderr purposedly and use logging instead, so that you have to manage this yourself: I would suggest to use subp...
2
5
0
I have some Python code that works correctly when I use python.exe to run it, but fails if I use pythonw.exe. def runStuff(commandLine): outputFileName = 'somefile.txt' outputFile = open(outputFileName, "w") try: result = subprocess.call(commandLine, shell=True, stdout=outputFi...
Python subprocess.call() fails when using pythonw.exe
1.2
0
0
6,198
337,870
2008-12-03T16:54:00.000
2
0
1
1
python,multithreading,subprocess
25,453,133
3
false
0
0
This is an old question, but the same problem happened with pyInstaller too. In the truth, this will happen with any framework that converts code in python for exe without console. In my tests, I observed that if I use the flag "console=True" into my spec file (pyInstaller) the error no longer occurs. . The solution w...
2
5
0
I have some Python code that works correctly when I use python.exe to run it, but fails if I use pythonw.exe. def runStuff(commandLine): outputFileName = 'somefile.txt' outputFile = open(outputFileName, "w") try: result = subprocess.call(commandLine, shell=True, stdout=outputFi...
Python subprocess.call() fails when using pythonw.exe
0.132549
0
0
6,198
338,103
2008-12-03T17:56:00.000
4
0
1
0
python,macos,configuration,emacs,ipython
1,607,236
3
false
0
0
also ipython wont load with the official python.el being used with emacs 23.1.1
2
11
0
I'm running Emacs 22.1.1 and IPython 0.9.1 on OS X and I'd like to be able to run lines/methods/snippets of Python code from my current buffer on demand inside an IPython interpreter. What do I need to do to get this working?
How do I use IPython as my Emacs Python interpreter?
0.26052
0
0
5,820
338,103
2008-12-03T17:56:00.000
0
0
1
0
python,macos,configuration,emacs,ipython
26,387,688
3
false
0
0
python-mode.el supports IPython natively. Just make sure shebang doesn't point to another interpreter. In this case: either call a command with ending "-ipython", which will override shebang customize "ipython" as default interpreter and set `py-force-py-shell-name-p'. This might be done also via menu Python/.../Swit...
2
11
0
I'm running Emacs 22.1.1 and IPython 0.9.1 on OS X and I'd like to be able to run lines/methods/snippets of Python code from my current buffer on demand inside an IPython interpreter. What do I need to do to get this working?
How do I use IPython as my Emacs Python interpreter?
0
0
0
5,820
338,767
2008-12-03T21:26:00.000
12
0
1
0
python,indentation
510,920
5
false
0
0
:retab will swap tab with spaces, and :retab! will swap spaces with tab. 1 tab = 4 spaces, 4 spaces = 1 tab, depending on your tab setting.
3
12
0
I have a some .py files that use spaces for indentation, and I'd like to convert them to tabs. I could easily hack together something using regexes, but I can think of several edge cases where this approach could fail. Is there a tool that does this by parsing the file and determining the indentation level the same wa...
Tool to convert python indentation from spaces to tabs?
1
0
0
14,275
338,767
2008-12-03T21:26:00.000
16
0
1
0
python,indentation
338,929
5
false
0
0
Python includes a script for the opposite (tabs to spaces). It's C:\Python24\Tools\Scripts\reindent.py for me
3
12
0
I have a some .py files that use spaces for indentation, and I'd like to convert them to tabs. I could easily hack together something using regexes, but I can think of several edge cases where this approach could fail. Is there a tool that does this by parsing the file and determining the indentation level the same wa...
Tool to convert python indentation from spaces to tabs?
1
0
0
14,275
338,767
2008-12-03T21:26:00.000
3
0
1
0
python,indentation
338,966
5
false
0
0
In emacs, M-x tabify will convert spaces to tabs where possible. You'll probably want to set the tab-width variable appropriately. I don't know if this addresses your concern that spaces be interpreted in the same way as the python interpreter, but you could always load up python-mode and use M-x indent-region.
3
12
0
I have a some .py files that use spaces for indentation, and I'd like to convert them to tabs. I could easily hack together something using regexes, but I can think of several edge cases where this approach could fail. Is there a tool that does this by parsing the file and determining the indentation level the same wa...
Tool to convert python indentation from spaces to tabs?
0.119427
0
0
14,275
339,217
2008-12-04T00:17:00.000
2
0
1
0
python,dsl,dsl-tools
343,028
8
false
0
0
DSLs are a good thing, so you don't need to defend yourself :-) However, have you considered an internal DSL ? These have so many pros versus external (parsed) DSLs that they're at least worth consideration. Mixing a DSL with the power of the native language really solves lots of the problems for you, and Python is not...
1
6
0
I am writing a game in python and have decided to create a DSL for the map data files. I know I could write my own parser with regex, but I am wondering if there are existing python tools which can do this more easily, like re2c which is used in the PHP engine. Some extra info: Yes, I do need a DSL, and even if I didn...
Writing a compiler for a DSL in python
0.049958
0
0
8,510
340,128
2008-12-04T10:21:00.000
0
1
0
0
c#,python,unit-testing,ironpython
342,457
8
false
0
1
Very interesting. What would happen if you write all your code with IronPython (not just the unit tests)? Would you end up with approximately 10 times less code? Maybe I should learn IronPython too.
6
13
0
We know that Python provides a lot of productivity over any compiled languages. We have programming in C# & need to write the unit test cases in C# itself. If we see the amount of code we write for unit test is approximately ten times more than the original code. Is it ideal choice to write unit test cases in IronPyt...
IronPython For Unit Testing over C#
0
0
0
3,355
340,128
2008-12-04T10:21:00.000
0
1
0
0
c#,python,unit-testing,ironpython
443,959
8
false
0
1
I gotta go with Will and Jon.. I would prefer my tests be in the same language as the code I'm testing; it causes fewer cognitive context switches. But maybe I'm just not as mentally agile as I once was. Jon
6
13
0
We know that Python provides a lot of productivity over any compiled languages. We have programming in C# & need to write the unit test cases in C# itself. If we see the amount of code we write for unit test is approximately ten times more than the original code. Is it ideal choice to write unit test cases in IronPyt...
IronPython For Unit Testing over C#
0
0
0
3,355
340,128
2008-12-04T10:21:00.000
3
1
0
0
c#,python,unit-testing,ironpython
342,490
8
false
0
1
Actually testing is a great opportunity to try integrating a new language. Languages like Python shine especially well in testing, and it's a low risk project to try - the worst case is not too bad at all. As far as experience testing another language in Python, I've tested C and C++ systems like this and it was excell...
6
13
0
We know that Python provides a lot of productivity over any compiled languages. We have programming in C# & need to write the unit test cases in C# itself. If we see the amount of code we write for unit test is approximately ten times more than the original code. Is it ideal choice to write unit test cases in IronPyt...
IronPython For Unit Testing over C#
0.07486
0
0
3,355
340,128
2008-12-04T10:21:00.000
3
1
0
0
c#,python,unit-testing,ironpython
341,683
8
false
0
1
Python being a much less verbose language than C# might actually lower the barrier to writing unit tests since there is still a lot of developers that are resistant to doing automated unit testing in general. Introducing and having them use a language like IronPython that typically tends to take less time to write the ...
6
13
0
We know that Python provides a lot of productivity over any compiled languages. We have programming in C# & need to write the unit test cases in C# itself. If we see the amount of code we write for unit test is approximately ten times more than the original code. Is it ideal choice to write unit test cases in IronPyt...
IronPython For Unit Testing over C#
0.07486
0
0
3,355
340,128
2008-12-04T10:21:00.000
6
1
0
0
c#,python,unit-testing,ironpython
346,907
8
false
0
1
Python is excellent for UnitTesting C# code. Our app is 75% in Python and 25% C#(Python.Net), and our unit tests are 100% python. I find that it's much easier to make use of stubs and mocks in Python which is probably one of the most critical components that enable one to write effective unittests.
6
13
0
We know that Python provides a lot of productivity over any compiled languages. We have programming in C# & need to write the unit test cases in C# itself. If we see the amount of code we write for unit test is approximately ten times more than the original code. Is it ideal choice to write unit test cases in IronPyt...
IronPython For Unit Testing over C#
1
0
0
3,355
340,128
2008-12-04T10:21:00.000
2
1
0
0
c#,python,unit-testing,ironpython
340,152
8
false
0
1
There's an obvious disadvantage which is that everyone working on the code now needs to be proficient in two languages, not just one. I'm fairly hairy but not very pointy, but I do see why managers might be sceptical.
6
13
0
We know that Python provides a lot of productivity over any compiled languages. We have programming in C# & need to write the unit test cases in C# itself. If we see the amount of code we write for unit test is approximately ten times more than the original code. Is it ideal choice to write unit test cases in IronPyt...
IronPython For Unit Testing over C#
0.049958
0
0
3,355
340,318
2008-12-04T11:48:00.000
14
1
0
0
php,python
340,338
11
true
1
0
You need to take some parts into mind here, What will you gain from re-writing Is it an economically wise decision Will the code be easier to handle for new programmers Performance-wise, will this be a good option? These four points is something that is important, will the work be more efficient after you re-write th...
8
6
0
I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in...
Is rewriting a PHP app into Python a productive step?
1.2
0
0
1,366
340,318
2008-12-04T11:48:00.000
1
1
0
0
php,python
340,792
11
false
1
0
As others have said, re-writing will take a lot longer than you think and fixing all the bugs and making use everything worked like in the old version will take even longer. Chances are you are better off simply improving and refactoring the php code you have. There are only a few good reasons to port a project from o...
8
6
0
I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in...
Is rewriting a PHP app into Python a productive step?
0.01818
0
0
1,366
340,318
2008-12-04T11:48:00.000
0
1
0
0
php,python
340,719
11
false
1
0
Other issues include how business critical are the applications and how hard will it be to find maintainers. If the pages are hobbies of yours then I don't see a reason why you shouldn't rewrite them since if you introduce bugs or the rewrite doesn't go according to schedule a business won't lose money. If the applicat...
8
6
0
I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in...
Is rewriting a PHP app into Python a productive step?
0
0
0
1,366
340,318
2008-12-04T11:48:00.000
1
1
0
0
php,python
340,685
11
false
1
0
If you are going to add more features to the code you already have working, then it might be a good idea to port it to python. After all, it will get you increased productivity. You just have to balance it, whether the rewriting task will not outweigh the potential gain... And also, when you do that, try to unittest a...
8
6
0
I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in...
Is rewriting a PHP app into Python a productive step?
0.01818
0
0
1,366
340,318
2008-12-04T11:48:00.000
2
1
0
0
php,python
340,342
11
false
1
0
Well, it depends... ;) If you're going to use the old code together with new Python code, it might be useful, not so much for speed but for easier integration. But usually: "If it ain't broke, don't fix it". Allso rewriting can result in better code, but only do it if you need to. As a hobby project of course it's wort...
8
6
0
I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in...
Is rewriting a PHP app into Python a productive step?
0.036348
0
0
1,366
340,318
2008-12-04T11:48:00.000
1
1
0
0
php,python
341,834
11
false
1
0
I did a conversion between a PHP site and a Turbogears(Python) site for my company. The initial reason for doing so was two fold, first so a redesign would be easier and second that features could be easily added. It did take a while to get the full conversion done, but what we end up with was a very flexible back en...
8
6
0
I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in...
Is rewriting a PHP app into Python a productive step?
0.01818
0
0
1,366
340,318
2008-12-04T11:48:00.000
2
1
0
0
php,python
340,604
11
false
1
0
As others have said, look at why you are doing it. For instance, at work I am rewriting our existing inventory/sales system to a Python/django backend. Why? Because the existing PHP code base is stale, and is going to scale poorly as we grow our business (plus it was built when our business model was different, then p...
8
6
0
I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in...
Is rewriting a PHP app into Python a productive step?
0.036348
0
0
1,366
340,318
2008-12-04T11:48:00.000
1
1
0
0
php,python
340,334
11
false
1
0
Is your aim purely to improve the applications, or is it that you want to learn/work with Python? If it's the first, I would say you should stick with PHP, since you already know that.
8
6
0
I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in...
Is rewriting a PHP app into Python a productive step?
0.01818
0
0
1,366
341,138
2008-12-04T16:06:00.000
4
0
1
1
python,windows
341,369
2
true
0
0
found it win32api.InitiateSystemShutdown("localhost", "Maintenance Reboot", 60, 1, 1)
1
4
0
How can I reboot a Windows XP64 Machine in a Python Script? This machine does not have the "shutdown" or "restart" executables available.
How can I reboot a Windows XP64 Machine in a Python Script?
1.2
0
0
521
341,184
2008-12-04T16:18:00.000
1
0
1
1
python,windows,python-3.x,compatibility
341,231
20
false
0
0
I think there is an option to setup the windows file association for .py files in the installer. Uncheck it and you should be fine. If not, you can easily re-associate .py files with the previous version. The simplest way is to right click on a .py file, select "open with" / "choose program". On the dialog that appe...
5
176
0
I'm running Windows and the shell/OS automatically runs Python based on the registry settings when you run a program on the command line. Will this break if I install a 2.x and 3.x version of Python on the same machine? I want to play with Python 3 while still being able to run 2.x scripts on the same machine.
Can I install Python 3.x and 2.x on the same Windows computer?
0.01
0
0
244,252
341,184
2008-12-04T16:18:00.000
0
0
1
1
python,windows,python-3.x,compatibility
341,444
20
false
0
0
I would assume so, I have Python 2.4, 2.5 and 2.6 installed side-by-side on the same computer.
5
176
0
I'm running Windows and the shell/OS automatically runs Python based on the registry settings when you run a program on the command line. Will this break if I install a 2.x and 3.x version of Python on the same machine? I want to play with Python 3 while still being able to run 2.x scripts on the same machine.
Can I install Python 3.x and 2.x on the same Windows computer?
0
0
0
244,252
341,184
2008-12-04T16:18:00.000
1
0
1
1
python,windows,python-3.x,compatibility
453,580
20
false
0
0
You should make sure that the PATH environment variable doesn't contain both python.exe files ( add the one you're currently using to run scripts on a day to day basis ) , or do as Kniht suggested with the batch files . Aside from that , I don't see why not . P.S : I have 2.6 installed as my "primary" python and 3.0 as...
5
176
0
I'm running Windows and the shell/OS automatically runs Python based on the registry settings when you run a program on the command line. Will this break if I install a 2.x and 3.x version of Python on the same machine? I want to play with Python 3 while still being able to run 2.x scripts on the same machine.
Can I install Python 3.x and 2.x on the same Windows computer?
0.01
0
0
244,252
341,184
2008-12-04T16:18:00.000
4
0
1
1
python,windows,python-3.x,compatibility
341,216
20
false
0
0
As far as I know Python runs off of the commandline using the PATH variable as opposed to a registry setting. So if you point to the correct version on your PATH you will use that. Remember to restart your command prompt to use the new PATH settings.
5
176
0
I'm running Windows and the shell/OS automatically runs Python based on the registry settings when you run a program on the command line. Will this break if I install a 2.x and 3.x version of Python on the same machine? I want to play with Python 3 while still being able to run 2.x scripts on the same machine.
Can I install Python 3.x and 2.x on the same Windows computer?
0.039979
0
0
244,252
341,184
2008-12-04T16:18:00.000
0
0
1
1
python,windows,python-3.x,compatibility
42,079,860
20
false
0
0
I am just starting out with python now. I'm reading Zed Shaw's book "Learn Python the Hard Way" which requires python version 2.x but am also taking a class that requires python 3.x So here is what I did. Download python 2.7 run power shell (should already be installed on windows) run python IN POWERSHELL (if it does...
5
176
0
I'm running Windows and the shell/OS automatically runs Python based on the registry settings when you run a program on the command line. Will this break if I install a 2.x and 3.x version of Python on the same machine? I want to play with Python 3 while still being able to run 2.x scripts on the same machine.
Can I install Python 3.x and 2.x on the same Windows computer?
0
0
0
244,252
342,425
2008-12-04T23:16:00.000
4
0
1
0
python,deployment,shared-libraries,projects-and-solutions
342,442
3
false
0
0
"explicitly tested against App1,2,3 every time there was a new library" actually isn't that onerous. Two things. You need a formal set of API unit tests that the library must pass. This is just the API, not every nuance of functionality. If this passes, then your changes are good to go. If this fails, your changes ...
1
4
0
Our company (xyz) is moving a lot of our Flash code to Python. In Flash, we have a shared library between our Flash apps - package xyz. We can make changes to the package without fear of breaking other apps when they are deployed because Flash compiles their code and includes the contents of the library. We deploy the ...
Best way of sharing/managing our internal python library between applications
0.26052
0
0
1,065