Available Count
int64
1
31
AnswerCount
int64
1
35
GUI and Desktop Applications
int64
0
1
Users Score
int64
-17
588
Q_Score
int64
0
6.79k
Python Basics and Environment
int64
0
1
Score
float64
-1
1.2
Networking and APIs
int64
0
1
Question
stringlengths
15
7.24k
Database and SQL
int64
0
1
Tags
stringlengths
6
76
CreationDate
stringlengths
23
23
System Administration and DevOps
int64
0
1
Q_Id
int64
469
38.2M
Answer
stringlengths
15
7k
Data Science and Machine Learning
int64
0
1
ViewCount
int64
13
1.88M
is_accepted
bool
2 classes
Web Development
int64
0
1
Other
int64
1
1
Title
stringlengths
15
142
A_Id
int64
518
72.2M
1
2
0
0
1
1
0
0
I need to access the Scripts and tcl sub-directories of the currently executing Python instance's installation directory on Windows. What is the best way to locate these directories?
0
python,windows,installation,path,python-3.x
2010-02-16T21:31:00.000
1
2,276,512
Hmm, find the Lib dir from sys.path and extrapolate from there?
0
590
false
0
1
Path of current Python instance?
2,276,543
1
4
0
1
4
1
0.049958
0
I have a big library written in C++ and someone created an interface to use it in python (2.6) in an automatic way. Now I have a lot of classes with getter and setter methods. Really: I hate them. I want to re-implement the classes with a more pythonic interface using properties. The problem is that every class has hundreds of getters and setters and I have a lot of classes. How can I automatically create properties? For example, if I have a class called MyClass with a GetX() and SetX(x), GetY, SetY, etc... methods, how can I automatically create a derived class MyPythonicClass with the property X (readable if there is the getter and writable if there is the setter), and so on? I would like a mechanism that lets me to choose to skip some getter/setter couples where it is better to do the work by hand.
0
python,properties,metaprogramming,automatic-properties
2010-02-16T22:18:00.000
0
2,276,800
Be careful using magic, especially magically altering other people's bindings. This has the disadvantages that Your code is incompatible with other people accessing the same library. Someone can't import one of your modules or copy and paste your code and have it work perfectly with their program accessing the same library, and Your interface is different from the interface to the C++ code. This would make sense if your wrapper gave you a nicer, higher-level interface, but your changes are only trivial. Consider whether it wouldn't make more sense just to deal with the library you are using as it came to you.
0
2,591
false
0
1
Automatic transformation from getter/setter to properties
2,277,257
2
7
0
9
55
1
1
0
I am an experienced Perl developer with some degree of experience and/or familiarity with other languages (working experience with C/C++, school experience with Java and Scheme, and passing familiarity with many others). I might need to get some web work done in Python (most immediately, related to Google App Engine). As such, I'd like to ask SO overmind for good references on how to best learn Python for someone who's coming from Perl background (e.g. the emphasis would be on differences between the two and how to translate perl idiomatics into Python idiomatics, as opposed to generic Python references). Something also centered on Web development is even better. I'll take anything - articles, tutorials, books, sample apps? Thanks!
0
python,perl
2010-02-17T17:43:00.000
0
2,283,034
Being a hardcore Perl programmer, all I can say is DO NOT BUY O'Reilly's "Learning Python". It is nowhere NEAR as good as "Learning Perl", and there's no equivalent I know of to Larry Wall's "Programming Perl", which is simply unbeatable. I've had the most success taking past Perl programs and translating them into Python, trying to make use of as many new techniques as possible.
0
24,062
false
0
1
Python for a Perl programmer
2,286,686
2
7
0
-4
55
1
-1
0
I am an experienced Perl developer with some degree of experience and/or familiarity with other languages (working experience with C/C++, school experience with Java and Scheme, and passing familiarity with many others). I might need to get some web work done in Python (most immediately, related to Google App Engine). As such, I'd like to ask SO overmind for good references on how to best learn Python for someone who's coming from Perl background (e.g. the emphasis would be on differences between the two and how to translate perl idiomatics into Python idiomatics, as opposed to generic Python references). Something also centered on Web development is even better. I'll take anything - articles, tutorials, books, sample apps? Thanks!
0
python,perl
2010-02-17T17:43:00.000
0
2,283,034
I wouldn't try to compare Perl and Python too much in order to learn Python, especially since you have working knowledge of other languages. If you are unfamiliar with OOP/Functional programming aspects and just looking to work procedurally like in Perl, start learning the Python language constructs / syntax and then do a couple examples. if you are making a switch to OO or functional style paradigms, I would read up on OO fundamentals first, then start on Python syntax and examples...so you have a sort of mental blueprint of how things can be constructed before you start working with the actual materials. this is just my humble opinion however..
0
24,062
false
0
1
Python for a Perl programmer
2,283,093
5
11
0
1
14
1
0.01818
0
I'm currently working on a component of a trading product that will allow a quant or strategy developer to write their own custom strategies. I obviously can't have them write these strategies in natively compiled languages (or even a language that compiles to a bytecode to run on a vm) since their dev/test cycles have to be on the order of minutes. I've looked at lua, python, ruby so far and really enjoyed all of them so far, but still found them a little "low level" for my target users. Would I need to somehow write my own parser + interpreter to support a language with a minimum of support for looping, simple arithmatic, logical expression evaluation, or is there another recommendation any of you may have? Thanks in advance.
0
python,ruby,scripting,dsl,trading
2010-02-19T16:31:00.000
0
2,297,889
Custom-made modules are going to be needed, no matter what you choose, that define your firm's high level constructs. Here are some of the needs I envision -- you may have some of these covered already: a way to get current positions, current and historical quotes, previous performance data, etc... into the application. Define/backtest/send various kinds of orders (limit/market/stop, what exchange, triggers) or parameters of options, etc... You probably are going to need multiple sandboxes for testing as well as the real thing. Quants want to be able to do matrix operations, stochastic calculus, PDEs. If you wanted to do it in python, loading NumPy would be a start. You could also start with a proprietary system designed to do mathematical financial research such as something built on top of Mathematica or Matlab.
0
3,358
false
0
1
Scripting language for trading strategy development
2,297,992
5
11
0
0
14
1
0
0
I'm currently working on a component of a trading product that will allow a quant or strategy developer to write their own custom strategies. I obviously can't have them write these strategies in natively compiled languages (or even a language that compiles to a bytecode to run on a vm) since their dev/test cycles have to be on the order of minutes. I've looked at lua, python, ruby so far and really enjoyed all of them so far, but still found them a little "low level" for my target users. Would I need to somehow write my own parser + interpreter to support a language with a minimum of support for looping, simple arithmatic, logical expression evaluation, or is there another recommendation any of you may have? Thanks in advance.
0
python,ruby,scripting,dsl,trading
2010-02-19T16:31:00.000
0
2,297,889
Existing languages are "a little "low level" for my target users." Yet, all you need is "a minimum of support for looping, simple arithmatic, logical expression evaluation" I don't get the problem. You only want a few features. What's wrong with the list of languages you provided? They actually offer those features? What's the disconnect? Feel free to update your question to expand on what the problem is.
0
3,358
false
0
1
Scripting language for trading strategy development
2,298,038
5
11
0
0
14
1
0
0
I'm currently working on a component of a trading product that will allow a quant or strategy developer to write their own custom strategies. I obviously can't have them write these strategies in natively compiled languages (or even a language that compiles to a bytecode to run on a vm) since their dev/test cycles have to be on the order of minutes. I've looked at lua, python, ruby so far and really enjoyed all of them so far, but still found them a little "low level" for my target users. Would I need to somehow write my own parser + interpreter to support a language with a minimum of support for looping, simple arithmatic, logical expression evaluation, or is there another recommendation any of you may have? Thanks in advance.
0
python,ruby,scripting,dsl,trading
2010-02-19T16:31:00.000
0
2,297,889
I would use Common Lisp, which supports rapid development (you have a running image and can compile/recompile individual functions) and tailoring the language to your domain. You would provide functions and macros as building blocks to express strategies, and the whole language would be available to the user for combining these.
0
3,358
false
0
1
Scripting language for trading strategy development
2,298,183
5
11
0
0
14
1
0
0
I'm currently working on a component of a trading product that will allow a quant or strategy developer to write their own custom strategies. I obviously can't have them write these strategies in natively compiled languages (or even a language that compiles to a bytecode to run on a vm) since their dev/test cycles have to be on the order of minutes. I've looked at lua, python, ruby so far and really enjoyed all of them so far, but still found them a little "low level" for my target users. Would I need to somehow write my own parser + interpreter to support a language with a minimum of support for looping, simple arithmatic, logical expression evaluation, or is there another recommendation any of you may have? Thanks in advance.
0
python,ruby,scripting,dsl,trading
2010-02-19T16:31:00.000
0
2,297,889
Define the language first -- if possible, use the pseudo-language called EBN, it's very simple (see the Wikipedia entry). Then once you have that, pick the language. Almost certainly you will want to use a DSL. Ruby and Lua are both really good at that, IMO. Once you start working on it, you may find that you go back to your definition and tweak it. But that's the right order to do things, I think.
0
3,358
false
0
1
Scripting language for trading strategy development
2,298,573
5
11
0
0
14
1
0
0
I'm currently working on a component of a trading product that will allow a quant or strategy developer to write their own custom strategies. I obviously can't have them write these strategies in natively compiled languages (or even a language that compiles to a bytecode to run on a vm) since their dev/test cycles have to be on the order of minutes. I've looked at lua, python, ruby so far and really enjoyed all of them so far, but still found them a little "low level" for my target users. Would I need to somehow write my own parser + interpreter to support a language with a minimum of support for looping, simple arithmatic, logical expression evaluation, or is there another recommendation any of you may have? Thanks in advance.
0
python,ruby,scripting,dsl,trading
2010-02-19T16:31:00.000
0
2,297,889
This might be a bit simplistic, but a lot of quant users are used to working with Excel & VBA macros. Would something like VBSCript be usable, as they may have some experience in this area.
0
3,358
false
0
1
Scripting language for trading strategy development
2,298,008
1
2
0
0
0
0
0
0
What is the best way in python find the process name and owner? Now i use WMI, but this version is too slow.
0
python,windows,wmi
2010-02-19T21:15:00.000
1
2,299,627
Process name: is sys.argv[0] not sufficient for your purposes?
0
325
false
0
1
python and process
2,505,040
3
4
1
2
1
1
0.099668
0
If Python was so fast as C, the latter would be present in python apps/libraries? Example: if Python was fast as C would PIL be written completely in Python?
0
python,c,performance,bytecode
2010-02-20T20:55:00.000
0
2,303,683
It makes sense to use C modules in Python for: Performance Libraries that won't be ported to Python (because of performance reasons, for example) or that use OS-specific functions Scripting. For example, many games use Python, Lua and other languages as scripting languages. Therefore they expose C/C++ functions to Python. As to your example: Yes, but Python is inherently slower than C. If both were equally fast, it would make sense to use Python because C code is often more prone to attacks (buffer overflows and stuff).
0
196
false
0
1
Is there any purpose for a python application use C other than performance?
2,303,703
3
4
1
0
1
1
0
0
If Python was so fast as C, the latter would be present in python apps/libraries? Example: if Python was fast as C would PIL be written completely in Python?
0
python,c,performance,bytecode
2010-02-20T20:55:00.000
0
2,303,683
To access hardware.
0
196
false
0
1
Is there any purpose for a python application use C other than performance?
2,303,876
3
4
1
7
1
1
1.2
0
If Python was so fast as C, the latter would be present in python apps/libraries? Example: if Python was fast as C would PIL be written completely in Python?
0
python,c,performance,bytecode
2010-02-20T20:55:00.000
0
2,303,683
To access "legacy" C libraries and OS facilities.
0
196
true
0
1
Is there any purpose for a python application use C other than performance?
2,303,685
2
11
0
2
46
1
0.036348
0
Could you provide a regex that match Twitter usernames? Extra bonus if a Python example is provided.
0
python,regex,twitter
2010-02-21T03:19:00.000
0
2,304,632
The only characters accepted in the form are A-Z, 0-9, and underscore. Usernames are not case-sensitive, though, so you could use r'@(?i)[a-z0-9_]+' to match everything correctly and also discern between users.
0
35,359
false
0
1
regex for Twitter username
2,304,704
2
11
0
1
46
1
0.01818
0
Could you provide a regex that match Twitter usernames? Extra bonus if a Python example is provided.
0
python,regex,twitter
2010-02-21T03:19:00.000
0
2,304,632
Shorter, /@([\w]+)/ works fine.
0
35,359
false
0
1
regex for Twitter username
2,330,440
1
1
0
0
0
1
0
0
How can I get the IMEI number of a mobile phone using Python?
0
python,mobile-phones,imei
2010-02-22T06:02:00.000
0
2,309,108
Sending AT+CGSN through the appropriate serial device will have it return the IMEI.
0
2,251
false
0
1
IMEI number of a mobile phone using python
2,309,202
3
3
0
0
1
0
0
0
I have quite a lot of C++ legacy code modules from my colleagues, unfortunately poorly written. Each is doing a different job, but they are all GNU C++ code running under Linux. I want to write a controller program, to make a singular C++ module for a workflow, for a very urgent demo. Also I need to write a front-end web-app allowing clients submitting jobs to the controller. My main criteria are: development speed (very urgent demo) good binding with C++ (I have legacy code I do not want to rewrite in another language) smooth introduction of new programming language to team (has some python, java and perl knowledge) What programming language fits my needs best, and why? Details: I lean towards python for its perfect binding with C++, as writing JNI is too much work, and kind of obsolete nowadays. However, no one in my team is Python programmer; I do know some Python (no experience in server side programming at all). I have been developing Java EE apps last year, but I do not think JNI is a good solution. Only one team member knows some Perl, others are pure C++ programmers.
0
java,python,programming-languages,binding,java-native-interface
2010-02-22T18:11:00.000
1
2,313,017
I would use Python. You could write very basic wrappers using the Python C API and then call said functions from Python with relative ease.
0
317
false
0
1
Programming language decision for C++ legacy project workflow
2,313,266
3
3
0
2
1
0
0.132549
0
I have quite a lot of C++ legacy code modules from my colleagues, unfortunately poorly written. Each is doing a different job, but they are all GNU C++ code running under Linux. I want to write a controller program, to make a singular C++ module for a workflow, for a very urgent demo. Also I need to write a front-end web-app allowing clients submitting jobs to the controller. My main criteria are: development speed (very urgent demo) good binding with C++ (I have legacy code I do not want to rewrite in another language) smooth introduction of new programming language to team (has some python, java and perl knowledge) What programming language fits my needs best, and why? Details: I lean towards python for its perfect binding with C++, as writing JNI is too much work, and kind of obsolete nowadays. However, no one in my team is Python programmer; I do know some Python (no experience in server side programming at all). I have been developing Java EE apps last year, but I do not think JNI is a good solution. Only one team member knows some Perl, others are pure C++ programmers.
0
java,python,programming-languages,binding,java-native-interface
2010-02-22T18:11:00.000
1
2,313,017
Given the urgency, I'd have to stick with C++. Without that, I'd say keep what you got, but feel free to switch to a preferred language when refactoring. That would be the time to do it. What you should not do, ever, is "port" anything to another language without rewriting or changing functionality in any way. It is a total waste of time, when the "best" outcome you can hope for is that it has no new bugs when you are done.
0
317
false
0
1
Programming language decision for C++ legacy project workflow
2,313,312
3
3
0
3
1
0
1.2
0
I have quite a lot of C++ legacy code modules from my colleagues, unfortunately poorly written. Each is doing a different job, but they are all GNU C++ code running under Linux. I want to write a controller program, to make a singular C++ module for a workflow, for a very urgent demo. Also I need to write a front-end web-app allowing clients submitting jobs to the controller. My main criteria are: development speed (very urgent demo) good binding with C++ (I have legacy code I do not want to rewrite in another language) smooth introduction of new programming language to team (has some python, java and perl knowledge) What programming language fits my needs best, and why? Details: I lean towards python for its perfect binding with C++, as writing JNI is too much work, and kind of obsolete nowadays. However, no one in my team is Python programmer; I do know some Python (no experience in server side programming at all). I have been developing Java EE apps last year, but I do not think JNI is a good solution. Only one team member knows some Perl, others are pure C++ programmers.
0
java,python,programming-languages,binding,java-native-interface
2010-02-22T18:11:00.000
1
2,313,017
Noting the "very urgent demo" part, assuming that that would take about a month, depending on the complexity, I'd stick to the familiar. True, maintaining python would be easier in the end, and learning python should be a breeze, if you deem it viable. I'd say, have the team learn python and do the basic stuff, as you learn the deeper parts, you could build classes for them to extend/implement. That way, you get things done as they learn.
0
317
true
0
1
Programming language decision for C++ legacy project workflow
2,313,159
1
4
0
2
1
0
0.099668
0
Is there a way to get PHP-like print_r(object) funcionality in iPython? I know I can use '?' to get info about an object, but how do I view the values of the object?
0
php,python,object,ipython
2010-02-23T12:08:00.000
0
2,317,921
dir(object) will give you all its attribute names.
0
497
false
0
1
print_r functionality in iPython
2,317,942
1
3
0
0
1
1
0
0
I've a name of a class stored in var, which I need to create an object from. However I do not know in which module it is defined (if I did, I would just call getattr(module,var), but I do know it's imported. Should I go over every module and test if the class is defined there ? How do I do it in python ? What if I have the module + class in the same var, how can I create an object from it ? (ie var = 'module.class') Cheers, Ze
0
python,ruby,module,metaprogramming
2010-02-23T12:29:00.000
0
2,318,044
Classes are not added to a global registry in Python by default. You'll need to iterate over all imported modules and look for it.
0
389
false
0
1
Python equivalent for Ruby's ObjectSpace?
2,318,065
1
6
0
0
10
1
0
0
In general I want to disable as little code as possible, and I want it to be explicit: I don't want the code being tested to decide whether it's a test or not, I want the test to tell that code "hey, BTW, I'm running a unit test, can you please not make your call to solr, instead can you please stick what you would send to solr in this spot so I can check it". I have my ideas but I don't like any of them, I am hoping that there's a good pythonic way to do this.
0
python,unit-testing,testing,dependency-injection
2010-02-23T17:20:00.000
0
2,320,210
I know it's the typical use case for mock objects, but that's also an old argument... are Mock objects necessary at all or are they evil ? I'm on the side of those who believe mocks are evil and would try to avoid changing tested code at all. I even believe such need to modify tested code is a code smell... If you wish to change or intercept an internal function call for testing purpose you could also make this function an explicit external dependency set at instanciation time that would be provided both by your production code and test code. If you do that the problem disappear and you end up with a cleaner interface. Note that doing that there is not need to change the tested code at all neither internally nor by the test being performed.
0
2,347
false
0
1
In Python, what's a good pattern for disabling certain code during unit tests?
2,320,900
1
3
0
0
1
0
0
0
I know that with the SimpleHTTPServer I can make my directories accessible by web-browsers via Internet. So, I run just one line of the code and, as a result, another person working on another computer can use his/her browser to see content of my directories. But I wander if I can make more complicated things. For example, somebody uses his/her browser to load my Python program with a set of parameter (example.py?x=2&y=2) and, as a result, he/she sees the HTML page generated by the Python program (not the Python program). I also wander if I can process html form submitted to the SimpleHTTPServer.
0
python,post,get,webserver,simplehttpserver
2010-02-23T21:19:00.000
0
2,321,813
have you considered using CGIHTTPServer instead of SimpleHTTPServer? Then you can toss your scripts in cgi-bin and they'll execute. You have to include content-type header and whatnot but if you're looking for quick and dirty it's real convenient
0
7,811
false
1
1
Is it possible to write dynamic web pages in Python with the Really Simple HTTP Server?
8,673,542
1
3
0
0
1
0
0
0
Is there an active Python-Chat?
0
python,chat,irc
2010-02-24T12:32:00.000
0
2,325,938
My guess is that you are looking for a IRC channel? well this is not related to programming so you should not be posting that question here? any way quakenet has a python channel
0
465
false
0
1
Is there an active Python-Chat?
2,325,967
1
1
0
1
0
0
1.2
0
do you know/have you tried any code protection system which works with IronPython assemblies? Can you list it/them here?
0
asp.net,ironpython
2010-02-24T12:37:00.000
0
2,325,971
since iron python compiles to IL I would imagine you can use the same obfuscations tools such as DotFuscator. Are you using the pyc tool included in iron pythons tool folder?
0
159
true
1
1
Code protection system which works with IronPython assemblies?
2,326,011
2
9
0
0
25
0
0
0
I am working with a very large (~11GB) text file on a Linux system. I am running it through a program which is checking the file for errors. Once an error is found, I need to either fix the line or remove the line entirely. And then repeat... Eventually once I'm comfortable with the process, I'll automate it entirely. For now however, let's assume I'm running this by hand. What would be the fastest (in terms of execution time) way to remove a specific line from this large file? I thought of doing it in Python...but would be open to other examples. The line might be anywhere in the file. If Python, assume the following interface: def removeLine(filename, lineno): Thanks, -aj
0
python,optimization
2010-02-24T20:51:00.000
0
2,329,417
I think there was a somewhat similar if not exactly the same type of question asked here. Reading (and writing) line by line is slow, but you can read a bigger chunk into memory at once, go through that line by line skipping lines you don't want, then writing this as a single chunk to a new file. Repeat until done. Finally replace the original file with the new file. The thing to watch out for is when you read in a chunk, you need to deal with the last, potentially partial line you read, and prepend that into the next chunk you read.
0
16,660
false
0
1
Fastest Way to Delete a Line from Large File in Python
2,330,250
2
9
0
1
25
0
0.022219
0
I am working with a very large (~11GB) text file on a Linux system. I am running it through a program which is checking the file for errors. Once an error is found, I need to either fix the line or remove the line entirely. And then repeat... Eventually once I'm comfortable with the process, I'll automate it entirely. For now however, let's assume I'm running this by hand. What would be the fastest (in terms of execution time) way to remove a specific line from this large file? I thought of doing it in Python...but would be open to other examples. The line might be anywhere in the file. If Python, assume the following interface: def removeLine(filename, lineno): Thanks, -aj
0
python,optimization
2010-02-24T20:51:00.000
0
2,329,417
If the lines are variable length then I don't believe that there is a better algorithm than reading the file line by line and writing out all lines, except for the one(s) that you do not want. You can identify these lines by checking some criteria, or by keeping a running tally of lines read and suppressing the writing of the line(s) that you do not want. If the lines are fixed length and you want to delete specific line numbers, then you may be able to use seek to move the file pointer... I doubt you're that lucky though.
0
16,660
false
0
1
Fastest Way to Delete a Line from Large File in Python
2,329,515
1
3
0
0
1
0
0
1
i have a string ''' {"session_key":"3.KbRiifBOxY_0ouPag6__.3600.1267063200-16423986","uid":164 23386,"expires":12673200,"secret":"sm7WM_rRtjzXeOT_jDoQ__","sig":"6a6aeb66 64a1679bbeed4282154b35"} ''' how to get the value . thanks
0
python
2010-02-25T01:00:00.000
0
2,330,857
For a simple-to-code method, I suggest using ast.parse() or eval() to create a dictionary from your string, and then accessing the fields as usual. The difference between the two functions above is that ast.parse can only evaluate base types, and is therefore more secure if someone can give you a string that could contain "bad" code.
0
115
false
0
1
which is the best way to get the value of 'session_key','uid','expires'
2,330,884
1
5
0
2
8
0
0.07983
0
As far as I read, Django only supports sending mails using SMTP. I would like to send Emails from my script in Django, but do not want to setup SMTP server (it's too complex for me, I'm a linux newbie). Is it possible, to send mails in Django in the same way like I do it in PHP, without providing SMTP login, password and etc?
0
python,django,email
2010-02-25T15:56:00.000
0
2,335,384
So how does PHP do it? By magic? If you don't have an SMTP server, sign up for a GMail account and use that.
0
7,844
false
1
1
Send Email in Django without SMTP server. Like php mail() function does
2,335,399
2
5
0
0
3
0
0
0
We are working on Arabic Natural Language Processing project, we have limited our choices to either write the code in Python or C++ (and Boost library). We are thinking of these points: Python Slower than C++ (There is ongoing work to make Python faster) Better UTF8 support Faster in writing tests and trying different algorithms C++ Faster than Python Familiar code, every programmer knows C or C-like code After the project is done, it should be not very hard to port the project to another programming languages. What do you think is better and suitable for the project?
0
c++,python,boost,nlp
2010-02-26T18:56:00.000
0
2,344,081
IMO go for C/C++ simply because of the 'familiar' factor. Though LOC's will be more in C/C++ you will save time in understanding and testing.
0
4,180
false
0
1
NLP project, python or C++
7,779,679
2
5
0
2
3
0
0.07983
0
We are working on Arabic Natural Language Processing project, we have limited our choices to either write the code in Python or C++ (and Boost library). We are thinking of these points: Python Slower than C++ (There is ongoing work to make Python faster) Better UTF8 support Faster in writing tests and trying different algorithms C++ Faster than Python Familiar code, every programmer knows C or C-like code After the project is done, it should be not very hard to port the project to another programming languages. What do you think is better and suitable for the project?
0
c++,python,boost,nlp
2010-02-26T18:56:00.000
0
2,344,081
Familiar code, every programmer knows C or C-like code Many devs are familiar with C or C-like code, it doesn't make them C++ compliant. Unexperienced C++ devs can do a lot of harm to such a complex project and you would have to take extra care. I can't speak for python but I heard it's more beginner-friendly. I'd say, once again, you should go for the language you (as a team) know best.
0
4,180
false
0
1
NLP project, python or C++
2,344,099
2
5
0
9
12
1
1
0
What is the latest way to write Python tests? What modules/frameworks to use? And another question: are doctest tests still of any value? Or should all the tests be written in a more modern testing framework? Thanks, Boda Cydo.
0
python,testing
2010-02-28T20:22:00.000
0
2,352,516
Using the built-in unittest module is as relevant and easy as ever. The other unit testing options, py.test,nose, and twisted.trial are mostly compatible with unittest. Doctests are of the same value they always were—they are great for testing your documentation, not your code. If you are going to put code examples in your docstrings, doctest can assure you keep them correct and up to date. There's nothing worse than trying to reproduce an example and failing, only to later realize it was actually the documentation's fault.
0
2,407
false
0
1
How to write modern Python tests?
2,352,607
2
5
0
0
12
1
0
0
What is the latest way to write Python tests? What modules/frameworks to use? And another question: are doctest tests still of any value? Or should all the tests be written in a more modern testing framework? Thanks, Boda Cydo.
0
python,testing
2010-02-28T20:22:00.000
0
2,352,516
The important thing to remember about doctests is that the tests are based on string comparisons, and the way that numbers are rendered as strings will vary on different platforms and even in different python interpreters. Most of my work deals with computations, so I use doctests only to test my examples and my version string. I put a few in the __init__.py since that will show up as the front page of my epydoc-generated API documentation. I use nose for testing, although I'm very interested in checking out the latest changes to py.test.
0
2,407
false
0
1
How to write modern Python tests?
2,353,883
2
2
0
0
1
0
0
0
I'm currently planning out a web app that I want to host for people and allow them to host themselves on either Linux/Apache of IIS6 or IIS7 (for the benefits of bandwidth, directory services [login, etc.]). I see that PHP is supported on both platforms. I've heard people serving Django and Python in IIS using PyISAPIe. I'm not sure about Ruby/Rails on IIS until IronRuby ships. I don't have much Perl experience but understand it would run in IIS as well. Anyone have input for me? Thanks in advance.
0
php,python,apache,iis
2010-03-01T21:49:00.000
0
2,359,314
I have several production php5/6 applications that run on either windows/iis and apache/linux. switching between platforms has not been an issue for me. i test on a windows server talking to a mysql db on a linux machine. i deploy to a linux web server without issue. i cannot speak for rails or pytong as i'm not a ruby or python guy. however, they should work fine from what i understand of them. if i were you i'd pick the language you have the most experience with.
0
1,120
false
1
1
Compatibility with IIS and Apache -- PHP, Python, etc?
2,359,411
2
2
0
0
1
0
1.2
0
I'm currently planning out a web app that I want to host for people and allow them to host themselves on either Linux/Apache of IIS6 or IIS7 (for the benefits of bandwidth, directory services [login, etc.]). I see that PHP is supported on both platforms. I've heard people serving Django and Python in IIS using PyISAPIe. I'm not sure about Ruby/Rails on IIS until IronRuby ships. I don't have much Perl experience but understand it would run in IIS as well. Anyone have input for me? Thanks in advance.
0
php,python,apache,iis
2010-03-01T21:49:00.000
0
2,359,314
Your lowest common denominator for building apps to seemlessly run on both the LAMP and Microsoft stacks is PHP. Perl is another option, it's well supported on both Windows and Linux/Apache. But I think I'd be choosing PHP over Perl because of support for FastCGI which improves reliability and performance on the Windows stack. Microsoft and Zend have been doing a lot of work on PHP for Windows so that you can write PHP apps and confidently expect them to run well on both platforms. The proof of the pudding of this is that Joomla, WordPress, phpBBS and many other of the well known open source PHP applications run straight out of the box on Windows. Also as a developer and third line support engineer for a shared web hosting company, with a fair bit of experience in this area, I'd say that PHP on Windows is every bit as flexible, performant and reliable as PHP on the LAMP stack. Finally, Ruby on Rails and Python/DJango aren't well supported options on IIS and will be non-existant on shared hosting platforms. This is mostly due to the amount of console access you'd need to knock things into shape to be able to run Rails/DJango.
0
1,120
true
1
1
Compatibility with IIS and Apache -- PHP, Python, etc?
2,359,605
2
4
0
0
3
0
0
0
Could anyone tell me how to use pure Python without Cocoa support in Xcode? I can only find the Cocoa-Python template on the Internet. Thanks in advance.
0
python,xcode
2010-03-01T23:49:00.000
0
2,359,994
A lot of people like eclipse with PyDev for python, although I don't know how wel it works on OS X with apple's mishandling of java.
0
4,138
false
0
1
Pure Python in Xcode?
2,360,880
2
4
0
0
3
0
0
0
Could anyone tell me how to use pure Python without Cocoa support in Xcode? I can only find the Cocoa-Python template on the Internet. Thanks in advance.
0
python,xcode
2010-03-01T23:49:00.000
0
2,359,994
Just about the best IDE for editing and running Python code is actually still emacs. The python-mode for emacs does a wonderful job of maintaining whitespace and, with a bit of configuration, emacs is truly a powerful editor. Pretty radically different than your typical GUI editor, certainly, and some find it quite distasteful. I've personally used emacs, mostly, for editing Python since 1992 or so. Google will reveal all, including a native version of Emacs for Mac OS X.
0
4,138
false
0
1
Pure Python in Xcode?
2,360,692
2
3
0
7
2
1
1
0
I am looking for example where things in python would be easier to program just because it is dynamically typed? I want to compare it with Haskell type system because its static typing doesn't get in the way like c# or java. Can I program in Haskell as I can in python without static typing being a hindrance? PS: I am a python user and have played around little bit with ML and Haskell.. ... I hope it is clear now..
0
python,dynamic,haskell,static,types
2010-03-02T18:48:00.000
0
2,365,783
Can I program in Haskell as I can in python without static typing being a hindrance Yes. To elaborate, I would say the main gotcha will be the use of existential types in Haskell for heterogeneous data structures (regular data structures holding lists of variously typed elements). This often catches OO people used to a top "Object" type. It often catches Lisp/Scheme programmers. But I'm not sure it will matter to a Pythonista. Try to write some Haskell, and come back when you get a confusing type error. You should think of static typing as a benefit -- it checks a lot of things for you, and the more you lean on it, the less things you have to test for. In addition, it enables the compiler to make your code much faster.
0
1,567
false
0
1
haskell vs python typing
2,365,869
2
3
0
5
2
1
1.2
0
I am looking for example where things in python would be easier to program just because it is dynamically typed? I want to compare it with Haskell type system because its static typing doesn't get in the way like c# or java. Can I program in Haskell as I can in python without static typing being a hindrance? PS: I am a python user and have played around little bit with ML and Haskell.. ... I hope it is clear now..
0
python,dynamic,haskell,static,types
2010-03-02T18:48:00.000
0
2,365,783
Well for one you can't create a list containing multiple types of values without wrappers (like to get a list that may contain a string or an int, you'd have to create a list of Either Int String and wrap each item in a Left or a Right). You also can't define a function that may return multiple types of values (like if someCondition then 1 else "this won't compile"), again, without using wrappers.
0
1,567
true
0
1
haskell vs python typing
2,365,873
1
7
0
2
9
0
0.057081
0
I am searching for a python package that I can use to simulate molecular dynamics in non-equilibrium situations. I need a setup that can handle a fairly large number of molecules in a primarily kinetic theory manner, and that can handle having solid surfaces present. With regards to the surfaces, I would need to be able to create arbitrary shapes and monitor pressure and other variables resulting from the molecular action. Alternatively, I could add the surface parts myself if I had molecules that could handle it. Does anyone know of any packages that might be suitable?
0
python,packages,simulation,physics,kinematics
2010-03-03T04:06:00.000
0
2,368,671
Lampps and gromacs are two well known molecular dynamics codes. These codes both have some python based wrapper stuff, but I am not sure how much functionality the wrappers expose. They may not give you enough control over the simulation. Google for "GromacsWrapper" or google for "lammps" and "pizza.py" Digital material and ASE are two molecular dynamics codes that expose a lot of functionality, but last time I looked, they were both fairly specialized. They may not allow you to use the force potentials that you want Google for "digital material" and "cornell" or google for "ase" and dtu Note to MJV: Normal MD-codes take one time step at a time, and they move all particles in each time step. Most of the time is spend calculating the total force on each atom. This involves iterating over a list of pairs of neighboring atoms. I think the best idea is to do the force calculation and a few more basics in c++ or fortran and then wrap that functionality in python. (But it could be fun to see how far one can get by using numpy matrices)
0
7,273
false
0
1
Simulation of molecular dynamics in Python
2,369,508
1
1
0
0
0
0
0
0
I'm using the Windmill test system and have it running using test_windmill for Django which works fine for the Python tests. I'd like this to run a suite of Javascript tests also whilst the Django test server is running. I've used the run_js_tests call from the Windmill shell which works fine but I can't find a way to have this run as part of the Python tests. Does anyone know how to do this? Thanks Rob
0
python,django,unit-testing,automated-tests,windmill
2010-03-03T17:22:00.000
0
2,373,446
Ok, so couldn't find out how to do this so I'm running the website under Apache and using the windmill standard jstests parameter to run the Javascript tests against this.
0
354
false
1
1
How do I run Javascript tests in Windmill when using test_windmill for Django?
2,468,981
1
3
0
3
12
0
0.197375
0
Is there some way (using the standard Django.test.TestCase framework) to perform a global initialization of certain variables, so that it only happens once. Putting things setUp() makes it so that the variables are initialized before each test, which kills performance when the setup involves expensive operations. I'd like to run a setup type feature once, and then have the variables initialized here be visible to all my tests. I'd prefer not to rewrite the test runner framework. I am thinking of something similar to a before(:all) in the Ruby/RSpec world. -S
0
python,django,testing
2010-03-03T19:11:00.000
0
2,374,197
This is partially addressed in newer versions of python/django by setUpClass() which will at least allow me to run class level setup.
0
2,735
false
1
1
global set up in django test framework?
17,461,581
2
4
0
3
10
0
0.148885
0
The Psyco docs say: Just for reference, Psyco does not work on any 64-bit systems at all. This fact is worth being noted again, now that the latest Mac OS/X 10.6 "Snow Leopart" comes with a default Python that is 64-bit on 64-bit machines. The only way to use Psyco on OS/X 10.6 is by recompiling a custom Python in 32-bit mode. In general, porting programs from 32 to 64 bits is only really an issue when the code assumes a certain size for a pointer type and other similarly small(ish) issues. Considering that Psyco isn't a whole lot of code (~32K lines of C + ~8K lines of Python), how hard could it be? Has anyone tried this and hit a wall? I haven't really had a chance to take a good look at the Psyco sources yet, so I'd really appreciate knowing if I'm wasting my time looking into this...
0
python,c,64-bit,porting,psyco
2010-03-03T19:18:00.000
0
2,374,233
Psyco assumes that sizeof(int) == sizeof(void*) a bit all over the place. That's much harder than just writing down 64bit calling conventions and assembler. On the sidenote, pypy has 64bit jit support these days. Cheers, fijal
0
1,103
false
0
1
What are the possible pitfalls in porting Psyco to 64-bit?
3,738,027
2
4
0
3
10
0
1.2
0
The Psyco docs say: Just for reference, Psyco does not work on any 64-bit systems at all. This fact is worth being noted again, now that the latest Mac OS/X 10.6 "Snow Leopart" comes with a default Python that is 64-bit on 64-bit machines. The only way to use Psyco on OS/X 10.6 is by recompiling a custom Python in 32-bit mode. In general, porting programs from 32 to 64 bits is only really an issue when the code assumes a certain size for a pointer type and other similarly small(ish) issues. Considering that Psyco isn't a whole lot of code (~32K lines of C + ~8K lines of Python), how hard could it be? Has anyone tried this and hit a wall? I haven't really had a chance to take a good look at the Psyco sources yet, so I'd really appreciate knowing if I'm wasting my time looking into this...
0
python,c,64-bit,porting,psyco
2010-03-03T19:18:00.000
0
2,374,233
Since psyco is a compiler, it would need to be aware of the underlying assembly language to generate useful code. That would mean it would need to know about the 8 new registers, new opcodes for 64 bit code, etc. Furthermore, to interop with the existing code, it would need to use the same calling conventions as 64 bit code. The AMD-64 calling convention is similar to the old fast-call conventions in that some parameters are passed in registers (in the 64 bit case rcx,rdx,r8,r9 for pointers and Xmm0-Xmm3 for floating point) and the rest are pushed onto spill space on the stack. Unlike x86, this extra space is usually allocated once for all of the possible calls. The IA64 conventions and assembly language are different yet. So in short, I think this is probably not as simple as it sounds.
0
1,103
true
0
1
What are the possible pitfalls in porting Psyco to 64-bit?
2,374,371
2
2
0
1
4
0
0.099668
0
I'm looking for a way to list all fonts installed on a linux/Debian system, and then generate images of some strings using these fonts. I'm looking for your advice as I kind of see how to do each part, but not to do both: To list all fonts on a UNIX system, xlsfonts can do the trick: import os list_of_fonts=os.popen("xslfonts").readlines() To render a string into an image using a font, I could use PIL (Python Imaging Library) and the ImageFont class. However, ImagesFont.load expects a file name, whereas xlsfonts gives a kind of normalized font name, and the correspondence between the two doesn't seems obvious (I tried to search my system for files named as the output of xlsfonts, without results). Does anyone has an idea on how I can do that? Thanks!
0
python,linux,fonts,debian,python-imaging-library
2010-03-03T21:30:00.000
1
2,375,125
you best bet is to do a find on all the fonts on the system, and then use ImagesFont.load() on the results of that list. I don't know where the fonts are on Debian, but they should be in a well known folder you can just do an os.walk and then feed the filenames in that way.
0
894
false
0
1
Generate image for each font on a linux system using Python
2,375,489
2
2
0
1
4
0
1.2
0
I'm looking for a way to list all fonts installed on a linux/Debian system, and then generate images of some strings using these fonts. I'm looking for your advice as I kind of see how to do each part, but not to do both: To list all fonts on a UNIX system, xlsfonts can do the trick: import os list_of_fonts=os.popen("xslfonts").readlines() To render a string into an image using a font, I could use PIL (Python Imaging Library) and the ImageFont class. However, ImagesFont.load expects a file name, whereas xlsfonts gives a kind of normalized font name, and the correspondence between the two doesn't seems obvious (I tried to search my system for files named as the output of xlsfonts, without results). Does anyone has an idea on how I can do that? Thanks!
0
python,linux,fonts,debian,python-imaging-library
2010-03-03T21:30:00.000
1
2,375,125
You can do this using pango, through the pygtk package. Pango can list fonts and render them.
0
894
true
0
1
Generate image for each font on a linux system using Python
2,375,457
2
3
0
4
1
0
0.26052
0
thanks for helping me setting my cron jobs, crontab has really been a gold mine for me. Unfortunately I have a problem, and have no idea what so ever what it might be... basically a job does not start while the neighbour jobs do. I'll explain This is my crontabs job list: */10 * * * * python /webapps/foo/manage.py fetch_articles */10 * * * * python /webapps/bar/manage.py fetch_books I wrote them as they are in a file and stored them using crontab /path/to/file . Checked with crontab -l and the jobs are there. The strange thing is that 1 of these executes every 10 minutes normally... but the other one does not. I tried typing in the command manually, and it works fine without a problem. Does anyone have suggestions? Help would be much appreciated, thanks guys. Update: I've been in the system log files and I found this: Mar 5 02:50:01 localhost CRON[21652]: (root) CMD (python /webapps/foo/manage.py fetch_books) Does this mean crontab is calling the job fine? Thanks for your replies guys! FIXED IT! thank you very much everyone!! The problem was that the script silently failed, I believe it's due to the PYTHON_PATH changing due to where the script is called from... I'm entirely sure.
0
python,linux,ubuntu,cron,crontab
2010-03-05T02:40:00.000
1
2,384,225
From the crontab manpage: BUGS Although cron requires that each entry in a crontab end in a newline character, neither the crontab command nor the cron daemon will detect this error. Instead, the crontab will appear to load normally. However, the command will never run. The best choice is to ensure that your crontab has a blank line at the end. (my emphasis).
0
2,936
false
0
1
Crontab job does not start... ideas?
2,384,246
2
3
0
1
1
0
0.066568
0
thanks for helping me setting my cron jobs, crontab has really been a gold mine for me. Unfortunately I have a problem, and have no idea what so ever what it might be... basically a job does not start while the neighbour jobs do. I'll explain This is my crontabs job list: */10 * * * * python /webapps/foo/manage.py fetch_articles */10 * * * * python /webapps/bar/manage.py fetch_books I wrote them as they are in a file and stored them using crontab /path/to/file . Checked with crontab -l and the jobs are there. The strange thing is that 1 of these executes every 10 minutes normally... but the other one does not. I tried typing in the command manually, and it works fine without a problem. Does anyone have suggestions? Help would be much appreciated, thanks guys. Update: I've been in the system log files and I found this: Mar 5 02:50:01 localhost CRON[21652]: (root) CMD (python /webapps/foo/manage.py fetch_books) Does this mean crontab is calling the job fine? Thanks for your replies guys! FIXED IT! thank you very much everyone!! The problem was that the script silently failed, I believe it's due to the PYTHON_PATH changing due to where the script is called from... I'm entirely sure.
0
python,linux,ubuntu,cron,crontab
2010-03-05T02:40:00.000
1
2,384,225
I think ~unutbu's answer is probably correct if it's the second job that isn't running. However another thing to check is whether /webapps/bar/manage.py requires exclusive access to any resources, eg network sockets/tempfiles etc. Since you are starting 2 processes at the same time, you may be triggering a race condition.
0
2,936
false
0
1
Crontab job does not start... ideas?
2,384,281
1
2
0
0
0
0
0
0
I need to set properties related to Remote Desktop Services on Active Directory users in .NET (i.e., via System.DirectoryServices), but I can't see that these properties are exposed by the API? I know there is a COM interface for this purpose, IADsTSUserEx. Please show me how I can get at these properties in .NET :) Bear in mind that the programming language is Python.
0
.net,python,active-directory,directoryservices
2010-03-06T15:20:00.000
0
2,392,949
The problem with some of these properties is that you can see them on the UI via Active Directory Users and Computers, but you cannot set them (or see them) via ADSI Editor. Usually, for properties that aren't directly available from a DirectoryEntry object, you can use its Properties collection as described by Tim Robbinson (e.g. directoryEntry.Properties["PropertyName"].Value). For some properties, however, you cannot use this approach and have to use directoryEntry.InvokeSet("PropertyName", new object[]{ "SomeValue" });, e.g. for TerminalServicesHomeDirectory, TerminalServicesHomeDrive and TerminalServicesProfilePath. As said above, you won't see these three properties using ADSI Editor, you can only see the property values via the "normal" UI on the corresponding tab. How you can apply all this to Python I don't know, but it seems you've got instances of the DirectoryEntry class, so you should be fine.
0
2,366
false
0
1
How do I change Remote Desktop Services properties of AD users in .NET?
14,938,596
1
6
0
0
30
1
0
0
What's the simplest way to determine if a date is a U.S. bank holiday in Python? There seem to be various calendars and webservices listing holidays for various countries, but I haven't found anything specific to banks in the U.S.
0
python,date,bank
2010-03-06T21:55:00.000
0
2,394,235
I should caution contributors from thinking this is all solvable by an algorithm. Three examples: most Islamic holidays are lunar. The moon is predictable, some countries do this, but others explicitly require that the new moon be actually sighted in the country. Some even post people to the tops of tall mountains, tasked to try to spot the new moon. If the night is cloudy, the new moon may not be sighted, so the following day is not a holiday. a committee in China meets around November each year to decide on the number of holidays that will be given for Chinese New Year in mainland China the following February. As an added complication, because there are so many public holidays given for Chinese New Year, the Chinese Government sometimes nominates weekends after the holiday as working days, to boost economic activity. stock exchanges in India sometimes have a very short trading period at a weekend for auspicious religious reasons. For this reason, there are companies that do this research, get the updates, and publish holidays via an API, for a fee. Users typically query that API every day in case new holidays are announced.
0
35,484
false
0
1
Detecting a US Holiday
70,469,423
2
2
0
1
1
1
1.2
0
I have no knowledge of Python. I started with .NET and than learned PHP. Someone later asked me to learn Ruby as well. I started learning it. Since last few months I am seeing many libraries and drivers written in Python. I want to know what are the advantages of Python over PHP/Ruby? What type of language it is and is there a need to learn Python as well? Which is the purest version of Python? I could see many variants there like IronPython etc.
0
php,python,ruby
2010-03-07T04:16:00.000
0
2,395,157
If you're just getting started in python, chances are the standard python distribution will work just fine. Once you get into the guts of your project, changing to IronPython (etc) is not a big deal. I think the most important part is the "getting started" piece. Start writing python and you'll never look back.
0
98
true
0
1
Python Libraries and drivers
2,433,699
2
2
0
1
1
1
0.099668
0
I have no knowledge of Python. I started with .NET and than learned PHP. Someone later asked me to learn Ruby as well. I started learning it. Since last few months I am seeing many libraries and drivers written in Python. I want to know what are the advantages of Python over PHP/Ruby? What type of language it is and is there a need to learn Python as well? Which is the purest version of Python? I could see many variants there like IronPython etc.
0
php,python,ruby
2010-03-07T04:16:00.000
0
2,395,157
Nobody can tell you the exact answer because everybody has their own "holy grail". You will just have to find out for yourself which one suits you best for the task you want to perform. Case closed.
0
98
false
0
1
Python Libraries and drivers
2,395,204
1
2
0
0
1
1
1.2
0
I would like to do the following: 1) Serialize my class 2) Also manually edit the serialization dump file to remove certain objects of my class which I find unnecessary. I am currently using python with simplejson. As you know, simplejson converts all characters to unicde. As a result, when I dump a particular object with simplejson, the unicode characters becomes something like that "\u00bd" for 好. I am interested to manually edit the simplejson file for convenience. Anyone here know a work around for me to do this? My requirements for this serialization format: 1) Easy to use (just dump and load - done) 2) Allows me to edit them manually without much hassle. 3) Able to display chinese character I use vim. Does anyone know a way to conver "\u00bd" to 好 in vim?
0
python,vim
2010-03-08T08:37:00.000
0
2,400,088
If you want json/simplejson to produce unicode output instead of str output with Unicode escapes then you need to pass ensure_ascii=False to dump()/dumps(), then either encode before saving or use a file-like from codecs.
0
600
true
0
1
Python: getting \\u00bd correctly in editor
2,401,864
3
10
0
6
5
0
1
0
I'm Delphi developer, and I would like to build few web applications, I know about Intraweb, but I think it's not a real tool for web development, maybe for just intranet applications so I'm considering PHP, Python or ruby, I prefer python because it's better syntax than other( I feel it closer to Delphi), also I want to deploy the application to shared hosting, specially Linux. so as Delphi developer, what do you choose to develop web application?
0
php,python,ruby,delphi
2010-03-08T10:26:00.000
0
2,400,605
Why should an answer be different if the question was asked by a Delphi programmer, than a programmer from any other platform? Any decent language should be fun to learn, regardless of the tool you are using right now. That said, I myself walked a way from Borland Pascal and Delphi (quite some time ago), over PHP and ASP.NET (using C#). Right now I am working almost exclusively on Ruby (and occasionally Rails) and I am perfectly happy with it. But, then again, it's matter of personal preference: I really enjoy Ruby's pure object-orientation and functional capabilities, as well as dynamical nature of a scripting language. So, it's all up to you and your personal preferences. Although, one thing I can surely recommend is to stick with one of the major web-players, for pragmatic reasons: PHP, Python, Ruby, ASP.NET or possibly Java. I'm sorry to say that, but I don't think Pascaloid languages have any future anymore.
0
2,367
false
0
1
Best web application language for Delphi Developers
2,401,097
3
10
0
1
5
0
0.019997
0
I'm Delphi developer, and I would like to build few web applications, I know about Intraweb, but I think it's not a real tool for web development, maybe for just intranet applications so I'm considering PHP, Python or ruby, I prefer python because it's better syntax than other( I feel it closer to Delphi), also I want to deploy the application to shared hosting, specially Linux. so as Delphi developer, what do you choose to develop web application?
0
php,python,ruby,delphi
2010-03-08T10:26:00.000
0
2,400,605
PHP is a pretty simple answer. One reason is there is both Delphi4PHP (the rather cryptic IDE licensed by Embarcadero which in my estimation is really only for Web Apps (not for doing whole site)s) and PHP4Delphi (the pretty awesome Delphi Component that lets you compile your Delphi code to PHP Extensions).
0
2,367
false
0
1
Best web application language for Delphi Developers
2,401,646
3
10
0
0
5
0
0
0
I'm Delphi developer, and I would like to build few web applications, I know about Intraweb, but I think it's not a real tool for web development, maybe for just intranet applications so I'm considering PHP, Python or ruby, I prefer python because it's better syntax than other( I feel it closer to Delphi), also I want to deploy the application to shared hosting, specially Linux. so as Delphi developer, what do you choose to develop web application?
0
php,python,ruby,delphi
2010-03-08T10:26:00.000
0
2,400,605
I have done a fairly large (4-5 FTE) project based on webhub (www.href.com). I can certainly advise this if it is a webapp for internal use.
0
2,367
false
0
1
Best web application language for Delphi Developers
2,401,428
4
11
0
2
86
1
1.2
0
I have some json files with 500MB. If I use the "trivial" json.load() to load its content all at once, it will consume a lot of memory. Is there a way to read partially the file? If it was a text, line delimited file, I would be able to iterate over the lines. I am looking for analogy to it.
0
python,json,large-files
2010-03-08T10:34:00.000
0
2,400,643
Update See the other answers for advice. Original answer from 2010, now outdated Short answer: no. Properly dividing a json file would take intimate knowledge of the json object graph to get right. However, if you have this knowledge, then you could implement a file-like object that wraps the json file and spits out proper chunks. For instance, if you know that your json file is a single array of objects, you could create a generator that wraps the json file and returns chunks of the array. You would have to do some string content parsing to get the chunking of the json file right. I don't know what generates your json content. If possible, I would consider generating a number of managable files, instead of one huge file.
0
70,067
true
0
1
Is there a memory efficient and fast way to load big JSON files?
2,400,780
4
11
0
3
86
1
0.054491
0
I have some json files with 500MB. If I use the "trivial" json.load() to load its content all at once, it will consume a lot of memory. Is there a way to read partially the file? If it was a text, line delimited file, I would be able to iterate over the lines. I am looking for analogy to it.
0
python,json,large-files
2010-03-08T10:34:00.000
0
2,400,643
On your mention of running out of memory I must question if you're actually managing memory. Are you using the "del" keyword to remove your old object before trying to read a new one? Python should never silently retain something in memory if you remove it.
0
70,067
false
0
1
Is there a memory efficient and fast way to load big JSON files?
2,402,371
4
11
0
1
86
1
0.01818
0
I have some json files with 500MB. If I use the "trivial" json.load() to load its content all at once, it will consume a lot of memory. Is there a way to read partially the file? If it was a text, line delimited file, I would be able to iterate over the lines. I am looking for analogy to it.
0
python,json,large-files
2010-03-08T10:34:00.000
0
2,400,643
in addition to @codeape I would try writing a custom json parser to help you figure out the structure of the JSON blob you are dealing with. Print out the key names only, etc. Make a hierarchical tree and decide (yourself) how you can chunk it. This way you can do what @codeape suggests - break the file up into smaller chunks, etc
0
70,067
false
0
1
Is there a memory efficient and fast way to load big JSON files?
2,402,407
4
11
0
3
86
1
0.054491
0
I have some json files with 500MB. If I use the "trivial" json.load() to load its content all at once, it will consume a lot of memory. Is there a way to read partially the file? If it was a text, line delimited file, I would be able to iterate over the lines. I am looking for analogy to it.
0
python,json,large-files
2010-03-08T10:34:00.000
0
2,400,643
"the garbage collector should free the memory" Correct. Since it doesn't, something else is wrong. Generally, the problem with infinite memory growth is global variables. Remove all global variables. Make all module-level code into smaller functions.
0
70,067
false
0
1
Is there a memory efficient and fast way to load big JSON files?
2,406,386
1
3
0
0
2
0
0
0
I have mod_python installed on my server, but if I want to acceses a python script - let's say httü://site.com/something.py the script doesn't run, the download box "pops up" Any solutions?
0
python,apache,unix
2010-03-08T13:34:00.000
0
2,401,602
This should be on ServerFault. By the way, mod_python is deprecated, use WSGI instead.
0
280
false
0
1
How to run python scripts on your server?
2,401,607
2
3
0
0
4
0
0
0
I'd like to know what would you propose as the best way to unit test aspect-oriented application features (well, perhaps that's not the best name, but it's the best I was able to come up with :-) ) such as logging or security? These things are sort of omni-present in the application, so how to test them properly? E.g. say that I'm writing a Cherrypy web server in Python. I can use a decorator to check whether the logged-in user has the permission to access a given page. But then I'd need to write a test for every page to see whether it works oK (or more like to see that I had not forgotten to check security perms for that page). This could maybe (emphasis on maybe) be bearable if logging and/or security were implemented during the web server "normal business implementation". However, security and logging usually tend to be added to the app as an afterthough (or maybe that's just my experience, I'm usually given a server and then asked to implement security model :-) ). Any thoughts on this are very welcome. I have currently 'solved' this issue by, well - not testing this at all. Thanks.
0
python,unit-testing,aop
2010-03-08T14:03:00.000
0
2,401,789
Well... let's see. In my opinion you are testing three different things here (sorry for the "Java AOP jargon"): the features implemented by the interceptors (i.e. the methods that implement the functions activated at the cutpoints) the coverage of the filters (i.e. whether the intended cutpoints are activated correctly or not) the interaction between the cutpoints and the interceptors (with the side effects) You are unit testing (strictly speaking) if you can handle these three layers separatedly. You can actually unit test the first; you can use a coverage tool and some skeleton crew application with mock objects to test the second; but the third is not exactly unit testing, so you may have to setup a test environment, design an end-to-end test and write some scripts to input data in your application and gather the results (if it was a web app you could use Selenium, for example).
0
258
false
1
1
Unit testing aspect-oriented features
2,402,152
2
3
0
1
4
0
0.066568
0
I'd like to know what would you propose as the best way to unit test aspect-oriented application features (well, perhaps that's not the best name, but it's the best I was able to come up with :-) ) such as logging or security? These things are sort of omni-present in the application, so how to test them properly? E.g. say that I'm writing a Cherrypy web server in Python. I can use a decorator to check whether the logged-in user has the permission to access a given page. But then I'd need to write a test for every page to see whether it works oK (or more like to see that I had not forgotten to check security perms for that page). This could maybe (emphasis on maybe) be bearable if logging and/or security were implemented during the web server "normal business implementation". However, security and logging usually tend to be added to the app as an afterthough (or maybe that's just my experience, I'm usually given a server and then asked to implement security model :-) ). Any thoughts on this are very welcome. I have currently 'solved' this issue by, well - not testing this at all. Thanks.
0
python,unit-testing,aop
2010-03-08T14:03:00.000
0
2,401,789
IMHO, the way of testing users permissions to the pages depends on the design of your app and design of the framework you're using. Generally, it's probably enough to cover your permission checker decorator with unit tests to make sure it always works as expected and then write a test that cycles through your 'views' (or whatever term cherrypy uses, haven't used it for a very long time) and just check if these functions are decorated with appropriate decorator. As for logging it's not quite clear what you want test specifically. Anyway, why isn't it possible to stub the logging functionality and check what's going on there?
0
258
false
1
1
Unit testing aspect-oriented features
2,796,926
4
4
0
0
4
0
0
0
My friend and I are planning on building a sort of a forum type of webapp. We've used the major PHP frameworks but we're really thinking about using Python specifically the Pylons framework for our app. Although we're competent PHP programmers, we're somewhat noobs at Python (We could create practical scripts and such). But the thing is we really want to learn Python but by testing Pylons out it seems to be really difficult with all the numerous imports and all. What would you suggest? What advice could you give to us? How would you suggest that we learn Pylons?
0
php,python,pylons
2010-03-09T14:42:00.000
0
2,409,812
Many many times have we had this discussion at my job. We use PHP and everyone here would love to switch to python. Even for our new web projects PHP delivers, and since we use it every day that is what we use. Many things in PHP irk me, and I love python, that said Im a big fan of "use the best tool for the job". Good code is possible in PHP (and horrible horrible code too), so use what is the best tool for you, and for this job. If however this webapp is a hobby and/or not mission-critical software I would fully recommend python if only to learn a new language.
0
675
false
0
1
Should we use Pylons or PHP for our webapp?
6,481,796
4
4
0
5
4
0
0.244919
0
My friend and I are planning on building a sort of a forum type of webapp. We've used the major PHP frameworks but we're really thinking about using Python specifically the Pylons framework for our app. Although we're competent PHP programmers, we're somewhat noobs at Python (We could create practical scripts and such). But the thing is we really want to learn Python but by testing Pylons out it seems to be really difficult with all the numerous imports and all. What would you suggest? What advice could you give to us? How would you suggest that we learn Pylons?
0
php,python,pylons
2010-03-09T14:42:00.000
0
2,409,812
Don't be scared off by imports in python. They're much more common when coding in python than PHP in general, and this is good because your namespace never gets polluted with stuff you aren't expecting, unless you do from foo import * (so don't do that). I think you'll find that the structure pylons gives you will be invaluable. There are frameworks in PHP as well, but if you want to learn python anyway, I see no reason you shouldn't dive in with Pylons.
0
675
false
0
1
Should we use Pylons or PHP for our webapp?
2,409,917
4
4
0
9
4
0
1
0
My friend and I are planning on building a sort of a forum type of webapp. We've used the major PHP frameworks but we're really thinking about using Python specifically the Pylons framework for our app. Although we're competent PHP programmers, we're somewhat noobs at Python (We could create practical scripts and such). But the thing is we really want to learn Python but by testing Pylons out it seems to be really difficult with all the numerous imports and all. What would you suggest? What advice could you give to us? How would you suggest that we learn Pylons?
0
php,python,pylons
2010-03-09T14:42:00.000
0
2,409,812
Decide what you want to put your focus on, being productive or learning a new language: If you want to learn Pylons and Python, use Pylon and Python. If you want to deliver a stable forum software, use PHP, because that's what you're competent at. Note: I should add that this is not meant to imply that you cannot be productive with Python or Pylon in general. All I'm saying is, in your case, you will be more productive with PHP, because you know it.
0
675
false
0
1
Should we use Pylons or PHP for our webapp?
2,409,852
4
4
0
4
4
0
0.197375
0
My friend and I are planning on building a sort of a forum type of webapp. We've used the major PHP frameworks but we're really thinking about using Python specifically the Pylons framework for our app. Although we're competent PHP programmers, we're somewhat noobs at Python (We could create practical scripts and such). But the thing is we really want to learn Python but by testing Pylons out it seems to be really difficult with all the numerous imports and all. What would you suggest? What advice could you give to us? How would you suggest that we learn Pylons?
0
php,python,pylons
2010-03-09T14:42:00.000
0
2,409,812
I don't know about Pylons but I've been in a similar situation and built a site using Django. I learned enough about Python in an environment that I was familiar with (web apps) that I now go to Python as my first choice.
0
675
false
0
1
Should we use Pylons or PHP for our webapp?
2,409,860
2
4
0
1
2
0
0.049958
0
What will be the fastest way to check whether a folder size is beyond a specific size say 10 MB, 1 Gb , 10 GB etc, without actually calculating the folder size. Something like quota. A Pythonic solution will be great, but standard UNIX utilities also welcome
0
python,linux,shell
2010-03-10T06:21:00.000
1
2,414,917
Folder size is still the total size of the folder contents. You may try to call du -s foldername from python
0
1,806
false
0
1
What is the fastest way to check whether a folder size is greater than a specific size?
2,414,931
2
4
0
2
2
0
0.099668
0
What will be the fastest way to check whether a folder size is beyond a specific size say 10 MB, 1 Gb , 10 GB etc, without actually calculating the folder size. Something like quota. A Pythonic solution will be great, but standard UNIX utilities also welcome
0
python,linux,shell
2010-03-10T06:21:00.000
1
2,414,917
I'd have to say it's impossible. I don't believe any filesystems cache folder sizes. Whatever you do is going to have to walk the tree in some fashion or another. Using du is probably the fastest method since it's all going to be happening in C. If you know the maximum filesize expected or supported you could perhaps optimise a little by counting the enties in each folder rather than the sizes and short-cutting in the case where there aren't enough files to meet the limit.
0
1,806
false
0
1
What is the fastest way to check whether a folder size is greater than a specific size?
2,414,949
5
6
0
4
5
0
0.132549
0
I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred? Thank you Bala Update I am still confused. Please help. Better in my sense means: 1. Bug will be fixed periodically. 2. Chosen by most developers. 3. Additional features like authentication tokens like AWS, can be supported out of the box. 4. No strong dependency on version.( I see that wsgi requires python 2.6) 5. All python libraries will work out of the box. 6. Scalable in the future. 7. Future upgrade don't cause any issues. With my limited experience, I want these features. There might be some I might be missing. Thanks Bala Update I am sorry for all the confusion caused. I just want to expose a restful web services in python language. Is there a good framework?
0
python,rest,web-services,apache2
2010-03-10T22:10:00.000
0
2,421,007
If you just want to run web apps then use mod_wsgi. If you need to write a handler for the rest of httpd's request/response phases then use mod_python.
0
5,895
false
0
1
Apache2: mod_wsgi or mod_python, which one is better?
2,421,023
5
6
0
0
5
0
0
0
I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred? Thank you Bala Update I am still confused. Please help. Better in my sense means: 1. Bug will be fixed periodically. 2. Chosen by most developers. 3. Additional features like authentication tokens like AWS, can be supported out of the box. 4. No strong dependency on version.( I see that wsgi requires python 2.6) 5. All python libraries will work out of the box. 6. Scalable in the future. 7. Future upgrade don't cause any issues. With my limited experience, I want these features. There might be some I might be missing. Thanks Bala Update I am sorry for all the confusion caused. I just want to expose a restful web services in python language. Is there a good framework?
0
python,rest,web-services,apache2
2010-03-10T22:10:00.000
0
2,421,007
Bug will be fixed periodically. Unless you're paying money, you cannot have any idea about this. Chosen by most developers. mod_wsgi Additional features like authentication tokens like AWS, can be supported out of the box. True for every framework. No strong dependency on version.( I see that wsgi requires python 2.6) What? Everything depends on compatible versions. Everything. Every single piece of software. All python libraries will work out of the box. "All?" What about the poorly-written ones? Scalable in the future. Sure. We always hope for this. There's no guarantee. Future upgrade don't cause any issues. That's funny. "I want these features." We all do. Realistically, you can get #2. The rest don't make sense or cannot every be assured.
0
5,895
false
0
1
Apache2: mod_wsgi or mod_python, which one is better?
2,422,260
5
6
0
1
5
0
0.033321
0
I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred? Thank you Bala Update I am still confused. Please help. Better in my sense means: 1. Bug will be fixed periodically. 2. Chosen by most developers. 3. Additional features like authentication tokens like AWS, can be supported out of the box. 4. No strong dependency on version.( I see that wsgi requires python 2.6) 5. All python libraries will work out of the box. 6. Scalable in the future. 7. Future upgrade don't cause any issues. With my limited experience, I want these features. There might be some I might be missing. Thanks Bala Update I am sorry for all the confusion caused. I just want to expose a restful web services in python language. Is there a good framework?
0
python,rest,web-services,apache2
2010-03-10T22:10:00.000
0
2,421,007
mod_wsgi is much more actively maintained than mod_python at this point. It also has a good bit of momentum, as it was somewhat recently adopted as the preferred deployment method on apache2 by Django. The author is also actively engaged with the Python community in regards to the future evolution of WSGI.
0
5,895
false
0
1
Apache2: mod_wsgi or mod_python, which one is better?
2,422,564
5
6
0
5
5
0
0.16514
0
I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred? Thank you Bala Update I am still confused. Please help. Better in my sense means: 1. Bug will be fixed periodically. 2. Chosen by most developers. 3. Additional features like authentication tokens like AWS, can be supported out of the box. 4. No strong dependency on version.( I see that wsgi requires python 2.6) 5. All python libraries will work out of the box. 6. Scalable in the future. 7. Future upgrade don't cause any issues. With my limited experience, I want these features. There might be some I might be missing. Thanks Bala Update I am sorry for all the confusion caused. I just want to expose a restful web services in python language. Is there a good framework?
0
python,rest,web-services,apache2
2010-03-10T22:10:00.000
0
2,421,007
Don't confuse what WSGI and mod_wsgi are. WSGI is an interface specification for hosting Python web applications on a server. The mod_wsgi module is an implementation of the WSGI specification using Apache as the underlying web server. Thus, Python and WSGI are not choices exactly, WSGI is just one way of being able to communicate between a Python web service/application and the web server. The mod_wsgi package is one implementation of that interface. So, WSGI is a means to an end, not a solution in itself. Personally, I'd very much suggest you just use a minimal Python framework/non framework and as Alex suggests, Werkzeug is a good choice.
0
5,895
false
0
1
Apache2: mod_wsgi or mod_python, which one is better?
2,421,104
5
6
0
3
5
0
0.099668
0
I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred? Thank you Bala Update I am still confused. Please help. Better in my sense means: 1. Bug will be fixed periodically. 2. Chosen by most developers. 3. Additional features like authentication tokens like AWS, can be supported out of the box. 4. No strong dependency on version.( I see that wsgi requires python 2.6) 5. All python libraries will work out of the box. 6. Scalable in the future. 7. Future upgrade don't cause any issues. With my limited experience, I want these features. There might be some I might be missing. Thanks Bala Update I am sorry for all the confusion caused. I just want to expose a restful web services in python language. Is there a good framework?
0
python,rest,web-services,apache2
2010-03-10T22:10:00.000
0
2,421,007
mod_wsgi is specifically tuned to run Python web apps that use WSGI in Apache. mod_python is for any kind of Python web app, including WSGI apps. mod_wsgi also has a lower memory footprint than mod_python.
0
5,895
false
0
1
Apache2: mod_wsgi or mod_python, which one is better?
2,421,190
2
2
0
179
125
0
1.2
0
Is there a Bash equivalent to the Python's pass statement?
0
python,bash,language-comparisons
2010-03-10T23:54:00.000
1
2,421,586
You can use : for this.
0
36,506
true
0
1
What is the Bash equivalent of Python's pass statement
2,421,592
2
2
0
45
125
0
1
0
Is there a Bash equivalent to the Python's pass statement?
0
python,bash,language-comparisons
2010-03-10T23:54:00.000
1
2,421,586
true is a command that successfully does nothing. (false would, in a way, be the opposite: it doesn't do anything, but claims that a failure occurred.)
0
36,506
false
0
1
What is the Bash equivalent of Python's pass statement
2,421,637
1
1
0
2
2
1
0.379949
0
Are there any downsides to UPX-ing my 32-bit Python 2.6.4 development environment EXE/PYD/DLL files? The reason I'm asking is that I frequently use a custom PY2EXE script that UPX's copies of these files on every build. Yes, I could get fancy and try to cache UPXed files, but I think a simpler, safer, and higher performance solution would be for me to just UPX my Python 2.6.4 directory once and be done with it. Thoughts? Malcolm
0
python,py2exe,upx
2010-03-12T07:56:00.000
1
2,431,236
I have experienced significant increases in start up time when UPX compressed executables are run on systems with certain virus scanners. I was only compressing single executables, but I expect that each compressed dll would add to the start time. Is it really necessary to use UPX? I can't imagine the space savings to be significant enough to be worth the trouble.
0
637
false
0
1
Any downsides to UPX-ing my 32-bit Python 2.6.4 development environment EXE/PYD/DLL files?
2,433,251
2
2
0
5
1
0
1.2
0
I'm doing some prototyping with OpenCV for a hobby project involving processing of real time camera data. I wonder if it is worth the effort to reimplement this in C or C++ when I have it all figured out or if no significant performance boost can be expected. The program basically chains OpenCV functions, so the main part of the work should be done in native code anyway.
0
c++,python,c,performance,opencv
2010-03-12T12:54:00.000
0
2,432,792
You've answered your own question pretty well. Most of the expensive computations should be within the OpenCV library, and thus independent of the language you use. If you're really concerned about efficiency, you could profile your code and confirm that this is indeed the case. If need be, your custom processing functions, if any, could be coded in C/C++ and exposed in python through the method of your choice (eg: boost-python), to follow the same approach. But in my experience, python works just fine as a "composition" tool for such a use.
1
1,352
true
0
1
OpenCV performance in different languages
2,433,626
2
2
0
0
1
0
0
0
I'm doing some prototyping with OpenCV for a hobby project involving processing of real time camera data. I wonder if it is worth the effort to reimplement this in C or C++ when I have it all figured out or if no significant performance boost can be expected. The program basically chains OpenCV functions, so the main part of the work should be done in native code anyway.
0
c++,python,c,performance,opencv
2010-03-12T12:54:00.000
0
2,432,792
OpenCV used to utilize IPP, which is very fast. However, OpenCV 2.0 does not. You might customize your OpenCV using IPP, for example color conversion routines.
1
1,352
false
0
1
OpenCV performance in different languages
2,470,491
2
2
0
1
2
0
0.099668
0
ruby -n is the closest thing I found, but it repeats the whole script. Also it's not available for irb.
0
python,ruby
2010-03-13T07:06:00.000
0
2,437,582
$ cat > hello.rb $hello = 'Hello, world!' puts $hello ^D $ irb irb(main):001:0> load 'hello.rb' Hello, world! => true irb(main):002:0> $hello => "Hello, world!" A bit tedious, and local variables won't carry through. May be close enough for your usage? (This is basically like Python's execfile.)
0
267
false
0
1
Is there a ruby equivalent of "python -i"?
2,437,648
2
2
0
1
2
0
1.2
0
ruby -n is the closest thing I found, but it repeats the whole script. Also it's not available for irb.
0
python,ruby
2010-03-13T07:06:00.000
0
2,437,582
irb -r hello.rb
0
267
true
0
1
Is there a ruby equivalent of "python -i"?
2,880,523
1
12
0
8
28
0
1
0
How do I retrieve the temperature of my CPU using Python? (Assuming I'm on Linux)
0
python,cpu,temperature
2010-03-13T23:35:00.000
1
2,440,511
If your Linux supports ACPI, reading pseudo-file /proc/acpi/thermal_zone/THM0/temperature (the path may differ, I know it's /proc/acpi/thermal_zone/THRM/temperature in some systems) should do it. But I don't think there's a way that works in every Linux system in the world, so you'll have to be more specific about exactly what Linux you have!-)
0
57,891
false
0
1
Getting CPU temperature using Python?
2,440,544
2
5
0
2
8
1
0.07983
0
I'm looking for a way to ship the Python interpreter with my application (also written in Python), so that it doesn't need to have Python installed on the machine. I searched Google and found a bunch of results about how to embed the Python interpreter in applications written in various languages, but nothing for applications written in Python itself... I don't need to "hide" my code or make a binary like cx_freeze does, I just don't want my users to have to install Python to use my app, that's all.
0
python,interpreter,embedding
2010-03-14T04:24:00.000
0
2,441,172
Making a frozen binary using a utility like cx_freeze or py2exe is probably the easiest way to do this. That way you only need to distribute the executable. I know that you might prefer not to distribute a binary, but if that is a concern you could always give users the option to download the source and run from an interpreter.
0
3,296
false
0
1
Embed Python interpreter in a Python application
2,441,185
2
5
0
2
8
1
0.07983
0
I'm looking for a way to ship the Python interpreter with my application (also written in Python), so that it doesn't need to have Python installed on the machine. I searched Google and found a bunch of results about how to embed the Python interpreter in applications written in various languages, but nothing for applications written in Python itself... I don't need to "hide" my code or make a binary like cx_freeze does, I just don't want my users to have to install Python to use my app, that's all.
0
python,interpreter,embedding
2010-03-14T04:24:00.000
0
2,441,172
You need some sort of executable in order to start Python. May as well be the one your app has been frozen into. The alternative is to copy the executable, library, and pieces of the stdlib that you need into a private directory and invoke that against your app.
0
3,296
false
0
1
Embed Python interpreter in a Python application
2,441,182
2
5
0
0
7
1
0
0
Our server cluster consists of 20 machines, each with 10 pids of 5 threads. We'd like some way to prevent any two threads, in any pid, on any machine, from modifying the same object at the same time. Our code's written in Python and runs on Linux, if that helps narrow things down. Also, it's a pretty rare case that two such threads want to do this, so we'd prefer something that optimizes the "only one thread needs this object" case to be really fast, even if it means that the "one thread has locked this object and another one needs it" case isn't great. What are some of the best practices?
0
python,linux,multithreading,mutex
2010-03-15T17:08:00.000
1
2,448,984
Write code using immutable objects. Write objects that implement the Singleton Pattern. Use a stable Distributed messaging technology such as IPC, webservices, or XML-RPC. I would take a look at Twisted. They got plenty of solutions for such task. I wouldn't use threads in Python esp with regards to the GIL, I would look at using Processes as working applications and use a comms technology as described above for intercommunications. Your singleton class could then appear in one of these applications and interfaced via comms technology of choice. Not a fast solution with all the interfacing, but if done correctly should be stable.
0
2,492
false
0
1
What are some good ways to do intermachine locking?
2,449,391
2
5
0
1
7
1
0.039979
0
Our server cluster consists of 20 machines, each with 10 pids of 5 threads. We'd like some way to prevent any two threads, in any pid, on any machine, from modifying the same object at the same time. Our code's written in Python and runs on Linux, if that helps narrow things down. Also, it's a pretty rare case that two such threads want to do this, so we'd prefer something that optimizes the "only one thread needs this object" case to be really fast, even if it means that the "one thread has locked this object and another one needs it" case isn't great. What are some of the best practices?
0
python,linux,multithreading,mutex
2010-03-15T17:08:00.000
1
2,448,984
if you can get the complete infrastructure for a distributed lock manager then go ahead and use that. But that infrastructure is not easy to setup! But here is a practical solution: -designate the node with the lowest ip address as the the master node (that means if the node with lowest ip address hangs, a new node with lowest ip address will become new master) -let all nodes contact the master node to get the lock on the object. -let the master node use native lock semantics to get the lock. this will simplify things unless you need complete clustering infrastructure and DLM to do the job.
0
2,492
false
0
1
What are some good ways to do intermachine locking?
2,466,954
1
2
0
5
0
1
0.462117
0
I have a module "B", I want to run it from a script "C", and I want to call global variables in "B", as they were in the "C" root. Another problem is if I imported sys in "B" when I run "C" it doesn't see sys # NameError: global name 'sys' is not defined # What shall I do?
0
python,import,global-variables,module
2010-03-16T13:19:00.000
0
2,454,576
When you import a module B (like import B), every line in B will be interpreted. I assume this is what you mean when you say you want to run it. To reference members in B's namespace, you can get them like: B.something_defined_in_B. If you wish to use sys explicitly in C, you will need to import it within C as well.
0
4,158
false
0
1
How do you run python scripts from other script and have their root in my root?
2,454,624
1
1
0
19
11
1
1.2
0
I'd like to run a spell checker on the docstrings of my Python code, if possible from within emacs. I've found the ispell-check-comments setting which can be used to spell check only comments in code, but I was not able to target only the docstrings which are a fairly python-specific thing.
0
python,emacs,spell-checking,docstring
2010-03-16T14:20:00.000
0
2,455,062
I recommend you to try flyspell-mode. You could use something like: (add-hook 'python-mode-hook 'flyspell-prog-mode) in your Emacs configuration.
0
1,226
true
0
1
How to spell check python docstring with emacs?
2,455,436
1
2
0
1
2
1
1.2
0
I'm looking for a way to create a tree of test files to unit test a packaging tool. Basically, I want to create some common file system structures -- directories, nested directories, symlinks within the selected tree, symlinks outside the tree, &c. Ideally I want to do this with as little boilerplate as possible. Of course, I could hand-write the set of files I want to see, but I'm thinking that somebody has to have automated this for a test suite somewhere. Any suggestions?
0
python,unit-testing,automation
2010-03-16T16:35:00.000
0
2,456,226
I do this type of thing for testing Unix user creation and home directory copies. The Zip suggestion is a good one. I personally keep two directory structures -- one is a source and one becomes the test structure. I just sync the source to the destination via shutil.copytree as part of the test setup. That makes it easy to change the test structure on the fly (and not have to unzip).
0
149
true
0
1
Using Python, what's the best way to create a set of files on disk for testing?
2,456,703
1
1
0
0
0
1
0
0
I am currently working with converting Pycrypto over to Python 3.X Whilst I seem to have the cryptography side working the same cannot be said for the tests provided with the module :( I have used the tests under Python 2.64 and all works fine. I then ran '2to3' over the tests to generate new files in 3.X format. There are several references to the following: from .common import make_block_tests Whenever I run the tests I get: ValueError: Attempted relative import in non-package If someone would point me towards a way to fix this it would be much appreciated :) Cheers Grail
0
python-3.x,relative-path
2010-03-17T02:54:00.000
0
2,459,636
You are trying to run the test files directly, then you can't have relative imports. Change them to be absolute imports, and it will solve the problem.
0
215
false
0
1
Python 3 relative path conversion issue
5,054,020
1
1
0
2
1
0
0.379949
0
I have a python CGI which runs some script in the background and shows the stdout in the html page. I run the script when the user clicks some button in the page. My problem is when the script starts running the page becomes busy and the user can't use the other client side features in the page. What I want is: The script should run in background when the user clicks the button and should notify the CGI when run is complete. Then the CGI show should the stdout of the script run. How can this be done?
0
python,cgi,backgroundworker
2010-03-17T11:59:00.000
0
2,461,964
well, short answer: you can't. medium answer: CGI sucks. long answer: CGI works by running your script and returning whatever your script prints to the browser. If your script is still running, the browser will be waiting. If your script launches a background job and returns data to the browser, then the background job can't notify the CGI script because it is already done. You must choose an alternate solution. Save the results of the background job to a file, database, or some other persistent storage, and make the user request that data, using another link in your page, which runs a different code that retrieves the saved results and display them. Another way is to use AJAX techniques in the browser. Write javascript code to do the request to the data in the background. So the browser can still be responsive with other page elements while the script is running.
0
1,221
false
1
1
Running a python script in background from a CGI
2,462,349
2
2
0
0
1
0
1.2
0
One of our page templates is made up of a bunch of macros. These items are a bunch of html tables. Now, I want a couple of these tables in a Python script to create a PDF. Is there a way call a macro from a Python script and get back the HTML that is produced? If so, can you explain? Thanks Eric
0
python,zope
2010-03-17T17:32:00.000
0
2,464,442
Maybe you could create a new template including (use-macro) just the macros you want to access from python and then use z3c.pt.pagetemplate.PageTemplateFile() to render it? Actually, it might be possible (and certainly easier) to use chameleon.zpt.template.PageTemplate('<div tal:use-macro="<your-macro-here>" />'), but I've never did this myself.
0
334
true
1
1
Call macro from Python script?
2,466,236
2
2
0
0
1
0
0
0
One of our page templates is made up of a bunch of macros. These items are a bunch of html tables. Now, I want a couple of these tables in a Python script to create a PDF. Is there a way call a macro from a Python script and get back the HTML that is produced? If so, can you explain? Thanks Eric
0
python,zope
2010-03-17T17:32:00.000
0
2,464,442
I'd probably use urllib.urlopen(url), pull the data from the page back to python and use BeautifulSoup to pull the table(s) out of the HTML... And then render that to PDF with XHTML2PDF (pisa.ho). There might be a simpler way but for me, this would be the least stressful approach.
0
334
false
1
1
Call macro from Python script?
2,464,507
1
3
0
0
2
0
0
0
Can C/C++ be choice of keeping all your logic (business/domain) for web application? Why? I've two resources (cousins) having knowledge on C/C++ and me also good in C/C++, Python, HTML, CSS and JavaScript. We like to utilize our free time to work on our some good ideas we developed together. The ideas require knowledge of web application development. And I'm the only one who has it. Is there a way they developed the core in C/C++ and I do the rest of scripting for front-end development? Thanks.
0
c++,python,c
2010-03-18T06:03:00.000
0
2,467,807
I don't think you should use a compiled language (at least not c++) for web programming. I thought about doing this once too but remember that for any change you'll have to compile etc. Facebook uses php and it's hip hop application changes php into c++. Maybe you should take a look at that. Of course c++ (or any compiled language) will be faster than an interpreted language, but you also have to take in account the development time of the web site/app. Hope this helps :)
0
390
false
1
1
C/C++ for Core Logic Development of a Web Application?
2,468,907
1
3
0
0
5
0
0
0
I began learning and loving python about a month ago. Dive into python, django and now Tornado is the path i followed during this time. I chose pydev as an IDE since it seems to be the most up to date and i wanted to come back to eclipse since i'm using Netbeans for php and Java. My question is the following: When i write classes in php or java i declare my methods and properties. I instantiate them somewhere else and use them. The autocompletion works great for java and php but with python, it seems to be always suggesting me a bunch of garbage and never the real object's methods from the class i instantiated. Is it the same for you ? Is it a limitation from pydev ? Am i doing something wrong ? Thank you in advance for pointing me in a direction. Matthieu.
0
python,pydev
2010-03-18T13:31:00.000
0
2,470,121
Well, as you didn't say what 'garbage' is showing, it's a bit hard to guess, but I believe you mean the __hash__, __str__, etc from the object class (is that it?) If that's the case, this has been dealt in the current nightly build (the '_' methods will still appear, but with lower priority, so, the methods you're probably more interested in are at the top)
0
1,825
false
1
1
Bad auto completion with python on pydev?
5,761,144
1
1
0
1
1
1
1.2
0
I am reading cpython code for python 3k and I have noticed, that __missing__ is called only when dict_subscript is called, but not when PyDict_GetItem is used. What is the difference between those two methods and when each is called? If I pass an PyObject that is a subclass of dict and has __missing__ method, how can I force using it, since PyDict_GetItem doesn't do that.
0
python,dictionary,cpython
2010-03-18T15:17:00.000
0
2,470,928
Observations, guesses, etc: Same happens in Python 2.x. dict_subscript implements the equivalent of the high_level dict.__getitem__ method and thus will be called whenever adict[somekey] appears other than on the LHS of an assignment in Python code. PyDict_GetItem is part of the C API. Perhaps it's an oversight that it hasn't been updated. Having read the dire comments at the start of PyDict_GetItem, I'd be using PyDict_GetItemWithError instead ;-) Perhaps you can do the C-level equivalent of my_getitem = getattr(my_dict, '__getitem__') once then call that. Perhaps you could raise a bug ticket or ask on comp.lang.python
0
698
true
0
1
cpython: when PyDict_GetItem is called and when dict_subscript?
2,473,724
3
7
0
2
29
0
0.057081
1
I have a python server that listens on a couple sockets. At startup, I try to connect to these sockets before listening, so I can be sure that nothing else is already using that port. This adds about three seconds to my server's startup (which is about .54 seconds without the test) and I'd like to trim it down. Since I'm only testing localhost, I think a timeout of about 50 milliseconds is more than ample for that. Unfortunately, the socket.setdefaulttimeout(50) method doesn't seem to work for some reason. How I can trim this down?
0
python,sockets
2010-03-18T15:21:00.000
0
2,470,971
Are you on Linux? If so, perhaps your application could run netstat -lant (or netstat -lanu if you're using UDP) and see what ports are in use. This should be faster...
0
46,722
false
0
1
Fast way to test if a port is in use using Python
2,471,078
3
7
0
2
29
0
0.057081
1
I have a python server that listens on a couple sockets. At startup, I try to connect to these sockets before listening, so I can be sure that nothing else is already using that port. This adds about three seconds to my server's startup (which is about .54 seconds without the test) and I'd like to trim it down. Since I'm only testing localhost, I think a timeout of about 50 milliseconds is more than ample for that. Unfortunately, the socket.setdefaulttimeout(50) method doesn't seem to work for some reason. How I can trim this down?
0
python,sockets
2010-03-18T15:21:00.000
0
2,470,971
Simon B's answer is the way to go - don't check anything, just try to bind and handle the error case if it's already in use. Otherwise you're in a race condition where some other app can grab the port in between your check that it's free and your subsequent attempt to bind to it. That means you still have to handle the possibility that your call to bind will fail, so checking in advance achieved nothing.
0
46,722
false
0
1
Fast way to test if a port is in use using Python
2,471,762
3
7
0
14
29
0
1.2
1
I have a python server that listens on a couple sockets. At startup, I try to connect to these sockets before listening, so I can be sure that nothing else is already using that port. This adds about three seconds to my server's startup (which is about .54 seconds without the test) and I'd like to trim it down. Since I'm only testing localhost, I think a timeout of about 50 milliseconds is more than ample for that. Unfortunately, the socket.setdefaulttimeout(50) method doesn't seem to work for some reason. How I can trim this down?
0
python,sockets
2010-03-18T15:21:00.000
0
2,470,971
How about just trying to bind to the port you want, and handle the error case if the port is occupied? (If the issue is that you might start the same service twice then don't look at open ports.) This is the reasonable way also to avoid causing a race-condition, as @eemz said in another answer.
0
46,722
true
0
1
Fast way to test if a port is in use using Python
2,471,039
1
4
0
0
5
1
0
0
I have a folder full of files and I want to search some string inside them. The issue is that some files may be zip, exe, ogg, etc. Can I check somehow what kind of file is it so I only open and search through txt, PHP, etc. files. I can't rely on the file extension.
0
python
2010-03-18T17:56:00.000
0
2,472,221
If you're on linux you can parse the output of the file command-line tool.
0
7,602
false
0
1
How to check if a file contains plain text?
2,472,233